diff mbox

[1/1] mmc: sdhci-esdhc-imx: Use pinctrl PM helpers

Message ID 1434101473-4109-1-git-send-email-mirza.krak@hostmobility.com (mailing list archive)
State New, archived
Headers show

Commit Message

Mirza Krak June 12, 2015, 9:31 a.m. UTC
From: Mirza Krak <mirza.krak@hostmobility.com>

Add support for current states of pinctrl, which are "default", "idle"
and "sleep".

The "default" pinctrl state is set by Drivers core before
calling the driver's probe, hence we do not need a initial call to
"default" state.

Signed-off-by: Mirza Krak <mirza.krak@hostmobility.com>
---
 drivers/mmc/host/sdhci-esdhc-imx.c | 8 ++++++++
 1 file changed, 8 insertions(+)

Comments

Ulf Hansson June 15, 2015, 9:55 a.m. UTC | #1
On 12 June 2015 at 11:31, Mirza Krak <mirza.krak@hostmobility.com> wrote:
> From: Mirza Krak <mirza.krak@hostmobility.com>
>
> Add support for current states of pinctrl, which are "default", "idle"
> and "sleep".
>
> The "default" pinctrl state is set by Drivers core before
> calling the driver's probe, hence we do not need a initial call to
> "default" state.
>
> Signed-off-by: Mirza Krak <mirza.krak@hostmobility.com>

Hi Mirza,

This looks okay to me, but it seems like it needs a re-base towards my
mmc next branch.

Kind regards
Uffe

> ---
>  drivers/mmc/host/sdhci-esdhc-imx.c | 8 ++++++++
>  1 file changed, 8 insertions(+)
>
> diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c b/drivers/mmc/host/sdhci-esdhc-imx.c
> index 84b3365e4773..6d51a4f48361 100644
> --- a/drivers/mmc/host/sdhci-esdhc-imx.c
> +++ b/drivers/mmc/host/sdhci-esdhc-imx.c
> @@ -1129,6 +1129,8 @@ static int sdhci_esdhc_suspend(struct device *dev)
>         pm_runtime_mark_last_busy(dev);
>         pm_runtime_put_autosuspend(dev);
>
> +       pinctrl_pm_select_sleep_state(dev);
> +
>         return ret;
>  }
>
> @@ -1137,6 +1139,8 @@ static int sdhci_esdhc_resume(struct device *dev)
>         int ret;
>         struct sdhci_host *host = dev_get_drvdata(dev);
>
> +       pinctrl_pm_select_default_state(dev);
> +
>         pm_runtime_get_sync(dev);
>         ret = sdhci_resume_host(host);
>         pm_runtime_mark_last_busy(dev);
> @@ -1160,6 +1164,8 @@ static int sdhci_esdhc_runtime_suspend(struct device *dev)
>         }
>         clk_disable_unprepare(imx_data->clk_ahb);
>
> +       pinctrl_pm_select_idle_state(dev);
> +
>         return ret;
>  }
>
> @@ -1169,6 +1175,8 @@ static int sdhci_esdhc_runtime_resume(struct device *dev)
>         struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
>         struct pltfm_imx_data *imx_data = pltfm_host->priv;
>
> +       pinctrl_pm_select_default_state(dev);
> +
>         if (!sdhci_sdio_irq_enabled(host)) {
>                 clk_prepare_enable(imx_data->clk_per);
>                 clk_prepare_enable(imx_data->clk_ipg);
> --
> 2.1.0
>
--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Mirza Krak June 15, 2015, 10:03 a.m. UTC | #2
2015-06-15 11:55 GMT+02:00 Ulf Hansson <ulf.hansson@linaro.org>:
> On 12 June 2015 at 11:31, Mirza Krak <mirza.krak@hostmobility.com> wrote:
>> From: Mirza Krak <mirza.krak@hostmobility.com>
>>
>> Add support for current states of pinctrl, which are "default", "idle"
>> and "sleep".
>>
>> The "default" pinctrl state is set by Drivers core before
>> calling the driver's probe, hence we do not need a initial call to
>> "default" state.
>>
>> Signed-off-by: Mirza Krak <mirza.krak@hostmobility.com>
>
> Hi Mirza,
>
> This looks okay to me, but it seems like it needs a re-base towards my
> mmc next branch.

Ok, will do that.
Mirza Krak June 16, 2015, 6:52 a.m. UTC | #3
2015-06-15 11:55 GMT+02:00 Ulf Hansson <ulf.hansson@linaro.org>:
> On 12 June 2015 at 11:31, Mirza Krak <mirza.krak@hostmobility.com> wrote:
>> From: Mirza Krak <mirza.krak@hostmobility.com>
>>
>> Add support for current states of pinctrl, which are "default", "idle"
>> and "sleep".
>>
>> The "default" pinctrl state is set by Drivers core before
>> calling the driver's probe, hence we do not need a initial call to
>> "default" state.
>>
>> Signed-off-by: Mirza Krak <mirza.krak@hostmobility.com>
>
> Hi Mirza,
>
> This looks okay to me, but it seems like it needs a re-base towards my
> mmc next branch.
>
> Kind regards
> Uffe

Looked at the mmc next branch.

I see that the suspend/resume methods of sdhci-esdhci-imx have been
removed and the generic sdhci_pltfm_suspend/resume are used. So I am
unsure if it is OK to set the pinctl "sleep" state in
sdhci_pltfm_suspend or is there a better location for this.

I am thinking sdhci_suspend_host would be good location, but then the
change will effect a lot more drivers. Maybe a good thing?

Regarding the "idle" state of pinctrl, this could also be moved to
sdhci_runtime_suspend_host, affecting more drivers. Again a good
thing?
Stefan Agner June 16, 2015, 9:05 a.m. UTC | #4
On 2015-06-16 08:52, Mirza Krak wrote:
> 2015-06-15 11:55 GMT+02:00 Ulf Hansson <ulf.hansson@linaro.org>:
>> On 12 June 2015 at 11:31, Mirza Krak <mirza.krak@hostmobility.com> wrote:
>>> From: Mirza Krak <mirza.krak@hostmobility.com>
>>>
>>> Add support for current states of pinctrl, which are "default", "idle"
>>> and "sleep".
>>>
>>> The "default" pinctrl state is set by Drivers core before
>>> calling the driver's probe, hence we do not need a initial call to
>>> "default" state.
>>>
>>> Signed-off-by: Mirza Krak <mirza.krak@hostmobility.com>
>>
>> Hi Mirza,
>>
>> This looks okay to me, but it seems like it needs a re-base towards my
>> mmc next branch.
>>
>> Kind regards
>> Uffe
> 
> Looked at the mmc next branch.
> 
> I see that the suspend/resume methods of sdhci-esdhci-imx have been
> removed and the generic sdhci_pltfm_suspend/resume are used. So I am
> unsure if it is OK to set the pinctl "sleep" state in
> sdhci_pltfm_suspend or is there a better location for this.

The pltfm_suspend/resume functions have been used since quite some time.
However, the Toradex branch carries a patch which introduces local
suspend/resume functions to work around a system PM vs. runtime PM
suspend issue.

My upstream patch for the same issue is in v3 and solves the issue by
introducing a generic runtime PM enabled pltfm_suspend/resume function:
https://lkml.org/lkml/2015/5/21/104

I'm not sure if that is going to be accepted, maybe Ulf can have a look
at it first?

> 
> I am thinking sdhci_suspend_host would be good location, but then the
> change will effect a lot more drivers. Maybe a good thing?

I guess most device trees don't have a specific idle/sleep state
specification, how does the pinctrl API act in this situation?

FWIW, the Vybrid SoC is not able to control pins during LPSTOP suspend,
hence configuring the sleep mode explicitly for system PM is not very
useful on that platform. However, for runtime PM it coud still be
valuable I guess.

--
Stefan
--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Mirza Krak June 16, 2015, 9:49 a.m. UTC | #5
2015-06-16 11:05 GMT+02:00 Stefan Agner <stefan@agner.ch>:
> The pltfm_suspend/resume functions have been used since quite some time.
> However, the Toradex branch carries a patch which introduces local
> suspend/resume functions to work around a system PM vs. runtime PM
> suspend issue.

Hence my confusion :).

> > I am thinking sdhci_suspend_host would be good location, but then the
> > change will effect a lot more drivers. Maybe a good thing?
>
> I guess most device trees don't have a specific idle/sleep state
> specification, how does the pinctrl API act in this situation?

pinctrl API can handle if states are not defined. Also the API calls
are considered successful when successfully set state or if no state
definition is present.

Undefined states are set to ERR_PTR(-ENODEV)

and in the API calls there is a

if (IS_ERR(state))
    return 0; /* No such state */

>
> FWIW, the Vybrid SoC is not able to control pins during LPSTOP suspend,
> hence configuring the sleep mode explicitly for system PM is not very
> useful on that platform. However, for runtime PM it coud still be
> valuable I guess.

I was testing the "standby" state and noticed unwanted states on some
pins and hence this patch :). Good to know about LPSTOP.
diff mbox

Patch

diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c b/drivers/mmc/host/sdhci-esdhc-imx.c
index 84b3365e4773..6d51a4f48361 100644
--- a/drivers/mmc/host/sdhci-esdhc-imx.c
+++ b/drivers/mmc/host/sdhci-esdhc-imx.c
@@ -1129,6 +1129,8 @@  static int sdhci_esdhc_suspend(struct device *dev)
 	pm_runtime_mark_last_busy(dev);
 	pm_runtime_put_autosuspend(dev);
 
+	pinctrl_pm_select_sleep_state(dev);
+
 	return ret;
 }
 
@@ -1137,6 +1139,8 @@  static int sdhci_esdhc_resume(struct device *dev)
 	int ret;
 	struct sdhci_host *host = dev_get_drvdata(dev);
 
+	pinctrl_pm_select_default_state(dev);
+
 	pm_runtime_get_sync(dev);
 	ret = sdhci_resume_host(host);
 	pm_runtime_mark_last_busy(dev);
@@ -1160,6 +1164,8 @@  static int sdhci_esdhc_runtime_suspend(struct device *dev)
 	}
 	clk_disable_unprepare(imx_data->clk_ahb);
 
+	pinctrl_pm_select_idle_state(dev);
+
 	return ret;
 }
 
@@ -1169,6 +1175,8 @@  static int sdhci_esdhc_runtime_resume(struct device *dev)
 	struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
 	struct pltfm_imx_data *imx_data = pltfm_host->priv;
 
+	pinctrl_pm_select_default_state(dev);
+
 	if (!sdhci_sdio_irq_enabled(host)) {
 		clk_prepare_enable(imx_data->clk_per);
 		clk_prepare_enable(imx_data->clk_ipg);