[PATCH 1/2] mtd: spi-nor: sst: Fix write enable before AAI sequence

Sanjaikumar V S
2026-02-01T16:58:45Z

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. */