[PATCH linux dev-4.10 2/5] leds: gpio: Allow LED to retain state at shutdown
Andrew Jeffery
andrew at aj.id.au
Fri Aug 25 17:43:14 AEST 2017
On Fri, 2017-08-25 at 09:40 +0200, Cédric Le Goater wrote:
> On 08/25/2017 08:52 AM, Andrew Jeffery wrote:
> > In some systems, such as BMCs, we want to retain the state of LEDs
> > across a reboot of the BMC whilst the host remains up.
> >
> > > > Signed-off-by: Andrew Jeffery <andrew at aj.id.au>
> > ---
> > drivers/leds/leds-gpio.c | 7 ++++++-
> > include/linux/leds.h | 3 +++
> > 2 files changed, 9 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/leds/leds-gpio.c b/drivers/leds/leds-gpio.c
> > index d400dcaf4d29..061ab9220048 100644
> > --- a/drivers/leds/leds-gpio.c
> > +++ b/drivers/leds/leds-gpio.c
> > @@ -134,6 +134,8 @@ static int create_gpio_led(const struct gpio_led *template,
> > > > led_dat->cdev.flags |= LED_CORE_SUSPENDRESUME;
> > > > if (template->panic_indicator)
> > > > led_dat->cdev.flags |= LED_PANIC_INDICATOR;
> > > > + if (template->retain_state_shutdown)
> > > > + led_dat->cdev.flags |= LED_RETAIN_AT_SHUTDOWN;
> >
> > > > ret = gpiod_direction_output(led_dat->gpiod, state);
> > > > if (ret < 0)
> > @@ -203,6 +205,8 @@ static struct gpio_leds_priv *gpio_leds_create(struct platform_device *pdev)
> >
> > > > if (fwnode_property_present(child, "retain-state-suspended"))
> > > > led.retain_state_suspended = 1;
> > > > + if (fwnode_property_present(child, "retain-state-shutdown"))
> > > > + led.retain_state_shutdown = 1;
> > > > if (fwnode_property_present(child, "panic-indicator"))
> > > > led.panic_indicator = 1;
> >
> > @@ -265,7 +269,8 @@ static void gpio_led_shutdown(struct platform_device *pdev)
> > > > for (i = 0; i < priv->num_leds; i++) {
> > > > struct gpio_led_data *led = &priv->leds[i];
> >
> > > > - gpio_led_set(&led->cdev, LED_OFF);
> > > > + if (!(led->cdev.flags & LED_RETAIN_AT_SHUTDOWN))
> > > > + gpio_led_set(&led->cdev, LED_OFF);
> > > > }
> > }
> >
> > diff --git a/include/linux/leds.h b/include/linux/leds.h
> > index 569cb531094c..4d39f767f34a 100644
> > --- a/include/linux/leds.h
> > +++ b/include/linux/leds.h
> > @@ -46,6 +46,8 @@ struct led_classdev {
> > > > #define LED_DEV_CAP_FLASH (1 << 18)
> > > > #define LED_HW_PLUGGABLE (1 << 19)
> > > > #define LED_PANIC_INDICATOR (1 << 20)
> > +#define LED_BRIGHT_HW_CHANGED (1 << 21)
>
> where does this come from ? is it used ?
Ah, forgot to comment about that. It comes from upstream. I backported
the changes from on top of v4.13-rc6.
I kept it from the conflict to justify using (1 << 22) below, to remain
compatible with upstream.
Andrew
>
> Thanks,
>
> C.
>
> > > > +#define LED_RETAIN_AT_SHUTDOWN (1 << 22)
> >
> > > > /* set_brightness_work / blink_timer flags, atomic, private. */
> > > > > > unsigned long work_flags;
> > @@ -378,6 +380,7 @@ struct gpio_led {
> > > > > > unsigned retain_state_suspended : 1;
> > > > > > unsigned panic_indicator : 1;
> > > > > > unsigned default_state : 2;
> > > > > > + unsigned retain_state_shutdown : 1;
> > > > /* default_state should be one of LEDS_GPIO_DEFSTATE_(ON|OFF|KEEP) */
> > > > struct gpio_desc *gpiod;
> > };
> >
>
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: This is a digitally signed message part
URL: <http://lists.ozlabs.org/pipermail/openbmc/attachments/20170825/b7f487c3/attachment.sig>
More information about the openbmc
mailing list