[PATCH 1/5] spi: cadence-xspi: Reconfigure to STIG mode before SPI message

From: Paul Cercueil

Date: Wed Nov 04 2026 - 05:11:47 EST


From: Tanmay Jagdale <tanmay@xxxxxxxxxxx>

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@xxxxxxxxxxxxxxx
Signed-off-by: Tanmay Jagdale <tanmay@xxxxxxxxxxx>
Co-developed-by: Paul Cercueil <paul.cercueil@xxxxxxxxxxx>
Signed-off-by: Paul Cercueil <paul.cercueil@xxxxxxxxxxx>
---
drivers/spi/spi-cadence-xspi.c | 28 ++++++++++++++++++++++------
1 file changed, 22 insertions(+), 6 deletions(-)

diff --git a/drivers/spi/spi-cadence-xspi.c b/drivers/spi/spi-cadence-xspi.c
index 3687853e4ce4..e3e265f51e56 100644
--- a/drivers/spi/spi-cadence-xspi.c
+++ b/drivers/spi/spi-cadence-xspi.c
@@ -367,6 +367,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])
{
@@ -536,12 +550,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;

cdns_xspi->set_interrupts_handler(cdns_xspi, true);
cdns_xspi->sdma_error = false;
@@ -1112,6 +1123,11 @@ 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;
+
+ ret = cdns_xspi_set_stig_mode(cdns_xspi);
+ if (ret)
+ return ret;

/* Enable xfer state machine */
if (!cdns_xspi->xfer_in_progress) {
--
2.47.3