[PATCH 04/30] mci: tuning: fix fallback to DDR52
Ahmad Fatoum
a.fatoum at pengutronix.de
Mon May 5 05:06:07 PDT 2025
When CONFIG_MCI_TUNING is enabled, but a card mmc_card_hs200 return
false, the fallback currently puts the card into high speed mode instead
of DDR52, which would've been the next best thing.
Rework the code to fix this.
Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
drivers/mci/mci-core.c | 31 ++++++++++++++++---------------
1 file changed, 16 insertions(+), 15 deletions(-)
diff --git a/drivers/mci/mci-core.c b/drivers/mci/mci-core.c
index 54d3fab4f10c..bb345dc5454e 100644
--- a/drivers/mci/mci-core.c
+++ b/drivers/mci/mci-core.c
@@ -1781,34 +1781,35 @@ static int mci_startup_mmc(struct mci *mci)
}
if (IS_ENABLED(CONFIG_MCI_TUNING)) {
- /*
- * Select timing interface
- */
+ dev_dbg(&mci->dev, "select timing %s\n", mci_timing_tostr(host->ios.timing));
+
ret = mmc_select_timing(mci);
if (ret)
return ret;
- if (mmc_card_hs200(mci))
+ if (mmc_card_hs200(mci)) {
ret = mmc_hs200_tuning(mci);
+ if (!ret) {
+ dev_dbg(&mci->dev, "HS200 tuning succeeded\n");
+ return 0;
+ }
+
+ dev_dbg(&mci->dev, "HS200 tuning failed, falling back to HS\n");
- if (ret) {
host->ios.timing = MMC_TIMING_MMC_HS;
mci_switch(mci, EXT_CSD_HS_TIMING, EXT_CSD_TIMING_HS);
}
}
- if (ret || !IS_ENABLED(CONFIG_MCI_TUNING)) {
- mci_set_clock(mci, mci->tran_speed);
+ mci_set_clock(mci, mci->tran_speed);
- /* find out maximum bus width and then try DDR if supported */
- ret = mci_mmc_select_bus_width(mci);
- if (ret > MMC_BUS_WIDTH_1 && mci->tran_speed == 52000000)
- ret = mci_mmc_select_hs_ddr(mci);
+ /* find out maximum bus width and then try DDR if supported */
+ ret = mci_mmc_select_bus_width(mci);
+ if (ret > MMC_BUS_WIDTH_1 && mci->tran_speed == 52000000)
+ ret = mci_mmc_select_hs_ddr(mci);
- if (ret < 0) {
- dev_warn(&mci->dev, "Changing MMC bus width failed: %d\n", ret);
- }
- }
+ if (ret < 0)
+ dev_warn(&mci->dev, "Changing MMC bus width failed: %d\n", ret);
return ret >= MMC_BUS_WIDTH_1 ? 0 : ret;
}
--
2.39.5
More information about the barebox
mailing list