U-Boot Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] spi: fsl_qspi: Add optional clock support
@ 2026-11-20 14:43 Yixun Lan
  2026-11-21 22:14 ` E Shattow
  0 siblings, 1 reply; 4+ messages in thread
From: Yixun Lan @ 2026-11-20 14:43 UTC (permalink / raw)
  To: u-boot; +Cc: Tom Rini, Raymond Mao, Yixun Lan

The clock required by QSPI controller may not be enabled by default,
So explicitly get and enable the clocks described by the DT node, due
to keep compatibility reason, keep the clock optional for platforms if
there is no clock framework support or no clocks property provided.

Signed-off-by: Yixun Lan <dlan@kernel.org>
---
While testing in SpacemiT K3 Platform, we found the QSPI clock need to
be explicitly enabled if boot from USB fastboot mode. While there is no
problem in booting from SPI nor flash mode which the clock already
enabled by BROM code.

In order to not break other platforms, try to set the clock optional,
so it won't abort if there is no clock framework support, or no clock
device tree property.
---
 drivers/spi/fsl_qspi.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/drivers/spi/fsl_qspi.c b/drivers/spi/fsl_qspi.c
index 5692510a558..454dfaf1814 100644
--- a/drivers/spi/fsl_qspi.c
+++ b/drivers/spi/fsl_qspi.c
@@ -23,6 +23,7 @@
  * Transition to spi-mem in spi-fsl-qspi.c
  */
 
+#include <clk.h>
 #include <dm.h>
 #include <dm/device_compat.h>
 #include <log.h>
@@ -716,6 +717,29 @@ static int fsl_qspi_adjust_op_size(struct spi_slave *slave,
 	return 0;
 }
 
+static int fsl_qspi_clock_setup(struct fsl_qspi *q)
+{
+	struct clk_bulk clks;
+	int ret;
+
+	ret = clk_get_bulk(q->dev, &clks);
+
+	/* Ignore if no DT clock property or no clock framework support */
+	if (ret == -ENOENT || ret == -ENOSYS)
+		return 0;
+
+	if (ret) {
+		dev_err(q->dev, "Failed to get clocks: %d\n", ret);
+		return ret;
+	}
+
+	ret = clk_enable_bulk(&clks);
+	if (ret)
+		dev_err(q->dev, "Failed to enable clocks: %d\n", ret);
+
+	return ret;
+}
+
 static int fsl_qspi_default_setup(struct fsl_qspi *q)
 {
 	void __iomem *base = q->iobase;
@@ -829,6 +853,7 @@ static int fsl_qspi_probe(struct udevice *bus)
 	dm_bus->max_hz = fdtdec_get_int(blob, node, "spi-max-frequency",
 					66000000);
 
+	fsl_qspi_clock_setup(q);
 	fsl_qspi_default_setup(q);
 
 	return 0;

---
base-commit: c1958b5f6cce03956d309ce422b5d9f819955d4a
change-id: 20261120-05-fsl-qspi-clock-e3df6b72ab8a

Best regards,
--  
Yixun Lan <dlan@kernel.org>


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-11-25 12:04 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-20 14:43 [PATCH] spi: fsl_qspi: Add optional clock support Yixun Lan
2026-11-21 22:14 ` E Shattow
2026-11-22  0:38   ` Yixun Lan
2026-11-25 12:04     ` E Shattow

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox