diff mbox series

[v2,04/12] board: stm32mp1: update management of boot-led

Message ID 20200422142834.v2.4.I15cb0a6245fb4cd5d23371683c2697f794adf306@changeid
State Accepted
Commit 0c95295e17b046616457aaed8885a73b595a1ae8
Delegated to: Patrick Delaunay
Headers show
Series stm32mp1: several board and arch updates | expand

Commit Message

Patrick DELAUNAY April 22, 2020, 12:29 p.m. UTC
Force boot-led ON and no more rely on default-state.
This patch avoid device-tree modification for U-Boot.


Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
---

Changes in v2:
- use CONFIG_IS_ENABLED(LED) everywhere

 arch/arm/dts/stm32mp157a-dk1-u-boot.dtsi |  4 ---
 arch/arm/dts/stm32mp157c-ed1-u-boot.dtsi |  4 ---
 board/st/stm32mp1/stm32mp1.c             | 33 ++++++++++++------------
 3 files changed, 16 insertions(+), 25 deletions(-)

Comments

Patrice CHOTARD May 11, 2020, 1:58 p.m. UTC | #1
On 4/22/20 2:29 PM, Patrick Delaunay wrote:
> Force boot-led ON and no more rely on default-state.
> This patch avoid device-tree modification for U-Boot.
>
>
> Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
> ---
>
> Changes in v2:
> - use CONFIG_IS_ENABLED(LED) everywhere
>
>  arch/arm/dts/stm32mp157a-dk1-u-boot.dtsi |  4 ---
>  arch/arm/dts/stm32mp157c-ed1-u-boot.dtsi |  4 ---
>  board/st/stm32mp1/stm32mp1.c             | 33 ++++++++++++------------
>  3 files changed, 16 insertions(+), 25 deletions(-)
>
> diff --git a/arch/arm/dts/stm32mp157a-dk1-u-boot.dtsi b/arch/arm/dts/stm32mp157a-dk1-u-boot.dtsi
> index 5844d41c53..c52abeb1e7 100644
> --- a/arch/arm/dts/stm32mp157a-dk1-u-boot.dtsi
> +++ b/arch/arm/dts/stm32mp157a-dk1-u-boot.dtsi
> @@ -27,10 +27,6 @@
>  			default-state = "off";
>  			status = "okay";
>  		};
> -
> -		blue {
> -			default-state = "on";
> -		};
>  	};
>  };
>  
> diff --git a/arch/arm/dts/stm32mp157c-ed1-u-boot.dtsi b/arch/arm/dts/stm32mp157c-ed1-u-boot.dtsi
> index ed2f024be9..84af7fa47b 100644
> --- a/arch/arm/dts/stm32mp157c-ed1-u-boot.dtsi
> +++ b/arch/arm/dts/stm32mp157c-ed1-u-boot.dtsi
> @@ -28,10 +28,6 @@
>  			default-state = "off";
>  			status = "okay";
>  		};
> -
> -		blue {
> -			default-state = "on";
> -		};
>  	};
>  };
>  
> diff --git a/board/st/stm32mp1/stm32mp1.c b/board/st/stm32mp1/stm32mp1.c
> index d85a57cee2..6a3e2e64bf 100644
> --- a/board/st/stm32mp1/stm32mp1.c
> +++ b/board/st/stm32mp1/stm32mp1.c
> @@ -260,7 +260,6 @@ int g_dnl_bind_fixup(struct usb_device_descriptor *dev, const char *name)
>  
>  #endif /* CONFIG_USB_GADGET */
>  
> -#ifdef CONFIG_LED
>  static int get_led(struct udevice **dev, char *led_string)
>  {
>  	char *led_name;
> @@ -286,6 +285,9 @@ 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;
> @@ -293,32 +295,29 @@ static int setup_led(enum led_state_t cmd)
>  	ret = led_set_state(dev, cmd);
>  	return ret;
>  }
> -#endif
>  
>  static void __maybe_unused led_error_blink(u32 nb_blink)
>  {
> -#ifdef CONFIG_LED
>  	int ret;
>  	struct udevice *led;
>  	u32 i;
> -#endif
>  
>  	if (!nb_blink)
>  		return;
>  
> -#ifdef CONFIG_LED
> -	ret = get_led(&led, "u-boot,error-led");
> -	if (!ret) {
> -		/* make u-boot,error-led blinking */
> -		/* if U32_MAX and 125ms interval, for 17.02 years */
> -		for (i = 0; i < 2 * nb_blink; i++) {
> -			led_set_state(led, LEDST_TOGGLE);
> -			mdelay(125);
> -			WATCHDOG_RESET();
> +	if (CONFIG_IS_ENABLED(LED)) {
> +		ret = get_led(&led, "u-boot,error-led");
> +		if (!ret) {
> +			/* make u-boot,error-led blinking */
> +			/* if U32_MAX and 125ms interval, for 17.02 years */
> +			for (i = 0; i < 2 * nb_blink; i++) {
> +				led_set_state(led, LEDST_TOGGLE);
> +				mdelay(125);
> +				WATCHDOG_RESET();
> +			}
> +			led_set_state(led, LEDST_ON);
>  		}
> -		led_set_state(led, LEDST_ON);
>  	}
> -#endif
>  
>  	/* infinite: the boot process must be stopped */
>  	if (nb_blink == U32_MAX)
> @@ -651,6 +650,8 @@ int board_init(void)
>  	if (CONFIG_IS_ENABLED(LED))
>  		led_default_state();
>  
> +	setup_led(LEDST_ON);
> +
>  	return 0;
>  }
>  
> @@ -705,9 +706,7 @@ int board_late_init(void)
>  
>  void board_quiesce_devices(void)
>  {
> -#ifdef CONFIG_LED
>  	setup_led(LEDST_OFF);
> -#endif
>  }
>  
>  /* eth init function : weak called in eqos driver */

Reviewed-by: Patrice Chotard <patrice.chotard@st.com>

Thanks

Patrice
diff mbox series

Patch

diff --git a/arch/arm/dts/stm32mp157a-dk1-u-boot.dtsi b/arch/arm/dts/stm32mp157a-dk1-u-boot.dtsi
index 5844d41c53..c52abeb1e7 100644
--- a/arch/arm/dts/stm32mp157a-dk1-u-boot.dtsi
+++ b/arch/arm/dts/stm32mp157a-dk1-u-boot.dtsi
@@ -27,10 +27,6 @@ 
 			default-state = "off";
 			status = "okay";
 		};
-
-		blue {
-			default-state = "on";
-		};
 	};
 };
 
diff --git a/arch/arm/dts/stm32mp157c-ed1-u-boot.dtsi b/arch/arm/dts/stm32mp157c-ed1-u-boot.dtsi
index ed2f024be9..84af7fa47b 100644
--- a/arch/arm/dts/stm32mp157c-ed1-u-boot.dtsi
+++ b/arch/arm/dts/stm32mp157c-ed1-u-boot.dtsi
@@ -28,10 +28,6 @@ 
 			default-state = "off";
 			status = "okay";
 		};
-
-		blue {
-			default-state = "on";
-		};
 	};
 };
 
diff --git a/board/st/stm32mp1/stm32mp1.c b/board/st/stm32mp1/stm32mp1.c
index d85a57cee2..6a3e2e64bf 100644
--- a/board/st/stm32mp1/stm32mp1.c
+++ b/board/st/stm32mp1/stm32mp1.c
@@ -260,7 +260,6 @@  int g_dnl_bind_fixup(struct usb_device_descriptor *dev, const char *name)
 
 #endif /* CONFIG_USB_GADGET */
 
-#ifdef CONFIG_LED
 static int get_led(struct udevice **dev, char *led_string)
 {
 	char *led_name;
@@ -286,6 +285,9 @@  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;
@@ -293,32 +295,29 @@  static int setup_led(enum led_state_t cmd)
 	ret = led_set_state(dev, cmd);
 	return ret;
 }
-#endif
 
 static void __maybe_unused led_error_blink(u32 nb_blink)
 {
-#ifdef CONFIG_LED
 	int ret;
 	struct udevice *led;
 	u32 i;
-#endif
 
 	if (!nb_blink)
 		return;
 
-#ifdef CONFIG_LED
-	ret = get_led(&led, "u-boot,error-led");
-	if (!ret) {
-		/* make u-boot,error-led blinking */
-		/* if U32_MAX and 125ms interval, for 17.02 years */
-		for (i = 0; i < 2 * nb_blink; i++) {
-			led_set_state(led, LEDST_TOGGLE);
-			mdelay(125);
-			WATCHDOG_RESET();
+	if (CONFIG_IS_ENABLED(LED)) {
+		ret = get_led(&led, "u-boot,error-led");
+		if (!ret) {
+			/* make u-boot,error-led blinking */
+			/* if U32_MAX and 125ms interval, for 17.02 years */
+			for (i = 0; i < 2 * nb_blink; i++) {
+				led_set_state(led, LEDST_TOGGLE);
+				mdelay(125);
+				WATCHDOG_RESET();
+			}
+			led_set_state(led, LEDST_ON);
 		}
-		led_set_state(led, LEDST_ON);
 	}
-#endif
 
 	/* infinite: the boot process must be stopped */
 	if (nb_blink == U32_MAX)
@@ -651,6 +650,8 @@  int board_init(void)
 	if (CONFIG_IS_ENABLED(LED))
 		led_default_state();
 
+	setup_led(LEDST_ON);
+
 	return 0;
 }
 
@@ -705,9 +706,7 @@  int board_late_init(void)
 
 void board_quiesce_devices(void)
 {
-#ifdef CONFIG_LED
 	setup_led(LEDST_OFF);
-#endif
 }
 
 /* eth init function : weak called in eqos driver */