summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorMichael Polyntsov <[email protected]>2024-07-19 13:12:12 +0400
committerTom Rini <[email protected]>2024-07-30 12:35:23 -0600
commitb557f55e90f087ec310592b833441cd326206f61 (patch)
treea7d3ee88851b7f242eb24dedfe2115e5fe7a395b /include
parent2a15c676fa3413e7995e2a8b47e8932300e9e70b (diff)
led: Implement software led blinking
If hardware (or driver) doesn't support leds blinking, it's now possible to use software implementation of blinking instead. This relies on cyclic functions. Signed-off-by: Michael Polyntsov <[email protected]> Signed-off-by: Mikhail Kshevetskiy <[email protected]> Reviewed-by: Simon Glass <[email protected]>
Diffstat (limited to 'include')
-rw-r--r--include/led.h22
1 files changed, 22 insertions, 0 deletions
diff --git a/include/led.h b/include/led.h
index 9b24a4ce188..8270d6cef93 100644
--- a/include/led.h
+++ b/include/led.h
@@ -18,6 +18,20 @@ enum led_state_t {
LEDST_COUNT,
};
+enum led_sw_blink_state_t {
+ LED_SW_BLINK_ST_DISABLED,
+ LED_SW_BLINK_ST_NOT_READY,
+ LED_SW_BLINK_ST_OFF,
+ LED_SW_BLINK_ST_ON,
+};
+
+struct led_sw_blink {
+ enum led_sw_blink_state_t state;
+ struct udevice *dev;
+ struct cyclic_info cyclic;
+ const char cyclic_name[0];
+};
+
/**
* struct led_uc_plat - Platform data the uclass stores about each device
*
@@ -27,6 +41,9 @@ enum led_state_t {
struct led_uc_plat {
const char *label;
enum led_state_t default_state;
+#ifdef CONFIG_LED_SW_BLINK
+ struct led_sw_blink *sw_blink;
+#endif
};
/**
@@ -116,4 +133,9 @@ int led_set_period(struct udevice *dev, int period_ms);
*/
int led_bind_generic(struct udevice *parent, const char *driver_name);
+/* Internal functions for software blinking. Do not use them in your code */
+int led_sw_set_period(struct udevice *dev, int period_ms);
+bool led_sw_is_blinking(struct udevice *dev);
+bool led_sw_on_state_change(struct udevice *dev, enum led_state_t state);
+
#endif