aboutsummaryrefslogtreecommitdiff
path: root/lib/fdtdec.c
diff options
context:
space:
mode:
authorPatrick Delaunay <patrick.delaunay@foss.st.com>2021-04-06 09:38:06 +0200
committerSimon Glass <sjg@chromium.org>2021-04-29 03:23:39 -0700
commitfeb7ac457c20ac575749471141722b0bbe6303ca (patch)
treed313185a6a75fa108a2da7b5e9798ee4bd792508 /lib/fdtdec.c
parent1736575b0cfe5dfe511a2904dd84289fc781728e (diff)
downloadu-boot-feb7ac457c20ac575749471141722b0bbe6303ca.zip
u-boot-feb7ac457c20ac575749471141722b0bbe6303ca.tar.gz
u-boot-feb7ac457c20ac575749471141722b0bbe6303ca.tar.bz2
dm: core: Add address translation in fdt_get_resource
Today of_address_to_resource() is called only in ofnode_read_resource() for livetree support and fdt_get_resource() is called when livetree is not supported. The fdt_get_resource() doesn't do the address translation so when it is required, but the address translation is done by ofnode_read_resource() caller, for example in drivers/firmware/scmi/smt.c::scmi_dt_get_smt_buffer() { ... ret = ofnode_read_resource(args.node, 0, &resource); if (ret) return ret; faddr = cpu_to_fdt32(resource.start); paddr = ofnode_translate_address(args.node, &faddr); ... The both behavior should be aligned and the address translation must be called in fdt_get_resource() and removed for each caller. Fixes: a44810123f9e ("dm: core: Add dev_read_resource() to read device resources") Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com> Acked-by: Etienne Carriere <etienne.carriere@linaro.org>
Diffstat (limited to 'lib/fdtdec.c')
-rw-r--r--lib/fdtdec.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/fdtdec.c b/lib/fdtdec.c
index 8645891..4b097fb 100644
--- a/lib/fdtdec.c
+++ b/lib/fdtdec.c
@@ -942,7 +942,11 @@ int fdt_get_resource(const void *fdt, int node, const char *property,
while (ptr + na + ns <= end) {
if (i == index) {
- res->start = fdtdec_get_number(ptr, na);
+ if (CONFIG_IS_ENABLED(OF_TRANSLATE))
+ res->start = fdt_translate_address(fdt, node, ptr);
+ else
+ res->start = fdtdec_get_number(ptr, na);
+
res->end = res->start;
res->end += fdtdec_get_number(&ptr[na], ns) - 1;
return 0;