[PATCH v2 1/4] mtd: spi-nor: macronix: Clear the default RDCR opcode

From: Miquel Raynal

Date: Thu Nov 26 2026 - 08:42:48 EST


The core defaults opcodes.read_sr2 to the JEDEC RDCR opcode (0x35) and
opcodes.write_sr1_and_sr2 to the 16-bit Write Status command. Macronix
flashes do not use 0x35 to access their configuration register; they
read it with 0x15, and some parts have no configuration register at all.
A 16-bit write would then send zeroes to a register we cannot read.

Clear the RDCR opcode and default to 1-byte SR1 writes in the
manufacturer default_init, which runs after the core default and before
the SFDP parsing. Parts that do support the vendor opcode can opt in from
their own fixup, and SFDP will still select 16-bit writes for parts that
require them.

Signed-off-by: Miquel Raynal <miquel.raynal@xxxxxxxxxxx>
---
drivers/mtd/spi-nor/macronix.c | 10 ++++++++++
1 file changed, 10 insertions(+)

diff --git a/drivers/mtd/spi-nor/macronix.c b/drivers/mtd/spi-nor/macronix.c
index b3fdb4b2fa1c..163f1006130b 100644
--- a/drivers/mtd/spi-nor/macronix.c
+++ b/drivers/mtd/spi-nor/macronix.c
@@ -333,6 +333,16 @@ static void macronix_nor_default_init(struct spi_nor *nor)
{
nor->params->qe_mask[0] = BIT(6);
nor->params->qe_mask[1] = 0;
+
+ /*
+ * The JEDEC RDCR opcode (0x35) is not valid for Macronix: some parts
+ * have no CR at all, others use 0x15. Clear the core default. Parts
+ * that do support the vendor opcode but do not carry proper SFDP tables
+ * can opt-in from their own fixup.
+ */
+ nor->params->opcodes.read_sr2 = 0;
+ nor->params->opcodes.write_sr1 = SPINOR_OP_WRSR;
+ nor->params->opcodes.write_sr1_and_sr2 = 0;
}

static int macronix_nor_late_init(struct spi_nor *nor)

--
2.56.0