Module Name:    src
Committed By:   tnn
Date:           Wed Apr  1 20:37:32 UTC 2020

Modified Files:
        src/sys/arch/arm/rockchip: rk_spi.c

Log Message:
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).


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/arm/rockchip/rk_spi.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/rockchip/rk_spi.c
diff -u src/sys/arch/arm/rockchip/rk_spi.c:1.3 src/sys/arch/arm/rockchip/rk_spi.c:1.4
--- src/sys/arch/arm/rockchip/rk_spi.c:1.3	Tue Aug 13 17:15:55 2019
+++ src/sys/arch/arm/rockchip/rk_spi.c	Wed Apr  1 20:37:32 2020
@@ -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 @@ rk_spi_configure(void *cookie, int slave
 	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;

Reply via email to