Skip to content

Commit 119a508

Browse files
ffainellithierryreding
authored andcommitted
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 <[email protected]> Signed-off-by: Florian Fainelli <[email protected]> Reviewed-by: Uwe Kleine-König <[email protected]> Signed-off-by: Thierry Reding <[email protected]>
1 parent aacbd65 commit 119a508

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

drivers/pwm/pwm-bcm2835.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,25 @@ static int bcm2835_pwm_probe(struct platform_device *pdev)
163163
return 0;
164164
}
165165

166+
static int bcm2835_pwm_suspend(struct device *dev)
167+
{
168+
struct bcm2835_pwm *pc = dev_get_drvdata(dev);
169+
170+
clk_disable_unprepare(pc->clk);
171+
172+
return 0;
173+
}
174+
175+
static int bcm2835_pwm_resume(struct device *dev)
176+
{
177+
struct bcm2835_pwm *pc = dev_get_drvdata(dev);
178+
179+
return clk_prepare_enable(pc->clk);
180+
}
181+
182+
static DEFINE_SIMPLE_DEV_PM_OPS(bcm2835_pwm_pm_ops, bcm2835_pwm_suspend,
183+
bcm2835_pwm_resume);
184+
166185
static const struct of_device_id bcm2835_pwm_of_match[] = {
167186
{ .compatible = "brcm,bcm2835-pwm", },
168187
{ /* sentinel */ }
@@ -173,6 +192,7 @@ static struct platform_driver bcm2835_pwm_driver = {
173192
.driver = {
174193
.name = "bcm2835-pwm",
175194
.of_match_table = bcm2835_pwm_of_match,
195+
.pm = pm_ptr(&bcm2835_pwm_pm_ops),
176196
},
177197
.probe = bcm2835_pwm_probe,
178198
};

0 commit comments

Comments
 (0)