All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/1] mmc: sdhci-esdhc-imx: Use pinctrl PM helpers
@ 2015-06-12  9:31 Mirza Krak
  2015-06-15  9:55 ` Ulf Hansson
  0 siblings, 1 reply; 6+ messages in thread
From: Mirza Krak @ 2015-06-12  9:31 UTC (permalink / raw)
  To: chris, ulf.hansson
  Cc: shawn.guo, dirk.behme, peter.griffin, stefan, linux-mmc, Mirza Krak

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(+)

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


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/1] mmc: sdhci-esdhc-imx: Use pinctrl PM helpers
  2015-06-12  9:31 [PATCH 1/1] mmc: sdhci-esdhc-imx: Use pinctrl PM helpers Mirza Krak
@ 2015-06-15  9:55 ` Ulf Hansson
  2015-06-15 10:03   ` Mirza Krak
  2015-06-16  6:52   ` Mirza Krak
  0 siblings, 2 replies; 6+ messages in thread
From: Ulf Hansson @ 2015-06-15  9:55 UTC (permalink / raw)
  To: Mirza Krak
  Cc: Chris Ball, Shawn Guo, Dirk Behme, Peter Griffin, Stefan Agner,
	linux-mmc

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
>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/1] mmc: sdhci-esdhc-imx: Use pinctrl PM helpers
  2015-06-15  9:55 ` Ulf Hansson
@ 2015-06-15 10:03   ` Mirza Krak
  2015-06-16  6:52   ` Mirza Krak
  1 sibling, 0 replies; 6+ messages in thread
From: Mirza Krak @ 2015-06-15 10:03 UTC (permalink / raw)
  To: Ulf Hansson
  Cc: Chris Ball, Shawn Guo, Dirk Behme, Peter Griffin, Stefan Agner,
	linux-mmc

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.
-- 
Med Vänliga Hälsningar / Best Regards

*******************************************************************
Mirza Krak
Host Mobility AB
mirza.krak@hostmobility.com
Anders Personsgatan 12, 416 64 Göteborg
Sweden
http://www.hostmobility.com
Direct: +46 31 31 32 704
Phone: +46 31 31 32 700
Fax: +46 31 80 67 51
Mobile: +46 730 28 06 22
*******************************************************************

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/1] mmc: sdhci-esdhc-imx: Use pinctrl PM helpers
  2015-06-15  9:55 ` Ulf Hansson
  2015-06-15 10:03   ` Mirza Krak
@ 2015-06-16  6:52   ` Mirza Krak
  2015-06-16  9:05     ` Stefan Agner
  1 sibling, 1 reply; 6+ messages in thread
From: Mirza Krak @ 2015-06-16  6:52 UTC (permalink / raw)
  To: Ulf Hansson
  Cc: Chris Ball, Shawn Guo, Dirk Behme, Peter Griffin, Stefan Agner,
	linux-mmc

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?

-- 
Med Vänliga Hälsningar / Best Regards

*******************************************************************
Mirza Krak
Host Mobility AB
mirza.krak@hostmobility.com
Anders Personsgatan 12, 416 64 Göteborg
Sweden
http://www.hostmobility.com
Direct: +46 31 31 32 704
Phone: +46 31 31 32 700
Fax: +46 31 80 67 51
Mobile: +46 730 28 06 22
*******************************************************************

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/1] mmc: sdhci-esdhc-imx: Use pinctrl PM helpers
  2015-06-16  6:52   ` Mirza Krak
@ 2015-06-16  9:05     ` Stefan Agner
  2015-06-16  9:49       ` Mirza Krak
  0 siblings, 1 reply; 6+ messages in thread
From: Stefan Agner @ 2015-06-16  9:05 UTC (permalink / raw)
  To: Mirza Krak, Ulf Hansson
  Cc: Chris Ball, Shawn Guo, Dirk Behme, Peter Griffin, linux-mmc

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/1] mmc: sdhci-esdhc-imx: Use pinctrl PM helpers
  2015-06-16  9:05     ` Stefan Agner
@ 2015-06-16  9:49       ` Mirza Krak
  0 siblings, 0 replies; 6+ messages in thread
From: Mirza Krak @ 2015-06-16  9:49 UTC (permalink / raw)
  To: Stefan Agner
  Cc: Ulf Hansson, Chris Ball, Shawn Guo, Dirk Behme, Peter Griffin, linux-mmc

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.

-- 
Med Vänliga Hälsningar / Best Regards

*******************************************************************
Mirza Krak
Host Mobility AB
mirza.krak@hostmobility.com
Anders Personsgatan 12, 416 64 Göteborg
Sweden
http://www.hostmobility.com
Direct: +46 31 31 32 704
Phone: +46 31 31 32 700
Fax: +46 31 80 67 51
Mobile: +46 730 28 06 22
*******************************************************************

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2015-06-16  9:49 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-12  9:31 [PATCH 1/1] mmc: sdhci-esdhc-imx: Use pinctrl PM helpers Mirza Krak
2015-06-15  9:55 ` Ulf Hansson
2015-06-15 10:03   ` Mirza Krak
2015-06-16  6:52   ` Mirza Krak
2015-06-16  9:05     ` Stefan Agner
2015-06-16  9:49       ` Mirza Krak

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.