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 <pgwipe...@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

Reply via email to