rockchip: rk3399: spl: Make baudrate and UART configurable
Subsystems (3)
v2 cover rockchip: rk3399: spl: Make baudrate and UART configurable
The default configuration for debug output from the RK3399 SPL is UART2 at 1.5MBaud. While this works reasonably well for the EVB, custom boards may want to change these settings.
To simplify the enablement (i.e. to use the RS232 connector on our baseboard and to improve the compatibility with commonly available RS232-to-UART dongles) for the RK3399-Q7 SoM, we need to make both the UART and the baudrate configurable.
This patch-series makes CONFIG_BAUDRATE a first-class citizen within the Kconfig framework (so we can set it via defconfig) and adds the required iomux support for UART0 in the RK3399 SPL.
Changes in v2:
- Changed hex constant to lowercase
Philipp Tomsich (2):
rockchip: rk3399: spl: add UART0 support for SPL
rockchip: config: rk3399: update defconfigs and rk3399_common
arch/arm/include/asm/arch-rockchip/grf_rk3399.h | 8 +++++++ arch/arm/mach-rockchip/rk3399-board-spl.c | 29 ++++++++++++++++++------- configs/evb-rk3399_defconfig | 2 ++ configs/puma_defconfig | 4 +++- include/configs/rk3399_common.h | 1 - 5 files changed, 34 insertions(+), 10 deletions(-)
Signature · 1 line
1.9.1
PATCH v2 1/2 rockchip: rk3399: spl: add UART0 support for SPL
The RK3399-Q7 ("Puma") SoM exposes UART0 as the Qseven UART (i.e. the serial line available via standardised pins on the edge connector and available on a RS232 connector).
To support boards (such as the RK3399-Q7) that require UART0 as a debug console, we match CONFIG_DEBUG_UART_BASE and add the appropriate iomux setup to the rk3399 SPL code.
As we are already touching this code, we also move the board-specific UART setup (i.e. iomux setup) into board_debug_uart_init(). This will be called from the debug UART init when CONFIG_DEBUG_UART_BOARD_INIT is set.
---
Changes in v2:
- Changed hex constant to lowercase
arch/arm/include/asm/arch-rockchip/grf_rk3399.h | 8 +++++++ arch/arm/mach-rockchip/rk3399-board-spl.c | 29 ++++++++++++++++++------- 2 files changed, 29 insertions(+), 8 deletions(-)
arch/arm/include/asm/arch-rockchip/grf_rk3399.h +8 -0
@@ -333,6 +333,14 @@ enum {GRF_GPIO2B4_SEL_MASK =3 <<GRF_GPIO2B4_SEL_SHIFT ,GRF_SPI2TPM_CSN0 =1 , +/* GRF_GPIO2C_IOMUX */ +GRF_GPIO2C0_SEL_SHIFT =0 , +GRF_GPIO2C0_SEL_MASK =3 <<GRF_GPIO2C0_SEL_SHIFT , +GRF_UART0BT_SIN =1 , +GRF_GPIO2C1_SEL_SHIFT =2 , +GRF_GPIO2C1_SEL_MASK =3 <<GRF_GPIO2C1_SEL_SHIFT , +GRF_UART0BT_SOUT =1 , +/* GRF_GPIO3A_IOMUX */ GRF_GPIO3A4_SEL_SHIFT =8 , GRF_GPIO3A4_SEL_MASK = 3 << GRF_GPIO3A4_SEL_SHIFT,
arch/arm/mach-rockchip/rk3399-board-spl.c +21 -8
@@ -57,19 +57,22 @@ void secure_timer_init(void)writel (TIMER_EN |TIMER_FMODE ,TIMER_CHN10_BASE +TIMER_CONTROL_REG ); } -#define GRF_EMMCCORE_CON11 0xff77f02c -void board_init_f (ulong dummy) +void board_debug_uart_init (void ) { -struct udevice *pinctrl; -struct udevice *dev; -int ret; - -/* Example code showing how to enable the debug UART on RK3288 */ #include <asm/arch/grf_rk3399.h> -/* Enable early UART2 channel C on the RK3399 */ #define GRF_BASE 0xff770000struct rk3399_grf_regs *const grf = (void *)GRF_BASE ; +#if defined(CONFIG_DEBUG_UART_BASE ) && (CONFIG_DEBUG_UART_BASE ==0xff180000 ) +/* Enable early UART0 on the RK3399 */ +rk_clrsetreg (&grf->gpio2c_iomux, +GRF_GPIO2C0_SEL_MASK , +GRF_UART0BT_SIN <<GRF_GPIO2C0_SEL_SHIFT ); +rk_clrsetreg (&grf->gpio2c_iomux, +GRF_GPIO2C1_SEL_MASK , +GRF_UART0BT_SOUT <<GRF_GPIO2C1_SEL_SHIFT ); +#else +/* Enable early UART2 channel C on the RK3399 */ rk_clrsetreg (&grf->gpio4c_iomux,GRF_GPIO4C3_SEL_MASK ,GRF_UART2DGBC_SIN <<GRF_GPIO4C3_SEL_SHIFT );
@@ -80,6 +83,16 @@ void board_init_f(ulong dummy)rk_clrsetreg (&grf->soc_con7,GRF_UART_DBG_SEL_MASK ,GRF_UART_DBG_SEL_C <<GRF_UART_DBG_SEL_SHIFT ); +#endif +} + +#define GRF_EMMCCORE_CON11 0xff77f02c +void board_init_f (ulong dummy) +{ +struct udevice *pinctrl; +struct udevice *dev; +int ret; +#define EARLY_UART #ifdef EARLY_UART /*
Signature · 1 line
1.9.1
PATCH v2 1/2 rockchip: rk3399: spl: add UART0 support for SPL
Hi Philipp,
Quoted 84 lines · Philipp Tomsich
The RK3399-Q7 ("Puma") SoM exposes UART0 as the Qseven UART (i.e. the serial line available via standardised pins on the edge connector and available on a RS232 connector).
To support boards (such as the RK3399-Q7) that require UART0 as a debug console, we match
CONFIG_DEBUG_UART_BASEand add the appropriate iomux setup to the rk3399 SPL code.As we are already touching this code, we also move the board-specific UART setup (i.e. iomux setup) into
board_debug_uart_init(). This will be called from the debug UART init whenCONFIG_DEBUG_UART_BOARD_INITis set.Signed-off-by Philipp Tomsich <[email protected]>---
Changes in v2:
- Changed hex constant to lowercasearch/arm/include/asm/arch-rockchip/grf_rk3399.h | 8 +++++++ arch/arm/mach-rockchip/rk3399-board-spl.c | 29 ++++++++++++++++++------- 2 files changed, 29 insertions(+), 8 deletions(-)arch/arm/include/asm/arch-rockchip/grf_rk3399.h +8
-0@@ -333,6 +333,14 @@ enum {GRF_GPIO2B4_SEL_MASK =3 <<GRF_GPIO2B4_SEL_SHIFT ,GRF_SPI2TPM_CSN0 =1 , +/* GRF_GPIO2C_IOMUX */ +GRF_GPIO2C0_SEL_SHIFT =0 , +GRF_GPIO2C0_SEL_MASK =3 <<GRF_GPIO2C0_SEL_SHIFT , +GRF_UART0BT_SIN =1 , +GRF_GPIO2C1_SEL_SHIFT =2 , +GRF_GPIO2C1_SEL_MASK =3 <<GRF_GPIO2C1_SEL_SHIFT , +GRF_UART0BT_SOUT =1 , +/* GRF_GPIO3A_IOMUX */ GRF_GPIO3A4_SEL_SHIFT =8 , GRF_GPIO3A4_SEL_MASK = 3 << GRF_GPIO3A4_SEL_SHIFT,arch/arm/mach-rockchip/rk3399-board-spl.c +14
-8@@ -57,19 +57,22 @@ void secure_timer_init(void)writel (TIMER_EN |TIMER_FMODE ,TIMER_CHN10_BASE +TIMER_CONTROL_REG ); } -#define GRF_EMMCCORE_CON11 0xff77f02c -void board_init_f (ulong dummy) +void board_debug_uart_init (void ) { -struct udevice *pinctrl; -struct udevice *dev; -int ret; - -/* Example code showing how to enable the debug UART on RK3288 */ #include <asm/arch/grf_rk3399.h> -/* Enable early UART2 channel C on the RK3399 */ #define GRF_BASE 0xff770000struct rk3399_grf_regs *const grf = (void *)GRF_BASE ; +#if defined(CONFIG_DEBUG_UART_BASE ) && (CONFIG_DEBUG_UART_BASE ==0xff180000 ) +/* Enable early UART0 on the RK3399 */ +rk_clrsetreg (&grf->gpio2c_iomux, +GRF_GPIO2C0_SEL_MASK , +GRF_UART0BT_SIN <<GRF_GPIO2C0_SEL_SHIFT ); +rk_clrsetreg (&grf->gpio2c_iomux, +GRF_GPIO2C1_SEL_MASK , +GRF_UART0BT_SOUT <<GRF_GPIO2C1_SEL_SHIFT ); +#else +/* Enable early UART2 channel C on the RK3399 */ rk_clrsetreg (&grf->gpio4c_iomux,GRF_GPIO4C3_SEL_MASK ,GRF_UART2DGBC_SIN <<GRF_GPIO4C3_SEL_SHIFT );@@ -80,6 +83,16 @@ void board_init_f(ulong dummy)rk_clrsetreg (&grf->soc_con7,GRF_UART_DBG_SEL_MASK ,GRF_UART_DBG_SEL_C <<GRF_UART_DBG_SEL_SHIFT ); +#endif +} +
arch/arm/mach-rockchip/rk3399-board-spl.c void board_init_f(ulong dummy) · line 98
Quoted 10 lines
arch/arm/mach-rockchip/rk3399-board-spl.c +7
-0+#define GRF_EMMCCORE_CON11 0xff77f02c +void board_init_f (ulong dummy) +{ +struct udevice *pinctrl; +struct udevice *dev; +int ret; +#define EARLY_UART #ifdef EARLY_UART /*
Thanks,
- Kever
PATCH v2 1/2 rockchip: rk3399: spl: add UART0 support for SPL
Hi,
Quoted 28 lines · Kever Yang
Hi Philipp,
Quoted 23 lines · Philipp Tomsich
The RK3399-Q7 ("Puma") SoM exposes UART0 as the Qseven UART (i.e. the serial line available via standardised pins on the edge connector and available on a RS232 connector).
To support boards (such as the RK3399-Q7) that require UART0 as a debug console, we match
CONFIG_DEBUG_UART_BASEand add the appropriate iomux setup to the rk3399 SPL code.As we are already touching this code, we also move the board-specific UART setup (i.e. iomux setup) into
board_debug_uart_init(). This will be called from the debug UART init whenCONFIG_DEBUG_UART_BOARD_INITis set.Signed-off-by Philipp Tomsich <[email protected]>---
Changes in v2:
- Changed hex constant to lowercasearch/arm/include/asm/arch-rockchip/grf_rk3399.h | 8 +++++++ arch/arm/mach-rockchip/rk3399-board-spl.c | 29 ++++++++++++++++++------- 2 files changed, 29 insertions(+), 8 deletions(-)
This patch causes a build error for me:
aarch64: + evb-rk3399+arch/arm/mach-rockchip/rk3399-board-spl.c:60:6: error: redefinition of 'board_debug_uart_init'
+ void board_debug_uart_init(void)
+ ^
+In file included from arch/arm/mach-rockchip/rk3399-board-spl.c:8:0:+include/debug_uart.h:68:20: note: previous definition of 'board_debug_uart_init' was here
+ static inline void board_debug_uart_init(void)
+ ^
+make[3]: *** [spl/arch/arm/mach-rockchip/rk3399-board-spl.o] Error 1 +make[2]: *** [spl/arch/arm/mach-rockchip] Error 2 +make[1]: *** [spl/u-boot-spl] Error 2
+make: *** [sub-make] Error 2
Regards,
Simon
PATCH v2 1/2 rockchip: rk3399: spl: add UART0 support for SPL
Simon,
you’ll need
CONFIG_DEBUG_UART_BOARD_INIT=y
as include/debug_uart.h checks this macro and either defines this function inline (with an empty body) or allows the function definition.
Seems like everyone just adds this to their defconfig (as did we), but I am open towards an automatic selection of this for ROCKCHIP_RK3399 via Kconfig.
Regards,
Philipp.
Quoted 54 lines · Simon Glass
Hi,
Quoted 28 lines · On 23 March 2017 at 20:12, Kever Yang <kever.yang at rock-chips.com…
Hi Philipp,
Quoted 23 lines · Philipp Tomsich
The RK3399-Q7 ("Puma") SoM exposes UART0 as the Qseven UART (i.e. the serial line available via standardised pins on the edge connector and available on a RS232 connector).
To support boards (such as the RK3399-Q7) that require UART0 as a debug console, we match
CONFIG_DEBUG_UART_BASEand add the appropriate iomux setup to the rk3399 SPL code.As we are already touching this code, we also move the board-specific UART setup (i.e. iomux setup) into
board_debug_uart_init(). This will be called from the debug UART init whenCONFIG_DEBUG_UART_BOARD_INITis set.Signed-off-by Philipp Tomsich <[email protected]>---
Changes in v2:
- Changed hex constant to lowercasearch/arm/include/asm/arch-rockchip/grf_rk3399.h | 8 +++++++ arch/arm/mach-rockchip/rk3399-board-spl.c | 29 ++++++++++++++++++------- 2 files changed, 29 insertions(+), 8 deletions(-)This patch causes a build error for me:
aarch64: + evb-rk3399
+arch/arm/mach-rockchip/rk3399-board-spl.c:60:6: error: redefinition of 'board_debug_uart_init'
+ voidboard_debug_uart_init(void)(quoted diff) +3
-0+ ^ +In file included from arch/arm/mach-rockchip/rk3399-board-spl.c:8:0: +include/debug_uart.h:68:20: note: previous definition of'
board_debug_uart_init' was here
+ static inline voidboard_debug_uart_init(void)(quoted diff) +5
-0+ ^ +make[3]: *** [spl/arch/arm/mach-rockchip/rk3399-board-spl.o] Error 1 +make[2]: *** [spl/arch/arm/mach-rockchip] Error 2 +make[1]: *** [spl/u-boot-spl] Error 2 +make: *** [sub-make] Error 2Regards,
Simon
PATCH v2 1/2 rockchip: rk3399: spl: add UART0 support for SPL
Hi,
Quoted 11 lines · Dr. Philipp Tomsich
Simon,
you’ll need
CONFIG_DEBUG_UART_BOARD_INIT=y
asinclude/debug_uart.hchecks this macro and either defines this function inline (with
an empty body) or allows the function definition.Seems like everyone just adds this to their defconfig (as did we), but I am open towards
an automatic selection of this forROCKCHIP_RK3399viaKconfig.
Well we need to do something since I cannot apply patches which break the build! Please can you make sure your patches apply cleaning to u-boot mainline or u-boot-rockchip, and that each one independently builds. It really speeds up the process!
Quoted 54 lines
Regards,
Philipp.On 26 Mar 2017, at 04:38, Simon Glass <[email protected]> wrote:
Hi,
On 23 March 2017 at 20:12, Kever Yang <[email protected]> wrote:
Hi Philipp,
On 03/24/2017 06:24 AM, Philipp Tomsich wrote:
The RK3399-Q7 ("Puma") SoM exposes UART0 as the Qseven UART (i.e. the serial line available via standardised pins on the edge connector and available on a RS232 connector).
To support boards (such as the RK3399-Q7) that require UART0 as a debug console, we match
CONFIG_DEBUG_UART_BASEand add the appropriate iomux setup to the rk3399 SPL code.As we are already touching this code, we also move the board-specific UART setup (i.e. iomux setup) into
board_debug_uart_init(). This will be called from the debug UART init whenCONFIG_DEBUG_UART_BOARD_INITis set.Signed-off-by Philipp Tomsich <[email protected]>---
Changes in v2:
- Changed hex constant to lowercasearch/arm/include/asm/arch-rockchip/grf_rk3399.h | 8 +++++++ arch/arm/mach-rockchip/rk3399-board-spl.c | 29 ++++++++++++++++++------- 2 files changed, 29 insertions(+), 8 deletions(-)This patch causes a build error for me:
aarch64: + evb-rk3399
+arch/arm/mach-rockchip/rk3399-board-spl.c:60:6: error: redefinition of 'board_debug_uart_init'
+ voidboard_debug_uart_init(void)(quoted diff) +3
-0+ ^ +In file included from arch/arm/mach-rockchip/rk3399-board-spl.c:8:0: +include/debug_uart.h:68:20: note: previous definition of'
board_debug_uart_init' was here
+ static inline voidboard_debug_uart_init(void)
Review
Quoted 5 lines
(quoted diff) +5
-0+ ^ +make[3]: *** [spl/arch/arm/mach-rockchip/rk3399-board-spl.o] Error 1 +make[2]: *** [spl/arch/arm/mach-rockchip] Error 2 +make[1]: *** [spl/u-boot-spl] Error 2 +make: *** [sub-make] Error 2
Regards,
Simon
PATCH v2 2/2 rockchip: config: rk3399: update defconfigs and rk3399_common
In reply to Philipp TomsichWith everything set up to define CONFIG_BAUDRATE via defconfig and with to have the SPL debug UART either on UART0 or UART2, the configs for the RK3399 EVB and for the RK3399-Q7 can be updated.
---
Changes in v2: None
configs/evb-rk3399_defconfig | 2 ++ configs/puma_defconfig | 4 +++- include/configs/rk3399_common.h | 1 - 3 files changed, 5 insertions(+), 2 deletions(-)
configs/evb-rk3399_defconfig +2 -0
@@ -43,7 +43,9 @@ CONFIG_DM_REGULATOR_FIXED=y CONFIG_PWM_ROCKCHIP=y CONFIG_RAM=y CONFIG_SPL_RAM=y +CONFIG_BAUDRATE=1500000 CONFIG_DEBUG_UART=y +CONFIG_DEBUG_UART_BOARD_INIT=y CONFIG_DEBUG_UART_BASE=0xFF1A0000 CONFIG_DEBUG_UART_CLOCK=24000000 CONFIG_DEBUG_UART_SHIFT=2
configs/puma_defconfig +3 -1
@@ -43,8 +43,10 @@ CONFIG_DM_REGULATOR_FIXED=y CONFIG_PWM_ROCKCHIP=y CONFIG_RAM=y CONFIG_SPL_RAM=y +CONFIG_BAUDRATE=115200 CONFIG_DEBUG_UART=y -CONFIG_DEBUG_UART_BASE=0xFF1A0000 +CONFIG_DEBUG_UART_BOARD_INIT=y +CONFIG_DEBUG_UART_BASE=0xFF180000 CONFIG_DEBUG_UART_CLOCK=24000000 CONFIG_DEBUG_UART_SHIFT=2 CONFIG_SYS_NS16550=y
include/configs/rk3399_common.h +0 -1
@@ -12,7 +12,6 @@#define CONFIG_NR_DRAM_BANKS 1#define CONFIG_ENV_SIZE 0x2000#define CONFIG_SYS_MAXARGS 16 -#define CONFIG_BAUDRATE 1500000#define CONFIG_SYS_MALLOC_LEN (32 << 20)#define CONFIG_SYS_CBSIZE 1024#define CONFIG_SKIP_LOWLEVEL_INIT
Signature · 1 line
1.9.1
PATCH v2 2/2 rockchip: config: rk3399: update defconfigs and rk3399_common
Hi Philipp,
Quoted 50 lines · Philipp Tomsich
With everything set up to define
CONFIG_BAUDRATEvia defconfig and with to have the SPL debug UART either on UART0 or UART2, the configs for the RK3399 EVB and for the RK3399-Q7 can be updated.Signed-off-by Philipp Tomsich <[email protected]>---
Changes in v2: None
configs/evb-rk3399_defconfig | 2 ++ configs/puma_defconfig | 4 +++- include/configs/rk3399_common.h | 1 - 3 files changed, 5 insertions(+), 2 deletions(-)configs/evb-rk3399_defconfig +2
-0@@ -43,7 +43,9 @@ CONFIG_DM_REGULATOR_FIXED=y CONFIG_PWM_ROCKCHIP=y CONFIG_RAM=y CONFIG_SPL_RAM=y +CONFIG_BAUDRATE=1500000 CONFIG_DEBUG_UART=y +CONFIG_DEBUG_UART_BOARD_INIT=y CONFIG_DEBUG_UART_BASE=0xFF1A0000 CONFIG_DEBUG_UART_CLOCK=24000000 CONFIG_DEBUG_UART_SHIFT=2configs/puma_defconfig +3
-1@@ -43,8 +43,10 @@ CONFIG_DM_REGULATOR_FIXED=y CONFIG_PWM_ROCKCHIP=y CONFIG_RAM=y CONFIG_SPL_RAM=y +CONFIG_BAUDRATE=115200 CONFIG_DEBUG_UART=y -CONFIG_DEBUG_UART_BASE=0xFF1A0000 +CONFIG_DEBUG_UART_BOARD_INIT=y +CONFIG_DEBUG_UART_BASE=0xFF180000 CONFIG_DEBUG_UART_CLOCK=24000000 CONFIG_DEBUG_UART_SHIFT=2 CONFIG_SYS_NS16550=yinclude/configs/rk3399_common.h +0
-0
include/configs/rk3399_common.h line 17
Quoted 7 lines
include/configs/rk3399_common.h +0
-1@@ -12,7 +12,6 @@#define CONFIG_NR_DRAM_BANKS 1#define CONFIG_ENV_SIZE 0x2000#define CONFIG_SYS_MAXARGS 16 -#define CONFIG_BAUDRATE 1500000#define CONFIG_SYS_MALLOC_LEN (32 << 20)#define CONFIG_SYS_CBSIZE 1024#define CONFIG_SKIP_LOWLEVEL_INIT
Looks good to me.
Thanks,
- Kever
PATCH v2 2/2 rockchip: config: rk3399: update defconfigs and rk3399_common
In reply to Philipp TomsichHi,
configs/puma_defconfig
Quoted 33 lines · Philipp Tomsich
With everything set up to define
CONFIG_BAUDRATEvia defconfig and with to have the SPL debug UART either on UART0 or UART2, the configs for the RK3399 EVB and for the RK3399-Q7 can be updated.Signed-off-by Philipp Tomsich <[email protected]>---
Changes in v2: None
configs/evb-rk3399_defconfig | 2 ++ configs/puma_defconfig | 4 +++- include/configs/rk3399_common.h | 1 - 3 files changed, 5 insertions(+), 2 deletions(-)configs/evb-rk3399_defconfig +2
-0@@ -43,7 +43,9 @@ CONFIG_DM_REGULATOR_FIXED=y CONFIG_PWM_ROCKCHIP=y CONFIG_RAM=y CONFIG_SPL_RAM=y +CONFIG_BAUDRATE=1500000 CONFIG_DEBUG_UART=y +CONFIG_DEBUG_UART_BOARD_INIT=y CONFIG_DEBUG_UART_BASE=0xFF1A0000 CONFIG_DEBUG_UART_CLOCK=24000000 CONFIG_DEBUG_UART_SHIFT=2configs/puma_defconfig +0
-0
I don't have this file in my tree. Is this based on mainline?
Regards,
Simon