commit e58e68d9 ("mmc: mtk-sd: assign plat->cfg.f_max with a correct value")
wrongly assumed that plat->cfg.f_max is always unset at the time
mscd_drv_probe() is run. This is not true in case max-frequency being
defined in device tree, as it is then already set by mmc_of_parse()
in msdc_of_to_plat().
Only set plat->cfg.f_max to the default maximum value in case it is
not already set to a sane value.

Fixes: e58e68d93e ("mmc: mtk-sd: assign plat->cfg.f_max with a correct value")
Cc: Stefan Roese <[email protected]>
Cc: Weijie Gao <[email protected]>
Signed-off-by: Daniel Golle <[email protected]>
---
 drivers/mmc/mtk-sd.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/mmc/mtk-sd.c b/drivers/mmc/mtk-sd.c
index 3b9c12266a..48a764be82 100644
--- a/drivers/mmc/mtk-sd.c
+++ b/drivers/mmc/mtk-sd.c
@@ -1639,7 +1639,8 @@ static int msdc_drv_probe(struct udevice *dev)
        else
                cfg->f_min = host->src_clk_freq / (4 * 4095);
 
-       cfg->f_max = host->src_clk_freq;
+       if (cfg->f_max < cfg->f_min || cfg->f_max > host->src_clk_freq)
+               cfg->f_max = host->src_clk_freq;
 
        cfg->b_max = 1024;
        cfg->voltages = MMC_VDD_32_33 | MMC_VDD_33_34;
-- 
2.30.2

Attachment: signature.asc
Description: PGP signature

Reply via email to