mtd: spi-nor: add SPI_NOR_HAS_LOCK flag

Linux-MTD Mailing List linux-mtd at lists.infradead.org
Thu Mar 24 11:59:11 PDT 2016


Gitweb:     http://git.infradead.org/?p=mtd-2.6.git;a=commit;h=76a4707de5e18dc32d9cb4e990686140c5664a15
Commit:     76a4707de5e18dc32d9cb4e990686140c5664a15
Parent:     0618114e2c5dd059f8d22787e62e3f1723af68fc
Author:     Brian Norris <computersforpeace at gmail.com>
AuthorDate: Fri Jan 29 11:25:35 2016 -0800
Committer:  Brian Norris <computersforpeace at gmail.com>
CommitDate: Mon Mar 7 18:01:57 2016 -0800

    mtd: spi-nor: add SPI_NOR_HAS_LOCK flag
    
    We can't determine this purely by manufacturer type (see commit
    67b9bcd36906 ("mtd: spi-nor: fix Spansion regressions (aliased with
    Winbond)")), and it's not autodetectable by anything like SFDP. So make
    a new flag for it.
    
    Signed-off-by: Brian Norris <computersforpeace at gmail.com>
    Reviewed-by: Ezequiel Garcia <ezequiel at vanguardiasur.com.ar>
    Tested-by: Ezequiel Garcia <ezequiel at vanguardiasur.com.ar>
---
 drivers/mtd/spi-nor/spi-nor.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c
index 72d87c2..d1edafc 100644
--- a/drivers/mtd/spi-nor/spi-nor.c
+++ b/drivers/mtd/spi-nor/spi-nor.c
@@ -69,6 +69,7 @@ struct flash_info {
 #define SPI_NOR_DUAL_READ	BIT(5)	/* Flash supports Dual Read */
 #define SPI_NOR_QUAD_READ	BIT(6)	/* Flash supports Quad Read */
 #define USE_FSR			BIT(7)	/* use flag status register */
+#define SPI_NOR_HAS_LOCK	BIT(8)	/* Flash supports lock/unlock via SR */
 };
 
 #define JEDEC_MFR(info)	((info)->id[0])
@@ -1237,7 +1238,8 @@ int spi_nor_scan(struct spi_nor *nor, const char *name, enum read_mode mode)
 
 	if (JEDEC_MFR(info) == SNOR_MFR_ATMEL ||
 	    JEDEC_MFR(info) == SNOR_MFR_INTEL ||
-	    JEDEC_MFR(info) == SNOR_MFR_SST) {
+	    JEDEC_MFR(info) == SNOR_MFR_SST ||
+	    info->flags & SPI_NOR_HAS_LOCK) {
 		write_enable(nor);
 		write_sr(nor, 0);
 		spi_nor_wait_till_ready(nor);
@@ -1254,7 +1256,8 @@ int spi_nor_scan(struct spi_nor *nor, const char *name, enum read_mode mode)
 	mtd->_read = spi_nor_read;
 
 	/* NOR protection support for STmicro/Micron chips and similar */
-	if (JEDEC_MFR(info) == SNOR_MFR_MICRON) {
+	if (JEDEC_MFR(info) == SNOR_MFR_MICRON ||
+			info->flags & SPI_NOR_HAS_LOCK) {
 		nor->flash_lock = stm_lock;
 		nor->flash_unlock = stm_unlock;
 		nor->flash_is_locked = stm_is_locked;



More information about the linux-mtd-cvs mailing list