parent
5a31cacee4
commit
1f400189cf
2012
patches/openwrt/0026-kernel-backport-spi-nor-driver-from-4.4.9.patch
Normal file
2012
patches/openwrt/0026-kernel-backport-spi-nor-driver-from-4.4.9.patch
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,115 @@
|
|||||||
|
From: Matthias Schiffer <mschiffer@universe-factory.net>
|
||||||
|
Date: Sat, 7 May 2016 00:17:55 +0200
|
||||||
|
Subject: kernel: mtd: spi-nor: wait until status register writes are ready
|
||||||
|
|
||||||
|
diff --git a/target/linux/generic/patches-3.18/094-0001-mtd-spi-nor-wait-until-lock-unlock-operations-are-re.patch b/target/linux/generic/patches-3.18/094-0001-mtd-spi-nor-wait-until-lock-unlock-operations-are-re.patch
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000..2c2e5f3
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/target/linux/generic/patches-3.18/094-0001-mtd-spi-nor-wait-until-lock-unlock-operations-are-re.patch
|
||||||
|
@@ -0,0 +1,66 @@
|
||||||
|
+From 32321e950d8a237d7e8f3a9b76220007dfa87544 Mon Sep 17 00:00:00 2001
|
||||||
|
+Message-Id: <32321e950d8a237d7e8f3a9b76220007dfa87544.1462572686.git.mschiffer@universe-factory.net>
|
||||||
|
+From: =?UTF-8?q?Ezequiel=20Garc=C3=ADa?= <ezequiel@vanguardiasur.com.ar>
|
||||||
|
+Date: Mon, 28 Dec 2015 17:54:51 -0300
|
||||||
|
+Subject: [PATCH] mtd: spi-nor: wait until lock/unlock operations are ready
|
||||||
|
+
|
||||||
|
+On Micron and Numonyx devices, the status register write command
|
||||||
|
+(WRSR), raises a work-in-progress bit (WIP) on the status register.
|
||||||
|
+The datasheets for these devices specify that while the status
|
||||||
|
+register write is in progress, the status register WIP bit can still
|
||||||
|
+be read to check the end of the operation.
|
||||||
|
+
|
||||||
|
+This commit adds a wait_till_ready call on lock/unlock operations,
|
||||||
|
+which is required for Micron and Numonyx but should be harmless for
|
||||||
|
+others. This is needed to prevent applications from issuing erase or
|
||||||
|
+program operations before the unlock operation is completed.
|
||||||
|
+
|
||||||
|
+Reported-by: Stas Sergeev <stsp@list.ru>
|
||||||
|
+Signed-off-by: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>
|
||||||
|
+Signed-off-by: Brian Norris <computersforpeace@gmail.com>
|
||||||
|
+---
|
||||||
|
+ drivers/mtd/spi-nor/spi-nor.c | 12 ++++++++++--
|
||||||
|
+ 1 file changed, 10 insertions(+), 2 deletions(-)
|
||||||
|
+
|
||||||
|
+--- a/drivers/mtd/spi-nor/spi-nor.c
|
||||||
|
++++ b/drivers/mtd/spi-nor/spi-nor.c
|
||||||
|
+@@ -462,6 +462,7 @@ static int stm_lock(struct spi_nor *nor,
|
||||||
|
+ u8 status_old, status_new;
|
||||||
|
+ u8 mask = SR_BP2 | SR_BP1 | SR_BP0;
|
||||||
|
+ u8 shift = ffs(mask) - 1, pow, val;
|
||||||
|
++ int ret;
|
||||||
|
+
|
||||||
|
+ status_old = read_sr(nor);
|
||||||
|
+
|
||||||
|
+@@ -498,7 +499,10 @@ static int stm_lock(struct spi_nor *nor,
|
||||||
|
+ return -EINVAL;
|
||||||
|
+
|
||||||
|
+ write_enable(nor);
|
||||||
|
+- return write_sr(nor, status_new);
|
||||||
|
++ ret = write_sr(nor, status_new);
|
||||||
|
++ if (ret)
|
||||||
|
++ return ret;
|
||||||
|
++ return spi_nor_wait_till_ready(nor);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ /*
|
||||||
|
+@@ -512,6 +516,7 @@ static int stm_unlock(struct spi_nor *no
|
||||||
|
+ uint8_t status_old, status_new;
|
||||||
|
+ u8 mask = SR_BP2 | SR_BP1 | SR_BP0;
|
||||||
|
+ u8 shift = ffs(mask) - 1, pow, val;
|
||||||
|
++ int ret;
|
||||||
|
+
|
||||||
|
+ status_old = read_sr(nor);
|
||||||
|
+
|
||||||
|
+@@ -546,7 +551,10 @@ static int stm_unlock(struct spi_nor *no
|
||||||
|
+ return -EINVAL;
|
||||||
|
+
|
||||||
|
+ write_enable(nor);
|
||||||
|
+- return write_sr(nor, status_new);
|
||||||
|
++ ret = write_sr(nor, status_new);
|
||||||
|
++ if (ret)
|
||||||
|
++ return ret;
|
||||||
|
++ return spi_nor_wait_till_ready(nor);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ /*
|
||||||
|
diff --git a/target/linux/generic/patches-3.18/094-0002-mtd-spi-nor-wait-for-SR_WIP-to-clear-on-initial-unlo.patch b/target/linux/generic/patches-3.18/094-0002-mtd-spi-nor-wait-for-SR_WIP-to-clear-on-initial-unlo.patch
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000..a0573d5
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/target/linux/generic/patches-3.18/094-0002-mtd-spi-nor-wait-for-SR_WIP-to-clear-on-initial-unlo.patch
|
||||||
|
@@ -0,0 +1,33 @@
|
||||||
|
+From edf891ef9ab773363f8e58022a26d7d31604aed6 Mon Sep 17 00:00:00 2001
|
||||||
|
+Message-Id: <edf891ef9ab773363f8e58022a26d7d31604aed6.1462572703.git.mschiffer@universe-factory.net>
|
||||||
|
+From: Brian Norris <computersforpeace@gmail.com>
|
||||||
|
+Date: Fri, 29 Jan 2016 11:25:30 -0800
|
||||||
|
+Subject: [PATCH] mtd: spi-nor: wait for SR_WIP to clear on initial unlock
|
||||||
|
+
|
||||||
|
+Fixup a piece leftover by commit 32321e950d8a ("mtd: spi-nor: wait until
|
||||||
|
+lock/unlock operations are ready"). That commit made us wait for the WIP
|
||||||
|
+bit to settle after lock/unlock operations, but it missed the open-coded
|
||||||
|
+"unlock" that happens at probe() time.
|
||||||
|
+
|
||||||
|
+We should probably have this code utilize the unlock() routines in the
|
||||||
|
+future, to avoid duplication, but unfortunately, flash which need to be
|
||||||
|
+unlocked don't all have a proper ->flash_unlock() callback.
|
||||||
|
+
|
||||||
|
+Signed-off-by: Brian Norris <computersforpeace@gmail.com>
|
||||||
|
+Cc: Stas Sergeev <stsp@users.sourceforge.net>
|
||||||
|
+Reviewed-by: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>
|
||||||
|
+Tested-by: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>
|
||||||
|
+---
|
||||||
|
+ drivers/mtd/spi-nor/spi-nor.c | 1 +
|
||||||
|
+ 1 file changed, 1 insertion(+)
|
||||||
|
+
|
||||||
|
+--- a/drivers/mtd/spi-nor/spi-nor.c
|
||||||
|
++++ b/drivers/mtd/spi-nor/spi-nor.c
|
||||||
|
+@@ -1167,6 +1167,7 @@ int spi_nor_scan(struct spi_nor *nor, co
|
||||||
|
+ JEDEC_MFR(info) == SNOR_MFR_SST) {
|
||||||
|
+ write_enable(nor);
|
||||||
|
+ write_sr(nor, 0);
|
||||||
|
++ spi_nor_wait_till_ready(nor);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ if (!mtd->name)
|
@ -0,0 +1,56 @@
|
|||||||
|
From: Matthias Schiffer <mschiffer@universe-factory.net>
|
||||||
|
Date: Sat, 7 May 2016 00:29:06 +0200
|
||||||
|
Subject: kernel: mtd: spi-nor: unlock Winbond flashs
|
||||||
|
|
||||||
|
diff --git a/target/linux/generic/patches-3.18/463-Revert-mtd-spi-nor-fix-Spansion-regressions-aliased-.patch b/target/linux/generic/patches-3.18/463-Revert-mtd-spi-nor-fix-Spansion-regressions-aliased-.patch
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000..4682b7a
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/target/linux/generic/patches-3.18/463-Revert-mtd-spi-nor-fix-Spansion-regressions-aliased-.patch
|
||||||
|
@@ -0,0 +1,46 @@
|
||||||
|
+From 20bbd73b6b04677a73933830363ab3178adc2ce9 Mon Sep 17 00:00:00 2001
|
||||||
|
+Message-Id: <20bbd73b6b04677a73933830363ab3178adc2ce9.1462573588.git.mschiffer@universe-factory.net>
|
||||||
|
+From: Matthias Schiffer <mschiffer@universe-factory.net>
|
||||||
|
+Date: Sat, 7 May 2016 00:26:23 +0200
|
||||||
|
+Subject: [PATCH] Revert "mtd: spi-nor: fix Spansion regressions (aliased with
|
||||||
|
+ Winbond)"
|
||||||
|
+
|
||||||
|
+This reverts commit 67b9bcd36906e12a15ffec19463afbbd6a41660e.
|
||||||
|
+---
|
||||||
|
+ drivers/mtd/spi-nor/spi-nor.c | 6 ++++--
|
||||||
|
+ include/linux/mtd/spi-nor.h | 2 +-
|
||||||
|
+ 2 files changed, 5 insertions(+), 3 deletions(-)
|
||||||
|
+
|
||||||
|
+--- a/drivers/mtd/spi-nor/spi-nor.c
|
||||||
|
++++ b/drivers/mtd/spi-nor/spi-nor.c
|
||||||
|
+@@ -1165,7 +1165,8 @@ int spi_nor_scan(struct spi_nor *nor, co
|
||||||
|
+ if (JEDEC_MFR(info) == SNOR_MFR_ATMEL ||
|
||||||
|
+ JEDEC_MFR(info) == SNOR_MFR_INTEL ||
|
||||||
|
+ JEDEC_MFR(info) == SNOR_MFR_MACRONIX ||
|
||||||
|
+- JEDEC_MFR(info) == SNOR_MFR_SST) {
|
||||||
|
++ JEDEC_MFR(info) == SNOR_MFR_SST ||
|
||||||
|
++ JEDEC_MFR(info) == SNOR_MFR_WINBOND) {
|
||||||
|
+ write_enable(nor);
|
||||||
|
+ write_sr(nor, 0);
|
||||||
|
+ spi_nor_wait_till_ready(nor);
|
||||||
|
+@@ -1182,7 +1183,8 @@ int spi_nor_scan(struct spi_nor *nor, co
|
||||||
|
+ 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 ||
|
||||||
|
++ JEDEC_MFR(info) == SNOR_MFR_WINBOND) {
|
||||||
|
+ nor->flash_lock = stm_lock;
|
||||||
|
+ nor->flash_unlock = stm_unlock;
|
||||||
|
+ nor->flash_is_locked = stm_is_locked;
|
||||||
|
+--- a/include/linux/mtd/spi-nor.h
|
||||||
|
++++ b/include/linux/mtd/spi-nor.h
|
||||||
|
+@@ -25,7 +25,7 @@
|
||||||
|
+ #define SNOR_MFR_MACRONIX CFI_MFR_MACRONIX
|
||||||
|
+ #define SNOR_MFR_SPANSION CFI_MFR_AMD
|
||||||
|
+ #define SNOR_MFR_SST CFI_MFR_SST
|
||||||
|
+-#define SNOR_MFR_WINBOND 0xef /* Also used by some Spansion */
|
||||||
|
++#define SNOR_MFR_WINBOND 0xef
|
||||||
|
+
|
||||||
|
+ /*
|
||||||
|
+ * Note on opcode nomenclature: some opcodes have a format like
|
Loading…
Reference in New Issue
Block a user