diff options
author | Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net> | 2012-03-01 22:38:27 +0000 |
---|---|---|
committer | Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net> | 2012-03-01 22:38:27 +0000 |
commit | 10c8ce7b45ce8c941f4b568f116758fafd17ea9c (patch) | |
tree | d2ddcfc5b5c2f1e4f212280c7aa81f9ac2d42d96 | |
parent | 04d241d122aadd0882b9e16359f6eeb1f5a98a88 (diff) | |
download | flashrom-10c8ce7b45ce8c941f4b568f116758fafd17ea9c.zip flashrom-10c8ce7b45ce8c941f4b568f116758fafd17ea9c.tar.gz |
Fix parallel-style programmer access from ITE IT87/Winbond W83627 SPI
The ITE IT87 SPI driver uses a trick to speed up reading and writing:
If a flash chip is 512 kByte or less, the flash chip can be completely
mapped in memory and both read and write accesses are faster that way.
The current IT87 SPI code did use the parallel programmer interface for
memory mapped reads and writes, but that's the wrong abstraction. It has
been fixed to use mmio_read*/mmio_write* for that purpose.
The Winbond W83627 SPI driver uses the same trick in its read path for
all supported chip sizes. Fix it the same way.
Switch internal_chip_readn to use mmio_readn as proper abstraction.
Kudos to Michael Karcher for spotting the bugs.
Reported-by: Johan Svensson <flashrom.js@crypt.se>
Tested-by: Johan Svensson <flashrom.js@crypt.se>
Corresponding to flashrom svn r1511.
Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Acked-by: Michael Karcher <flashrom@mkarcher.dialup.fu-berlin.de>
-rw-r--r-- | hwaccess.c | 6 | ||||
-rw-r--r-- | internal.c | 2 | ||||
-rw-r--r-- | it87spi.c | 4 | ||||
-rw-r--r-- | programmer.h | 1 | ||||
-rw-r--r-- | wbsio_spi.c | 3 |
5 files changed, 12 insertions, 4 deletions
@@ -169,6 +169,12 @@ uint32_t mmio_readl(void *addr) return *(volatile uint32_t *) addr; } +void mmio_readn(void *addr, uint8_t *buf, size_t len) +{ + memcpy(buf, addr, len); + return; +} + void mmio_le_writeb(uint8_t val, void *addr) { mmio_writeb(cpu_to_le8(val), addr); @@ -387,6 +387,6 @@ static uint32_t internal_chip_readl(const struct flashctx *flash, static void internal_chip_readn(const struct flashctx *flash, uint8_t *buf, const chipaddr addr, size_t len) { - memcpy(buf, (void *)addr, len); + mmio_readn((void *)addr, buf, len); return; } @@ -330,7 +330,7 @@ static int it8716f_spi_page_program(struct flashctx *flash, uint8_t *buf, OUTB(0x06, it8716f_flashport + 1); OUTB(((2 + (fast_spi ? 1 : 0)) << 4), it8716f_flashport); for (i = 0; i < flash->page_size; i++) - chip_writeb(flash, buf[i], bios + start + i); + mmio_writeb(buf[i], (void *)(bios + start + i)); OUTB(0, it8716f_flashport); /* Wait until the Write-In-Progress bit is cleared. * This usually takes 1-10 ms, so wait in 1 ms steps. @@ -356,7 +356,7 @@ static int it8716f_spi_chip_read(struct flashctx *flash, uint8_t *buf, if ((flash->total_size * 1024 > 512 * 1024)) { spi_read_chunked(flash, buf, start, len, 3); } else { - read_memmapped(flash, buf, start, len); + mmio_readn((void *)(flash->virtual_memory + start), buf, len); } return 0; diff --git a/programmer.h b/programmer.h index 240e1af..c99e37f 100644 --- a/programmer.h +++ b/programmer.h @@ -312,6 +312,7 @@ void mmio_writel(uint32_t val, void *addr); uint8_t mmio_readb(void *addr); uint16_t mmio_readw(void *addr); uint32_t mmio_readl(void *addr); +void mmio_readn(void *addr, uint8_t *buf, size_t len); void mmio_le_writeb(uint8_t val, void *addr); void mmio_le_writew(uint16_t val, void *addr); void mmio_le_writel(uint32_t val, void *addr); diff --git a/wbsio_spi.c b/wbsio_spi.c index 740a48c..774890e 100644 --- a/wbsio_spi.c +++ b/wbsio_spi.c @@ -202,7 +202,8 @@ static int wbsio_spi_send_command(struct flashctx *flash, unsigned int writecnt, static int wbsio_spi_read(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len) { - return read_memmapped(flash, buf, start, len); + mmio_readn((void *)(flash->virtual_memory + start), buf, len); + return 0; } #endif |