diff mbox series

ARM: debug: stm32: add UART early console configuration

Message ID 1554883239-12051-1-git-send-email-erwan.leray@st.com (mailing list archive)
State New, archived
Headers show
Series ARM: debug: stm32: add UART early console configuration | expand

Commit Message

Erwan LE RAY April 10, 2019, 8 a.m. UTC
- This patch allows to configure UART instance for early console by setting
physical and virtual base addresses.
- This patch adds UART early console support for stm32h7 and stm32mp157c.

Signed-off-by: Erwan Le Ray <erwan.leray@st.com>

Comments

Clément Péron April 10, 2019, 10:19 a.m. UTC | #1
Hi,

On Wed, 10 Apr 2019 at 10:03, Erwan Le Ray <erwan.leray@st.com> wrote:
>
> - This patch allows to configure UART instance for early console by setting
> physical and virtual base addresses.
> - This patch adds UART early console support for stm32h7 and stm32mp157c.

*Newbie kernel speaking*

I think this patch introduce at least 2, I will go for 3 modifications:
-Adding H7 Debug
-Adding MP1 debug
-(Fixing dependencies F4/F7)

With my little knowledge, I will separate this patch in 3.
Also try to have a commit log like this :
1) Explain What's wrong or is not present
2) Explain what you do in the patch

here you don't explain a lot what the issues are.

My 2cts on your patch, again newbie user here and I have post only few
patches but this is my sharing.

Thanks,
Clement

>
> Signed-off-by: Erwan Le Ray <erwan.leray@st.com>
>
> diff --git a/arch/arm/Kconfig.debug b/arch/arm/Kconfig.debug
> index 6d6e033..4ea3e17 100644
> --- a/arch/arm/Kconfig.debug
> +++ b/arch/arm/Kconfig.debug
> @@ -1201,23 +1201,49 @@ choice
>
>         config STM32F4_DEBUG_UART
>                 bool "Use STM32F4 UART for low-level debug"
> -               depends on ARCH_STM32
> +               depends on MACH_STM32F429 || MACH_STM32F469
>                 select DEBUG_STM32_UART
>                 help
>                   Say Y here if you want kernel low-level debugging support
>                   on STM32F4 based platforms, which default UART is wired on
> -                 USART1.
> +                 USART1, but another UART instance can be selected by modifying
> +                 CONFIG_DEBUG_UART_PHYS.
>
>                   If unsure, say N.
>
>         config STM32F7_DEBUG_UART
>                 bool "Use STM32F7 UART for low-level debug"
> -               depends on ARCH_STM32
> +               depends on MACH_STM32F746 || MACH_STM32F769
>                 select DEBUG_STM32_UART
>                 help
>                   Say Y here if you want kernel low-level debugging support
>                   on STM32F7 based platforms, which default UART is wired on
> -                 USART1.
> +                 USART1, but another UART instance can be selected by modifying
> +                 CONFIG_DEBUG_UART_PHYS.
> +
> +                 If unsure, say N.
> +
> +       config STM32H7_DEBUG_UART
> +               bool "Use STM32H7 UART for low-level debug"
> +               depends on MACH_STM32H743
> +               select DEBUG_STM32_UART
> +               help
> +                 Say Y here if you want kernel low-level debugging support
> +                 on STM32H7 based platforms, which default UART is wired on
> +                 USART1, but another UART instance can be selected by modifying
> +                 CONFIG_DEBUG_UART_PHYS.
> +
> +                 If unsure, say N.
> +
> +       config STM32MP1_DEBUG_UART
> +               bool "Use STM32MP1 UART for low-level debug"
> +               depends on MACH_STM32MP157
> +               select DEBUG_STM32_UART
> +               help
> +                 Say Y here if you want kernel low-level debugging support
> +                 on STM32MP1 based platforms, wich default UART is wired on
> +                 UART4, but another UART instance can be selected by modifying
> +                 CONFIG_DEBUG_UART_PHYS and CONFIG_DEBUG_UART_VIRT.
>
>                   If unsure, say N.
>
> @@ -1622,6 +1648,9 @@ config DEBUG_UART_PHYS
>         default 0x3e000000 if DEBUG_BCM_KONA_UART
>         default 0x3f201000 if DEBUG_BCM2836
>         default 0x4000e400 if DEBUG_LL_UART_EFM32
> +       default 0x40010000 if STM32MP1_DEBUG_UART
> +       default 0x40011000 if STM32F4_DEBUG_UART || STM32F7_DEBUG_UART || \
> +                               STM32H7_DEBUG_UART
>         default 0x40028000 if DEBUG_AT91_SAMV7_USART1
>         default 0x40081000 if DEBUG_LPC18XX_UART0
>         default 0x40090000 if DEBUG_LPC32XX
> @@ -1716,7 +1745,7 @@ config DEBUG_UART_PHYS
>                 DEBUG_S3C64XX_UART || \
>                 DEBUG_BCM63XX_UART || DEBUG_ASM9260_UART || \
>                 DEBUG_SIRFSOC_UART || DEBUG_DIGICOLOR_UA0 || \
> -               DEBUG_AT91_UART
> +               DEBUG_AT91_UART || DEBUG_STM32_UART
>
>  config DEBUG_UART_VIRT
>         hex "Virtual base address of debug UART"
> @@ -1784,6 +1813,7 @@ config DEBUG_UART_VIRT
>         default 0xfd012000 if DEBUG_MVEBU_UART0_ALTERNATE && ARCH_MV78XX0
>         default 0xfd883000 if DEBUG_ALPINE_UART0
>         default 0xfde12000 if DEBUG_MVEBU_UART0_ALTERNATE && ARCH_DOVE
> +       default 0xfe010000 if STM32MP1_DEBUG_UART
>         default 0xfe012000 if DEBUG_MVEBU_UART0_ALTERNATE && ARCH_ORION5X
>         default 0xfe017000 if DEBUG_MMP_UART2
>         default 0xfe018000 if DEBUG_MMP_UART3
> @@ -1832,7 +1862,7 @@ config DEBUG_UART_VIRT
>                 DEBUG_S3C64XX_UART || \
>                 DEBUG_BCM63XX_UART || DEBUG_ASM9260_UART || \
>                 DEBUG_SIRFSOC_UART || DEBUG_DIGICOLOR_UA0 || \
> -               DEBUG_AT91_UART
> +               DEBUG_AT91_UART || DEBUG_STM32_UART
>
>  config DEBUG_UART_8250_SHIFT
>         int "Register offset shift for the 8250 debug UART"
> diff --git a/arch/arm/include/debug/stm32.S b/arch/arm/include/debug/stm32.S
> index 1abb32f..6446e46 100644
> --- a/arch/arm/include/debug/stm32.S
> +++ b/arch/arm/include/debug/stm32.S
> @@ -4,14 +4,13 @@
>   * Author:   Gerald Baeza <gerald.baeza@st.com> for STMicroelectronics.
>   */
>
> -#define STM32_UART_BASE                        0x40011000      /* USART1 */
> -
>  #ifdef CONFIG_STM32F4_DEBUG_UART
>  #define STM32_USART_SR_OFF             0x00
>  #define STM32_USART_TDR_OFF            0x04
>  #endif
>
> -#ifdef CONFIG_STM32F7_DEBUG_UART
> +#if defined(CONFIG_STM32F7_DEBUG_UART) || (CONFIG_STM32H7_DEBUG_UART) || \
> +       defined(CONFIG_STM32MP1_DEBUG_UART)
>  #define STM32_USART_SR_OFF             0x1C
>  #define STM32_USART_TDR_OFF            0x28
>  #endif
> @@ -20,8 +19,8 @@
>  #define STM32_USART_TXE                        (1 << 7)        /* Tx data reg empty */
>
>  .macro addruart, rp, rv, tmp
> -       ldr     \rp,      =STM32_UART_BASE      @ physical base
> -       ldr     \rv,      =STM32_UART_BASE      @ virt base /* NoMMU */
> +       ldr     \rp, =CONFIG_DEBUG_UART_PHYS @ physical base
> +       ldr     \rv, =CONFIG_DEBUG_UART_VIRT @ virt base
>  .endm
>
>  .macro  senduart,rd,rx
> --
> 1.9.1
>
Erwan LE RAY May 9, 2019, 7:41 a.m. UTC | #2
Hi Olof, Arnd and Kevin,

Can you please provide me your feedback about the patch, and about 
Clement changes proposal.

I would like to know if you expect a V2 (based on Clement comments), or 
if the V1 if OK for your.

Best regards, Erwan.


On 4/10/19 12:19 PM, Clément Péron wrote:
> Hi,
>
> On Wed, 10 Apr 2019 at 10:03, Erwan Le Ray <erwan.leray@st.com> wrote:
>> - This patch allows to configure UART instance for early console by setting
>> physical and virtual base addresses.
>> - This patch adds UART early console support for stm32h7 and stm32mp157c.
> *Newbie kernel speaking*
>
> I think this patch introduce at least 2, I will go for 3 modifications:
> -Adding H7 Debug
> -Adding MP1 debug
> -(Fixing dependencies F4/F7)
>
> With my little knowledge, I will separate this patch in 3.
> Also try to have a commit log like this :
> 1) Explain What's wrong or is not present
> 2) Explain what you do in the patch
>
> here you don't explain a lot what the issues are.
>
> My 2cts on your patch, again newbie user here and I have post only few
> patches but this is my sharing.
>
> Thanks,
> Clement
>
>> Signed-off-by: Erwan Le Ray <erwan.leray@st.com>
>>
>> diff --git a/arch/arm/Kconfig.debug b/arch/arm/Kconfig.debug
>> index 6d6e033..4ea3e17 100644
>> --- a/arch/arm/Kconfig.debug
>> +++ b/arch/arm/Kconfig.debug
>> @@ -1201,23 +1201,49 @@ choice
>>
>>          config STM32F4_DEBUG_UART
>>                  bool "Use STM32F4 UART for low-level debug"
>> -               depends on ARCH_STM32
>> +               depends on MACH_STM32F429 || MACH_STM32F469
>>                  select DEBUG_STM32_UART
>>                  help
>>                    Say Y here if you want kernel low-level debugging support
>>                    on STM32F4 based platforms, which default UART is wired on
>> -                 USART1.
>> +                 USART1, but another UART instance can be selected by modifying
>> +                 CONFIG_DEBUG_UART_PHYS.
>>
>>                    If unsure, say N.
>>
>>          config STM32F7_DEBUG_UART
>>                  bool "Use STM32F7 UART for low-level debug"
>> -               depends on ARCH_STM32
>> +               depends on MACH_STM32F746 || MACH_STM32F769
>>                  select DEBUG_STM32_UART
>>                  help
>>                    Say Y here if you want kernel low-level debugging support
>>                    on STM32F7 based platforms, which default UART is wired on
>> -                 USART1.
>> +                 USART1, but another UART instance can be selected by modifying
>> +                 CONFIG_DEBUG_UART_PHYS.
>> +
>> +                 If unsure, say N.
>> +
>> +       config STM32H7_DEBUG_UART
>> +               bool "Use STM32H7 UART for low-level debug"
>> +               depends on MACH_STM32H743
>> +               select DEBUG_STM32_UART
>> +               help
>> +                 Say Y here if you want kernel low-level debugging support
>> +                 on STM32H7 based platforms, which default UART is wired on
>> +                 USART1, but another UART instance can be selected by modifying
>> +                 CONFIG_DEBUG_UART_PHYS.
>> +
>> +                 If unsure, say N.
>> +
>> +       config STM32MP1_DEBUG_UART
>> +               bool "Use STM32MP1 UART for low-level debug"
>> +               depends on MACH_STM32MP157
>> +               select DEBUG_STM32_UART
>> +               help
>> +                 Say Y here if you want kernel low-level debugging support
>> +                 on STM32MP1 based platforms, wich default UART is wired on
>> +                 UART4, but another UART instance can be selected by modifying
>> +                 CONFIG_DEBUG_UART_PHYS and CONFIG_DEBUG_UART_VIRT.
>>
>>                    If unsure, say N.
>>
>> @@ -1622,6 +1648,9 @@ config DEBUG_UART_PHYS
>>          default 0x3e000000 if DEBUG_BCM_KONA_UART
>>          default 0x3f201000 if DEBUG_BCM2836
>>          default 0x4000e400 if DEBUG_LL_UART_EFM32
>> +       default 0x40010000 if STM32MP1_DEBUG_UART
>> +       default 0x40011000 if STM32F4_DEBUG_UART || STM32F7_DEBUG_UART || \
>> +                               STM32H7_DEBUG_UART
>>          default 0x40028000 if DEBUG_AT91_SAMV7_USART1
>>          default 0x40081000 if DEBUG_LPC18XX_UART0
>>          default 0x40090000 if DEBUG_LPC32XX
>> @@ -1716,7 +1745,7 @@ config DEBUG_UART_PHYS
>>                  DEBUG_S3C64XX_UART || \
>>                  DEBUG_BCM63XX_UART || DEBUG_ASM9260_UART || \
>>                  DEBUG_SIRFSOC_UART || DEBUG_DIGICOLOR_UA0 || \
>> -               DEBUG_AT91_UART
>> +               DEBUG_AT91_UART || DEBUG_STM32_UART
>>
>>   config DEBUG_UART_VIRT
>>          hex "Virtual base address of debug UART"
>> @@ -1784,6 +1813,7 @@ config DEBUG_UART_VIRT
>>          default 0xfd012000 if DEBUG_MVEBU_UART0_ALTERNATE && ARCH_MV78XX0
>>          default 0xfd883000 if DEBUG_ALPINE_UART0
>>          default 0xfde12000 if DEBUG_MVEBU_UART0_ALTERNATE && ARCH_DOVE
>> +       default 0xfe010000 if STM32MP1_DEBUG_UART
>>          default 0xfe012000 if DEBUG_MVEBU_UART0_ALTERNATE && ARCH_ORION5X
>>          default 0xfe017000 if DEBUG_MMP_UART2
>>          default 0xfe018000 if DEBUG_MMP_UART3
>> @@ -1832,7 +1862,7 @@ config DEBUG_UART_VIRT
>>                  DEBUG_S3C64XX_UART || \
>>                  DEBUG_BCM63XX_UART || DEBUG_ASM9260_UART || \
>>                  DEBUG_SIRFSOC_UART || DEBUG_DIGICOLOR_UA0 || \
>> -               DEBUG_AT91_UART
>> +               DEBUG_AT91_UART || DEBUG_STM32_UART
>>
>>   config DEBUG_UART_8250_SHIFT
>>          int "Register offset shift for the 8250 debug UART"
>> diff --git a/arch/arm/include/debug/stm32.S b/arch/arm/include/debug/stm32.S
>> index 1abb32f..6446e46 100644
>> --- a/arch/arm/include/debug/stm32.S
>> +++ b/arch/arm/include/debug/stm32.S
>> @@ -4,14 +4,13 @@
>>    * Author:   Gerald Baeza <gerald.baeza@st.com> for STMicroelectronics.
>>    */
>>
>> -#define STM32_UART_BASE                        0x40011000      /* USART1 */
>> -
>>   #ifdef CONFIG_STM32F4_DEBUG_UART
>>   #define STM32_USART_SR_OFF             0x00
>>   #define STM32_USART_TDR_OFF            0x04
>>   #endif
>>
>> -#ifdef CONFIG_STM32F7_DEBUG_UART
>> +#if defined(CONFIG_STM32F7_DEBUG_UART) || (CONFIG_STM32H7_DEBUG_UART) || \
>> +       defined(CONFIG_STM32MP1_DEBUG_UART)
>>   #define STM32_USART_SR_OFF             0x1C
>>   #define STM32_USART_TDR_OFF            0x28
>>   #endif
>> @@ -20,8 +19,8 @@
>>   #define STM32_USART_TXE                        (1 << 7)        /* Tx data reg empty */
>>
>>   .macro addruart, rp, rv, tmp
>> -       ldr     \rp,      =STM32_UART_BASE      @ physical base
>> -       ldr     \rv,      =STM32_UART_BASE      @ virt base /* NoMMU */
>> +       ldr     \rp, =CONFIG_DEBUG_UART_PHYS @ physical base
>> +       ldr     \rv, =CONFIG_DEBUG_UART_VIRT @ virt base
>>   .endm
>>
>>   .macro  senduart,rd,rx
>> --
>> 1.9.1
>>
Erwan LE RAY June 10, 2019, 3:47 p.m. UTC | #3
Hi Olof, Arnd and Kevin,

Gentle reminder on my feedback request.

Best regards, Erwan.
diff mbox series

Patch

diff --git a/arch/arm/Kconfig.debug b/arch/arm/Kconfig.debug
index 6d6e033..4ea3e17 100644
--- a/arch/arm/Kconfig.debug
+++ b/arch/arm/Kconfig.debug
@@ -1201,23 +1201,49 @@  choice
 
 	config STM32F4_DEBUG_UART
 		bool "Use STM32F4 UART for low-level debug"
-		depends on ARCH_STM32
+		depends on MACH_STM32F429 || MACH_STM32F469
 		select DEBUG_STM32_UART
 		help
 		  Say Y here if you want kernel low-level debugging support
 		  on STM32F4 based platforms, which default UART is wired on
-		  USART1.
+		  USART1, but another UART instance can be selected by modifying
+		  CONFIG_DEBUG_UART_PHYS.
 
 		  If unsure, say N.
 
 	config STM32F7_DEBUG_UART
 		bool "Use STM32F7 UART for low-level debug"
-		depends on ARCH_STM32
+		depends on MACH_STM32F746 || MACH_STM32F769
 		select DEBUG_STM32_UART
 		help
 		  Say Y here if you want kernel low-level debugging support
 		  on STM32F7 based platforms, which default UART is wired on
-		  USART1.
+		  USART1, but another UART instance can be selected by modifying
+		  CONFIG_DEBUG_UART_PHYS.
+
+		  If unsure, say N.
+
+	config STM32H7_DEBUG_UART
+		bool "Use STM32H7 UART for low-level debug"
+		depends on MACH_STM32H743
+		select DEBUG_STM32_UART
+		help
+		  Say Y here if you want kernel low-level debugging support
+		  on STM32H7 based platforms, which default UART is wired on
+		  USART1, but another UART instance can be selected by modifying
+		  CONFIG_DEBUG_UART_PHYS.
+
+		  If unsure, say N.
+
+	config STM32MP1_DEBUG_UART
+		bool "Use STM32MP1 UART for low-level debug"
+		depends on MACH_STM32MP157
+		select DEBUG_STM32_UART
+		help
+		  Say Y here if you want kernel low-level debugging support
+		  on STM32MP1 based platforms, wich default UART is wired on
+		  UART4, but another UART instance can be selected by modifying
+		  CONFIG_DEBUG_UART_PHYS and CONFIG_DEBUG_UART_VIRT.
 
 		  If unsure, say N.
 
@@ -1622,6 +1648,9 @@  config DEBUG_UART_PHYS
 	default 0x3e000000 if DEBUG_BCM_KONA_UART
 	default 0x3f201000 if DEBUG_BCM2836
 	default 0x4000e400 if DEBUG_LL_UART_EFM32
+	default 0x40010000 if STM32MP1_DEBUG_UART
+	default 0x40011000 if STM32F4_DEBUG_UART || STM32F7_DEBUG_UART || \
+				STM32H7_DEBUG_UART
 	default 0x40028000 if DEBUG_AT91_SAMV7_USART1
 	default 0x40081000 if DEBUG_LPC18XX_UART0
 	default 0x40090000 if DEBUG_LPC32XX
@@ -1716,7 +1745,7 @@  config DEBUG_UART_PHYS
 		DEBUG_S3C64XX_UART || \
 		DEBUG_BCM63XX_UART || DEBUG_ASM9260_UART || \
 		DEBUG_SIRFSOC_UART || DEBUG_DIGICOLOR_UA0 || \
-		DEBUG_AT91_UART
+		DEBUG_AT91_UART || DEBUG_STM32_UART
 
 config DEBUG_UART_VIRT
 	hex "Virtual base address of debug UART"
@@ -1784,6 +1813,7 @@  config DEBUG_UART_VIRT
 	default 0xfd012000 if DEBUG_MVEBU_UART0_ALTERNATE && ARCH_MV78XX0
 	default 0xfd883000 if DEBUG_ALPINE_UART0
 	default 0xfde12000 if DEBUG_MVEBU_UART0_ALTERNATE && ARCH_DOVE
+	default 0xfe010000 if STM32MP1_DEBUG_UART
 	default 0xfe012000 if DEBUG_MVEBU_UART0_ALTERNATE && ARCH_ORION5X
 	default 0xfe017000 if DEBUG_MMP_UART2
 	default 0xfe018000 if DEBUG_MMP_UART3
@@ -1832,7 +1862,7 @@  config DEBUG_UART_VIRT
 		DEBUG_S3C64XX_UART || \
 		DEBUG_BCM63XX_UART || DEBUG_ASM9260_UART || \
 		DEBUG_SIRFSOC_UART || DEBUG_DIGICOLOR_UA0 || \
-		DEBUG_AT91_UART
+		DEBUG_AT91_UART || DEBUG_STM32_UART
 
 config DEBUG_UART_8250_SHIFT
 	int "Register offset shift for the 8250 debug UART"
diff --git a/arch/arm/include/debug/stm32.S b/arch/arm/include/debug/stm32.S
index 1abb32f..6446e46 100644
--- a/arch/arm/include/debug/stm32.S
+++ b/arch/arm/include/debug/stm32.S
@@ -4,14 +4,13 @@ 
  * Author:   Gerald Baeza <gerald.baeza@st.com> for STMicroelectronics.
  */
 
-#define STM32_UART_BASE			0x40011000	/* USART1 */
-
 #ifdef CONFIG_STM32F4_DEBUG_UART
 #define STM32_USART_SR_OFF		0x00
 #define STM32_USART_TDR_OFF		0x04
 #endif
 
-#ifdef CONFIG_STM32F7_DEBUG_UART
+#if defined(CONFIG_STM32F7_DEBUG_UART) || (CONFIG_STM32H7_DEBUG_UART) || \
+	defined(CONFIG_STM32MP1_DEBUG_UART)
 #define STM32_USART_SR_OFF		0x1C
 #define STM32_USART_TDR_OFF		0x28
 #endif
@@ -20,8 +19,8 @@ 
 #define STM32_USART_TXE			(1 << 7)	/* Tx data reg empty */
 
 .macro	addruart, rp, rv, tmp
-	ldr	\rp,      =STM32_UART_BASE	@ physical base
-	ldr	\rv,      =STM32_UART_BASE      @ virt base /* NoMMU */
+	ldr	\rp, =CONFIG_DEBUG_UART_PHYS @ physical base
+	ldr	\rv, =CONFIG_DEBUG_UART_VIRT @ virt base
 .endm
 
 .macro  senduart,rd,rx