xref: /openbmc/u-boot/include/dm/fdtaddr.h (revision 203e94f6)
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_map_physmem() - Read device address from reg property of the
39  *                     device node and map the address into CPU address
40  *                     space.
41  *
42  * @dev: Pointer to device
43  * @size: size of the memory to map
44  *
45  * @return  mapped address, or NULL if the device does not have reg
46  *          property.
47  */
48 void *devfdt_map_physmem(struct udevice *dev, unsigned long size);
49 
50 /**
51  * devfdt_get_addr_index() - Get the indexed reg property of a device
52  *
53  * @dev: Pointer to a device
54  * @index: the 'reg' property can hold a list of <addr, size> pairs
55  *	   and @index is used to select which one is required
56  *
57  * @return addr
58  */
59 fdt_addr_t devfdt_get_addr_index(struct udevice *dev, int index);
60 
61 /**
62  * devfdt_get_addr_size_index() - Get the indexed reg property of a device
63  *
64  * Returns the address and size specified in the 'reg' property of a device.
65  *
66  * @dev: Pointer to a device
67  * @index: the 'reg' property can hold a list of <addr, size> pairs
68  *	   and @index is used to select which one is required
69  * @size: Pointer to size varible - this function returns the size
70  *        specified in the 'reg' property here
71  *
72  * @return addr
73  */
74 fdt_addr_t devfdt_get_addr_size_index(struct udevice *dev, int index,
75 				   fdt_size_t *size);
76 
77 /**
78  * devfdt_get_addr_name() - Get the reg property of a device, indexed by name
79  *
80  * @dev: Pointer to a device
81  * @name: the 'reg' property can hold a list of <addr, size> pairs, with the
82  *	  'reg-names' property providing named-based identification. @index
83  *	  indicates the value to search for in 'reg-names'.
84  *
85  * @return addr
86  */
87 fdt_addr_t devfdt_get_addr_name(struct udevice *dev, const char *name);
88 
89 /**
90  * dm_set_translation_offset() - Set translation offset
91  * @offs: Translation offset
92  *
93  * Some platforms need a special address translation. Those
94  * platforms (e.g. mvebu in SPL) can configure a translation
95  * offset in the DM by calling this function. It will be
96  * added to all addresses returned in devfdt_get_addr().
97  */
98 void dm_set_translation_offset(fdt_addr_t offs);
99 
100 /**
101  * dm_get_translation_offset() - Get translation offset
102  *
103  * This function returns the translation offset that can
104  * be configured by calling dm_set_translation_offset().
105  *
106  * @return translation offset for the device address (0 as default).
107  */
108 fdt_addr_t dm_get_translation_offset(void);
109 
110 #endif
111