* [PATCH] leds/pca963x: implement power management
@ 2024-01-16 7:34 Amitesh Singh
2024-01-25 13:30 ` Lee Jones
0 siblings, 1 reply; 5+ messages in thread
From: Amitesh Singh @ 2024-01-16 7:34 UTC (permalink / raw)
To: pavel; +Cc: lee, linux-leds, linux-kernel, Amitesh Singh
This implements power management in upstream driver
for pca9633 which enables device sleep and resume
on system-wide sleep/hibernation
Signed-off-by: Amitesh Singh <singh.amitesh@gmail.com>
---
drivers/leds/leds-pca963x.c | 34 ++++++++++++++++++++++++++++++++++
1 file changed, 34 insertions(+)
diff --git a/drivers/leds/leds-pca963x.c b/drivers/leds/leds-pca963x.c
index 47223c850e4b..a5804989d756 100644
--- a/drivers/leds/leds-pca963x.c
+++ b/drivers/leds/leds-pca963x.c
@@ -39,6 +39,7 @@
#define PCA963X_LED_PWM 0x2 /* Controlled through PWM */
#define PCA963X_LED_GRP_PWM 0x3 /* Controlled through PWM/GRPPWM */
+#define PCA963X_MODE1_SLEEP 0x04 /* Normal mode or Low Power mode, oscillator off */
#define PCA963X_MODE2_OUTDRV 0x04 /* Open-drain or totem pole */
#define PCA963X_MODE2_INVRT 0x10 /* Normal or inverted direction */
#define PCA963X_MODE2_DMBLNK 0x20 /* Enable blinking */
@@ -380,6 +381,38 @@ static int pca963x_register_leds(struct i2c_client *client,
return ret;
}
+#ifdef CONFIG_PM_SLEEP
+static int pca963x_suspend(struct device *dev)
+{
+ struct pca963x *chip;
+ u8 reg;
+
+ chip = dev_get_drvdata(dev);
+
+ reg = i2c_smbus_read_byte_data(chip->client, PCA963X_MODE1);
+ reg = reg | (1 << PCA963X_MODE1_SLEEP);
+ i2c_smbus_write_byte_data(chip->client, PCA963X_MODE1, reg);
+
+ return 0;
+}
+
+static int pca963x_resume(struct device *dev)
+{
+ struct pca963x *chip;
+ u8 reg;
+
+ chip = dev_get_drvdata(dev);
+
+ reg = i2c_smbus_read_byte_data(chip->client, PCA963X_MODE1);
+ reg = reg & ~(1 << PCA963X_MODE1_SLEEP);
+ i2c_smbus_write_byte_data(chip->client, PCA963X_MODE1, reg);
+
+ return 0;
+}
+#endif
+
+static SIMPLE_DEV_PM_OPS(pca963x_pm, pca963x_suspend, pca963x_resume);
+
static const struct of_device_id of_pca963x_match[] = {
{ .compatible = "nxp,pca9632", },
{ .compatible = "nxp,pca9633", },
@@ -430,6 +463,7 @@ static struct i2c_driver pca963x_driver = {
.driver = {
.name = "leds-pca963x",
.of_match_table = of_pca963x_match,
+ .pm = &pca963x_pm
},
.probe = pca963x_probe,
.id_table = pca963x_id,
--
2.43.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] leds/pca963x: implement power management
2024-01-16 7:34 [PATCH] leds/pca963x: implement power management Amitesh Singh
@ 2024-01-25 13:30 ` Lee Jones
2024-01-29 11:32 ` Amitesh Singh
0 siblings, 1 reply; 5+ messages in thread
From: Lee Jones @ 2024-01-25 13:30 UTC (permalink / raw)
To: Amitesh Singh; +Cc: pavel, linux-leds, linux-kernel
On Tue, 16 Jan 2024, Amitesh Singh wrote:
> This implements power management in upstream driver
> for pca9633 which enables device sleep and resume
> on system-wide sleep/hibernation
>
> Signed-off-by: Amitesh Singh <singh.amitesh@gmail.com>
> ---
> drivers/leds/leds-pca963x.c | 34 ++++++++++++++++++++++++++++++++++
> 1 file changed, 34 insertions(+)
Same review comments as before.
--
Lee Jones [李琼斯]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] leds/pca963x: implement power management
2024-01-25 13:30 ` Lee Jones
@ 2024-01-29 11:32 ` Amitesh Singh
0 siblings, 0 replies; 5+ messages in thread
From: Amitesh Singh @ 2024-01-29 11:32 UTC (permalink / raw)
To: Lee Jones; +Cc: pavel, linux-leds, linux-kernel
On Thu, Jan 25, 2024 at 7:00 PM Lee Jones <lee@kernel.org> wrote:
>
> On Tue, 16 Jan 2024, Amitesh Singh wrote:
>
> > This implements power management in upstream driver
> > for pca9633 which enables device sleep and resume
> > on system-wide sleep/hibernation
> >
> > Signed-off-by: Amitesh Singh <singh.amitesh@gmail.com>
> > ---
> > drivers/leds/leds-pca963x.c | 34 ++++++++++++++++++++++++++++++++++
> > 1 file changed, 34 insertions(+)
>
> Same review comments as before.
>
Thanks for reviewing it. I've updated the patch and sent it with v2 in
the subject line.
> --
> Lee Jones [李琼斯]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] leds/pca963x: implement power management
2024-01-16 7:24 Amitesh Singh
@ 2024-01-25 13:29 ` Lee Jones
0 siblings, 0 replies; 5+ messages in thread
From: Lee Jones @ 2024-01-25 13:29 UTC (permalink / raw)
To: Amitesh Singh; +Cc: pavel, linux-leds, linux-kernel
On Tue, 16 Jan 2024, Amitesh Singh wrote:
> This implements power management in upstream driver
This *is* the upstream driver. No need to mention that.
> for pca9633 which enables device sleep and resume
> on system-wide sleep/hibernation
>
> Signed-off-by: Amitesh Singh <singh.amitesh@gmail.com>
> ---
> drivers/leds/leds-pca963x.c | 38 +++++++++++++++++++++++++++++++++++++
> 1 file changed, 38 insertions(+)
>
> diff --git a/drivers/leds/leds-pca963x.c b/drivers/leds/leds-pca963x.c
> index 47223c850e4b..2474e40d8479 100644
> --- a/drivers/leds/leds-pca963x.c
> +++ b/drivers/leds/leds-pca963x.c
> @@ -39,6 +39,7 @@
> #define PCA963X_LED_PWM 0x2 /* Controlled through PWM */
> #define PCA963X_LED_GRP_PWM 0x3 /* Controlled through PWM/GRPPWM */
>
> +#define PCA963X_MODE1_SLEEP 0x04 /* Normal mode or Low Power mode, oscillator off */
> #define PCA963X_MODE2_OUTDRV 0x04 /* Open-drain or totem pole */
> #define PCA963X_MODE2_INVRT 0x10 /* Normal or inverted direction */
> #define PCA963X_MODE2_DMBLNK 0x20 /* Enable blinking */
> @@ -380,6 +381,42 @@ static int pca963x_register_leds(struct i2c_client *client,
> return ret;
> }
>
> +#ifdef CONFIG_PM_SLEEP
> +static int pca963x_suspend(struct device *dev)
> +{
> + struct pca963x *chip;
> + u8 reg;
> +
> + chip = dev_get_drvdata(dev);
Do the assignment during declaration.
> + reg = i2c_smbus_read_byte_data(chip->client, PCA963X_MODE1);
> + reg = reg | (1 << PCA963X_MODE1_SLEEP);
BIT()
> + i2c_smbus_write_byte_data(chip->client, PCA963X_MODE1, reg);
> +
> + return 0;
> +}
> +
> +static int pca963x_resume(struct device *dev)
> +{
> + struct pca963x *chip;
> + u8 reg;
> +
> + chip = dev_get_drvdata(dev);
As above.
> + reg = i2c_smbus_read_byte_data(chip->client, PCA963X_MODE1);
> + reg = reg & ~(1 << PCA963X_MODE1_SLEEP);
As above.
> + i2c_smbus_write_byte_data(chip->client, PCA963X_MODE1, reg);
> +
> + return 0;
> +}
> +#endif
> +
> +static const struct dev_pm_ops pca963x_pmops = {
> + SET_SYSTEM_SLEEP_PM_OPS(pca963x_suspend, pca963x_resume)
> +};
> +
Remove this line.
> +static SIMPLE_DEV_PM_OPS(pca963x_pm, pca963x_suspend, pca963x_resume);
> +
> static const struct of_device_id of_pca963x_match[] = {
> { .compatible = "nxp,pca9632", },
> { .compatible = "nxp,pca9633", },
> @@ -430,6 +467,7 @@ static struct i2c_driver pca963x_driver = {
> .driver = {
> .name = "leds-pca963x",
> .of_match_table = of_pca963x_match,
> + .pm = &pca963x_pmops
> },
> .probe = pca963x_probe,
> .id_table = pca963x_id,
> --
> 2.43.0
>
--
Lee Jones [李琼斯]
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH] leds/pca963x: implement power management
@ 2024-01-16 7:24 Amitesh Singh
2024-01-25 13:29 ` Lee Jones
0 siblings, 1 reply; 5+ messages in thread
From: Amitesh Singh @ 2024-01-16 7:24 UTC (permalink / raw)
To: pavel; +Cc: lee, linux-leds, linux-kernel, Amitesh Singh
This implements power management in upstream driver
for pca9633 which enables device sleep and resume
on system-wide sleep/hibernation
Signed-off-by: Amitesh Singh <singh.amitesh@gmail.com>
---
drivers/leds/leds-pca963x.c | 38 +++++++++++++++++++++++++++++++++++++
1 file changed, 38 insertions(+)
diff --git a/drivers/leds/leds-pca963x.c b/drivers/leds/leds-pca963x.c
index 47223c850e4b..2474e40d8479 100644
--- a/drivers/leds/leds-pca963x.c
+++ b/drivers/leds/leds-pca963x.c
@@ -39,6 +39,7 @@
#define PCA963X_LED_PWM 0x2 /* Controlled through PWM */
#define PCA963X_LED_GRP_PWM 0x3 /* Controlled through PWM/GRPPWM */
+#define PCA963X_MODE1_SLEEP 0x04 /* Normal mode or Low Power mode, oscillator off */
#define PCA963X_MODE2_OUTDRV 0x04 /* Open-drain or totem pole */
#define PCA963X_MODE2_INVRT 0x10 /* Normal or inverted direction */
#define PCA963X_MODE2_DMBLNK 0x20 /* Enable blinking */
@@ -380,6 +381,42 @@ static int pca963x_register_leds(struct i2c_client *client,
return ret;
}
+#ifdef CONFIG_PM_SLEEP
+static int pca963x_suspend(struct device *dev)
+{
+ struct pca963x *chip;
+ u8 reg;
+
+ chip = dev_get_drvdata(dev);
+
+ reg = i2c_smbus_read_byte_data(chip->client, PCA963X_MODE1);
+ reg = reg | (1 << PCA963X_MODE1_SLEEP);
+ i2c_smbus_write_byte_data(chip->client, PCA963X_MODE1, reg);
+
+ return 0;
+}
+
+static int pca963x_resume(struct device *dev)
+{
+ struct pca963x *chip;
+ u8 reg;
+
+ chip = dev_get_drvdata(dev);
+
+ reg = i2c_smbus_read_byte_data(chip->client, PCA963X_MODE1);
+ reg = reg & ~(1 << PCA963X_MODE1_SLEEP);
+ i2c_smbus_write_byte_data(chip->client, PCA963X_MODE1, reg);
+
+ return 0;
+}
+#endif
+
+static const struct dev_pm_ops pca963x_pmops = {
+ SET_SYSTEM_SLEEP_PM_OPS(pca963x_suspend, pca963x_resume)
+};
+
+static SIMPLE_DEV_PM_OPS(pca963x_pm, pca963x_suspend, pca963x_resume);
+
static const struct of_device_id of_pca963x_match[] = {
{ .compatible = "nxp,pca9632", },
{ .compatible = "nxp,pca9633", },
@@ -430,6 +467,7 @@ static struct i2c_driver pca963x_driver = {
.driver = {
.name = "leds-pca963x",
.of_match_table = of_pca963x_match,
+ .pm = &pca963x_pmops
},
.probe = pca963x_probe,
.id_table = pca963x_id,
--
2.43.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2024-01-29 11:32 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-16 7:34 [PATCH] leds/pca963x: implement power management Amitesh Singh
2024-01-25 13:30 ` Lee Jones
2024-01-29 11:32 ` Amitesh Singh
-- strict thread matches above, loose matches on Subject: below --
2024-01-16 7:24 Amitesh Singh
2024-01-25 13:29 ` Lee Jones
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.