[RFC PATCH v2 05/12] mtd: spi-nor: perform controller tuning during probe
Santhosh Kumar K
s-k6 at ti.com
Tue Jan 13 06:16:10 PST 2026
SPI controllers may need tuning for reliable high-speed operation.
Without it, controllers use conservative timing that limits performance.
Call spi_mem_execute_tuning() during probe to optimize timing for
the device's read operation. Failures are non-fatal as controllers
fall back to default timing.
Signed-off-by: Santhosh Kumar K <s-k6 at ti.com>
---
drivers/mtd/spi-nor/core.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c
index 63f3051d7a6b..d69cb8eaad83 100644
--- a/drivers/mtd/spi-nor/core.c
+++ b/drivers/mtd/spi-nor/core.c
@@ -3704,6 +3704,7 @@ static int spi_nor_probe(struct spi_mem *spimem)
struct device *dev = &spi->dev;
struct flash_platform_data *data = dev_get_platdata(dev);
struct spi_nor *nor;
+ struct spi_mem_op read_op;
/*
* Enable all caps by default. The core will mask them after
* checking what's really supported using spi_mem_supports_op().
@@ -3773,6 +3774,16 @@ static int spi_nor_probe(struct spi_mem *spimem)
if (ret)
return ret;
+ read_op = spi_nor_spimem_get_read_op(nor);
+ ret = spi_mem_execute_tuning(spimem, &read_op, NULL);
+ if (ret && ret != -EOPNOTSUPP) {
+ dev_warn(dev, "Failed to execute PHY tuning: %d\n", ret);
+ /*
+ * Tuning failure is non-fatal; the controller falls back to
+ * default timing, reducing speed but ensuring operation.
+ */
+ }
+
return mtd_device_register(&nor->mtd, data ? data->parts : NULL,
data ? data->nr_parts : 0);
}
--
2.34.1
More information about the linux-mtd
mailing list