[PATCH 5/9] led: implement LED activity API
Christian Marangi
ansuelsmth at gmail.com
Mon Jun 24 23:46:15 CEST 2024
Implement LED activity API similar to BOOT LED API.
Usual activity might be a file transfer with TFTP, a flash write...
User of this API will call led_activity_on/off/blink() to signal these
kind of activity.
New Kconfig are implemented similar to BOOT LED, LED_ACTIVITY_ENABLE to
enable support for it, LED_ACTIVITY_LABEL to assign the LED in DT for
activity usage and LED_ACTIVITY_PERIOD to set the blinking period.
Signed-off-by: Christian Marangi <ansuelsmth at gmail.com>
---
drivers/led/Kconfig | 23 +++++++++++++++++++++++
include/led.h | 40 ++++++++++++++++++++++++++++++++++++++++
2 files changed, 63 insertions(+)
diff --git a/drivers/led/Kconfig b/drivers/led/Kconfig
index 0506a33b6ee..f53e5fb5bd3 100644
--- a/drivers/led/Kconfig
+++ b/drivers/led/Kconfig
@@ -31,6 +31,29 @@ config LED_BOOT_PERIOD
Value is normalized per CONFIG_SYS_HZ.
+config LED_ACTIVITY_ENABLE
+ bool "Enable LED activity support"
+ help
+ Enable LED activity support.
+
+ LED activity is a specific LED assigned to signal activity operation
+ like file trasnfer, flash write/erase...
+
+config LED_ACTIVITY_LABEL
+ string "LED activity label"
+ depends on LED_ACTIVITY_ENABLE
+ help
+ LED label defined in DT to assign for LED activity usage.
+
+config LED_ACTIVITY_PERIOD
+ int "LED activity period"
+ depends on LED_ACTIVITY_ENABLE && LED_BLINK
+ default 2
+ help
+ LED activity 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 479c6d17c5b..409397e1df9 100644
--- a/include/led.h
+++ b/include/led.h
@@ -176,4 +176,44 @@ static inline int led_boot_blink(void)
#endif
#endif
+#ifdef CONFIG_LED_ACTIVITY_ENABLE
+
+#define LED_ACTIVITY_PERIOD CONFIG_SYS_HZ / CONFIG_LED_ACTIVITY_PERIOD
+
+/**
+ * led_activity_on() - turn ON the designated LED for activity
+ *
+ * Return: 0 if OK, -ve on error
+ */
+static inline int led_activity_on(void)
+{
+ return led_set_state_by_label(CONFIG_LED_ACTIVITY_LABEL, LEDST_ON);
+}
+
+/**
+ * led_activity_off() - turn OFF the designated LED for activity
+ *
+ * Return: 0 if OK, -ve on error
+ */
+static inline int led_activity_off(void)
+{
+ return led_set_state_by_label(CONFIG_LED_ACTIVITY_LABEL, LEDST_OFF);
+}
+
+#ifdef CONFIG_LED_BLINK
+/**
+ * led_activity_blink() - turn ON the designated LED for activity
+ *
+ * Return: 0 if OK, -ve on error
+ */
+static inline int led_activity_blink(void)
+{
+ return led_set_period_by_label(CONFIG_LED_ACTIVITY_LABEL, LED_BOOT_PERIOD);
+}
+#else
+/* If LED BLINK is not supported/enabled, fallback to LED ON */
+#define led_activity_blink led_activity_on
+#endif
+#endif
+
#endif
--
2.45.1
More information about the U-Boot
mailing list