linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 1/2] pinctrl: pinctrl-imx: Add suspend/resume for LPSR
@ 2019-03-25 13:59 Abel Vesa
  2019-03-25 13:59 ` [PATCH v2 2/2] pinctrl: pinctrl-imx8mq: Add support PM operations Abel Vesa
  0 siblings, 1 reply; 3+ messages in thread
From: Abel Vesa @ 2019-03-25 13:59 UTC (permalink / raw)
  To: Robin Gong, Aisheng Dong, Fabio Estevam, Shawn Guo, Stefan Agner,
	Linus Walleij, Sascha Hauer
  Cc: dl-linux-imx, linux-gpio, linux-arm-kernel,
	Linux Kernel Mailing List, Abel Vesa

From: Robin Gong <yibin.gong@nxp.com>

To support pinctl hog restore after LPSR resume back,
add suspend/resume in pinctrl driver.

Signed-off-by: Robin Gong <yibin.gong@nxp.com>
Signed-off-by: Abel Vesa <abel.vesa@nxp.com>
---

Changes since v1:
 * fixed Robin's email

 drivers/pinctrl/freescale/pinctrl-imx.c | 20 ++++++++++++++++++++
 drivers/pinctrl/freescale/pinctrl-imx.h |  3 +++
 2 files changed, 23 insertions(+)

diff --git a/drivers/pinctrl/freescale/pinctrl-imx.c b/drivers/pinctrl/freescale/pinctrl-imx.c
index 188001b..93c0253 100644
--- a/drivers/pinctrl/freescale/pinctrl-imx.c
+++ b/drivers/pinctrl/freescale/pinctrl-imx.c
@@ -887,3 +887,23 @@ int imx_pinctrl_probe(struct platform_device *pdev,
 
 	return ret;
 }
+
+int imx_pinctrl_suspend(struct device *dev)
+{
+	struct imx_pinctrl *ipctl = dev_get_drvdata(dev);
+
+	if (!ipctl)
+		return -EINVAL;
+
+	return pinctrl_force_sleep(ipctl->pctl);
+}
+
+int imx_pinctrl_resume(struct device *dev)
+{
+	struct imx_pinctrl *ipctl = dev_get_drvdata(dev);
+
+	if (!ipctl)
+		return -EINVAL;
+
+	return pinctrl_force_default(ipctl->pctl);
+}
diff --git a/drivers/pinctrl/freescale/pinctrl-imx.h b/drivers/pinctrl/freescale/pinctrl-imx.h
index 98a4889..795669c 100644
--- a/drivers/pinctrl/freescale/pinctrl-imx.h
+++ b/drivers/pinctrl/freescale/pinctrl-imx.h
@@ -136,6 +136,9 @@ struct imx_pinctrl {
 int imx_pinctrl_probe(struct platform_device *pdev,
 			const struct imx_pinctrl_soc_info *info);
 
+int imx_pinctrl_suspend(struct device *dev);
+int imx_pinctrl_resume(struct device *dev);
+
 #ifdef CONFIG_PINCTRL_IMX_SCU
 #define BM_PAD_CTL_GP_ENABLE		BIT(30)
 #define BM_PAD_CTL_IFMUX_ENABLE		BIT(31)
-- 
2.7.4


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

* [PATCH v2 2/2] pinctrl: pinctrl-imx8mq: Add support PM operations
  2019-03-25 13:59 [PATCH v2 1/2] pinctrl: pinctrl-imx: Add suspend/resume for LPSR Abel Vesa
@ 2019-03-25 13:59 ` Abel Vesa
  2019-04-04  6:51   ` Aisheng Dong
  0 siblings, 1 reply; 3+ messages in thread
From: Abel Vesa @ 2019-03-25 13:59 UTC (permalink / raw)
  To: Robin Gong, Aisheng Dong, Fabio Estevam, Shawn Guo, Stefan Agner,
	Linus Walleij, Sascha Hauer
  Cc: dl-linux-imx, linux-gpio, linux-arm-kernel,
	Linux Kernel Mailing List, Abel Vesa

Add suspend/resume pm ops to the pinctrl i.MX8MQ driver.
Make the suspend late and the resume early since some of the
pins might be needed active very late.
These call the pinctrl-imx generic handlers.

Signed-off-by: Abel Vesa <abel.vesa@nxp.com>
---
 drivers/pinctrl/freescale/pinctrl-imx8mq.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/drivers/pinctrl/freescale/pinctrl-imx8mq.c b/drivers/pinctrl/freescale/pinctrl-imx8mq.c
index 8d39af5..2a212bc 100644
--- a/drivers/pinctrl/freescale/pinctrl-imx8mq.c
+++ b/drivers/pinctrl/freescale/pinctrl-imx8mq.c
@@ -335,10 +335,26 @@ static int imx8mq_pinctrl_probe(struct platform_device *pdev)
 	return imx_pinctrl_probe(pdev, &imx8mq_pinctrl_info);
 }
 
+static int imx8mq_pinctrl_suspend(struct device *dev)
+{
+	return imx_pinctrl_suspend(dev);
+}
+
+static int imx8mq_pinctrl_resume(struct device *dev)
+{
+	return imx_pinctrl_resume(dev);
+}
+
+static const struct dev_pm_ops imx8mq_pinctrl_pm_ops = {
+	SET_LATE_SYSTEM_SLEEP_PM_OPS(imx8mq_pinctrl_suspend,
+					imx8mq_pinctrl_resume)
+};
+
 static struct platform_driver imx8mq_pinctrl_driver = {
 	.driver = {
 		.name = "imx8mq-pinctrl",
 		.of_match_table = of_match_ptr(imx8mq_pinctrl_of_match),
+		.pm = &imx8mq_pinctrl_pm_ops,
 		.suppress_bind_attrs = true,
 	},
 	.probe = imx8mq_pinctrl_probe,
-- 
2.7.4


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

* RE: [PATCH v2 2/2] pinctrl: pinctrl-imx8mq: Add support PM operations
  2019-03-25 13:59 ` [PATCH v2 2/2] pinctrl: pinctrl-imx8mq: Add support PM operations Abel Vesa
@ 2019-04-04  6:51   ` Aisheng Dong
  0 siblings, 0 replies; 3+ messages in thread
From: Aisheng Dong @ 2019-04-04  6:51 UTC (permalink / raw)
  To: Abel Vesa, Robin Gong, Fabio Estevam, Shawn Guo, Stefan Agner,
	Linus Walleij, Sascha Hauer
  Cc: dl-linux-imx, linux-gpio, linux-arm-kernel, Linux Kernel Mailing List

> From: Abel Vesa
> Sent: Monday, March 25, 2019 10:00 PM
> 
> Add suspend/resume pm ops to the pinctrl i.MX8MQ driver.
> Make the suspend late and the resume early since some of the pins might be
> needed active very late.
> These call the pinctrl-imx generic handlers.
> 
> Signed-off-by: Abel Vesa <abel.vesa@nxp.com>
> ---
>  drivers/pinctrl/freescale/pinctrl-imx8mq.c | 16 ++++++++++++++++
>  1 file changed, 16 insertions(+)
> 
> diff --git a/drivers/pinctrl/freescale/pinctrl-imx8mq.c
> b/drivers/pinctrl/freescale/pinctrl-imx8mq.c
> index 8d39af5..2a212bc 100644
> --- a/drivers/pinctrl/freescale/pinctrl-imx8mq.c
> +++ b/drivers/pinctrl/freescale/pinctrl-imx8mq.c
> @@ -335,10 +335,26 @@ static int imx8mq_pinctrl_probe(struct
> platform_device *pdev)
>  	return imx_pinctrl_probe(pdev, &imx8mq_pinctrl_info);  }
> 
> +static int imx8mq_pinctrl_suspend(struct device *dev) {
> +	return imx_pinctrl_suspend(dev);
> +}
> +
> +static int imx8mq_pinctrl_resume(struct device *dev) {
> +	return imx_pinctrl_resume(dev);
> +}
> +
> +static const struct dev_pm_ops imx8mq_pinctrl_pm_ops = {

It looks we did not nothing special on the dev_pm_ops for platform drivers.
So do you think if we can move this into common pinctrl-imx.c?
Then platform driver does not need to implement the duplicated things?

Regards
Dong Aisheng

> +	SET_LATE_SYSTEM_SLEEP_PM_OPS(imx8mq_pinctrl_suspend,
> +					imx8mq_pinctrl_resume)
> +};
> +
>  static struct platform_driver imx8mq_pinctrl_driver = {
>  	.driver = {
>  		.name = "imx8mq-pinctrl",
>  		.of_match_table = of_match_ptr(imx8mq_pinctrl_of_match),
> +		.pm = &imx8mq_pinctrl_pm_ops,
>  		.suppress_bind_attrs = true,
>  	},
>  	.probe = imx8mq_pinctrl_probe,
> --
> 2.7.4


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

end of thread, other threads:[~2019-04-04  6:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-25 13:59 [PATCH v2 1/2] pinctrl: pinctrl-imx: Add suspend/resume for LPSR Abel Vesa
2019-03-25 13:59 ` [PATCH v2 2/2] pinctrl: pinctrl-imx8mq: Add support PM operations Abel Vesa
2019-04-04  6:51   ` Aisheng Dong

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).