[flashrom] [PATCH] Convert SPI chip erase to multicommand
Carl-Daniel Hailfinger
c-d.hailfinger.devel.2006 at gmx.net
Sat Jul 11 02:07:40 CEST 2009
Convert SPI chip erase to use the multicommand infrastructure.
This breaks ICH/VIA SPI. The good news is that once VIA/SPI are
converted to multicommand, a lot of hacks can disappear.
Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006 at gmx.net>
Index: flashrom-spi_multicommand_chiperase/spi.c
===================================================================
--- flashrom-spi_multicommand_chiperase/spi.c (Revision 645)
+++ flashrom-spi_multicommand_chiperase/spi.c (Arbeitskopie)
@@ -417,21 +417,34 @@
int spi_chip_erase_60(struct flashchip *flash)
{
- const unsigned char cmd[JEDEC_CE_60_OUTSIZE] = {JEDEC_CE_60};
int result;
+ struct spi_command spicommands[] = {
+ {
+ .writecnt = JEDEC_WREN_OUTSIZE,
+ .writearr = (const unsigned char[]){ JEDEC_WREN },
+ .readcnt = 0,
+ .readarr = NULL,
+ }, {
+ .writecnt = JEDEC_CE_60_OUTSIZE,
+ .writearr = (const unsigned char[]){ JEDEC_CE_60 },
+ .readcnt = 0,
+ .readarr = NULL,
+ }, {
+ .writecnt = 0,
+ .writearr = NULL,
+ .readcnt = 0,
+ .readarr = NULL,
+ }};
result = spi_disable_blockprotect();
if (result) {
printf_debug("spi_disable_blockprotect failed\n");
return result;
}
- result = spi_write_enable();
- if (result)
- return result;
- /* Send CE (Chip Erase) */
- result = spi_send_command(sizeof(cmd), 0, cmd, NULL);
+
+ result = spi_send_multicommand(spicommands);
if (result) {
- printf_debug("spi_chip_erase_60 failed sending erase\n");
+ printf_debug("%s failed during command execution\n", __func__);
return result;
}
/* Wait until the Write-In-Progress bit is cleared.
@@ -449,21 +462,34 @@
int spi_chip_erase_c7(struct flashchip *flash)
{
- const unsigned char cmd[JEDEC_CE_C7_OUTSIZE] = { JEDEC_CE_C7 };
int result;
+ struct spi_command spicommands[] = {
+ {
+ .writecnt = JEDEC_WREN_OUTSIZE,
+ .writearr = (const unsigned char[]){ JEDEC_WREN },
+ .readcnt = 0,
+ .readarr = NULL,
+ }, {
+ .writecnt = JEDEC_CE_C7_OUTSIZE,
+ .writearr = (const unsigned char[]){ JEDEC_CE_C7 },
+ .readcnt = 0,
+ .readarr = NULL,
+ }, {
+ .writecnt = 0,
+ .writearr = NULL,
+ .readcnt = 0,
+ .readarr = NULL,
+ }};
result = spi_disable_blockprotect();
if (result) {
printf_debug("spi_disable_blockprotect failed\n");
return result;
}
- result = spi_write_enable();
- if (result)
- return result;
- /* Send CE (Chip Erase) */
- result = spi_send_command(sizeof(cmd), 0, cmd, NULL);
+
+ result = spi_send_multicommand(spicommands);
if (result) {
- printf_debug("spi_chip_erase_60 failed sending erase\n");
+ printf_debug("%s failed during command execution\n", __func__);
return result;
}
/* Wait until the Write-In-Progress bit is cleared.
--
http://www.hailfinger.org/
More information about the flashrom
mailing list