summaryrefslogtreecommitdiffstats
path: root/drivers/pwm/pwm-imx-tpm.c
diff options
context:
space:
mode:
authorShenwei Wang <shenwei.wang@nxp.com>2024-07-02 18:45:14 +0200
committerUwe Kleine-König <ukleinek@kernel.org>2024-07-10 17:53:51 +0200
commit9b22ceb31a7dda9a78959db3c6e35b04888032f9 (patch)
tree053f667db8626ef9a5de7da780119fd1ab0fa22d /drivers/pwm/pwm-imx-tpm.c
parentpwm: lpss: drop redundant runtime PM handles (diff)
downloadlinux-9b22ceb31a7dda9a78959db3c6e35b04888032f9.tar.xz
linux-9b22ceb31a7dda9a78959db3c6e35b04888032f9.zip
pwm: imx-tpm: Enable pinctrl setting for sleep state
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> Link: https://lore.kernel.org/r/20240702164514.11007-1-shenwei.wang@nxp.com Signed-off-by: Uwe Kleine-König <ukleinek@kernel.org>
Diffstat (limited to 'drivers/pwm/pwm-imx-tpm.c')
-rw-r--r--drivers/pwm/pwm-imx-tpm.c16
1 files 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;
}