[PATCH v2 07/22] board: st: stm32mp2: add led support
Patrice CHOTARD
patrice.chotard at foss.st.com
Mon Apr 28 15:23:08 CEST 2025
On 4/25/25 15:15, Patrice Chotard wrote:
> From: Patrick Delaunay <patrick.delaunay at foss.st.com>
>
> 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 at foss.st.com>
> Signed-off-by: Patrice Chotard <patrice.chotard at foss.st.com>
> ---
>
> (no changes since v1)
>
> arch/arm/dts/stm32mp257f-ev1-u-boot.dtsi | 1 +
> board/st/stm32mp2/stm32mp2.c | 43 ++++++++++++++++++++++++
> configs/stm32mp25_defconfig | 2 ++
> 3 files changed, 46 insertions(+)
>
> diff --git a/arch/arm/dts/stm32mp257f-ev1-u-boot.dtsi b/arch/arm/dts/stm32mp257f-ev1-u-boot.dtsi
> index d4a75b2f03e..a9bd5e042fa 100644
> --- a/arch/arm/dts/stm32mp257f-ev1-u-boot.dtsi
> +++ b/arch/arm/dts/stm32mp257f-ev1-u-boot.dtsi
> @@ -7,6 +7,7 @@
>
> / {
> config {
> + u-boot,boot-led = "led-blue";
> u-boot,mmc-env-partition = "u-boot-env";
> };
>
> diff --git a/board/st/stm32mp2/stm32mp2.c b/board/st/stm32mp2/stm32mp2.c
> index 8446b8fd3d6..576a958c783 100644
> --- a/board/st/stm32mp2/stm32mp2.c
> +++ b/board/st/stm32mp2/stm32mp2.c
> @@ -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);
> +}
> diff --git a/configs/stm32mp25_defconfig b/configs/stm32mp25_defconfig
> index fd5c36ec3e2..3d6665335f5 100644
> --- a/configs/stm32mp25_defconfig
> +++ b/configs/stm32mp25_defconfig
> @@ -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
Applied to u-boot-stm32/master
Thanks
Patrice
More information about the U-Boot
mailing list