rockchip: migrate to use common TPL board file
Subsystems (3)
cover rockchip: migrate to use common TPL board file
Rockchip SoCs have very similar boot process, we can use TPL for all SoCs and all these SoCs can share the same board file. Migrate to use common board file to avoid unneccessary copy-paste for different SoCs.
Kever Yang (7):
rockchip: add common tpl board file
rockchip: rk322x: use common TPL board file
rockchip: rk3288: use common SPL board file
rockchip: rk3368: use common TPL board file
rockchip: rk3399: use common secure_timer_init() for spl/tpl
rockchip: rk3399: remove TPL_BOARD_INIT
rockchip: rk3399: use common TPL board file
arch/arm/mach-rockchip/Kconfig | 14 ++-
arch/arm/mach-rockchip/Makefile | 6 +-
arch/arm/mach-rockchip/rk3288-board-tpl.c | 89 ------------------
arch/arm/mach-rockchip/rk3368-board-tpl.c | 74 ---------------
arch/arm/mach-rockchip/rk3399-board-spl.c | 19 +---
arch/arm/mach-rockchip/rk3399-board-tpl.c | 91 -------------------
arch/arm/mach-rockchip/rk3399/rk3399.c | 29 ++++++
.../{rk322x-board-tpl.c => tpl.c} | 28 +++---
include/configs/rk3399_common.h | 1 +
9 files changed, 62 insertions(+), 289 deletions(-)
delete mode 100644 arch/arm/mach-rockchip/rk3288-board-tpl.c
delete mode 100644 arch/arm/mach-rockchip/rk3368-board-tpl.c
delete mode 100644 arch/arm/mach-rockchip/rk3399-board-tpl.c
rename arch/arm/mach-rockchip/{rk322x-board-tpl.c => tpl.c} (82%)Signature · 1 line
2.17.1
PATCH 1/7 rockchip: add common tpl board file
Rockchip SoCs have similar boot process, prefer to use TPL for DRAM init and back to bootrom, and SPL as Trust ATF/U-Boot loader. TPL common board is a basic TPL board init which can be shared for most of SoCs to avoid copy-pase for different SoCs.
---
arch/arm/mach-rockchip/Kconfig | 9 ++++ arch/arm/mach-rockchip/Makefile | 1 + arch/arm/mach-rockchip/tpl.c | 86 +++++++++++++++++++++++++++++++++ 3 files changed, 96 insertions(+) create mode 100644 arch/arm/mach-rockchip/tpl.c
arch/arm/mach-rockchip/Kconfig +9 -0
@@ -223,6 +223,15 @@ config TPL_ROCKCHIP_BACK_TO_BROM SPL will return to the boot rom, which will then load the U-Boot binary to keep going on. +config TPL_ROCKCHIP_COMMON_BOARD + bool "" + depends on TPL + help + Rockchip SoCs have similar boot process, prefer to use TPL for DRAM + init and back to bootrom, and SPL as Trust ATF/U-Boot loader. TPL + common board is a basic TPL board init which can be shared for most + of SoCs to avoid copy-pase for different SoCs. + config ROCKCHIP_BOOT_MODE_REG hex "Rockchip boot mode flag register address" default 0
arch/arm/mach-rockchip/Makefile +1 -0
@@ -8,6 +8,7 @@ # the stack-pointer is valid before switching to the U-Boot stack). obj-spl-$(CONFIG_ROCKCHIP_BROM_HELPER) += bootrom.o obj-tpl-$(CONFIG_ROCKCHIP_BROM_HELPER) += bootrom.o +obj-tpl-$(CONFIG_TPL_ROCKCHIP_COMMON_BOARD) += tpl.o obj-tpl-$(CONFIG_ROCKCHIP_RK3288) += rk3288-board-tpl.o obj-tpl-$(CONFIG_ROCKCHIP_RK3368) += rk3368-board-tpl.o
arch/arm/mach-rockchip/tpl.c new file +86 -0
86 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH 2/7 rockchip: rk322x: use common TPL board file
In reply to Kever YangUse Common tpl.c instead of rk322x-board-tpl.c
---
arch/arm/mach-rockchip/Kconfig | 1 + arch/arm/mach-rockchip/Makefile | 1 - arch/arm/mach-rockchip/rk322x-board-tpl.c | 80 ----------------------- 3 files changed, 1 insertion(+), 81 deletions(-) delete mode 100644 arch/arm/mach-rockchip/rk322x-board-tpl.c
arch/arm/mach-rockchip/Kconfig +1 -0
@@ -59,6 +59,7 @@ config ROCKCHIP_RK322X select SPL_DRIVERS_MISC_SUPPORT imply SPL_SERIAL_SUPPORT imply TPL_SERIAL_SUPPORT + imply TPL_ROCKCHIP_COMMON_BOARD select ROCKCHIP_BROM_HELPER select TPL_LIBCOMMON_SUPPORT select TPL_LIBGENERIC_SUPPORT
arch/arm/mach-rockchip/Makefile +0 -1
@@ -12,7 +12,6 @@ obj-tpl-$(CONFIG_TPL_ROCKCHIP_COMMON_BOARD) += tpl.o obj-tpl-$(CONFIG_ROCKCHIP_RK3288) += rk3288-board-tpl.o obj-tpl-$(CONFIG_ROCKCHIP_RK3368) += rk3368-board-tpl.o -obj-tpl-$(CONFIG_ROCKCHIP_RK322X) += rk322x-board-tpl.o obj-tpl-$(CONFIG_ROCKCHIP_RK3399) += rk3399-board-tpl.o obj-spl-$(CONFIG_ROCKCHIP_RK3036) += rk3036-board-spl.o
arch/arm/mach-rockchip/rk322x-board-tpl.c deleted +0 -80
80 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH 3/7 rockchip: rk3288: use common SPL board file
In reply to Kever YangUse Common tpl.c instead of rk322x-board-tpl.c
---
arch/arm/mach-rockchip/Kconfig | 1 + arch/arm/mach-rockchip/Makefile | 1 - arch/arm/mach-rockchip/rk3288-board-tpl.c | 89 ----------------------- 3 files changed, 1 insertion(+), 90 deletions(-) delete mode 100644 arch/arm/mach-rockchip/rk3288-board-tpl.c
arch/arm/mach-rockchip/Kconfig +1 -0
@@ -88,6 +88,7 @@ config ROCKCHIP_RK3288 imply TPL_OF_PLATDATA imply TPL_RAM imply TPL_REGMAP + imply TPL_ROCKCHIP_COMMON_BOARD imply TPL_SERIAL_SUPPORT imply TPL_SYSCON imply USB_FUNCTION_ROCKUSB
arch/arm/mach-rockchip/Makefile +0 -1
@@ -10,7 +10,6 @@ obj-spl-$(CONFIG_ROCKCHIP_BROM_HELPER) += bootrom.o obj-tpl-$(CONFIG_ROCKCHIP_BROM_HELPER) += bootrom.o obj-tpl-$(CONFIG_TPL_ROCKCHIP_COMMON_BOARD) += tpl.o -obj-tpl-$(CONFIG_ROCKCHIP_RK3288) += rk3288-board-tpl.o obj-tpl-$(CONFIG_ROCKCHIP_RK3368) += rk3368-board-tpl.o obj-tpl-$(CONFIG_ROCKCHIP_RK3399) += rk3399-board-tpl.o
arch/arm/mach-rockchip/rk3288-board-tpl.c deleted +0 -89
89 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH 4/7 rockchip: rk3368: use common TPL board file
In reply to Kever YangUse common tpl.c instead of rk3368-board-tpl.c
---
arch/arm/mach-rockchip/Kconfig | 1 + arch/arm/mach-rockchip/Makefile | 1 - arch/arm/mach-rockchip/rk3368-board-tpl.c | 74 ----------------------- 3 files changed, 1 insertion(+), 75 deletions(-) delete mode 100644 arch/arm/mach-rockchip/rk3368-board-tpl.c
arch/arm/mach-rockchip/Kconfig +1 -0
@@ -127,6 +127,7 @@ config ROCKCHIP_RK3368 imply SPL_SEPARATE_BSS imply SPL_SERIAL_SUPPORT imply TPL_SERIAL_SUPPORT + imply TPL_ROCKCHIP_COMMON_BOARD help The Rockchip RK3368 is a ARM-based SoC with a octa-core (organised into a big and little cluster with 4 cores each) Cortex-A53 including
arch/arm/mach-rockchip/Makefile +0 -1
@@ -10,7 +10,6 @@ obj-spl-$(CONFIG_ROCKCHIP_BROM_HELPER) += bootrom.o obj-tpl-$(CONFIG_ROCKCHIP_BROM_HELPER) += bootrom.o obj-tpl-$(CONFIG_TPL_ROCKCHIP_COMMON_BOARD) += tpl.o -obj-tpl-$(CONFIG_ROCKCHIP_RK3368) += rk3368-board-tpl.o obj-tpl-$(CONFIG_ROCKCHIP_RK3399) += rk3399-board-tpl.o obj-spl-$(CONFIG_ROCKCHIP_RK3036) += rk3036-board-spl.o
arch/arm/mach-rockchip/rk3368-board-tpl.c deleted +0 -74
74 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH 5/7 rockchip: rk3399: use common secure_timer_init() for spl/tpl
In reply to Kever YangSPL/TPL share the same secure_timer_init(), update to use one copy source code and update to use CONFIG_ROCKCHIP_STIMER_BASE as base address.
---
arch/arm/mach-rockchip/rk3399-board-spl.c | 19 +-------------- arch/arm/mach-rockchip/rk3399-board-tpl.c | 18 +------------- arch/arm/mach-rockchip/rk3399/rk3399.c | 29 +++++++++++++++++++++++ include/configs/rk3399_common.h | 1 + 4 files changed, 32 insertions(+), 35 deletions(-)
arch/arm/mach-rockchip/rk3399-board-spl.c +1 -18
@@ -109,27 +109,10 @@ void spl_perform_fixups(struct spl_image_info *spl_image) "u-boot,spl-boot-device", boot_ofpath); } -#define TIMER_CHN10_BASE 0xff8680a0 -#define TIMER_END_COUNT_L 0x00 -#define TIMER_END_COUNT_H 0x04 -#define TIMER_INIT_COUNT_L 0x10 -#define TIMER_INIT_COUNT_H 0x14 -#define TIMER_CONTROL_REG 0x1c - -#define TIMER_EN 0x1 -#define TIMER_FMODE (0 << 1) -#define TIMER_RMODE (1 << 1) - -void secure_timer_init (void ) +__weak void secure_timer_init (void ) { -writel (0xffffffff ,TIMER_CHN10_BASE +TIMER_END_COUNT_L ); -writel (0xffffffff ,TIMER_CHN10_BASE +TIMER_END_COUNT_H ); -writel (0 ,TIMER_CHN10_BASE +TIMER_INIT_COUNT_L ); -writel (0 ,TIMER_CHN10_BASE +TIMER_INIT_COUNT_H ); -writel (TIMER_EN |TIMER_FMODE ,TIMER_CHN10_BASE +TIMER_CONTROL_REG ); } -void board_init_f (ulong dummy) {struct udevice *dev;
arch/arm/mach-rockchip/rk3399-board-tpl.c +1 -17
@@ -12,24 +12,8 @@#include <asm/io.h> #include <asm/arch-rockchip/bootrom.h> -#define TIMER_CHN10_BASE 0xff8680a0 -#define TIMER_END_COUNT_L 0x00 -#define TIMER_END_COUNT_H 0x04 -#define TIMER_INIT_COUNT_L 0x10 -#define TIMER_INIT_COUNT_H 0x14 -#define TIMER_CONTROL_REG 0x1c - -#define TIMER_EN 0x1 -#define TIMER_FMODE (0 << 1) -#define TIMER_RMODE (1 << 1) - -void secure_timer_init (void ) +__weak void secure_timer_init (void ) { -writel (0xffffffff ,TIMER_CHN10_BASE +TIMER_END_COUNT_L ); -writel (0xffffffff ,TIMER_CHN10_BASE +TIMER_END_COUNT_H ); -writel (0 ,TIMER_CHN10_BASE +TIMER_INIT_COUNT_L ); -writel (0 ,TIMER_CHN10_BASE +TIMER_INIT_COUNT_H ); -writel (TIMER_EN |TIMER_FMODE ,TIMER_CHN10_BASE +TIMER_CONTROL_REG ); }void board_init_f (ulong dummy)
arch/arm/mach-rockchip/rk3399/rk3399.c +29 -0
@@ -38,6 +38,35 @@ static struct mm_region rk3399_mem_map[] = {struct mm_region *mem_map = rk3399_mem_map; +#ifdef CONFIG_SPL_BUILD + +#define TIMER_END_COUNT_L 0x00 +#define TIMER_END_COUNT_H 0x04 +#define TIMER_INIT_COUNT_L 0x10 +#define TIMER_INIT_COUNT_H 0x14 +#define TIMER_CONTROL_REG 0x1c + +#define TIMER_EN 0x1 +#define TIMER_FMODE BIT(0) +#define TIMER_RMODE BIT(1) + +void secure_timer_init (void ) +{ +/* If Timer already enabled, don't re-init it */ +u32 reg =readl (CONFIG_ROCKCHIP_STIMER_BASE +TIMER_CONTROL_REG ); + +if (reg &TIMER_EN ) +return ; + +writel (0xffffffff ,CONFIG_ROCKCHIP_STIMER_BASE +TIMER_END_COUNT_L ); +writel (0xffffffff ,CONFIG_ROCKCHIP_STIMER_BASE +TIMER_END_COUNT_H ); +writel (0 ,CONFIG_ROCKCHIP_STIMER_BASE +TIMER_INIT_COUNT_L ); +writel (0 ,CONFIG_ROCKCHIP_STIMER_BASE +TIMER_INIT_COUNT_H ); +writel (TIMER_EN |TIMER_FMODE ,CONFIG_ROCKCHIP_STIMER_BASE + \ +TIMER_CONTROL_REG ); +} +#endif +int dram_init_banksize (void ) {size_t max_size =min ((unsigned long )gd->ram_size, gd->ram_top);
include/configs/rk3399_common.h +1 -0
@@ -13,6 +13,7 @@#define CONFIG_SKIP_LOWLEVEL_INIT #define COUNTER_FREQUENCY 24000000 +#define CONFIG_ROCKCHIP_STIMER_BASE 0xff8680a0#define CONFIG_SYS_NS16550_MEM32
Signature · 1 line
2.17.1
PATCH 6/7 rockchip: rk3399: remove TPL_BOARD_INIT
In reply to Kever YangRK3399 TPL do not need a dedicate board init, print the firmware info when debug init instead.
---
arch/arm/mach-rockchip/Kconfig | 1 - arch/arm/mach-rockchip/rk3399-board-tpl.c | 9 ++------- 2 files changed, 2 insertions(+), 8 deletions(-)
arch/arm/mach-rockchip/Kconfig +0 -1
@@ -173,7 +173,6 @@ config ROCKCHIP_RK3399 imply TPL_LIBCOMMON_SUPPORT imply TPL_LIBGENERIC_SUPPORT imply TPL_SYS_MALLOC_SIMPLE - imply TPL_BOARD_INIT imply TPL_BOOTROM_SUPPORT imply TPL_DRIVERS_MISC_SUPPORT imply TPL_OF_CONTROL
arch/arm/mach-rockchip/rk3399-board-tpl.c +2 -7
@@ -31,7 +31,8 @@ void board_init_f(ulong dummy)* printhex8(0x1234); * printascii("string"); */ -debug ("U-Boot TPL board init\n" ); +printascii ("\nU-Boot TPL " PLAIN_VERSION " (" U_BOOT_DATE " - " +U_BOOT_TIME " " U_BOOT_TZ ")\n" );#endif ret =spl_early_init ();if (ret) {
@@ -58,12 +59,6 @@ u32 spl_boot_device(void)return BOOT_DEVICE_BOOTROM ; } -void spl_board_init (void ) -{ -puts ("\nU-Boot TPL " PLAIN_VERSION " (" U_BOOT_DATE " - " -U_BOOT_TIME " " U_BOOT_TZ ")\n" ); -} -#ifdef CONFIG_SPL_LOAD_FIT int board_fit_config_name_match (const char *name) {
Signature · 1 line
2.17.1
PATCH 7/7 rockchip: rk3399: use common TPL board file
In reply to Kever YangUse common tpl.c instead of rk3368-board-tpl.c
---
arch/arm/mach-rockchip/Kconfig | 1 + arch/arm/mach-rockchip/Makefile | 2 - arch/arm/mach-rockchip/rk3399-board-tpl.c | 70 ----------------------- 3 files changed, 1 insertion(+), 72 deletions(-) delete mode 100644 arch/arm/mach-rockchip/rk3399-board-tpl.c
arch/arm/mach-rockchip/Kconfig +1 -0
@@ -182,6 +182,7 @@ config ROCKCHIP_RK3399 imply TPL_RAM imply TPL_CLK imply TPL_TINY_MEMSET + imply TPL_ROCKCHIP_COMMON_BOARD help The Rockchip RK3399 is a ARM-based SoC with a dual-core Cortex-A72 and quad-core Cortex-A53.
arch/arm/mach-rockchip/Makefile +0 -2
@@ -10,8 +10,6 @@ obj-spl-$(CONFIG_ROCKCHIP_BROM_HELPER) += bootrom.o obj-tpl-$(CONFIG_ROCKCHIP_BROM_HELPER) += bootrom.o obj-tpl-$(CONFIG_TPL_ROCKCHIP_COMMON_BOARD) += tpl.o -obj-tpl-$(CONFIG_ROCKCHIP_RK3399) += rk3399-board-tpl.o - obj-spl-$(CONFIG_ROCKCHIP_RK3036) += rk3036-board-spl.o obj-spl-$(CONFIG_ROCKCHIP_RK3188) += rk3188-board-spl.o obj-spl-$(CONFIG_ROCKCHIP_RK322X) += rk322x-board-spl.o spl-boot-order.o
arch/arm/mach-rockchip/rk3399-board-tpl.c deleted +0 -70
70 lines not on this page · raw message
Signature · 1 line
2.17.1