svn commit: r292419 - head/sys/arm/freescale/imx
Ian Lepore
ian at FreeBSD.org
Fri Dec 18 01:25:31 UTC 2015
Author: ian
Date: Fri Dec 18 01:25:30 2015
New Revision: 292419
URL: https://svnweb.freebsd.org/changeset/base/292419
Log:
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.
Modified:
head/sys/arm/freescale/imx/imx_sdhci.c
Modified: head/sys/arm/freescale/imx/imx_sdhci.c
==============================================================================
--- head/sys/arm/freescale/imx/imx_sdhci.c Fri Dec 18 01:03:34 2015 (r292418)
+++ head/sys/arm/freescale/imx/imx_sdhci.c Fri Dec 18 01:25:30 2015 (r292419)
@@ -522,12 +522,19 @@ imx_sdhc_set_clock(struct imx_sdhci_soft
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;
More information about the svn-src-head
mailing list