[PATCH 1/2] led: migrate last legacy LED user (olinuxino+net) to modern LED framework
Quentin Schulz
foss+uboot at 0leil.net
Thu Nov 20 13:48:05 CET 2025
From: Quentin Schulz <quentin.schulz at cherry.de>
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 at cherry.de>
---
arch/arm/dts/imx23-olinuxino-u-boot.dtsi | 15 +++++++++++++++
board/olimex/mx23_olinuxino/mx23_olinuxino.c | 7 -------
configs/mx23_olinuxino_defconfig | 12 ++++--------
net/bootp.c | 8 ++++----
4 files changed, 23 insertions(+), 19 deletions(-)
diff --git a/arch/arm/dts/imx23-olinuxino-u-boot.dtsi b/arch/arm/dts/imx23-olinuxino-u-boot.dtsi
index dee8433696f..3f2f117b953 100644
--- a/arch/arm/dts/imx23-olinuxino-u-boot.dtsi
+++ b/arch/arm/dts/imx23-olinuxino-u-boot.dtsi
@@ -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;
};
diff --git a/board/olimex/mx23_olinuxino/mx23_olinuxino.c b/board/olimex/mx23_olinuxino/mx23_olinuxino.c
index b2bb6678c23..78136c1620a 100644
--- a/board/olimex/mx23_olinuxino/mx23_olinuxino.c
+++ b/board/olimex/mx23_olinuxino/mx23_olinuxino.c
@@ -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;
}
diff --git a/configs/mx23_olinuxino_defconfig b/configs/mx23_olinuxino_defconfig
index 1da18f31344..3df1c8d007d 100644
--- a/configs/mx23_olinuxino_defconfig
+++ b/configs/mx23_olinuxino_defconfig
@@ -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
diff --git a/net/bootp.c b/net/bootp.c
index 64fca9a42d9..1d905a01a47 100644
--- a/net/bootp.c
+++ b/net/bootp.c
@@ -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 */
--
2.51.1
More information about the U-Boot
mailing list