linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] pinctrl: msm: Add sleep pinctrl state transitions
@ 2018-11-09 22:28 Evan Green
  2018-11-10  0:02 ` Stephen Boyd
  2018-11-10  7:20 ` Bjorn Andersson
  0 siblings, 2 replies; 4+ messages in thread
From: Evan Green @ 2018-11-09 22:28 UTC (permalink / raw)
  To: Linus Walleij, Bjorn Andersson
  Cc: Stephen Boyd, Evan Green, linux-gpio, linux-kernel, linux-arm-msm

Add PM suspend callbacks to the msm core driver that select the
sleep and default pinctrl states. Then wire those callbacks up
in the sdm845 driver, for those boards that may have GPIO hogs
that need to change state during suspend.

Signed-off-by: Evan Green <evgreen@chromium.org>
---

 drivers/pinctrl/qcom/pinctrl-msm.c    | 16 ++++++++++++++++
 drivers/pinctrl/qcom/pinctrl-msm.h    |  2 ++
 drivers/pinctrl/qcom/pinctrl-sdm845.c |  4 ++++
 3 files changed, 22 insertions(+)

diff --git a/drivers/pinctrl/qcom/pinctrl-msm.c b/drivers/pinctrl/qcom/pinctrl-msm.c
index 7c7d083e2c0dc..d505d0a50f0a5 100644
--- a/drivers/pinctrl/qcom/pinctrl-msm.c
+++ b/drivers/pinctrl/qcom/pinctrl-msm.c
@@ -1072,6 +1072,22 @@ static void msm_pinctrl_setup_pm_reset(struct msm_pinctrl *pctrl)
 		}
 }
 
+int msm_pinctrl_suspend(struct device *dev)
+{
+	struct msm_pinctrl *pctrl = dev_get_drvdata(dev);
+
+	return pinctrl_force_sleep(pctrl->pctrl);
+}
+EXPORT_SYMBOL(msm_pinctrl_suspend);
+
+int msm_pinctrl_resume(struct device *dev)
+{
+	struct msm_pinctrl *pctrl = dev_get_drvdata(dev);
+
+	return pinctrl_force_default(pctrl->pctrl);
+}
+EXPORT_SYMBOL(msm_pinctrl_resume);
+
 int msm_pinctrl_probe(struct platform_device *pdev,
 		      const struct msm_pinctrl_soc_data *soc_data)
 {
diff --git a/drivers/pinctrl/qcom/pinctrl-msm.h b/drivers/pinctrl/qcom/pinctrl-msm.h
index 29172fdf5882c..e163ca600ecd3 100644
--- a/drivers/pinctrl/qcom/pinctrl-msm.h
+++ b/drivers/pinctrl/qcom/pinctrl-msm.h
@@ -123,6 +123,8 @@ struct msm_pinctrl_soc_data {
 	unsigned int ntiles;
 };
 
+int msm_pinctrl_suspend(struct device *dev);
+int msm_pinctrl_resume(struct device *dev);
 int msm_pinctrl_probe(struct platform_device *pdev,
 		      const struct msm_pinctrl_soc_data *soc_data);
 int msm_pinctrl_remove(struct platform_device *pdev);
diff --git a/drivers/pinctrl/qcom/pinctrl-sdm845.c b/drivers/pinctrl/qcom/pinctrl-sdm845.c
index 2ab7a88857579..a3ac9cbeabad1 100644
--- a/drivers/pinctrl/qcom/pinctrl-sdm845.c
+++ b/drivers/pinctrl/qcom/pinctrl-sdm845.c
@@ -1287,6 +1287,9 @@ static const struct msm_pinctrl_soc_data sdm845_pinctrl = {
 	.ngpios = 150,
 };
 
+static SIMPLE_DEV_PM_OPS(sdm845_pinctrl_dev_pm_ops, msm_pinctrl_suspend,
+			 msm_pinctrl_resume);
+
 static int sdm845_pinctrl_probe(struct platform_device *pdev)
 {
 	return msm_pinctrl_probe(pdev, &sdm845_pinctrl);
@@ -1300,6 +1303,7 @@ static const struct of_device_id sdm845_pinctrl_of_match[] = {
 static struct platform_driver sdm845_pinctrl_driver = {
 	.driver = {
 		.name = "sdm845-pinctrl",
+		.pm = &sdm845_pinctrl_dev_pm_ops,
 		.of_match_table = sdm845_pinctrl_of_match,
 	},
 	.probe = sdm845_pinctrl_probe,
-- 
2.16.4


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

* Re: [PATCH] pinctrl: msm: Add sleep pinctrl state transitions
  2018-11-09 22:28 [PATCH] pinctrl: msm: Add sleep pinctrl state transitions Evan Green
@ 2018-11-10  0:02 ` Stephen Boyd
  2018-11-10  7:20 ` Bjorn Andersson
  1 sibling, 0 replies; 4+ messages in thread
From: Stephen Boyd @ 2018-11-10  0:02 UTC (permalink / raw)
  To: Bjorn Andersson, Evan Green, Linus Walleij
  Cc: Evan Green, linux-gpio, linux-kernel, linux-arm-msm

Quoting Evan Green (2018-11-09 14:28:35)
> Add PM suspend callbacks to the msm core driver that select the
> sleep and default pinctrl states. Then wire those callbacks up
> in the sdm845 driver, for those boards that may have GPIO hogs
> that need to change state during suspend.
> 
> Signed-off-by: Evan Green <evgreen@chromium.org>
> ---

Reviewed-by: Stephen Boyd <swboyd@chromium.org>

> 
>  drivers/pinctrl/qcom/pinctrl-msm.c    | 16 ++++++++++++++++
>  drivers/pinctrl/qcom/pinctrl-msm.h    |  2 ++
>  drivers/pinctrl/qcom/pinctrl-sdm845.c |  4 ++++
>  3 files changed, 22 insertions(+)
> 
> diff --git a/drivers/pinctrl/qcom/pinctrl-msm.c b/drivers/pinctrl/qcom/pinctrl-msm.c
> index 7c7d083e2c0dc..d505d0a50f0a5 100644
> --- a/drivers/pinctrl/qcom/pinctrl-msm.c
> +++ b/drivers/pinctrl/qcom/pinctrl-msm.c
> @@ -1072,6 +1072,22 @@ static void msm_pinctrl_setup_pm_reset(struct msm_pinctrl *pctrl)
>                 }
>  }
>  
> +int msm_pinctrl_suspend(struct device *dev)
> +{
> +       struct msm_pinctrl *pctrl = dev_get_drvdata(dev);
> +
> +       return pinctrl_force_sleep(pctrl->pctrl);
> +}
> +EXPORT_SYMBOL(msm_pinctrl_suspend);
> +
> +int msm_pinctrl_resume(struct device *dev)
> +{
> +       struct msm_pinctrl *pctrl = dev_get_drvdata(dev);
> +
> +       return pinctrl_force_default(pctrl->pctrl);
> +}
> +EXPORT_SYMBOL(msm_pinctrl_resume);

It's too bad this can't be installed by default into the driver somehow
so we don't have to repeat this for each device driver. O well!


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

* Re: [PATCH] pinctrl: msm: Add sleep pinctrl state transitions
  2018-11-09 22:28 [PATCH] pinctrl: msm: Add sleep pinctrl state transitions Evan Green
  2018-11-10  0:02 ` Stephen Boyd
@ 2018-11-10  7:20 ` Bjorn Andersson
  2018-11-12 18:26   ` Evan Green
  1 sibling, 1 reply; 4+ messages in thread
From: Bjorn Andersson @ 2018-11-10  7:20 UTC (permalink / raw)
  To: Evan Green
  Cc: Linus Walleij, Stephen Boyd, linux-gpio, linux-kernel, linux-arm-msm

On Fri 09 Nov 14:28 PST 2018, Evan Green wrote:

> Add PM suspend callbacks to the msm core driver that select the
> sleep and default pinctrl states. Then wire those callbacks up
> in the sdm845 driver, for those boards that may have GPIO hogs
> that need to change state during suspend.
> 
> Signed-off-by: Evan Green <evgreen@chromium.org>
> ---
> 
>  drivers/pinctrl/qcom/pinctrl-msm.c    | 16 ++++++++++++++++
>  drivers/pinctrl/qcom/pinctrl-msm.h    |  2 ++
>  drivers/pinctrl/qcom/pinctrl-sdm845.c |  4 ++++
>  3 files changed, 22 insertions(+)
> 
> diff --git a/drivers/pinctrl/qcom/pinctrl-msm.c b/drivers/pinctrl/qcom/pinctrl-msm.c
> index 7c7d083e2c0dc..d505d0a50f0a5 100644
> --- a/drivers/pinctrl/qcom/pinctrl-msm.c
> +++ b/drivers/pinctrl/qcom/pinctrl-msm.c
> @@ -1072,6 +1072,22 @@ static void msm_pinctrl_setup_pm_reset(struct msm_pinctrl *pctrl)
>  		}
>  }
>  
> +int msm_pinctrl_suspend(struct device *dev)
> +{
> +	struct msm_pinctrl *pctrl = dev_get_drvdata(dev);
> +
> +	return pinctrl_force_sleep(pctrl->pctrl);
> +}
> +EXPORT_SYMBOL(msm_pinctrl_suspend);
> +
> +int msm_pinctrl_resume(struct device *dev)
> +{
> +	struct msm_pinctrl *pctrl = dev_get_drvdata(dev);
> +
> +	return pinctrl_force_default(pctrl->pctrl);
> +}
> +EXPORT_SYMBOL(msm_pinctrl_resume);
> +
>  int msm_pinctrl_probe(struct platform_device *pdev,
>  		      const struct msm_pinctrl_soc_data *soc_data)
>  {
> diff --git a/drivers/pinctrl/qcom/pinctrl-msm.h b/drivers/pinctrl/qcom/pinctrl-msm.h
> index 29172fdf5882c..e163ca600ecd3 100644
> --- a/drivers/pinctrl/qcom/pinctrl-msm.h
> +++ b/drivers/pinctrl/qcom/pinctrl-msm.h
> @@ -123,6 +123,8 @@ struct msm_pinctrl_soc_data {
>  	unsigned int ntiles;
>  };
>  
> +int msm_pinctrl_suspend(struct device *dev);
> +int msm_pinctrl_resume(struct device *dev);
>  int msm_pinctrl_probe(struct platform_device *pdev,
>  		      const struct msm_pinctrl_soc_data *soc_data);
>  int msm_pinctrl_remove(struct platform_device *pdev);
> diff --git a/drivers/pinctrl/qcom/pinctrl-sdm845.c b/drivers/pinctrl/qcom/pinctrl-sdm845.c
> index 2ab7a88857579..a3ac9cbeabad1 100644
> --- a/drivers/pinctrl/qcom/pinctrl-sdm845.c
> +++ b/drivers/pinctrl/qcom/pinctrl-sdm845.c
> @@ -1287,6 +1287,9 @@ static const struct msm_pinctrl_soc_data sdm845_pinctrl = {
>  	.ngpios = 150,
>  };
>  
> +static SIMPLE_DEV_PM_OPS(sdm845_pinctrl_dev_pm_ops, msm_pinctrl_suspend,
> +			 msm_pinctrl_resume);

I don't expect this to differ between the various platforms, so how
about moving it to pinctrl-msm?

Regards,
Bjorn

> +
>  static int sdm845_pinctrl_probe(struct platform_device *pdev)
>  {
>  	return msm_pinctrl_probe(pdev, &sdm845_pinctrl);
> @@ -1300,6 +1303,7 @@ static const struct of_device_id sdm845_pinctrl_of_match[] = {
>  static struct platform_driver sdm845_pinctrl_driver = {
>  	.driver = {
>  		.name = "sdm845-pinctrl",
> +		.pm = &sdm845_pinctrl_dev_pm_ops,
>  		.of_match_table = sdm845_pinctrl_of_match,
>  	},
>  	.probe = sdm845_pinctrl_probe,
> -- 
> 2.16.4
> 

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

* Re: [PATCH] pinctrl: msm: Add sleep pinctrl state transitions
  2018-11-10  7:20 ` Bjorn Andersson
@ 2018-11-12 18:26   ` Evan Green
  0 siblings, 0 replies; 4+ messages in thread
From: Evan Green @ 2018-11-12 18:26 UTC (permalink / raw)
  To: Bjorn Andersson
  Cc: Linus Walleij, swboyd, linux-gpio, linux-kernel, linux-arm-msm

On Fri, Nov 9, 2018 at 11:20 PM Bjorn Andersson
<bjorn.andersson@linaro.org> wrote:
>
> On Fri 09 Nov 14:28 PST 2018, Evan Green wrote:
>
> > Add PM suspend callbacks to the msm core driver that select the
> > sleep and default pinctrl states. Then wire those callbacks up
> > in the sdm845 driver, for those boards that may have GPIO hogs
> > that need to change state during suspend.
> >
> > Signed-off-by: Evan Green <evgreen@chromium.org>
> > ---
> >
> >  drivers/pinctrl/qcom/pinctrl-msm.c    | 16 ++++++++++++++++
> >  drivers/pinctrl/qcom/pinctrl-msm.h    |  2 ++
> >  drivers/pinctrl/qcom/pinctrl-sdm845.c |  4 ++++
> >  3 files changed, 22 insertions(+)
> >
> > diff --git a/drivers/pinctrl/qcom/pinctrl-msm.c b/drivers/pinctrl/qcom/pinctrl-msm.c
> > index 7c7d083e2c0dc..d505d0a50f0a5 100644
> > --- a/drivers/pinctrl/qcom/pinctrl-msm.c
> > +++ b/drivers/pinctrl/qcom/pinctrl-msm.c
> > @@ -1072,6 +1072,22 @@ static void msm_pinctrl_setup_pm_reset(struct msm_pinctrl *pctrl)
> >               }
> >  }
> >
> > +int msm_pinctrl_suspend(struct device *dev)
> > +{
> > +     struct msm_pinctrl *pctrl = dev_get_drvdata(dev);
> > +
> > +     return pinctrl_force_sleep(pctrl->pctrl);
> > +}
> > +EXPORT_SYMBOL(msm_pinctrl_suspend);
> > +
> > +int msm_pinctrl_resume(struct device *dev)
> > +{
> > +     struct msm_pinctrl *pctrl = dev_get_drvdata(dev);
> > +
> > +     return pinctrl_force_default(pctrl->pctrl);
> > +}
> > +EXPORT_SYMBOL(msm_pinctrl_resume);
> > +
> >  int msm_pinctrl_probe(struct platform_device *pdev,
> >                     const struct msm_pinctrl_soc_data *soc_data)
> >  {
> > diff --git a/drivers/pinctrl/qcom/pinctrl-msm.h b/drivers/pinctrl/qcom/pinctrl-msm.h
> > index 29172fdf5882c..e163ca600ecd3 100644
> > --- a/drivers/pinctrl/qcom/pinctrl-msm.h
> > +++ b/drivers/pinctrl/qcom/pinctrl-msm.h
> > @@ -123,6 +123,8 @@ struct msm_pinctrl_soc_data {
> >       unsigned int ntiles;
> >  };
> >
> > +int msm_pinctrl_suspend(struct device *dev);
> > +int msm_pinctrl_resume(struct device *dev);
> >  int msm_pinctrl_probe(struct platform_device *pdev,
> >                     const struct msm_pinctrl_soc_data *soc_data);
> >  int msm_pinctrl_remove(struct platform_device *pdev);
> > diff --git a/drivers/pinctrl/qcom/pinctrl-sdm845.c b/drivers/pinctrl/qcom/pinctrl-sdm845.c
> > index 2ab7a88857579..a3ac9cbeabad1 100644
> > --- a/drivers/pinctrl/qcom/pinctrl-sdm845.c
> > +++ b/drivers/pinctrl/qcom/pinctrl-sdm845.c
> > @@ -1287,6 +1287,9 @@ static const struct msm_pinctrl_soc_data sdm845_pinctrl = {
> >       .ngpios = 150,
> >  };
> >
> > +static SIMPLE_DEV_PM_OPS(sdm845_pinctrl_dev_pm_ops, msm_pinctrl_suspend,
> > +                      msm_pinctrl_resume);
>
> I don't expect this to differ between the various platforms, so how
> about moving it to pinctrl-msm?

Sounds good! Will spin.

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

end of thread, other threads:[~2018-11-12 18:27 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-09 22:28 [PATCH] pinctrl: msm: Add sleep pinctrl state transitions Evan Green
2018-11-10  0:02 ` Stephen Boyd
2018-11-10  7:20 ` Bjorn Andersson
2018-11-12 18:26   ` Evan Green

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).