From: Michael Polyntsov Date: Fri, 19 Jul 2024 09:12:13 +0000 (+0400) Subject: led: Add dts property to specify blinking of the led X-Git-Url: http://git.dujemihanovic.xyz/%22http:/www.sics.se/static/%7B%7B%20%24.Site.BaseURL%20%7D%7Dposts/index.xml?a=commitdiff_plain;h=f15e89efad6f1bd7ddeb6fc5209427133cf22150;p=u-boot.git led: Add dts property to specify blinking of the led The standard property linux,default-trigger = "pattern"; used to get an effect. No blinking parameters can be set yet. Signed-off-by: Michael Polyntsov Signed-off-by: Mikhail Kshevetskiy Reviewed-by: Simon Glass --- diff --git a/drivers/led/led-uclass.c b/drivers/led/led-uclass.c index e6312d1dc4..199d68bc25 100644 --- a/drivers/led/led-uclass.c +++ b/drivers/led/led-uclass.c @@ -118,6 +118,14 @@ static int led_post_bind(struct udevice *dev) else return 0; + if (IS_ENABLED(CONFIG_LED_BLINK)) { + const char *trigger; + + trigger = dev_read_string(dev, "linux,default-trigger"); + if (trigger && !strncmp(trigger, "pattern", 7)) + uc_plat->default_state = LEDST_BLINK; + } + /* * In case the LED has default-state DT property, trigger * probe() to configure its default state during startup. @@ -130,12 +138,24 @@ static int led_post_bind(struct udevice *dev) static int led_post_probe(struct udevice *dev) { struct led_uc_plat *uc_plat = dev_get_uclass_plat(dev); + int default_period_ms = 1000; + int ret = 0; + + switch (uc_plat->default_state) { + case LEDST_ON: + case LEDST_OFF: + ret = led_set_state(dev, uc_plat->default_state); + break; + case LEDST_BLINK: + ret = led_set_period(dev, default_period_ms); + if (!ret) + ret = led_set_state(dev, uc_plat->default_state); + break; + default: + break; + } - if (uc_plat->default_state == LEDST_ON || - uc_plat->default_state == LEDST_OFF) - led_set_state(dev, uc_plat->default_state); - - return 0; + return ret; } UCLASS_DRIVER(led) = {