diff options
author | Randall Spangler <rspangler@chromium.org> | 2016-09-14 16:48:23 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2016-09-23 12:21:51 -0700 |
commit | 818dea4a07337b96a696f805a207860abf979c8f (patch) | |
tree | 6d564d3e0a304360f95e0d3e200796845a83cff4 /util | |
parent | 5818cdc7286a37cf06d2f2c0d79b0f4ae5ee664c (diff) | |
download | chrome-ec-818dea4a07337b96a696f805a207860abf979c8f.tar.gz |
flash: Add command to get SPI flash chip info
Previously, there was no way to identify which flash chip was used by
the EC, for ECs using an external SPI flash. Now, 'ectool flashinfo'
will print more information about the SPI flash chip in these cases.
BUG=chrome-os-partner:56765
BRANCH=any EC with MEC1322 or NPCX still going through factory
TEST=define CONFIG_HOSTCMD_FLASH_SPI_INFO, then
'ectool flashspiinfo' on samus indicates no SPI flash info,
and prints additional info on chell and kevin. Without
the config defined, all platforms report no spi flash info.
CQ-DEPEND=CL:386368
Change-Id: I3c162f7ad12ed4b30ab951c03f24476683382114
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/385702
Reviewed-by: Shawn N <shawnn@chromium.org>
Diffstat (limited to 'util')
-rw-r--r-- | util/ectool.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/util/ectool.c b/util/ectool.c index b8e5415c22..ac9357dda0 100644 --- a/util/ectool.c +++ b/util/ectool.c @@ -100,6 +100,8 @@ const char help_str[] = " Erases EC flash\n" " flashinfo\n" " Prints information on the EC flash\n" + " flashspiinfo\n" + " Prints information on EC SPI flash, if present\n" " flashpd <dev_id> <port> <filename>\n" " Flash commands over PD\n" " flashprotect [now] [enable | disable]\n" @@ -750,6 +752,33 @@ int cmd_flash_info(int argc, char *argv[]) return 0; } +int cmd_flash_spi_info(int argc, char *argv[]) +{ + struct ec_response_flash_spi_info r; + int rv; + + memset(&r, 0, sizeof(r)); + + /* Print SPI flash info if available */ + if (!ec_cmd_version_supported(EC_CMD_FLASH_SPI_INFO, 0)) { + printf("EC has no info (does not use SPI flash?)\n"); + return -1; + } + + rv = ec_command(EC_CMD_FLASH_SPI_INFO, 0, NULL, 0, &r, sizeof(r)); + if (rv < 0) + return rv; + + printf("JEDECManufacturerID 0x%02x\n", r.jedec[0]); + printf("JEDECDeviceID 0x%02x 0x%02x\n", r.jedec[1], r.jedec[2]); + printf("JEDECCapacity %d\n", 1 << r.jedec[2]); + printf("ManufacturerID 0x%02x\n", r.mfr_dev_id[0]); + printf("DeviceID 0x%02x\n", r.mfr_dev_id[1]); + printf("StatusRegister1 0x%02x\n", r.sr1); + printf("StatusRegister2 0x%02x\n", r.sr2); + return 0; +} + int cmd_flash_read(int argc, char *argv[]) { int offset, size; @@ -6800,6 +6829,7 @@ const struct command commands[] = { {"flashread", cmd_flash_read}, {"flashwrite", cmd_flash_write}, {"flashinfo", cmd_flash_info}, + {"flashspiinfo", cmd_flash_spi_info}, {"flashpd", cmd_flash_pd}, {"forcelidopen", cmd_force_lid_open}, {"gpioget", cmd_gpio_get}, |