]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
sf: winbond: Add initial rd|wr_cmd support
authorJagannadha Sutradharudu Teki <jaganna@xilinx.com>
Tue, 20 Aug 2013 08:56:20 +0000 (14:26 +0530)
committerMichal Simek <michal.simek@xilinx.com>
Wed, 21 Aug 2013 07:55:25 +0000 (09:55 +0200)
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 <jaganna@xilinx.com>
drivers/mtd/spi/winbond.c

index c399bf14d1f6ec52c719ec26e55c83ea2d0ea3d4..9181f1418e13c7dd2452fdee9bd292f057e65082 100644 (file)
@@ -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;