drivers/mtd/spi-nor/core.c | 2 +- drivers/mtd/spi-nor/sst.c | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-)
From: Sanjaikumar V S <sanjaikumar.vs@dicortech.com> This series fixes SST flash AAI (Auto Address Increment) write mode, which was broken due to two issues: 1. When writing starts at an odd address, a single byte is programmed first using the byte program (BP) command. The flash hardware clears the Write Enable Latch (WEL) after this operation, but the driver did not re-enable writes before starting the AAI sequence. 2. When the SPI controller does not support direct mapping (nodirmap=true), the write path falls back to using an operation template created at probe time. This template has the standard page program opcode, not the AAI opcode, causing AAI writes to fail. Tested on SST25VF016B with i.MX8X running linux-imx 5.15.71. The conditional write enable (only when AAI follows) is based on code analysis and not runtime tested. v2: Resend with corrected maintainer email addresses Sanjaikumar V S (2): mtd: spi-nor: sst: Fix write enable before AAI sequence mtd: spi-nor: core: Fix AAI mode when dirmap is not available drivers/mtd/spi-nor/core.c | 2 +- drivers/mtd/spi-nor/sst.c | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) -- 2.43.0
From: Sanjaikumar V S <sanjaikumar.vs@dicortech.com> This patch series addresses two distinct problems affecting SST flash Auto Address Increment write functionality: 1. When writes begin at odd addresses, a single byte is programmed first using byte program command, which clears the Write Enable Latch. The driver fails to re-enable writes before the AAI sequence. 2. When the SPI controller lacks direct mapping support, the fallback path uses a probe-time operation template with standard page program opcodes instead of AAI opcodes. Changes in v3: - Patch 1/2: Use local boolean 'needs_write_enable' for clarity as suggested by Michael Walle - Patch 1/2: Improved comment explaining the fix - Patch 1/2: Added Fixes tag Changes in v2: - Split fixes into separate patches - Added detailed commit messages Sanjaikumar V S (2): mtd: spi-nor: sst: Fix write enable before AAI sequence mtd: spi-nor: core: Fix AAI mode when dirmap is not available drivers/mtd/spi-nor/core.c | 2 +- drivers/mtd/spi-nor/sst.c | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) -- 2.43.0
From: Sanjaikumar V S <sanjaikumar.vs@dicortech.com>
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 when more
data needs to be written. Use a local boolean for clarity.
Fixes: b199489d37b2 ("mtd: spi-nor: add the framework for SPI NOR")
Cc: stable@vger.kernel.org
Signed-off-by: Sanjaikumar V S <sanjaikumar.vs@dicortech.com>
---
drivers/mtd/spi-nor/sst.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/drivers/mtd/spi-nor/sst.c b/drivers/mtd/spi-nor/sst.c
index 175211fe6a5e..db02c14ba16f 100644
--- a/drivers/mtd/spi-nor/sst.c
+++ b/drivers/mtd/spi-nor/sst.c
@@ -203,6 +203,8 @@ static int sst_nor_write(struct mtd_info *mtd, loff_t to, size_t len,
/* Start write from odd address. */
if (to % 2) {
+ bool needs_write_enable = (len > 1);
+
/* write one byte. */
ret = sst_nor_write_data(nor, to, 1, buf);
if (ret < 0)
@@ -210,6 +212,17 @@ static int sst_nor_write(struct mtd_info *mtd, loff_t to, size_t len,
to++;
actual++;
+
+ /*
+ * Byte program clears the write enable latch. If more
+ * data needs to be written using the AAI sequence,
+ * re-enable writes.
+ */
+ if (needs_write_enable) {
+ ret = spi_nor_write_enable(nor);
+ if (ret)
+ goto out;
+ }
}
/* Write out most of the data here. */
--
2.43.0
From: Sanjaikumar V S <sanjaikumar.vs@dicortech.com>
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
© 2016 - 2026 Red Hat, Inc.