]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
spi: fsl-qspi: add a clock disable quirk
authorAlex Elder <elder@riscstar.com>
Mon, 27 Oct 2025 13:30:03 +0000 (08:30 -0500)
committerMark Brown <broonie@kernel.org>
Thu, 6 Nov 2025 16:57:34 +0000 (16:57 +0000)
The SpacemiT K1 SoC QSPI implementation needs to avoid shutting off the
clock when changing its rate.  Add a new quirk to indicate that disabling
and enabling the clock should be skipped when changing its rate.

Reviewed-by: Frank Li <Frank.Li@nxp.com>
Signed-off-by: Alex Elder <elder@riscstar.com>
Link: https://patch.msgid.link/20251027133008.360237-6-elder@riscstar.com
Signed-off-by: Mark Brown <broonie@kernel.org>
drivers/spi/spi-fsl-qspi.c

index 1944e63169d36f0db7916f2546f6fe0b1295cc85..2c030dd6facc7e3cfcd202ac00f6db15fe80b3d5 100644 (file)
  */
 #define QUADSPI_QUIRK_USE_TDH_SETTING  BIT(5)
 
+/*
+ * Do not disable the "qspi" clock when changing its rate.
+ */
+#define QUADSPI_QUIRK_SKIP_CLK_DISABLE BIT(6)
+
 struct fsl_qspi_devtype_data {
        unsigned int rxfifo;
        unsigned int txfifo;
@@ -306,6 +311,11 @@ static bool needs_tdh_setting(struct fsl_qspi *q)
        return !!(q->devtype_data->quirks & QUADSPI_QUIRK_USE_TDH_SETTING);
 }
 
+static bool needs_clk_disable(struct fsl_qspi *q)
+{
+       return !(q->devtype_data->quirks & QUADSPI_QUIRK_SKIP_CLK_DISABLE);
+}
+
 /*
  * An IC bug makes it necessary to rearrange the 32-bit data.
  * Later chips, such as IMX6SLX, have fixed this bug.
@@ -536,15 +546,18 @@ static void fsl_qspi_select_mem(struct fsl_qspi *q, struct spi_device *spi,
        if (needs_4x_clock(q))
                rate *= 4;
 
-       fsl_qspi_clk_disable_unprep(q);
+       if (needs_clk_disable(q))
+               fsl_qspi_clk_disable_unprep(q);
 
        ret = clk_set_rate(q->clk, rate);
        if (ret)
                return;
 
-       ret = fsl_qspi_clk_prep_enable(q);
-       if (ret)
-               return;
+       if (needs_clk_disable(q)) {
+               ret = fsl_qspi_clk_prep_enable(q);
+               if (ret)
+                       return;
+       }
 
        q->selected = spi_get_chipselect(spi, 0);