[PATCH 3/3] mmc: fsl_esdhc_imx: correct the actual card clock
haibo.chen at nxp.com
haibo.chen at nxp.com
Fri Feb 11 12:16:57 CET 2022
From: Haibo Chen <haibo.chen at nxp.com>
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 at nxp.com>
---
drivers/mmc/fsl_esdhc_imx.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/mmc/fsl_esdhc_imx.c b/drivers/mmc/fsl_esdhc_imx.c
index 0be7cae1e5..0ea7b0b50c 100644
--- a/drivers/mmc/fsl_esdhc_imx.c
+++ b/drivers/mmc/fsl_esdhc_imx.c
@@ -609,6 +609,8 @@ static void set_sysctl(struct fsl_esdhc_priv *priv, struct mmc *mmc, uint clock)
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;
@@ -630,7 +632,6 @@ static void set_sysctl(struct fsl_esdhc_priv *priv, struct mmc *mmc, uint clock)
else
esdhc_setbits32(®s->sysctl, SYSCTL_PEREN | SYSCTL_CKEN);
- mmc->clock = sdhc_clk / pre_div / div;
priv->clock = clock;
}
--
2.17.1
More information about the U-Boot
mailing list