* [PATCH 1/2] mtd: spi-nor: sst: Fix write enable before AAI sequence
[not found] <20260201165106.30-1-sanjaikumar.vs@dicortech.com>
@ 2026-02-01 16:51 ` Sanjaikumar V S
0 siblings, 0 replies; 3+ messages in thread
From: Sanjaikumar V S @ 2026-02-01 16:51 UTC (permalink / raw)
To: sanjaikumar.vs; +Cc: stable
When writing to SST flash starting at an odd address, a single byte is
first programmed using the byte program (BP) command. After this
operation completes, the flash hardware automatically clears the Write
Enable Latch (WEL) bit.
If an AAI (Auto Address Increment) word program sequence follows, it
requires WEL to be set. Without re-enabling writes, the AAI sequence
fails.
Add spi_nor_write_enable() after the odd-address byte program, but only
when an AAI sequence will follow (len > 2 bytes remaining).
Cc: stable@vger.kernel.org
Signed-off-by: Sanjaikumar V S <sanjaikumar.vs@dicortech.com>
---
drivers/mtd/spi-nor/sst.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/drivers/mtd/spi-nor/sst.c b/drivers/mtd/spi-nor/sst.c
index 175211fe6a5e..fe714e6d0914 100644
--- a/drivers/mtd/spi-nor/sst.c
+++ b/drivers/mtd/spi-nor/sst.c
@@ -210,6 +210,13 @@ static int sst_nor_write(struct mtd_info *mtd, loff_t to, size_t len,
to++;
actual++;
+
+ /* BP clears WEL, re-enable if AAI sequence follows */
+ if (actual < len - 1) {
+ ret = spi_nor_write_enable(nor);
+ if (ret)
+ goto out;
+ }
}
/* Write out most of the data here. */
--
2.43.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 1/2] mtd: spi-nor: sst: Fix write enable before AAI sequence
[not found] <20260201165817.53-1-sanjaikumar.vs@dicortech.com>
@ 2026-02-01 16:58 ` Sanjaikumar V S
2026-02-01 16:58 ` [PATCH 2/2] mtd: spi-nor: core: Fix AAI mode when dirmap is not available Sanjaikumar V S
1 sibling, 0 replies; 3+ messages in thread
From: Sanjaikumar V S @ 2026-02-01 16:58 UTC (permalink / raw)
To: tudor.ambarus, pratyush, michael.walle
Cc: linux-mtd, linux-kernel, Sanjaikumar V S, stable
When writing to SST flash starting at an odd address, a single byte is
first programmed using the byte program (BP) command. After this
operation completes, the flash hardware automatically clears the Write
Enable Latch (WEL) bit.
If an AAI (Auto Address Increment) word program sequence follows, it
requires WEL to be set. Without re-enabling writes, the AAI sequence
fails.
Add spi_nor_write_enable() after the odd-address byte program, but only
when an AAI sequence will follow (len > 2 bytes remaining).
Cc: stable@vger.kernel.org
Signed-off-by: Sanjaikumar V S <sanjaikumar.vs@dicortech.com>
---
drivers/mtd/spi-nor/sst.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/drivers/mtd/spi-nor/sst.c b/drivers/mtd/spi-nor/sst.c
index 175211fe6a5e..fe714e6d0914 100644
--- a/drivers/mtd/spi-nor/sst.c
+++ b/drivers/mtd/spi-nor/sst.c
@@ -210,6 +210,13 @@ static int sst_nor_write(struct mtd_info *mtd, loff_t to, size_t len,
to++;
actual++;
+
+ /* BP clears WEL, re-enable if AAI sequence follows */
+ if (actual < len - 1) {
+ ret = spi_nor_write_enable(nor);
+ if (ret)
+ goto out;
+ }
}
/* Write out most of the data here. */
--
2.43.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 2/2] mtd: spi-nor: core: Fix AAI mode when dirmap is not available
[not found] <20260201165817.53-1-sanjaikumar.vs@dicortech.com>
2026-02-01 16:58 ` [PATCH 1/2] mtd: spi-nor: sst: Fix write enable before AAI sequence Sanjaikumar V S
@ 2026-02-01 16:58 ` Sanjaikumar V S
1 sibling, 0 replies; 3+ messages in thread
From: Sanjaikumar V S @ 2026-02-01 16:58 UTC (permalink / raw)
To: tudor.ambarus, pratyush, michael.walle
Cc: linux-mtd, linux-kernel, Sanjaikumar V S, stable
When the SPI controller does not support direct mapping (nodirmap=true),
spi_nor_spimem_write_data() calls spi_mem_dirmap_write() which falls
back to spi_mem_no_dirmap_write(). This fallback uses the operation
template created at probe time with the standard page program opcode.
For SST flashes using AAI mode, this fails because the template cannot
handle the dynamic opcode and address byte changes required by AAI.
Fix by checking nodirmap and using spi_nor_spimem_exec_op() directly,
which uses the runtime-built operation with correct AAI configuration.
Cc: stable@vger.kernel.org
Signed-off-by: Sanjaikumar V S <sanjaikumar.vs@dicortech.com>
---
drivers/mtd/spi-nor/core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c
index d3f8a78efd3b..7caeb508d628 100644
--- a/drivers/mtd/spi-nor/core.c
+++ b/drivers/mtd/spi-nor/core.c
@@ -281,7 +281,7 @@ static ssize_t spi_nor_spimem_write_data(struct spi_nor *nor, loff_t to,
if (spi_nor_spimem_bounce(nor, &op))
memcpy(nor->bouncebuf, buf, op.data.nbytes);
- if (nor->dirmap.wdesc) {
+ if (nor->dirmap.wdesc && !nor->dirmap.wdesc->nodirmap) {
nbytes = spi_mem_dirmap_write(nor->dirmap.wdesc, op.addr.val,
op.data.nbytes, op.data.buf.out);
} else {
--
2.43.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-02-01 16:58 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20260201165817.53-1-sanjaikumar.vs@dicortech.com>
2026-02-01 16:58 ` [PATCH 1/2] mtd: spi-nor: sst: Fix write enable before AAI sequence Sanjaikumar V S
2026-02-01 16:58 ` [PATCH 2/2] mtd: spi-nor: core: Fix AAI mode when dirmap is not available Sanjaikumar V S
[not found] <20260201165106.30-1-sanjaikumar.vs@dicortech.com>
2026-02-01 16:51 ` [PATCH 1/2] mtd: spi-nor: sst: Fix write enable before AAI sequence Sanjaikumar V S
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox