mtd: spi-nor: sst: Fix write enable before AAI sequence
Subsystems (3)
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH 1/2 mtd: spi-nor: sst: Fix write enable before AAI sequence
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).
--- drivers/mtd/spi-nor/sst.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/mtd/spi-nor/sst.c +7 -0
@@ -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. */
Signature · 1 line
2.43.0
PATCH 2/2 mtd: spi-nor: core: Fix AAI mode when dirmap is not available
In reply to a message not in the archiveWhen 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.
--- drivers/mtd/spi-nor/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mtd/spi-nor/core.c +1 -1
@@ -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 {
Signature · 1 line
2.43.0