summaryrefslogtreecommitdiff
path: root/spi25.c
diff options
context:
space:
mode:
authorhailfinger <hailfinger@2b7e53f0-3cfb-0310-b3e9-8179ed1497e1>2010-10-27 22:07:11 +0000
committerhailfinger <hailfinger@2b7e53f0-3cfb-0310-b3e9-8179ed1497e1>2010-10-27 22:07:11 +0000
commit13db454e0514b749ec93c6a66cff91f3e3a0c909 (patch)
tree5b8d6ec01a60208129a46e24a33ab0c18f9012c9 /spi25.c
parentf37c81a74401feed6ab21763af647248abded21e (diff)
downloadflashrom-13db454e0514b749ec93c6a66cff91f3e3a0c909.tar.gz
Fix internal offset calculations for SPI BYTE PROGRAM and SPI AAI PROGRAM.
The bug was invisible so far because we always started at offset 0. The pending partial write patch uses nonzero start offsets and trips over this bug. Clarify a few comments in IT87 SPI. Thanks to Idwer Vollering for reporting write breakage with my latest partial write patch. This should fix the underlying problem. Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net> Acked-by: Idwer Vollering <vidwer@gmail.com> git-svn-id: https://code.coreboot.org/svn/flashrom/trunk@1217 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
Diffstat (limited to 'spi25.c')
-rw-r--r--spi25.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/spi25.c b/spi25.c
index 39e9c8c..fc3173f 100644
--- a/spi25.c
+++ b/spi25.c
@@ -1309,7 +1309,7 @@ int spi_chip_write_1(struct flashchip *flash, uint8_t *buf, int start, int len)
int i, result = 0;
for (i = start; i < start + len; i++) {
- result = spi_byte_program(i, buf[i]);
+ result = spi_byte_program(i, buf[i - start]);
if (result)
return 1;
while (spi_read_status_register() & JEDEC_RDSR_BIT_WIP)
@@ -1377,6 +1377,14 @@ int spi_aai_write(struct flashchip *flash, uint8_t *buf, int start, int len)
if (spi_chip_write_1(flash, buf, start, start % 2))
return SPI_GENERIC_ERROR;
pos += start % 2;
+ cmds[1].writearr = (const unsigned char[]){
+ JEDEC_AAI_WORD_PROGRAM,
+ (pos >> 16) & 0xff,
+ (pos >> 8) & 0xff,
+ (pos & 0xff),
+ buf[pos - start],
+ buf[pos - start + 1]
+ };
/* Do not return an error for now. */
//return SPI_GENERIC_ERROR;
}
@@ -1406,8 +1414,8 @@ int spi_aai_write(struct flashchip *flash, uint8_t *buf, int start, int len)
/* Are there at least two more bytes to write? */
while (pos < start + len - 1) {
- cmd[1] = buf[pos++];
- cmd[2] = buf[pos++];
+ cmd[1] = buf[pos++ - start];
+ cmd[2] = buf[pos++ - start];
spi_send_command(JEDEC_AAI_WORD_PROGRAM_CONT_OUTSIZE, 0, cmd, NULL);
while (spi_read_status_register() & JEDEC_RDSR_BIT_WIP)
programmer_delay(10);
@@ -1420,7 +1428,7 @@ int spi_aai_write(struct flashchip *flash, uint8_t *buf, int start, int len)
/* Write remaining byte (if any). */
if (pos < start + len) {
- if (spi_chip_write_1(flash, buf + pos, pos, pos % 2))
+ if (spi_chip_write_1(flash, buf + pos - start, pos, pos % 2))
return SPI_GENERIC_ERROR;
pos += pos % 2;
}