diff options
author | Simon Glass <sjg@chromium.org> | 2018-06-11 22:07:18 +0300 |
---|---|---|
committer | Simon Glass <sjg@chromium.org> | 2018-07-09 18:11:00 +0300 |
commit | 964cadc445f1437e63f1d2b4fffd233ac053c6e6 (patch) | |
tree | e753eaf7147763c8d2a7aa8f20ab086c7a36c863 /include/dm | |
parent | 5e0a7341cdda182f310624d5c336fb48be04a703 (diff) | |
download | u-boot-964cadc445f1437e63f1d2b4fffd233ac053c6e6.tar.xz |
dm: core: Add a function to decode a memory region
Add a way to decode a memory region, including the memory type (sram or
sdram) and its start address and size.
Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'include/dm')
-rw-r--r-- | include/dm/of_extra.h | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/include/dm/of_extra.h b/include/dm/of_extra.h index e1540c1fbd..97988b6663 100644 --- a/include/dm/of_extra.h +++ b/include/dm/of_extra.h @@ -40,4 +40,49 @@ struct fmap_entry { */ int ofnode_read_fmap_entry(ofnode node, struct fmap_entry *entry); +/** + * ofnode_decode_region() - Decode a memory region from a node + * + * 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 node ofnode to examine + * @param prop_name name of property to find + * @param basep Returns base address of region + * @param size Returns size of region + * @return 0 if ok, -1 on error (property not found) + */ +int ofnode_decode_region(ofnode node, const char *prop_name, fdt_addr_t *basep, + fdt_size_t *sizep); + +/** + * ofnode_decode_memory_region()- Decode a named region within a memory bank + * + * This function handles selection of a memory region. The region is + * specified as an offset/size within a particular type of memory. + * + * The properties used are: + * + * <mem_type>-memory<suffix> for the name of the memory bank + * <mem_type>-offset<suffix> for the offset in that bank + * + * The property value must have an offset and a size. The function checks + * that the region is entirely within the memory bank.5 + * + * @param node ofnode containing the properties (-1 for /config) + * @param mem_type Type of memory to use, which is a name, such as + * "u-boot" or "kernel". + * @param suffix String to append to the memory/offset + * property names + * @param basep Returns base of region + * @param sizep Returns size of region + * @return 0 if OK, -ive on error + */ +int ofnode_decode_memory_region(ofnode config_node, const char *mem_type, + const char *suffix, fdt_addr_t *basep, + fdt_size_t *sizep); + #endif |