123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115 |
- 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 0000000000000000000000000000000000000000..2c2e5f32259416f0cc7f342e420ffbd32c139d97
- --- /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 0000000000000000000000000000000000000000..a0573d5aea939c965cb44b2e72a2b7d498b0a5cd
- --- /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)
|