All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mtd: spinand: Only touch the QE bit on chips that have one
@ 2026-09-10 15:53 Ahmed Naseef
  0 siblings, 0 replies; only message in thread
From: Ahmed Naseef @ 2026-09-10 15:53 UTC (permalink / raw)
  To: linux-mtd
  Cc: Miquel Raynal, Richard Weinberger, Vignesh Raghavendra,
	linux-kernel, Ahmed Naseef

Since commit be0b86c648bf ("mtd: spinand: Gather all the bus interface
steps in one single function") spinand_init_quad_enable() is called
unconditionally and clears bit 0 of the configuration register even on
chips without SPINAND_HAS_QE_BIT. On such chips that bit can have another
meaning: on the Winbond W25N02KV it is H-DIS (Hold Disable, default 1),
and clearing it enables the /HOLD function, after which erase and program
operations silently stop taking effect on MT7986 boards.

Only program the QE bit when the chip declares SPINAND_HAS_QE_BIT, as
before.

Fixes: be0b86c648bf ("mtd: spinand: Gather all the bus interface steps in one single function")
Cc: stable@vger.kernel.org
Assisted-by: Claude Code:claude-opus-5
Signed-off-by: Ahmed Naseef <naseefkm@gmail.com>
---
 drivers/mtd/nand/spi/core.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/drivers/mtd/nand/spi/core.c b/drivers/mtd/nand/spi/core.c
index 43bbe2629b85..9fc1512e4fe2 100644
--- a/drivers/mtd/nand/spi/core.c
+++ b/drivers/mtd/nand/spi/core.c
@@ -1781,7 +1781,7 @@ static int spinand_detect(struct spinand_device *spinand)
 static int spinand_configure_chip(struct spinand_device *spinand)
 {
 	bool odtr = false, quad_enable = false;
-	int ret;
+	int ret = 0;
 
 	if (spinand->odtr_op_templates.read_cache &&
 	    spinand->odtr_op_templates.write_cache &&
@@ -1808,16 +1808,21 @@ static int spinand_configure_chip(struct spinand_device *spinand)
 	}
 
 try_ssdr:
+	/*
+	 * Only touch the QE bit on chips that actually have one. On other
+	 * chips bit 0 of the configuration register may have a different
+	 * meaning (e.g. H-DIS on the Winbond W25N02KV).
+	 */
 	if (spinand->flags & SPINAND_HAS_QE_BIT) {
 		if (spinand->ssdr_op_templates.read_cache->data.buswidth == 4 ||
 		    spinand->ssdr_op_templates.write_cache->data.buswidth == 4 ||
 		    spinand->ssdr_op_templates.update_cache->data.buswidth == 4)
 			quad_enable = true;
-	}
 
-	ret = spinand_init_quad_enable(spinand, quad_enable);
-	if (ret)
-		return ret;
+		ret = spinand_init_quad_enable(spinand, quad_enable);
+		if (ret)
+			return ret;
+	}
 
 	if (spinand->configure_chip) {
 		ret = spinand->configure_chip(spinand, SSDR);

base-commit: 21f027016b1290d13c30b198ae7a00e6b3d1d5a5
-- 
2.34.1


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-09-10 15:54 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-10 15:53 [PATCH] mtd: spinand: Only touch the QE bit on chips that have one Ahmed Naseef

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.