devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] leds: gpio: Allow retaining state on shutdown
@ 2017-08-25  6:35 Andrew Jeffery
  2017-08-25  6:35 ` [PATCH 1/2] dt-bindings: leds: gpio: Add optional retain-state-shutdown property Andrew Jeffery
  2017-08-25  6:35 ` [PATCH 2/2] leds: gpio: Allow LED to retain state at shutdown Andrew Jeffery
  0 siblings, 2 replies; 6+ messages in thread
From: Andrew Jeffery @ 2017-08-25  6:35 UTC (permalink / raw)
  To: linux-leds
  Cc: Andrew Jeffery, rpurdie, jacek.anaszewski, pavel, robh+dt,
	mark.rutland, devicetree, linux-kernel, joel, openbmc

Hello,

LEDs controlled by BMCs are sometimes required to retain their state across BMC
resets. BMC resets may occur whilst the host is alive, thus the chassis and
host system remain powered up. In these two patches I define an new devicetree
property to describe the behaviour for GPIO LEDs and add support to the
leds-gpio driver.

Please review!

Cheers,

Andrew

Andrew Jeffery (2):
  dt-bindings: leds: gpio: Add optional retain-state-shutdown property
  leds: gpio: Allow LED to retain state at shutdown

 Documentation/devicetree/bindings/leds/leds-gpio.txt | 3 +++
 drivers/leds/leds-gpio.c                             | 7 ++++++-
 include/linux/leds.h                                 | 2 ++
 3 files changed, 11 insertions(+), 1 deletion(-)

-- 
2.11.0

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/2] dt-bindings: leds: gpio: Add optional retain-state-shutdown property
  2017-08-25  6:35 [PATCH 0/2] leds: gpio: Allow retaining state on shutdown Andrew Jeffery
@ 2017-08-25  6:35 ` Andrew Jeffery
  2017-08-25  6:35 ` [PATCH 2/2] leds: gpio: Allow LED to retain state at shutdown Andrew Jeffery
  1 sibling, 0 replies; 6+ messages in thread
From: Andrew Jeffery @ 2017-08-25  6:35 UTC (permalink / raw)
  To: linux-leds
  Cc: Andrew Jeffery, rpurdie, jacek.anaszewski, pavel, robh+dt,
	mark.rutland, devicetree, linux-kernel, joel, openbmc

On BMC systems it's sometimes necessary for a LED to retain its state
across a BMC reset (which is independent of the host system state). Add
a devicetree property to describe this behaviour. The property would
typically be used in conjunction with 'default-state = "keep"'.

Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
---
 Documentation/devicetree/bindings/leds/leds-gpio.txt | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/Documentation/devicetree/bindings/leds/leds-gpio.txt b/Documentation/devicetree/bindings/leds/leds-gpio.txt
index 76535ca37120..a48dda268f81 100644
--- a/Documentation/devicetree/bindings/leds/leds-gpio.txt
+++ b/Documentation/devicetree/bindings/leds/leds-gpio.txt
@@ -18,6 +18,9 @@ LED sub-node properties:
   see Documentation/devicetree/bindings/leds/common.txt
 - retain-state-suspended: (optional) The suspend state can be retained.Such
   as charge-led gpio.
+- retain-state-shutdown: (optional) Retain the state of the LED on shutdown.
+  Useful in BMC systems, for example when the BMC is rebooted while the host
+  remains up.
 - panic-indicator : (optional)
   see Documentation/devicetree/bindings/leds/common.txt
 
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/2] leds: gpio: Allow LED to retain state at shutdown
  2017-08-25  6:35 [PATCH 0/2] leds: gpio: Allow retaining state on shutdown Andrew Jeffery
  2017-08-25  6:35 ` [PATCH 1/2] dt-bindings: leds: gpio: Add optional retain-state-shutdown property Andrew Jeffery
@ 2017-08-25  6:35 ` Andrew Jeffery
  2017-08-25  7:32   ` Pavel Machek
  1 sibling, 1 reply; 6+ messages in thread
From: Andrew Jeffery @ 2017-08-25  6:35 UTC (permalink / raw)
  To: linux-leds
  Cc: Andrew Jeffery, rpurdie, jacek.anaszewski, pavel, robh+dt,
	mark.rutland, devicetree, linux-kernel, joel, openbmc

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@aj.id.au>
---
 drivers/leds/leds-gpio.c | 7 ++++++-
 include/linux/leds.h     | 2 ++
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/leds/leds-gpio.c b/drivers/leds/leds-gpio.c
index e753ba93ba1e..764c31301f90 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)
@@ -205,6 +207,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;
 
@@ -267,7 +271,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 64c56d454f7d..bf6db4fe895b 100644
--- a/include/linux/leds.h
+++ b/include/linux/leds.h
@@ -49,6 +49,7 @@ struct led_classdev {
 #define LED_HW_PLUGGABLE	(1 << 19)
 #define LED_PANIC_INDICATOR	(1 << 20)
 #define LED_BRIGHT_HW_CHANGED	(1 << 21)
+#define LED_RETAIN_AT_SHUTDOWN	(1 << 22)
 
 	/* set_brightness_work / blink_timer flags, atomic, private. */
 	unsigned long		work_flags;
@@ -392,6 +393,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;
 };
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/2] leds: gpio: Allow LED to retain state at shutdown
  2017-08-25  6:35 ` [PATCH 2/2] leds: gpio: Allow LED to retain state at shutdown Andrew Jeffery
@ 2017-08-25  7:32   ` Pavel Machek
  2017-08-27 11:01     ` Jacek Anaszewski
  0 siblings, 1 reply; 6+ messages in thread
From: Pavel Machek @ 2017-08-25  7:32 UTC (permalink / raw)
  To: Andrew Jeffery
  Cc: linux-leds, rpurdie, jacek.anaszewski, robh+dt, mark.rutland,
	devicetree, linux-kernel, joel, openbmc

[-- Attachment #1: Type: text/plain, Size: 442 bytes --]

On Fri 2017-08-25 16:05:03, 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.

I'd spell out what BMC is...

Otherwise series looks good.

Acked-by: Pavel Machek <pavel@ucw.cz>


								Pavel
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/2] leds: gpio: Allow LED to retain state at shutdown
  2017-08-25  7:32   ` Pavel Machek
@ 2017-08-27 11:01     ` Jacek Anaszewski
       [not found]       ` <3b89ad70-7024-b4ac-bf4e-49a02d12da51-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
  0 siblings, 1 reply; 6+ messages in thread
From: Jacek Anaszewski @ 2017-08-27 11:01 UTC (permalink / raw)
  To: Andrew Jeffery
  Cc: Pavel Machek, linux-leds, rpurdie, robh+dt, mark.rutland,
	devicetree, linux-kernel, joel, openbmc

Hi Andrew,

On 08/25/2017 09:32 AM, Pavel Machek wrote:
> On Fri 2017-08-25 16:05:03, 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.
> 
> I'd spell out what BMC is...

I agree with Pavel. Please give the expansion of the acronym
in both DT patch and the driver commit message.

> 
> Otherwise series looks good.
> 
> Acked-by: Pavel Machek <pavel@ucw.cz>

-- 
Best regards,
Jacek Anaszewski

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/2] leds: gpio: Allow LED to retain state at shutdown
       [not found]       ` <3b89ad70-7024-b4ac-bf4e-49a02d12da51-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
@ 2017-08-28  0:00         ` Andrew Jeffery
  0 siblings, 0 replies; 6+ messages in thread
From: Andrew Jeffery @ 2017-08-28  0:00 UTC (permalink / raw)
  To: Jacek Anaszewski
  Cc: Pavel Machek, linux-leds-u79uwXL29TY76Z2rM5mHXA,
	rpurdie-Fm38FmjxZ/leoWH0uzbU5w, robh+dt-DgEjT+Ai2ygdnm+yROfE0A,
	mark.rutland-5wv7dgnIgG8, devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA, joel-U3u1mxZcP9KHXe+LvDLADg,
	openbmc-uLR06cmDAlY/bJ5BZ2RsiQ

[-- Attachment #1: Type: text/plain, Size: 692 bytes --]

Hi Jacek, Pavel

On Sun, 2017-08-27 at 13:01 +0200, Jacek Anaszewski wrote:
> Hi Andrew,
> 
> On 08/25/2017 09:32 AM, Pavel Machek wrote:
> > On Fri 2017-08-25 16:05:03, 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.
> > 
> > I'd spell out what BMC is...
> 
> I agree with Pavel. Please give the expansion of the acronym
> in both DT patch and the driver commit message.

No worries, will reword and resend.

Thanks for the review.

Andrew

> 
> > 
> > Otherwise series looks good.
> > 
> > Acked-by: Pavel Machek <pavel-+ZI9xUNit7I@public.gmane.org>
> 
> 

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 801 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2017-08-28  0:00 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-08-25  6:35 [PATCH 0/2] leds: gpio: Allow retaining state on shutdown Andrew Jeffery
2017-08-25  6:35 ` [PATCH 1/2] dt-bindings: leds: gpio: Add optional retain-state-shutdown property Andrew Jeffery
2017-08-25  6:35 ` [PATCH 2/2] leds: gpio: Allow LED to retain state at shutdown Andrew Jeffery
2017-08-25  7:32   ` Pavel Machek
2017-08-27 11:01     ` Jacek Anaszewski
     [not found]       ` <3b89ad70-7024-b4ac-bf4e-49a02d12da51-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-08-28  0:00         ` Andrew Jeffery

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).