diff options
author | Sekhar Nori <nsekhar@ti.com> | 2019-08-01 16:42:56 +0300 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2019-08-12 20:33:39 +0300 |
commit | f5b904796fa876bbfdf6eb9d2b311f9d01d80f5a (patch) | |
tree | 696d7835d6784adde746d196fcd455ca59a59401 /drivers/core/read.c | |
parent | acbb7cd4d34caec36ff6d044a8f55325fa27459f (diff) | |
download | u-boot-f5b904796fa876bbfdf6eb9d2b311f9d01d80f5a.tar.xz |
dm: core: add support for getting register address and size
Current dev_read_*() API lacks support to get address and size
of a "reg" property by name or index. Add support for the same.
Livetree support has been added but not tested on real hardware.
The existing unit tests testing reading address from device-tree
have been updated to test address as well as size.
Reviewed-by: Lokesh Vutla <lokeshvutla@ti.com>
Signed-off-by: Sekhar Nori <nsekhar@ti.com>
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 1a044b05e8..8b5502de11 100644 --- a/drivers/core/read.c +++ b/drivers/core/read.c @@ -82,6 +82,15 @@ fdt_addr_t dev_read_addr_index(struct udevice *dev, int index) return devfdt_get_addr_index(dev, index); } +fdt_addr_t dev_read_addr_size_index(struct udevice *dev, int index, + fdt_size_t *size) +{ + if (ofnode_is_np(dev_ofnode(dev))) + return ofnode_get_addr_size_index(dev_ofnode(dev), index, size); + else + return devfdt_get_addr_size_index(dev, index, size); +} + void *dev_remap_addr_index(struct udevice *dev, int index) { fdt_addr_t addr = dev_read_addr_index(dev, index); @@ -102,6 +111,17 @@ fdt_addr_t dev_read_addr_name(struct udevice *dev, const char *name) return dev_read_addr_index(dev, index); } +fdt_addr_t dev_read_addr_size_name(struct udevice *dev, const char *name, + fdt_size_t *size) +{ + int index = dev_read_stringlist_search(dev, "reg-names", name); + + if (index < 0) + return FDT_ADDR_T_NONE; + else + return dev_read_addr_size_index(dev, index, size); +} + void *dev_remap_addr_name(struct udevice *dev, const char *name) { fdt_addr_t addr = dev_read_addr_name(dev, name); |