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.
This commit is contained in:
parent
a12e9d2b9f
commit
7292e55261
@ -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;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user