* [PATCH v2] pwm: bcm2835: Add support for suspend/resume
@ 2023-10-09 20:42 Florian Fainelli
2023-10-10 7:19 ` Uwe Kleine-König
0 siblings, 1 reply; 2+ messages in thread
From: Florian Fainelli @ 2023-10-09 20:42 UTC (permalink / raw
To: linux-pwm
Cc: Florian Fainelli, Angus Clark, Thierry Reding,
Uwe Kleine-König, Broadcom internal kernel review list,
Ray Jui, Scott Branden,
moderated list:BROADCOM BCM2711/BCM2835 ARM ARCHITECTURE,
moderated list:BROADCOM BCM2711/BCM2835 ARM ARCHITECTURE,
open list
[-- Attachment #1.1: Type: text/plain, Size: 1519 bytes --]
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 v2:
- use DEFINE_SIMPLE_DEV_PM_OPS as suggested by Uwe
drivers/pwm/pwm-bcm2835.c | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/drivers/pwm/pwm-bcm2835.c b/drivers/pwm/pwm-bcm2835.c
index bdfc2a5ec0d6..938f993ae746 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 __maybe_unused bcm2835_pwm_suspend(struct device *dev)
+{
+ struct bcm2835_pwm *pc = dev_get_drvdata(dev);
+
+ clk_disable_unprepare(pc->clk);
+
+ return 0;
+}
+
+static int __maybe_unused 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 = &bcm2835_pwm_pm_ops,
},
.probe = bcm2835_pwm_probe,
.remove_new = bcm2835_pwm_remove,
--
2.34.1
[-- Attachment #1.2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 4221 bytes --]
[-- Attachment #2: Type: text/plain, Size: 176 bytes --]
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2] pwm: bcm2835: Add support for suspend/resume
2023-10-09 20:42 [PATCH v2] pwm: bcm2835: Add support for suspend/resume Florian Fainelli
@ 2023-10-10 7:19 ` Uwe Kleine-König
0 siblings, 0 replies; 2+ messages in thread
From: Uwe Kleine-König @ 2023-10-10 7:19 UTC (permalink / raw
To: Florian Fainelli
Cc: linux-pwm, Angus Clark, Thierry Reding,
Broadcom internal kernel review list, Ray Jui, Scott Branden,
moderated list:BROADCOM BCM2711/BCM2835 ARM ARCHITECTURE,
moderated list:BROADCOM BCM2711/BCM2835 ARM ARCHITECTURE,
open list
[-- Attachment #1.1: Type: text/plain, Size: 2067 bytes --]
On Mon, Oct 09, 2023 at 01:42:26PM -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 v2:
>
> - use DEFINE_SIMPLE_DEV_PM_OPS as suggested by Uwe
>
> drivers/pwm/pwm-bcm2835.c | 20 ++++++++++++++++++++
> 1 file changed, 20 insertions(+)
>
> diff --git a/drivers/pwm/pwm-bcm2835.c b/drivers/pwm/pwm-bcm2835.c
> index bdfc2a5ec0d6..938f993ae746 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 __maybe_unused bcm2835_pwm_suspend(struct device *dev)
> +{
> + struct bcm2835_pwm *pc = dev_get_drvdata(dev);
> +
> + clk_disable_unprepare(pc->clk);
> +
> + return 0;
> +}
> +
> +static int __maybe_unused bcm2835_pwm_resume(struct device *dev)
With DEFINE_SIMPLE_DEV_PM_OPS you don't need the __maybe_unused (which
is one of the upsides of DEFINE_SIMPLE_DEV_PM_OPS compared to
SIMPLE_DEV_PM_OPS)
> +{
> + 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 = &bcm2835_pwm_pm_ops,
I think
+ .pm = pm_ptr(&bcm2835_pwm_pm_ops),
is the right thing here.
Best regards
Uwe
--
Pengutronix e.K. | Uwe Kleine-König |
Industrial Linux Solutions | https://www.pengutronix.de/ |
[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
[-- Attachment #2: Type: text/plain, Size: 176 bytes --]
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-10-10 7:19 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-09 20:42 [PATCH v2] pwm: bcm2835: Add support for suspend/resume Florian Fainelli
2023-10-10 7:19 ` Uwe Kleine-König
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).