Module Name: src
Committed By: tnn
Date: Sun Sep 3 11:36:52 UTC 2023
Modified Files:
src/sys/arch/arm/broadcom: bcm2835_spi.c
Log Message:
bcm2835_spi: guard against too large clock divider and clamp if necessary
To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/arm/broadcom/bcm2835_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/broadcom/bcm2835_spi.c
diff -u src/sys/arch/arm/broadcom/bcm2835_spi.c:1.12 src/sys/arch/arm/broadcom/bcm2835_spi.c:1.13
--- src/sys/arch/arm/broadcom/bcm2835_spi.c:1.12 Sat May 7 07:26:27 2022
+++ src/sys/arch/arm/broadcom/bcm2835_spi.c Sun Sep 3 11:36:52 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: bcm2835_spi.c,v 1.12 2022/05/07 07:26:27 skrll Exp $ */
+/* $NetBSD: bcm2835_spi.c,v 1.13 2023/09/03 11:36:52 tnn Exp $ */
/*
* Copyright (c) 2012 Jonathan A. Kollasch
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: bcm2835_spi.c,v 1.12 2022/05/07 07:26:27 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bcm2835_spi.c,v 1.13 2023/09/03 11:36:52 tnn Exp $");
#include <sys/param.h>
#include <sys/device.h>
@@ -182,6 +182,8 @@ bcmspi_configure(void *cookie, int slave
clk = 2 * 250000000 / speed; /* XXX 250MHz */
clk = (clk / 2) + (clk & 1);
clk = roundup(clk, 2);
+ if (clk >= 0xfffe)
+ clk = 0xfffe;
clk = __SHIFTIN(clk, SPI_CLK_CDIV);
bus_space_write_4(sc->sc_iot, sc->sc_ioh, SPI_CLK, clk);