Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/arm/rockchip Don't fail if we cannot compute the cl...



details:   https://anonhg.NetBSD.org/src/rev/ed743aa447d7
branches:  trunk
changeset: 850319:ed743aa447d7
user:      tnn <tnn%NetBSD.org@localhost>
date:      Wed Apr 01 20:37:32 2020 +0000

description:
Don't fail if we cannot compute the clock divider because the master
clock is too slow for what the slave device requested.
Instead warn and select the highest available slave clock rate.
Should fix boot hang on Pinebook Pro when using spiflash(4).

diffstat:

 sys/arch/arm/rockchip/rk_spi.c |  12 ++++++++----
 1 files changed, 8 insertions(+), 4 deletions(-)

diffs (33 lines):

diff -r 2794e5a86353 -r ed743aa447d7 sys/arch/arm/rockchip/rk_spi.c
--- a/sys/arch/arm/rockchip/rk_spi.c    Wed Apr 01 20:24:50 2020 +0000
+++ b/sys/arch/arm/rockchip/rk_spi.c    Wed Apr 01 20:37:32 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rk_spi.c,v 1.3 2019/08/13 17:15:55 tnn Exp $   */
+/*     $NetBSD: rk_spi.c,v 1.4 2020/04/01 20:37:32 tnn Exp $   */
 
 /*
  * Copyright (c) 2019 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rk_spi.c,v 1.3 2019/08/13 17:15:55 tnn Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rk_spi.c,v 1.4 2020/04/01 20:37:32 tnn Exp $");
 
 #include <sys/param.h>
 #include <sys/device.h>
@@ -277,8 +277,12 @@
        uint16_t divider;
 
        divider = (sc->sc_spi_freq / speed) & ~1;
-       if (divider < 2)
-               return EINVAL;
+       if (divider < 2) {
+               aprint_error_dev(sc->sc_dev,
+                   "spi_clk %u is too low for speed %u, using speed %u\n",
+                    sc->sc_spi_freq, speed, sc->sc_spi_freq / 2);
+               divider = 2;
+       }
 
        if (slave >= sc->sc_spi.sct_nslaves)
                return EINVAL;



Home | Main Index | Thread Index | Old Index