From d03761f2ee7797a50ffd4720a5ef55a0b85c9c37 Mon Sep 17 00:00:00 2001 From: mglocker Date: Sat, 11 Sep 2021 22:42:12 +0000 Subject: [PATCH] Don't set the highspeed bit on bcm2835-sdhci sdhc(4) controllers. Same approach as on Linux and NetBSD. This fixes bwfm(4) Wi-Fi on the Raspberry Pi 3 Model B Plus. help and ok kettenis@ --- sys/dev/fdt/sdhc_fdt.c | 3 ++- sys/dev/sdmmc/sdhc.c | 13 ++++++++----- sys/dev/sdmmc/sdhcvar.h | 3 ++- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/sys/dev/fdt/sdhc_fdt.c b/sys/dev/fdt/sdhc_fdt.c index 9633d6630c2..6cc8beaaed4 100644 --- a/sys/dev/fdt/sdhc_fdt.c +++ b/sys/dev/fdt/sdhc_fdt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sdhc_fdt.c,v 1.16 2021/05/03 13:11:40 visa Exp $ */ +/* $OpenBSD: sdhc_fdt.c,v 1.17 2021/09/11 22:42:12 mglocker Exp $ */ /* * Copyright (c) 2017 Mark Kettenis * @@ -249,6 +249,7 @@ sdhc_fdt_attach(struct device *parent, struct device *self, void *aux) sc->sc.sc_clkbase = freq / 1000; sc->sc.sc_flags |= SDHC_F_32BIT_ACCESS; + sc->sc.sc_flags |= SDHC_F_NO_HS_BIT; } if (OF_is_compatible(faa->fa_node, "marvell,armada-3700-sdhci") || diff --git a/sys/dev/sdmmc/sdhc.c b/sys/dev/sdmmc/sdhc.c index 65e054649b0..6e6847b07ac 100644 --- a/sys/dev/sdmmc/sdhc.c +++ b/sys/dev/sdmmc/sdhc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sdhc.c,v 1.70 2021/06/13 06:57:51 jsg Exp $ */ +/* $OpenBSD: sdhc.c,v 1.71 2021/09/11 22:42:12 mglocker Exp $ */ /* * Copyright (c) 2006 Uwe Stuehler @@ -654,6 +654,7 @@ int sdhc_bus_clock(sdmmc_chipset_handle_t sch, int freq, int timing) { struct sdhc_host *hp = sch; + struct sdhc_softc *sc = hp->sc; int s; int div; int sdclk; @@ -679,10 +680,12 @@ sdhc_bus_clock(sdmmc_chipset_handle_t sch, int freq, int timing) if (freq == SDMMC_SDCLK_OFF) goto ret; - if (timing == SDMMC_TIMING_LEGACY) - HCLR1(hp, SDHC_HOST_CTL, SDHC_HIGH_SPEED); - else - HSET1(hp, SDHC_HOST_CTL, SDHC_HIGH_SPEED); + if (!ISSET(sc->sc_flags, SDHC_F_NO_HS_BIT)) { + if (timing == SDMMC_TIMING_LEGACY) + HCLR1(hp, SDHC_HOST_CTL, SDHC_HIGH_SPEED); + else + HSET1(hp, SDHC_HOST_CTL, SDHC_HIGH_SPEED); + } if (SDHC_SPEC_VERSION(hp->version) >= SDHC_SPEC_V3) { switch (timing) { diff --git a/sys/dev/sdmmc/sdhcvar.h b/sys/dev/sdmmc/sdhcvar.h index 8a04c0a5725..831ac2e9111 100644 --- a/sys/dev/sdmmc/sdhcvar.h +++ b/sys/dev/sdmmc/sdhcvar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: sdhcvar.h,v 1.14 2020/05/22 10:23:14 patrick Exp $ */ +/* $OpenBSD: sdhcvar.h,v 1.15 2021/09/11 22:42:12 mglocker Exp $ */ /* * Copyright (c) 2006 Uwe Stuehler @@ -52,5 +52,6 @@ void sdhc_needs_discover(struct sdhc_softc *); #define SDHC_F_NODDR50 (1 << 1) #define SDHC_F_NONREMOVABLE (1 << 2) #define SDHC_F_32BIT_ACCESS (1 << 3) +#define SDHC_F_NO_HS_BIT (1 << 4) #endif -- 2.20.1