diff mbox series

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

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

Commit Message

Bough Chen Nov. 15, 2019, 11:12 a.m. UTC
From: Haibo Chen <haibo.chen@nxp.com>

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 | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

Comments

Adrian Hunter Nov. 26, 2019, 12:50 p.m. UTC | #1
On 15/11/19 1:12 PM, haibo.chen@nxp.com wrote:
> From: Haibo Chen <haibo.chen@nxp.com>
> 
> 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 | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c b/drivers/mmc/host/sdhci-esdhc-imx.c
> index 1c988d6a2433..25b01f059aca 100644
> --- a/drivers/mmc/host/sdhci-esdhc-imx.c
> +++ b/drivers/mmc/host/sdhci-esdhc-imx.c
> @@ -1623,7 +1623,11 @@ 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)
> +		pinctrl_pm_select_sleep_state(dev);

Error return?

> +
> +	return ret;
>  }
>  
>  static int sdhci_esdhc_resume(struct device *dev)
> @@ -1631,6 +1635,8 @@ static int sdhci_esdhc_resume(struct device *dev)
>  	struct sdhci_host *host = dev_get_drvdata(dev);
>  	int ret;
>  
> +	pinctrl_pm_select_default_state(dev);

Error return?

> +
>  	/* re-initialize hw state in case it's lost in low power mode */
>  	sdhci_esdhc_imx_hwinit(host);
>  
>
Bough Chen Nov. 27, 2019, 10:49 a.m. UTC | #2
> -----Original Message-----
> From: Adrian Hunter <adrian.hunter@intel.com>
> Sent: 2019年11月26日 20:51
> To: BOUGH CHEN <haibo.chen@nxp.com>; ulf.hansson@linaro.org;
> shawnguo@kernel.org; s.hauer@pengutronix.de; kernel@pengutronix.de
> Cc: festevam@gmail.com; linux-mmc@vger.kernel.org; dl-linux-imx
> <linux-imx@nxp.com>
> Subject: Re: [PATCH 04/14] mmc: sdhci-esdhc-imx: restore pin state when
> resume back
> 
> On 15/11/19 1:12 PM, haibo.chen@nxp.com wrote:
> > From: Haibo Chen <haibo.chen@nxp.com>
> >
> > 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 | 8 +++++++-
> >  1 file changed, 7 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c
> > b/drivers/mmc/host/sdhci-esdhc-imx.c
> > index 1c988d6a2433..25b01f059aca 100644
> > --- a/drivers/mmc/host/sdhci-esdhc-imx.c
> > +++ b/drivers/mmc/host/sdhci-esdhc-imx.c
> > @@ -1623,7 +1623,11 @@ 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)
> > +		pinctrl_pm_select_sleep_state(dev);
> 
> Error return?

Thanks for point out that, I will check the return of pinctrl_pm_select_sleep_state(dev).

> 
> > +
> > +	return ret;
> >  }
> >
> >  static int sdhci_esdhc_resume(struct device *dev) @@ -1631,6 +1635,8
> > @@ static int sdhci_esdhc_resume(struct device *dev)
> >  	struct sdhci_host *host = dev_get_drvdata(dev);
> >  	int ret;
> >
> > +	pinctrl_pm_select_default_state(dev);
> 
> Error return?
> 
> > +
> >  	/* re-initialize hw state in case it's lost in low power mode */
> >  	sdhci_esdhc_imx_hwinit(host);
> >
> >
diff mbox series

Patch

diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c b/drivers/mmc/host/sdhci-esdhc-imx.c
index 1c988d6a2433..25b01f059aca 100644
--- a/drivers/mmc/host/sdhci-esdhc-imx.c
+++ b/drivers/mmc/host/sdhci-esdhc-imx.c
@@ -1623,7 +1623,11 @@  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)
+		pinctrl_pm_select_sleep_state(dev);
+
+	return ret;
 }
 
 static int sdhci_esdhc_resume(struct device *dev)
@@ -1631,6 +1635,8 @@  static int sdhci_esdhc_resume(struct device *dev)
 	struct sdhci_host *host = dev_get_drvdata(dev);
 	int ret;
 
+	pinctrl_pm_select_default_state(dev);
+
 	/* re-initialize hw state in case it's lost in low power mode */
 	sdhci_esdhc_imx_hwinit(host);