rockchip: Separate the reset cause from display cpuinfo
Subsystems (3)
PATCH 1/5 rockchip: Separate the reset cause from display cpuinfo
reset cause is a generic functionality based on the soc cru registers in rockchip. This can be used for printing the cause of reset in cpuinfo or some other place where reset cause is needed.?
Other than cpuinfo, reset cause can also be using during bootcount for checking the specific reset cause and glow the led based on the reset cause.
So, let's separate the reset cause code from cpuinfo, and add a check to build it for rk3399, rk3288 since these two soc are supporting reset cause as of now.
--- arch/arm/include/asm/arch-rockchip/cru.h | 2 ++ arch/arm/mach-rockchip/Makefile | 5 ++++- arch/arm/mach-rockchip/cpu-info.c | 20 ++++++++++++-------- 3 files changed, 18 insertions(+), 9 deletions(-)
arch/arm/include/asm/arch-rockchip/cru.h +2 -0
@@ -27,4 +27,6 @@ enum {#define MHz 1000000 +char *get_reset_cause (void ); +#endif /* _ROCKCHIP_CLOCK_H */
arch/arm/mach-rockchip/Makefile +4 -1
@@ -15,6 +15,10 @@ obj-tpl-$(CONFIG_ROCKCHIP_PX30) += px30-board-tpl.o obj-spl-$(CONFIG_ROCKCHIP_RK3036) += rk3036-board-spl.o +ifeq ($(CONFIG_ROCKCHIP_RK3288)$(CONFIG_ROCKCHIP_RK3399), y) +obj-y += cpu-info.o +endif + ifeq ($(CONFIG_SPL_BUILD)$(CONFIG_TPL_BUILD),) # Always include boot_mode.o, as we bypass it (i.e. turn it off)
@@ -22,7 +26,6 @@ ifeq ($(CONFIG_SPL_BUILD)$(CONFIG_TPL_BUILD),) # we can have the preprocessor correctly recognise both 0x0 and 0 # meaning "turn it off". obj-y += boot_mode.o -obj-$(CONFIG_DISPLAY_CPUINFO) += cpu-info.o obj-$(CONFIG_ROCKCHIP_COMMON_BOARD) += board.o obj-$(CONFIG_MISC_INIT_R) += misc.o endif
arch/arm/mach-rockchip/cpu-info.c +12 -8
@@ -11,7 +11,7 @@#include <asm/arch-rockchip/hardware.h> #include <linux/err.h> -static char *get_reset_cause (void ) +char *get_reset_cause (void ) {struct rockchip_cru *cru =rockchip_get_cru ();char *cause =NULL ;
@@ -39,12 +39,6 @@ static char *get_reset_cause(void) cause ="unknown reset" ; } -/** -* reset_reason env is used by rk3288, due to special use case -* to figure it the boot behavior. so keep this as it is. -*/ -env_set ("reset_reason" , cause); -/* * Clear glb_rst_st, so we can determine the last reset cause * for following resets.
@@ -54,12 +48,22 @@ static char *get_reset_cause(void)return cause; } +#ifdef CONFIG_DISPLAY_CPUINFO int print_cpuinfo (void ) { +char *cause =get_reset_cause (); +printf ("SoC: Rockchip %s\n" ,CONFIG_SYS_SOC ); -printf ("Reset cause: %s\n" ,get_reset_cause ()); +printf ("Reset cause: %s\n" , cause); + +/** +* reset_reason env is used by rk3288, due to special use case +* to figure it the boot behavior. so keep this as it is. +*/ +env_set ("reset_reason" , cause);/* TODO print operating temparature and clock */ return 0 ; } +#endif
Signature · 1 line
2.17.1
PATCH 2/5 roc-rk3399-pc: Configure the leds only during POR
ROC-RK3399-PC has specific set of configurations for on-board led setup.
Due to easiness for user to know the state of the board roc-rk339-pc board code will setup the led on/off, and waiting for user to press power key.
All this needs to happen only during power-on-reset not for soft reset or WDT. So add reset cause check to POR and configure leds.
--- board/firefly/roc-pc-rk3399/roc-pc-rk3399.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
board/firefly/roc-pc-rk3399/roc-pc-rk3399.c +10 -1
@@ -33,11 +33,12 @@ out:#endif #if defined(CONFIG_TPL_BUILD ) +#include <asm/arch-rockchip/cru.h> #define PMUGRF_BASE 0xff320000#define GPIO0_BASE 0xff720000 -int board_early_init_f (void ) +void board_early_led_setup (void ) {struct rockchip_gpio_regs *const gpio0 = (void *)GPIO0_BASE ;struct rk3399_pmugrf_regs *const pmugrf = (void *)PMUGRF_BASE ;
@@ -55,7 +56,15 @@ int board_early_init_f(void)spl_gpio_output (gpio0,GPIO (BANK_A ,2 ),0 ); spl_gpio_output(gpio0, GPIO(BANK_B, 5), 1); +} + +int board_early_init_f (void ) +{ +/* Set the leds only during POR */ +if (!strcmp (get_reset_cause (),"POR" )) +board_early_led_setup ();return 0 ; } +#endif
Signature · 1 line
2.17.1
PATCH 2/5 roc-rk3399-pc: Configure the leds only during POR
As far as linux reboot is concerned, once reboot is done, there is no led status indication when in u-boot. Since its a reboot and board has entered full power mode, enabling RED led would be fine I guess.
Suniel
PATCH 3/5 rockchip: tpl: Move board_early_init_f after cpu timer
In reply to Jagan TekiCustom board_early_init_f not only deal with simple gpio configuration but also have a possibility to access clocks to process any clock related operations like checking reset cause state and etc.
So, call it once the rockchip timer initialization done instead of calling first place of board_init_f which doesn't have any rockchip init code before.
This specific concern was tested with checking reset reason via board_early_init_f, which indeed require a clk probe.
--- arch/arm/mach-rockchip/tpl.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
arch/arm/mach-rockchip/tpl.c +3 -2
@@ -50,8 +50,6 @@ void board_init_f(ulong dummy)struct udevice *dev;int ret; -board_early_init_f (); -#if defined(CONFIG_DEBUG_UART ) && defined(CONFIG_TPL_SERIAL_SUPPORT )/* * Debug UART can be used from here if required:
@@ -78,6 +76,9 @@ void board_init_f(ulong dummy)/* Init ARM arch timer in arch/arm/cpu/ */ timer_init (); +/* custom board early initialization */ +board_early_init_f (); + ret =uclass_get_device (UCLASS_RAM ,0 , &dev);if (ret) {printf ("DRAM init failed: %d\n" , ret);
Signature · 1 line
2.17.1
PATCH 4/5 rockchip: tpl: Print TPL banner at end-of board_init_f
In reply to Jagan TekiUsually printing the TPL banner various between architecture or board codes.
- Some of them would print at the end of board_init_f for making sure all initialization prior to this would happen properly. if at all there is a requirement for serial init, that happen properly since it prints all after that.
- Some of them would print at the beginning once the debug uart done. assuming this particular banner wouldn't require any serial setup code.
Rockchip TPL is following later one and printing early in board_init_f.
But, sometimes there is a use case where we can print the banner only when the board_init_early_f done.
It is because board_init_early_f has gpio configuration required for non-standard board design to glow the specific LEDs upon user interaction. These board design wouldn't recommend to print any console logs unless user interact with board via some kind of power button.
This look specific to board but since all rockchip boards use common tpl code, this seems to the desired solution. and also it is following similar initialization as rockchip SPL like
- printing banner at end of board_init_f
- debug print at early board_init_f in debug_uart_init block.
--- arch/arm/mach-rockchip/tpl.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
arch/arm/mach-rockchip/tpl.c +6 -4
@@ -60,10 +60,7 @@ void board_init_f(ulong dummy)* printascii("string"); */ debug_uart_init (); -#ifdef CONFIG_TPL_BANNER_PRINT -printascii ("\nU-Boot TPL " PLAIN_VERSION " (" U_BOOT_DATE " - " \ -U_BOOT_TIME ")\n" ); -#endif +debug ("\ntpl:debug uart enabled in %s\n" , __func__);#endif ret =spl_early_init ();if (ret) {
@@ -84,6 +81,11 @@ void board_init_f(ulong dummy)printf ("DRAM init failed: %d\n" , ret);return ; } + +#ifdef CONFIG_TPL_BANNER_PRINT +printascii ("\nU-Boot TPL " PLAIN_VERSION " (" U_BOOT_DATE " - " \ +U_BOOT_TIME ")\n" ); +#endif } int board_return_to_bootrom(struct spl_image_info *spl_image,
Signature · 1 line
2.17.1
PATCH 5/5 rockchip: spl: Move board_early_init_f after cpu timer
In reply to Jagan TekiCustom board_early_init_f not only deal with simple gpio configuration but also have a possibility to access clocks to process any clock related operations like checking reset cause state and etc.
So, call it once the rockchip timer initialization done instead of calling first place of board_init_f which doesn't have any rockchip init code before.
This specific concern was tested with checking reset reason via board_early_init_f, which indeed require a clk probe.
--- arch/arm/mach-rockchip/spl.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
arch/arm/mach-rockchip/spl.c +3 -2
@@ -120,8 +120,6 @@ void board_init_f(ulong dummy)debug ("\nspl:debug uart enabled in %s\n" , __func__);#endif -board_early_init_f (); - ret =spl_early_init ();if (ret) {printf ("spl_early_init() failed: %d\n" , ret);
@@ -135,6 +133,9 @@ void board_init_f(ulong dummy)/* Init ARM arch timer in arch/arm/cpu/armv7/arch_timer.c */ timer_init ();#endif + +board_early_init_f (); +#if !defined(CONFIG_TPL ) || defined(CONFIG_SPL_OS_BOOT )debug ("\nspl:init dram\n" ); ret =uclass_get_device (UCLASS_RAM ,0 , &dev);
Signature · 1 line
2.17.1