summaryrefslogtreecommitdiffstats
path: root/drivers/core
diff options
context:
space:
mode:
authorÁlvaro Fernández Rojas <noltari@gmail.com>2018-12-03 19:37:09 +0100
committerSimon Glass <sjg@chromium.org>2018-12-05 06:06:44 -0700
commit7959882049a9b389c131eff9a128437ee8ebe08e (patch)
treea0b31f0e5dbf3d95ae731918a675c075614db3be /drivers/core
parentbb48470df21c0ce4ebed47f5dc3ea25ff02fd4dd (diff)
downloadu-boot-7959882049a9b389c131eff9a128437ee8ebe08e.tar.gz
u-boot-7959882049a9b389c131eff9a128437ee8ebe08e.tar.xz
u-boot-7959882049a9b389c131eff9a128437ee8ebe08e.zip
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')
-rw-r--r--drivers/core/fdtaddr.c10
-rw-r--r--drivers/core/read.c20
2 files changed, 30 insertions, 0 deletions
diff --git a/drivers/core/fdtaddr.c b/drivers/core/fdtaddr.c
index bfd9580050..e113f1dd39 100644
--- a/drivers/core/fdtaddr.c
+++ b/drivers/core/fdtaddr.c
@@ -146,6 +146,16 @@ void *devfdt_remap_addr_index(struct udevice *dev, int index)
return map_physmem(addr, 0, MAP_NOCACHE);
}
+void *devfdt_remap_addr_name(struct udevice *dev, const char *name)
+{
+ fdt_addr_t addr = devfdt_get_addr_name(dev, name);
+
+ if (addr == FDT_ADDR_T_NONE)
+ return NULL;
+
+ return map_physmem(addr, 0, MAP_NOCACHE);
+}
+
void *devfdt_remap_addr(struct udevice *dev)
{
return devfdt_remap_addr_index(dev, 0);
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);