[coreboot] [PATCH] flashrom: Handle one-byte SPI writes
Carl-Daniel Hailfinger
c-d.hailfinger.devel.2006 at gmx.net
Thu May 7 15:14:53 CEST 2009
Chips like the SST SST25VF080B can only handle single byte writes
outside AAI mode.
Change SPI architecture to handle 1-byte chunk chip writing differently
from 256-byte chunk chip writing.
Convert all flashchips.c entries with SPI programing to the 256-byte
version by default.
Change the flashchips entry for SST SST25VF080B to 1-byte writing.
Untested.
Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006 at gmx.net>
Index: flashrom-SST25VF080B/flash.h
===================================================================
--- flashrom-SST25VF080B/flash.h (Revision 471)
+++ flashrom-SST25VF080B/flash.h (Arbeitskopie)
@@ -565,7 +565,8 @@
int spi_chip_erase_d8(struct flashchip *flash);
int spi_block_erase_52(const struct flashchip *flash, unsigned long addr);
int spi_block_erase_d8(const struct flashchip *flash, unsigned long addr);
-int spi_chip_write(struct flashchip *flash, uint8_t *buf);
+int spi_chip_write_1(struct flashchip *flash, uint8_t *buf);
+int spi_chip_write_256(struct flashchip *flash, uint8_t *buf);
int spi_chip_read(struct flashchip *flash, uint8_t *buf);
uint8_t spi_read_status_register(void);
int spi_disable_blockprotect(void);
@@ -593,7 +594,7 @@
int ich_spi_command(unsigned int writecnt, unsigned int readcnt,
const unsigned char *writearr, unsigned char *readarr);
int ich_spi_read(struct flashchip *flash, uint8_t * buf);
-int ich_spi_write(struct flashchip *flash, uint8_t * buf);
+int ich_spi_write_256(struct flashchip *flash, uint8_t * buf);
/* it87spi.c */
extern uint16_t it8716f_flashport;
@@ -601,13 +602,14 @@
int it8716f_spi_command(unsigned int writecnt, unsigned int readcnt,
const unsigned char *writearr, unsigned char *readarr);
int it8716f_spi_chip_read(struct flashchip *flash, uint8_t *buf);
-int it8716f_spi_chip_write(struct flashchip *flash, uint8_t *buf);
+int it8716f_spi_chip_write_1(struct flashchip *flash, uint8_t *buf);
+int it8716f_spi_chip_write_256(struct flashchip *flash, uint8_t *buf);
/* sb600spi.c */
int sb600_spi_command(unsigned int writecnt, unsigned int readcnt,
const unsigned char *writearr, unsigned char *readarr);
int sb600_spi_read(struct flashchip *flash, uint8_t *buf);
-int sb600_spi_write(struct flashchip *flash, uint8_t *buf);
+int sb600_spi_write_256(struct flashchip *flash, uint8_t *buf);
uint8_t sb600_read_status_register(void);
extern uint8_t volatile *sb600_spibar;
@@ -706,7 +708,7 @@
int wbsio_check_for_spi(const char *name);
int wbsio_spi_command(unsigned int writecnt, unsigned int readcnt, const unsigned char *writearr, unsigned char *readarr);
int wbsio_spi_read(struct flashchip *flash, uint8_t *buf);
-int wbsio_spi_write(struct flashchip *flash, uint8_t *buf);
+int wbsio_spi_write_256(struct flashchip *flash, uint8_t *buf);
/* stm50flw0x0x.c */
int probe_stm50flw0x0x(struct flashchip *flash);
Index: flashrom-SST25VF080B/it87spi.c
===================================================================
--- flashrom-SST25VF080B/it87spi.c (Revision 471)
+++ flashrom-SST25VF080B/it87spi.c (Arbeitskopie)
@@ -215,10 +215,12 @@
}
/*
- * IT8716F only allows maximum of 512 kb SPI mapped to LPC memory cycles
* Program chip using firmware cycle byte programming. (SLOW!)
+ * This is for chips which can only handle one byte writes
+ * and for chips where memory mapped programming is impossible due to
+ * size constraints in IT87* (over 512 kB)
*/
-int it8716f_over512k_spi_chip_write(struct flashchip *flash, uint8_t *buf)
+int it8716f_spi_chip_write_1(struct flashchip *flash, uint8_t *buf)
{
int total_size = 1024 * flash->total_size;
int i;
@@ -262,13 +264,17 @@
return 0;
}
-int it8716f_spi_chip_write(struct flashchip *flash, uint8_t *buf)
+int it8716f_spi_chip_write_256(struct flashchip *flash, uint8_t *buf)
{
int total_size = 1024 * flash->total_size;
int i;
+ /*
+ * IT8716F only allows maximum of 512 kb SPI chip size for memory
+ * mapped access.
+ */
if (total_size > 512 * 1024) {
- it8716f_over512k_spi_chip_write(flash, buf);
+ it8716f_spi_chip_write_1(flash, buf);
} else {
for (i = 0; i < total_size / 256; i++) {
it8716f_spi_page_program(i, buf,
Index: flashrom-SST25VF080B/flashchips.c
===================================================================
--- flashrom-SST25VF080B/flashchips.c (Revision 471)
+++ flashrom-SST25VF080B/flashchips.c (Arbeitskopie)
@@ -151,7 +151,7 @@
.tested = TEST_UNTESTED,
.probe = probe_spi_rdid,
.erase = spi_chip_erase_60_c7,
- .write = spi_chip_write,
+ .write = spi_chip_write_256,
.read = spi_chip_read,
},
@@ -165,7 +165,7 @@
.tested = TEST_UNTESTED,
.probe = probe_spi_rdid,
.erase = spi_chip_erase_60_c7,
- .write = spi_chip_write,
+ .write = spi_chip_write_256,
.read = spi_chip_read,
},
@@ -179,7 +179,7 @@
.tested = TEST_UNTESTED,
.probe = probe_spi_rdid,
.erase = spi_chip_erase_60_c7,
- .write = spi_chip_write,
+ .write = spi_chip_write_256,
.read = spi_chip_read,
},
@@ -193,7 +193,7 @@
.tested = TEST_UNTESTED,
.probe = probe_spi_rdid,
.erase = spi_chip_erase_60_c7,
- .write = spi_chip_write,
+ .write = spi_chip_write_256,
.read = spi_chip_read,
},
@@ -207,7 +207,7 @@
.tested = TEST_OK_PREW,
.probe = probe_spi_rdid,
.erase = spi_chip_erase_60_c7,
- .write = spi_chip_write,
+ .write = spi_chip_write_256,
.read = spi_chip_read,
},
@@ -221,7 +221,7 @@
.tested = TEST_UNTESTED,
.probe = probe_spi_rdid,
.erase = spi_chip_erase_60_c7,
- .write = spi_chip_write,
+ .write = spi_chip_write_256,
.read = spi_chip_read,
},
@@ -235,7 +235,7 @@
.tested = TEST_UNTESTED,
.probe = probe_spi_rdid,
.erase = spi_chip_erase_60_c7,
- .write = spi_chip_write,
+ .write = spi_chip_write_256,
.read = spi_chip_read,
},
@@ -249,7 +249,7 @@
.tested = TEST_UNTESTED,
.probe = probe_spi_rdid,
.erase = spi_chip_erase_60_c7,
- .write = spi_chip_write,
+ .write = spi_chip_write_256,
.read = spi_chip_read,
},
@@ -263,7 +263,7 @@
.tested = TEST_UNTESTED,
.probe = probe_spi_rdid,
.erase = spi_chip_erase_60_c7,
- .write = spi_chip_write,
+ .write = spi_chip_write_256,
.read = spi_chip_read,
},
@@ -277,7 +277,7 @@
.tested = TEST_UNTESTED,
.probe = probe_spi_rdid,
.erase = spi_chip_erase_60_c7,
- .write = spi_chip_write,
+ .write = spi_chip_write_256,
.read = spi_chip_read,
},
@@ -305,7 +305,7 @@
.tested = TEST_UNTESTED,
.probe = probe_spi_rdid,
.erase = spi_chip_erase_60_c7,
- .write = spi_chip_write,
+ .write = spi_chip_write_256,
.read = spi_chip_read,
},
@@ -319,7 +319,7 @@
.tested = TEST_UNTESTED,
.probe = probe_spi_rdid,
.erase = spi_chip_erase_60_c7,
- .write = spi_chip_write,
+ .write = spi_chip_write_256,
.read = spi_chip_read,
},
@@ -333,7 +333,7 @@
.tested = TEST_UNTESTED,
.probe = probe_spi_rdid,
.erase = spi_chip_erase_60_c7,
- .write = spi_chip_write,
+ .write = spi_chip_write_256,
.read = spi_chip_read,
},
@@ -348,7 +348,7 @@
.tested = TEST_UNTESTED,
.probe = probe_spi_rdid,
.erase = spi_chip_erase_60_c7,
- .write = spi_chip_write,
+ .write = spi_chip_write_256,
.read = spi_chip_read,
},*/
@@ -554,7 +554,7 @@
.tested = TEST_OK_PREW,
.probe = probe_spi_rdid4,
.erase = spi_chip_erase_c7,
- .write = spi_chip_write,
+ .write = spi_chip_write_256,
.read = spi_chip_read,
},
@@ -737,7 +737,7 @@
.tested = TEST_UNTESTED,
.probe = probe_spi_rdid,
.erase = spi_chip_erase_60_c7,
- .write = spi_chip_write,
+ .write = spi_chip_write_256,
.read = spi_chip_read,
},
@@ -751,7 +751,7 @@
.tested = TEST_UNTESTED,
.probe = probe_spi_rdid,
.erase = spi_chip_erase_60_c7,
- .write = spi_chip_write,
+ .write = spi_chip_write_256,
.read = spi_chip_read,
},
@@ -765,7 +765,7 @@
.tested = TEST_UNTESTED,
.probe = probe_spi_rdid,
.erase = spi_chip_erase_60_c7,
- .write = spi_chip_write,
+ .write = spi_chip_write_256,
.read = spi_chip_read,
},
@@ -779,7 +779,7 @@
.tested = TEST_OK_PREW,
.probe = probe_spi_rdid,
.erase = spi_chip_erase_60_c7,
- .write = spi_chip_write,
+ .write = spi_chip_write_256,
.read = spi_chip_read,
},
@@ -793,7 +793,7 @@
.tested = TEST_OK_PREW,
.probe = probe_spi_rdid,
.erase = spi_chip_erase_60_c7,
- .write = spi_chip_write,
+ .write = spi_chip_write_256,
.read = spi_chip_read,
},
@@ -807,7 +807,7 @@
.tested = TEST_OK_PREW,
.probe = probe_spi_rdid,
.erase = spi_chip_erase_60_c7,
- .write = spi_chip_write,
+ .write = spi_chip_write_256,
.read = spi_chip_read,
},
@@ -821,7 +821,7 @@
.tested = TEST_UNTESTED,
.probe = probe_spi_rdid,
.erase = spi_chip_erase_60_c7,
- .write = spi_chip_write,
+ .write = spi_chip_write_256,
.read = spi_chip_read,
},
@@ -835,7 +835,7 @@
.tested = TEST_OK_PREW,
.probe = probe_spi_rdid,
.erase = spi_chip_erase_60_c7,
- .write = spi_chip_write,
+ .write = spi_chip_write_256,
.read = spi_chip_read,
},
@@ -849,7 +849,7 @@
.tested = TEST_UNTESTED,
.probe = probe_spi_rdid,
.erase = spi_chip_erase_60_c7,
- .write = spi_chip_write,
+ .write = spi_chip_write_256,
.read = spi_chip_read,
},
@@ -863,7 +863,7 @@
.tested = TEST_UNTESTED,
.probe = probe_spi_rdid,
.erase = spi_chip_erase_60_c7,
- .write = spi_chip_write,
+ .write = spi_chip_write_256,
.read = spi_chip_read,
},
@@ -877,7 +877,7 @@
.tested = TEST_UNTESTED,
.probe = probe_spi_rdid,
.erase = spi_chip_erase_60_c7,
- .write = spi_chip_write,
+ .write = spi_chip_write_256,
.read = spi_chip_read,
},
@@ -930,7 +930,7 @@
.tested = TEST_UNTESTED,
.probe = probe_spi_rdid,
.erase = spi_chip_erase_d8,
- .write = spi_chip_write,
+ .write = spi_chip_write_256,
.read = spi_chip_read,
},
@@ -944,7 +944,7 @@
.tested = TEST_UNTESTED,
.probe = probe_spi_rdid,
.erase = spi_chip_erase_d8,
- .write = spi_chip_write,
+ .write = spi_chip_write_256,
.read = spi_chip_read,
},
@@ -958,7 +958,7 @@
.tested = TEST_UNTESTED,
.probe = probe_spi_rdid,
.erase = spi_chip_erase_d8,
- .write = spi_chip_write,
+ .write = spi_chip_write_256,
.read = spi_chip_read,
},
@@ -972,7 +972,7 @@
.tested = TEST_OK_PREW,
.probe = probe_spi_rdid,
.erase = spi_chip_erase_d8,
- .write = spi_chip_write,
+ .write = spi_chip_write_256,
.read = spi_chip_read,
},
@@ -986,7 +986,7 @@
.tested = TEST_UNTESTED,
.probe = probe_spi_rdid,
.erase = spi_chip_erase_d8,
- .write = spi_chip_write,
+ .write = spi_chip_write_256,
.read = spi_chip_read,
},
@@ -1000,7 +1000,7 @@
.tested = TEST_UNTESTED,
.probe = probe_spi_rdid,
.erase = spi_chip_erase_c7,
- .write = spi_chip_write,
+ .write = spi_chip_write_256,
.read = spi_chip_read,
},
@@ -1014,7 +1014,7 @@
.tested = TEST_UNTESTED,
.probe = probe_spi_rdid,
.erase = spi_chip_erase_c7,
- .write = spi_chip_write,
+ .write = spi_chip_write_256,
.read = spi_chip_read,
},
@@ -1028,7 +1028,7 @@
.tested = TEST_UNTESTED,
.probe = probe_spi_rdid,
.erase = spi_chip_erase_c7,
- .write = spi_chip_write,
+ .write = spi_chip_write_256,
.read = spi_chip_read,
},
@@ -1042,7 +1042,7 @@
.tested = TEST_UNTESTED,
.probe = probe_spi_rdid,
.erase = spi_chip_erase_c7,
- .write = spi_chip_write,
+ .write = spi_chip_write_256,
.read = spi_chip_read,
},
@@ -1056,7 +1056,7 @@
.tested = TEST_UNTESTED,
.probe = probe_spi_rdid,
.erase = spi_chip_erase_c7,
- .write = spi_chip_write,
+ .write = spi_chip_write_256,
.read = spi_chip_read,
},
@@ -1070,7 +1070,7 @@
.tested = TEST_UNTESTED,
.probe = probe_spi_rdid,
.erase = spi_chip_erase_c7,
- .write = spi_chip_write,
+ .write = spi_chip_write_256,
.read = spi_chip_read,
},
@@ -1123,7 +1123,7 @@
.tested = TEST_OK_PREW,
.probe = probe_spi_rdid,
.erase = spi_chip_erase_c7,
- .write = spi_chip_write,
+ .write = spi_chip_write_256,
.read = spi_chip_read,
},
@@ -1137,7 +1137,7 @@
.tested = TEST_OK_PREW,
.probe = probe_spi_rdid,
.erase = spi_chip_erase_c7,
- .write = spi_chip_write,
+ .write = spi_chip_write_256,
.read = spi_chip_read,
},
@@ -1151,7 +1151,7 @@
.tested = TEST_OK_PREW,
.probe = probe_spi_rdid,
.erase = spi_chip_erase_c7,
- .write = spi_chip_write,
+ .write = spi_chip_write_256,
.read = spi_chip_read,
},
@@ -1165,7 +1165,7 @@
.tested = TEST_UNTESTED,
.probe = probe_spi_rdid,
.erase = spi_chip_erase_c7,
- .write = spi_chip_write,
+ .write = spi_chip_write_256,
.read = spi_chip_read,
},
@@ -1179,7 +1179,7 @@
.tested = TEST_OK_PR,
.probe = probe_spi_rems,
.erase = spi_chip_erase_60,
- .write = spi_chip_write,
+ .write = spi_chip_write_256,
.read = spi_chip_read,
},
@@ -1207,7 +1207,7 @@
.tested = TEST_OK_PREW,
.probe = probe_spi_rdid,
.erase = spi_chip_erase_60_c7,
- .write = spi_chip_write,
+ .write = spi_chip_write_1,
.read = spi_chip_read,
},
@@ -1559,7 +1559,7 @@
.tested = TEST_UNTESTED,
.probe = probe_spi_rdid,
.erase = spi_chip_erase_c7,
- .write = spi_chip_write,
+ .write = spi_chip_write_256,
.read = spi_chip_read,
},
@@ -1573,7 +1573,7 @@
.tested = TEST_UNTESTED,
.probe = probe_spi_rdid,
.erase = spi_chip_erase_c7,
- .write = spi_chip_write,
+ .write = spi_chip_write_256,
.read = spi_chip_read,
},
@@ -1587,7 +1587,7 @@
.tested = TEST_UNTESTED,
.probe = probe_spi_rdid,
.erase = spi_chip_erase_c7,
- .write = spi_chip_write,
+ .write = spi_chip_write_256,
.read = spi_chip_read,
},
@@ -1601,7 +1601,7 @@
.tested = TEST_UNTESTED,
.probe = probe_spi_rdid,
.erase = spi_chip_erase_c7,
- .write = spi_chip_write,
+ .write = spi_chip_write_256,
.read = spi_chip_read,
},
@@ -1615,7 +1615,7 @@
.tested = TEST_UNTESTED,
.probe = probe_spi_res,
.erase = spi_chip_erase_c7,
- .write = spi_chip_write,
+ .write = spi_chip_write_256,
.read = spi_chip_read,
},
@@ -1629,7 +1629,7 @@
.tested = TEST_UNTESTED,
.probe = probe_spi_rdid,
.erase = spi_chip_erase_c7,
- .write = spi_chip_write,
+ .write = spi_chip_write_256,
.read = spi_chip_read,
},
@@ -1643,7 +1643,7 @@
.tested = TEST_OK_PREW,
.probe = probe_spi_rdid,
.erase = spi_chip_erase_c7,
- .write = spi_chip_write,
+ .write = spi_chip_write_256,
.read = spi_chip_read,
},
@@ -1657,7 +1657,7 @@
.tested = TEST_OK_PREW,
.probe = probe_spi_rdid,
.erase = spi_chip_erase_c7,
- .write = spi_chip_write,
+ .write = spi_chip_write_256,
.read = spi_chip_read,
},
@@ -1671,7 +1671,7 @@
.tested = TEST_UNTESTED,
.probe = probe_spi_rdid,
.erase = spi_chip_erase_c7,
- .write = spi_chip_write,
+ .write = spi_chip_write_256,
.read = spi_chip_read,
},
@@ -1685,7 +1685,7 @@
.tested = TEST_UNTESTED,
.probe = probe_spi_rdid,
.erase = spi_chip_erase_c7,
- .write = spi_chip_write,
+ .write = spi_chip_write_256,
.read = spi_chip_read,
},
@@ -1946,7 +1946,7 @@
.tested = TEST_UNTESTED,
.probe = probe_spi_rdid,
.erase = spi_chip_erase_c7,
- .write = spi_chip_write,
+ .write = spi_chip_write_256,
.read = spi_chip_read,
},
@@ -1960,7 +1960,7 @@
.tested = TEST_UNTESTED,
.probe = probe_spi_rdid,
.erase = spi_chip_erase_c7,
- .write = spi_chip_write,
+ .write = spi_chip_write_256,
.read = spi_chip_read,
},
@@ -1974,7 +1974,7 @@
.tested = TEST_OK_PREW,
.probe = probe_spi_rdid,
.erase = spi_chip_erase_c7,
- .write = spi_chip_write,
+ .write = spi_chip_write_256,
.read = spi_chip_read,
},
@@ -1988,7 +1988,7 @@
.tested = TEST_OK_PREW,
.probe = probe_spi_rdid,
.erase = spi_chip_erase_c7,
- .write = spi_chip_write,
+ .write = spi_chip_write_256,
.read = spi_chip_read,
},
Index: flashrom-SST25VF080B/spi.c
===================================================================
--- flashrom-SST25VF080B/spi.c (Revision 471)
+++ flashrom-SST25VF080B/spi.c (Arbeitskopie)
@@ -597,19 +597,41 @@
return 1;
}
-int spi_chip_write(struct flashchip *flash, uint8_t *buf)
+/*
+ * Program chip using firmware cycle byte programming. (SLOW!)
+ * This is for chips which can only handle one byte writes
+ * and for chips where memory mapped programming is impossible
+ * (e.g. due to size constraints in IT87* for over 512 kB)
+ */
+int spi_chip_write_1(struct flashchip *flash, uint8_t *buf)
{
+ int total_size = 1024 * flash->total_size;
+ int i;
+
+ spi_disable_blockprotect();
+ for (i = 0; i < total_size; i++) {
+ spi_write_enable();
+ spi_byte_program(i, buf[i]);
+ while (spi_read_status_register() & JEDEC_RDSR_BIT_WIP)
+ myusec_delay(10);
+ }
+
+ return 0;
+}
+
+int spi_chip_write_256(struct flashchip *flash, uint8_t *buf)
+{
switch (flashbus) {
case BUS_TYPE_IT87XX_SPI:
- return it8716f_spi_chip_write(flash, buf);
+ return it8716f_spi_chip_write_256(flash, buf);
case BUS_TYPE_SB600_SPI:
- return sb600_spi_write(flash, buf);
+ return sb600_spi_write_256(flash, buf);
case BUS_TYPE_ICH7_SPI:
case BUS_TYPE_ICH9_SPI:
case BUS_TYPE_VIA_SPI:
- return ich_spi_write(flash, buf);
+ return ich_spi_write_256(flash, buf);
case BUS_TYPE_WBSIO_SPI:
- return wbsio_spi_write(flash, buf);
+ return wbsio_spi_write_256(flash, buf);
default:
printf_debug
("%s called, but no SPI chipset/strapping detected\n",
@@ -627,7 +649,7 @@
case BUS_TYPE_WBSIO_SPI:
fprintf(stderr, "%s: impossible with Winbond SPI masters,"
" degrading to byte program\n", __func__);
- return spi_chip_write(flash, buf);
+ return spi_chip_write_1(flash, buf);
default:
break;
}
Index: flashrom-SST25VF080B/wbsio_spi.c
===================================================================
--- flashrom-SST25VF080B/wbsio_spi.c (Revision 471)
+++ flashrom-SST25VF080B/wbsio_spi.c (Arbeitskopie)
@@ -186,7 +186,7 @@
return 0;
}
-int wbsio_spi_write(struct flashchip *flash, uint8_t *buf)
+int wbsio_spi_write_256(struct flashchip *flash, uint8_t *buf)
{
int pos, size = flash->total_size * 1024;
Index: flashrom-SST25VF080B/sb600spi.c
===================================================================
--- flashrom-SST25VF080B/sb600spi.c (Revision 471)
+++ flashrom-SST25VF080B/sb600spi.c (Arbeitskopie)
@@ -64,7 +64,7 @@
return readarr[0];
}
-int sb600_spi_write(struct flashchip *flash, uint8_t *buf)
+int sb600_spi_write_256(struct flashchip *flash, uint8_t *buf)
{
int rc = 0, i;
int total_size = flash->total_size * 1024;
Index: flashrom-SST25VF080B/ichspi.c
===================================================================
--- flashrom-SST25VF080B/ichspi.c (Revision 471)
+++ flashrom-SST25VF080B/ichspi.c (Arbeitskopie)
@@ -707,7 +707,7 @@
return rc;
}
-int ich_spi_write(struct flashchip *flash, uint8_t * buf)
+int ich_spi_write_256(struct flashchip *flash, uint8_t * buf)
{
int i, j, rc = 0;
int total_size = flash->total_size * 1024;
--
http://www.hailfinger.org/
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: flashrom_spi_256_1_byte_write_infrastructure_SST25VF080B.diff
URL: <http://www.coreboot.org/pipermail/coreboot/attachments/20090507/c8ea49eb/attachment.ksh>
More information about the coreboot
mailing list