* [PATCH] driver/mtd/spi-nor: Regression lock/unlock fail
@ 2019-09-19 1:49 Shreyas Joshi
2019-09-19 5:05 ` Tudor.Ambarus
0 siblings, 1 reply; 4+ messages in thread
From: Shreyas Joshi @ 2019-09-19 1:49 UTC (permalink / raw)
To: marek.vasut, tudor.ambarus, linux-mtd, shreyasjoshi15
From: shreyas <shreyasjoshi15@gmail.com>
The n25q128 micron chips cannot be treated similar to STM SPI NOR
when it comes to flash lock/unlock. The JDEC ID read here is just 1 byte
and it is not sufficient to distinguish between different chips. Thus,
memory type is used here in addition to JDEC ID to distinguish further.
Once the unique manufacture id is detected, it will invoke the required
lock/unlock function required for n25 micron chipsets.
Signed-off-by: shreyas <shreyasjoshi15@gmail.com>
---
drivers/mtd/spi-nor/spi-nor.c | 20 +++++++++++---------
include/linux/mtd/spi-nor.h | 4 ++--
2 files changed, 13 insertions(+), 11 deletions(-)
diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c
index f3b2df2c52b4..6dfdd95a5961 100644
--- a/drivers/mtd/spi-nor/spi-nor.c
+++ b/drivers/mtd/spi-nor/spi-nor.c
@@ -1356,6 +1356,7 @@ static int n25q_lock(struct spi_nor *nor, loff_t ofs, uint64_t len)
int status_old, status_new;
uint32_t offset = ofs;
int ret = 0;
+
status_old = read_sr(nor);
if (status_old < 0)
return status_old;
@@ -1373,7 +1374,8 @@ static int n25q_lock(struct spi_nor *nor, loff_t ofs, uint64_t len)
status_new = (status_old & ~(SR_BP2|SR_BP0)) | SR_BP1;
else
status_new = (status_old & ~(SR_BP2|SR_BP1)) | SR_BP0;
- if ((status_new & (SR_BP2|SR_BP1|SR_BP0)) > (status_old & (SR_BP2|SR_BP1|SR_BP0))) {
+ if ((status_new & (SR_BP2|SR_BP1|SR_BP0)) >
+ (status_old & (SR_BP2|SR_BP1|SR_BP0))) {
write_enable(nor);
if (write_sr(nor, status_new) < 0)
return -EINVAL;
@@ -1392,6 +1394,7 @@ static int n25q_unlock(struct spi_nor *nor, loff_t ofs, uint64_t len)
int status_old, status_new;
uint32_t offset = ofs;
int ret = 0;
+
status_old = read_sr(nor);
if (status_old < 0)
return status_old;
@@ -4266,14 +4269,13 @@ int spi_nor_scan(struct spi_nor *nor, const char *name,
if (JEDEC_MFR(info) == SNOR_MFR_ST ||
JEDEC_MFR(info) == SNOR_MFR_MICRON ||
info->flags & SPI_NOR_HAS_LOCK) {
- if (JEDEC_MT(info) == SNOR_MT_MICRON) {
- nor->flash_lock = n25q_lock;
- nor->flash_unlock = n25q_unlock;
- }
- else {
- nor->flash_lock = stm_lock;
- nor->flash_unlock = stm_unlock;
- }
+ if (JEDEC_MT(info) == SNOR_MT_MICRON) {
+ nor->flash_lock = n25q_lock;
+ nor->flash_unlock = n25q_unlock;
+ } else {
+ nor->flash_lock = stm_lock;
+ nor->flash_unlock = stm_unlock;
+ }
nor->flash_is_locked = stm_is_locked;
}
if (nor->flash_lock && nor->flash_unlock && nor->flash_is_locked) {
diff --git a/include/linux/mtd/spi-nor.h b/include/linux/mtd/spi-nor.h
index aaa3c1065b3b..3939cd77d778 100644
--- a/include/linux/mtd/spi-nor.h
+++ b/include/linux/mtd/spi-nor.h
@@ -27,8 +27,8 @@
#define SNOR_MFR_WINBOND 0xef /* Also used by some Spansion */
/* Manufacturer Memory Type
-* The second byte returned from the flash after sending opcode SPINOR_OP_RDID.
-*/
+ * The second byte returned from the flash after sending opcode SPINOR_OP_RDID.
+ */
#define SNOR_MT_MICRON 0xba
#define SNOR_MT_ST 0x20
--
2.20.1
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] driver/mtd/spi-nor: Regression lock/unlock fail
2019-09-19 1:49 [PATCH] driver/mtd/spi-nor: Regression lock/unlock fail Shreyas Joshi
@ 2019-09-19 5:05 ` Tudor.Ambarus
[not found] ` <CABY4bmpv4cdYDHaLvXX9ReACytqQktTTv867BUB4MNH-NHoCxw@mail.gmail.com>
0 siblings, 1 reply; 4+ messages in thread
From: Tudor.Ambarus @ 2019-09-19 5:05 UTC (permalink / raw)
To: shreyasjoshi15, marek.vasut, linux-mtd
On 09/19/2019 04:49 AM, Shreyas Joshi wrote:
> @@ -1356,6 +1356,7 @@ static int n25q_lock(struct spi_nor *nor, loff_t ofs, uint64_t len)
n25q_lock is not yet defined in spi-nor.c.
You should do your patches on top of
https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git, spi-nor/next branch.
Cheers,
ta
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-04-21 4:43 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-19 1:49 [PATCH] driver/mtd/spi-nor: Regression lock/unlock fail Shreyas Joshi
2019-09-19 5:05 ` Tudor.Ambarus
[not found] ` <CABY4bmpv4cdYDHaLvXX9ReACytqQktTTv867BUB4MNH-NHoCxw@mail.gmail.com>
2020-04-20 7:29 ` Tudor.Ambarus
[not found] ` <CABY4bmrSwLdnUMa5vJhfi2Hvbq4FHxU=hcXJX90o5dFXBi1Q4w@mail.gmail.com>
2020-04-21 4:42 ` Tudor.Ambarus
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).