]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
sf: Add support for device SST26WF016B
authorSiva Durga Prasad Paladugu <siva.durga.paladugu@xilinx.com>
Tue, 29 Sep 2015 07:30:36 +0000 (13:00 +0530)
committerMichal Simek <michal.simek@xilinx.com>
Wed, 30 Sep 2015 20:33:29 +0000 (22:33 +0200)
This patch adds support for Microchip part
SST26WF016B. This device needs unlock
block protection command to be sent for
all the erase and write ops to be successful.

Signed-off-by: Siva Durga Prasad Paladugu <sivadur@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
drivers/mtd/spi/sf_internal.h
drivers/mtd/spi/sf_ops.c
drivers/mtd/spi/sf_params.c
drivers/mtd/spi/sf_probe.c

index 44f0e07db02da167424a033aebec4765547302bf..f8e426729f4fd5e06532308b795a8196ad7a0ab7 100644 (file)
@@ -43,6 +43,7 @@ enum {
        SST_BP          = 1 << 3,
        SST_WP          = 1 << 4,
        WR_QPP          = 1 << 5,
+       SST_LOCKBP      = 1 << 6,
 };
 
 #define SST_WR         (SST_BP | SST_WP)
@@ -112,6 +113,7 @@ enum {
 #ifdef CONFIG_SPI_FLASH_SST
 # define CMD_SST_BP            0x02    /* Byte Program */
 # define CMD_SST_AAI_WP                0xAD    /* Auto Address Incr Word Program */
+# define CMD_BLOCK_PROTECT_UNLOCK      0x98
 
 int sst_write_wp(struct spi_flash *flash, u32 offset, size_t len,
                const void *buf);
index 4cedbd56508d94e4616e1c8c24d893ba1f4c4f10..7fd0361d0adbbc90b2b9eb12b92a1e82654ea635 100644 (file)
@@ -62,6 +62,22 @@ int spi_flash_cmd_write_status(struct spi_flash *flash, u8 ws)
        return 0;
 }
 
+#if defined(CONFIG_SPI_FLASH_SST)
+int spi_flash_cmd_bp_unlock(struct spi_flash *flash)
+{
+       u8 cmd = CMD_BLOCK_PROTECT_UNLOCK;
+       int ret;
+
+       ret = spi_flash_read_common(flash, &cmd, 1, NULL, 0);
+       if (ret < 0) {
+               debug("SF: fail to unlock block protect\n");
+               return ret;
+       }
+
+       return 0;
+}
+#endif
+
 #if defined(CONFIG_SPI_FLASH_SPANSION) || defined(CONFIG_SPI_FLASH_WINBOND)
 int spi_flash_cmd_read_config(struct spi_flash *flash, u8 *rc)
 {
index ded24ac36080aa31f07bd0641560d4dc02c5e56b..09dc6ca718cde625a9a91121ae28501386de5bfe 100644 (file)
@@ -105,6 +105,7 @@ const struct spi_flash_params spi_flash_params_table[] = {
        {"SST25WF010",     0xbf2502, 0x0,       64 * 1024,     2, RD_NORM,          SECT_4K | SST_WR},
        {"SST25WF020",     0xbf2503, 0x0,       64 * 1024,     4, RD_NORM,          SECT_4K | SST_WR},
        {"SST25WF040",     0xbf2504, 0x0,       64 * 1024,     8, RD_NORM,          SECT_4K | SST_WR},
+       {"SST25WF016B",    0xbf2651, 0x0,        4 * 1024,   512, RD_NORM,          SST_LOCKBP | SECT_4K},
        {"SST25WF040B",    0x621613, 0x0,       64 * 1024,     8, RD_NORM,                   SECT_4K},
        {"SST25WF080",     0xbf2505, 0x0,       64 * 1024,    16, RD_NORM,          SECT_4K | SST_WR},
 #endif
index 3e57b5da833a067c6445096d8fa101459aca477c..c205b192efd5db9fcf3c627bb6c4a6bd51476d6d 100644 (file)
@@ -396,6 +396,17 @@ static int spi_flash_validate_params(struct spi_slave *spi, u8 *idcode,
                spi_flash_cmd_write_status(flash, 0);
 #endif
 
+#if defined(CONFIG_SPI_FLASH_SST)
+       if(params->flags == SST_LOCKBP) {
+               int ret;
+               ret = spi_flash_cmd_bp_unlock();
+               if (ret) {
+                       debug("SF: fail to unlock block protection\n");
+                       return ret;
+               }
+       }
+#endif
+
        return 0;
 }