Skip to contentSkip to conversation

led: Configure LED default-state on boot

PATCH In review Marek Vasut 4 participants 13 messages Apr 3, 2022 – Apr 22, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 led: Configure LED default-state on boot

In case the DT LED subnode contains "default-state" property set to either "on" or "off", probe the LED driver and configure the LED state automatically.

Cc Alex Nemirovsky <[email protected]>
Cc Patrick Delaunay <[email protected]>
Cc Philippe Reynes <[email protected]>
Cc Sean Anderson <[email protected]>
Cc Simon Glass <[email protected]>
Cc Steven Lawrance <[email protected]>
---
 drivers/led/led-uclass.c | 57 ++++++++++++++++++++++------------------
 include/led.h            | 24 +++++++++--------
 2 files changed, 45 insertions(+), 36 deletions(-)
drivers/led/led-uclass.c +32 -25
index 2f4aa18fb10..5d7bf40896b 100644
@@ -66,43 +66,49 @@ int led_set_period(struct udevice *dev, int period_ms)
 }
 #endif
 
+/* This is superseded by led_post_bind()/led_post_probe() below. */
 int led_default_state(void)
 {
-	struct udevice *dev;
-	struct uclass *uc;
-	const char *default_state;
-	int ret;
-
-	ret = uclass_get(UCLASS_LED, &uc);
-	if (ret)
-		return ret;
-	for (uclass_find_first_device(UCLASS_LED, &dev);
-	     dev;
-	     uclass_find_next_device(&dev)) {
-		default_state = dev_read_string(dev, "default-state");
-		if (!default_state)
-			continue;
-		ret = device_probe(dev);
-		if (ret)
-			return ret;
-		if (!strncmp(default_state, "on", 2))
-			led_set_state(dev, LEDST_ON);
-		else if (!strncmp(default_state, "off", 3))
-			led_set_state(dev, LEDST_OFF);
-		/* default-state = "keep" : device is only probed */
-	}
-
-	return ret;
+	return 0;
 }
 
 static int led_post_bind(struct udevice *dev)
 {
 	struct led_uc_plat *uc_plat = dev_get_uclass_plat(dev);
+	const char *default_state;
 
 	uc_plat->label = dev_read_string(dev, "label");
 	if (!uc_plat->label)
 		uc_plat->label = ofnode_get_name(dev_ofnode(dev));
 
+	uc_plat->default_state = LEDST_COUNT;
+
+	default_state = dev_read_string(dev, "default-state");
+	if (!default_state)
+		return 0;
+
+	if (!strncmp(default_state, "on", 2))
+		uc_plat->default_state = LEDST_ON;
+	else if (!strncmp(default_state, "off", 3))
+		uc_plat->default_state = LEDST_OFF;
+	else
+		return 0;
+
+	/*
+	 * In case the LED has default-state DT property, trigger
+	 * probe() to configure its default state during startup.
+	 */
+	return device_probe(dev);
+}
+
+static int led_post_probe(struct udevice *dev)
+{
+	struct led_uc_plat *uc_plat = dev_get_uclass_plat(dev);
+
+	if (uc_plat->default_state == LEDST_ON ||
+	    uc_plat->default_state == LEDST_OFF)
+		led_set_state(dev, uc_plat->default_state);
+
 	return 0;
 }
 
@@ -111,4 +117,5 @@ UCLASS_DRIVER(led) = {
 	.name		= "led",
 	.per_device_plat_auto	= sizeof(struct led_uc_plat),
 	.post_bind	= led_post_bind,
+	.post_probe	= led_post_probe,
 };
include/led.h +13 -11
index 8eeb5a7c6d3..43acca85719 100644
@@ -9,13 +9,26 @@
 
 struct udevice;
 
+enum led_state_t {
+	LEDST_OFF = 0,
+	LEDST_ON = 1,
+	LEDST_TOGGLE,
+#ifdef CONFIG_LED_BLINK
+	LEDST_BLINK,
+#endif
+
+	LEDST_COUNT,
+};
+
 /**
  * struct led_uc_plat - Platform data the uclass stores about each device
  *
  * @label:	LED label
+ * @default_state:	LED default state
  */
 struct led_uc_plat {
 	const char *label;
+	enum led_state_t default_state;
 };
 
 /**
@@ -27,17 +40,6 @@ struct led_uc_priv {
 	int period_ms;
 };
 
-enum led_state_t {
-	LEDST_OFF = 0,
-	LEDST_ON = 1,
-	LEDST_TOGGLE,
-#ifdef CONFIG_LED_BLINK
-	LEDST_BLINK,
-#endif
-
-	LEDST_COUNT,
-};
-
 struct led_ops {
 	/**
 	 * set_state() - set the state of an LED
Signature · 1 line
2.35.1
#1 lore raw
Quoted 11 lines · Marek Vasut

In case the DT LED subnode contains "default-state" property set to either "on" or "off", probe the LED driver and configure the LED state automatically.

Cc Alex Nemirovsky <[email protected]>
Cc Patrick Delaunay <[email protected]>
Cc Philippe Reynes <[email protected]>
Cc Sean Anderson <[email protected]>
Cc Simon Glass <[email protected]>
Cc Steven Lawrance <[email protected]>

Applied to u-boot/master, thanks!

Signature · 1 line
Tom
#2 lore raw
In reply to Marek Vasut

Hi Marek

I tested the current U-Boot master branch (22bfaa1f673ab5442dfb9778eea4c9a18dee42d0) This patch is breaking the boot sequence on stm32mp157c-dk2.

Thanks
Patrice

Quoted 150 lines · Marek Vasut

In case the DT LED subnode contains "default-state" property set to either "on" or "off", probe the LED driver and configure the LED state automatically.

Cc Alex Nemirovsky <[email protected]>
Cc Patrick Delaunay <[email protected]>
Cc Philippe Reynes <[email protected]>
Cc Sean Anderson <[email protected]>
Cc Simon Glass <[email protected]>
Cc Steven Lawrance <[email protected]>
---
 drivers/led/led-uclass.c | 57 ++++++++++++++++++++++------------------
 include/led.h            | 24 +++++++++--------
 2 files changed, 45 insertions(+), 36 deletions(-)
drivers/led/led-uclass.c +32 -25
index 2f4aa18fb10..5d7bf40896b 100644
@@ -66,43 +66,49 @@ int led_set_period(struct udevice *dev, int period_ms)
 }
 #endif
 
+/* This is superseded by led_post_bind()/led_post_probe() below. */
 int led_default_state(void)
 {
-	struct udevice *dev;
-	struct uclass *uc;
-	const char *default_state;
-	int ret;
-
-	ret = uclass_get(UCLASS_LED, &uc);
-	if (ret)
-		return ret;
-	for (uclass_find_first_device(UCLASS_LED, &dev);
-	     dev;
-	     uclass_find_next_device(&dev)) {
-		default_state = dev_read_string(dev, "default-state");
-		if (!default_state)
-			continue;
-		ret = device_probe(dev);
-		if (ret)
-			return ret;
-		if (!strncmp(default_state, "on", 2))
-			led_set_state(dev, LEDST_ON);
-		else if (!strncmp(default_state, "off", 3))
-			led_set_state(dev, LEDST_OFF);
-		/* default-state = "keep" : device is only probed */
-	}
-
-	return ret;
+	return 0;
 }
 
 static int led_post_bind(struct udevice *dev)
 {
 	struct led_uc_plat *uc_plat = dev_get_uclass_plat(dev);
+	const char *default_state;
 
 	uc_plat->label = dev_read_string(dev, "label");
 	if (!uc_plat->label)
 		uc_plat->label = ofnode_get_name(dev_ofnode(dev));
 
+	uc_plat->default_state = LEDST_COUNT;
+
+	default_state = dev_read_string(dev, "default-state");
+	if (!default_state)
+		return 0;
+
+	if (!strncmp(default_state, "on", 2))
+		uc_plat->default_state = LEDST_ON;
+	else if (!strncmp(default_state, "off", 3))
+		uc_plat->default_state = LEDST_OFF;
+	else
+		return 0;
+
+	/*
+	 * In case the LED has default-state DT property, trigger
+	 * probe() to configure its default state during startup.
+	 */
+	return device_probe(dev);
+}
+
+static int led_post_probe(struct udevice *dev)
+{
+	struct led_uc_plat *uc_plat = dev_get_uclass_plat(dev);
+
+	if (uc_plat->default_state == LEDST_ON ||
+	    uc_plat->default_state == LEDST_OFF)
+		led_set_state(dev, uc_plat->default_state);
+
 	return 0;
 }
 
@@ -111,4 +117,5 @@ UCLASS_DRIVER(led) = {
 	.name		= "led",
 	.per_device_plat_auto	= sizeof(struct led_uc_plat),
 	.post_bind	= led_post_bind,
+	.post_probe	= led_post_probe,
 };
include/led.h +13 -11
index 8eeb5a7c6d3..43acca85719 100644
@@ -9,13 +9,26 @@
 
 struct udevice;
 
+enum led_state_t {
+	LEDST_OFF = 0,
+	LEDST_ON = 1,
+	LEDST_TOGGLE,
+#ifdef CONFIG_LED_BLINK
+	LEDST_BLINK,
+#endif
+
+	LEDST_COUNT,
+};
+
 /**
  * struct led_uc_plat - Platform data the uclass stores about each device
  *
  * @label:	LED label
+ * @default_state:	LED default state
  */
 struct led_uc_plat {
 	const char *label;
+	enum led_state_t default_state;
 };
 
 /**
@@ -27,17 +40,6 @@ struct led_uc_priv {
 	int period_ms;
 };
 
-enum led_state_t {
-	LEDST_OFF = 0,
-	LEDST_ON = 1,
-	LEDST_TOGGLE,
-#ifdef CONFIG_LED_BLINK
-	LEDST_BLINK,
-#endif
-
-	LEDST_COUNT,
-};
-
 struct led_ops {
 	/**
 	 * set_state() - set the state of an LED
#3 lore raw
Quoted 1 line · Patrice CHOTARD

Hi Marek

Hi,

Quoted 2 lines

I tested the current U-Boot master branch (22bfaa1f673ab5442dfb9778eea4c9a18dee42d0) This patch is breaking the boot sequence on stm32mp157c-dk2.

Breaking it ... how ? What happens, hang ?

#4 lore raw
Quoted 9 lines · Marek Vasut
Quoted 1 line · Patrice CHOTARD

Hi Marek

Hi,

Quoted 2 lines

I tested the current U-Boot master branch (22bfaa1f673ab5442dfb9778eea4c9a18dee42d0) This patch is breaking the boot sequence on stm32mp157c-dk2.

Breaking it ... how ? What happens, hang ?

Here is the boot log :

U-Boot SPL 2022.04-00827-g22bfaa1f67 (Apr 21 2022 - 17:22:47 +0200)
RAM: DDR3-DDR3L 16bits 533000kHz
WDT: Started watchdog@5a002000 with servicing (32s timeout)

U-Boot 2022.04-00827-g22bfaa1f67 (Apr 21 2022 - 17:22:47 +0200)

CPU: STM32MP157CAC Rev.B
Model: STMicroelectronics STM32MP157C-DK2 Discovery Board
Board: stm32mp1 in basic mode (st,stm32mp157c-dk2)
Board: MB1272 Var2.0 Rev.C-01
DRAM: 512 MiB
Clocks:
- MPU : 0 MHz
- MCU : 0 MHz
- AXI : 0 MHz
- PER : 0 MHz
- DDR : 0 MHz
clock rate is 0
clock rate is 0
clock rate is 0
clock rate is 0
clock rate is 0
cloc

What worried me is that all clocks are set to 0 (MPU/MCU/AXI ....)...no direct link with the led-uclass update. For information, if i comment the device_probe(dev) in led_post_bind(), it avoid the hang.

Thanks
Patrice

#5 lore raw
Quoted 40 lines · Patrice CHOTARD
Quoted 9 lines · Marek Vasut
Quoted 1 line · Patrice CHOTARD

Hi Marek

Hi,

Quoted 2 lines

I tested the current U-Boot master branch (22bfaa1f673ab5442dfb9778eea4c9a18dee42d0) This patch is breaking the boot sequence on stm32mp157c-dk2.

Breaking it ... how ? What happens, hang ?

Here is the boot log :

U-Boot SPL 2022.04-00827-g22bfaa1f67 (Apr 21 2022 - 17:22:47 +0200)
RAM: DDR3-DDR3L 16bits 533000kHz
WDT: Started watchdog@5a002000 with servicing (32s timeout)

U-Boot 2022.04-00827-g22bfaa1f67 (Apr 21 2022 - 17:22:47 +0200)

CPU: STM32MP157CAC Rev.B
Model: STMicroelectronics STM32MP157C-DK2 Discovery Board
Board: stm32mp1 in basic mode (st,stm32mp157c-dk2)
Board: MB1272 Var2.0 Rev.C-01
DRAM: 512 MiB
Clocks:
- MPU : 0 MHz
- MCU : 0 MHz
- AXI : 0 MHz
- PER : 0 MHz
- DDR : 0 MHz
clock rate is 0
clock rate is 0
clock rate is 0
clock rate is 0
clock rate is 0
cloc

Quoted 2 lines

What worried me is that all clocks are set to 0 (MPU/MCU/AXI ....)...no direct link with the led-uclass update. For information, if i comment the device_probe(dev) in led_post_bind(), it avoid the hang.

Can you try applying the LED patch on top of 2022.04?
I made some clock changes recently, so it could be an interaction with that.

--Sean

#6 lore raw

Hi Sean

Quoted 41 lines · Sean Anderson
Quoted 40 lines · Patrice CHOTARD
Quoted 9 lines · Marek Vasut
Quoted 1 line · Patrice CHOTARD

Hi Marek

Hi,

Quoted 2 lines

I tested the current U-Boot master branch (22bfaa1f673ab5442dfb9778eea4c9a18dee42d0) This patch is breaking the boot sequence on stm32mp157c-dk2.

Breaking it ... how ? What happens, hang ?

Here is the boot log :

U-Boot SPL 2022.04-00827-g22bfaa1f67 (Apr 21 2022 - 17:22:47 +0200)
RAM: DDR3-DDR3L 16bits 533000kHz
WDT:   Started watchdog@5a002000 with servicing (32s timeout)

U-Boot 2022.04-00827-g22bfaa1f67 (Apr 21 2022 - 17:22:47 +0200)

CPU: STM32MP157CAC Rev.B
Model: STMicroelectronics STM32MP157C-DK2 Discovery Board
Board: stm32mp1 in basic mode (st,stm32mp157c-dk2)
Board: MB1272 Var2.0 Rev.C-01
DRAM:  512 MiB
Clocks:
- MPU : 0 MHz
- MCU : 0 MHz
- AXI : 0 MHz
- PER : 0 MHz
- DDR : 0 MHz
clock rate is 0
clock rate is 0
clock rate is 0
clock rate is 0
clock rate is 0
cloc

Quoted 6 lines
Quoted 2 lines

What worried me is that all clocks are set to 0 (MPU/MCU/AXI ....)...no direct link with the led-uclass update. For information, if i comment the device_probe(dev) in led_post_bind(), it avoid the hang.

Can you try applying the LED patch on top of 2022.04?
I made some clock changes recently, so it could be an interaction with that.

Thanks for the tips, but unfortunately, i have the same issue when applying this patch on top of v2022.04. I am still investigating ..... ;-)

Patrice

Quoted 1 line

--Sean

#7 lore raw
Quoted 47 lines · Patrice CHOTARD

Hi Sean

Quoted 44 lines · Sean Anderson
Quoted 42 lines · Patrice CHOTARD
Quoted 9 lines · Marek Vasut
Quoted 1 line · Patrice CHOTARD

Hi Marek

Hi,

Quoted 2 lines

I tested the current U-Boot master branch (22bfaa1f673ab5442dfb9778eea4c9a18dee42d0) This patch is breaking the boot sequence on stm32mp157c-dk2.

Breaking it ... how ? What happens, hang ?

Here is the boot log :

U-Boot SPL 2022.04-00827-g22bfaa1f67 (Apr 21 2022 - 17:22:47 +0200)
RAM: DDR3-DDR3L 16bits 533000kHz
WDT:   Started watchdog@5a002000 with servicing (32s timeout)

U-Boot 2022.04-00827-g22bfaa1f67 (Apr 21 2022 - 17:22:47 +0200)

CPU: STM32MP157CAC Rev.B
Model: STMicroelectronics STM32MP157C-DK2 Discovery Board
Board: stm32mp1 in basic mode (st,stm32mp157c-dk2)
Board: MB1272 Var2.0 Rev.C-01
DRAM:  512 MiB
Clocks:
- MPU : 0 MHz
- MCU : 0 MHz
- AXI : 0 MHz
- PER : 0 MHz
- DDR : 0 MHz
clock rate is 0
clock rate is 0
clock rate is 0
clock rate is 0
clock rate is 0
cloc

What worried me is that all clocks are set to 0 (MPU/MCU/AXI ....)...no direct link with the led-uclass update. For information, if i comment the device_probe(dev) in led_post_bind(), it avoid the hang.

Quoted 6 lines
Quoted 3 lines

Can you try applying the LED patch on top of 2022.04?
I made some clock changes recently, so it could be an interaction with that.

Thanks for the tips, but unfortunately, i have the same issue when applying this patch on top of v2022.04. I am still investigating ..... ;-)

Maybe the clk_* in gpio_stm32 is the problem, is the gpio driver for mp1 probed by the time the led post_bind is called ? If not, maybe that's an issue.

I'll have a look too.

#8 lore raw
Quoted 52 lines · Marek Vasut
Quoted 51 lines · Patrice CHOTARD

Hi Sean

Quoted 47 lines · Sean Anderson
Quoted 40 lines · Patrice CHOTARD
Quoted 9 lines · Marek Vasut
Quoted 1 line · Patrice CHOTARD

Hi Marek

Hi,

Quoted 2 lines

I tested the current U-Boot master branch (22bfaa1f673ab5442dfb9778eea4c9a18dee42d0) This patch is breaking the boot sequence on stm32mp157c-dk2.

Breaking it ... how ? What happens, hang ?

Here is the boot log :

U-Boot SPL 2022.04-00827-g22bfaa1f67 (Apr 21 2022 - 17:22:47 +0200)
RAM: DDR3-DDR3L 16bits 533000kHz
WDT:   Started watchdog@5a002000 with servicing (32s timeout)

U-Boot 2022.04-00827-g22bfaa1f67 (Apr 21 2022 - 17:22:47 +0200)

CPU: STM32MP157CAC Rev.B
Model: STMicroelectronics STM32MP157C-DK2 Discovery Board
Board: stm32mp1 in basic mode (st,stm32mp157c-dk2)
Board: MB1272 Var2.0 Rev.C-01
DRAM:  512 MiB
Clocks:
- MPU : 0 MHz
- MCU : 0 MHz
- AXI : 0 MHz
- PER : 0 MHz
- DDR : 0 MHz
clock rate is 0
clock rate is 0
clock rate is 0
clock rate is 0
clock rate is 0
cloc

Quoted 2 lines

What worried me is that all clocks are set to 0 (MPU/MCU/AXI ....)...no direct link with the led-uclass update. For information, if i comment the device_probe(dev) in led_post_bind(), it avoid the hang.

Can you try applying the LED patch on top of 2022.04?
I made some clock changes recently, so it could be an interaction with that.

Quoted 6 lines
Quoted 2 lines

Thanks for the tips, but unfortunately, i have the same issue when applying this patch on top of v2022.04. I am still investigating ..... ;-)

Maybe the clk_* in gpio_stm32 is the problem, is the gpio driver for mp1 probed by the time the led post_bind is called ? If not, maybe that's an issue.

I'll have a look too.

Try this patch, does it "fix" it for you ?

arch/arm/dts/stm32mp151.dtsi +2 -2
index 5a2be007586..ec5cddfcf98 100644
@@ -70,7 +70,7 @@
                interrupt-parent = <&intc>;
        };
 
-       clocks {
+//     clocks {
                clk_hse: clk-hse {
                        #clock-cells = <0>;
                        compatible = "fixed-clock";
@@ -100,7 +100,7 @@
                        compatible = "fixed-clock";
                        clock-frequency = <4000000>;
                };
-       };
+//     };
 
        thermal-zones {
                cpu_thermal: cpu-thermal {

If so, we need to figure out why.

#9 lore raw

Hi Marek

Quoted 85 lines · Marek Vasut
Quoted 52 lines · Marek Vasut
Quoted 51 lines · Patrice CHOTARD

Hi Sean

Quoted 47 lines · Sean Anderson
Quoted 40 lines · Patrice CHOTARD
Quoted 9 lines · Marek Vasut
Quoted 1 line · Patrice CHOTARD

Hi Marek

Hi,

Quoted 2 lines

I tested the current U-Boot master branch (22bfaa1f673ab5442dfb9778eea4c9a18dee42d0) This patch is breaking the boot sequence on stm32mp157c-dk2.

Breaking it ... how ? What happens, hang ?

Here is the boot log :

U-Boot SPL 2022.04-00827-g22bfaa1f67 (Apr 21 2022 - 17:22:47 +0200)
RAM: DDR3-DDR3L 16bits 533000kHz
WDT:   Started watchdog@5a002000 with servicing (32s timeout)

U-Boot 2022.04-00827-g22bfaa1f67 (Apr 21 2022 - 17:22:47 +0200)

CPU: STM32MP157CAC Rev.B
Model: STMicroelectronics STM32MP157C-DK2 Discovery Board
Board: stm32mp1 in basic mode (st,stm32mp157c-dk2)
Board: MB1272 Var2.0 Rev.C-01
DRAM:  512 MiB
Clocks:
- MPU : 0 MHz
- MCU : 0 MHz
- AXI : 0 MHz
- PER : 0 MHz
- DDR : 0 MHz
clock rate is 0
clock rate is 0
clock rate is 0
clock rate is 0
clock rate is 0
cloc

Quoted 2 lines

What worried me is that all clocks are set to 0 (MPU/MCU/AXI ....)...no direct link with the led-uclass update. For information, if i comment the device_probe(dev) in led_post_bind(), it avoid the hang.

Can you try applying the LED patch on top of 2022.04?
I made some clock changes recently, so it could be an interaction with that.

Quoted 6 lines
Quoted 2 lines

Thanks for the tips, but unfortunately, i have the same issue when applying this patch on top of v2022.04. I am still investigating ..... ;-)

Maybe the clk_* in gpio_stm32 is the problem, is the gpio driver for mp1 probed by the time the led post_bind is called ? If not, maybe that's an issue.

I'll have a look too.

Try this patch, does it "fix" it for you ?

arch/arm/dts/stm32mp151.dtsi +2 -2
index 5a2be007586..ec5cddfcf98 100644
@@ -70,7 +70,7 @@
                 interrupt-parent = <&intc>;
         };
 
-       clocks {
+//     clocks {
                 clk_hse: clk-hse {
                         #clock-cells = <0>;
                         compatible = "fixed-clock";
@@ -100,7 +100,7 @@
                         compatible = "fixed-clock";
                         clock-frequency = <4000000>;
                 };
-       };
+//     };
 
         thermal-zones {
                 cpu_thermal: cpu-thermal {
Quoted 1 line

If so, we need to figure out why.

With this patch, the board is booting fine

The "led patch" is changing the order of probing of some early drivers (led, clock, gpio, pinctrl....) ..... to be continued ... ;-)

Thanks
Patrice

#10 lore raw
Quoted 85 lines · Patrice CHOTARD

Hi Marek

Quoted 82 lines · Marek Vasut
Quoted 52 lines · Marek Vasut
Quoted 51 lines · Patrice CHOTARD

Hi Sean

Quoted 47 lines · Sean Anderson
Quoted 40 lines · Patrice CHOTARD
Quoted 9 lines · Marek Vasut
Quoted 1 line · Patrice CHOTARD

Hi Marek

Hi,

Quoted 2 lines

I tested the current U-Boot master branch (22bfaa1f673ab5442dfb9778eea4c9a18dee42d0) This patch is breaking the boot sequence on stm32mp157c-dk2.

Breaking it ... how ? What happens, hang ?

Here is the boot log :

U-Boot SPL 2022.04-00827-g22bfaa1f67 (Apr 21 2022 - 17:22:47 +0200)
RAM: DDR3-DDR3L 16bits 533000kHz
WDT:   Started watchdog@5a002000 with servicing (32s timeout)

U-Boot 2022.04-00827-g22bfaa1f67 (Apr 21 2022 - 17:22:47 +0200)

CPU: STM32MP157CAC Rev.B
Model: STMicroelectronics STM32MP157C-DK2 Discovery Board
Board: stm32mp1 in basic mode (st,stm32mp157c-dk2)
Board: MB1272 Var2.0 Rev.C-01
DRAM:  512 MiB
Clocks:
- MPU : 0 MHz
- MCU : 0 MHz
- AXI : 0 MHz
- PER : 0 MHz
- DDR : 0 MHz
clock rate is 0
clock rate is 0
clock rate is 0
clock rate is 0
clock rate is 0
cloc

Quoted 2 lines

What worried me is that all clocks are set to 0 (MPU/MCU/AXI ....)...no direct link with the led-uclass update. For information, if i comment the device_probe(dev) in led_post_bind(), it avoid the hang.

Can you try applying the LED patch on top of 2022.04?
I made some clock changes recently, so it could be an interaction with that.

Quoted 6 lines
Quoted 2 lines

Thanks for the tips, but unfortunately, i have the same issue when applying this patch on top of v2022.04. I am still investigating ..... ;-)

Maybe the clk_* in gpio_stm32 is the problem, is the gpio driver for mp1 probed by the time the led post_bind is called ? If not, maybe that's an issue.

I'll have a look too.

Try this patch, does it "fix" it for you ?

arch/arm/dts/stm32mp151.dtsi +2 -2
index 5a2be007586..ec5cddfcf98 100644
@@ -70,7 +70,7 @@
                 interrupt-parent = <&intc>;
         };
 
-       clocks {
+//     clocks {
                 clk_hse: clk-hse {
                         #clock-cells = <0>;
                         compatible = "fixed-clock";
@@ -100,7 +100,7 @@
                         compatible = "fixed-clock";
                         clock-frequency = <4000000>;
                 };
-       };
+//     };
 
Quoted 8 lines
Quoted 4 lines
arch/arm/dts/stm32mp151.dtsi +0 -0
         thermal-zones {
                 cpu_thermal: cpu-thermal {

If so, we need to figure out why.

With this patch, the board is booting fine

The "led patch" is changing the order of probing of some early drivers (led, clock, gpio, pinctrl....) ..... to be continued ... ;-)

Larger change is coming, you are on CC.

#11 lore raw

Hi Marek

Quoted 89 lines · Marek Vasut
Quoted 88 lines · Patrice CHOTARD

Hi Marek

Quoted 85 lines · Marek Vasut
Quoted 52 lines · Marek Vasut
Quoted 51 lines · Patrice CHOTARD

Hi Sean

Quoted 47 lines · Sean Anderson
Quoted 40 lines · Patrice CHOTARD
Quoted 9 lines · Marek Vasut
Quoted 1 line · Patrice CHOTARD

Hi Marek

Hi,

Quoted 2 lines

I tested the current U-Boot master branch (22bfaa1f673ab5442dfb9778eea4c9a18dee42d0) This patch is breaking the boot sequence on stm32mp157c-dk2.

Breaking it ... how ? What happens, hang ?

Here is the boot log :

U-Boot SPL 2022.04-00827-g22bfaa1f67 (Apr 21 2022 - 17:22:47 +0200)
RAM: DDR3-DDR3L 16bits 533000kHz
WDT:   Started watchdog@5a002000 with servicing (32s timeout)

U-Boot 2022.04-00827-g22bfaa1f67 (Apr 21 2022 - 17:22:47 +0200)

CPU: STM32MP157CAC Rev.B
Model: STMicroelectronics STM32MP157C-DK2 Discovery Board
Board: stm32mp1 in basic mode (st,stm32mp157c-dk2)
Board: MB1272 Var2.0 Rev.C-01
DRAM:  512 MiB
Clocks:
- MPU : 0 MHz
- MCU : 0 MHz
- AXI : 0 MHz
- PER : 0 MHz
- DDR : 0 MHz
clock rate is 0
clock rate is 0
clock rate is 0
clock rate is 0
clock rate is 0
cloc

Quoted 2 lines

What worried me is that all clocks are set to 0 (MPU/MCU/AXI ....)...no direct link with the led-uclass update. For information, if i comment the device_probe(dev) in led_post_bind(), it avoid the hang.

Can you try applying the LED patch on top of 2022.04?
I made some clock changes recently, so it could be an interaction with that.

Quoted 6 lines
Quoted 2 lines

Thanks for the tips, but unfortunately, i have the same issue when applying this patch on top of v2022.04. I am still investigating ..... ;-)

Maybe the clk_* in gpio_stm32 is the problem, is the gpio driver for mp1 probed by the time the led post_bind is called ? If not, maybe that's an issue.

I'll have a look too.

Try this patch, does it "fix" it for you ?

arch/arm/dts/stm32mp151.dtsi +2 -2
index 5a2be007586..ec5cddfcf98 100644
@@ -70,7 +70,7 @@
                  interrupt-parent = <&intc>;
          };
 
-       clocks {
+//     clocks {
                  clk_hse: clk-hse {
                          #clock-cells = <0>;
                          compatible = "fixed-clock";
@@ -100,7 +100,7 @@
                          compatible = "fixed-clock";
                          clock-frequency = <4000000>;
                  };
-       };
+//     };
 
          thermal-zones {
                  cpu_thermal: cpu-thermal {
Quoted 7 lines
Quoted 5 lines
Quoted 1 line

If so, we need to figure out why.

With this patch, the board is booting fine

The "led patch" is changing the order of probing of some early drivers (led, clock, gpio, pinctrl....) ..... to be continued ... ;-)

Larger change is coming, you are on CC.

Thanks, it fixes the issue ;-)

#12 lore raw

On 4/22/22 15:46, Patrice CHOTARD wrote:

Hi,

[...]

Quoted 9 lines
Quoted 7 lines
Quoted 5 lines
Quoted 1 line

If so, we need to figure out why.

With this patch, the board is booting fine

The "led patch" is changing the order of probing of some early drivers (led, clock, gpio, pinctrl....) ..... to be continued ... ;-)

Larger change is coming, you are on CC.

Thanks, it fixes the issue ;-)

You're welcome.