Tom Rini | 83d290c | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0+ */ |
Simon Glass | d6ffb00 | 2017-05-17 17:18:04 -0600 | [diff] [blame] | 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> |
Simon Glass | d6ffb00 | 2017-05-17 17:18:04 -0600 | [diff] [blame] | 8 | */ |
| 9 | |
Simon Glass | 38d21b4 | 2017-05-18 20:08:59 -0600 | [diff] [blame] | 10 | #ifndef _DM_FDTADDR_H |
| 11 | #define _DM_FDTADDR_H |
Simon Glass | d6ffb00 | 2017-05-17 17:18:04 -0600 | [diff] [blame] | 12 | |
| 13 | #include <fdtdec.h> |
| 14 | |
| 15 | struct udevice; |
| 16 | |
| 17 | /** |
Simon Glass | a821c4a | 2017-05-17 17:18:05 -0600 | [diff] [blame] | 18 | * devfdt_get_addr() - Get the reg property of a device |
Simon Glass | d6ffb00 | 2017-05-17 17:18:04 -0600 | [diff] [blame] | 19 | * |
| 20 | * @dev: Pointer to a device |
| 21 | * |
| 22 | * @return addr |
| 23 | */ |
Simon Glass | a821c4a | 2017-05-17 17:18:05 -0600 | [diff] [blame] | 24 | fdt_addr_t devfdt_get_addr(struct udevice *dev); |
Simon Glass | d6ffb00 | 2017-05-17 17:18:04 -0600 | [diff] [blame] | 25 | |
| 26 | /** |
Simon Glass | a821c4a | 2017-05-17 17:18:05 -0600 | [diff] [blame] | 27 | * devfdt_get_addr_ptr() - Return pointer to the address of the reg property |
Simon Glass | d6ffb00 | 2017-05-17 17:18:04 -0600 | [diff] [blame] | 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 | */ |
Simon Glass | a821c4a | 2017-05-17 17:18:05 -0600 | [diff] [blame] | 34 | void *devfdt_get_addr_ptr(struct udevice *dev); |
Simon Glass | d6ffb00 | 2017-05-17 17:18:04 -0600 | [diff] [blame] | 35 | |
| 36 | /** |
Álvaro Fernández Rojas | 30a90f5 | 2018-04-29 21:56:54 +0200 | [diff] [blame] | 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(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(struct udevice *dev, int index); |
| 57 | |
| 58 | /** |
Álvaro Fernández Rojas | 7959882 | 2018-12-03 19:37:09 +0100 | [diff] [blame] | 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(struct udevice *dev, const char *name); |
| 70 | |
| 71 | /** |
Simon Glass | a821c4a | 2017-05-17 17:18:05 -0600 | [diff] [blame] | 72 | * devfdt_map_physmem() - Read device address from reg property of the |
Simon Glass | d6ffb00 | 2017-05-17 17:18:04 -0600 | [diff] [blame] | 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 |
| 80 | * property. |
| 81 | */ |
Simon Glass | a821c4a | 2017-05-17 17:18:05 -0600 | [diff] [blame] | 82 | void *devfdt_map_physmem(struct udevice *dev, unsigned long size); |
Simon Glass | d6ffb00 | 2017-05-17 17:18:04 -0600 | [diff] [blame] | 83 | |
| 84 | /** |
Simon Glass | a821c4a | 2017-05-17 17:18:05 -0600 | [diff] [blame] | 85 | * devfdt_get_addr_index() - Get the indexed reg property of a device |
Simon Glass | d6ffb00 | 2017-05-17 17:18:04 -0600 | [diff] [blame] | 86 | * |
| 87 | * @dev: Pointer to a device |
| 88 | * @index: the 'reg' property can hold a list of <addr, size> pairs |
| 89 | * and @index is used to select which one is required |
| 90 | * |
| 91 | * @return addr |
| 92 | */ |
Simon Glass | a821c4a | 2017-05-17 17:18:05 -0600 | [diff] [blame] | 93 | fdt_addr_t devfdt_get_addr_index(struct udevice *dev, int index); |
Simon Glass | d6ffb00 | 2017-05-17 17:18:04 -0600 | [diff] [blame] | 94 | |
| 95 | /** |
Simon Glass | a821c4a | 2017-05-17 17:18:05 -0600 | [diff] [blame] | 96 | * devfdt_get_addr_size_index() - Get the indexed reg property of a device |
Simon Glass | d6ffb00 | 2017-05-17 17:18:04 -0600 | [diff] [blame] | 97 | * |
| 98 | * Returns the address and size specified in the 'reg' property of a device. |
| 99 | * |
| 100 | * @dev: Pointer to a device |
| 101 | * @index: the 'reg' property can hold a list of <addr, size> pairs |
| 102 | * and @index is used to select which one is required |
| 103 | * @size: Pointer to size varible - this function returns the size |
| 104 | * specified in the 'reg' property here |
| 105 | * |
| 106 | * @return addr |
| 107 | */ |
Simon Glass | a821c4a | 2017-05-17 17:18:05 -0600 | [diff] [blame] | 108 | fdt_addr_t devfdt_get_addr_size_index(struct udevice *dev, int index, |
Simon Glass | d6ffb00 | 2017-05-17 17:18:04 -0600 | [diff] [blame] | 109 | fdt_size_t *size); |
| 110 | |
| 111 | /** |
Simon Glass | a821c4a | 2017-05-17 17:18:05 -0600 | [diff] [blame] | 112 | * devfdt_get_addr_name() - Get the reg property of a device, indexed by name |
Simon Glass | d6ffb00 | 2017-05-17 17:18:04 -0600 | [diff] [blame] | 113 | * |
| 114 | * @dev: Pointer to a device |
| 115 | * @name: the 'reg' property can hold a list of <addr, size> pairs, with the |
| 116 | * 'reg-names' property providing named-based identification. @index |
| 117 | * indicates the value to search for in 'reg-names'. |
| 118 | * |
| 119 | * @return addr |
| 120 | */ |
Simon Glass | a821c4a | 2017-05-17 17:18:05 -0600 | [diff] [blame] | 121 | fdt_addr_t devfdt_get_addr_name(struct udevice *dev, const char *name); |
Simon Glass | d6ffb00 | 2017-05-17 17:18:04 -0600 | [diff] [blame] | 122 | |
Sekhar Nori | f5b9047 | 2019-08-01 19:12:56 +0530 | [diff] [blame] | 123 | /** |
| 124 | * devfdt_get_addr_size_name() - Get the reg property and its size for a device, |
| 125 | * indexed by name |
| 126 | * |
| 127 | * Returns the address and size specified in the 'reg' property of a device. |
| 128 | * |
| 129 | * @dev: Pointer to a device |
| 130 | * @name: the 'reg' property can hold a list of <addr, size> pairs, with the |
| 131 | * 'reg-names' property providing named-based identification. @index |
| 132 | * indicates the value to search for in 'reg-names'. |
| 133 | * @size: Pointer to size variable - this function returns the size |
| 134 | * specified in the 'reg' property here |
| 135 | * |
| 136 | * @return addr |
| 137 | */ |
| 138 | fdt_addr_t devfdt_get_addr_size_name(struct udevice *dev, const char *name, |
| 139 | fdt_size_t *size); |
| 140 | |
Simon Glass | d6ffb00 | 2017-05-17 17:18:04 -0600 | [diff] [blame] | 141 | #endif |