MLK-13358 mmc: sdhci-esdhc-imx: make sure usdhc clock enabled while doing suspend
authorHaibo Chen <haibo.chen@nxp.com>
Tue, 18 Oct 2016 06:34:12 +0000 (14:34 +0800)
committerNitin Garg <nitin.garg@nxp.com>
Mon, 19 Mar 2018 19:52:30 +0000 (14:52 -0500)
When suspend usdhc, it will access usdhc register. So usdhc clock
should be enabled, otherwise the access usdhc register will return
error or cause system.

Take this into consideration, if system enable a usdhc and do not
connect any SD/SDIO/MMC card, after system boot up, this usdhc
will do runtime suspend, and close all usdhc clock. At this time,
if suspend the system, due to no card persent, usdhc runtime resume
will not be called. So usdhc clock still closed, then in suspend,
once access usdhc register, system hung or bus error return.

This patch make sure usdhc clock always enabled while doing usdhc
suspend.

Signed-off-by: Haibo Chen <haibo.chen@nxp.com>
drivers/mmc/host/sdhci-esdhc-imx.c

index 966de7b..6df3bf1 100644 (file)
@@ -1418,6 +1418,10 @@ static int sdhci_esdhc_suspend(struct device *dev)
        struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
        struct pltfm_imx_data *imx_data = sdhci_pltfm_priv(pltfm_host);
 
+#ifdef CONFIG_PM
+       pm_runtime_get_sync(host->mmc->parent);
+#endif
+
        if ((imx_data->socdata->flags & ESDHC_FLAG_STATE_LOST_IN_LPMODE) &&
            (host->tuning_mode != SDHCI_TUNING_MODE_1)) {
                mmc_retune_timer_stop(host->mmc);
@@ -1430,11 +1434,19 @@ static int sdhci_esdhc_suspend(struct device *dev)
 static int sdhci_esdhc_resume(struct device *dev)
 {
        struct sdhci_host *host = dev_get_drvdata(dev);
+       int ret;
 
        /* re-initialize hw state in case it's lost in low power mode */
        sdhci_esdhc_imx_hwinit(host);
 
-       return sdhci_resume_host(host);
+       ret = sdhci_resume_host(host);
+
+#ifdef CONFIG_PM
+       pm_runtime_mark_last_busy(host->mmc->parent);
+       pm_runtime_put_autosuspend(host->mmc->parent);
+#endif
+
+       return ret;
 }
 #endif