diff options
author | Andre Przywara <andre.przywara@arm.com> | 2020-03-26 12:11:34 +0000 |
---|---|---|
committer | Andre Przywara <andre.przywara@arm.com> | 2020-05-05 15:36:51 +0100 |
commit | 7ad6d362016a875eaee0d227365b74acd464050b (patch) | |
tree | e0c1cf5fb7b5f5f178fedafe260039fb7b431015 /common | |
parent | 658086747dc638e3012a052293e855339d211a95 (diff) | |
download | platform_external_arm-trusted-firmware-7ad6d362016a875eaee0d227365b74acd464050b.tar.gz platform_external_arm-trusted-firmware-7ad6d362016a875eaee0d227365b74acd464050b.tar.bz2 platform_external_arm-trusted-firmware-7ad6d362016a875eaee0d227365b74acd464050b.zip |
plat/stm32: Use generic fdt_get_reg_props_by_name()
The STM32 platform port parse DT nodes to find base address to
peripherals. It does this by using its own implementation, even though
this functionality is generic and actually widely useful outside of the
STM32 code.
Re-implement fdt_get_reg_props_by_name() on top of the newly introduced
fdt_get_reg_props_by_index() function, and move it to fdt_wrapper.c.
This is removes the assumption that #address-cells and #size-cells are
always one.
Change-Id: I6d584930262c732b6e0356d98aea50b2654f789d
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
Diffstat (limited to 'common')
-rw-r--r-- | common/fdt_wrappers.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/common/fdt_wrappers.c b/common/fdt_wrappers.c index 842d71339..2c4b9c353 100644 --- a/common/fdt_wrappers.c +++ b/common/fdt_wrappers.c @@ -276,3 +276,21 @@ int fdt_get_reg_props_by_index(const void *dtb, int node, int index, return 0; } + +/******************************************************************************* + * This function fills reg node info (base & size) with an index found by + * checking the reg-names node. + * Returns 0 on success and a negative FDT error code on failure. + ******************************************************************************/ +int fdt_get_reg_props_by_name(const void *dtb, int node, const char *name, + uintptr_t *base, size_t *size) +{ + int index; + + index = fdt_stringlist_search(dtb, node, "reg-names", name); + if (index < 0) { + return index; + } + + return fdt_get_reg_props_by_index(dtb, node, index, base, size); +} |