diff options
author | Simon Glass <sjg@chromium.org> | 2012-10-25 16:31:00 +0000 |
---|---|---|
committer | Gerald Van Baren <gvb@unssw.com> | 2012-11-12 23:00:34 -0500 |
commit | f20c461984c3d986fde037d4c5bf600aa0497676 (patch) | |
tree | bd00ee8c90b160fa69bcddceaa5641c867f03a03 /lib | |
parent | 332ab0d54aaa5b8b27096996d10c8c6183c6972c (diff) | |
download | u-boot-imx-f20c461984c3d986fde037d4c5bf600aa0497676.zip u-boot-imx-f20c461984c3d986fde037d4c5bf600aa0497676.tar.gz u-boot-imx-f20c461984c3d986fde037d4c5bf600aa0497676.tar.bz2 |
fdt: Add fdtdec_decode_region() to decode memory region
A memory region has a start and a size and is often specified in
a node by a 'reg' property. Add a function to decode this information
from the fdt.
Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/fdtdec.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/fdtdec.c b/lib/fdtdec.c index 2d60c8a..5570972 100644 --- a/lib/fdtdec.c +++ b/lib/fdtdec.c @@ -542,3 +542,20 @@ char *fdtdec_get_config_string(const void *blob, const char *prop_name) return (char *)nodep; } + +int fdtdec_decode_region(const void *blob, int node, + const char *prop_name, void **ptrp, size_t *size) +{ + const fdt_addr_t *cell; + int len; + + debug("%s: %s\n", __func__, prop_name); + cell = fdt_getprop(blob, node, prop_name, &len); + if (!cell || (len != sizeof(fdt_addr_t) * 2)) + return -1; + + *ptrp = (void *)fdt_addr_to_cpu(*cell); + *size = fdt_size_to_cpu(cell[1]); + debug("%s: size=%zx\n", __func__, *size); + return 0; +} |