generic: mtd: backport SPI_NOR_HAS_LOCK
[openwrt/openwrt.git] / target / linux / generic / patches-4.4 / 048-mtd-spi-nor-backport-SPI_NOR_HAS_LOCK-flag.patch
1 From 76a4707de5e18dc32d9cb4e990686140c5664a15 Mon Sep 17 00:00:00 2001
2 From: Brian Norris <computersforpeace@gmail.com>
3 Date: Fri, 29 Jan 2016 11:25:35 -0800
4 Subject: [PATCH] mtd: spi-nor: add SPI_NOR_HAS_LOCK flag
5
6 We can't determine this purely by manufacturer type (see commit
7 67b9bcd36906 ("mtd: spi-nor: fix Spansion regressions (aliased with
8 Winbond)")), and it's not autodetectable by anything like SFDP. So make
9 a new flag for it.
10
11 Signed-off-by: Brian Norris <computersforpeace@gmail.com>
12 Reviewed-by: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>
13 Tested-by: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>
14 ---
15 drivers/mtd/spi-nor/spi-nor.c | 7 +++++--
16 1 file changed, 5 insertions(+), 2 deletions(-)
17
18 diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c
19 index 72d87c2..d1edafc 100644
20 --- a/drivers/mtd/spi-nor/spi-nor.c
21 +++ b/drivers/mtd/spi-nor/spi-nor.c
22 @@ -68,6 +68,7 @@ struct flash_info {
23 #define SPI_NOR_DUAL_READ 0x20 /* Flash supports Dual Read */
24 #define SPI_NOR_QUAD_READ 0x40 /* Flash supports Quad Read */
25 #define USE_FSR 0x80 /* use flag status register */
26 +#define SPI_NOR_HAS_LOCK 0x100 /* Flash supports lock/unlock via SR */
27 };
28
29 #define JEDEC_MFR(info) ((info)->id[0])
30 @@ -1156,7 +1157,8 @@ int spi_nor_scan(struct spi_nor *nor, co
31
32 if (JEDEC_MFR(info) == SNOR_MFR_ATMEL ||
33 JEDEC_MFR(info) == SNOR_MFR_INTEL ||
34 - JEDEC_MFR(info) == SNOR_MFR_SST) {
35 + JEDEC_MFR(info) == SNOR_MFR_SST ||
36 + info->flags & SPI_NOR_HAS_LOCK) {
37 write_enable(nor);
38 write_sr(nor, 0);
39 }
40 @@ -1172,7 +1174,8 @@ int spi_nor_scan(struct spi_nor *nor, co
41 mtd->_read = spi_nor_read;
42
43 /* NOR protection support for STmicro/Micron chips and similar */
44 - if (JEDEC_MFR(info) == SNOR_MFR_MICRON) {
45 + if (JEDEC_MFR(info) == SNOR_MFR_MICRON ||
46 + info->flags & SPI_NOR_HAS_LOCK) {
47 nor->flash_lock = stm_lock;
48 nor->flash_unlock = stm_unlock;
49 nor->flash_is_locked = stm_is_locked;