summaryrefslogtreecommitdiff
path: root/sys/dev/sdmmc
diff options
context:
space:
mode:
Diffstat (limited to 'sys/dev/sdmmc')
-rw-r--r--sys/dev/sdmmc/sdhc.c11
-rw-r--r--sys/dev/sdmmc/sdhcreg.h4
-rw-r--r--sys/dev/sdmmc/sdhcvar.h3
3 files changed, 13 insertions, 5 deletions
diff --git a/sys/dev/sdmmc/sdhc.c b/sys/dev/sdmmc/sdhc.c
index cf5e355c70d..e7881a1a607 100644
--- a/sys/dev/sdmmc/sdhc.c
+++ b/sys/dev/sdmmc/sdhc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sdhc.c,v 1.56 2018/02/10 05:21:13 jmatthew Exp $ */
+/* $OpenBSD: sdhc.c,v 1.57 2018/03/19 21:40:32 kettenis Exp $ */
/*
* Copyright (c) 2006 Uwe Stuehler <uwe@openbsd.org>
@@ -203,6 +203,11 @@ sdhc_host_found(struct sdhc_softc *sc, bus_space_tag_t iot,
hp->clkbase = SDHC_BASE_FREQ_KHZ(caps);
}
if (hp->clkbase == 0) {
+ /* Make sure we can clock down to 400 kHz. */
+ max_clock = 400 * SDHC_SDCLK_DIV_MAX_V3;
+ hp->clkbase = sc->sc_clkbase;
+ }
+ if (hp->clkbase == 0) {
/* The attachment driver must tell us. */
printf("%s: base clock frequency unknown\n",
sc->sc_dev.dv_xname);
@@ -536,11 +541,11 @@ sdhc_bus_power(sdmmc_chipset_handle_t sch, u_int32_t ocr)
static int
sdhc_clock_divisor(struct sdhc_host *hp, u_int freq)
{
- int max_div = 256;
+ int max_div = SDHC_SDCLK_DIV_MAX;;
int div;
if (SDHC_SPEC_VERSION(hp->version) >= SDHC_SPEC_V3)
- max_div = 2046;
+ max_div = SDHC_SDCLK_DIV_MAX_V3;;
for (div = 1; div <= max_div; div *= 2)
if ((hp->clkbase / div) <= freq)
diff --git a/sys/dev/sdmmc/sdhcreg.h b/sys/dev/sdmmc/sdhcreg.h
index 8b221e879fa..97b3e748bff 100644
--- a/sys/dev/sdmmc/sdhcreg.h
+++ b/sys/dev/sdmmc/sdhcreg.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: sdhcreg.h,v 1.7 2016/04/30 11:49:29 kettenis Exp $ */
+/* $OpenBSD: sdhcreg.h,v 1.8 2018/03/19 21:40:32 kettenis Exp $ */
/*
* Copyright (c) 2006 Uwe Stuehler <uwe@openbsd.org>
@@ -211,6 +211,8 @@
#define SDHC_SDCLK_DIV_V3(div) \
(SDHC_SDCLK_DIV(div) | \
(((div) & SDHC_SDCLK_DIV_MASK_V3) >> SDHC_SDCLK_DIV_RSHIFT_V3))
+#define SDHC_SDCLK_DIV_MAX 256
+#define SDHC_SDCLK_DIV_MAX_V3 2046
/* SDHC_CAPABILITIES decoding */
#define SDHC_BASE_FREQ_KHZ(cap) \
diff --git a/sys/dev/sdmmc/sdhcvar.h b/sys/dev/sdmmc/sdhcvar.h
index 9d4d759a2bc..7775015ac97 100644
--- a/sys/dev/sdmmc/sdhcvar.h
+++ b/sys/dev/sdmmc/sdhcvar.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: sdhcvar.h,v 1.10 2017/05/05 15:10:07 kettenis Exp $ */
+/* $OpenBSD: sdhcvar.h,v 1.11 2018/03/19 21:40:32 kettenis Exp $ */
/*
* Copyright (c) 2006 Uwe Stuehler <uwe@openbsd.org>
@@ -28,6 +28,7 @@ struct sdhc_softc {
struct sdhc_host **sc_host;
int sc_nhosts;
u_int sc_flags;
+ u_int sc_clkbase;
bus_dma_tag_t sc_dmat;