Skip to content

Commit 9b22ceb

Browse files
Shenwei WangUwe Kleine-König
authored andcommitted
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 <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Uwe Kleine-König <[email protected]>
1 parent f3a616e commit 9b22ceb

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

drivers/pwm/pwm-imx-tpm.c

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include <linux/io.h>
2121
#include <linux/module.h>
2222
#include <linux/of.h>
23+
#include <linux/pinctrl/consumer.h>
2324
#include <linux/platform_device.h>
2425
#include <linux/pwm.h>
2526
#include <linux/slab.h>
@@ -380,6 +381,7 @@ static int pwm_imx_tpm_probe(struct platform_device *pdev)
380381
static int pwm_imx_tpm_suspend(struct device *dev)
381382
{
382383
struct imx_tpm_pwm_chip *tpm = dev_get_drvdata(dev);
384+
int ret;
383385

384386
if (tpm->enable_count > 0)
385387
return -EBUSY;
@@ -393,17 +395,27 @@ static int pwm_imx_tpm_suspend(struct device *dev)
393395

394396
clk_disable_unprepare(tpm->clk);
395397

396-
return 0;
398+
ret = pinctrl_pm_select_sleep_state(dev);
399+
if (ret)
400+
clk_prepare_enable(tpm->clk);
401+
402+
return ret;
397403
}
398404

399405
static int pwm_imx_tpm_resume(struct device *dev)
400406
{
401407
struct imx_tpm_pwm_chip *tpm = dev_get_drvdata(dev);
402408
int ret = 0;
403409

404-
ret = clk_prepare_enable(tpm->clk);
410+
ret = pinctrl_pm_select_default_state(dev);
405411
if (ret)
412+
return ret;
413+
414+
ret = clk_prepare_enable(tpm->clk);
415+
if (ret) {
406416
dev_err(dev, "failed to prepare or enable clock: %d\n", ret);
417+
pinctrl_pm_select_sleep_state(dev);
418+
}
407419

408420
return ret;
409421
}

0 commit comments

Comments
 (0)