LED
Generic LED API provided when a supported compatible is defined in DeviceTree.
To enable support for LEDs, enable the CONFIG_LED Kconfig option.
The most common implementation is for GPIO-connected LEDs. If using GPIO-connected LEDs, enable the LED_GPIO Kconfig option.
LED_BLINK support requires LED driver support and is therefore optional. If LED blink functionality is needed, enable the LED_BLINK Kconfig option. If LED driver doesn’t support HW Blink, SW Blink can be used with the Cyclic framework by enabling the CONFIG_LED_SW_BLINK.
Boot and Activity LEDs are also supported. These LEDs can signal various system operations during runtime, such as boot initialization, file transfers, and flash write/erase operations.
To enable a Boot LED, enable CONFIG_LED_BOOT and define in /options/u-boot root node the property boot-led. This will enable the specified LED to blink and turn ON when the bootloader initializes correctly.
To enable an Activity LED, enable CONFIG_LED_ACTIVITY and define in /options/u-boot root node the property activity-led. This will enable the specified LED to blink and turn ON during file transfers or flash write/erase operations.
Both Boot and Activity LEDs provide a simple API to turn the LED ON or OFF: led_boot_on(), led_boot_off(), led_activity_on(), and led_activity_off().
Both configurations can optionally define a boot/activity-led-period property if CONFIG_LED_BLINK or CONFIG_LED_SW_BLINK is enabled for LED blink operations, which is usually used by the Activity LED. If not defined the default value of 250 (ms) is used.
When CONFIG_LED_BLINK or CONFIG_LED_SW_BLINK is enabled, additional APIs are exposed: led_boot_blink() and led_activity_blink(). Note that if CONFIG_LED_BLINK or CONFIG_LED_SW_BLINK is disabled, these APIs will behave like the led_boot_on() and led_activity_on() APIs, respectively.
-
struct led_uc_plat
Platform data the uclass stores about each device
Definition
struct led_uc_plat {
const char *label;
enum led_state_t default_state;
char name[LED_MAX_NAME_SIZE];
#ifdef CONFIG_LED_SW_BLINK;
struct led_sw_blink *sw_blink;
#endif;
};
Members
label
LED label
default_state
LED default state
name
LED name, derived from function, color or function-enumerator property.
sw_blink
LED software blink struct
-
struct led_uc_priv
Private data the uclass stores about each device
Definition
struct led_uc_priv {
#ifdef CONFIG_LED_BOOT;
const char *boot_led_label;
int boot_led_period;
#endif;
#ifdef CONFIG_LED_ACTIVITY;
const char *activity_led_label;
int activity_led_period;
#endif;
};
Members
boot_led_label
Boot LED label
boot_led_period
Boot LED blink period
activity_led_label
Activity LED label
activity_led_period
Activity LED blink period
Parameters
const char *label
LED label to look up
struct udevice **devp
Returns the associated device, if found
Return
0 if found, -ENODEV if not found, other -ve on error
Parameters
struct udevice *dev
LED device to change
enum led_state_t state
LED state to set
Return
0 if OK, -ve on error
Parameters
struct udevice *dev
LED device to change
Return
LED state led_state_t, or -ve on error
Parameters
struct udevice *dev
LED device to change
int period_ms
LED blink period in milliseconds
Return
0 if OK, -ve on error
-
int led_bind_generic(struct udevice *parent, const char *driver_name)
bind children of parent to given driver
Parameters
struct udevice *parent
Top-level LED device
const char *driver_name
Driver for handling individual child nodes
-
int led_boot_on(void)
turn ON the designated LED for booting
Parameters
void
no arguments
Return
0 if OK, -ve on error
-
int led_boot_off(void)
turn OFF the designated LED for booting
Parameters
void
no arguments
Return
0 if OK, -ve on error
-
int led_boot_blink(void)
turn ON the designated LED for booting
Parameters
void
no arguments
Return
0 if OK, -ve on error
-
int led_activity_on(void)
turn ON the designated LED for activity
Parameters
void
no arguments
Return
0 if OK, -ve on error
-
int led_activity_off(void)
turn OFF the designated LED for activity
Parameters
void
no arguments
Return
0 if OK, -ve on error
-
int led_activity_blink(void)
turn ON the designated LED for activity
Parameters
void
no arguments
Return
0 if OK, -ve on error