xref: /OK3568_Linux_fs/u-boot/include/dm/fdtaddr.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1 /*
2  * Copyright (c) 2017 Google, Inc
3  *
4  * (C) Copyright 2012
5  * Pavel Herrmann <morpheus.ibis@gmail.com>
6  * Marek Vasut <marex@denx.de>
7  *
8  * SPDX-License-Identifier:	GPL-2.0+
9  */
10 
11 #ifndef _DM_FDTADDR_H
12 #define _DM_FDTADDR_H
13 
14 #include <fdtdec.h>
15 
16 struct udevice;
17 
18 /**
19  * devfdt_get_addr() - Get the reg property of a device
20  *
21  * @dev: Pointer to a device
22  *
23  * @return addr
24  */
25 fdt_addr_t devfdt_get_addr(struct udevice *dev);
26 
27 /**
28  * devfdt_get_addr_ptr() - Return pointer to the address of the reg property
29  *                      of a device
30  *
31  * @dev: Pointer to a device
32  *
33  * @return Pointer to addr, or NULL if there is no such property
34  */
35 void *devfdt_get_addr_ptr(struct udevice *dev);
36 
37 /**
38  * devfdt_remap_addr_index() - Return indexed pointer to the memory-mapped
39  *                                 I/O address of the reg property of a device
40  * @index: the 'reg' property can hold a list of <addr, size> pairs
41  *         and @index is used to select which one is required
42  *
43  * @dev: Pointer to a device
44  *
45  * Return: Pointer to addr, or NULL if there is no such property
46  */
47 void *devfdt_remap_addr_index(struct udevice *dev, int index);
48 
49 /**
50  * devfdt_map_physmem() - Read device address from reg property of the
51  *                     device node and map the address into CPU address
52  *                     space.
53  *
54  * @dev: Pointer to device
55  * @size: size of the memory to map
56  *
57  * @return  mapped address, or NULL if the device does not have reg
58  *          property.
59  */
60 void *devfdt_map_physmem(struct udevice *dev, unsigned long size);
61 
62 /**
63  * devfdt_get_addr_index() - Get the indexed reg property of a device
64  *
65  * @dev: Pointer to a device
66  * @index: the 'reg' property can hold a list of <addr, size> pairs
67  *	   and @index is used to select which one is required
68  *
69  * @return addr
70  */
71 fdt_addr_t devfdt_get_addr_index(struct udevice *dev, int index);
72 
73 /**
74  * devfdt_get_addr_size_index() - Get the indexed reg property of a device
75  *
76  * Returns the address and size specified in the 'reg' property of a device.
77  *
78  * @dev: Pointer to a device
79  * @index: the 'reg' property can hold a list of <addr, size> pairs
80  *	   and @index is used to select which one is required
81  * @size: Pointer to size varible - this function returns the size
82  *        specified in the 'reg' property here
83  *
84  * @return addr
85  */
86 fdt_addr_t devfdt_get_addr_size_index(struct udevice *dev, int index,
87 				   fdt_size_t *size);
88 
89 /**
90  * devfdt_get_addr_name() - Get the reg property of a device, indexed by name
91  *
92  * @dev: Pointer to a device
93  * @name: the 'reg' property can hold a list of <addr, size> pairs, with the
94  *	  'reg-names' property providing named-based identification. @index
95  *	  indicates the value to search for in 'reg-names'.
96  *
97  * @return addr
98  */
99 fdt_addr_t devfdt_get_addr_name(struct udevice *dev, const char *name);
100 
101 /**
102  * dm_set_translation_offset() - Set translation offset
103  * @offs: Translation offset
104  *
105  * Some platforms need a special address translation. Those
106  * platforms (e.g. mvebu in SPL) can configure a translation
107  * offset in the DM by calling this function. It will be
108  * added to all addresses returned in devfdt_get_addr().
109  */
110 void dm_set_translation_offset(fdt_addr_t offs);
111 
112 /**
113  * dm_get_translation_offset() - Get translation offset
114  *
115  * This function returns the translation offset that can
116  * be configured by calling dm_set_translation_offset().
117  *
118  * @return translation offset for the device address (0 as default).
119  */
120 fdt_addr_t dm_get_translation_offset(void);
121 
122 #endif
123