diff mbox series

[v3] pwm: bcm2835: Add support for suspend/resume

Message ID 20231011170717.3738712-1-florian.fainelli@broadcom.com (mailing list archive)
State New, archived
Headers show
Series [v3] pwm: bcm2835: Add support for suspend/resume | expand

Commit Message

Florian Fainelli Oct. 11, 2023, 5:07 p.m. UTC
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>
---
Changes in v3:

- removed __maybe_unused and use pm_ptr()

Changes in v2:

- use DEFINE_SIMPLE_DEV_PM_OPS as suggested by Uwe

 drivers/pwm/pwm-bcm2835.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

Comments

Uwe Kleine-König Oct. 11, 2023, 8:06 p.m. UTC | #1
Hello Florian,

On Wed, Oct 11, 2023 at 10:07:17AM -0700, Florian Fainelli wrote:
> 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>

Thanks for your respin,
Uwe
Thierry Reding Oct. 12, 2023, 1:55 p.m. UTC | #2
On Wed, Oct 11, 2023 at 10:07:17AM -0700, Florian Fainelli wrote:
> 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>
> ---
> Changes in v3:
> 
> - removed __maybe_unused and use pm_ptr()
> 
> Changes in v2:
> 
> - use DEFINE_SIMPLE_DEV_PM_OPS as suggested by Uwe
> 
>  drivers/pwm/pwm-bcm2835.c | 20 ++++++++++++++++++++
>  1 file changed, 20 insertions(+)

Applied, thanks.

Thierry
diff mbox series

Patch

diff --git a/drivers/pwm/pwm-bcm2835.c b/drivers/pwm/pwm-bcm2835.c
index bdfc2a5ec0d6..21ed2f2ebdd0 100644
--- a/drivers/pwm/pwm-bcm2835.c
+++ b/drivers/pwm/pwm-bcm2835.c
@@ -182,6 +182,25 @@  static void bcm2835_pwm_remove(struct platform_device *pdev)
 	clk_disable_unprepare(pc->clk);
 }
 
+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 */ }
@@ -192,6 +211,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,
 	.remove_new = bcm2835_pwm_remove,