summaryrefslogtreecommitdiff
path: root/drivers/mmc/mmc.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/mmc/mmc.c')
-rw-r--r--drivers/mmc/mmc.c32
1 files changed, 27 insertions, 5 deletions
diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
index 8078a89f18..d3babbfeb1 100644
--- a/drivers/mmc/mmc.c
+++ b/drivers/mmc/mmc.c
@@ -823,7 +823,7 @@ static int __mmc_switch(struct mmc *mmc, u8 set, u8 index, u8 value,
* capable of polling by using mmc_wait_dat0, then rely on waiting the
* stated timeout to be sufficient.
*/
- if (ret == -ENOSYS && !send_status) {
+ if (ret == -ENOSYS || !send_status) {
mdelay(timeout_ms);
return 0;
}
@@ -2092,14 +2092,16 @@ static int mmc_select_mode_and_width(struct mmc *mmc, uint card_caps)
}
#if CONFIG_IS_ENABLED(MMC_HS200_SUPPORT) || \
- CONFIG_IS_ENABLED(MMC_HS400_SUPPORT)
+ CONFIG_IS_ENABLED(MMC_HS400_SUPPORT) || \
+ CONFIG_IS_ENABLED(MMC_HS400_ES_SUPPORT)
/*
* In case the eMMC is in HS200/HS400 mode, downgrade to HS mode
* before doing anything else, since a transition from either of
* the HS200/HS400 mode directly to legacy mode is not supported.
*/
if (mmc->selected_mode == MMC_HS_200 ||
- mmc->selected_mode == MMC_HS_400)
+ mmc->selected_mode == MMC_HS_400 ||
+ mmc->selected_mode == MMC_HS_400_ES)
mmc_set_card_speed(mmc, MMC_HS, true);
else
#endif
@@ -2862,7 +2864,25 @@ int mmc_start_init(struct mmc *mmc)
* timings.
*/
mmc->host_caps = mmc->cfg->host_caps | MMC_CAP(MMC_LEGACY) |
- MMC_CAP(MMC_LEGACY) | MMC_MODE_1BIT;
+ MMC_MODE_1BIT;
+
+ if (IS_ENABLED(CONFIG_MMC_SPEED_MODE_SET)) {
+ if (mmc->user_speed_mode != MMC_MODES_END) {
+ int i;
+ /* set host caps */
+ if (mmc->host_caps & MMC_CAP(mmc->user_speed_mode)) {
+ /* Remove all existing speed capabilities */
+ for (i = MMC_LEGACY; i < MMC_MODES_END; i++)
+ mmc->host_caps &= ~MMC_CAP(i);
+ mmc->host_caps |= (MMC_CAP(mmc->user_speed_mode)
+ | MMC_CAP(MMC_LEGACY) |
+ MMC_MODE_1BIT);
+ } else {
+ pr_err("bus_mode requested is not supported\n");
+ return -EINVAL;
+ }
+ }
+ }
#if CONFIG_IS_ENABLED(DM_MMC)
mmc_deferred_probe(mmc);
#endif
@@ -2952,7 +2972,7 @@ int mmc_deinit(struct mmc *mmc)
return sd_select_mode_and_width(mmc, caps_filtered);
} else {
caps_filtered = mmc->card_caps &
- ~(MMC_CAP(MMC_HS_200) | MMC_CAP(MMC_HS_400));
+ ~(MMC_CAP(MMC_HS_200) | MMC_CAP(MMC_HS_400) | MMC_CAP(MMC_HS_400_ES));
return mmc_select_mode_and_width(mmc, caps_filtered);
}
@@ -3060,6 +3080,8 @@ int mmc_init_device(int num)
}
m = mmc_get_mmc_dev(dev);
+ m->user_speed_mode = MMC_MODES_END; /* Initialising user set speed mode */
+
if (!m)
return 0;
if (m->preinit)