From 4519cd867eaf7524181a8b6eb3ec25ae1e6d4196 Mon Sep 17 00:00:00 2001 From: Jagannadha Sutradharudu Teki Date: Tue, 20 Aug 2013 14:26:20 +0530 Subject: [PATCH] sf: winbond: Add initial rd|wr_cmd support This patch adds rd|wr_cmd support by detecting the fastest command w.r.t command initialized by the controller. Added possible 3-byte address commands support to W25Q256 SPI flash. Signed-off-by: Jagannadha Sutradharudu Teki --- drivers/mtd/spi/winbond.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/drivers/mtd/spi/winbond.c b/drivers/mtd/spi/winbond.c index c399bf14d1f..9181f1418e1 100644 --- a/drivers/mtd/spi/winbond.c +++ b/drivers/mtd/spi/winbond.c @@ -13,6 +13,8 @@ struct winbond_spi_flash_params { uint16_t id; uint16_t nr_blocks; + u8 rd_cmd; + u8 wr_cmd; const char *name; }; @@ -80,6 +82,8 @@ static const struct winbond_spi_flash_params winbond_spi_flash_table[] = { { .id = 0x4019, .nr_blocks = 512, + .rd_cmd = READ_CMD_FULL, + .wr_cmd = PAGE_PROGRAM | QUAD_PAGE_PROGRAM, .name = "W25Q256", }, { @@ -114,6 +118,7 @@ struct spi_flash *spi_flash_probe_winbond(struct spi_slave *spi, u8 *idcode) const struct winbond_spi_flash_params *params; struct spi_flash *flash; unsigned int i; + u8 cmd; for (i = 0; i < ARRAY_SIZE(winbond_spi_flash_table); i++) { params = &winbond_spi_flash_table[i]; @@ -133,6 +138,20 @@ struct spi_flash *spi_flash_probe_winbond(struct spi_slave *spi, u8 *idcode) return NULL; } + /* Look for the fastest read cmd */ + cmd = fls(params->rd_cmd & flash->spi->rd_cmd); + if (cmd) { + cmd = spi_read_cmds_array[cmd - 1]; + flash->read_cmd = cmd; + } + + /* Look for the fastest write cmd */ + cmd = fls(params->wr_cmd & flash->spi->wr_cmd); + if (cmd) { + cmd = spi_write_cmds_array[cmd - 1]; + flash->write_cmd = cmd; + } + flash->page_size = 256; flash->sector_size = (idcode[1] == 0x20) ? 65536 : 4096; flash->size = 4096 * 16 * params->nr_blocks; -- 2.47.3