diff options
author | Álvaro Fernández Rojas <noltari@gmail.com> | 2018-12-03 21:37:09 +0300 |
---|---|---|
committer | Simon Glass <sjg@chromium.org> | 2018-12-05 16:06:44 +0300 |
commit | 7959882049a9b389c131eff9a128437ee8ebe08e (patch) | |
tree | a0b31f0e5dbf3d95ae731918a675c075614db3be /drivers/core/read.c | |
parent | bb48470df21c0ce4ebed47f5dc3ea25ff02fd4dd (diff) | |
download | u-boot-7959882049a9b389c131eff9a128437ee8ebe08e.tar.xz |
dm: core: add functions to get/remap I/O addresses by name
This functions allow us to get and remap I/O addresses by name, which is useful when there are multiple reg addresses indexed by reg-names property.
This is needed in bmips dma/eth patch series, but can also be used on many
other drivers.
Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
Reviewed-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'drivers/core/read.c')
-rw-r--r-- | drivers/core/read.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/drivers/core/read.c b/drivers/core/read.c index 96766c7876..cdd78be03e 100644 --- a/drivers/core/read.c +++ b/drivers/core/read.c @@ -69,6 +69,26 @@ void *dev_remap_addr_index(struct udevice *dev, int index) return map_physmem(addr, 0, MAP_NOCACHE); } +fdt_addr_t dev_read_addr_name(struct udevice *dev, const char *name) +{ + int index = dev_read_stringlist_search(dev, "reg-names", name); + + if (index < 0) + return FDT_ADDR_T_NONE; + else + return dev_read_addr_index(dev, index); +} + +void *dev_remap_addr_name(struct udevice *dev, const char *name) +{ + fdt_addr_t addr = dev_read_addr_name(dev, name); + + if (addr == FDT_ADDR_T_NONE) + return NULL; + + return map_physmem(addr, 0, MAP_NOCACHE); +} + fdt_addr_t dev_read_addr(struct udevice *dev) { return dev_read_addr_index(dev, 0); |