
Implement LED boot API to signal correct boot of the system.
led_boot_on/off/blink() are introduced to turn ON, OFF and BLINK the designated boot LED.
New Kconfig are introduced, CONFIG_LED_BOOT_ENABLE to enable the feature, CONFIG_LED_BOOT_LABEL to declare the LED label in DT to reference the LED for BOOT usage and CONFIG_LED_BOOT_PERIOD to declare the blinking period.
If CONFIG_LED_BLINK is not enabled, led_boot_blink call will fallback to simple LED ON.
Signed-off-by: Christian Marangi ansuelsmth@gmail.com --- drivers/led/Kconfig | 22 ++++++++++++++++++++++ include/led.h | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+)
diff --git a/drivers/led/Kconfig b/drivers/led/Kconfig index 13d6eb40cea..0506a33b6ee 100644 --- a/drivers/led/Kconfig +++ b/drivers/led/Kconfig @@ -9,6 +9,28 @@ config LED can provide access to board-specific LEDs. Use of the device tree for configuration is encouraged.
+config LED_BOOT_ENABLE + bool "Enable LED boot support" + help + Enable LED boot support. + + LED boot is a specific LED assigned to signal boot operation status. + +config LED_BOOT_LABEL + string "LED boot label" + depends on LED_BOOT_ENABLE + help + LED label defined in DT to assign for LED boot usage. + +config LED_BOOT_PERIOD + int "LED boot period" + depends on LED_BOOT_ENABLE && LED_BLINK + default 2 + help + LED boot blink period in ms. + + Value is normalized per CONFIG_SYS_HZ. + config LED_BCM6328 bool "LED Support for BCM6328" depends on LED && ARCH_BMIPS diff --git a/include/led.h b/include/led.h index 71dd7a28d93..479c6d17c5b 100644 --- a/include/led.h +++ b/include/led.h @@ -136,4 +136,44 @@ int led_set_period_by_label(const char *label, int period_ms); */ int led_bind_generic(struct udevice *parent, const char *driver_name);
+#ifdef CONFIG_LED_BOOT_ENABLE + +#define LED_BOOT_PERIOD CONFIG_SYS_HZ / CONFIG_LED_BOOT_PERIOD + +/** + * led_boot_on() - turn ON the designated LED for booting + * + * Return: 0 if OK, -ve on error + */ +static inline int led_boot_on(void) +{ + return led_set_state_by_label(CONFIG_LED_BOOT_LABEL, LEDST_ON); +} + +/** + * led_boot_off() - turn OFF the designated LED for booting + * + * Return: 0 if OK, -ve on error + */ +static inline int led_boot_off(void) +{ + return led_set_state_by_label(CONFIG_LED_BOOT_LABEL, LEDST_OFF); +} + +#ifdef CONFIG_LED_BLINK +/** + * led_boot_blink() - turn ON the designated LED for booting + * + * Return: 0 if OK, -ve on error + */ +static inline int led_boot_blink(void) +{ + return led_set_period_by_label(CONFIG_LED_BOOT_LABEL, LED_BOOT_PERIOD); +} +#else +/* If LED BLINK is not supported/enabled, fallback to LED ON */ +#define led_boot_blink led_boot_on +#endif +#endif + #endif