summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorVadim Bendebury <vbendeb@chromium.org>2011-09-14 13:28:19 -0700
committerVadim Bendebury <vbendeb@chromium.org>2011-09-15 12:34:53 -0700
commit0797d6dcb08ce12f7040a5252d304f6a862fa8b7 (patch)
treeb3fedfa3579dd090f269f2d102c51948cf873695 /drivers
parenta203fc396572861bdc5a410bd2a719ab84c7429a (diff)
Allow for smaller write units in Winbond SPI flash driver.
This CL is a Winbond SPI flash specific modification following the same pattern as the earlier Macronix SPI flash specific fix (http://gerrit.chromium.org/gerrit/7522). BUG=chromium-os:20105 TEST=manual . build a Newton bootloader image . program the image on a Newton device . restart the device . at the 'boot>' prompt run the following commands: setenv xyz 'this is a string' saveenv . reboot the device . at the 'boot>' prompt run 'printenv' Observe the environment include the new variable. Change-Id: Ic82751ba8adc4ce8576141899afa989a60249003 Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: http://gerrit.chromium.org/gerrit/7729 Reviewed-by: Stefan Reinauer <reinauer@google.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/mtd/spi/winbond.c16
1 files changed, 6 insertions, 10 deletions
diff --git a/drivers/mtd/spi/winbond.c b/drivers/mtd/spi/winbond.c
index ff2043f3d4..10bd6c4739 100644
--- a/drivers/mtd/spi/winbond.c
+++ b/drivers/mtd/spi/winbond.c
@@ -109,18 +109,14 @@ static int winbond_write(struct spi_flash *flash,
u32 offset, size_t len, const void *buf)
{
struct winbond_spi_flash *stm = to_winbond_spi_flash(flash);
- unsigned long page_addr;
unsigned long byte_addr;
unsigned long page_size;
- unsigned int page_shift;
size_t chunk_len;
size_t actual;
int ret;
u8 cmd[4];
- page_shift = stm->params->l2_page_size;
- page_size = (1 << page_shift);
- page_addr = offset / page_size;
+ page_size = min(1 << stm->params->l2_page_size, CONTROLLER_PAGE_LIMIT);
byte_addr = offset % page_size;
ret = spi_claim_bus(flash->spi);
@@ -133,9 +129,9 @@ static int winbond_write(struct spi_flash *flash,
chunk_len = min(len - actual, page_size - byte_addr);
cmd[0] = CMD_W25_PP;
- cmd[1] = page_addr >> (16 - page_shift);
- cmd[2] = page_addr << (page_shift - 8) | (byte_addr >> 8);
- cmd[3] = byte_addr;
+ cmd[1] = (offset >> 16) & 0xff;
+ cmd[2] = (offset >> 8) & 0xff;
+ cmd[3] = offset & 0xff;
debug("PP: 0x%p => cmd = { 0x%02x 0x%02x%02x%02x } chunk_len = %d\n",
buf + actual,
cmd[0], cmd[1], cmd[2], cmd[3], chunk_len);
@@ -157,12 +153,12 @@ static int winbond_write(struct spi_flash *flash,
if (ret)
goto out;
- page_addr++;
+ offset += chunk_len;
byte_addr = 0;
}
debug("SF: Winbond: Successfully programmed %u bytes @ 0x%x\n",
- len, offset);
+ len, offset - len);
ret = 0;
out: