diff options
author | Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at> | 2012-09-21 12:46:56 +0000 |
---|---|---|
committer | Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at> | 2012-09-21 12:46:56 +0000 |
commit | 3c0fcd0f30f2b3c0df57b66e645859d923e68d16 (patch) | |
tree | 55a94a70e9662a8558667c171b33bdfe99be483e /spi25.c | |
parent | 14fbc4b40045c6fcb345da52ab048d961fc15c6c (diff) | |
download | flashrom-3c0fcd0f30f2b3c0df57b66e645859d923e68d16.tar.gz flashrom-3c0fcd0f30f2b3c0df57b66e645859d923e68d16.tar.bz2 flashrom-3c0fcd0f30f2b3c0df57b66e645859d923e68d16.zip |
Add spi_block_erase_62
This is used by the AT25F series (only?), but is generic enough to
reside in spi25.c. The only currently supported chip is the AT25F512B.
Other members of that series need some additional infrastructure code,
hence this patch adds the erase function to the AT25F512B only.
Corresponding to flashrom svn r1600.
Signed-off-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at>
Acked-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at>
Diffstat (limited to 'spi25.c')
-rw-r--r-- | spi25.c | 47 |
1 files changed, 47 insertions, 0 deletions
@@ -487,6 +487,43 @@ int spi_chip_erase_60(struct flashctx *flash) return 0; } +int spi_chip_erase_62(struct flashctx *flash) +{ + int result; + struct spi_command cmds[] = { + { + .writecnt = JEDEC_WREN_OUTSIZE, + .writearr = (const unsigned char[]){ JEDEC_WREN }, + .readcnt = 0, + .readarr = NULL, + }, { + .writecnt = JEDEC_CE_62_OUTSIZE, + .writearr = (const unsigned char[]){ JEDEC_CE_62 }, + .readcnt = 0, + .readarr = NULL, + }, { + .writecnt = 0, + .writearr = NULL, + .readcnt = 0, + .readarr = NULL, + }}; + + result = spi_send_multicommand(flash, cmds); + if (result) { + msg_cerr("%s failed during command execution\n", + __func__); + return result; + } + /* Wait until the Write-In-Progress bit is cleared. + * This usually takes 2-5 s, so wait in 100 ms steps. + */ + /* FIXME: We assume spi_read_status_register will never fail. */ + while (spi_read_status_register(flash) & SPI_SR_WIP) + programmer_delay(100 * 1000); + /* FIXME: Check the status register for errors. */ + return 0; +} + int spi_chip_erase_c7(struct flashctx *flash) { int result; @@ -711,6 +748,16 @@ int spi_block_erase_60(struct flashctx *flash, unsigned int addr, return spi_chip_erase_60(flash); } +int spi_block_erase_62(struct flashctx *flash, unsigned int addr, unsigned int blocklen) +{ + if ((addr != 0) || (blocklen != flash->chip->total_size * 1024)) { + msg_cerr("%s called with incorrect arguments\n", + __func__); + return -1; + } + return spi_chip_erase_62(flash); +} + int spi_block_erase_c7(struct flashctx *flash, unsigned int addr, unsigned int blocklen) { |