* [PATCH v2] pwm: imx-tpm: Enable pinctrl setting for sleep state
@ 2024-07-02 16:45 Shenwei Wang
2024-07-05 8:37 ` Uwe Kleine-König
0 siblings, 1 reply; 2+ messages in thread
From: Shenwei Wang @ 2024-07-02 16:45 UTC (permalink / raw)
To: Uwe Kleine-König, Shawn Guo, Sascha Hauer
Cc: Pengutronix Kernel Team, Fabio Estevam, linux-pwm, imx,
linux-arm-kernel, linux-imx, Shenwei Wang
Apply the pinctrl setting of sleep state when system enters
suspend state.
Restore to the default pinctrl setting when system resumes.
Signed-off-by: Shenwei Wang <shenwei.wang@nxp.com>
---
Changes in V2:
- restore the clk states in error path in .suspend function
- restore the pinctrl states in error path in .resume function
drivers/pwm/pwm-imx-tpm.c | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
diff --git a/drivers/pwm/pwm-imx-tpm.c b/drivers/pwm/pwm-imx-tpm.c
index c50ddbac43c8..96ea343856f0 100644
--- a/drivers/pwm/pwm-imx-tpm.c
+++ b/drivers/pwm/pwm-imx-tpm.c
@@ -20,6 +20,7 @@
#include <linux/io.h>
#include <linux/module.h>
#include <linux/of.h>
+#include <linux/pinctrl/consumer.h>
#include <linux/platform_device.h>
#include <linux/pwm.h>
#include <linux/slab.h>
@@ -380,6 +381,7 @@ static int pwm_imx_tpm_probe(struct platform_device *pdev)
static int pwm_imx_tpm_suspend(struct device *dev)
{
struct imx_tpm_pwm_chip *tpm = dev_get_drvdata(dev);
+ int ret;
if (tpm->enable_count > 0)
return -EBUSY;
@@ -393,7 +395,11 @@ static int pwm_imx_tpm_suspend(struct device *dev)
clk_disable_unprepare(tpm->clk);
- return 0;
+ ret = pinctrl_pm_select_sleep_state(dev);
+ if (ret)
+ clk_prepare_enable(tpm->clk);
+
+ return ret;
}
static int pwm_imx_tpm_resume(struct device *dev)
@@ -401,9 +407,15 @@ static int pwm_imx_tpm_resume(struct device *dev)
struct imx_tpm_pwm_chip *tpm = dev_get_drvdata(dev);
int ret = 0;
- ret = clk_prepare_enable(tpm->clk);
+ ret = pinctrl_pm_select_default_state(dev);
if (ret)
+ return ret;
+
+ ret = clk_prepare_enable(tpm->clk);
+ if (ret) {
dev_err(dev, "failed to prepare or enable clock: %d\n", ret);
+ pinctrl_pm_select_sleep_state(dev);
+ }
return ret;
}
--
2.34.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2] pwm: imx-tpm: Enable pinctrl setting for sleep state
2024-07-02 16:45 [PATCH v2] pwm: imx-tpm: Enable pinctrl setting for sleep state Shenwei Wang
@ 2024-07-05 8:37 ` Uwe Kleine-König
0 siblings, 0 replies; 2+ messages in thread
From: Uwe Kleine-König @ 2024-07-05 8:37 UTC (permalink / raw)
To: Shenwei Wang
Cc: Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
linux-pwm, imx, linux-arm-kernel, linux-imx
[-- Attachment #1: Type: text/plain, Size: 430 bytes --]
Hello,
On Tue, Jul 02, 2024 at 11:45:14AM -0500, Shenwei Wang wrote:
> Apply the pinctrl setting of sleep state when system enters
> suspend state.
> Restore to the default pinctrl setting when system resumes.
>
> Signed-off-by: Shenwei Wang <shenwei.wang@nxp.com>
> ---
I applied this patch to
https://git.kernel.org/pub/scm/linux/kernel/git/ukleinek/linux.git pwm/for-next
.
Thanks for your contribution
Uwe
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-07-05 8:37 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-02 16:45 [PATCH v2] pwm: imx-tpm: Enable pinctrl setting for sleep state Shenwei Wang
2024-07-05 8:37 ` Uwe Kleine-König
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox