summaryrefslogtreecommitdiffstats
path: root/drivers/pwm
diff options
context:
space:
mode:
authorFlorian Fainelli <florian.fainelli@broadcom.com>2023-10-11 19:07:17 +0200
committerThierry Reding <thierry.reding@gmail.com>2023-10-13 10:07:18 +0200
commit119a508c4dc956c859854f40a504c577598b68a8 (patch)
tree56b9b870dba09bdb313f5966cffcdddfee799afe /drivers/pwm
parentpwm: brcmstb: Checked clk_prepare_enable() return value (diff)
downloadlinux-119a508c4dc956c859854f40a504c577598b68a8.tar.xz
linux-119a508c4dc956c859854f40a504c577598b68a8.zip
pwm: bcm2835: Add support for suspend/resume
Similar to other drivers, we need to make sure that the clock is disabled during suspend and re-enabled during resume. Reported-by: Angus Clark <angus.clark@broadcom.com> Signed-off-by: Florian Fainelli <florian.fainelli@broadcom.com> Reviewed-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
Diffstat (limited to 'drivers/pwm')
-rw-r--r--drivers/pwm/pwm-bcm2835.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/drivers/pwm/pwm-bcm2835.c b/drivers/pwm/pwm-bcm2835.c
index 8c69ddfea2d0..9777babd5b95 100644
--- a/drivers/pwm/pwm-bcm2835.c
+++ b/drivers/pwm/pwm-bcm2835.c
@@ -163,6 +163,25 @@ static int bcm2835_pwm_probe(struct platform_device *pdev)
return 0;
}
+static int bcm2835_pwm_suspend(struct device *dev)
+{
+ struct bcm2835_pwm *pc = dev_get_drvdata(dev);
+
+ clk_disable_unprepare(pc->clk);
+
+ return 0;
+}
+
+static int bcm2835_pwm_resume(struct device *dev)
+{
+ struct bcm2835_pwm *pc = dev_get_drvdata(dev);
+
+ return clk_prepare_enable(pc->clk);
+}
+
+static DEFINE_SIMPLE_DEV_PM_OPS(bcm2835_pwm_pm_ops, bcm2835_pwm_suspend,
+ bcm2835_pwm_resume);
+
static const struct of_device_id bcm2835_pwm_of_match[] = {
{ .compatible = "brcm,bcm2835-pwm", },
{ /* sentinel */ }
@@ -173,6 +192,7 @@ static struct platform_driver bcm2835_pwm_driver = {
.driver = {
.name = "bcm2835-pwm",
.of_match_table = bcm2835_pwm_of_match,
+ .pm = pm_ptr(&bcm2835_pwm_pm_ops),
},
.probe = bcm2835_pwm_probe,
};