diff options
author | Simon Glass <sjg@chromium.org> | 2014-02-27 13:26:03 -0700 |
---|---|---|
committer | Simon Glass <sjg@chromium.org> | 2014-03-17 20:05:46 -0600 |
commit | d7f25f35f448b15f815d355abd9ba39836fd9e32 (patch) | |
tree | ff20a0da108f10c24f24f72634b8bc93e01cb7f3 /drivers/misc | |
parent | 41364f0fbe1e550a3326dd4310e41adec5ce30d7 (diff) | |
download | u-boot-imx-d7f25f35f448b15f815d355abd9ba39836fd9e32.zip u-boot-imx-d7f25f35f448b15f815d355abd9ba39836fd9e32.tar.gz u-boot-imx-d7f25f35f448b15f815d355abd9ba39836fd9e32.tar.bz2 |
cros_ec: Add a function for decoding the Chrome OS EC flashmap
In order to talk to the EC properly we need to be able to understand the
layout of its internal flash memory. This permits emulation of the EC
for sandbox, and also software update in a system with a real EC.
Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'drivers/misc')
-rw-r--r-- | drivers/misc/cros_ec.c | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/drivers/misc/cros_ec.c b/drivers/misc/cros_ec.c index 301e8eb..1998653 100644 --- a/drivers/misc/cros_ec.c +++ b/drivers/misc/cros_ec.c @@ -958,6 +958,56 @@ int cros_ec_decode_region(int argc, char * const argv[]) return -1; } +int cros_ec_decode_ec_flash(const void *blob, struct fdt_cros_ec *config) +{ + int flash_node, node; + + node = fdtdec_next_compatible(blob, 0, COMPAT_GOOGLE_CROS_EC); + if (node < 0) { + debug("Failed to find chrome-ec node'\n"); + return -1; + } + + flash_node = fdt_subnode_offset(blob, node, "flash"); + if (flash_node < 0) { + debug("Failed to find flash node\n"); + return -1; + } + + if (fdtdec_read_fmap_entry(blob, flash_node, "flash", + &config->flash)) { + debug("Failed to decode flash node in chrome-ec'\n"); + return -1; + } + + config->flash_erase_value = fdtdec_get_int(blob, flash_node, + "erase-value", -1); + for (node = fdt_first_subnode(blob, flash_node); node >= 0; + node = fdt_next_subnode(blob, node)) { + const char *name = fdt_get_name(blob, node, NULL); + enum ec_flash_region region; + + if (0 == strcmp(name, "ro")) { + region = EC_FLASH_REGION_RO; + } else if (0 == strcmp(name, "rw")) { + region = EC_FLASH_REGION_RW; + } else if (0 == strcmp(name, "wp-ro")) { + region = EC_FLASH_REGION_WP_RO; + } else { + debug("Unknown EC flash region name '%s'\n", name); + return -1; + } + + if (fdtdec_read_fmap_entry(blob, node, "reg", + &config->region[region])) { + debug("Failed to decode flash region in chrome-ec'\n"); + return -1; + } + } + + return 0; +} + /** * Perform a flash read or write command * |