From 30a90f56c3a20da0456e09e6e665b648719b8935 Mon Sep 17 00:00:00 2001 From: Álvaro Fernández Rojas Date: Sun, 29 Apr 2018 21:56:54 +0200 Subject: dm: core: add functions to get memory-mapped I/O addresses MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Álvaro Fernández Rojas Reviewed-by: Daniel Schwierzeck Signed-off-by: Daniel Schwierzeck Reviewed-by: Simon Glass --- include/dm/fdtaddr.h | 22 ++++++++++++++++++++++ include/dm/read.h | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+) (limited to 'include') diff --git a/include/dm/fdtaddr.h b/include/dm/fdtaddr.h index db4c11e083..49a6ffd5f8 100644 --- a/include/dm/fdtaddr.h +++ b/include/dm/fdtaddr.h @@ -33,6 +33,28 @@ fdt_addr_t devfdt_get_addr(struct udevice *dev); */ void *devfdt_get_addr_ptr(struct udevice *dev); +/** + * devfdt_remap_addr() - Return pointer to the memory-mapped I/O address + * of the reg property of a device + * + * @dev: Pointer to a device + * + * @return Pointer to addr, or NULL if there is no such property + */ +void *devfdt_remap_addr(struct udevice *dev); + +/** + * devfdt_remap_addr_index() - Return indexed pointer to the memory-mapped + * I/O address of the reg property of a device + * @index: the 'reg' property can hold a list of pairs + * and @index is used to select which one is required + * + * @dev: Pointer to a device + * + * @return Pointer to addr, or NULL if there is no such property + */ +void *devfdt_remap_addr_index(struct udevice *dev, int index); + /** * devfdt_map_physmem() - Read device address from reg property of the * device node and map the address into CPU address diff --git a/include/dm/read.h b/include/dm/read.h index 4a725bc923..a27b8554fb 100644 --- a/include/dm/read.h +++ b/include/dm/read.h @@ -112,6 +112,18 @@ int dev_read_size(struct udevice *dev, const char *propname); */ fdt_addr_t dev_read_addr_index(struct udevice *dev, int index); +/** + * dev_remap_addr_index() - Get the indexed reg property of a device + * as a memory-mapped I/O pointer + * + * @dev: Device to read from + * @index: the 'reg' property can hold a list of pairs + * and @index is used to select which one is required + * + * @return pointer or NULL if not found + */ +void *dev_remap_addr_index(struct udevice *dev, int index); + /** * dev_read_addr() - Get the reg property of a device * @@ -131,6 +143,16 @@ fdt_addr_t dev_read_addr(struct udevice *dev); */ void *dev_read_addr_ptr(struct udevice *dev); +/** + * dev_remap_addr() - Get the reg property of a device as a + * memory-mapped I/O pointer + * + * @dev: Device to read from + * + * @return pointer or NULL if not found + */ +void *dev_remap_addr(struct udevice *dev); + /** * dev_read_addr_size() - get address and size from a device property * @@ -482,6 +504,16 @@ static inline void *dev_read_addr_ptr(struct udevice *dev) return devfdt_get_addr_ptr(dev); } +static inline void *dev_remap_addr(struct udevice *dev) +{ + return devfdt_remap_addr(dev); +} + +static inline void *dev_remap_addr_index(struct udevice *dev, int index) +{ + return devfdt_remap_addr_index(dev, index); +} + static inline fdt_addr_t dev_read_addr_size(struct udevice *dev, const char *propname, fdt_size_t *sizep) -- cgit