summaryrefslogtreecommitdiffstats
path: root/sys/arm/freescale/imx/imx_sdhci.c
diff options
context:
space:
mode:
authorian <ian@FreeBSD.org>2015-12-18 01:25:30 +0000
committerian <ian@FreeBSD.org>2015-12-18 01:25:30 +0000
commit7292e552617fd10f13dffc4202d64eeddbc14bcb (patch)
tree794fb3c66e06ba5d74a78006e507f274158065a0 /sys/arm/freescale/imx/imx_sdhci.c
parenta12e9d2b9f45e8ba9e4392031bda53e5d047180d (diff)
downloadFreeBSD-src-7292e552617fd10f13dffc4202d64eeddbc14bcb.zip
FreeBSD-src-7292e552617fd10f13dffc4202d64eeddbc14bcb.tar.gz
Fix the clock divisor calc for imx6 sdcard bus speed.
I don't know what alternate universe I was inhabiting when I wrote it originally, but apparently the basic workings of mathematics were different than in this universe. I also can't explain how it ever worked, except "by accident", because completely bogus values were being written into the divisor register.
Diffstat (limited to 'sys/arm/freescale/imx/imx_sdhci.c')
-rw-r--r--sys/arm/freescale/imx/imx_sdhci.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/sys/arm/freescale/imx/imx_sdhci.c b/sys/arm/freescale/imx/imx_sdhci.c
index 6acc86e..17edf07 100644
--- a/sys/arm/freescale/imx/imx_sdhci.c
+++ b/sys/arm/freescale/imx/imx_sdhci.c
@@ -522,12 +522,19 @@ imx_sdhc_set_clock(struct imx_sdhci_softc *sc, int enable)
else
freq = sc->baseclk_hz / (2 * divisor);
- for (prescale = 2; prescale < freq / prescale / 16;)
+ for (prescale = 2; freq < sc->baseclk_hz / (prescale * 16);)
prescale <<= 1;
- for (divisor = 1; freq < freq / prescale / divisor;)
+ for (divisor = 1; freq < sc->baseclk_hz / (prescale * divisor);)
++divisor;
+#ifdef DEBUG
+ device_printf(sc->dev,
+ "desired SD freq: %d, actual: %d; base %d prescale %d divisor %d\n",
+ freq, sc->baseclk_hz / (prescale * divisor), sc->baseclk_hz,
+ prescale, divisor);
+#endif
+
prescale >>= 1;
divisor -= 1;
OpenPOWER on IntegriCloud