diff mbox series

[v2,12/14] mmc: sdhci-esdhc-imx: restore pin state when resume back

Message ID 20191203130120.11511-13-haibo.chen@nxp.com (mailing list archive)
State New, archived
Headers show
Series [v2,01/14] mmc: sdhci: do not enable card detect interrupt for gpio cd type | expand

Commit Message

Bough Chen Dec. 3, 2019, 12:54 p.m. UTC
In some low power mode, SoC will lose the pin state, so need to restore
the pin state when resume back.

Signed-off-by: Haibo Chen <haibo.chen@nxp.com>
---
 drivers/mmc/host/sdhci-esdhc-imx.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c b/drivers/mmc/host/sdhci-esdhc-imx.c
index ae1538e30b23..246b4eb52378 100644
--- a/drivers/mmc/host/sdhci-esdhc-imx.c
+++ b/drivers/mmc/host/sdhci-esdhc-imx.c
@@ -1690,7 +1690,13 @@  static int sdhci_esdhc_suspend(struct device *dev)
 	if (host->tuning_mode != SDHCI_TUNING_MODE_3)
 		mmc_retune_needed(host->mmc);
 
-	return sdhci_suspend_host(host);
+	ret = sdhci_suspend_host(host);
+	if (!ret)
+		if (pinctrl_pm_select_sleep_state(dev))
+			dev_warn(mmc_dev(host->mmc),
+			 "%s, failed to select sleep pin state!\n", __func__);
+
+	return ret;
 }
 
 static int sdhci_esdhc_resume(struct device *dev)
@@ -1698,6 +1704,10 @@  static int sdhci_esdhc_resume(struct device *dev)
 	struct sdhci_host *host = dev_get_drvdata(dev);
 	int ret;
 
+	if (pinctrl_pm_select_default_state(dev))
+		dev_warn(mmc_dev(host->mmc),
+		 "%s, failed to select default pin state!\n", __func__);
+
 	/* re-initialize hw state in case it's lost in low power mode */
 	sdhci_esdhc_imx_hwinit(host);