[PATCH 1/5] spi: spi-zynqmp-gqspi: Factor out zynqmp_qspi_disable_hw()

Srikanth Boyapally srikanth.boyapally at amd.com
Sun Nov 15 08:56:40 PST 2026


From: Mohammad Zeeshan <zeeshan.mohammad2 at amd.com>

Move the clear-mask-disable sequence out of zynqmp_qspi_init_hw() into
its own zynqmp_qspi_disable_hw(), so it can be reused by other paths
that need to stop the controller.

No functional change: this is pure code motion, zynqmp_qspi_init_hw()
calls the new helper in exactly the same place it used to run the
sequence inline.

Signed-off-by: Mohammad Zeeshan <zeeshan.mohammad2 at amd.com>
Signed-off-by: Srikanth Boyapally <srikanth.boyapally at amd.com>
---
 drivers/spi/spi-zynqmp-gqspi.c | 54 ++++++++++++++++++++++++++----------------
 1 file changed, 34 insertions(+), 20 deletions(-)

diff --git a/drivers/spi/spi-zynqmp-gqspi.c b/drivers/spi/spi-zynqmp-gqspi.c
index 15e9d3ef8839..0da44ebaf39c 100644
--- a/drivers/spi/spi-zynqmp-gqspi.c
+++ b/drivers/spi/spi-zynqmp-gqspi.c
@@ -280,6 +280,38 @@ static void zynqmp_gqspi_selecttarget(struct zynqmp_qspi *instanceptr,
 	}
 }
 
+/**
+ * zynqmp_qspi_disable_hw - Clear and mask all interrupts, stop the controller
+ * @xqspi:	Pointer to the zynqmp_qspi structure
+ *
+ * Acknowledges any pending GQSPI and DMA status, masks every interrupt source
+ * and disables the controller. Used when (re)initialising the hardware and
+ * when handing the system over on reboot, poweroff or kexec.
+ */
+static void zynqmp_qspi_disable_hw(struct zynqmp_qspi *xqspi)
+{
+	/* Select the GQSPI mode */
+	zynqmp_gqspi_write(xqspi, GQSPI_SEL_OFST, GQSPI_SEL_MASK);
+	/* Clear and disable interrupts */
+	zynqmp_gqspi_write(xqspi, GQSPI_ISR_OFST,
+			   zynqmp_gqspi_read(xqspi, GQSPI_ISR_OFST) |
+			   GQSPI_ISR_WR_TO_CLR_MASK);
+	/* Clear the DMA STS */
+	zynqmp_gqspi_write(xqspi, GQSPI_QSPIDMA_DST_I_STS_OFST,
+			   zynqmp_gqspi_read(xqspi,
+					     GQSPI_QSPIDMA_DST_I_STS_OFST));
+	zynqmp_gqspi_write(xqspi, GQSPI_QSPIDMA_DST_STS_OFST,
+			   zynqmp_gqspi_read(xqspi,
+					     GQSPI_QSPIDMA_DST_STS_OFST) |
+					     GQSPI_QSPIDMA_DST_STS_WTC);
+	zynqmp_gqspi_write(xqspi, GQSPI_IDR_OFST, GQSPI_IDR_ALL_MASK);
+	zynqmp_gqspi_write(xqspi,
+			   GQSPI_QSPIDMA_DST_I_DIS_OFST,
+			   GQSPI_QSPIDMA_DST_INTR_ALL_MASK);
+	/* Disable the GQSPI */
+	zynqmp_gqspi_write(xqspi, GQSPI_EN_OFST, 0x0);
+}
+
 /**
  * zynqmp_qspi_set_tapdelay:   To configure qspi tap delays
  * @xqspi:             Pointer to the zynqmp_qspi structure
@@ -355,26 +387,8 @@ static void zynqmp_qspi_init_hw(struct zynqmp_qspi *xqspi)
 	u32 config_reg, baud_rate_val = 0;
 	ulong clk_rate;
 
-	/* Select the GQSPI mode */
-	zynqmp_gqspi_write(xqspi, GQSPI_SEL_OFST, GQSPI_SEL_MASK);
-	/* Clear and disable interrupts */
-	zynqmp_gqspi_write(xqspi, GQSPI_ISR_OFST,
-			   zynqmp_gqspi_read(xqspi, GQSPI_ISR_OFST) |
-			   GQSPI_ISR_WR_TO_CLR_MASK);
-	/* Clear the DMA STS */
-	zynqmp_gqspi_write(xqspi, GQSPI_QSPIDMA_DST_I_STS_OFST,
-			   zynqmp_gqspi_read(xqspi,
-					     GQSPI_QSPIDMA_DST_I_STS_OFST));
-	zynqmp_gqspi_write(xqspi, GQSPI_QSPIDMA_DST_STS_OFST,
-			   zynqmp_gqspi_read(xqspi,
-					     GQSPI_QSPIDMA_DST_STS_OFST) |
-					     GQSPI_QSPIDMA_DST_STS_WTC);
-	zynqmp_gqspi_write(xqspi, GQSPI_IDR_OFST, GQSPI_IDR_ALL_MASK);
-	zynqmp_gqspi_write(xqspi,
-			   GQSPI_QSPIDMA_DST_I_DIS_OFST,
-			   GQSPI_QSPIDMA_DST_INTR_ALL_MASK);
-	/* Disable the GQSPI */
-	zynqmp_gqspi_write(xqspi, GQSPI_EN_OFST, 0x0);
+	zynqmp_qspi_disable_hw(xqspi);
+
 	config_reg = zynqmp_gqspi_read(xqspi, GQSPI_CONFIG_OFST);
 	config_reg &= ~GQSPI_CFG_MODE_EN_MASK;
 	/* Manual start */

-- 
2.43.0




More information about the linux-arm-kernel mailing list