diff options
author | Tom Wai-Hong Tam <waihong@chromium.org> | 2011-07-15 09:55:28 +0800 |
---|---|---|
committer | Simon Glass <sjg@chromium.org> | 2011-08-29 10:59:05 -0700 |
commit | 1f824792fd983636f5626f4b24b9aa1e5485fe3a (patch) | |
tree | 80c0c5fa9cc0f429c58485262669d079dd2c175c /common/fdt_decode.c | |
parent | b60d4cfd5eb060d688e62d86fa9cf4271bf0873c (diff) |
fdt: Decode memory section from fdt.
BUG=chromium-os:17950
TEST=build without error, pending test until we use it to clear the ram regions.
Change-Id: Icf7695e7ca512541dc77cd84397818e6392f2e9a
Reviewed-on: http://gerrit.chromium.org/gerrit/4479
Reviewed-by: Simon Glass <sjg@chromium.org>
Tested-by: Tom Wai-Hong Tam <waihong@chromium.org>
Diffstat (limited to 'common/fdt_decode.c')
-rw-r--r-- | common/fdt_decode.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/common/fdt_decode.c b/common/fdt_decode.c index da2c6ff7c8..01431e8ef0 100644 --- a/common/fdt_decode.c +++ b/common/fdt_decode.c @@ -344,6 +344,25 @@ int fdt_decode_get_spi_switch(const void *blob, struct fdt_spi_uart *config) return 0; } +int fdt_decode_memory(const void *blob, struct fdt_memory *config) +{ + int node, len; + const addr_t *cell; + + node = fdt_path_offset(blob, "/memory"); + if (node < 0) + return node; + + cell = fdt_getprop(blob, node, "reg", &len); + if (cell && len == sizeof(addr_t) * 2) { + config->start = addr_to_cpu(cell[0]); + config->end = addr_to_cpu(cell[1]); + } else + return -FDT_ERR_BADLAYOUT; + + return 0; +} + /** * Decode a list of GPIOs from an FDT. This creates a list of GPIOs with no * terminating item. |