Skip to content

Commit 76a4707

Browse files
mtd: spi-nor: add SPI_NOR_HAS_LOCK flag
We can't determine this purely by manufacturer type (see commit 67b9bcd ("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@gmail.com> Reviewed-by: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar> Tested-by: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>
1 parent 0618114 commit 76a4707

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

‎drivers/mtd/spi-nor/spi-nor.c‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ struct flash_info {
6969
#define SPI_NOR_DUAL_READ BIT(5) /* Flash supports Dual Read */
7070
#define SPI_NOR_QUAD_READ BIT(6) /* Flash supports Quad Read */
7171
#define USE_FSR BIT(7) /* use flag status register */
72+
#define SPI_NOR_HAS_LOCK BIT(8) /* Flash supports lock/unlock via SR */
7273
};
7374

7475
#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)
12371238

12381239
if (JEDEC_MFR(info) == SNOR_MFR_ATMEL ||
12391240
JEDEC_MFR(info) == SNOR_MFR_INTEL ||
1240-
JEDEC_MFR(info) == SNOR_MFR_SST) {
1241+
JEDEC_MFR(info) == SNOR_MFR_SST ||
1242+
info->flags & SPI_NOR_HAS_LOCK) {
12411243
write_enable(nor);
12421244
write_sr(nor, 0);
12431245
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)
12541256
mtd->_read = spi_nor_read;
12551257

12561258
/* NOR protection support for STmicro/Micron chips and similar */
1257-
if (JEDEC_MFR(info) == SNOR_MFR_MICRON) {
1259+
if (JEDEC_MFR(info) == SNOR_MFR_MICRON ||
1260+
info->flags & SPI_NOR_HAS_LOCK) {
12581261
nor->flash_lock = stm_lock;
12591262
nor->flash_unlock = stm_unlock;
12601263
nor->flash_is_locked = stm_is_locked;

0 commit comments

Comments
 (0)