[PATCH v5 00/13] Prepare RK3066 U-boot support

This patch serie combines a number of cleanups and fixes that are needed in preparation of Rockchip RK3066 U-boot support.
The common TPL/SPL files contain support for 2 timers that are not used in the early models. Change there call condition. As we are there also increase the build coverage.
The existing timer driver is not prepared for OF_PLATDATA. Code was added to make it work for RK3066.
Early Rockchip SoCs don't have MMC internal dma support. Add code to enable the fifo-mode and OF_PLATDATA support. Fix clock ID's when calling the clock driver.
Rockchip serial driver support is split up between SYS_NS16550 for full U-boot and ROCKCHIP_SERIAL init in TPL/SPL. Make it work for more SoC models and OF_PLATDATA.
Changed V5: TPL/SPL: remove IS_ENABLED condition for rockchip_stimer_init() call
MMC: add OF_PLATDATA u_boot_spl_fifo_mode requirement
SERIAL: rename U_BOOT_DRIVER name to rockchip_uart allow ROCKCHIP_SERIAL enabled in TPL
Changed V4: combine series rebase style fixes
===
Johan Jonker (13): rockchip: move ROCKCHIP_STIMER_BASE to Kconfig rockchip: spl: change call condition rockchip_stimer_init() rockchip: tpl: change call condition rockchip_stimer_init() rockchip: tpl: use IS_ENABLED for timer_init() call condition rockchip: timer: add OF_PLATDATA support for dw-apb-timer rockchip: timer: dw-apb-timer: fix whitespace in U_BOOT_DRIVER structure rockchip: mmc: rockchip_dw_mmc: fix ciu clock index rockchip: mmc: rockchip_dw_mmc: add rk3066/rk3188 support rockchip: serial: restyle the serial_rockchip.c driver rockchip: serial: move driver alias to serial_rockchip.c rockchip: serial: rename U_BOOT_DRIVER name to rockchip_uart rockchip: serial: Kconfig: add select SYS_NS16550 to config ROCKCHIP_SERIAL rockchip: serial: Kconfig: allow ROCKCHIP_SERIAL enabled in TPL
arch/arm/mach-rockchip/Kconfig | 10 ++++++ arch/arm/mach-rockchip/px30/Kconfig | 3 ++ arch/arm/mach-rockchip/rk3036/Kconfig | 3 ++ arch/arm/mach-rockchip/rk3128/Kconfig | 3 ++ arch/arm/mach-rockchip/rk322x/Kconfig | 3 ++ arch/arm/mach-rockchip/rk3288/Kconfig | 3 ++ arch/arm/mach-rockchip/rk3308/Kconfig | 10 +++--- arch/arm/mach-rockchip/rk3328/Kconfig | 3 ++ arch/arm/mach-rockchip/rk3368/Kconfig | 3 ++ arch/arm/mach-rockchip/rk3399/Kconfig | 3 ++ arch/arm/mach-rockchip/rk3568/Kconfig | 3 ++ arch/arm/mach-rockchip/spl.c | 8 ++--- arch/arm/mach-rockchip/tpl.c | 9 +++-- configs/rock_defconfig | 3 +- drivers/mmc/rockchip_dw_mmc.c | 7 ++-- drivers/serial/Kconfig | 5 +-- drivers/serial/Makefile | 2 -- drivers/serial/ns16550.c | 2 -- drivers/serial/serial_rockchip.c | 46 +++++++++++------------- drivers/timer/dw-apb-timer.c | 52 +++++++++++++++++++-------- include/configs/px30_common.h | 1 - include/configs/rk3036_common.h | 1 - include/configs/rk3128_common.h | 1 - include/configs/rk322x_common.h | 1 - include/configs/rk3288_common.h | 1 - include/configs/rk3308_common.h | 1 - include/configs/rk3328_common.h | 1 - include/configs/rk3368_common.h | 1 - include/configs/rk3399_common.h | 1 - include/configs/rk3568_common.h | 1 - 30 files changed, 122 insertions(+), 69 deletions(-)

Move ROCKCHIP_STIMER_BASE to Kconfig.
Signed-off-by: Johan Jonker jbx6244@gmail.com Reviewed-by: Kever Yang kever.yang@rock-chips.com ---
Changed V4: rebase remove depends on rk3188/rk3066 must now disable ROCKCHIP_STIMER in defconfig with defconfig there is more flexibility for other SoC types
Changed V3: add ROCKCHIP_STIMER --- arch/arm/mach-rockchip/Kconfig | 10 ++++++++++ arch/arm/mach-rockchip/px30/Kconfig | 3 +++ arch/arm/mach-rockchip/rk3036/Kconfig | 3 +++ arch/arm/mach-rockchip/rk3128/Kconfig | 3 +++ arch/arm/mach-rockchip/rk322x/Kconfig | 3 +++ arch/arm/mach-rockchip/rk3288/Kconfig | 3 +++ arch/arm/mach-rockchip/rk3308/Kconfig | 10 ++++++---- arch/arm/mach-rockchip/rk3328/Kconfig | 3 +++ arch/arm/mach-rockchip/rk3368/Kconfig | 3 +++ arch/arm/mach-rockchip/rk3399/Kconfig | 3 +++ arch/arm/mach-rockchip/rk3568/Kconfig | 3 +++ configs/rock_defconfig | 3 ++- include/configs/px30_common.h | 1 - include/configs/rk3036_common.h | 1 - include/configs/rk3128_common.h | 1 - include/configs/rk322x_common.h | 1 - include/configs/rk3288_common.h | 1 - include/configs/rk3308_common.h | 1 - include/configs/rk3328_common.h | 1 - include/configs/rk3368_common.h | 1 - include/configs/rk3399_common.h | 1 - include/configs/rk3568_common.h | 1 - 22 files changed, 45 insertions(+), 15 deletions(-)
diff --git a/arch/arm/mach-rockchip/Kconfig b/arch/arm/mach-rockchip/Kconfig index 308dc09b03..811964973a 100644 --- a/arch/arm/mach-rockchip/Kconfig +++ b/arch/arm/mach-rockchip/Kconfig @@ -339,6 +339,16 @@ config ROCKCHIP_BOOT_MODE_REG The Soc will enter to different boot mode(defined in asm/arch-rockchip/boot_mode.h) according to the value from this register.
+config ROCKCHIP_STIMER + bool "Rockchip STIMER support" + default y + help + Enable Rockchip STIMER support. + +config ROCKCHIP_STIMER_BASE + hex + depends on ROCKCHIP_STIMER + config ROCKCHIP_SPL_RESERVE_IRAM hex "Size of IRAM reserved in SPL" default 0 diff --git a/arch/arm/mach-rockchip/px30/Kconfig b/arch/arm/mach-rockchip/px30/Kconfig index 145bf3591f..4886fe946e 100644 --- a/arch/arm/mach-rockchip/px30/Kconfig +++ b/arch/arm/mach-rockchip/px30/Kconfig @@ -38,6 +38,9 @@ config TARGET_PX30_CORE config ROCKCHIP_BOOT_MODE_REG default 0xff010200
+config ROCKCHIP_STIMER_BASE + default 0xff220020 + config SYS_SOC default "px30"
diff --git a/arch/arm/mach-rockchip/rk3036/Kconfig b/arch/arm/mach-rockchip/rk3036/Kconfig index b746795d81..111531be1e 100644 --- a/arch/arm/mach-rockchip/rk3036/Kconfig +++ b/arch/arm/mach-rockchip/rk3036/Kconfig @@ -16,6 +16,9 @@ endchoice config ROCKCHIP_BOOT_MODE_REG default 0x200081c8
+config ROCKCHIP_STIMER_BASE + default 0x200440a0 + config SYS_SOC default "rk3036"
diff --git a/arch/arm/mach-rockchip/rk3128/Kconfig b/arch/arm/mach-rockchip/rk3128/Kconfig index b867401c7f..9cc494eb40 100644 --- a/arch/arm/mach-rockchip/rk3128/Kconfig +++ b/arch/arm/mach-rockchip/rk3128/Kconfig @@ -16,6 +16,9 @@ endchoice config ROCKCHIP_BOOT_MODE_REG default 0x100a0038
+config ROCKCHIP_STIMER_BASE + default 0x200440a0 + config SYS_SOC default "rk3128"
diff --git a/arch/arm/mach-rockchip/rk322x/Kconfig b/arch/arm/mach-rockchip/rk322x/Kconfig index 6458cd5581..058f848ddc 100644 --- a/arch/arm/mach-rockchip/rk322x/Kconfig +++ b/arch/arm/mach-rockchip/rk322x/Kconfig @@ -8,6 +8,9 @@ config TARGET_EVB_RK3229 config ROCKCHIP_BOOT_MODE_REG default 0x110005c8
+config ROCKCHIP_STIMER_BASE + default 0x110d0020 + config SYS_SOC default "rk322x"
diff --git a/arch/arm/mach-rockchip/rk3288/Kconfig b/arch/arm/mach-rockchip/rk3288/Kconfig index f37b1bdfd5..dd8c7826fc 100644 --- a/arch/arm/mach-rockchip/rk3288/Kconfig +++ b/arch/arm/mach-rockchip/rk3288/Kconfig @@ -148,6 +148,9 @@ config ROCKCHIP_FAST_SPL config ROCKCHIP_BOOT_MODE_REG default 0xff730094
+config ROCKCHIP_STIMER_BASE + default 0xff810020 + config SYS_SOC default "rk3288"
diff --git a/arch/arm/mach-rockchip/rk3308/Kconfig b/arch/arm/mach-rockchip/rk3308/Kconfig index 8fa536e15d..194353e4cd 100644 --- a/arch/arm/mach-rockchip/rk3308/Kconfig +++ b/arch/arm/mach-rockchip/rk3308/Kconfig @@ -8,6 +8,12 @@ config TARGET_ROC_RK3308_CC bool "Firefly roc-rk3308-cc" select BOARD_LATE_INIT
+config ROCKCHIP_BOOT_MODE_REG + default 0xff000500 + +config ROCKCHIP_STIMER_BASE + default 0xff1b00a0 + config SYS_SOC default "rk3308"
@@ -17,10 +23,6 @@ config SYS_MALLOC_F_LEN config SPL_SERIAL default y
-config ROCKCHIP_BOOT_MODE_REG - default 0xff000500 - - source "board/rockchip/evb_rk3308/Kconfig" source "board/firefly/firefly-rk3308/Kconfig"
diff --git a/arch/arm/mach-rockchip/rk3328/Kconfig b/arch/arm/mach-rockchip/rk3328/Kconfig index d13a169022..f6f1e06a83 100644 --- a/arch/arm/mach-rockchip/rk3328/Kconfig +++ b/arch/arm/mach-rockchip/rk3328/Kconfig @@ -15,6 +15,9 @@ endchoice config ROCKCHIP_BOOT_MODE_REG default 0xff1005c8
+config ROCKCHIP_STIMER_BASE + default 0xff1d0020 + config SYS_SOC default "rk3328"
diff --git a/arch/arm/mach-rockchip/rk3368/Kconfig b/arch/arm/mach-rockchip/rk3368/Kconfig index 78eb96df3d..104db36737 100644 --- a/arch/arm/mach-rockchip/rk3368/Kconfig +++ b/arch/arm/mach-rockchip/rk3368/Kconfig @@ -45,6 +45,9 @@ endchoice config ROCKCHIP_BOOT_MODE_REG default 0xff738200
+config ROCKCHIP_STIMER_BASE + default 0xff830020 + config SYS_SOC default "rk3368"
diff --git a/arch/arm/mach-rockchip/rk3399/Kconfig b/arch/arm/mach-rockchip/rk3399/Kconfig index 0833e083d9..c1f251316c 100644 --- a/arch/arm/mach-rockchip/rk3399/Kconfig +++ b/arch/arm/mach-rockchip/rk3399/Kconfig @@ -125,6 +125,9 @@ endchoice config ROCKCHIP_BOOT_MODE_REG default 0xff320300
+config ROCKCHIP_STIMER_BASE + default 0xff8680a0 + config SYS_SOC default "rk3399"
diff --git a/arch/arm/mach-rockchip/rk3568/Kconfig b/arch/arm/mach-rockchip/rk3568/Kconfig index 201c63c2a9..4e7c02cce0 100644 --- a/arch/arm/mach-rockchip/rk3568/Kconfig +++ b/arch/arm/mach-rockchip/rk3568/Kconfig @@ -9,6 +9,9 @@ config TARGET_EVB_RK3568 config ROCKCHIP_BOOT_MODE_REG default 0xfdc20200
+config ROCKCHIP_STIMER_BASE + default 0xfdd1c020 + config SYS_SOC default "rk3568"
diff --git a/configs/rock_defconfig b/configs/rock_defconfig index 46df66994b..4aa4608f90 100644 --- a/configs/rock_defconfig +++ b/configs/rock_defconfig @@ -11,12 +11,13 @@ CONFIG_ENV_OFFSET=0x3F8000 CONFIG_DEFAULT_DEVICE_TREE="rk3188-radxarock" CONFIG_SPL_TEXT_BASE=0x10080800 CONFIG_ROCKCHIP_RK3188=y +# CONFIG_ROCKCHIP_STIMER is not set CONFIG_TARGET_ROCK=y CONFIG_SPL_STACK_R_ADDR=0x60080000 CONFIG_DEBUG_UART_BASE=0x20064000 CONFIG_DEBUG_UART_CLOCK=24000000 -CONFIG_DEBUG_UART=y CONFIG_SYS_LOAD_ADDR=0x60800800 +CONFIG_DEBUG_UART=y CONFIG_USE_PREBOOT=y CONFIG_DEFAULT_FDT_FILE="rk3188-radxarock.dtb" # CONFIG_DISPLAY_CPUINFO is not set diff --git a/include/configs/px30_common.h b/include/configs/px30_common.h index 0992387157..dc609013f3 100644 --- a/include/configs/px30_common.h +++ b/include/configs/px30_common.h @@ -12,7 +12,6 @@
#define CONFIG_SYS_NS16550_MEM32
-#define CONFIG_ROCKCHIP_STIMER_BASE 0xff220020 #define COUNTER_FREQUENCY 24000000
/* FIXME: ff020000 is pmu_mem (10k), while ff0e0000 is regular int_mem */ diff --git a/include/configs/rk3036_common.h b/include/configs/rk3036_common.h index 00c453d739..5905518edf 100644 --- a/include/configs/rk3036_common.h +++ b/include/configs/rk3036_common.h @@ -10,7 +10,6 @@
#define CONFIG_SYS_CBSIZE 1024
-#define CONFIG_ROCKCHIP_STIMER_BASE 0x200440a0 #define COUNTER_FREQUENCY 24000000 #define CONFIG_SYS_HZ_CLOCK 24000000
diff --git a/include/configs/rk3128_common.h b/include/configs/rk3128_common.h index 97caceacfe..d77a7d7b09 100644 --- a/include/configs/rk3128_common.h +++ b/include/configs/rk3128_common.h @@ -11,7 +11,6 @@ #define CONFIG_SYS_MAXARGS 16 #define CONFIG_SYS_CBSIZE 1024
-#define CONFIG_ROCKCHIP_STIMER_BASE 0x200440a0 #define COUNTER_FREQUENCY 24000000 #define CONFIG_SYS_HZ_CLOCK 24000000
diff --git a/include/configs/rk322x_common.h b/include/configs/rk322x_common.h index ef55ef0a83..3258820fcd 100644 --- a/include/configs/rk322x_common.h +++ b/include/configs/rk322x_common.h @@ -11,7 +11,6 @@ #define CONFIG_SYS_CBSIZE 1024 #define CONFIG_SYS_BOOTM_LEN (64 << 20) /* 64M */
-#define CONFIG_ROCKCHIP_STIMER_BASE 0x110d0020 #define COUNTER_FREQUENCY 24000000 #define CONFIG_SYS_HZ_CLOCK 24000000
diff --git a/include/configs/rk3288_common.h b/include/configs/rk3288_common.h index 490da7cb23..e2e0f70a70 100644 --- a/include/configs/rk3288_common.h +++ b/include/configs/rk3288_common.h @@ -13,7 +13,6 @@
#define CONFIG_SYS_CBSIZE 1024
-#define CONFIG_ROCKCHIP_STIMER_BASE 0xff810020 #define COUNTER_FREQUENCY 24000000 #define CONFIG_SYS_HZ_CLOCK 24000000
diff --git a/include/configs/rk3308_common.h b/include/configs/rk3308_common.h index 1664707ca6..9cda8d9c48 100644 --- a/include/configs/rk3308_common.h +++ b/include/configs/rk3308_common.h @@ -15,7 +15,6 @@
#define CONFIG_SYS_NS16550_MEM32
-#define CONFIG_ROCKCHIP_STIMER_BASE 0xff1b00a0 #define CONFIG_IRAM_BASE 0xfff80000 #define CONFIG_SYS_INIT_SP_ADDR 0x00800000 #define CONFIG_SPL_STACK 0x00400000 diff --git a/include/configs/rk3328_common.h b/include/configs/rk3328_common.h index c1e26a019b..8a5f0c8999 100644 --- a/include/configs/rk3328_common.h +++ b/include/configs/rk3328_common.h @@ -10,7 +10,6 @@
#define CONFIG_IRAM_BASE 0xff090000
-#define CONFIG_ROCKCHIP_STIMER_BASE 0xff1d0020 #define COUNTER_FREQUENCY 24000000
#define CONFIG_SYS_CBSIZE 1024 diff --git a/include/configs/rk3368_common.h b/include/configs/rk3368_common.h index 8b239ca07d..239296c1d2 100644 --- a/include/configs/rk3368_common.h +++ b/include/configs/rk3368_common.h @@ -15,7 +15,6 @@ #define SDRAM_MAX_SIZE 0xff000000 #define CONFIG_SYS_CBSIZE 1024
-#define CONFIG_ROCKCHIP_STIMER_BASE 0xff830020 #define COUNTER_FREQUENCY 24000000
#define CONFIG_IRAM_BASE 0xff8c0000 diff --git a/include/configs/rk3399_common.h b/include/configs/rk3399_common.h index ed72c8bb6b..4037dba58c 100644 --- a/include/configs/rk3399_common.h +++ b/include/configs/rk3399_common.h @@ -11,7 +11,6 @@ #define CONFIG_SYS_CBSIZE 1024
#define COUNTER_FREQUENCY 24000000 -#define CONFIG_ROCKCHIP_STIMER_BASE 0xff8680a0
#define CONFIG_IRAM_BASE 0xff8c0000
diff --git a/include/configs/rk3568_common.h b/include/configs/rk3568_common.h index 25d7c5cc8f..5649cd64e0 100644 --- a/include/configs/rk3568_common.h +++ b/include/configs/rk3568_common.h @@ -11,7 +11,6 @@ #define CONFIG_SYS_CBSIZE 1024
#define COUNTER_FREQUENCY 24000000 -#define CONFIG_ROCKCHIP_STIMER_BASE 0xfdd1c020
#define CONFIG_IRAM_BASE 0xfdcc0000

The Rockchip SoCs rk3066/rk3188 have no CONFIG_ROCKCHIP_STIMER_BASE defined. Currently only rk3188 has an exception in SPL. Make this more generic and compile code inside the function rockchip_stimer_init() only when CONFIG_ROCKCHIP_STIMER_BASE is available.
Signed-off-by: Johan Jonker jbx6244@gmail.com ---
Changed V5: reword remove IS_ENABLED remove include kconfig.h
Changed V3: use CONFIG_ROCKCHIP_STIMER
Changed V2: use IS_ENABLED add include kconfig.h move define location so that rockchip_stimer_init() is always visible to the compiler --- arch/arm/mach-rockchip/spl.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/arch/arm/mach-rockchip/spl.c b/arch/arm/mach-rockchip/spl.c index 7a8db632b8..9bdc47bf7c 100644 --- a/arch/arm/mach-rockchip/spl.c +++ b/arch/arm/mach-rockchip/spl.c @@ -71,7 +71,6 @@ u32 spl_mmc_boot_mode(const u32 boot_device) return MMCSD_MODE_RAW; }
-#if !defined(CONFIG_ROCKCHIP_RK3188) #define TIMER_LOAD_COUNT_L 0x00 #define TIMER_LOAD_COUNT_H 0x04 #define TIMER_CONTROL_REG 0x10 @@ -81,6 +80,7 @@ u32 spl_mmc_boot_mode(const u32 boot_device)
__weak void rockchip_stimer_init(void) { +#if defined(CONFIG_ROCKCHIP_STIMER_BASE) /* If Timer already enabled, don't re-init it */ u32 reg = readl(CONFIG_ROCKCHIP_STIMER_BASE + TIMER_CONTROL_REG);
@@ -95,8 +95,8 @@ __weak void rockchip_stimer_init(void) writel(0xffffffff, CONFIG_ROCKCHIP_STIMER_BASE + 4); writel(TIMER_EN | TIMER_FMODE, CONFIG_ROCKCHIP_STIMER_BASE + TIMER_CONTROL_REG); -} #endif +}
__weak int board_early_init_f(void) { @@ -133,9 +133,9 @@ void board_init_f(ulong dummy) hang(); } arch_cpu_init(); -#if !defined(CONFIG_ROCKCHIP_RK3188) + rockchip_stimer_init(); -#endif + #ifdef CONFIG_SYS_ARCH_TIMER /* Init ARM arch timer in arch/arm/cpu/armv7/arch_timer.c */ timer_init();

On 2022/4/10 00:55, Johan Jonker wrote:
The Rockchip SoCs rk3066/rk3188 have no CONFIG_ROCKCHIP_STIMER_BASE defined. Currently only rk3188 has an exception in SPL. Make this more generic and compile code inside the function rockchip_stimer_init() only when CONFIG_ROCKCHIP_STIMER_BASE is available.
Signed-off-by: Johan Jonker jbx6244@gmail.com
Reviewed-by: Kever Yang kever.yang@rock-chips.com
Thanks, - Kever
Changed V5: reword remove IS_ENABLED remove include kconfig.h
Changed V3: use CONFIG_ROCKCHIP_STIMER
Changed V2: use IS_ENABLED add include kconfig.h move define location so that rockchip_stimer_init() is always visible to the compiler
arch/arm/mach-rockchip/spl.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/arch/arm/mach-rockchip/spl.c b/arch/arm/mach-rockchip/spl.c index 7a8db632b8..9bdc47bf7c 100644 --- a/arch/arm/mach-rockchip/spl.c +++ b/arch/arm/mach-rockchip/spl.c @@ -71,7 +71,6 @@ u32 spl_mmc_boot_mode(const u32 boot_device) return MMCSD_MODE_RAW; }
-#if !defined(CONFIG_ROCKCHIP_RK3188) #define TIMER_LOAD_COUNT_L 0x00 #define TIMER_LOAD_COUNT_H 0x04 #define TIMER_CONTROL_REG 0x10 @@ -81,6 +80,7 @@ u32 spl_mmc_boot_mode(const u32 boot_device)
__weak void rockchip_stimer_init(void) { +#if defined(CONFIG_ROCKCHIP_STIMER_BASE) /* If Timer already enabled, don't re-init it */ u32 reg = readl(CONFIG_ROCKCHIP_STIMER_BASE + TIMER_CONTROL_REG);
@@ -95,8 +95,8 @@ __weak void rockchip_stimer_init(void) writel(0xffffffff, CONFIG_ROCKCHIP_STIMER_BASE + 4); writel(TIMER_EN | TIMER_FMODE, CONFIG_ROCKCHIP_STIMER_BASE + TIMER_CONTROL_REG); -} #endif +}
__weak int board_early_init_f(void) { @@ -133,9 +133,9 @@ void board_init_f(ulong dummy) hang(); } arch_cpu_init(); -#if !defined(CONFIG_ROCKCHIP_RK3188)
- rockchip_stimer_init();
-#endif
- #ifdef CONFIG_SYS_ARCH_TIMER /* Init ARM arch timer in arch/arm/cpu/armv7/arch_timer.c */ timer_init();

The Rockchip SoCs rk3066/rk3188 have no CONFIG_ROCKCHIP_STIMER_BASE defined. Currently there's no exception in TPL. Make this more generic and compile the code inside the function rockchip_stimer_init() only when CONFIG_ROCKCHIP_STIMER_BASE is available.
Signed-off-by: Johan Jonker jbx6244@gmail.com ---
Changed V5: reword remove IS_ENABLED remove include kconfig.h
Changed V3: use CONFIG_ROCKCHIP_STIMER
Changed V2: use IS_ENABLED add include kconfig.h move define location so that rockchip_stimer_init() is always visible to the compiler --- arch/arm/mach-rockchip/tpl.c | 2 ++ 1 file changed, 2 insertions(+)
diff --git a/arch/arm/mach-rockchip/tpl.c b/arch/arm/mach-rockchip/tpl.c index 3c007bb450..7f43f58406 100644 --- a/arch/arm/mach-rockchip/tpl.c +++ b/arch/arm/mach-rockchip/tpl.c @@ -29,6 +29,7 @@
__weak void rockchip_stimer_init(void) { +#if defined(CONFIG_ROCKCHIP_STIMER_BASE) /* If Timer already enabled, don't re-init it */ u32 reg = readl(CONFIG_ROCKCHIP_STIMER_BASE + TIMER_CONTROL_REG);
@@ -45,6 +46,7 @@ __weak void rockchip_stimer_init(void) writel(0xffffffff, CONFIG_ROCKCHIP_STIMER_BASE + 4); writel(TIMER_EN | TIMER_FMODE, CONFIG_ROCKCHIP_STIMER_BASE + TIMER_CONTROL_REG); +#endif }
void board_init_f(ulong dummy)

On 2022/4/10 00:55, Johan Jonker wrote:
The Rockchip SoCs rk3066/rk3188 have no CONFIG_ROCKCHIP_STIMER_BASE defined. Currently there's no exception in TPL. Make this more generic and compile the code inside the function rockchip_stimer_init() only when CONFIG_ROCKCHIP_STIMER_BASE is available.
Signed-off-by: Johan Jonker jbx6244@gmail.com
Reviewed-by: Kever Yang kever.yang@rock-chips.com
Thanks, - Kever
Changed V5: reword remove IS_ENABLED remove include kconfig.h
Changed V3: use CONFIG_ROCKCHIP_STIMER
Changed V2: use IS_ENABLED add include kconfig.h move define location so that rockchip_stimer_init() is always visible to the compiler
arch/arm/mach-rockchip/tpl.c | 2 ++ 1 file changed, 2 insertions(+)
diff --git a/arch/arm/mach-rockchip/tpl.c b/arch/arm/mach-rockchip/tpl.c index 3c007bb450..7f43f58406 100644 --- a/arch/arm/mach-rockchip/tpl.c +++ b/arch/arm/mach-rockchip/tpl.c @@ -29,6 +29,7 @@
__weak void rockchip_stimer_init(void) { +#if defined(CONFIG_ROCKCHIP_STIMER_BASE) /* If Timer already enabled, don't re-init it */ u32 reg = readl(CONFIG_ROCKCHIP_STIMER_BASE + TIMER_CONTROL_REG);
@@ -45,6 +46,7 @@ __weak void rockchip_stimer_init(void) writel(0xffffffff, CONFIG_ROCKCHIP_STIMER_BASE + 4); writel(TIMER_EN | TIMER_FMODE, CONFIG_ROCKCHIP_STIMER_BASE + TIMER_CONTROL_REG); +#endif }
void board_init_f(ulong dummy)

Not all Rockchip SoC models use the ARM arch timer. Call the function timer_init() only when CONFIG_SYS_ARCH_TIMER is available. Use the call condition IS_ENABLED to increase build coverage and make the code easier to read.
Signed-off-by: Johan Jonker jbx6244@gmail.com Reviewed-by: Simon Glass sjg@chromium.org Reviewed-by: Kever Yang kever.yang@rock-chips.com ---
Changed V5: rebase add include kconfig.h --- arch/arm/mach-rockchip/tpl.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/arch/arm/mach-rockchip/tpl.c b/arch/arm/mach-rockchip/tpl.c index 7f43f58406..8126587060 100644 --- a/arch/arm/mach-rockchip/tpl.c +++ b/arch/arm/mach-rockchip/tpl.c @@ -15,6 +15,7 @@ #include <asm/io.h> #include <asm/arch-rockchip/bootrom.h> #include <linux/bitops.h> +#include <linux/kconfig.h>
#if CONFIG_IS_ENABLED(BANNER_PRINT) #include <timestamp.h> @@ -77,8 +78,10 @@ void board_init_f(ulong dummy)
/* Init secure timer */ rockchip_stimer_init(); - /* Init ARM arch timer in arch/arm/cpu/ */ - timer_init(); + + /* Init ARM arch timer */ + if (IS_ENABLED(CONFIG_SYS_ARCH_TIMER)) + timer_init();
ret = uclass_get_device(UCLASS_RAM, 0, &dev); if (ret) {

The Rockchip rk3066 SoC has 3 dw-apb-timer nodes. U-boot is compiled with OF_PLATDATA TPL/SPL options, so add OF_PLATDATA support for the dw-apb-timer. Also change driver name to be able to compile with U-boot scripts. No reset OF_PLATDATA support was added, because the rk3066 nodes don't need/have them.
Signed-off-by: Johan Jonker jbx6244@gmail.com Reviewed-by: Simon Glass sjg@chromium.org Reviewed-by: Kever Yang kever.yang@rock-chips.com ---
Changed V3: use if (CONFIG_IS_ENABLED(OF_REAL)) remove white space fix
Changed V2: use #if CONFIG_IS_ENABLED(OF_REAL) --- drivers/timer/dw-apb-timer.c | 50 ++++++++++++++++++++++++++---------- 1 file changed, 37 insertions(+), 13 deletions(-)
diff --git a/drivers/timer/dw-apb-timer.c b/drivers/timer/dw-apb-timer.c index 9aed5dd217..f722697934 100644 --- a/drivers/timer/dw-apb-timer.c +++ b/drivers/timer/dw-apb-timer.c @@ -8,10 +8,12 @@ #include <common.h> #include <dm.h> #include <clk.h> +#include <dt-structs.h> #include <malloc.h> #include <reset.h> #include <timer.h> #include <dm/device_compat.h> +#include <linux/kconfig.h>
#include <asm/io.h> #include <asm/arch/timer.h> @@ -25,6 +27,12 @@ struct dw_apb_timer_priv { struct reset_ctl_bulk resets; };
+struct dw_apb_timer_plat { +#if CONFIG_IS_ENABLED(OF_PLATDATA) + struct dtd_snps_dw_apb_timer dtplat; +#endif +}; + static u64 dw_apb_timer_get_count(struct udevice *dev) { struct dw_apb_timer_priv *priv = dev_get_priv(dev); @@ -43,20 +51,33 @@ static int dw_apb_timer_probe(struct udevice *dev) struct dw_apb_timer_priv *priv = dev_get_priv(dev); struct clk clk; int ret; +#if CONFIG_IS_ENABLED(OF_PLATDATA) + struct dw_apb_timer_plat *plat = dev_get_plat(dev); + struct dtd_snps_dw_apb_timer *dtplat = &plat->dtplat;
- ret = reset_get_bulk(dev, &priv->resets); - if (ret) - dev_warn(dev, "Can't get reset: %d\n", ret); - else - reset_deassert_bulk(&priv->resets); + priv->regs = dtplat->reg[0];
- ret = clk_get_by_index(dev, 0, &clk); - if (ret) + ret = clk_get_by_phandle(dev, &dtplat->clocks[0], &clk); + if (ret < 0) return ret;
- uc_priv->clock_rate = clk_get_rate(&clk); + uc_priv->clock_rate = dtplat->clock_frequency; +#endif + if (CONFIG_IS_ENABLED(OF_REAL)) { + ret = reset_get_bulk(dev, &priv->resets); + if (ret) + dev_warn(dev, "Can't get reset: %d\n", ret); + else + reset_deassert_bulk(&priv->resets); + + ret = clk_get_by_index(dev, 0, &clk); + if (ret) + return ret;
- clk_free(&clk); + uc_priv->clock_rate = clk_get_rate(&clk); + + clk_free(&clk); + }
/* init timer */ writel(0xffffffff, priv->regs + DW_APB_LOAD_VAL); @@ -68,9 +89,11 @@ static int dw_apb_timer_probe(struct udevice *dev)
static int dw_apb_timer_of_to_plat(struct udevice *dev) { - struct dw_apb_timer_priv *priv = dev_get_priv(dev); + if (CONFIG_IS_ENABLED(OF_REAL)) { + struct dw_apb_timer_priv *priv = dev_get_priv(dev);
- priv->regs = dev_read_addr(dev); + priv->regs = dev_read_addr(dev); + }
return 0; } @@ -91,8 +114,8 @@ static const struct udevice_id dw_apb_timer_ids[] = { {} };
-U_BOOT_DRIVER(dw_apb_timer) = { - .name = "dw_apb_timer", +U_BOOT_DRIVER(snps_dw_apb_timer) = { + .name = "snps_dw_apb_timer", .id = UCLASS_TIMER, .ops = &dw_apb_timer_ops, .probe = dw_apb_timer_probe, @@ -100,4 +123,5 @@ U_BOOT_DRIVER(dw_apb_timer) = { .of_to_plat = dw_apb_timer_of_to_plat, .remove = dw_apb_timer_remove, .priv_auto = sizeof(struct dw_apb_timer_priv), + .plat_auto = sizeof(struct dw_apb_timer_plat), };

The line with .of_to_plat in the U_BOOT_DRIVER structure of dw-apb-timer.c is not aligned with the rest. Add an extra TAB to fix the whitespace.
Signed-off-by: Johan Jonker jbx6244@gmail.com Reviewed-by: Simon Glass sjg@chromium.org Reviewed-by: Kever Yang kever.yang@rock-chips.com --- drivers/timer/dw-apb-timer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/timer/dw-apb-timer.c b/drivers/timer/dw-apb-timer.c index f722697934..10f0a9f646 100644 --- a/drivers/timer/dw-apb-timer.c +++ b/drivers/timer/dw-apb-timer.c @@ -120,7 +120,7 @@ U_BOOT_DRIVER(snps_dw_apb_timer) = { .ops = &dw_apb_timer_ops, .probe = dw_apb_timer_probe, .of_match = dw_apb_timer_ids, - .of_to_plat = dw_apb_timer_of_to_plat, + .of_to_plat = dw_apb_timer_of_to_plat, .remove = dw_apb_timer_remove, .priv_auto = sizeof(struct dw_apb_timer_priv), .plat_auto = sizeof(struct dw_apb_timer_plat),

The document rockchip-dw-mshc.yaml decribes a maximum of 4 clocks. In the rockchip_dw_mmc driver the clock name in use was "fixed" to "ciu" with index 1, but later reverted back to index 0. The clock drivers can handle both, but the calling driver should submit correct data as a standard practice. Fix the "ciu" clock index by setting it back to 1.
clock-names: minItems: 2 items: - const: biu - const: ciu - const: ciu-drive - const: ciu-sample
Signed-off-by: Johan Jonker jbx6244@gmail.com Reviewed-by: Kever Yang kever.yang@rock-chips.com --- drivers/mmc/rockchip_dw_mmc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/mmc/rockchip_dw_mmc.c b/drivers/mmc/rockchip_dw_mmc.c index 7f8dea1e34..be065ec0c3 100644 --- a/drivers/mmc/rockchip_dw_mmc.c +++ b/drivers/mmc/rockchip_dw_mmc.c @@ -123,11 +123,11 @@ static int rockchip_dwmmc_probe(struct udevice *dev) priv->minmax[0] = 400000; /* 400 kHz */ priv->minmax[1] = dtplat->max_frequency;
- ret = clk_get_by_phandle(dev, dtplat->clocks, &priv->clk); + ret = clk_get_by_phandle(dev, &dtplat->clocks[1], &priv->clk); if (ret < 0) return ret; #else - ret = clk_get_by_index(dev, 0, &priv->clk); + ret = clk_get_by_index(dev, 1, &priv->clk); if (ret < 0) return ret; #endif

The Rockchip SoCs rk3066/rk3188 have MMC DT nodes with as compatible string "rockchip,rk2928-dw-mshc". Add OF_PLATDATA support to the existing driver with help of a DM_DRIVER_ALIAS.
This type needs a permanent enabled fifo. The other Rockchip SoCs always have the property "u-boot,spl-fifo-mode" in the MMC DT nodes, because MMC to SRAM can't do DMA. Make this property a requirement for MMC OF_PLATDATA structures. The property "fifo-mode" must be added for all other compile modes.
Signed-off-by: Johan Jonker jbx6244@gmail.com ---
Changed V5: reword remove driver_data add OF_PLATDATA u_boot_spl_fifo_mode requirement
Changed V4: use boolean --- drivers/mmc/rockchip_dw_mmc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/mmc/rockchip_dw_mmc.c b/drivers/mmc/rockchip_dw_mmc.c index be065ec0c3..573bf16c87 100644 --- a/drivers/mmc/rockchip_dw_mmc.c +++ b/drivers/mmc/rockchip_dw_mmc.c @@ -119,7 +119,7 @@ static int rockchip_dwmmc_probe(struct udevice *dev) host->priv = dev; host->dev_index = 0; priv->fifo_depth = dtplat->fifo_depth; - priv->fifo_mode = 0; + priv->fifo_mode = dtplat->u_boot_spl_fifo_mode; priv->minmax[0] = 400000; /* 400 kHz */ priv->minmax[1] = dtplat->max_frequency;
@@ -180,5 +180,6 @@ U_BOOT_DRIVER(rockchip_rk3288_dw_mshc) = { .plat_auto = sizeof(struct rockchip_mmc_plat), };
+DM_DRIVER_ALIAS(rockchip_rk3288_dw_mshc, rockchip_rk2928_dw_mshc) DM_DRIVER_ALIAS(rockchip_rk3288_dw_mshc, rockchip_rk3328_dw_mshc) DM_DRIVER_ALIAS(rockchip_rk3288_dw_mshc, rockchip_rk3368_dw_mshc)

On 2022/4/10 00:55, Johan Jonker wrote:
The Rockchip SoCs rk3066/rk3188 have MMC DT nodes with as compatible string "rockchip,rk2928-dw-mshc". Add OF_PLATDATA support to the existing driver with help of a DM_DRIVER_ALIAS.
This type needs a permanent enabled fifo. The other Rockchip SoCs always have the property "u-boot,spl-fifo-mode" in the MMC DT nodes, because MMC to SRAM can't do DMA. Make this property a requirement for MMC OF_PLATDATA structures. The property "fifo-mode" must be added for all other compile modes.
Signed-off-by: Johan Jonker jbx6244@gmail.com
Reviewed-by: Kever Yang kever.yang@rock-chips.com
Thanks, - Kever
Changed V5: reword remove driver_data add OF_PLATDATA u_boot_spl_fifo_mode requirement
Changed V4: use boolean
drivers/mmc/rockchip_dw_mmc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/mmc/rockchip_dw_mmc.c b/drivers/mmc/rockchip_dw_mmc.c index be065ec0c3..573bf16c87 100644 --- a/drivers/mmc/rockchip_dw_mmc.c +++ b/drivers/mmc/rockchip_dw_mmc.c @@ -119,7 +119,7 @@ static int rockchip_dwmmc_probe(struct udevice *dev) host->priv = dev; host->dev_index = 0; priv->fifo_depth = dtplat->fifo_depth;
- priv->fifo_mode = 0;
- priv->fifo_mode = dtplat->u_boot_spl_fifo_mode; priv->minmax[0] = 400000; /* 400 kHz */ priv->minmax[1] = dtplat->max_frequency;
@@ -180,5 +180,6 @@ U_BOOT_DRIVER(rockchip_rk3288_dw_mshc) = { .plat_auto = sizeof(struct rockchip_mmc_plat), };
+DM_DRIVER_ALIAS(rockchip_rk3288_dw_mshc, rockchip_rk2928_dw_mshc) DM_DRIVER_ALIAS(rockchip_rk3288_dw_mshc, rockchip_rk3328_dw_mshc) DM_DRIVER_ALIAS(rockchip_rk3288_dw_mshc, rockchip_rk3368_dw_mshc)

The ns16550.c driver has the following conditions for .of_match:
CONFIG_IS_ENABLED(OF_REAL)
For Rockchip SoCs with TPL/SPL and platform data that need serial support the serial_rockchip.c driver was made. It copies this data and then calls ns16550_serial_probe(). With the addition of yet an other SoC type this driver is in need for a little restyle. Simplify struct rockchip_uart_plat and add extra SoCs with DM_DRIVER_ALIAS(). Return -ENODEV when the ns16550.c driver probe function is available.
Signed-off-by: Johan Jonker jbx6244@gmail.com Reviewed-by: Simon Glass sjg@chromium.org Reviewed-by: Kever Yang kever.yang@rock-chips.com ---
Changed V4: add empty line --- drivers/serial/serial_rockchip.c | 37 +++++++++++++------------------- 1 file changed, 15 insertions(+), 22 deletions(-)
diff --git a/drivers/serial/serial_rockchip.c b/drivers/serial/serial_rockchip.c index 97d40869a2..f5ac705f4d 100644 --- a/drivers/serial/serial_rockchip.c +++ b/drivers/serial/serial_rockchip.c @@ -12,22 +12,20 @@ #include <asm/arch-rockchip/clock.h> #include <dm/device-internal.h>
-#if defined(CONFIG_ROCKCHIP_RK3188) -struct rockchip_uart_plat { - struct dtd_rockchip_rk3188_uart dtplat; - struct ns16550_plat plat; -}; -struct dtd_rockchip_rk3188_uart *dtplat, s_dtplat; -#elif defined(CONFIG_ROCKCHIP_RK3288) struct rockchip_uart_plat { +#if CONFIG_IS_ENABLED(OF_PLATDATA) struct dtd_rockchip_rk3288_uart dtplat; +#endif struct ns16550_plat plat; }; + +#if CONFIG_IS_ENABLED(OF_PLATDATA) struct dtd_rockchip_rk3288_uart *dtplat, s_dtplat; #endif
static int rockchip_serial_probe(struct udevice *dev) { +#if CONFIG_IS_ENABLED(OF_PLATDATA) struct rockchip_uart_plat *plat = dev_get_plat(dev);
/* Create some new platform data for the standard driver */ @@ -38,24 +36,19 @@ static int rockchip_serial_probe(struct udevice *dev) dev_set_plat(dev, &plat->plat);
return ns16550_serial_probe(dev); +#else + return -ENODEV; +#endif }
-U_BOOT_DRIVER(rockchip_rk3188_uart) = { - .name = "rockchip_rk3188_uart", - .id = UCLASS_SERIAL, - .priv_auto = sizeof(struct ns16550), - .plat_auto = sizeof(struct rockchip_uart_plat), - .probe = rockchip_serial_probe, - .ops = &ns16550_serial_ops, - .flags = DM_FLAG_PRE_RELOC, -}; - U_BOOT_DRIVER(rockchip_rk3288_uart) = { - .name = "rockchip_rk3288_uart", - .id = UCLASS_SERIAL, + .name = "rockchip_rk3288_uart", + .id = UCLASS_SERIAL, .priv_auto = sizeof(struct ns16550), .plat_auto = sizeof(struct rockchip_uart_plat), - .probe = rockchip_serial_probe, - .ops = &ns16550_serial_ops, - .flags = DM_FLAG_PRE_RELOC, + .probe = rockchip_serial_probe, + .ops = &ns16550_serial_ops, + .flags = DM_FLAG_PRE_RELOC, }; +DM_DRIVER_ALIAS(rockchip_rk3288_uart, rockchip_rk3066_uart) +DM_DRIVER_ALIAS(rockchip_rk3288_uart, rockchip_rk3188_uart)

The Rockchip uart DT nodes have "snps,dw-apb-uart" as fall back string. The driver ns16550.c has CONFIG_IS_ENABLED(OF_REAL) as condition to of_match and does not copy dtplat data. For TPL/SPL the driver serial_rockchip.c is used. Move driver alias to correct driver.
Signed-off-by: Johan Jonker jbx6244@gmail.com Reviewed-by: Simon Glass sjg@chromium.org Reviewed-by: Kever Yang kever.yang@rock-chips.com --- drivers/serial/ns16550.c | 2 -- drivers/serial/serial_rockchip.c | 2 ++ 2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/serial/ns16550.c b/drivers/serial/ns16550.c index 796ff1658c..a4220fd0ae 100644 --- a/drivers/serial/ns16550.c +++ b/drivers/serial/ns16550.c @@ -624,8 +624,6 @@ U_BOOT_DRIVER(ns16550_serial) = { #endif };
-DM_DRIVER_ALIAS(ns16550_serial, rockchip_rk3328_uart) -DM_DRIVER_ALIAS(ns16550_serial, rockchip_rk3368_uart) DM_DRIVER_ALIAS(ns16550_serial, ti_da830_uart) #endif #endif /* SERIAL_PRESENT */ diff --git a/drivers/serial/serial_rockchip.c b/drivers/serial/serial_rockchip.c index f5ac705f4d..10e731caa1 100644 --- a/drivers/serial/serial_rockchip.c +++ b/drivers/serial/serial_rockchip.c @@ -52,3 +52,5 @@ U_BOOT_DRIVER(rockchip_rk3288_uart) = { }; DM_DRIVER_ALIAS(rockchip_rk3288_uart, rockchip_rk3066_uart) DM_DRIVER_ALIAS(rockchip_rk3288_uart, rockchip_rk3188_uart) +DM_DRIVER_ALIAS(rockchip_rk3288_uart, rockchip_rk3328_uart) +DM_DRIVER_ALIAS(rockchip_rk3288_uart, rockchip_rk3368_uart)

When a defconfig for rk3288 is compiled it gives the warning:
rockchip_rk3288_uart: Missing .compatible in ./drivers/serial/serial_rockchip.c : WARNING: the driver rockchip_rk3288_uart was not found in the driver list
Fix by renaming U_BOOT_DRIVER name of serial_rockchip.c to rockchip_uart. Add rk3288 serial support with a DM_DRIVER_ALIAS define.
Signed-off-by: Johan Jonker jbx6244@gmail.com --- drivers/serial/serial_rockchip.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-)
diff --git a/drivers/serial/serial_rockchip.c b/drivers/serial/serial_rockchip.c index 10e731caa1..f4e9422ed9 100644 --- a/drivers/serial/serial_rockchip.c +++ b/drivers/serial/serial_rockchip.c @@ -14,13 +14,13 @@
struct rockchip_uart_plat { #if CONFIG_IS_ENABLED(OF_PLATDATA) - struct dtd_rockchip_rk3288_uart dtplat; + struct dtd_rockchip_uart dtplat; #endif struct ns16550_plat plat; };
#if CONFIG_IS_ENABLED(OF_PLATDATA) -struct dtd_rockchip_rk3288_uart *dtplat, s_dtplat; +struct dtd_rockchip_uart *dtplat, s_dtplat; #endif
static int rockchip_serial_probe(struct udevice *dev) @@ -41,8 +41,8 @@ static int rockchip_serial_probe(struct udevice *dev) #endif }
-U_BOOT_DRIVER(rockchip_rk3288_uart) = { - .name = "rockchip_rk3288_uart", +U_BOOT_DRIVER(rockchip_uart) = { + .name = "rockchip_uart", .id = UCLASS_SERIAL, .priv_auto = sizeof(struct ns16550), .plat_auto = sizeof(struct rockchip_uart_plat), @@ -50,7 +50,8 @@ U_BOOT_DRIVER(rockchip_rk3288_uart) = { .ops = &ns16550_serial_ops, .flags = DM_FLAG_PRE_RELOC, }; -DM_DRIVER_ALIAS(rockchip_rk3288_uart, rockchip_rk3066_uart) -DM_DRIVER_ALIAS(rockchip_rk3288_uart, rockchip_rk3188_uart) -DM_DRIVER_ALIAS(rockchip_rk3288_uart, rockchip_rk3328_uart) -DM_DRIVER_ALIAS(rockchip_rk3288_uart, rockchip_rk3368_uart) +DM_DRIVER_ALIAS(rockchip_uart, rockchip_rk3066_uart) +DM_DRIVER_ALIAS(rockchip_uart, rockchip_rk3188_uart) +DM_DRIVER_ALIAS(rockchip_uart, rockchip_rk3288_uart) +DM_DRIVER_ALIAS(rockchip_uart, rockchip_rk3328_uart) +DM_DRIVER_ALIAS(rockchip_uart, rockchip_rk3368_uart)

On 2022/4/10 00:55, Johan Jonker wrote:
When a defconfig for rk3288 is compiled it gives the warning:
rockchip_rk3288_uart: Missing .compatible in ./drivers/serial/serial_rockchip.c : WARNING: the driver rockchip_rk3288_uart was not found in the driver list
Fix by renaming U_BOOT_DRIVER name of serial_rockchip.c to rockchip_uart. Add rk3288 serial support with a DM_DRIVER_ALIAS define.
Signed-off-by: Johan Jonker jbx6244@gmail.com
Reviewed-by: Kever Yang kever.yang@rock-chips.com
Thanks, - Kever
drivers/serial/serial_rockchip.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-)
diff --git a/drivers/serial/serial_rockchip.c b/drivers/serial/serial_rockchip.c index 10e731caa1..f4e9422ed9 100644 --- a/drivers/serial/serial_rockchip.c +++ b/drivers/serial/serial_rockchip.c @@ -14,13 +14,13 @@
struct rockchip_uart_plat { #if CONFIG_IS_ENABLED(OF_PLATDATA)
- struct dtd_rockchip_rk3288_uart dtplat;
struct dtd_rockchip_uart dtplat; #endif struct ns16550_plat plat; };
#if CONFIG_IS_ENABLED(OF_PLATDATA)
-struct dtd_rockchip_rk3288_uart *dtplat, s_dtplat; +struct dtd_rockchip_uart *dtplat, s_dtplat; #endif
static int rockchip_serial_probe(struct udevice *dev) @@ -41,8 +41,8 @@ static int rockchip_serial_probe(struct udevice *dev) #endif }
-U_BOOT_DRIVER(rockchip_rk3288_uart) = {
- .name = "rockchip_rk3288_uart",
+U_BOOT_DRIVER(rockchip_uart) = {
- .name = "rockchip_uart", .id = UCLASS_SERIAL, .priv_auto = sizeof(struct ns16550), .plat_auto = sizeof(struct rockchip_uart_plat),
@@ -50,7 +50,8 @@ U_BOOT_DRIVER(rockchip_rk3288_uart) = { .ops = &ns16550_serial_ops, .flags = DM_FLAG_PRE_RELOC, }; -DM_DRIVER_ALIAS(rockchip_rk3288_uart, rockchip_rk3066_uart) -DM_DRIVER_ALIAS(rockchip_rk3288_uart, rockchip_rk3188_uart) -DM_DRIVER_ALIAS(rockchip_rk3288_uart, rockchip_rk3328_uart) -DM_DRIVER_ALIAS(rockchip_rk3288_uart, rockchip_rk3368_uart) +DM_DRIVER_ALIAS(rockchip_uart, rockchip_rk3066_uart) +DM_DRIVER_ALIAS(rockchip_uart, rockchip_rk3188_uart) +DM_DRIVER_ALIAS(rockchip_uart, rockchip_rk3288_uart) +DM_DRIVER_ALIAS(rockchip_uart, rockchip_rk3328_uart) +DM_DRIVER_ALIAS(rockchip_uart, rockchip_rk3368_uart)

The Rockchip serial driver depends on an enabled NS16550 driver, so add select SYS_NS16550 to config ROCKCHIP_SERIAL.
Signed-off-by: Johan Jonker jbx6244@gmail.com Reviewed-by: Simon Glass sjg@chromium.org Reviewed-by: Kever Yang kever.yang@rock-chips.com --- drivers/serial/Kconfig | 1 + 1 file changed, 1 insertion(+)
diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig index 76171e7146..06a69e78de 100644 --- a/drivers/serial/Kconfig +++ b/drivers/serial/Kconfig @@ -763,6 +763,7 @@ config PL01X_SERIAL config ROCKCHIP_SERIAL bool "Rockchip on-chip UART support" depends on DM_SERIAL && SPL_OF_PLATDATA + select SYS_NS16550 help Select this to enable a debug UART for Rockchip devices when using CONFIG_SPL_OF_PLATDATA (i.e. a compiled-in device tree replacemenmt).

The serial_rockchip.c driver converts platdata to the data structure used in the ns16550.c file and then calls the function ns16550_serial_probe(). When compiled with OF_REAL the serial_rockchip.c driver returns now -ENODEV when probed and does no harm. The config ROCKCHIP_SERIAL is currently depends on SPL_OF_PLATDATA. Allow serial port use for both SPL and TPL by removing this dependency and SPL_BUILD restriction.
Signed-off-by: Johan Jonker jbx6244@gmail.com --- drivers/serial/Kconfig | 4 ++-- drivers/serial/Makefile | 2 -- 2 files changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig index 06a69e78de..9bf83b29ca 100644 --- a/drivers/serial/Kconfig +++ b/drivers/serial/Kconfig @@ -762,11 +762,11 @@ config PL01X_SERIAL
config ROCKCHIP_SERIAL bool "Rockchip on-chip UART support" - depends on DM_SERIAL && SPL_OF_PLATDATA + depends on DM_SERIAL select SYS_NS16550 help Select this to enable a debug UART for Rockchip devices when using - CONFIG_SPL_OF_PLATDATA (i.e. a compiled-in device tree replacemenmt). + OF_PLATDATA (i.e. a compiled-in device tree replacemenmt). This uses the ns16550 driver, converting the platdata from of-platdata to the ns16550 format.
diff --git a/drivers/serial/Makefile b/drivers/serial/Makefile index b68b5e7b2b..d8e26d72ea 100644 --- a/drivers/serial/Makefile +++ b/drivers/serial/Makefile @@ -46,9 +46,7 @@ obj-$(CONFIG_MXC_UART) += serial_mxc.o obj-$(CONFIG_PXA_SERIAL) += serial_pxa.o obj-$(CONFIG_MESON_SERIAL) += serial_meson.o obj-$(CONFIG_INTEL_MID_SERIAL) += serial_intel_mid.o -ifdef CONFIG_SPL_BUILD obj-$(CONFIG_ROCKCHIP_SERIAL) += serial_rockchip.o -endif obj-$(CONFIG_XILINX_UARTLITE) += serial_xuartlite.o obj-$(CONFIG_SANDBOX_SERIAL) += sandbox.o obj-$(CONFIG_SCIF_CONSOLE) += serial_sh.o

On 2022/4/10 00:55, Johan Jonker wrote:
The serial_rockchip.c driver converts platdata to the data structure used in the ns16550.c file and then calls the function ns16550_serial_probe(). When compiled with OF_REAL the serial_rockchip.c driver returns now -ENODEV when probed and does no harm. The config ROCKCHIP_SERIAL is currently depends on SPL_OF_PLATDATA. Allow serial port use for both SPL and TPL by removing this dependency and SPL_BUILD restriction.
Signed-off-by: Johan Jonker jbx6244@gmail.com
Reviewed-by: Kever Yang kever.yang@rock-chips.com
Thanks, - Kever
drivers/serial/Kconfig | 4 ++-- drivers/serial/Makefile | 2 -- 2 files changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig index 06a69e78de..9bf83b29ca 100644 --- a/drivers/serial/Kconfig +++ b/drivers/serial/Kconfig @@ -762,11 +762,11 @@ config PL01X_SERIAL
config ROCKCHIP_SERIAL bool "Rockchip on-chip UART support"
- depends on DM_SERIAL && SPL_OF_PLATDATA
- depends on DM_SERIAL select SYS_NS16550 help Select this to enable a debug UART for Rockchip devices when using
CONFIG_SPL_OF_PLATDATA (i.e. a compiled-in device tree replacemenmt).
This uses the ns16550 driver, converting the platdata from of-platdata to the ns16550 format.OF_PLATDATA (i.e. a compiled-in device tree replacemenmt).
diff --git a/drivers/serial/Makefile b/drivers/serial/Makefile index b68b5e7b2b..d8e26d72ea 100644 --- a/drivers/serial/Makefile +++ b/drivers/serial/Makefile @@ -46,9 +46,7 @@ obj-$(CONFIG_MXC_UART) += serial_mxc.o obj-$(CONFIG_PXA_SERIAL) += serial_pxa.o obj-$(CONFIG_MESON_SERIAL) += serial_meson.o obj-$(CONFIG_INTEL_MID_SERIAL) += serial_intel_mid.o -ifdef CONFIG_SPL_BUILD obj-$(CONFIG_ROCKCHIP_SERIAL) += serial_rockchip.o -endif obj-$(CONFIG_XILINX_UARTLITE) += serial_xuartlite.o obj-$(CONFIG_SANDBOX_SERIAL) += sandbox.o obj-$(CONFIG_SCIF_CONSOLE) += serial_sh.o
participants (2)
-
Johan Jonker
-
Kever Yang