arm: Tidy up debug UART init
Subsystems (3)
cover arm: Tidy up debug UART init
The debug UART init should be done early in boot by the architecture. At present ARM leaves boards to fend for themselves, resulting in quite a bit of inconsistency.
This series attempts a small clean-up, so that enabling the debug UART should be just a matter of enabling the CONFIG options for most boards.
Simon Glass (4):
arm: Fix some inconsistent debug-UART CONFIG options
arm: Init the debug UART
arm: qemu: Enable the debug UART
rk3399: Don't enable the debug UART if there is no driver
arch/arm/lib/crt0.S | 4 +++ arch/arm/lib/crt0_64.S | 4 +++ arch/arm/mach-rockchip/rk3399/rk3399.c | 34 ++++++++++++++------------ configs/elgin-rv1108_defconfig | 1 + configs/evb-rk3128_defconfig | 1 + configs/evb-rv1108_defconfig | 1 + configs/pm9g45_defconfig | 1 - configs/qemu_arm64_defconfig | 5 ++++ configs/qemu_arm_defconfig | 5 ++++ configs/snow_defconfig | 1 + 10 files changed, 40 insertions(+), 17 deletions(-)
Signature · 1 line
2.33.1.1089.g2158813163f-goog
PATCH 1/4 arm: Fix some inconsistent debug-UART CONFIG options
A few boards enable CONFIG_DEBUG_UART_BOARD_INIT but do not define the required init function. Fix this by disabling the debug UART.
With snow the debug UART is enabled but the driver CONFIG is not. Fix this too.
---
configs/elgin-rv1108_defconfig | 1 + configs/evb-rk3128_defconfig | 1 + configs/evb-rv1108_defconfig | 1 + configs/pm9g45_defconfig | 1 - configs/snow_defconfig | 1 + 5 files changed, 4 insertions(+), 1 deletion(-)
configs/elgin-rv1108_defconfig +1 -0
@@ -6,6 +6,7 @@ CONFIG_NR_DRAM_BANKS=1 CONFIG_ENV_OFFSET=0x3F8000 CONFIG_DEFAULT_DEVICE_TREE="rv1108-elgin-r1" CONFIG_ROCKCHIP_RV1108=y +# CONFIG_DEBUG_UART_BOARD_INIT is not set CONFIG_ROCKCHIP_BOOT_MODE_REG=0 CONFIG_TARGET_ELGIN_RV1108=y CONFIG_DEBUG_UART_BASE=0x10210000
configs/evb-rk3128_defconfig +1 -0
@@ -6,6 +6,7 @@ CONFIG_NR_DRAM_BANKS=2 CONFIG_ENV_OFFSET=0x0 CONFIG_DEFAULT_DEVICE_TREE="rk3128-evb" CONFIG_ROCKCHIP_RK3128=y +# CONFIG_DEBUG_UART_BOARD_INIT is not set CONFIG_DEBUG_UART_BASE=0x20068000 CONFIG_DEBUG_UART_CLOCK=24000000 CONFIG_DEBUG_UART=y
configs/evb-rv1108_defconfig +1 -0
@@ -5,6 +5,7 @@ CONFIG_SYS_TEXT_BASE=0x60000000 CONFIG_NR_DRAM_BANKS=1 CONFIG_DEFAULT_DEVICE_TREE="rv1108-evb" CONFIG_ROCKCHIP_RV1108=y +# CONFIG_DEBUG_UART_BOARD_INIT is not set CONFIG_DEBUG_UART_BASE=0x10210000 CONFIG_DEBUG_UART_CLOCK=24000000 CONFIG_DEBUG_UART=y
configs/pm9g45_defconfig +0 -1
@@ -8,7 +8,6 @@ CONFIG_TARGET_PM9G45=y CONFIG_NR_DRAM_BANKS=1 CONFIG_DM_GPIO=y CONFIG_DEFAULT_DEVICE_TREE="at91sam9m10g45ek" -CONFIG_DEBUG_UART_BOARD_INIT=y CONFIG_DEBUG_UART_BASE=0xffffee00 CONFIG_DEBUG_UART_CLOCK=132000000 CONFIG_ENV_OFFSET_REDUND=0x100000
configs/snow_defconfig +1 -0
@@ -18,6 +18,7 @@ CONFIG_SPL_TEXT_BASE=0x02023400 CONFIG_SPL=y CONFIG_DEBUG_UART_BASE=0x12c30000 CONFIG_DEBUG_UART_CLOCK=100000000 +CONFIG_DEBUG_UART_S5P=y CONFIG_IDENT_STRING=" for snow" CONFIG_DEBUG_UART=y CONFIG_DISTRO_DEFAULTS=y
Signature · 1 line
2.33.1.1089.g2158813163f-goog
Re: [PATCH 1/4] arm: Fix some inconsistent debug-UART CONFIG options
Quoted 7 lines · Simon Glass
A few boards enable
CONFIG_DEBUG_UART_BOARD_INITbut do not define the required init function. Fix this by disabling the debug UART.With snow the debug UART is enabled but the driver CONFIG is not. Fix this too.
Signed-off-by Simon Glass <[email protected]>
Applied to u-boot/next, thanks!
Signature · 1 line
Tom
PATCH 2/4 arm: Init the debug UART
In reply to Simon GlassAt present we don't init the debug UART in the generic ARM code, but instead leave it to individual machines to handle. This is not the way it is supposed to work.
Add the required init to the crt files. This ensures that the UART is available as early as possible and that the announcement appears when it should, if enabled.
---
arch/arm/lib/crt0.S | 4 ++++ arch/arm/lib/crt0_64.S | 4 ++++ 2 files changed, 8 insertions(+)
arch/arm/lib/crt0.S +4 -0
@@ -109,6 +109,10 @@ ENTRY(_main) mov r9, r0 bl board_init_f_init_reserve +#if defined(CONFIG_DEBUG_UART) && CONFIG_IS_ENABLED(SERIAL) + bl debug_uart_init +#endif + #if defined(CONFIG_SPL_BUILD) && defined(CONFIG_SPL_EARLY_BSS) CLEAR_BSS #endif
arch/arm/lib/crt0_64.S +4 -0
@@ -91,6 +91,10 @@ ENTRY(_main) mov x18, x0 bl board_init_f_init_reserve +#if defined(CONFIG_DEBUG_UART) && CONFIG_IS_ENABLED(SERIAL) + bl debug_uart_init +#endif + mov x0, #0 bl board_init_f
Signature · 1 line
2.33.1.1089.g2158813163f-goog
Re: [PATCH 2/4] arm: Init the debug UART
Quoted 9 lines · Simon Glass
At present we don't init the debug UART in the generic ARM code, but instead leave it to individual machines to handle. This is not the way it is supposed to work.
Add the required init to the crt files. This ensures that the UART is available as early as possible and that the announcement appears when it should, if enabled.
Signed-off-by Simon Glass <[email protected]>
Applied to u-boot/next, thanks!
Signature · 1 line
Tom
PATCH 3/4 arm: qemu: Enable the debug UART
In reply to Simon GlassEnable this to permit early debugging. Due to the way qmeu works, the input clock can be zero and things still work.
---
configs/qemu_arm64_defconfig | 5 +++++ configs/qemu_arm_defconfig | 5 +++++ 2 files changed, 10 insertions(+)
configs/qemu_arm64_defconfig +5 -0
@@ -5,6 +5,9 @@ CONFIG_SYS_MALLOC_LEN=0x1000000 CONFIG_NR_DRAM_BANKS=1 CONFIG_ENV_SIZE=0x40000 CONFIG_ENV_SECT_SIZE=0x40000 +CONFIG_DEBUG_UART_BASE=0x9000000 +CONFIG_DEBUG_UART_CLOCK=0 +CONFIG_DEBUG_UART=y CONFIG_AHCI=y CONFIG_DISTRO_DEFAULTS=y CONFIG_SYS_LOAD_ADDR=0x40200000
@@ -47,6 +50,8 @@ CONFIG_PCI=y CONFIG_PCIE_ECAM_GENERIC=y CONFIG_SCSI=y CONFIG_DM_SCSI=y +CONFIG_DEBUG_UART_PL011=y +CONFIG_DEBUG_UART_SHIFT=2 CONFIG_SYSRESET=y CONFIG_SYSRESET_PSCI=y CONFIG_USB=y
configs/qemu_arm_defconfig +5 -0
@@ -6,7 +6,10 @@ CONFIG_NR_DRAM_BANKS=1 CONFIG_ENV_SIZE=0x40000 CONFIG_ENV_SECT_SIZE=0x40000 CONFIG_TARGET_QEMU_ARM_32BIT=y +CONFIG_DEBUG_UART_BASE=0x9000000 +CONFIG_DEBUG_UART_CLOCK=0 CONFIG_ARMV7_LPAE=y +CONFIG_DEBUG_UART=y CONFIG_AHCI=y CONFIG_DISTRO_DEFAULTS=y CONFIG_SYS_LOAD_ADDR=0x40200000
@@ -49,6 +52,8 @@ CONFIG_PCI=y CONFIG_PCIE_ECAM_GENERIC=y CONFIG_SCSI=y CONFIG_DM_SCSI=y +CONFIG_DEBUG_UART_PL011=y +CONFIG_DEBUG_UART_SHIFT=2 CONFIG_SYSRESET=y CONFIG_SYSRESET_PSCI=y CONFIG_USB=y
Signature · 1 line
2.33.1.1089.g2158813163f-goog
Re: [PATCH 3/4] arm: qemu: Enable the debug UART
Quoted 4 lines · Simon Glass
Enable this to permit early debugging. Due to the way qmeu works, the input clock can be zero and things still work.
Signed-off-by Simon Glass <[email protected]>
Applied to u-boot/next, thanks!
Signature · 1 line
Tom
PATCH 4/4 rk3399: Don't enable the debug UART if there is no driver
In reply to Simon GlassSome boards do not enable SPL_SERIAL so cannot use the debug UART. Add this condition to the code and drop use of the preprocessor while we are here.
---
arch/arm/mach-rockchip/rk3399/rk3399.c | 34 ++++++++++++++------------ 1 file changed, 18 insertions(+), 16 deletions(-)
arch/arm/mach-rockchip/rk3399/rk3399.c +18 -16
@@ -118,10 +118,6 @@ void board_debug_uart_init(void)#define GPIO0_BASE 0xff720000#define PMUGRF_BASE 0xff320000struct rk3399_grf_regs *const grf = (void *)GRF_BASE ; -#ifdef CONFIG_TARGET_CHROMEBOOK_BOB -struct rk3399_pmugrf_regs *const pmugrf = (void *)PMUGRF_BASE ; -struct rockchip_gpio_regs *const gpio = (void *)GPIO0_BASE ; -#endif #if defined(CONFIG_DEBUG_UART_BASE ) && (CONFIG_DEBUG_UART_BASE ==0xff180000 )/* Enable early UART0 on the RK3399 */
@@ -140,19 +136,25 @@ void board_debug_uart_init(void)GRF_GPIO3B7_SEL_MASK , GRF_UART3_SOUT << GRF_GPIO3B7_SEL_SHIFT);#else -# ifdef CONFIG_TARGET_CHROMEBOOK_BOB -rk_setreg (&grf->io_vsel,1 <<0 ); - -/* -* Let's enable these power rails here, we are already running the SPI -* Flash based code. -*/ -spl_gpio_output (gpio,GPIO (BANK_B ,2 ),1 );/* PP1500_EN */ -spl_gpio_set_pull (&pmugrf->gpio0_p,GPIO (BANK_B ,2 ),GPIO_PULL_NORMAL ); +struct rk3399_pmugrf_regs *const pmugrf = (void *)PMUGRF_BASE ; +struct rockchip_gpio_regs *const gpio = (void *)GPIO0_BASE ; -spl_gpio_output (gpio,GPIO (BANK_B ,4 ),1 );/* PP3000_EN */ -spl_gpio_set_pull (&pmugrf->gpio0_p,GPIO (BANK_B ,4 ),GPIO_PULL_NORMAL ); -#endif /* CONFIG_TARGET_CHROMEBOOK_BOB */ +if (IS_ENABLED (CONFIG_SPL_BUILD ) && +IS_ENABLED (CONFIG_TARGET_CHROMEBOOK_BOB )) { +rk_setreg (&grf->io_vsel,1 <<0 ); + +/* +* Let's enable these power rails here, we are already running +* the SPI-Flash-based code. +*/ +spl_gpio_output (gpio,GPIO (BANK_B ,2 ),1 );/* PP1500_EN */ +spl_gpio_set_pull (&pmugrf->gpio0_p,GPIO (BANK_B ,2 ), +GPIO_PULL_NORMAL ); + +spl_gpio_output (gpio,GPIO (BANK_B ,4 ),1 );/* PP3000_EN */ +spl_gpio_set_pull (&pmugrf->gpio0_p,GPIO (BANK_B ,4 ), +GPIO_PULL_NORMAL ); + }/* Enable early UART2 channel C on the RK3399 */ rk_clrsetreg(&grf->gpio4c_iomux,
Signature · 1 line
2.33.1.1089.g2158813163f-goog
Re: [PATCH 4/4] rk3399: Don't enable the debug UART if there is no driver
Quoted 6 lines · Simon Glass
Some boards do not enable
SPL_SERIALso cannot use the debug UART. Add this condition to the code and drop use of the preprocessor while we are here.Signed-off-by Simon Glass <[email protected]>
Re: [PATCH 4/4] rk3399: Don't enable the debug UART if there is no driver
In reply to Simon GlassQuoted 6 lines · Simon Glass
Some boards do not enable
SPL_SERIALso cannot use the debug UART. Add this condition to the code and drop use of the preprocessor while we are here.Signed-off-by Simon Glass <[email protected]>Reviewed-by Philipp Tomsich <[email protected]>
Applied to u-boot/next, thanks!
Signature · 1 line
Tom