board: st: stm32mp2: add led support
authorPatrick Delaunay <patrick.delaunay@foss.st.com>
Tue, 26 Jul 2022 17:26:16 +0000 (19:26 +0200)
committerPatrice Chotard <patrice.chotard@foss.st.com>
Fri, 25 Apr 2025 14:00:22 +0000 (16:00 +0200)
Add led support, force default state on U-Boot initialization and put on
the Linux heartbeat led = "blue-led" during U-Boot execution.

Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
Signed-off-by: Patrice Chotard <patrice.chotard@foss.st.com>
arch/arm/dts/stm32mp257f-ev1-u-boot.dtsi
board/st/stm32mp2/stm32mp2.c
configs/stm32mp25_defconfig

index d4a75b2..a9bd5e0 100644 (file)
@@ -7,6 +7,7 @@
 
 / {
        config {
+               u-boot,boot-led = "led-blue";
                u-boot,mmc-env-partition = "u-boot-env";
        };
 
index 8446b8f..576a958 100644 (file)
@@ -8,6 +8,7 @@
 #include <config.h>
 #include <env_internal.h>
 #include <fdt_support.h>
+#include <led.h>
 #include <log.h>
 #include <misc.h>
 #include <mmc.h>
@@ -54,9 +55,46 @@ int checkboard(void)
        return 0;
 }
 
+static int get_led(struct udevice **dev, char *led_string)
+{
+       const char *led_name;
+       int ret;
+
+       led_name = ofnode_conf_read_str(led_string);
+       if (!led_name) {
+               log_debug("could not find %s config string\n", led_string);
+               return -ENOENT;
+       }
+       ret = led_get_by_label(led_name, dev);
+       if (ret) {
+               log_debug("get=%d\n", ret);
+               return ret;
+       }
+
+       return 0;
+}
+
+static int setup_led(enum led_state_t cmd)
+{
+       struct udevice *dev;
+       int ret;
+
+       if (!CONFIG_IS_ENABLED(LED))
+               return 0;
+
+       ret = get_led(&dev, "u-boot,boot-led");
+       if (ret)
+               return ret;
+
+       ret = led_set_state(dev, cmd);
+       return ret;
+}
+
 /* board dependent setup after realloc */
 int board_init(void)
 {
+       setup_led(LEDST_ON);
+
        return 0;
 }
 
@@ -142,3 +180,8 @@ int board_late_init(void)
 
        return 0;
 }
+
+void board_quiesce_devices(void)
+{
+       setup_led(LEDST_OFF);
+}
index fd5c36e..3d66653 100644 (file)
@@ -43,6 +43,8 @@ CONFIG_GPIO_HOG=y
 CONFIG_DM_I2C=y
 CONFIG_SYS_I2C_STM32F7=y
 CONFIG_SUPPORT_EMMC_BOOT=y
+CONFIG_LED=y
+CONFIG_LED_GPIO=y
 CONFIG_STM32_SDMMC2=y
 CONFIG_MTD=y
 CONFIG_USE_SYS_MAX_FLASH_BANKS=y