]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
led: migrate last legacy LED user (olinuxino+net) to modern LED framework
authorQuentin Schulz <quentin.schulz@cherry.de>
Thu, 20 Nov 2025 12:48:05 +0000 (13:48 +0100)
committerTom Rini <trini@konsulko.com>
Wed, 18 Mar 2026 19:06:19 +0000 (13:06 -0600)
This migrates the last user of the legacy LED API, IMX233-OLinuXino, to
the modern LED framework.

The current implementation does the following:
 - lit the LED when booting,
 - turn off the LED the moment a BOOTP packet is received,

The first step is easily reproduced by using the
/options/u-boot/boot-led property to point at the LED. Unfortunately,
the boot-led is only lit by U-Boot proper at the very end of the boot
process, much later than currently. We can however force the LED on
whenever the GPIO LED driver is bound by marking the LED as
default-state = "on", and this happens slightly before board_init() is
called. We then do not need /options/u-boot/boot-led property for that
anymore.

However, the second step relies on /options/u-boot/boot-led and
CONFIG_LED_BOOT being set to reproduce the same behavior and requires us
to migrate net/bootp.c to the modern LED framework at the same time to
keep bisectability.

I couldn't figure out how to map CONFIG_LED_STATUS_BIT=778 to an actual
GPIO on the SoC but according to the schematics[1] only one LED is
present. I couldn't also map the SoC pin number to an actual GPIO from
the IMX23 manual, but there's already one GPIO LED specified in the
Device Tree so my guess is all of those are one and the same.

This was only build tested as I do not own this device.

[1] https://github.com/OLIMEX/OLINUXINO/blob/master/HARDWARE/iMX233-OLinuXino-Mini/1.%20Latest%20hardware%20revision/iMX233-OLINUXINO-MINI%20hardware%20revision%20E/iMX233-OLINUXINO-MINI_Rev_E.pdf

Signed-off-by: Quentin Schulz <quentin.schulz@cherry.de>
arch/arm/dts/imx23-olinuxino-u-boot.dtsi
board/olimex/mx23_olinuxino/mx23_olinuxino.c
configs/mx23_olinuxino_defconfig
net/bootp.c

index dee8433696f869b7020414d6f9c387eb1659035e..3f2f117b953bc5b26eb6f7b15499ab6e5f0c629d 100644 (file)
@@ -1,5 +1,20 @@
 // SPDX-License-Identifier: GPL-2.0+
 
+/ {
+       leds {
+               user_led: user {
+                       default-state = "on";
+               };
+       };
+
+       options {
+               u-boot {
+                       compatible = "u-boot,config";
+                       boot-led = <&user_led>;
+               };
+       };
+};
+
 &ssp0 {
        non-removable;
 };
index b2bb6678c23f48a7f224a4d5f1c8b88a5e61071a..78136c1620a3991e89bec59a22dd9f6e4e5b0577 100644 (file)
@@ -13,9 +13,6 @@
 #include <asm/arch/imx-regs.h>
 #include <asm/arch/clock.h>
 #include <asm/arch/sys_proto.h>
-#ifdef CONFIG_LED_STATUS
-#include <status_led.h>
-#endif
 #include <linux/delay.h>
 
 DECLARE_GLOBAL_DATA_PTR;
@@ -61,9 +58,5 @@ int board_init(void)
        /* Adress of boot parameters */
        gd->bd->bi_boot_params = PHYS_SDRAM_1 + 0x100;
 
-#if defined(CONFIG_LED_STATUS) && defined(CONFIG_LED_STATUS_BOOT_ENABLE)
-       status_led_set(CONFIG_LED_STATUS_BOOT, CONFIG_LED_STATUS_STATE);
-#endif
-
        return 0;
 }
index 1da18f313442a626b499806362376a8c47ce7757..3df1c8d007daf5a6c94f50156b8e41fa92bffe0f 100644 (file)
@@ -8,6 +8,7 @@ CONFIG_NR_DRAM_BANKS=1
 CONFIG_ENV_SIZE=0x4000
 CONFIG_ENV_OFFSET=0x40000
 CONFIG_IMX_CONFIG=""
+CONFIG_DM_GPIO=y
 CONFIG_DEFAULT_DEVICE_TREE="imx23-olinuxino"
 CONFIG_TARGET_MX23_OLINUXINO=y
 CONFIG_SPL_SERIAL=y
@@ -38,14 +39,9 @@ CONFIG_USE_BOOTFILE=y
 CONFIG_BOOTFILE="uImage"
 CONFIG_VERSION_VARIABLE=y
 CONFIG_MXS_GPIO=y
-CONFIG_LED_STATUS=y
-CONFIG_LED_STATUS_GPIO=y
-CONFIG_LED_STATUS0=y
-CONFIG_LED_STATUS_BIT=778
-CONFIG_LED_STATUS_STATE=2
-CONFIG_LED_STATUS_BOOT_ENABLE=y
-CONFIG_LED_STATUS_BOOT=0
-CONFIG_LED_STATUS_CMD=y
+CONFIG_LED=y
+CONFIG_LED_BOOT=y
+CONFIG_LED_GPIO=y
 CONFIG_MMC_MXS=y
 CONFIG_CONS_INDEX=0
 CONFIG_DM_SERIAL=y
index 64fca9a42d9856cd6d06c18a4166ce9ff33af0f8..1d905a01a4784e9eeded435c61e872a071948f71 100644 (file)
@@ -19,8 +19,8 @@
 #include <linux/delay.h>
 #include <net/tftp.h>
 #include "bootp.h"
-#ifdef CONFIG_LED_STATUS
-#include <status_led.h>
+#if IS_ENABLED(CONFIG_LED_BOOT)
+#include <led.h>
 #endif
 #ifdef CONFIG_BOOTP_RANDOM_DELAY
 #include "net_rand.h"
@@ -396,8 +396,8 @@ static void bootp_handler(uchar *pkt, unsigned dest, struct in_addr sip,
        /*
         *      Got a good BOOTP reply.  Copy the data into our variables.
         */
-#if defined(CONFIG_LED_STATUS) && defined(CONFIG_LED_STATUS_BOOT_ENABLE)
-       status_led_set(CONFIG_LED_STATUS_BOOT, CONFIG_LED_STATUS_OFF);
+#if IS_ENABLED(CONFIG_LED_BOOT)
+       led_boot_off();
 #endif
 
        store_net_params(bp);           /* Store net parameters from reply */