diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c index fde49464a637..a88d9b908d97 100644 --- a/drivers/mmc/host/dw_mmc.c +++ b/drivers/mmc/host/dw_mmc.c @@ -1468,7 +1468,7 @@ static void dw_mci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) { struct dw_mci_slot *slot = mmc_priv(mmc); const struct dw_mci_drv_data *drv_data = slot->host->drv_data; - u32 regs; + u32 regs, power_off_delay; int ret; switch (ios->bus_width) { @@ -1507,8 +1507,14 @@ static void dw_mci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) switch (ios->power_mode) { case MMC_POWER_UP: - if (!IS_ERR_OR_NULL(slot->host->pinctrl)) - pinctrl_select_state(slot->host->pinctrl, slot->host->idle_state); + if (dw_mci_get_cd(mmc) && !IS_ERR_OR_NULL(slot->host->pinctrl)) { + if (!pinctrl_select_state(slot->host->pinctrl, slot->host->idle_state)) { + if (device_property_read_u32(slot->host->dev, "power-off-delay-ms", + &power_off_delay)) + power_off_delay = 200; + msleep(power_off_delay); + } + } if (!IS_ERR(mmc->supply.vmmc)) { ret = mmc_regulator_set_ocr(mmc, mmc->supply.vmmc,