Skip to contentSkip to conversation

arm: am33xx: Fix early debug UART initialization

PATCH In review Felix Brack 3 participants 7 messages Feb 14, 2022 – Feb 24, 2022

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

PATCH 1/1 arm: am33xx: Fix early debug UART initialization

The changes from commit 0dba45864b2a ("arm: Init the debug UART") prevent the early debug UART from being initialized correctly. By adding a new SoC specific early UART initialization function this patch provides a generic location to add the required code. This code has to be SoC and not board specific.
For the am33xx SoCs the fix consist of configuring early clocks.

---

 arch/arm/mach-omap2/am33xx/board.c |  7 +++++++
 drivers/serial/Kconfig             | 13 +++++++++++++
 include/debug_uart.h               | 15 +++++++++++++++
 3 files changed, 35 insertions(+)
arch/arm/mach-omap2/am33xx/board.c +7 -0
index c44667668e..a7f0445b93 100644
@@ -604,3 +604,10 @@ int arch_cpu_init_dm(void)
 #endif
 	return 0;
 }
+
+#if IS_ENABLED(CONFIG_DEBUG_UART_SOC_INIT)
+void soc_debug_uart_init(void)
+{
+	setup_early_clocks();
+}
+#endif
drivers/serial/Kconfig +13 -0
index 345d1881f5..3da4064d35 100644
@@ -490,6 +490,19 @@ config DEBUG_UART_SHIFT
 	  value. Use this value to specify the shift to use, where 0=byte
 	  registers, 2=32-bit word registers, etc.
 
+config DEBUG_UART_SOC_INIT
+	bool "Enable SoC-specific debug UART init"
+	depends on DEBUG_UART
+	help
+	  Boards using the same SoC might require some common settings before
+	  the debug UART can be used. The board specific board_debug_uart_init()
+	  is not the right place for such common settings as they would apply
+	  to a specific board only instead of all boards using the same SoC.
+	  When this option is enabled, the SoC specific function
+	  soc_debug_uart_init() will be called when debug_uart_init() is called.
+	  You can put any code here that is needed to set up the UART ready for
+	  use.
+
 config DEBUG_UART_BOARD_INIT
 	bool "Enable board-specific debug UART init"
 	depends on DEBUG_UART
include/debug_uart.h +15 -0
index 714b369e6f..ebc84c44cd 100644
@@ -42,6 +42,12 @@
  * - Immediately afterwards, add DEBUG_UART_FUNCS to define the rest of the
  *     functionality (printch(), etc.)
  *
+ * If your SoC needs additional init for the UART to work, enable
+ * CONFIG_DEBUG_UART_SOC_INIT and write a function called
+ * soc_debug_uart_init() to perform that init. When debug_uart_init() is
+ * called, the init will happen automatically. Board specific code does not
+ * go here, see board_debug_uart_init() below.
+ *
  * If your board needs additional init for the UART to work, enable
  * CONFIG_DEBUG_UART_BOARD_INIT and write a function called
  * board_debug_uart_init() to perform that init. When debug_uart_init() is
@@ -61,6 +67,14 @@
  */
 void debug_uart_init(void);
 
+#ifdef CONFIG_DEBUG_UART_SOC_INIT
+void soc_debug_uart_init(void);
+#else
+static inline void soc_debug_uart_init(void)
+{
+}
+#endif
+
 #ifdef CONFIG_DEBUG_UART_BOARD_INIT
 void board_debug_uart_init(void);
 #else
@@ -192,6 +206,7 @@ void printdec(unsigned int value);
 \
 	void debug_uart_init(void) \
 	{ \
+		soc_debug_uart_init(); \
 		board_debug_uart_init(); \
 		_debug_uart_init(); \
 		_DEBUG_UART_ANNOUNCE \
Signature · 1 line
2.25.1
#1 lore raw
Quoted 87 lines · Felix Brack

The changes from commit 0dba45864b2a ("arm: Init the debug UART") prevent the early debug UART from being initialized correctly. By adding a new SoC specific early UART initialization function this patch provides a generic location to add the required code. This code has to be SoC and not board specific.
For the am33xx SoCs the fix consist of configuring early clocks.

---

 arch/arm/mach-omap2/am33xx/board.c |  7 +++++++
 drivers/serial/Kconfig             | 13 +++++++++++++
 include/debug_uart.h               | 15 +++++++++++++++
 3 files changed, 35 insertions(+)
arch/arm/mach-omap2/am33xx/board.c +7 -0
index c44667668e..a7f0445b93 100644
@@ -604,3 +604,10 @@ int arch_cpu_init_dm(void)
 #endif
 	return 0;
 }
+
+#if IS_ENABLED(CONFIG_DEBUG_UART_SOC_INIT)
+void soc_debug_uart_init(void)
+{
+	setup_early_clocks();
+}
+#endif
drivers/serial/Kconfig +13 -0
index 345d1881f5..3da4064d35 100644
@@ -490,6 +490,19 @@ config DEBUG_UART_SHIFT
 	  value. Use this value to specify the shift to use, where 0=byte
 	  registers, 2=32-bit word registers, etc.
 
+config DEBUG_UART_SOC_INIT
+	bool "Enable SoC-specific debug UART init"
+	depends on DEBUG_UART
+	help
+	  Boards using the same SoC might require some common settings before
+	  the debug UART can be used. The board specific board_debug_uart_init()
+	  is not the right place for such common settings as they would apply
+	  to a specific board only instead of all boards using the same SoC.
+	  When this option is enabled, the SoC specific function
+	  soc_debug_uart_init() will be called when debug_uart_init() is called.
+	  You can put any code here that is needed to set up the UART ready for
+	  use.
+
 config DEBUG_UART_BOARD_INIT
 	bool "Enable board-specific debug UART init"
 	depends on DEBUG_UART
include/debug_uart.h +14 -0
index 714b369e6f..ebc84c44cd 100644
@@ -42,6 +42,12 @@
  * - Immediately afterwards, add DEBUG_UART_FUNCS to define the rest of the
  *     functionality (printch(), etc.)
  *
+ * If your SoC needs additional init for the UART to work, enable
+ * CONFIG_DEBUG_UART_SOC_INIT and write a function called
+ * soc_debug_uart_init() to perform that init. When debug_uart_init() is
+ * called, the init will happen automatically. Board specific code does not
+ * go here, see board_debug_uart_init() below.
+ *
  * If your board needs additional init for the UART to work, enable
  * CONFIG_DEBUG_UART_BOARD_INIT and write a function called
  * board_debug_uart_init() to perform that init. When debug_uart_init() is
@@ -61,6 +67,14 @@
  */
 void debug_uart_init(void);
 
+#ifdef CONFIG_DEBUG_UART_SOC_INIT
+void soc_debug_uart_init(void);
+#else
+static inline void soc_debug_uart_init(void)
+{
+}
+#endif
+
 #ifdef CONFIG_DEBUG_UART_BOARD_INIT
 void board_debug_uart_init(void);
 #else

include/debug_uart.h void printdec(unsigned int value); · line 212

Quoted 7 lines
include/debug_uart.h +1 -0
@@ -192,6 +206,7 @@ void printdec(unsigned int value);
 \
 	void debug_uart_init(void) \
 	{ \
+		soc_debug_uart_init(); \
 		board_debug_uart_init(); \
 		_debug_uart_init(); \
 		_DEBUG_UART_ANNOUNCE \

I'd be inclined to just re-use board_debug_uart_init on am33xx like other "board" function we have in the SoC level board.c file. That's likely what other platforms are doing as well where this is more SoC than board dependent? Thanks for digging in here BTW, I think I never saw this myself when I needed the UART because I have mine set for UART boot first (and then it does SD boot).

Signature · 1 line
Tom
#2 lore raw

Hello Tom,

Quoted 94 lines · Tom Rini
Quoted 93 lines · Felix Brack

The changes from commit 0dba45864b2a ("arm: Init the debug UART") prevent the early debug UART from being initialized correctly. By adding a new SoC specific early UART initialization function this patch provides a generic location to add the required code. This code has to be SoC and not board specific.
For the am33xx SoCs the fix consist of configuring early clocks.

---

 arch/arm/mach-omap2/am33xx/board.c |  7 +++++++
 drivers/serial/Kconfig             | 13 +++++++++++++
 include/debug_uart.h               | 15 +++++++++++++++
 3 files changed, 35 insertions(+)
arch/arm/mach-omap2/am33xx/board.c +7 -0
index c44667668e..a7f0445b93 100644
@@ -604,3 +604,10 @@ int arch_cpu_init_dm(void)
 #endif
 	return 0;
 }
+
+#if IS_ENABLED(CONFIG_DEBUG_UART_SOC_INIT)
+void soc_debug_uart_init(void)
+{
+	setup_early_clocks();
+}
+#endif
drivers/serial/Kconfig +13 -0
index 345d1881f5..3da4064d35 100644
@@ -490,6 +490,19 @@ config DEBUG_UART_SHIFT
 	  value. Use this value to specify the shift to use, where 0=byte
 	  registers, 2=32-bit word registers, etc.
 
+config DEBUG_UART_SOC_INIT
+	bool "Enable SoC-specific debug UART init"
+	depends on DEBUG_UART
+	help
+	  Boards using the same SoC might require some common settings before
+	  the debug UART can be used. The board specific board_debug_uart_init()
+	  is not the right place for such common settings as they would apply
+	  to a specific board only instead of all boards using the same SoC.
+	  When this option is enabled, the SoC specific function
+	  soc_debug_uart_init() will be called when debug_uart_init() is called.
+	  You can put any code here that is needed to set up the UART ready for
+	  use.
+
 config DEBUG_UART_BOARD_INIT
 	bool "Enable board-specific debug UART init"
 	depends on DEBUG_UART
include/debug_uart.h +15 -0
index 714b369e6f..ebc84c44cd 100644
@@ -42,6 +42,12 @@
  * - Immediately afterwards, add DEBUG_UART_FUNCS to define the rest of the
  *     functionality (printch(), etc.)
  *
+ * If your SoC needs additional init for the UART to work, enable
+ * CONFIG_DEBUG_UART_SOC_INIT and write a function called
+ * soc_debug_uart_init() to perform that init. When debug_uart_init() is
+ * called, the init will happen automatically. Board specific code does not
+ * go here, see board_debug_uart_init() below.
+ *
  * If your board needs additional init for the UART to work, enable
  * CONFIG_DEBUG_UART_BOARD_INIT and write a function called
  * board_debug_uart_init() to perform that init. When debug_uart_init() is
@@ -61,6 +67,14 @@
  */
 void debug_uart_init(void);
 
+#ifdef CONFIG_DEBUG_UART_SOC_INIT
+void soc_debug_uart_init(void);
+#else
+static inline void soc_debug_uart_init(void)
+{
+}
+#endif
+
 #ifdef CONFIG_DEBUG_UART_BOARD_INIT
 void board_debug_uart_init(void);
 #else
@@ -192,6 +206,7 @@ void printdec(unsigned int value);
 \
 	void debug_uart_init(void) \
 	{ \
+		soc_debug_uart_init(); \
 		board_debug_uart_init(); \
 		_debug_uart_init(); \
Quoted 9 lines

include/debug_uart.h void printdec(unsigned int value); · line 212

Quoted 1 line
include/debug_uart.h +0 -0
 		_DEBUG_UART_ANNOUNCE \

I'd be inclined to just re-use board_debug_uart_init on am33xx like other "board" function we have in the SoC level board.c file. That's likely what other platforms are doing as well where this is more SoC than board dependent? Thanks for digging in here BTW, I think I never saw this myself when I needed the UART because I have mine set for UART boot first (and then it does SD boot).

On the PDU001 board the board specific board_debug_uart_init() is (for now) responsible for the pin configuration of UART3 (the debug UART). From a discussion with Simon I concluded that other boards based on the AM33XX SoCs are also affected from the problem introduced with commit 0dba45864b2a.
The function board_debug_uart_init() can not be moved to the SoC level since some boards (like the PDU001) require it. Hence the idea of a SoC specific soc_debug_uart_init() function.
However I now realize that such a "one fits it all" solution is probably not the right way to fix things. It might be better to fix this on board level especially since there are some boards that are not affected at all. Hence I think it is best to drop my patch. I will send a new patch fixing the problem for the PDU001 board specifically.

Signature · 1 line
Regards, Felix
#3 lore raw
Quoted 106 lines · Felix Brack

Hello Tom,

Quoted 94 lines · Tom Rini
Quoted 93 lines · Felix Brack

The changes from commit 0dba45864b2a ("arm: Init the debug UART") prevent the early debug UART from being initialized correctly. By adding a new SoC specific early UART initialization function this patch provides a generic location to add the required code. This code has to be SoC and not board specific.
For the am33xx SoCs the fix consist of configuring early clocks.

---

 arch/arm/mach-omap2/am33xx/board.c |  7 +++++++
 drivers/serial/Kconfig             | 13 +++++++++++++
 include/debug_uart.h               | 15 +++++++++++++++
 3 files changed, 35 insertions(+)
arch/arm/mach-omap2/am33xx/board.c +7 -0
index c44667668e..a7f0445b93 100644
@@ -604,3 +604,10 @@ int arch_cpu_init_dm(void)
 #endif
 	return 0;
 }
+
+#if IS_ENABLED(CONFIG_DEBUG_UART_SOC_INIT)
+void soc_debug_uart_init(void)
+{
+	setup_early_clocks();
+}
+#endif
drivers/serial/Kconfig +13 -0
index 345d1881f5..3da4064d35 100644
@@ -490,6 +490,19 @@ config DEBUG_UART_SHIFT
 	  value. Use this value to specify the shift to use, where 0=byte
 	  registers, 2=32-bit word registers, etc.
 
+config DEBUG_UART_SOC_INIT
+	bool "Enable SoC-specific debug UART init"
+	depends on DEBUG_UART
+	help
+	  Boards using the same SoC might require some common settings before
+	  the debug UART can be used. The board specific board_debug_uart_init()
+	  is not the right place for such common settings as they would apply
+	  to a specific board only instead of all boards using the same SoC.
+	  When this option is enabled, the SoC specific function
+	  soc_debug_uart_init() will be called when debug_uart_init() is called.
+	  You can put any code here that is needed to set up the UART ready for
+	  use.
+
 config DEBUG_UART_BOARD_INIT
 	bool "Enable board-specific debug UART init"
 	depends on DEBUG_UART
include/debug_uart.h +15 -0
index 714b369e6f..ebc84c44cd 100644
@@ -42,6 +42,12 @@
  * - Immediately afterwards, add DEBUG_UART_FUNCS to define the rest of the
  *     functionality (printch(), etc.)
  *
+ * If your SoC needs additional init for the UART to work, enable
+ * CONFIG_DEBUG_UART_SOC_INIT and write a function called
+ * soc_debug_uart_init() to perform that init. When debug_uart_init() is
+ * called, the init will happen automatically. Board specific code does not
+ * go here, see board_debug_uart_init() below.
+ *
  * If your board needs additional init for the UART to work, enable
  * CONFIG_DEBUG_UART_BOARD_INIT and write a function called
  * board_debug_uart_init() to perform that init. When debug_uart_init() is
@@ -61,6 +67,14 @@
  */
 void debug_uart_init(void);
 
+#ifdef CONFIG_DEBUG_UART_SOC_INIT
+void soc_debug_uart_init(void);
+#else
+static inline void soc_debug_uart_init(void)
+{
+}
+#endif
+
 #ifdef CONFIG_DEBUG_UART_BOARD_INIT
 void board_debug_uart_init(void);
 #else
@@ -192,6 +206,7 @@ void printdec(unsigned int value);
 \
 	void debug_uart_init(void) \
 	{ \
+		soc_debug_uart_init(); \
 		board_debug_uart_init(); \
 		_debug_uart_init(); \
Quoted 9 lines

include/debug_uart.h void printdec(unsigned int value); · line 212

Quoted 1 line
include/debug_uart.h +0 -0
 		_DEBUG_UART_ANNOUNCE \

I'd be inclined to just re-use board_debug_uart_init on am33xx like other "board" function we have in the SoC level board.c file. That's likely what other platforms are doing as well where this is more SoC than board dependent? Thanks for digging in here BTW, I think I never saw this myself when I needed the UART because I have mine set for UART boot first (and then it does SD boot).

Quoted 13 lines

On the PDU001 board the board specific board_debug_uart_init() is (for now) responsible for the pin configuration of UART3 (the debug UART). From a discussion with Simon I concluded that other boards based on the AM33XX SoCs are also affected from the problem introduced with commit 0dba45864b2a.
The function board_debug_uart_init() can not be moved to the SoC level since some boards (like the PDU001) require it. Hence the idea of a SoC specific soc_debug_uart_init() function.
However I now realize that such a "one fits it all" solution is probably not the right way to fix things. It might be better to fix this on board level especially since there are some boards that are not affected at all. Hence I think it is best to drop my patch. I will send a new patch fixing the problem for the PDU001 board specifically.

Ah, OK, thanks.

Signature · 1 line
Tom
Reviewed-by on v1 1/1
#4 lore raw
In reply to Felix Brack

Hi Felix,

Quoted 4 lines · Felix Brack

The changes from commit 0dba45864b2a ("arm: Init the debug UART") prevent the early debug UART from being initialized correctly. By adding a new SoC specific early UART initialization function this

SoC-specific

You need the hyphen for this to make sense, since you are creating an adjective.

Quoted 2 lines

patch provides a generic location to add the required code. This code has to be SoC and not board specific.

board-specific

Quoted 9 lines

For the am33xx SoCs the fix consist of configuring early clocks.

---

 arch/arm/mach-omap2/am33xx/board.c |  7 +++++++
 drivers/serial/Kconfig             | 13 +++++++++++++
 include/debug_uart.h               | 15 +++++++++++++++
 3 files changed, 35 insertions(+)

More nits below.

Quoted 26 lines
arch/arm/mach-omap2/am33xx/board.c +7 -0
index c44667668e..a7f0445b93 100644
@@ -604,3 +604,10 @@ int arch_cpu_init_dm(void)
 #endif
        return 0;
 }
+
+#if IS_ENABLED(CONFIG_DEBUG_UART_SOC_INIT)
+void soc_debug_uart_init(void)
+{
+       setup_early_clocks();
+}
+#endif
drivers/serial/Kconfig +2 -0
index 345d1881f5..3da4064d35 100644
@@ -490,6 +490,19 @@ config DEBUG_UART_SHIFT
          value. Use this value to specify the shift to use, where 0=byte
          registers, 2=32-bit word registers, etc.
 
+config DEBUG_UART_SOC_INIT
+       bool "Enable SoC-specific debug UART init"

drivers/serial/Kconfig config DEBUG_UART_SHIFT · line 504

Quoted 10 lines
drivers/serial/Kconfig +10 -0
+       depends on DEBUG_UART
+       help
+         Boards using the same SoC might require some common settings before
+         the debug UART can be used. The board specific board_debug_uart_init()
+         is not the right place for such common settings as they would apply
+         to a specific board only instead of all boards using the same SoC.
+         When this option is enabled, the SoC specific function
+         soc_debug_uart_init() will be called when debug_uart_init() is called.
+         You can put any code here that is needed to set up the UART ready for
+         use.

Please mention the order in which the board and SoC functions are called.

Quoted 9 lines
drivers/serial/Kconfig +1 -0
+
 config DEBUG_UART_BOARD_INIT
        bool "Enable board-specific debug UART init"
        depends on DEBUG_UART
include/debug_uart.h +0 -0
index 714b369e6f..ebc84c44cd 100644

include/debug_uart.h line 49

Quoted 8 lines
include/debug_uart.h +5 -0
@@ -42,6 +42,12 @@
  * - Immediately afterwards, add DEBUG_UART_FUNCS to define the rest of the
  *     functionality (printch(), etc.)
  *
+ * If your SoC needs additional init for the UART to work, enable
+ * CONFIG_DEBUG_UART_SOC_INIT and write a function called
+ * soc_debug_uart_init() to perform that init. When debug_uart_init() is
+ * called, the init will happen automatically. Board specific code does not
+ * go here, see board_debug_uart_init() below.

Again please fix your specifics.

Quoted 30 lines
include/debug_uart.h +10 -1
+ *
  * If your board needs additional init for the UART to work, enable
  * CONFIG_DEBUG_UART_BOARD_INIT and write a function called
  * board_debug_uart_init() to perform that init. When debug_uart_init() is
@@ -61,6 +67,14 @@
  */
 void debug_uart_init(void);
 
+#ifdef CONFIG_DEBUG_UART_SOC_INIT
+void soc_debug_uart_init(void);
+#else
+static inline void soc_debug_uart_init(void)
+{
+}
+#endif
+
 #ifdef CONFIG_DEBUG_UART_BOARD_INIT
 void board_debug_uart_init(void);
 #else
@@ -192,6 +206,7 @@ void printdec(unsigned int value);
 \
        void debug_uart_init(void) \
        { \
+               soc_debug_uart_init(); \
                board_debug_uart_init(); \
                _debug_uart_init(); \
                _DEBUG_UART_ANNOUNCE \
--

2.25.1

#5 lore raw

Hello Simon,

Quoted 113 lines · Simon Glass

Hi Felix,

Quoted 4 lines · Felix Brack

The changes from commit 0dba45864b2a ("arm: Init the debug UART") prevent the early debug UART from being initialized correctly. By adding a new SoC specific early UART initialization function this

SoC-specific

You need the hyphen for this to make sense, since you are creating an adjective.

Quoted 2 lines

patch provides a generic location to add the required code. This code has to be SoC and not board specific.

board-specific

Quoted 9 lines

For the am33xx SoCs the fix consist of configuring early clocks.

---

 arch/arm/mach-omap2/am33xx/board.c |  7 +++++++
 drivers/serial/Kconfig             | 13 +++++++++++++
 include/debug_uart.h               | 15 +++++++++++++++
 3 files changed, 35 insertions(+)

More nits below.

Quoted 26 lines
arch/arm/mach-omap2/am33xx/board.c +7 -0
index c44667668e..a7f0445b93 100644
@@ -604,3 +604,10 @@ int arch_cpu_init_dm(void)
 #endif
        return 0;
 }
+
+#if IS_ENABLED(CONFIG_DEBUG_UART_SOC_INIT)
+void soc_debug_uart_init(void)
+{
+       setup_early_clocks();
+}
+#endif
drivers/serial/Kconfig +2 -0
index 345d1881f5..3da4064d35 100644
@@ -490,6 +490,19 @@ config DEBUG_UART_SHIFT
          value. Use this value to specify the shift to use, where 0=byte
          registers, 2=32-bit word registers, etc.
 
+config DEBUG_UART_SOC_INIT
+       bool "Enable SoC-specific debug UART init"

drivers/serial/Kconfig config DEBUG_UART_SHIFT · line 504

Quoted 10 lines
drivers/serial/Kconfig +10 -0
+       depends on DEBUG_UART
+       help
+         Boards using the same SoC might require some common settings before
+         the debug UART can be used. The board specific board_debug_uart_init()
+         is not the right place for such common settings as they would apply
+         to a specific board only instead of all boards using the same SoC.
+         When this option is enabled, the SoC specific function
+         soc_debug_uart_init() will be called when debug_uart_init() is called.
+         You can put any code here that is needed to set up the UART ready for
+         use.

Please mention the order in which the board and SoC functions are called.

Quoted 9 lines
drivers/serial/Kconfig +1 -0
+
 config DEBUG_UART_BOARD_INIT
        bool "Enable board-specific debug UART init"
        depends on DEBUG_UART
include/debug_uart.h +0 -0
index 714b369e6f..ebc84c44cd 100644

include/debug_uart.h line 49

Quoted 8 lines
include/debug_uart.h +5 -0
@@ -42,6 +42,12 @@
  * - Immediately afterwards, add DEBUG_UART_FUNCS to define the rest of the
  *     functionality (printch(), etc.)
  *
+ * If your SoC needs additional init for the UART to work, enable
+ * CONFIG_DEBUG_UART_SOC_INIT and write a function called
+ * soc_debug_uart_init() to perform that init. When debug_uart_init() is
+ * called, the init will happen automatically. Board specific code does not
+ * go here, see board_debug_uart_init() below.

Again please fix your specifics.

Quoted 22 lines
include/debug_uart.h +9 -0
+ *
  * If your board needs additional init for the UART to work, enable
  * CONFIG_DEBUG_UART_BOARD_INIT and write a function called
  * board_debug_uart_init() to perform that init. When debug_uart_init() is
@@ -61,6 +67,14 @@
  */
 void debug_uart_init(void);
 
+#ifdef CONFIG_DEBUG_UART_SOC_INIT
+void soc_debug_uart_init(void);
+#else
+static inline void soc_debug_uart_init(void)
+{
+}
+#endif
+
 #ifdef CONFIG_DEBUG_UART_BOARD_INIT
 void board_debug_uart_init(void);
 #else
@@ -192,6 +206,7 @@ void printdec(unsigned int value);
 \
        void debug_uart_init(void) \
Quoted 8 lines
Quoted 8 lines
include/debug_uart.h +1 -1
        { \
+               soc_debug_uart_init(); \
                board_debug_uart_init(); \
                _debug_uart_init(); \
                _DEBUG_UART_ANNOUNCE \
--

2.25.1

Thanks for the review! However it looks like this patch will never get applied. If I'm wrong please let me know and I'll be happy to send a fixed version.

Signature · 1 line
Regards, Felix
#6 lore raw

Hi Felix,

Quoted 120 lines · Felix Brack

Hello Simon,

Quoted 116 lines · Simon Glass

Hi Felix,

Quoted 4 lines · Felix Brack

The changes from commit 0dba45864b2a ("arm: Init the debug UART") prevent the early debug UART from being initialized correctly. By adding a new SoC specific early UART initialization function this

SoC-specific

You need the hyphen for this to make sense, since you are creating an adjective.

Quoted 2 lines

patch provides a generic location to add the required code. This code has to be SoC and not board specific.

board-specific

Quoted 9 lines

For the am33xx SoCs the fix consist of configuring early clocks.

---

 arch/arm/mach-omap2/am33xx/board.c |  7 +++++++
 drivers/serial/Kconfig             | 13 +++++++++++++
 include/debug_uart.h               | 15 +++++++++++++++
 3 files changed, 35 insertions(+)

More nits below.

Quoted 26 lines
arch/arm/mach-omap2/am33xx/board.c +7 -0
index c44667668e..a7f0445b93 100644
@@ -604,3 +604,10 @@ int arch_cpu_init_dm(void)
 #endif
        return 0;
 }
+
+#if IS_ENABLED(CONFIG_DEBUG_UART_SOC_INIT)
+void soc_debug_uart_init(void)
+{
+       setup_early_clocks();
+}
+#endif
drivers/serial/Kconfig +2 -0
index 345d1881f5..3da4064d35 100644
@@ -490,6 +490,19 @@ config DEBUG_UART_SHIFT
          value. Use this value to specify the shift to use, where 0=byte
          registers, 2=32-bit word registers, etc.
 
+config DEBUG_UART_SOC_INIT
+       bool "Enable SoC-specific debug UART init"

drivers/serial/Kconfig config DEBUG_UART_SHIFT · line 504

Quoted 10 lines
drivers/serial/Kconfig +10 -0
+       depends on DEBUG_UART
+       help
+         Boards using the same SoC might require some common settings before
+         the debug UART can be used. The board specific board_debug_uart_init()
+         is not the right place for such common settings as they would apply
+         to a specific board only instead of all boards using the same SoC.
+         When this option is enabled, the SoC specific function
+         soc_debug_uart_init() will be called when debug_uart_init() is called.
+         You can put any code here that is needed to set up the UART ready for
+         use.

Please mention the order in which the board and SoC functions are called.

Quoted 9 lines
drivers/serial/Kconfig +1 -0
+
 config DEBUG_UART_BOARD_INIT
        bool "Enable board-specific debug UART init"
        depends on DEBUG_UART
include/debug_uart.h +0 -0
index 714b369e6f..ebc84c44cd 100644

include/debug_uart.h line 49

Quoted 8 lines
include/debug_uart.h +5 -0
@@ -42,6 +42,12 @@
  * - Immediately afterwards, add DEBUG_UART_FUNCS to define the rest of the
  *     functionality (printch(), etc.)
  *
+ * If your SoC needs additional init for the UART to work, enable
+ * CONFIG_DEBUG_UART_SOC_INIT and write a function called
+ * soc_debug_uart_init() to perform that init. When debug_uart_init() is
+ * called, the init will happen automatically. Board specific code does not
+ * go here, see board_debug_uart_init() below.

Again please fix your specifics.

Quoted 25 lines
include/debug_uart.h +10 -0
+ *
  * If your board needs additional init for the UART to work, enable
  * CONFIG_DEBUG_UART_BOARD_INIT and write a function called
  * board_debug_uart_init() to perform that init. When debug_uart_init() is
@@ -61,6 +67,14 @@
  */
 void debug_uart_init(void);
 
+#ifdef CONFIG_DEBUG_UART_SOC_INIT
+void soc_debug_uart_init(void);
+#else
+static inline void soc_debug_uart_init(void)
+{
+}
+#endif
+
 #ifdef CONFIG_DEBUG_UART_BOARD_INIT
 void board_debug_uart_init(void);
 #else
@@ -192,6 +206,7 @@ void printdec(unsigned int value);
 \
        void debug_uart_init(void) \
        { \
+               soc_debug_uart_init(); \
                board_debug_uart_init(); \
Quoted 8 lines
Quoted 5 lines
Quoted 5 lines
include/debug_uart.h +0 -1
                _debug_uart_init(); \
                _DEBUG_UART_ANNOUNCE \
--

2.25.1

Thanks for the review! However it looks like this patch will never get applied. If I'm wrong please let me know and I'll be happy to send a fixed version.

OK, I suppose it can wait until another board comes along that needs it.

Regards,
Simon