diff options
author | Haibo Chen <haibo.chen@nxp.com> | 2022-02-11 19:16:57 +0800 |
---|---|---|
committer | Stefano Babic <sbabic@denx.de> | 2022-02-19 14:46:54 +0100 |
commit | d7d042e8b62d753c8b4fc4bbd1e3969448ed41a1 (patch) | |
tree | a20ba17b67c249e86afd13c78d6eafe231d4038c /drivers/mmc | |
parent | 45254edd9415df2923098f960b8e4d05aea24b74 (diff) | |
download | u-boot-d7d042e8b62d753c8b4fc4bbd1e3969448ed41a1.tar.gz |
mmc: fsl_esdhc_imx: correct the actual card clock
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>
Diffstat (limited to 'drivers/mmc')
-rw-r--r-- | drivers/mmc/fsl_esdhc_imx.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/mmc/fsl_esdhc_imx.c b/drivers/mmc/fsl_esdhc_imx.c index 29a945ed73..697e3c641d 100644 --- a/drivers/mmc/fsl_esdhc_imx.c +++ b/drivers/mmc/fsl_esdhc_imx.c @@ -608,6 +608,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; @@ -629,7 +631,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; } |