diff options
author | Alexander Dahl <ada@thorsis.com> | 2023-08-23 15:58:55 +0200 |
---|---|---|
committer | Eugen Hristev <eugen.hristev@collabora.com> | 2023-08-29 17:39:01 +0300 |
commit | 1818b44b7bc8c8aaaa0d80c9a47e559a1f07bf1d (patch) | |
tree | 66f79ef0aa273e5519fb2817589475082fc4d925 | |
parent | 72d5e3c1405a5a6312435eb87a7e6b9f0a9333fa (diff) | |
download | u-boot-1818b44b7bc8c8aaaa0d80c9a47e559a1f07bf1d.zip u-boot-1818b44b7bc8c8aaaa0d80c9a47e559a1f07bf1d.tar.gz u-boot-1818b44b7bc8c8aaaa0d80c9a47e559a1f07bf1d.tar.bz2 |
board: sam9x60-curiosity: Let LED subsystem init leds if enabled
If CONFIG_LED and CONFIG_LED_GPIO are enabled, it is not necessary to
initialize the RGB LED on the board by manually setting hardcoded GPIOs
anymore. Everything is well defined in dts and can be used like on
boards of other vendors.
Keep the old behaviour as fallback, though.
With all this in place enabling CONFIG_CMD_LED gives us a working 'led'
command on the U-Boot shell.
Signed-off-by: Alexander Dahl <ada@thorsis.com>
-rw-r--r-- | arch/arm/dts/at91-sam9x60_curiosity-u-boot.dtsi | 18 | ||||
-rw-r--r-- | board/atmel/sam9x60_curiosity/sam9x60_curiosity.c | 18 |
2 files changed, 36 insertions, 0 deletions
diff --git a/arch/arm/dts/at91-sam9x60_curiosity-u-boot.dtsi b/arch/arm/dts/at91-sam9x60_curiosity-u-boot.dtsi index a1b76e9..dd46233 100644 --- a/arch/arm/dts/at91-sam9x60_curiosity-u-boot.dtsi +++ b/arch/arm/dts/at91-sam9x60_curiosity-u-boot.dtsi @@ -20,6 +20,24 @@ chosen { bootph-all; }; + + config { + u-boot,boot-led = "blue"; + }; + + leds { + led-red { + default-state = "off"; + }; + + led-green { + default-state = "off"; + }; + + led-blue { + default-state = "off"; + }; + }; }; &clk32 { diff --git a/board/atmel/sam9x60_curiosity/sam9x60_curiosity.c b/board/atmel/sam9x60_curiosity/sam9x60_curiosity.c index 0fe0de9..f53d359 100644 --- a/board/atmel/sam9x60_curiosity/sam9x60_curiosity.c +++ b/board/atmel/sam9x60_curiosity/sam9x60_curiosity.c @@ -9,6 +9,7 @@ #include <debug_uart.h> #include <fdtdec.h> #include <init.h> +#include <led.h> #include <asm/arch/at91_common.h> #include <asm/arch/at91_rstc.h> #include <asm/arch/at91_sfr.h> @@ -18,6 +19,7 @@ #include <asm/global_data.h> #include <asm/io.h> #include <asm/mach-types.h> +#include <dm/ofnode.h> extern void at91_pda_detect(void); @@ -27,9 +29,25 @@ void at91_prepare_cpu_var(void); static void board_leds_init(void) { +#if CONFIG_IS_ENABLED(LED) + const char *led_name; + struct udevice *dev; + int ret; + + led_name = ofnode_conf_read_str("u-boot,boot-led"); + if (!led_name) + return; + + ret = led_get_by_label(led_name, &dev); + if (ret) + return; + + led_set_state(dev, LEDST_ON); +#else at91_set_pio_output(AT91_PIO_PORTD, 17, 0); /* LED RED */ at91_set_pio_output(AT91_PIO_PORTD, 19, 0); /* LED GREEN */ at91_set_pio_output(AT91_PIO_PORTD, 21, 1); /* LED BLUE */ +#endif } int board_late_init(void) |