summaryrefslogtreecommitdiffstats
path: root/spi.c
diff options
context:
space:
mode:
authorCarl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>2010-07-14 16:19:05 +0000
committerCarl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>2010-07-14 16:19:05 +0000
commit9a795d83fbb8842a271d5e037dc983a57b0419fd (patch)
treea9049f708d0ab7d42d122fecd23855aaa819c5bc /spi.c
parent1748c5701f77ab7164ab3311f37abc356d825ccb (diff)
downloadast2050-flashrom-9a795d83fbb8842a271d5e037dc983a57b0419fd.zip
ast2050-flashrom-9a795d83fbb8842a271d5e037dc983a57b0419fd.tar.gz
Convert SPI chips to partial write
However, wrap the write functions in a compat layer to allow converting the rest of flashrom later. Tested on Intel NM10 by David Hendricks. Corresponding to flashrom svn r1080. Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net> Acked-by: Michael Karcher <flashrom@mkarcher.dialup.fu-berlin.de>
Diffstat (limited to 'spi.c')
-rw-r--r--spi.c34
1 files changed, 29 insertions, 5 deletions
diff --git a/spi.c b/spi.c
index ea64882..94dbe9e 100644
--- a/spi.c
+++ b/spi.c
@@ -66,7 +66,7 @@ const struct spi_programmer spi_programmer[] = {
.command = sb600_spi_send_command,
.multicommand = default_spi_send_multicommand,
.read = sb600_spi_read,
- .write_256 = sb600_spi_write_1,
+ .write_256 = sb600_spi_write_256,
},
{ /* SPI_CONTROLLER_VIA */
@@ -99,7 +99,7 @@ const struct spi_programmer spi_programmer[] = {
.command = dummy_spi_send_command,
.multicommand = default_spi_send_multicommand,
.read = dummy_spi_read,
- .write_256 = NULL,
+ .write_256 = dummy_spi_write_256,
},
#endif
@@ -117,7 +117,7 @@ const struct spi_programmer spi_programmer[] = {
.command = dediprog_spi_send_command,
.multicommand = default_spi_send_multicommand,
.read = dediprog_spi_read,
- .write_256 = spi_chip_write_1,
+ .write_256 = spi_chip_write_1_new,
},
#endif
@@ -196,8 +196,11 @@ int spi_chip_read(struct flashchip *flash, uint8_t *buf, int start, int len)
/*
* Program chip using page (256 bytes) programming.
* Some SPI masters can't do this, they use single byte programming instead.
+ * The redirect to single byte programming is achieved by setting
+ * .write_256 = spi_chip_write_1
*/
-int spi_chip_write_256(struct flashchip *flash, uint8_t *buf)
+/* real chunksize is up to 256, logical chunksize is 256 */
+int spi_chip_write_256_new(struct flashchip *flash, uint8_t *buf, int start, int len)
{
if (!spi_programmer[spi_controller].write_256) {
msg_perr("%s called, but SPI page write is unsupported on this "
@@ -206,7 +209,28 @@ int spi_chip_write_256(struct flashchip *flash, uint8_t *buf)
return 1;
}
- return spi_programmer[spi_controller].write_256(flash, buf);
+ return spi_programmer[spi_controller].write_256(flash, buf, start, len);
+}
+
+/* Wrapper function until the generic code is converted to partial writes. */
+int spi_chip_write_256(struct flashchip *flash, uint8_t *buf)
+{
+ int ret;
+
+ spi_disable_blockprotect();
+ msg_pinfo("Erasing flash before programming... ");
+ if (erase_flash(flash)) {
+ msg_perr("ERASE FAILED!\n");
+ return -1;
+ }
+ msg_pinfo("done.\n");
+ msg_pinfo("Programming flash... ");
+ ret = spi_chip_write_256_new(flash, buf, 0, flash->total_size * 1024);
+ if (!ret)
+ msg_pinfo("done.\n");
+ else
+ msg_pinfo("\n");
+ return ret;
}
/*
OpenPOWER on IntegriCloud