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