1 /* SPDX-License-Identifier: GPL-2.0+ */ 2 /* 3 * Copyright (c) 2017 Google, Inc 4 * 5 * (C) Copyright 2012 6 * Pavel Herrmann <morpheus.ibis@gmail.com> 7 * Marek Vasut <marex@denx.de> 8 */ 9 10 #ifndef _DM_FDTADDR_H 11 #define _DM_FDTADDR_H 12 13 #include <fdtdec.h> 14 15 struct udevice; 16 17 /** 18 * devfdt_get_addr() - Get the reg property of a device 19 * 20 * @dev: Pointer to a device 21 * 22 * Return: addr 23 */ 24 fdt_addr_t devfdt_get_addr(const struct udevice *dev); 25 26 /** 27 * devfdt_get_addr_ptr() - Return pointer to the address of the reg property 28 * of a device 29 * 30 * @dev: Pointer to a device 31 * 32 * Return: Pointer to addr, or NULL if there is no such property 33 */ 34 void *devfdt_get_addr_ptr(const struct udevice *dev); 35 36 /** 37 * devfdt_remap_addr() - Return pointer to the memory-mapped I/O address 38 * of the reg property of a device 39 * 40 * @dev: Pointer to a device 41 * 42 * Return: Pointer to addr, or NULL if there is no such property 43 */ 44 void *devfdt_remap_addr(const struct udevice *dev); 45 46 /** 47 * devfdt_remap_addr_index() - Return indexed pointer to the memory-mapped 48 * I/O address of the reg property of a device 49 * @index: the 'reg' property can hold a list of <addr, size> pairs 50 * and @index is used to select which one is required 51 * 52 * @dev: Pointer to a device 53 * 54 * Return: Pointer to addr, or NULL if there is no such property 55 */ 56 void *devfdt_remap_addr_index(const struct udevice *dev, int index); 57 58 /** 59 * devfdt_remap_addr_name() - Get the reg property of a device, indexed by 60 * name, as a memory-mapped I/O pointer 61 * @name: the 'reg' property can hold a list of <addr, size> pairs, with the 62 * 'reg-names' property providing named-based identification. @index 63 * indicates the value to search for in 'reg-names'. 64 * 65 * @dev: Pointer to a device 66 * 67 * Return: Pointer to addr, or NULL if there is no such property 68 */ 69 void *devfdt_remap_addr_name(const struct udevice *dev, const char *name); 70 71 /** 72 * devfdt_map_physmem() - Read device address from reg property of the 73 * device node and map the address into CPU address 74 * space. 75 * 76 * @dev: Pointer to device 77 * @size: size of the memory to map 78 * 79 * Return: mapped address, or NULL if the device does not have reg property. 80 */ 81 void *devfdt_map_physmem(const struct udevice *dev, unsigned long size); 82 83 /** 84 * devfdt_get_addr_index() - Get the indexed reg property of a device 85 * 86 * @dev: Pointer to a device 87 * @index: the 'reg' property can hold a list of <addr, size> pairs 88 * and @index is used to select which one is required 89 * 90 * Return: addr 91 */ 92 fdt_addr_t devfdt_get_addr_index(const struct udevice *dev, int index); 93 94 /** 95 * devfdt_get_addr_index_ptr() - Return indexed pointer to the address of the 96 * reg property of a device 97 * 98 * @dev: Pointer to a device 99 * @index: the 'reg' property can hold a list of <addr, size> pairs 100 * and @index is used to select which one is required 101 * 102 * Return: Pointer to addr, or NULL if there is no such property 103 */ 104 void *devfdt_get_addr_index_ptr(const struct udevice *dev, int index); 105 106 /** 107 * devfdt_get_addr_size_index() - Get the indexed reg property of a device 108 * 109 * Returns the address and size specified in the 'reg' property of a device. 110 * 111 * @dev: Pointer to a device 112 * @index: the 'reg' property can hold a list of <addr, size> pairs 113 * and @index is used to select which one is required 114 * @size: Pointer to size variable - this function returns the size 115 * specified in the 'reg' property here 116 * 117 * Return: addr 118 */ 119 fdt_addr_t devfdt_get_addr_size_index(const struct udevice *dev, int index, 120 fdt_size_t *size); 121 122 /** 123 * devfdt_get_addr_size_index_ptr() - Return indexed pointer to the address of the 124 * reg property of a device 125 * 126 * @dev: Pointer to a device 127 * @index: the 'reg' property can hold a list of <addr, size> pairs 128 * and @index is used to select which one is required 129 * @size: Pointer to size variable - this function returns the size 130 * specified in the 'reg' property here 131 * 132 * Return: Pointer to addr, or NULL if there is no such property 133 */ 134 void *devfdt_get_addr_size_index_ptr(const struct udevice *dev, int index, 135 fdt_size_t *size); 136 137 /** 138 * devfdt_get_addr_name() - Get the reg property of a device, indexed by name 139 * 140 * @dev: Pointer to a device 141 * @name: the 'reg' property can hold a list of <addr, size> pairs, with the 142 * 'reg-names' property providing named-based identification. @index 143 * indicates the value to search for in 'reg-names'. 144 * 145 * Return: addr 146 */ 147 fdt_addr_t devfdt_get_addr_name(const struct udevice *dev, const char *name); 148 149 /** 150 * devfdt_get_addr_size_name() - Get the reg property and its size for a device, 151 * indexed by name 152 * 153 * Returns the address and size specified in the 'reg' property of a device. 154 * 155 * @dev: Pointer to a device 156 * @name: the 'reg' property can hold a list of <addr, size> pairs, with the 157 * 'reg-names' property providing named-based identification. @index 158 * indicates the value to search for in 'reg-names'. 159 * @size: Pointer to size variable - this function returns the size 160 * specified in the 'reg' property here 161 * 162 * Return: addr 163 */ 164 fdt_addr_t devfdt_get_addr_size_name(const struct udevice *dev, 165 const char *name, fdt_size_t *size); 166 167 /** 168 * devfdt_get_addr_pci() - Read an address and handle PCI address translation 169 * 170 * @dev: Device to read from 171 * Return: address or FDT_ADDR_T_NONE if not found 172 */ 173 fdt_addr_t devfdt_get_addr_pci(const struct udevice *dev); 174 175 #endif 176