[PATCH v1 04/11] spi: rockchip-sfc: sanity check minimum freq

Peter Geis pgwipeout at gmail.com
Tue Feb 22 02:31:23 CET 2022


The rockchip-sfc driver sanity checks the maximum frequency, but not the
minimum frequency.
This causes the probe to fail when a frequency isn't defined, such as
with `sf probe 0`.
Clamp the minimum frequency to the rockchip default clock rate.

Signed-off-by: Peter Geis <pgwipeout at gmail.com>
---
 drivers/spi/rockchip_sfc.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/spi/rockchip_sfc.c b/drivers/spi/rockchip_sfc.c
index 851a6482985b..d0d2dc70a417 100644
--- a/drivers/spi/rockchip_sfc.c
+++ b/drivers/spi/rockchip_sfc.c
@@ -164,6 +164,8 @@
 /* DMA is only enabled for large data transmission */
 #define SFC_DMA_TRANS_THRETHOLD		(0x40)
 
+#define SFC_MIN_SPEED		(24 * 1000 * 1000)
+
 /* Maximum clock values from datasheet suggest keeping clock value under
  * 150MHz. No minimum or average value is suggested.
  */
@@ -596,6 +598,9 @@ static int rockchip_sfc_set_speed(struct udevice *bus, uint speed)
 	if (speed > sfc->max_freq)
 		speed = sfc->max_freq;
 
+	if (speed < SFC_MIN_SPEED)
+		speed = SFC_MIN_SPEED;
+
 	if (speed == sfc->speed)
 		return 0;
 
-- 
2.25.1



More information about the U-Boot mailing list