[PATCH 07/15] mtd: spi-nor: Allow configuring the actual number of dummy cycles
Miquel Raynal
miquel.raynal at bootlin.com
Fri Oct 2 05:21:20 PDT 2026
The SPI NOR core selects the fastest read variant advertised by the SFDP
tables. This may or may not be a wise choice but at least it is simpler
as any bus frequency will just work. There is however a downside: the
number of dummy cycles is maximized (in case the bus frequency is really
fast, this is how the chip enforces a sufficient delay). Maximizing the
number of dummy cycles means that, if the amount of cycles is
configurable in the chip, we might not take its default value. When this
happens, we need to make sure that the chip is configured accordingly.
Crete a callback to configure the chip for expecting a specific number
of dummy cycles.
Signed-off-by: Miquel Raynal <miquel.raynal at bootlin.com>
---
drivers/mtd/spi-nor/core.c | 12 +++++++++++-
drivers/mtd/spi-nor/core.h | 2 ++
2 files changed, 13 insertions(+), 1 deletion(-)
diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c
index 6e22342361c3..152add3834fc 100644
--- a/drivers/mtd/spi-nor/core.c
+++ b/drivers/mtd/spi-nor/core.c
@@ -2627,7 +2627,17 @@ static int spi_nor_setup(struct spi_nor *nor,
return err;
}
- return spi_nor_set_addr_nbytes(nor);
+ err = spi_nor_set_addr_nbytes(nor);
+ if (err)
+ return err;
+
+ if (nor->params->set_dummy) {
+ err = nor->params->set_dummy(nor, nor->read_dummy);
+ if (err)
+ return err;
+ }
+
+ return 0;
}
bool spi_nor_fixup_match(const struct spi_nor *nor,
diff --git a/drivers/mtd/spi-nor/core.h b/drivers/mtd/spi-nor/core.h
index 670182b3c2ad..b64f26b69c05 100644
--- a/drivers/mtd/spi-nor/core.h
+++ b/drivers/mtd/spi-nor/core.h
@@ -377,6 +377,7 @@ struct spi_nor_opcodes {
* Table.
* @otp: SPI NOR OTP info.
* @set_octal_dtr: enables or disables SPI NOR octal DTR mode.
+ * @set_dummy: configure the number of read dummy cycles.
* @quad_enable: enables SPI NOR quad mode.
* @qe_mask: two bytes mask used to set/clear the QE bit
* @set_4byte_addr_mode: puts the SPI NOR in 4 byte addressing mode.
@@ -410,6 +411,7 @@ struct spi_nor_flash_parameter {
struct spi_nor_otp otp;
int (*set_octal_dtr)(struct spi_nor *nor, bool enable);
+ int (*set_dummy)(struct spi_nor *nor, u8 dummy_cycles);
int (*quad_enable)(struct spi_nor *nor);
u8 qe_mask[2];
int (*set_4byte_addr_mode)(struct spi_nor *nor, bool enable);
--
2.55.0
More information about the linux-mtd
mailing list