diff options
author | Simon Glass <sjg@chromium.org> | 2012-10-25 16:31:00 (GMT) |
---|---|---|
committer | Gerald Van Baren <gvb@unssw.com> | 2012-11-13 04:00:34 (GMT) |
commit | f20c461984c3d986fde037d4c5bf600aa0497676 (patch) | |
tree | bd00ee8c90b160fa69bcddceaa5641c867f03a03 /include | |
parent | 332ab0d54aaa5b8b27096996d10c8c6183c6972c (diff) | |
download | u-boot-fsl-qoriq-f20c461984c3d986fde037d4c5bf600aa0497676.tar.xz |
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 'include')
-rw-r--r-- | include/fdtdec.h | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/include/fdtdec.h b/include/fdtdec.h index e828662..341e6a1 100644 --- a/include/fdtdec.h +++ b/include/fdtdec.h @@ -40,10 +40,12 @@ typedef u64 fdt_addr_t; #define FDT_ADDR_T_NONE (-1ULL) #define fdt_addr_to_cpu(reg) be64_to_cpu(reg) +#define fdt_size_to_cpu(reg) be64_to_cpu(reg) #else typedef u32 fdt_addr_t; #define FDT_ADDR_T_NONE (-1U) #define fdt_addr_to_cpu(reg) be32_to_cpu(reg) +#define fdt_size_to_cpu(reg) be32_to_cpu(reg) #endif /* Information obtained about memory from the FDT */ @@ -408,4 +410,21 @@ int fdtdec_get_byte_array(const void *blob, int node, const char *prop_name, */ const u8 *fdtdec_locate_byte_array(const void *blob, int node, const char *prop_name, int count); + +/** + * Look up a property in a node which contains a memory region address and + * size. Then return a pointer to this address. + * + * The property must hold one address with a length. This is only tested on + * 32-bit machines. + * + * @param blob FDT blob + * @param node node to examine + * @param prop_name name of property to find + * @param ptrp returns pointer to region, or NULL if no address + * @param size returns size of region + * @return 0 if ok, -1 on error (propery not found) + */ +int fdtdec_decode_region(const void *blob, int node, + const char *prop_name, void **ptrp, size_t *size); #endif |