kernel: remove linux 3.18 support
[openwrt/staging/chunkeey.git] / target / linux / generic / pending-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 --- a/drivers/mtd/spi-nor/spi-nor.c
19 +++ b/drivers/mtd/spi-nor/spi-nor.c
20 @@ -68,6 +68,7 @@ struct flash_info {
21 #define SPI_NOR_DUAL_READ 0x20 /* Flash supports Dual Read */
22 #define SPI_NOR_QUAD_READ 0x40 /* Flash supports Quad Read */
23 #define USE_FSR 0x80 /* use flag status register */
24 +#define SPI_NOR_HAS_LOCK 0x100 /* Flash supports lock/unlock via SR */
25 };
26
27 #define JEDEC_MFR(info) ((info)->id[0])
28 @@ -1163,7 +1164,8 @@ int spi_nor_scan(struct spi_nor *nor, co
29
30 if (JEDEC_MFR(info) == SNOR_MFR_ATMEL ||
31 JEDEC_MFR(info) == SNOR_MFR_INTEL ||
32 - JEDEC_MFR(info) == SNOR_MFR_SST) {
33 + JEDEC_MFR(info) == SNOR_MFR_SST ||
34 + info->flags & SPI_NOR_HAS_LOCK) {
35 write_enable(nor);
36 write_sr(nor, 0);
37 }
38 @@ -1179,7 +1181,8 @@ int spi_nor_scan(struct spi_nor *nor, co
39 mtd->_read = spi_nor_read;
40
41 /* NOR protection support for STmicro/Micron chips and similar */
42 - if (JEDEC_MFR(info) == SNOR_MFR_MICRON) {
43 + if (JEDEC_MFR(info) == SNOR_MFR_MICRON ||
44 + info->flags & SPI_NOR_HAS_LOCK) {
45 nor->flash_lock = stm_lock;
46 nor->flash_unlock = stm_unlock;
47 nor->flash_is_locked = stm_is_locked;