diff options
author | Mike Frysinger <vapier@gentoo.org> | 2011-01-10 02:20:14 -0500 |
---|---|---|
committer | Wolfgang Denk <wd@denx.de> | 2011-04-11 21:00:55 +0200 |
commit | a4c3b40b33e41563077ea9ccbae7cac9d26ca38f (patch) | |
tree | 9f108ec5820f069a7c790c65aa1df6726f48c9e2 /drivers/mtd/spi/winbond.c | |
parent | e7b44eddbef88b1a922f8d82088ba236aad01caf (diff) | |
download | u-boot-imx-a4c3b40b33e41563077ea9ccbae7cac9d26ca38f.zip u-boot-imx-a4c3b40b33e41563077ea9ccbae7cac9d26ca38f.tar.gz u-boot-imx-a4c3b40b33e41563077ea9ccbae7cac9d26ca38f.tar.bz2 |
sf: unify read functions
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Diffstat (limited to 'drivers/mtd/spi/winbond.c')
-rw-r--r-- | drivers/mtd/spi/winbond.c | 40 |
1 files changed, 1 insertions, 39 deletions
diff --git a/drivers/mtd/spi/winbond.c b/drivers/mtd/spi/winbond.c index 8470a82..e88802f 100644 --- a/drivers/mtd/spi/winbond.c +++ b/drivers/mtd/spi/winbond.c @@ -105,44 +105,6 @@ static const struct winbond_spi_flash_params winbond_spi_flash_table[] = { }, }; -/* - * Assemble the address part of a command for Winbond devices in - * non-power-of-two page size mode. - */ -static void winbond_build_address(struct winbond_spi_flash *stm, u8 *cmd, u32 offset) -{ - unsigned long page_addr; - unsigned long byte_addr; - unsigned long page_size; - unsigned int page_shift; - - /* - * The "extra" space per page is the power-of-two page size - * divided by 32. - */ - page_shift = stm->params->l2_page_size; - page_size = (1 << page_shift); - page_addr = offset / page_size; - byte_addr = offset % page_size; - - cmd[0] = page_addr >> (16 - page_shift); - cmd[1] = page_addr << (page_shift - 8) | (byte_addr >> 8); - cmd[2] = byte_addr; -} - -static int winbond_read_fast(struct spi_flash *flash, - u32 offset, size_t len, void *buf) -{ - struct winbond_spi_flash *stm = to_winbond_spi_flash(flash); - u8 cmd[5]; - - cmd[0] = CMD_READ_ARRAY_FAST; - winbond_build_address(stm, cmd + 1, offset); - cmd[4] = 0x00; - - return spi_flash_read_common(flash, cmd, sizeof(cmd), buf, len); -} - static int winbond_write(struct spi_flash *flash, u32 offset, size_t len, const void *buf) { @@ -250,7 +212,7 @@ struct spi_flash *spi_flash_probe_winbond(struct spi_slave *spi, u8 *idcode) stm->flash.write = winbond_write; stm->flash.erase = winbond_erase; - stm->flash.read = winbond_read_fast; + stm->flash.read = spi_flash_cmd_read_fast; stm->flash.size = page_size * params->pages_per_sector * params->sectors_per_block * params->nr_blocks; |