* [PATCH v5 0/7] spi: cadence-xspi: Fixes and ACPI changes
@ 2026-11-20 11:59 Paul Cercueil
2026-11-20 11:59 ` [PATCH v5 1/7] spi: cadence-xspi: Properly handle errors in .transfer_one_message Paul Cercueil
` (7 more replies)
0 siblings, 8 replies; 11+ messages in thread
From: Paul Cercueil @ 2026-11-20 11:59 UTC (permalink / raw)
To: Mark Brown
Cc: linux-spi, linux-kernel, Thomas Petazzoni, Bharat Bhushan,
Sunil Kovvuri Goutham, Tanmay Jagdale, Jisheng Zhang,
George Cherian, Witold Sadowski, Paul Cercueil
Hi Mark,
This is the v4 of my patchset that adds a few fixes to the cadence-xspi
driver, some cleanups, as well as a workaround for probing the Marvell
IP on firmwares that use the base string.
If that last one is a deal breaker then it can be skipped. Jisheng Zhang
queried the DT maintainers about a clarification on whether or not bugs
in out-of-tree DTs should be cared for, but they haven't responded yet.
The v5 is a minimal update from v4, only the first patch is different.
The error path of .transfer_one_message() will now disable the hardware
FIFO.
Changelog in v5:
- [1/7]:
- Reset hardware FIFO on error
Cheers,
-Paul
Tanmay Jagdale (7):
spi: cadence-xspi: Properly handle errors in .transfer_one_message
spi: cadence-xspi: Reconfigure to STIG mode before SPI message
spi: cadence-xspi: Inform SPI core about size transferred
spi: cadence-xspi: Clear "SDMA ready" IRQ flag after polling
spi: cadence-xspi: Drop useless cdns_xspi->cur_cs
spi: cadence-xspi: Rework resource discovery
spi: cadence-xspi: Add workaround for old Marvell firmwares
drivers/spi/spi-cadence-xspi.c | 183 ++++++++++++++++++++++-----------
1 file changed, 123 insertions(+), 60 deletions(-)
--
2.47.3
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH v5 1/7] spi: cadence-xspi: Properly handle errors in .transfer_one_message
2026-11-20 11:59 [PATCH v5 0/7] spi: cadence-xspi: Fixes and ACPI changes Paul Cercueil
@ 2026-11-20 11:59 ` Paul Cercueil
2026-11-20 11:59 ` [PATCH v5 2/7] spi: cadence-xspi: Reconfigure to STIG mode before SPI message Paul Cercueil
` (6 subsequent siblings)
7 siblings, 0 replies; 11+ messages in thread
From: Paul Cercueil @ 2026-11-20 11:59 UTC (permalink / raw)
To: Mark Brown
Cc: linux-spi, linux-kernel, Thomas Petazzoni, Bharat Bhushan,
Sunil Kovvuri Goutham, Tanmay Jagdale, Jisheng Zhang,
George Cherian, Witold Sadowski, stable, Paul Cercueil
From: Tanmay Jagdale <tanmay@marvell.com>
The cdns_xspi_transfer_one_message_b0() function was not setting
m->status on error, causing it to be stuck at -EINPROGRESS, confusing
the SPI core.
Additionally, reset cdns_xspi->xfer_in_progress on error.
Fixes: 931e389ded0f ("spi: cadence: Add Marvell xfer operation support")
Cc: stable@vger.kernel.org
Signed-off-by: Tanmay Jagdale <tanmay@marvell.com>
Co-developed-by: Paul Cercueil <paul.cercueil@bootlin.com>
Signed-off-by: Paul Cercueil <paul.cercueil@bootlin.com>
---
v2: New patch
v3: No change
v4: Also reset cdns_xspi->xfer_in_progress on error.
v5: Reset hardware FIFO on error
---
drivers/spi/spi-cadence-xspi.c | 20 +++++++++++++-------
1 file changed, 13 insertions(+), 7 deletions(-)
diff --git a/drivers/spi/spi-cadence-xspi.c b/drivers/spi/spi-cadence-xspi.c
index 72852849ba27..e2d5d464bd30 100644
--- a/drivers/spi/spi-cadence-xspi.c
+++ b/drivers/spi/spi-cadence-xspi.c
@@ -1243,6 +1243,7 @@ static int cdns_xspi_transfer_one_message_b0(struct spi_controller *controller,
int current_transfer_len;
int cs = spi_get_chipselect(spi, 0);
int cs_change = 0;
+ int ret = -EIO;
/* Enable xfer state machine */
if (!cdns_xspi->xfer_in_progress) {
@@ -1283,7 +1284,7 @@ static int cdns_xspi_transfer_one_message_b0(struct spi_controller *controller,
false, cmd_regs);
cdns_xspi_trigger_command(cdns_xspi, cmd_regs);
if (!cdns_xspi_is_stig_ready(cdns_xspi, true))
- return -EIO;
+ goto out;
} else {
cdns_xspi_prepare_generic(cs, txd, 1, true, cmd_regs);
cdns_xspi_trigger_command(cdns_xspi, cmd_regs);
@@ -1292,11 +1293,11 @@ static int cdns_xspi_transfer_one_message_b0(struct spi_controller *controller,
cdns_xspi_trigger_command(cdns_xspi, cmd_regs);
cdns_xspi->sdma_xfer_len = current_transfer_len - 1;
if (!cdns_xspi_is_sdma_ready(cdns_xspi, true))
- return -EIO;
+ goto out;
if (cdns_xspi->sdma_handler(cdns_xspi))
- return -EIO;
+ goto out;
if (!cdns_xspi_is_stig_ready(cdns_xspi, true))
- return -EIO;
+ goto out;
if (rxd)
cdns_xspi->in_buffer += current_transfer_len;
@@ -1324,7 +1325,10 @@ static int cdns_xspi_transfer_one_message_b0(struct spi_controller *controller,
spi_transfer_delay_exec(t);
}
- if (!cs_change) {
+ ret = 0;
+
+out:
+ if (ret != 0 || !cs_change) {
u32 xfer_control = readl(cdns_xspi->xferbase + MRVL_XFER_FUNC_CTRL);
xfer_control &= ~(MRVL_XFER_RECEIVE_ENABLE |
@@ -1333,10 +1337,12 @@ static int cdns_xspi_transfer_one_message_b0(struct spi_controller *controller,
cdns_xspi->xfer_in_progress = false;
}
- m->status = 0;
+ if (m->status == -EINPROGRESS)
+ m->status = ret;
+
spi_finalize_current_message(controller);
- return 0;
+ return ret;
}
#endif
--
2.47.3
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH v5 2/7] spi: cadence-xspi: Reconfigure to STIG mode before SPI message
2026-11-20 11:59 [PATCH v5 0/7] spi: cadence-xspi: Fixes and ACPI changes Paul Cercueil
2026-11-20 11:59 ` [PATCH v5 1/7] spi: cadence-xspi: Properly handle errors in .transfer_one_message Paul Cercueil
@ 2026-11-20 11:59 ` Paul Cercueil
2026-11-20 11:59 ` [PATCH v5 3/7] spi: cadence-xspi: Inform SPI core about size transferred Paul Cercueil
` (5 subsequent siblings)
7 siblings, 0 replies; 11+ messages in thread
From: Paul Cercueil @ 2026-11-20 11:59 UTC (permalink / raw)
To: Mark Brown
Cc: linux-spi, linux-kernel, Thomas Petazzoni, Bharat Bhushan,
Sunil Kovvuri Goutham, Tanmay Jagdale, Jisheng Zhang,
George Cherian, Witold Sadowski, stable, Paul Cercueil
From: Tanmay Jagdale <tanmay@marvell.com>
The .transfer_one_message() function uses the STIG mode, therefore the
xSPI needs to be configured to STIG mode before starting any transfer.
Without this, .transfer_one_message() simply won't work, at least on the
CN10K SoC.
Fixes: 931e389ded0f ("spi: cadence: Add Marvell xfer operation support")
Cc: stable@vger.kernel.org
Signed-off-by: Tanmay Jagdale <tanmay@marvell.com>
Co-developed-by: Paul Cercueil <paul.cercueil@bootlin.com>
Signed-off-by: Paul Cercueil <paul.cercueil@bootlin.com>
---
v2: Adapt the code slightly to work on top of [1/6]
v3-v5: No change
---
drivers/spi/spi-cadence-xspi.c | 31 ++++++++++++++++++++++++-------
1 file changed, 24 insertions(+), 7 deletions(-)
diff --git a/drivers/spi/spi-cadence-xspi.c b/drivers/spi/spi-cadence-xspi.c
index e2d5d464bd30..48a6db290408 100644
--- a/drivers/spi/spi-cadence-xspi.c
+++ b/drivers/spi/spi-cadence-xspi.c
@@ -491,6 +491,20 @@ static int cdns_xspi_wait_for_controller_idle(struct cdns_xspi_dev *cdns_xspi)
100, 1000);
}
+static int cdns_xspi_set_stig_mode(struct cdns_xspi_dev *cdns_xspi)
+{
+ int ret;
+
+ ret = cdns_xspi_wait_for_controller_idle(cdns_xspi);
+ if (ret < 0)
+ return -EIO;
+
+ writel(FIELD_PREP(CDNS_XSPI_CTRL_WORK_MODE, CDNS_XSPI_WORK_MODE_STIG),
+ cdns_xspi->iobase + CDNS_XSPI_CTRL_CONFIG_REG);
+
+ return 0;
+}
+
static void cdns_xspi_trigger_command(struct cdns_xspi_dev *cdns_xspi,
u32 cmd_regs[6])
{
@@ -665,12 +679,9 @@ static int cdns_xspi_send_stig_command(struct cdns_xspi_dev *cdns_xspi,
int ret;
int dummybytes = op->dummy.nbytes;
- ret = cdns_xspi_wait_for_controller_idle(cdns_xspi);
- if (ret < 0)
- return -EIO;
-
- writel(FIELD_PREP(CDNS_XSPI_CTRL_WORK_MODE, CDNS_XSPI_WORK_MODE_STIG),
- cdns_xspi->iobase + CDNS_XSPI_CTRL_CONFIG_REG);
+ ret = cdns_xspi_set_stig_mode(cdns_xspi);
+ if (ret)
+ return ret;
reinit_completion(&cdns_xspi->cmd_complete);
reinit_completion(&cdns_xspi->sdma_complete);
@@ -1243,7 +1254,13 @@ static int cdns_xspi_transfer_one_message_b0(struct spi_controller *controller,
int current_transfer_len;
int cs = spi_get_chipselect(spi, 0);
int cs_change = 0;
- int ret = -EIO;
+ int ret;
+
+ ret = cdns_xspi_set_stig_mode(cdns_xspi);
+ if (ret)
+ goto out;
+
+ ret = -EIO;
/* Enable xfer state machine */
if (!cdns_xspi->xfer_in_progress) {
--
2.47.3
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH v5 3/7] spi: cadence-xspi: Inform SPI core about size transferred
2026-11-20 11:59 [PATCH v5 0/7] spi: cadence-xspi: Fixes and ACPI changes Paul Cercueil
2026-11-20 11:59 ` [PATCH v5 1/7] spi: cadence-xspi: Properly handle errors in .transfer_one_message Paul Cercueil
2026-11-20 11:59 ` [PATCH v5 2/7] spi: cadence-xspi: Reconfigure to STIG mode before SPI message Paul Cercueil
@ 2026-11-20 11:59 ` Paul Cercueil
2026-11-20 11:59 ` [PATCH v5 4/7] spi: cadence-xspi: Clear "SDMA ready" IRQ flag after polling Paul Cercueil
` (4 subsequent siblings)
7 siblings, 0 replies; 11+ messages in thread
From: Paul Cercueil @ 2026-11-20 11:59 UTC (permalink / raw)
To: Mark Brown
Cc: linux-spi, linux-kernel, Thomas Petazzoni, Bharat Bhushan,
Sunil Kovvuri Goutham, Tanmay Jagdale, Jisheng Zhang,
George Cherian, Witold Sadowski, stable, Paul Cercueil
From: Tanmay Jagdale <tanmay@marvell.com>
The SPI core expects the 'actual_length' field of the spi_message to be
updated with the number of bytes transferred.
Fixes: 931e389ded0f ("spi: cadence: Add Marvell xfer operation support")
Cc: stable@vger.kernel.org
Signed-off-by: Tanmay Jagdale <tanmay@marvell.com>
Co-developed-by: Paul Cercueil <paul.cercueil@bootlin.com>
Signed-off-by: Paul Cercueil <paul.cercueil@bootlin.com>
---
v2-v5: No change
---
drivers/spi/spi-cadence-xspi.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/spi/spi-cadence-xspi.c b/drivers/spi/spi-cadence-xspi.c
index 48a6db290408..29a54ffa1664 100644
--- a/drivers/spi/spi-cadence-xspi.c
+++ b/drivers/spi/spi-cadence-xspi.c
@@ -1338,6 +1338,7 @@ static int cdns_xspi_transfer_one_message_b0(struct spi_controller *controller,
}
cs_change = t->cs_change;
t->len -= current_transfer_len;
+ m->actual_length += current_transfer_len;
}
spi_transfer_delay_exec(t);
}
--
2.47.3
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH v5 4/7] spi: cadence-xspi: Clear "SDMA ready" IRQ flag after polling
2026-11-20 11:59 [PATCH v5 0/7] spi: cadence-xspi: Fixes and ACPI changes Paul Cercueil
` (2 preceding siblings ...)
2026-11-20 11:59 ` [PATCH v5 3/7] spi: cadence-xspi: Inform SPI core about size transferred Paul Cercueil
@ 2026-11-20 11:59 ` Paul Cercueil
2026-11-20 11:59 ` [PATCH v5 5/7] spi: cadence-xspi: Drop useless cdns_xspi->cur_cs Paul Cercueil
` (3 subsequent siblings)
7 siblings, 0 replies; 11+ messages in thread
From: Paul Cercueil @ 2026-11-20 11:59 UTC (permalink / raw)
To: Mark Brown
Cc: linux-spi, linux-kernel, Thomas Petazzoni, Bharat Bhushan,
Sunil Kovvuri Goutham, Tanmay Jagdale, Jisheng Zhang,
George Cherian, Witold Sadowski, stable, Paul Cercueil
From: Tanmay Jagdale <tanmay@marvell.com>
When polling for the "SDMA ready" event, once the corresponding bit is
set in the CDNS_XSPI_SDMA_TRIGGER we should reset it to zero. Otherwise,
any subsequent call to cdns_xspi_is_sdma_ready() will just return early.
Fixes: 931e389ded0f ("spi: cadence: Add Marvell xfer operation support")
Cc: stable@vger.kernel.org
Signed-off-by: Tanmay Jagdale <tanmay@marvell.com>
Co-developed-by: Paul Cercueil <paul.cercueil@bootlin.com>
Signed-off-by: Paul Cercueil <paul.cercueil@bootlin.com>
---
Note that Sashiko complains about it racing vs. the IRQ handler but
that's bogus. This function is never called in a code path where IRQs
are enabled at the device level.
v4: New patch.
v5: No change.
---
drivers/spi/spi-cadence-xspi.c | 20 ++++++++++++++------
1 file changed, 14 insertions(+), 6 deletions(-)
diff --git a/drivers/spi/spi-cadence-xspi.c b/drivers/spi/spi-cadence-xspi.c
index 29a54ffa1664..7c7a604f4c62 100644
--- a/drivers/spi/spi-cadence-xspi.c
+++ b/drivers/spi/spi-cadence-xspi.c
@@ -1235,12 +1235,20 @@ static bool cdns_xspi_is_sdma_ready(struct cdns_xspi_dev *cdns_xspi, bool sleep)
{
u32 ctrl_stat;
- return !readl_relaxed_poll_timeout
- (cdns_xspi->iobase + CDNS_XSPI_INTR_STATUS_REG,
- ctrl_stat,
- (ctrl_stat & CDNS_XSPI_SDMA_TRIGGER),
- sleep ? MRVL_XSPI_POLL_DELAY_US : 0,
- sleep ? MRVL_XSPI_POLL_TIMEOUT_US : 0);
+ if (readl_relaxed_poll_timeout
+ (cdns_xspi->iobase + CDNS_XSPI_INTR_STATUS_REG,
+ ctrl_stat,
+ (ctrl_stat & CDNS_XSPI_SDMA_TRIGGER),
+ sleep ? MRVL_XSPI_POLL_DELAY_US : 0,
+ sleep ? MRVL_XSPI_POLL_TIMEOUT_US : 0)) {
+ return false;
+ }
+
+ /* Clear the flag */
+ writel(CDNS_XSPI_SDMA_TRIGGER,
+ cdns_xspi->iobase + CDNS_XSPI_INTR_STATUS_REG);
+
+ return true;
}
static int cdns_xspi_transfer_one_message_b0(struct spi_controller *controller,
--
2.47.3
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH v5 5/7] spi: cadence-xspi: Drop useless cdns_xspi->cur_cs
2026-11-20 11:59 [PATCH v5 0/7] spi: cadence-xspi: Fixes and ACPI changes Paul Cercueil
` (3 preceding siblings ...)
2026-11-20 11:59 ` [PATCH v5 4/7] spi: cadence-xspi: Clear "SDMA ready" IRQ flag after polling Paul Cercueil
@ 2026-11-20 11:59 ` Paul Cercueil
2026-11-20 11:59 ` [PATCH v5 6/7] spi: cadence-xspi: Rework resource discovery Paul Cercueil
` (2 subsequent siblings)
7 siblings, 0 replies; 11+ messages in thread
From: Paul Cercueil @ 2026-11-20 11:59 UTC (permalink / raw)
To: Mark Brown
Cc: linux-spi, linux-kernel, Thomas Petazzoni, Bharat Bhushan,
Sunil Kovvuri Goutham, Tanmay Jagdale, Jisheng Zhang,
George Cherian, Witold Sadowski, Paul Cercueil
From: Tanmay Jagdale <tanmay@marvell.com>
Make the code simpler by just passing down a 'cs' variable as argument
to the cdns_xspi_send_stig_command() function.
Signed-off-by: Tanmay Jagdale <tanmay@marvell.com>
Co-developed-by: Paul Cercueil <paul.cercueil@bootlin.com>
Signed-off-by: Paul Cercueil <paul.cercueil@bootlin.com>
---
v2-v5: No change
---
drivers/spi/spi-cadence-xspi.c | 16 +++++-----------
1 file changed, 5 insertions(+), 11 deletions(-)
diff --git a/drivers/spi/spi-cadence-xspi.c b/drivers/spi/spi-cadence-xspi.c
index 7c7a604f4c62..c752328bf267 100644
--- a/drivers/spi/spi-cadence-xspi.c
+++ b/drivers/spi/spi-cadence-xspi.c
@@ -335,7 +335,6 @@ struct cdns_xspi_dev {
void __iomem *xferbase;
int irq;
- int cur_cs;
unsigned int sdmasize;
unsigned int sdma_xfer_len;
struct dma_chan *dma_chan;
@@ -672,7 +671,7 @@ static int cdns_xspi_sdma_handle(struct cdns_xspi_dev *cdns_xspi)
static int cdns_xspi_send_stig_command(struct cdns_xspi_dev *cdns_xspi,
const struct spi_mem_op *op,
- bool data_phase)
+ int cs, bool data_phase)
{
u32 cmd_regs[6];
u32 cmd_status;
@@ -697,8 +696,7 @@ static int cdns_xspi_send_stig_command(struct cdns_xspi_dev *cdns_xspi,
} else {
cmd_regs[3] = CDNS_XSPI_CMD_FLD_P1_INSTR_CMD_3(op, 0);
}
- cmd_regs[4] = CDNS_XSPI_CMD_FLD_P1_INSTR_CMD_4(op,
- cdns_xspi->cur_cs);
+ cmd_regs[4] = CDNS_XSPI_CMD_FLD_P1_INSTR_CMD_4(op, cs);
cdns_xspi_trigger_command(cdns_xspi, cmd_regs);
@@ -707,8 +705,7 @@ static int cdns_xspi_send_stig_command(struct cdns_xspi_dev *cdns_xspi,
cmd_regs[1] = CDNS_XSPI_CMD_FLD_DSEQ_CMD_1(op);
cmd_regs[2] = CDNS_XSPI_CMD_FLD_DSEQ_CMD_2(op);
cmd_regs[3] = CDNS_XSPI_CMD_FLD_DSEQ_CMD_3(op, dummybytes);
- cmd_regs[4] = CDNS_XSPI_CMD_FLD_DSEQ_CMD_4(op,
- cdns_xspi->cur_cs);
+ cmd_regs[4] = CDNS_XSPI_CMD_FLD_DSEQ_CMD_4(op, cs);
cdns_xspi->in_buffer = op->data.buf.in;
cdns_xspi->out_buffer = op->data.buf.out;
@@ -743,11 +740,9 @@ static int cdns_xspi_mem_op(struct cdns_xspi_dev *cdns_xspi,
const struct spi_mem_op *op)
{
enum spi_mem_data_dir dir = op->data.dir;
+ int cs = spi_get_chipselect(mem->spi, 0);
- if (cdns_xspi->cur_cs != spi_get_chipselect(mem->spi, 0))
- cdns_xspi->cur_cs = spi_get_chipselect(mem->spi, 0);
-
- return cdns_xspi_send_stig_command(cdns_xspi, op,
+ return cdns_xspi_send_stig_command(cdns_xspi, op, cs,
(dir != SPI_MEM_NO_DATA));
}
@@ -1411,7 +1406,6 @@ static int cdns_xspi_probe(struct platform_device *pdev)
cdns_xspi->pdev = pdev;
cdns_xspi->host = host;
cdns_xspi->dev = &pdev->dev;
- cdns_xspi->cur_cs = 0;
init_completion(&cdns_xspi->cmd_complete);
init_completion(&cdns_xspi->auto_cmd_complete);
--
2.47.3
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH v5 6/7] spi: cadence-xspi: Rework resource discovery
2026-11-20 11:59 [PATCH v5 0/7] spi: cadence-xspi: Fixes and ACPI changes Paul Cercueil
` (4 preceding siblings ...)
2026-11-20 11:59 ` [PATCH v5 5/7] spi: cadence-xspi: Drop useless cdns_xspi->cur_cs Paul Cercueil
@ 2026-11-20 11:59 ` Paul Cercueil
2026-11-27 1:28 ` Mark Brown
2026-11-20 11:59 ` [PATCH v5 7/7] spi: cadence-xspi: Add workaround for old Marvell firmwares Paul Cercueil
2026-11-27 1:31 ` (subset) [PATCH v5 0/7] spi: cadence-xspi: Fixes and ACPI changes Mark Brown
7 siblings, 1 reply; 11+ messages in thread
From: Paul Cercueil @ 2026-11-20 11:59 UTC (permalink / raw)
To: Mark Brown
Cc: linux-spi, linux-kernel, Thomas Petazzoni, Bharat Bhushan,
Sunil Kovvuri Goutham, Tanmay Jagdale, Jisheng Zhang,
George Cherian, Witold Sadowski, Paul Cercueil
From: Tanmay Jagdale <tanmay@marvell.com>
The previous code worked, but calling
devm_platform_ioremap_resource_byname() on ACPI where resources aren't
named causes warnings to be printed, one per call:
cadence-xspi PRP0001:02: error -EINVAL: invalid resource (null)
cadence-xspi PRP0001:02: error -EINVAL: invalid resource (null)
cadence-xspi PRP0001:02: error -EINVAL: invalid resource (null)
cadence-xspi PRP0001:02: error -EINVAL: invalid resource (null)
We can avoid these warnings by first obtaining a pointer to the resource
with platform_get_resource_byname() and fallback to
platform_get_resource() if it fails, and then ioremap the resource using
devm_ioremap_resource().
Signed-off-by: Tanmay Jagdale <tanmay@marvell.com>
Co-developed-by: Paul Cercueil <paul.cercueil@bootlin.com>
Signed-off-by: Paul Cercueil <paul.cercueil@bootlin.com>
---
v2: - Drop warnings. devm_ioremap_resource() already warns.
v3-v5: No change
---
drivers/spi/spi-cadence-xspi.c | 56 ++++++++++++++++------------------
1 file changed, 27 insertions(+), 29 deletions(-)
diff --git a/drivers/spi/spi-cadence-xspi.c b/drivers/spi/spi-cadence-xspi.c
index c752328bf267..dbfb07e6751f 100644
--- a/drivers/spi/spi-cadence-xspi.c
+++ b/drivers/spi/spi-cadence-xspi.c
@@ -1415,48 +1415,46 @@ static int cdns_xspi_probe(struct platform_device *pdev)
if (ret)
return -ENODEV;
- cdns_xspi->iobase = devm_platform_ioremap_resource_byname(pdev, "io");
- if (IS_ERR(cdns_xspi->iobase)) {
- cdns_xspi->iobase = devm_platform_ioremap_resource(pdev, 0);
- if (IS_ERR(cdns_xspi->iobase)) {
- dev_err(dev, "Failed to remap controller base address\n");
- return PTR_ERR(cdns_xspi->iobase);
- }
- }
+ res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "io");
+ if (!res)
+ res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+
+ cdns_xspi->iobase = devm_ioremap_resource(dev, res);
+ if (IS_ERR(cdns_xspi->iobase))
+ return PTR_ERR(cdns_xspi->iobase);
res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "sdma");
- cdns_xspi->sdmabase = devm_ioremap_resource(dev, res);
- if (IS_ERR(cdns_xspi->sdmabase)) {
+ if (!res)
res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
- cdns_xspi->sdmabase = devm_ioremap_resource(dev, res);
- if (IS_ERR(cdns_xspi->sdmabase))
- return PTR_ERR(cdns_xspi->sdmabase);
- }
+
+ cdns_xspi->sdmabase = devm_ioremap_resource(dev, res);
+ if (IS_ERR(cdns_xspi->sdmabase))
+ return PTR_ERR(cdns_xspi->sdmabase);
cdns_xspi->sdmasize = resource_size(res);
ret = cdns_xspi_dma_init(cdns_xspi, res->start);
if (ret)
return ret;
- cdns_xspi->auxbase = devm_platform_ioremap_resource_byname(pdev, "aux");
- if (IS_ERR(cdns_xspi->auxbase)) {
- cdns_xspi->auxbase = devm_platform_ioremap_resource(pdev, 2);
- if (IS_ERR(cdns_xspi->auxbase)) {
- dev_err(dev, "Failed to remap AUX address\n");
- return PTR_ERR(cdns_xspi->auxbase);
- }
- }
+ res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "aux");
+ if (!res)
+ res = platform_get_resource(pdev, IORESOURCE_MEM, 2);
+
+ cdns_xspi->auxbase = devm_ioremap_resource(dev, res);
+ if (IS_ERR(cdns_xspi->auxbase))
+ return PTR_ERR(cdns_xspi->auxbase);
#ifdef CONFIG_64BIT
if (cdns_xspi->driver_data->mrvl_hw_overlay) {
- cdns_xspi->xferbase = devm_platform_ioremap_resource_byname(pdev, "xfer");
+ res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "xfer");
+ if (!res)
+ res = platform_get_resource(pdev, IORESOURCE_MEM, 3);
+
+ cdns_xspi->xferbase = devm_ioremap_resource(dev, res);
if (IS_ERR(cdns_xspi->xferbase)) {
- cdns_xspi->xferbase = devm_platform_ioremap_resource(pdev, 3);
- if (IS_ERR(cdns_xspi->xferbase)) {
- dev_info(dev, "XFER register base not found, set it\n");
- // For compatibility with older firmware
- cdns_xspi->xferbase = cdns_xspi->iobase + 0x8000;
- }
+ dev_info(dev, "XFER register base not found, set it\n");
+ // For compatibility with older firmware
+ cdns_xspi->xferbase = cdns_xspi->iobase + 0x8000;
}
}
#endif
--
2.47.3
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH v5 7/7] spi: cadence-xspi: Add workaround for old Marvell firmwares
2026-11-20 11:59 [PATCH v5 0/7] spi: cadence-xspi: Fixes and ACPI changes Paul Cercueil
` (5 preceding siblings ...)
2026-11-20 11:59 ` [PATCH v5 6/7] spi: cadence-xspi: Rework resource discovery Paul Cercueil
@ 2026-11-20 11:59 ` Paul Cercueil
2026-11-27 1:31 ` (subset) [PATCH v5 0/7] spi: cadence-xspi: Fixes and ACPI changes Mark Brown
7 siblings, 0 replies; 11+ messages in thread
From: Paul Cercueil @ 2026-11-20 11:59 UTC (permalink / raw)
To: Mark Brown
Cc: linux-spi, linux-kernel, Thomas Petazzoni, Bharat Bhushan,
Sunil Kovvuri Goutham, Tanmay Jagdale, Jisheng Zhang,
George Cherian, Witold Sadowski, Paul Cercueil
From: Tanmay Jagdale <tanmay@marvell.com>
Older firmwares from Marvell used the cdns,xspi-nor compatible string
for the Marvell-specific xSPI IP, which is incompatible.
Add a workaround to support this case, checking for a Marvell board in
the DTB or the ACPI tables.
Signed-off-by: Tanmay Jagdale <tanmay@marvell.com>
Co-developed-by: Paul Cercueil <paul.cercueil@bootlin.com>
Signed-off-by: Paul Cercueil <paul.cercueil@bootlin.com>
---
v2: Replace the workaround based on the presence of the "xfer" resource
with a mechanism that identifies a Marvell SoC based on the board's
compatible string on DTB, and the DSDT table on ACPI.
v3: Wrap ACPI specific code with CONFIG_ACPI guards, as some of the
functions and structs aren't defined without CONFIG_ACPI.
v4-v5: No change
---
drivers/spi/spi-cadence-xspi.c | 41 +++++++++++++++++++++++++++++++++-
1 file changed, 40 insertions(+), 1 deletion(-)
diff --git a/drivers/spi/spi-cadence-xspi.c b/drivers/spi/spi-cadence-xspi.c
index dbfb07e6751f..4dea1a68fe8d 100644
--- a/drivers/spi/spi-cadence-xspi.c
+++ b/drivers/spi/spi-cadence-xspi.c
@@ -2,6 +2,7 @@
// Cadence XSPI flash controller driver
// Copyright (C) 2020-21 Cadence
+#include <linux/acpi.h>
#include <linux/completion.h>
#include <linux/delay.h>
#include <linux/dmaengine.h>
@@ -13,11 +14,13 @@
#include <linux/iopoll.h>
#include <linux/kernel.h>
#include <linux/module.h>
+#include <linux/of.h>
#include <linux/platform_device.h>
#include <linux/pm_runtime.h>
#include <linux/property.h>
#include <linux/spi/spi.h>
#include <linux/spi/spi-mem.h>
+#include <linux/string.h>
#include <linux/bitfield.h>
#include <linux/limits.h>
#include <linux/log2.h>
@@ -906,7 +909,6 @@ static void cdns_xspi_print_phy_config(struct cdns_xspi_dev *cdns_xspi)
readl(cdns_xspi->auxbase + CDNS_XSPI_CCP_PHY_DLL_SLAVE_CTRL));
}
-#ifdef CONFIG_64BIT
static struct cdns_xspi_driver_data marvell_driver_data = {
.mrvl_hw_overlay = true,
.dll_phy_ctrl = MARVELL_REGS_DLL_PHY_CTRL,
@@ -919,6 +921,7 @@ static struct cdns_xspi_driver_data marvell_driver_data = {
.rfile_phy_dll_slave_ctrl = MARVELL_RFILE_PHY_DLL_SLAVE_CTRL,
};
+#ifdef CONFIG_64BIT
static const int cdns_mrvl_xspi_clk_div_list[] = {
4, //0x0 = Divide by 4. SPI clock is 200 MHz.
6, //0x1 = Divide by 6. SPI clock is 133.33 MHz.
@@ -1367,6 +1370,33 @@ static int cdns_xspi_transfer_one_message_b0(struct spi_controller *controller,
}
#endif
+#ifdef CONFIG_ACPI
+static const struct acpi_platform_list mrvl_platform_list[] = {
+ {
+ .oem_id = "MRVL ",
+ .oem_table_id = "CN10K",
+ .table = ACPI_SIG_DSDT,
+ .pred = all_versions,
+ },
+ { }
+};
+#endif
+
+static inline bool cdns_is_marvell(struct device *dev)
+{
+ const char *compatible;
+
+#ifdef CONFIG_ACPI
+ if (has_acpi_companion(dev))
+ return acpi_match_platform_list(mrvl_platform_list) >= 0;
+#endif
+
+ if (of_machine_read_compatible(&compatible, 0) < 0)
+ return false; /* shouldn't actually happen */
+
+ return strstarts(compatible, "marvell,");
+}
+
static int cdns_xspi_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
@@ -1388,6 +1418,15 @@ static int cdns_xspi_probe(struct platform_device *pdev)
if (!cdns_xspi->driver_data)
return -ENODEV;
+ if (IS_ENABLED(CONFIG_64BIT) &&
+ !cdns_xspi->driver_data->mrvl_hw_overlay &&
+ cdns_is_marvell(dev)) {
+ /* Some old firmwares use the base compatible string... */
+
+ dev_warn(dev, "Using the cdns,xspi-nor compatible string on a Marvell SoC. Please fix firmware!\n");
+ cdns_xspi->driver_data = &marvell_driver_data;
+ }
+
host->mem_ops = &cadence_xspi_mem_ops;
cdns_xspi->sdma_handler = &cdns_xspi_sdma_handle;
cdns_xspi->set_interrupts_handler = &cdns_xspi_set_interrupts;
--
2.47.3
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v5 6/7] spi: cadence-xspi: Rework resource discovery
2026-11-20 11:59 ` [PATCH v5 6/7] spi: cadence-xspi: Rework resource discovery Paul Cercueil
@ 2026-11-27 1:28 ` Mark Brown
2026-11-27 15:29 ` Paul Cercueil
0 siblings, 1 reply; 11+ messages in thread
From: Mark Brown @ 2026-11-27 1:28 UTC (permalink / raw)
To: Paul Cercueil
Cc: Mark Brown, linux-spi, linux-kernel, Thomas Petazzoni,
Bharat Bhushan, Sunil Kovvuri Goutham, Tanmay Jagdale,
Jisheng Zhang, George Cherian, Witold Sadowski
> The previous code worked, but calling
> devm_platform_ioremap_resource_byname() on ACPI where resources aren't
> named causes warnings to be printed, one per call:
>
> cadence-xspi PRP0001:02: error -EINVAL: invalid resource (null)
> cadence-xspi PRP0001:02: error -EINVAL: invalid resource (null)
> cadence-xspi PRP0001:02: error -EINVAL: invalid resource (null)
> cadence-xspi PRP0001:02: error -EINVAL: invalid resource (null)
> #ifdef CONFIG_64BIT
> if (cdns_xspi->driver_data->mrvl_hw_overlay) {
> - cdns_xspi->xferbase = devm_platform_ioremap_resource_byname(pdev, "xfer");
> + res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "xfer");
> + if (!res)
> + res = platform_get_resource(pdev, IORESOURCE_MEM, 3);
> +
> + cdns_xspi->xferbase = devm_ioremap_resource(dev, res);
> if (IS_ERR(cdns_xspi->xferbase)) {
> - cdns_xspi->xferbase = devm_platform_ioremap_resource(pdev, 3);
> - if (IS_ERR(cdns_xspi->xferbase)) {
> - dev_info(dev, "XFER register base not found, set it\n");
> - // For compatibility with older firmware
> - cdns_xspi->xferbase = cdns_xspi->iobase + 0x8000;
> - }
> + dev_info(dev, "XFER register base not found, set it\n");
> + // For compatibility with older firmware
> + cdns_xspi->xferbase = cdns_xspi->iobase + 0x8000;
Shouldn't we go directly here if res is NULL instead of trying to do the
ioremap, otherwise we'll continue to get errors? OTOH if we *do* have
the resource then we know we're supposed to use it instead of the legacy
one so we should propagate the error instead of guessing.
--
Mark Brown <broonie@kernel.org>
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: (subset) [PATCH v5 0/7] spi: cadence-xspi: Fixes and ACPI changes
2026-11-20 11:59 [PATCH v5 0/7] spi: cadence-xspi: Fixes and ACPI changes Paul Cercueil
` (6 preceding siblings ...)
2026-11-20 11:59 ` [PATCH v5 7/7] spi: cadence-xspi: Add workaround for old Marvell firmwares Paul Cercueil
@ 2026-11-27 1:31 ` Mark Brown
7 siblings, 0 replies; 11+ messages in thread
From: Mark Brown @ 2026-11-27 1:31 UTC (permalink / raw)
To: Paul Cercueil
Cc: linux-spi, linux-kernel, Thomas Petazzoni, Bharat Bhushan,
Sunil Kovvuri Goutham, Tanmay Jagdale, Jisheng Zhang,
George Cherian, Witold Sadowski
On Fri, 20 Nov 2026 12:59:18 +0100, Paul Cercueil wrote:
> spi: cadence-xspi: Fixes and ACPI changes
>
> Hi Mark,
>
> This is the v4 of my patchset that adds a few fixes to the cadence-xspi
> driver, some cleanups, as well as a workaround for probing the Marvell
> IP on firmwares that use the base string.
>
> [...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-7.5
Thanks!
[1/7] spi: cadence-xspi: Properly handle errors in .transfer_one_message
https://git.kernel.org/broonie/spi/c/ca89645f0d5a
[2/7] spi: cadence-xspi: Reconfigure to STIG mode before SPI message
https://git.kernel.org/broonie/spi/c/7983521ee731
[3/7] spi: cadence-xspi: Inform SPI core about size transferred
https://git.kernel.org/broonie/spi/c/4b3b8a72544f
[4/7] spi: cadence-xspi: Clear "SDMA ready" IRQ flag after polling
https://git.kernel.org/broonie/spi/c/31a9eb539567
[5/7] spi: cadence-xspi: Drop useless cdns_xspi->cur_cs
https://git.kernel.org/broonie/spi/c/b27e195dded4
[7/7] spi: cadence-xspi: Add workaround for old Marvell firmwares
https://git.kernel.org/broonie/spi/c/502760b2ba69
All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying
to this mail.
Thanks,
Mark
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v5 6/7] spi: cadence-xspi: Rework resource discovery
2026-11-27 1:28 ` Mark Brown
@ 2026-11-27 15:29 ` Paul Cercueil
0 siblings, 0 replies; 11+ messages in thread
From: Paul Cercueil @ 2026-11-27 15:29 UTC (permalink / raw)
To: Mark Brown
Cc: linux-spi, linux-kernel, Thomas Petazzoni, Bharat Bhushan,
Sunil Kovvuri Goutham, Tanmay Jagdale, Jisheng Zhang,
George Cherian, Witold Sadowski
Hi Mark,
Le vendredi 27 novembre 2026 à 01:28 +0000, Mark Brown a écrit :
> > The previous code worked, but calling
> > devm_platform_ioremap_resource_byname() on ACPI where resources aren't
> > named causes warnings to be printed, one per call:
> >
> > cadence-xspi PRP0001:02: error -EINVAL: invalid resource (null)
> > cadence-xspi PRP0001:02: error -EINVAL: invalid resource (null)
> > cadence-xspi PRP0001:02: error -EINVAL: invalid resource (null)
> > cadence-xspi PRP0001:02: error -EINVAL: invalid resource (null)
>
> > #ifdef CONFIG_64BIT
> > if (cdns_xspi->driver_data->mrvl_hw_overlay) {
> > - cdns_xspi->xferbase =
> > devm_platform_ioremap_resource_byname(pdev, "xfer");
> > + res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
> > "xfer");
> > + if (!res)
> > + res = platform_get_resource(pdev, IORESOURCE_MEM,
> > 3);
> > +
> > + cdns_xspi->xferbase = devm_ioremap_resource(dev, res);
> > if (IS_ERR(cdns_xspi->xferbase)) {
> > - cdns_xspi->xferbase =
> > devm_platform_ioremap_resource(pdev, 3);
> > - if (IS_ERR(cdns_xspi->xferbase)) {
> > - dev_info(dev, "XFER register base not
> > found, set it\n");
> > - // For compatibility with older firmware
> > - cdns_xspi->xferbase = cdns_xspi->iobase +
> > 0x8000;
> > - }
> > + dev_info(dev, "XFER register base not found, set
> > it\n");
> > + // For compatibility with older firmware
> > + cdns_xspi->xferbase = cdns_xspi->iobase + 0x8000;
>
> Shouldn't we go directly here if res is NULL instead of trying to do the
> ioremap, otherwise we'll continue to get errors? OTOH if we *do* have
> the resource then we know we're supposed to use it instead of the legacy
> one so we should propagate the error instead of guessing.
ACK. I'll send a new version.
Cheers,
-Paul
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2026-11-27 15:29 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-20 11:59 [PATCH v5 0/7] spi: cadence-xspi: Fixes and ACPI changes Paul Cercueil
2026-11-20 11:59 ` [PATCH v5 1/7] spi: cadence-xspi: Properly handle errors in .transfer_one_message Paul Cercueil
2026-11-20 11:59 ` [PATCH v5 2/7] spi: cadence-xspi: Reconfigure to STIG mode before SPI message Paul Cercueil
2026-11-20 11:59 ` [PATCH v5 3/7] spi: cadence-xspi: Inform SPI core about size transferred Paul Cercueil
2026-11-20 11:59 ` [PATCH v5 4/7] spi: cadence-xspi: Clear "SDMA ready" IRQ flag after polling Paul Cercueil
2026-11-20 11:59 ` [PATCH v5 5/7] spi: cadence-xspi: Drop useless cdns_xspi->cur_cs Paul Cercueil
2026-11-20 11:59 ` [PATCH v5 6/7] spi: cadence-xspi: Rework resource discovery Paul Cercueil
2026-11-27 1:28 ` Mark Brown
2026-11-27 15:29 ` Paul Cercueil
2026-11-20 11:59 ` [PATCH v5 7/7] spi: cadence-xspi: Add workaround for old Marvell firmwares Paul Cercueil
2026-11-27 1:31 ` (subset) [PATCH v5 0/7] spi: cadence-xspi: Fixes and ACPI changes Mark Brown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®