diff options
author | Shamile Khan <shamile.khan@intel.com> | 2015-09-25 16:27:42 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2015-09-29 14:42:05 -0700 |
commit | 1092919c51101cdbee266f21a493d95c7f0cd77c (patch) | |
tree | 418255eb04279dfa0a45cea572669d93e547bcff | |
parent | 9104bd94bb7a4da3088d73a22b97364b077616b1 (diff) | |
download | chrome-ec-1092919c51101cdbee266f21a493d95c7f0cd77c.tar.gz |
mec1322: Ensure flash operation has completed before returning.
When flashrom performs a flash read following an erase and we do not
wait in between for the erase to complete, we read 0x00 instead of
0xFF. Flashrom detects this and does not proceed further. Inserting
a wait after erase solves this issue.
Also added a wait following a flash write operation to preempt future
issues, and moved spi_flash_wait() calls from Host Command APIs to
lower level spi_flash_* functions.
BUG=chrome-os-partner:43160
BRANCH=none
TEST=Manually tested on Kunimitsu FAB3.
flashrom -p ec -w ec.bin is successful
Signed-off-by: Shamile Khan <shamile.khan@intel.com>
Change-Id: I00925aa2da3709a6f3e73a40543b079112906e0a
Signed-off-by: Shamile Khan <shamile.khan@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/302683
Reviewed-by: Shawn N <shawnn@chromium.org>
-rw-r--r-- | common/spi_flash.c | 54 |
1 files changed, 8 insertions, 46 deletions
diff --git a/common/spi_flash.c b/common/spi_flash.c index 248e401195..0b73df132e 100644 --- a/common/spi_flash.c +++ b/common/spi_flash.c @@ -182,11 +182,6 @@ static int spi_flash_erase_block(unsigned int offset, unsigned int block) if ((offset % (block * 1024)) != 0) return EC_ERROR_INVAL; - /* Wait for previous operation to complete */ - rv = spi_flash_wait(); - if (rv) - return rv; - /* Enable writing to SPI flash */ rv = spi_flash_write_enable(); if (rv) @@ -202,7 +197,8 @@ static int spi_flash_erase_block(unsigned int offset, unsigned int block) if (rv) return rv; - return rv; + /* Wait for previous operation to complete */ + return spi_flash_wait(); } /** @@ -304,7 +300,8 @@ int spi_flash_write(unsigned int offset, unsigned int bytes, bytes -= write_size; } - return rv; + /* Wait for previous operation to complete */ + return spi_flash_wait(); } /** @@ -506,18 +503,8 @@ static int command_spi_flasherase(int argc, char **argv) if (spi_flash_check_protect(offset, bytes)) return EC_ERROR_ACCESS_DENIED; - /* Wait for previous operation to complete */ - rv = spi_flash_wait(); - if (rv) - return rv; - ccprintf("Erasing %d bytes at 0x%x...\n", bytes, offset); - rv = spi_flash_erase(offset, bytes); - if (rv) - return rv; - - /* Wait for the operation to complete */ - return spi_flash_wait(); + return spi_flash_erase(offset, bytes); } DECLARE_CONSOLE_COMMAND(spi_flasherase, command_spi_flasherase, "offset [bytes]", @@ -554,11 +541,6 @@ static int command_spi_flashwrite(int argc, char **argv) write_len = ((bytes % SPI_FLASH_MAX_WRITE_SIZE) == bytes) ? bytes : SPI_FLASH_MAX_WRITE_SIZE; - /* Wait for previous operation to complete */ - rv = spi_flash_wait(); - if (rv) - return rv; - /* Perform write */ rv = spi_flash_write(offset, write_len, buf); if (rv) @@ -570,7 +552,7 @@ static int command_spi_flashwrite(int argc, char **argv) ASSERT(bytes == 0); - return spi_flash_wait(); + return rv; } DECLARE_CONSOLE_COMMAND(spi_flashwrite, command_spi_flashwrite, "offset [bytes]", @@ -661,19 +643,9 @@ static int command_spi_flashwrite_sr(int argc, char **argv) spi_enable(CONFIG_SPI_FLASH_PORT, 1); - /* Wait for previous operation to complete */ - rv = spi_flash_wait(); - if (rv) - return rv; - ccprintf("Writing 0x%02x to status register 1, ", val1); ccprintf("0x%02x to status register 2...\n", val2); - rv = spi_flash_set_status(val1, val2); - if (rv) - return rv; - - /* Wait for the operation to complete */ - return spi_flash_wait(); + return spi_flash_set_status(val1, val2); } DECLARE_CONSOLE_COMMAND(spi_flash_wsr, command_spi_flashwrite_sr, "value1 value2", @@ -691,18 +663,8 @@ static int command_spi_flashprotect(int argc, char **argv) spi_enable(CONFIG_SPI_FLASH_PORT, 1); - /* Wait for previous operation to complete */ - rv = spi_flash_wait(); - if (rv) - return rv; - ccprintf("Setting protection for 0x%06x to 0x%06x\n", val1, val1+val2); - rv = spi_flash_set_protect(val1, val2); - if (rv) - return rv; - - /* Wait for the operation to complete */ - return spi_flash_wait(); + return spi_flash_set_protect(val1, val2); } DECLARE_CONSOLE_COMMAND(spi_flash_prot, command_spi_flashprotect, "offset len", |