diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c index 0e1f0bbd6e4..89e5598078b 100644 --- a/drivers/mmc/core/mmc.c +++ b/drivers/mmc/core/mmc.c @@ -1430,6 +1430,31 @@ static void mmc_detect(struct mmc_host *host) } } +/* + * Save ios settings + */ +static void mmc_save_ios(struct mmc_host *host) +{ + BUG_ON(!host); + + mmc_host_clk_hold(host); + + memcpy(&host->saved_ios, &host->ios, sizeof(struct mmc_ios)); + + mmc_host_clk_release(host); +} + +/* + * Restore ios setting + */ +static void mmc_restore_ios(struct mmc_host *host) +{ + BUG_ON(!host); + + memcpy(&host->ios, &host->saved_ios, sizeof(struct mmc_ios)); + mmc_set_ios(host); +} + /* * Suspend callback from host. */ @@ -1441,6 +1466,7 @@ static int mmc_suspend(struct mmc_host *host) BUG_ON(!host->card); mmc_claim_host(host); + mmc_save_ios(host); if (mmc_can_poweroff_notify(host->card) && (host->caps2 & MMC_CAP2_POWER_OFF_VCCQ_DURING_SUSPEND)) { err = mmc_poweroff_notify(host, MMC_PW_OFF_NOTIFY_SHORT); @@ -1473,6 +1499,7 @@ static int mmc_resume(struct mmc_host *host) mmc_claim_host(host); if (mmc_card_is_sleep(host->card)) { + mmc_restore_ios(host); err = mmc_card_awake(host); } else err = mmc_init_card(host, host->ocr, host->card); diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h index fafe5b98039..ef9e1790520 100644 --- a/include/linux/mmc/host.h +++ b/include/linux/mmc/host.h @@ -352,6 +352,7 @@ struct mmc_host { } perf; bool perf_enable; #endif + struct mmc_ios saved_ios; unsigned long private[0] ____cacheline_aligned; };