* [PATCH] leds: leds-pca963x: add nxp,leds-suspend property @ 2016-10-05 2:29 ` Matt Ranostay 2016-10-05 8:09 ` Jacek Anaszewski 0 siblings, 1 reply; 4+ messages in thread From: Matt Ranostay @ 2016-10-05 2:29 UTC (permalink / raw) To: linux-leds, devicetree; +Cc: Matt Ranostay, Richard Purdie, Jacek Anaszewski Allow the LED subsystem to blank the LEDS on suspend. Cc: Richard Purdie <rpurdie@rpsys.net> Cc: Jacek Anaszewski <j.anaszewski@samsung.com> Signed-off-by: Matt Ranostay <matt@ranostay.consulting> --- Documentation/devicetree/bindings/leds/pca963x.txt | 1 + drivers/leds/leds-pca963x.c | 9 +++++++++ include/linux/platform_data/leds-pca963x.h | 6 ++++++ 3 files changed, 16 insertions(+) diff --git a/Documentation/devicetree/bindings/leds/pca963x.txt b/Documentation/devicetree/bindings/leds/pca963x.txt index dafbe9931c2b..61b1f037ebd0 100644 --- a/Documentation/devicetree/bindings/leds/pca963x.txt +++ b/Documentation/devicetree/bindings/leds/pca963x.txt @@ -7,6 +7,7 @@ Optional properties: - nxp,totem-pole : use totem pole (push-pull) instead of open-drain (pca9632 defaults to open-drain, newer chips to totem pole) - nxp,hw-blink : use hardware blinking instead of software blinking +- nxp,leds-suspend : turn off LEDS on system suspend Each led is represented as a sub-node of the nxp,pca963x device. diff --git a/drivers/leds/leds-pca963x.c b/drivers/leds/leds-pca963x.c index 407eba11e187..9a347b94f1db 100644 --- a/drivers/leds/leds-pca963x.c +++ b/drivers/leds/leds-pca963x.c @@ -294,6 +294,12 @@ pca963x_dt_init(struct i2c_client *client, struct pca963x_chipdef *chip) else pdata->blink_type = PCA963X_SW_BLINK; + /* default to turning off LEDs on suspend */ + if (of_property_read_bool(np, "nxp,leds-suspend")) + pdata->suspend = PCA963X_LED_SUSPEND; + else + pdata->suspend = PCA963X_LED_RETAIN; + return pdata; } @@ -386,6 +392,9 @@ static int pca963x_probe(struct i2c_client *client, if (pdata && pdata->blink_type == PCA963X_HW_BLINK) pca963x[i].led_cdev.blink_set = pca963x_blink_set; + if (pdata && pdata->suspend == PCA963X_LED_SUSPEND) + pca963x[i].led_cdev.flags = LED_CORE_SUSPENDRESUME; + err = led_classdev_register(&client->dev, &pca963x[i].led_cdev); if (err < 0) goto exit; diff --git a/include/linux/platform_data/leds-pca963x.h b/include/linux/platform_data/leds-pca963x.h index e731f0036329..e5bad91e2fab 100644 --- a/include/linux/platform_data/leds-pca963x.h +++ b/include/linux/platform_data/leds-pca963x.h @@ -33,10 +33,16 @@ enum pca963x_blink_type { PCA963X_HW_BLINK, }; +enum pca963x_suspend { + PCA963X_LED_RETAIN, + PCA963X_LED_SUSPEND, +}; + struct pca963x_platform_data { struct led_platform_data leds; enum pca963x_outdrv outdrv; enum pca963x_blink_type blink_type; + enum pca963x_suspend suspend; }; #endif /* __LINUX_PCA963X_H*/ -- 2.7.4 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] leds: leds-pca963x: add nxp,leds-suspend property 2016-10-05 2:29 ` [PATCH] leds: leds-pca963x: add nxp,leds-suspend property Matt Ranostay @ 2016-10-05 8:09 ` Jacek Anaszewski 2016-10-05 12:22 ` Rob Herring 0 siblings, 1 reply; 4+ messages in thread From: Jacek Anaszewski @ 2016-10-05 8:09 UTC (permalink / raw) To: Matt Ranostay, linux-leds, devicetree Cc: Matt Ranostay, Richard Purdie, Rob Herring Hi Matt, On 10/05/2016 04:29 AM, Matt Ranostay wrote: > Allow the LED subsystem to blank the LEDS on suspend. > > Cc: Richard Purdie <rpurdie@rpsys.net> > Cc: Jacek Anaszewski <j.anaszewski@samsung.com> > Signed-off-by: Matt Ranostay <matt@ranostay.consulting> > --- > Documentation/devicetree/bindings/leds/pca963x.txt | 1 + > drivers/leds/leds-pca963x.c | 9 +++++++++ > include/linux/platform_data/leds-pca963x.h | 6 ++++++ > 3 files changed, 16 insertions(+) > > diff --git a/Documentation/devicetree/bindings/leds/pca963x.txt b/Documentation/devicetree/bindings/leds/pca963x.txt > index dafbe9931c2b..61b1f037ebd0 100644 > --- a/Documentation/devicetree/bindings/leds/pca963x.txt > +++ b/Documentation/devicetree/bindings/leds/pca963x.txt > @@ -7,6 +7,7 @@ Optional properties: > - nxp,totem-pole : use totem pole (push-pull) instead of open-drain (pca9632 defaults > to open-drain, newer chips to totem pole) > - nxp,hw-blink : use hardware blinking instead of software blinking > +- nxp,leds-suspend : turn off LEDS on system suspend How about making this property generic and adding it to the common LED bindings? Cc Rob. > > Each led is represented as a sub-node of the nxp,pca963x device. > > diff --git a/drivers/leds/leds-pca963x.c b/drivers/leds/leds-pca963x.c > index 407eba11e187..9a347b94f1db 100644 > --- a/drivers/leds/leds-pca963x.c > +++ b/drivers/leds/leds-pca963x.c > @@ -294,6 +294,12 @@ pca963x_dt_init(struct i2c_client *client, struct pca963x_chipdef *chip) > else > pdata->blink_type = PCA963X_SW_BLINK; > > + /* default to turning off LEDs on suspend */ > + if (of_property_read_bool(np, "nxp,leds-suspend")) > + pdata->suspend = PCA963X_LED_SUSPEND; > + else > + pdata->suspend = PCA963X_LED_RETAIN; > + > return pdata; > } > > @@ -386,6 +392,9 @@ static int pca963x_probe(struct i2c_client *client, > if (pdata && pdata->blink_type == PCA963X_HW_BLINK) > pca963x[i].led_cdev.blink_set = pca963x_blink_set; > > + if (pdata && pdata->suspend == PCA963X_LED_SUSPEND) > + pca963x[i].led_cdev.flags = LED_CORE_SUSPENDRESUME; > + In the previous patch you had this: static int pca963x_set_power(struct i2c_client *client, bool state) { return i2c_smbus_write_byte_data(client, PCA963X_MODE1, state ? 0 : BIT(4)); } The LED core doesn't know how to turn a device in a power down mode. It will only set the brightness of all LEDs exposed by the driver to LED_OFF on suspend. It is driver's responsibility to tell the device that it should enter power down mode if all LEDs are off. > err = led_classdev_register(&client->dev, &pca963x[i].led_cdev); > if (err < 0) > goto exit; > diff --git a/include/linux/platform_data/leds-pca963x.h b/include/linux/platform_data/leds-pca963x.h > index e731f0036329..e5bad91e2fab 100644 > --- a/include/linux/platform_data/leds-pca963x.h > +++ b/include/linux/platform_data/leds-pca963x.h > @@ -33,10 +33,16 @@ enum pca963x_blink_type { > PCA963X_HW_BLINK, > }; > > +enum pca963x_suspend { > + PCA963X_LED_RETAIN, > + PCA963X_LED_SUSPEND, > +}; > + If we made the DT property generic, then we could skip PCA963X prefix and move this enum to the linux/leds.h. > struct pca963x_platform_data { > struct led_platform_data leds; > enum pca963x_outdrv outdrv; > enum pca963x_blink_type blink_type; > + enum pca963x_suspend suspend; > }; > > #endif /* __LINUX_PCA963X_H*/ > -- Best regards, Jacek Anaszewski ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] leds: leds-pca963x: add nxp,leds-suspend property 2016-10-05 8:09 ` Jacek Anaszewski @ 2016-10-05 12:22 ` Rob Herring 2016-10-05 13:11 ` Jacek Anaszewski 0 siblings, 1 reply; 4+ messages in thread From: Rob Herring @ 2016-10-05 12:22 UTC (permalink / raw) To: Jacek Anaszewski Cc: Matt Ranostay, Linux LED Subsystem, devicetree@vger.kernel.org, Matt Ranostay, Richard Purdie On Wed, Oct 5, 2016 at 3:09 AM, Jacek Anaszewski <j.anaszewski@samsung.com> wrote: > Hi Matt, > > On 10/05/2016 04:29 AM, Matt Ranostay wrote: >> >> Allow the LED subsystem to blank the LEDS on suspend. >> >> Cc: Richard Purdie <rpurdie@rpsys.net> >> Cc: Jacek Anaszewski <j.anaszewski@samsung.com> >> Signed-off-by: Matt Ranostay <matt@ranostay.consulting> >> --- >> Documentation/devicetree/bindings/leds/pca963x.txt | 1 + >> drivers/leds/leds-pca963x.c | 9 +++++++++ >> include/linux/platform_data/leds-pca963x.h | 6 ++++++ >> 3 files changed, 16 insertions(+) >> >> diff --git a/Documentation/devicetree/bindings/leds/pca963x.txt >> b/Documentation/devicetree/bindings/leds/pca963x.txt >> index dafbe9931c2b..61b1f037ebd0 100644 >> --- a/Documentation/devicetree/bindings/leds/pca963x.txt >> +++ b/Documentation/devicetree/bindings/leds/pca963x.txt >> @@ -7,6 +7,7 @@ Optional properties: >> - nxp,totem-pole : use totem pole (push-pull) instead of open-drain >> (pca9632 defaults >> to open-drain, newer chips to totem pole) >> - nxp,hw-blink : use hardware blinking instead of software blinking >> +- nxp,leds-suspend : turn off LEDS on system suspend > > > How about making this property generic and adding it to the common LED > bindings? > > Cc Rob. Fine with me though seems like keeping on would be less common. Maybe "keep-in-suspend". Also, if this is a user decision, then it should be a sysfs attr and shouldn't be in DT. Rob ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] leds: leds-pca963x: add nxp,leds-suspend property 2016-10-05 12:22 ` Rob Herring @ 2016-10-05 13:11 ` Jacek Anaszewski 0 siblings, 0 replies; 4+ messages in thread From: Jacek Anaszewski @ 2016-10-05 13:11 UTC (permalink / raw) To: Matt Ranostay Cc: Rob Herring, Linux LED Subsystem, devicetree@vger.kernel.org, Matt Ranostay, Richard Purdie On 10/05/2016 02:22 PM, Rob Herring wrote: > On Wed, Oct 5, 2016 at 3:09 AM, Jacek Anaszewski > <j.anaszewski@samsung.com> wrote: >> Hi Matt, >> >> On 10/05/2016 04:29 AM, Matt Ranostay wrote: >>> >>> Allow the LED subsystem to blank the LEDS on suspend. >>> >>> Cc: Richard Purdie <rpurdie@rpsys.net> >>> Cc: Jacek Anaszewski <j.anaszewski@samsung.com> >>> Signed-off-by: Matt Ranostay <matt@ranostay.consulting> >>> --- >>> Documentation/devicetree/bindings/leds/pca963x.txt | 1 + >>> drivers/leds/leds-pca963x.c | 9 +++++++++ >>> include/linux/platform_data/leds-pca963x.h | 6 ++++++ >>> 3 files changed, 16 insertions(+) >>> >>> diff --git a/Documentation/devicetree/bindings/leds/pca963x.txt >>> b/Documentation/devicetree/bindings/leds/pca963x.txt >>> index dafbe9931c2b..61b1f037ebd0 100644 >>> --- a/Documentation/devicetree/bindings/leds/pca963x.txt >>> +++ b/Documentation/devicetree/bindings/leds/pca963x.txt >>> @@ -7,6 +7,7 @@ Optional properties: >>> - nxp,totem-pole : use totem pole (push-pull) instead of open-drain >>> (pca9632 defaults >>> to open-drain, newer chips to totem pole) >>> - nxp,hw-blink : use hardware blinking instead of software blinking >>> +- nxp,leds-suspend : turn off LEDS on system suspend >> >> >> How about making this property generic and adding it to the common LED >> bindings? >> >> Cc Rob. > > Fine with me though seems like keeping on would be less common. Maybe > "keep-in-suspend". Also, if this is a user decision, then it should be > a sysfs attr and shouldn't be in DT. Matt, did you have any specific reason for making it configurable? I like the idea of adding generic sysfs attribute for that, which would allow for customizing behaviour for a LED used as torch. I believe that in most use cases the user doesn't want that the LED used as torch went off on suspend. -- Best regards, Jacek Anaszewski ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-10-05 13:11 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <CGME20161005022942eucas1p2b092723a0c38c116cc971971e43b169e@eucas1p2.samsung.com>
2016-10-05 2:29 ` [PATCH] leds: leds-pca963x: add nxp,leds-suspend property Matt Ranostay
2016-10-05 8:09 ` Jacek Anaszewski
2016-10-05 12:22 ` Rob Herring
2016-10-05 13:11 ` Jacek Anaszewski
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 NNTP newsgroup(s).