[PATCH v4 04/11] spi: spi-mem: Take the DQS wiring into account
From: Miquel Raynal
Date: Fri Nov 20 2026 - 12:15:06 EST
The DQS line may not be routed between the memory and the controller.
Parse the spi-dqs-not-wired property when the SPI memory device is
created and only report DQS as available when the memory supports it and
the line is wired.
Signed-off-by: Miquel Raynal <miquel.raynal@xxxxxxxxxxx>
---
drivers/spi/spi-mem.c | 7 +++++--
include/linux/spi/spi-mem.h | 2 ++
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/drivers/spi/spi-mem.c b/drivers/spi/spi-mem.c
index 8c283953b302..f2e1ecd49fd6 100644
--- a/drivers/spi/spi-mem.c
+++ b/drivers/spi/spi-mem.c
@@ -8,6 +8,7 @@
#include <linux/dmaengine.h>
#include <linux/iopoll.h>
#include <linux/pm_runtime.h>
+#include <linux/property.h>
#include <linux/spi/spi.h>
#include <linux/spi/spi-mem.h>
#include <linux/sched/task_stack.h>
@@ -570,11 +571,11 @@ EXPORT_SYMBOL_GPL(spi_mem_set_dqs_pin_available);
* @mem: the SPI memory
*
* Return: a boolean indicating whether the DQS signal is usable or not. DQS is
- * usable when the memory supports it.
+ * usable when the memory supports it and the line is wired.
*/
bool spi_mem_dqs_is_usable(struct spi_mem *mem)
{
- return mem->dqs_pin;
+ return mem->dqs_pin && mem->dqs_wired;
}
EXPORT_SYMBOL_GPL(spi_mem_dqs_is_usable);
@@ -1142,6 +1143,8 @@ static int spi_mem_probe(struct spi_device *spi)
return -ENOMEM;
mem->spi = spi;
+ mem->dqs_wired = !device_property_read_bool(&spi->dev,
+ "spi-dqs-not-wired");
if (ctlr->mem_ops && ctlr->mem_ops->get_name)
mem->name = ctlr->mem_ops->get_name(mem);
diff --git a/include/linux/spi/spi-mem.h b/include/linux/spi/spi-mem.h
index 85a61ac62e2c..73fab3b004b5 100644
--- a/include/linux/spi/spi-mem.h
+++ b/include/linux/spi/spi-mem.h
@@ -276,6 +276,7 @@ struct spi_mem_dirmap_desc {
* @drvpriv: spi_mem_driver private data
* @name: name of the SPI memory device
* @dqs_pin: the memory provides a DQS pin
+ * @dqs_wired: the DQS line is routed to the controller
*
* Extra information that describe the SPI memory device and may be needed by
* the controller to properly handle this device should be placed here.
@@ -288,6 +289,7 @@ struct spi_mem {
void *drvpriv;
const char *name;
bool dqs_pin;
+ bool dqs_wired;
};
/**
--
2.56.0