aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEzequiel Garcia <ezequiel@vanguardiasur.com.ar>2016-04-28 18:03:40 -0400
committerJacek Anaszewski <j.anaszewski@samsung.com>2016-05-06 04:26:07 -0400
commit80d6737b27bbdf645a815c136606836b435f0268 (patch)
tree5a4564508a9380adf07ff33a9a91b8ef51e554a1
parente4f4f7091ee6d085c4a84b4023a61483d71bc777 (diff)
leds: gpio: Support the "panic-indicator" firmware property
Calling a GPIO LEDs is quite likely to work even if the kernel has paniced, so they are ideal to blink in this situation. This commit adds support for the new "panic-indicator" firmware property, allowing to mark a given LED to blink on a kernel panic. Signed-off-by: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar> Reviewed-by: Matthias Brugger <mbrugger@suse.com> Acked-by: Pavel Machek <pavel@ucw.cz> Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com>
-rw-r--r--Documentation/devicetree/bindings/leds/leds-gpio.txt2
-rw-r--r--drivers/leds/leds-gpio.c4
-rw-r--r--include/linux/leds.h1
3 files changed, 7 insertions, 0 deletions
diff --git a/Documentation/devicetree/bindings/leds/leds-gpio.txt b/Documentation/devicetree/bindings/leds/leds-gpio.txt
index fea1ebfe24a9..cbbeb1850910 100644
--- a/Documentation/devicetree/bindings/leds/leds-gpio.txt
+++ b/Documentation/devicetree/bindings/leds/leds-gpio.txt
@@ -23,6 +23,8 @@ LED sub-node properties:
23 property is not present. 23 property is not present.
24- retain-state-suspended: (optional) The suspend state can be retained.Such 24- retain-state-suspended: (optional) The suspend state can be retained.Such
25 as charge-led gpio. 25 as charge-led gpio.
26- panic-indicator : (optional)
27 see Documentation/devicetree/bindings/leds/common.txt
26 28
27Examples: 29Examples:
28 30
diff --git a/drivers/leds/leds-gpio.c b/drivers/leds/leds-gpio.c
index 61143f55597e..8229f063b483 100644
--- a/drivers/leds/leds-gpio.c
+++ b/drivers/leds/leds-gpio.c
@@ -127,6 +127,8 @@ static int create_gpio_led(const struct gpio_led *template,
127 led_dat->cdev.brightness = state ? LED_FULL : LED_OFF; 127 led_dat->cdev.brightness = state ? LED_FULL : LED_OFF;
128 if (!template->retain_state_suspended) 128 if (!template->retain_state_suspended)
129 led_dat->cdev.flags |= LED_CORE_SUSPENDRESUME; 129 led_dat->cdev.flags |= LED_CORE_SUSPENDRESUME;
130 if (template->panic_indicator)
131 led_dat->cdev.flags |= LED_PANIC_INDICATOR;
130 132
131 ret = gpiod_direction_output(led_dat->gpiod, state); 133 ret = gpiod_direction_output(led_dat->gpiod, state);
132 if (ret < 0) 134 if (ret < 0)
@@ -200,6 +202,8 @@ static struct gpio_leds_priv *gpio_leds_create(struct platform_device *pdev)
200 202
201 if (fwnode_property_present(child, "retain-state-suspended")) 203 if (fwnode_property_present(child, "retain-state-suspended"))
202 led.retain_state_suspended = 1; 204 led.retain_state_suspended = 1;
205 if (fwnode_property_present(child, "panic-indicator"))
206 led.panic_indicator = 1;
203 207
204 ret = create_gpio_led(&led, &priv->leds[priv->num_leds], 208 ret = create_gpio_led(&led, &priv->leds[priv->num_leds],
205 dev, NULL); 209 dev, NULL);
diff --git a/include/linux/leds.h b/include/linux/leds.h
index 7e9fb00e15e8..d2b13066e781 100644
--- a/include/linux/leds.h
+++ b/include/linux/leds.h
@@ -365,6 +365,7 @@ struct gpio_led {
365 unsigned gpio; 365 unsigned gpio;
366 unsigned active_low : 1; 366 unsigned active_low : 1;
367 unsigned retain_state_suspended : 1; 367 unsigned retain_state_suspended : 1;
368 unsigned panic_indicator : 1;
368 unsigned default_state : 2; 369 unsigned default_state : 2;
369 /* default_state should be one of LEDS_GPIO_DEFSTATE_(ON|OFF|KEEP) */ 370 /* default_state should be one of LEDS_GPIO_DEFSTATE_(ON|OFF|KEEP) */
370 struct gpio_desc *gpiod; 371 struct gpio_desc *gpiod;