Re: [PATCH v4 2/2] mtd: spi-nor: core: Fix AAI mode when dirmap is not available
From: Sanjaikumar V S
Date: Tue Mar 31 2026 - 02:26:28 EST
Hi,
> But if the controller does support direct mapping, won't it end up
> using the wrong opcode? Would it be a better idea to update the
> dirmap_info with the right opcodes?
You're right. If the controller supports direct mapping, it would still
use the wrong opcode from the template created at probe time.
Updating dirmap_info at runtime is problematic because SST AAI mode
requires dynamic changes per write:
- cmd.opcode: SPINOR_OP_BP (single byte) vs SPINOR_OP_AAI_WP (word)
- addr.nbytes: must be 0 for subsequent AAI writes
Controllers may also cache the template at dirmap_create time, so
modifying it at runtime could cause issues.
A cleaner approach is to disable dirmap for SST AAI devices by setting
nodirmap=1 in sst_nor_late_init(). This ensures all writes go through
spi_nor_spimem_exec_op() which uses the runtime opcode.
This only affects devices with SST_WRITE flag (sst25wf*, sst25vf016b,
sst25vf032b, sst25vf040b, sst25vf080b). Other SST devices that use
standard page program can still benefit from dirmap.
I'll send a v5 with this change.
Thanks,
Sanjaikumar