The original code logic can not show the correct card clock, and also
has one risk when the div is 0. Because there is div -=1 before.
So move the operation before div -=1, and also involve ddr_pre_div
to get the correct value.
Signed-off-by: Haibo Chen <haibo.chen@nxp.com>
Reviewed-by: Marek Vasut <marex@denx.de>
while (sdhc_clk / (div * pre_div * ddr_pre_div) > clock && div < 16)
div++;
+ mmc->clock = sdhc_clk / pre_div / div / ddr_pre_div;
+
pre_div >>= 1;
div -= 1;
else
esdhc_setbits32(®s->sysctl, SYSCTL_PEREN | SYSCTL_CKEN);
- mmc->clock = sdhc_clk / pre_div / div;
priv->clock = clock;
}