From: Siva Durga Prasad Paladugu Date: Tue, 29 Sep 2015 07:30:36 +0000 (+0530) Subject: sf: Add support for device SST26WF016B X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=b2f9da136c23388c60cd593b552692704fa6b1d6;p=thirdparty%2Fu-boot.git sf: Add support for device SST26WF016B 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 Signed-off-by: Michal Simek --- diff --git a/drivers/mtd/spi/sf_internal.h b/drivers/mtd/spi/sf_internal.h index 44f0e07db02..f8e426729f4 100644 --- a/drivers/mtd/spi/sf_internal.h +++ b/drivers/mtd/spi/sf_internal.h @@ -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); diff --git a/drivers/mtd/spi/sf_ops.c b/drivers/mtd/spi/sf_ops.c index 4cedbd56508..7fd0361d0ad 100644 --- a/drivers/mtd/spi/sf_ops.c +++ b/drivers/mtd/spi/sf_ops.c @@ -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) { diff --git a/drivers/mtd/spi/sf_params.c b/drivers/mtd/spi/sf_params.c index ded24ac3608..09dc6ca718c 100644 --- a/drivers/mtd/spi/sf_params.c +++ b/drivers/mtd/spi/sf_params.c @@ -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 diff --git a/drivers/mtd/spi/sf_probe.c b/drivers/mtd/spi/sf_probe.c index 3e57b5da833..c205b192efd 100644 --- a/drivers/mtd/spi/sf_probe.c +++ b/drivers/mtd/spi/sf_probe.c @@ -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; }