diff options
author | Stephen Warren <swarren@nvidia.com> | 2016-08-05 09:47:51 -0600 |
---|---|---|
committer | Simon Glass <sjg@chromium.org> | 2016-08-12 09:20:27 -0600 |
commit | 6e06acb73248e32457064d8fe820cbc217c45f3f (patch) | |
tree | 106717d17611a41e530114091fd12693233759bc /lib | |
parent | 11e44fc6bda2248271d26a8488f5efe189b55a30 (diff) | |
download | u-boot-6e06acb73248e32457064d8fe820cbc217c45f3f.zip u-boot-6e06acb73248e32457064d8fe820cbc217c45f3f.tar.gz u-boot-6e06acb73248e32457064d8fe820cbc217c45f3f.tar.bz2 |
fdt: allow fdtdec_get_addr_size_*() to translate addresses
Some code may want to read reg values from DT, but from nodes that aren't
associated with DM devices, so using dev_get_addr_index() isn't
appropriate. In this case, fdtdec_get_addr_size_*() are the functions to
use. However, "translation" (via the chain of ranges properties in parent
nodes) may still be desirable. Add a function parameter to request that,
and implement it. Update all call sites to default to the original
behaviour.
Signed-off-by: Stephen Warren <swarren@nvidia.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Squashed in build fix from Stephen:
Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/fdtdec.c | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/lib/fdtdec.c b/lib/fdtdec.c index 462a24f..e638ca5 100644 --- a/lib/fdtdec.c +++ b/lib/fdtdec.c @@ -9,6 +9,7 @@ #include <errno.h> #include <serial.h> #include <libfdt.h> +#include <fdt_support.h> #include <fdtdec.h> #include <asm/sections.h> #include <linux/ctype.h> @@ -77,7 +78,7 @@ const char *fdtdec_get_compatible(enum fdt_compat_id id) fdt_addr_t fdtdec_get_addr_size_fixed(const void *blob, int node, const char *prop_name, int index, int na, int ns, - fdt_size_t *sizep) + fdt_size_t *sizep, bool translate) { const fdt32_t *prop, *prop_end; const fdt32_t *prop_addr, *prop_size, *prop_after_size; @@ -112,7 +113,12 @@ fdt_addr_t fdtdec_get_addr_size_fixed(const void *blob, int node, return FDT_ADDR_T_NONE; } - addr = fdtdec_get_number(prop_addr, na); +#if !defined(CONFIG_SPL_BUILD) && defined(CONFIG_OF_LIBFDT) + if (translate) + addr = fdt_translate_address(blob, node, prop_addr); + else +#endif + addr = fdtdec_get_number(prop_addr, na); if (sizep) { *sizep = fdtdec_get_number(prop_size, ns); @@ -126,7 +132,8 @@ fdt_addr_t fdtdec_get_addr_size_fixed(const void *blob, int node, } fdt_addr_t fdtdec_get_addr_size_auto_parent(const void *blob, int parent, - int node, const char *prop_name, int index, fdt_size_t *sizep) + int node, const char *prop_name, int index, fdt_size_t *sizep, + bool translate) { int na, ns; @@ -147,11 +154,12 @@ fdt_addr_t fdtdec_get_addr_size_auto_parent(const void *blob, int parent, debug("na=%d, ns=%d, ", na, ns); return fdtdec_get_addr_size_fixed(blob, node, prop_name, index, na, - ns, sizep); + ns, sizep, translate); } fdt_addr_t fdtdec_get_addr_size_auto_noparent(const void *blob, int node, - const char *prop_name, int index, fdt_size_t *sizep) + const char *prop_name, int index, fdt_size_t *sizep, + bool translate) { int parent; @@ -164,7 +172,7 @@ fdt_addr_t fdtdec_get_addr_size_auto_noparent(const void *blob, int node, } return fdtdec_get_addr_size_auto_parent(blob, parent, node, prop_name, - index, sizep); + index, sizep, translate); } fdt_addr_t fdtdec_get_addr_size(const void *blob, int node, @@ -174,7 +182,7 @@ fdt_addr_t fdtdec_get_addr_size(const void *blob, int node, return fdtdec_get_addr_size_fixed(blob, node, prop_name, 0, sizeof(fdt_addr_t) / sizeof(fdt32_t), - ns, sizep); + ns, sizep, false); } fdt_addr_t fdtdec_get_addr(const void *blob, int node, |