]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
sf: stmicro: Add initial rd|wr_cmd support
authorJagannadha Sutradharudu Teki <jaganna@xilinx.com>
Tue, 20 Aug 2013 09:31:44 +0000 (15:01 +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 N25Q128*
SPI flash.

Signed-off-by: Jagannadha Sutradharudu Teki <jaganna@xilinx.com>
drivers/mtd/spi/stmicro.c

index 9b2f8c2899af18b062f04c2c13ff1ff49c3a0807..7c9bd5e2d9937a641a8ae4df04a3f931e9b09e31 100644 (file)
@@ -40,6 +40,8 @@ struct stmicro_spi_flash_params {
        u16 id;
        u16 pages_per_sector;
        u16 nr_sectors;
+       u8 rd_cmd;
+       u8 wr_cmd;
        const char *name;
 };
 
@@ -120,12 +122,16 @@ static const struct stmicro_spi_flash_params stmicro_spi_flash_table[] = {
                .id = 0xba18,
                .pages_per_sector = 256,
                .nr_sectors = 256,
+               .rd_cmd = READ_CMD_FULL,
+               .wr_cmd = PAGE_PROGRAM | QUAD_PAGE_PROGRAM,
                .name = "N25Q128",
        },
        {
                .id = 0xbb18,
                .pages_per_sector = 256,
                .nr_sectors = 256,
+               .rd_cmd = READ_CMD_FULL,
+               .wr_cmd = PAGE_PROGRAM | QUAD_PAGE_PROGRAM,
                .name = "N25Q128A",
        },
        {
@@ -172,6 +178,7 @@ struct spi_flash *spi_flash_probe_stmicro(struct spi_slave *spi, u8 * idcode)
        struct spi_flash *flash;
        unsigned int i;
        u16 id;
+       u8 cmd;
 
        if (idcode[0] == 0xff) {
                i = spi_flash_cmd(spi, CMD_M25PXX_RES,
@@ -206,6 +213,20 @@ struct spi_flash *spi_flash_probe_stmicro(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 = 256 * params->pages_per_sector;