[PATCH v2 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.
Signed-off-by: Jagan Teki jagan@amarulasolutions.com --- Changes for v2: - none
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(-)
diff --git a/arch/arm/include/asm/arch-rockchip/cru.h b/arch/arm/include/asm/arch-rockchip/cru.h index 5cf2aec11a..b2ffc57c7d 100644 --- a/arch/arm/include/asm/arch-rockchip/cru.h +++ b/arch/arm/include/asm/arch-rockchip/cru.h @@ -27,4 +27,6 @@ enum {
#define MHz 1000000
+char *get_reset_cause(void); + #endif /* _ROCKCHIP_CLOCK_H */ diff --git a/arch/arm/mach-rockchip/Makefile b/arch/arm/mach-rockchip/Makefile index 5b38526fe0..ef4898e00c 100644 --- a/arch/arm/mach-rockchip/Makefile +++ b/arch/arm/mach-rockchip/Makefile @@ -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 diff --git a/arch/arm/mach-rockchip/cpu-info.c b/arch/arm/mach-rockchip/cpu-info.c index 4b0e99299a..ee0ec3d082 100644 --- a/arch/arm/mach-rockchip/cpu-info.c +++ b/arch/arm/mach-rockchip/cpu-info.c @@ -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

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 low power led on/off, and waiting for user to press power key and then glow full power led.
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 the low power leds, power key only. Note that the glowing red led is common across any reset.
Reported-by: Markus Reichl m.reichl@fivetechno.de Signed-off-by: Jagan Teki jagan@amarulasolutions.com --- Changes for v2: - glow red led to common across reboots
board/firefly/roc-pc-rk3399/roc-pc-rk3399.c | 24 ++++++++++++--------- 1 file changed, 14 insertions(+), 10 deletions(-)
diff --git a/board/firefly/roc-pc-rk3399/roc-pc-rk3399.c b/board/firefly/roc-pc-rk3399/roc-pc-rk3399.c index de9185a7ce..6cc81952d8 100644 --- a/board/firefly/roc-pc-rk3399/roc-pc-rk3399.c +++ b/board/firefly/roc-pc-rk3399/roc-pc-rk3399.c @@ -33,6 +33,7 @@ out: #endif
#if defined(CONFIG_TPL_BUILD) +#include <asm/arch-rockchip/cru.h>
#define PMUGRF_BASE 0xff320000 #define GPIO0_BASE 0xff720000 @@ -42,18 +43,21 @@ int board_early_init_f(void) struct rockchip_gpio_regs * const gpio0 = (void *)GPIO0_BASE; struct rk3399_pmugrf_regs * const pmugrf = (void *)PMUGRF_BASE;
- /** - * 1. Glow yellow LED, termed as low power - * 2. Poll for on board power key press - * 3. Once 2 done, off yellow and glow red LED, termed as full power - * 4. Continue booting... - */ - spl_gpio_output(gpio0, GPIO(BANK_A, 2), 1); + /* Set the low power leds, power key only during POR */ + if (!strcmp(get_reset_cause(), "POR")) { + /* 1. Glow yellow LED, termed as low power */ + spl_gpio_output(gpio0, GPIO(BANK_A, 2), 1);
- spl_gpio_set_pull(&pmugrf->gpio0_p, GPIO(BANK_A, 5), GPIO_PULL_NORMAL); - while (readl(&gpio0->ext_port) & 0x20); + /* 2. Poll for on board power key press */ + spl_gpio_set_pull(&pmugrf->gpio0_p, + GPIO(BANK_A, 5), GPIO_PULL_NORMAL); + while (readl(&gpio0->ext_port) & 0x20);
- spl_gpio_output(gpio0, GPIO(BANK_A, 2), 0); + /* 3. Once 2 done, turn off yellow */ + spl_gpio_output(gpio0, GPIO(BANK_A, 2), 0); + } + + /* 4. Turn on red LED, termed as full power */ spl_gpio_output(gpio0, GPIO(BANK_B, 5), 1);
return 0;

On Thu, Mar 19, 2020 at 3:43 PM Jagan Teki jagan@amarulasolutions.com wrote:
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 low power led on/off, and waiting for user to press power key and then glow full power led.
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 the low power leds, power key only. Note that the glowing red led is common across any reset.
Reported-by: Markus Reichl m.reichl@fivetechno.de Signed-off-by: Jagan Teki jagan@amarulasolutions.com
Changes for v2:
- glow red led to common across reboots
board/firefly/roc-pc-rk3399/roc-pc-rk3399.c | 24 ++++++++++++--------- 1 file changed, 14 insertions(+), 10 deletions(-)
diff --git a/board/firefly/roc-pc-rk3399/roc-pc-rk3399.c b/board/firefly/roc-pc-rk3399/roc-pc-rk3399.c index de9185a7ce..6cc81952d8 100644 --- a/board/firefly/roc-pc-rk3399/roc-pc-rk3399.c +++ b/board/firefly/roc-pc-rk3399/roc-pc-rk3399.c @@ -33,6 +33,7 @@ out: #endif
#if defined(CONFIG_TPL_BUILD) +#include <asm/arch-rockchip/cru.h>
#define PMUGRF_BASE 0xff320000 #define GPIO0_BASE 0xff720000 @@ -42,18 +43,21 @@ int board_early_init_f(void) struct rockchip_gpio_regs * const gpio0 = (void *)GPIO0_BASE; struct rk3399_pmugrf_regs * const pmugrf = (void *)PMUGRF_BASE;
/**
* 1. Glow yellow LED, termed as low power
* 2. Poll for on board power key press
* 3. Once 2 done, off yellow and glow red LED, termed as full power
* 4. Continue booting...
*/
spl_gpio_output(gpio0, GPIO(BANK_A, 2), 1);
/* Set the low power leds, power key only during POR */
if (!strcmp(get_reset_cause(), "POR")) {
/* 1. Glow yellow LED, termed as low power */
spl_gpio_output(gpio0, GPIO(BANK_A, 2), 1);
spl_gpio_set_pull(&pmugrf->gpio0_p, GPIO(BANK_A, 5), GPIO_PULL_NORMAL);
while (readl(&gpio0->ext_port) & 0x20);
/* 2. Poll for on board power key press */
spl_gpio_set_pull(&pmugrf->gpio0_p,
GPIO(BANK_A, 5), GPIO_PULL_NORMAL);
while (readl(&gpio0->ext_port) & 0x20);
spl_gpio_output(gpio0, GPIO(BANK_A, 2), 0);
/* 3. Once 2 done, turn off yellow */
spl_gpio_output(gpio0, GPIO(BANK_A, 2), 0);
}
/* 4. Turn on red LED, termed as full power */ spl_gpio_output(gpio0, GPIO(BANK_B, 5), 1); return 0;
-- 2.17.1
Tested-by: Suniel Mahesh sunil@amarulasolutions.com

Custom 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.
Signed-off-by: Jagan Teki jagan@amarulasolutions.com --- Changes for v2: - none
arch/arm/mach-rockchip/tpl.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/arch/arm/mach-rockchip/tpl.c b/arch/arm/mach-rockchip/tpl.c index a2b8d31cbd..fab85dff7d 100644 --- a/arch/arm/mach-rockchip/tpl.c +++ b/arch/arm/mach-rockchip/tpl.c @@ -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);

On Thu, Mar 19, 2020 at 3:43 PM Jagan Teki jagan@amarulasolutions.com wrote:
Custom 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.
Signed-off-by: Jagan Teki jagan@amarulasolutions.com
Changes for v2:
- none
arch/arm/mach-rockchip/tpl.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/arch/arm/mach-rockchip/tpl.c b/arch/arm/mach-rockchip/tpl.c index a2b8d31cbd..fab85dff7d 100644 --- a/arch/arm/mach-rockchip/tpl.c +++ b/arch/arm/mach-rockchip/tpl.c @@ -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);
-- 2.17.1
Tested-by: Suniel Mahesh sunil@amarulasolutions.com

Usually 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.
Signed-off-by: Jagan Teki jagan@amarulasolutions.com --- Changes for v2: - none
arch/arm/mach-rockchip/tpl.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/arch/arm/mach-rockchip/tpl.c b/arch/arm/mach-rockchip/tpl.c index fab85dff7d..a9eb27d788 100644 --- a/arch/arm/mach-rockchip/tpl.c +++ b/arch/arm/mach-rockchip/tpl.c @@ -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,

On Thu, Mar 19, 2020 at 3:43 PM Jagan Teki jagan@amarulasolutions.com wrote:
Usually 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.
Signed-off-by: Jagan Teki jagan@amarulasolutions.com
Changes for v2:
- none
arch/arm/mach-rockchip/tpl.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/arch/arm/mach-rockchip/tpl.c b/arch/arm/mach-rockchip/tpl.c index fab85dff7d..a9eb27d788 100644 --- a/arch/arm/mach-rockchip/tpl.c +++ b/arch/arm/mach-rockchip/tpl.c @@ -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,
2.17.1
Tested-by: Suniel Mahesh sunil@amarulasolutions.com

Custom 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.
Signed-off-by: Jagan Teki jagan@amarulasolutions.com --- Changes for v2: - none
arch/arm/mach-rockchip/spl.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/arch/arm/mach-rockchip/spl.c b/arch/arm/mach-rockchip/spl.c index 48ab0e60c6..4b4e756247 100644 --- a/arch/arm/mach-rockchip/spl.c +++ b/arch/arm/mach-rockchip/spl.c @@ -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);

On Thu, Mar 19, 2020 at 3:43 PM Jagan Teki jagan@amarulasolutions.com wrote:
Custom 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.
Signed-off-by: Jagan Teki jagan@amarulasolutions.com
Changes for v2:
- none
arch/arm/mach-rockchip/spl.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/arch/arm/mach-rockchip/spl.c b/arch/arm/mach-rockchip/spl.c index 48ab0e60c6..4b4e756247 100644 --- a/arch/arm/mach-rockchip/spl.c +++ b/arch/arm/mach-rockchip/spl.c @@ -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); -- 2.17.1
Tested-by: Suniel Mahesh sunil@amarulasolutions.com

On Thu, Mar 19, 2020 at 3:43 PM Jagan Teki jagan@amarulasolutions.com wrote:
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.
Signed-off-by: Jagan Teki jagan@amarulasolutions.com
Changes for v2:
- none
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(-)
diff --git a/arch/arm/include/asm/arch-rockchip/cru.h b/arch/arm/include/asm/arch-rockchip/cru.h index 5cf2aec11a..b2ffc57c7d 100644 --- a/arch/arm/include/asm/arch-rockchip/cru.h +++ b/arch/arm/include/asm/arch-rockchip/cru.h @@ -27,4 +27,6 @@ enum {
#define MHz 1000000
+char *get_reset_cause(void);
#endif /* _ROCKCHIP_CLOCK_H */ diff --git a/arch/arm/mach-rockchip/Makefile b/arch/arm/mach-rockchip/Makefile index 5b38526fe0..ef4898e00c 100644 --- a/arch/arm/mach-rockchip/Makefile +++ b/arch/arm/mach-rockchip/Makefile @@ -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 diff --git a/arch/arm/mach-rockchip/cpu-info.c b/arch/arm/mach-rockchip/cpu-info.c index 4b0e99299a..ee0ec3d082 100644 --- a/arch/arm/mach-rockchip/cpu-info.c +++ b/arch/arm/mach-rockchip/cpu-info.c @@ -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
2.17.1
Tested-by: Suniel Mahesh sunil@amarulasolutions.com

On 2020/3/19 下午6:12, Jagan Teki wrote:
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.
Signed-off-by: Jagan Teki jagan@amarulasolutions.com
Changes for v2:
none
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(-)
diff --git a/arch/arm/include/asm/arch-rockchip/cru.h b/arch/arm/include/asm/arch-rockchip/cru.h index 5cf2aec11a..b2ffc57c7d 100644 --- a/arch/arm/include/asm/arch-rockchip/cru.h +++ b/arch/arm/include/asm/arch-rockchip/cru.h @@ -27,4 +27,6 @@ enum {
#define MHz 1000000
+char *get_reset_cause(void);
- #endif /* _ROCKCHIP_CLOCK_H */
diff --git a/arch/arm/mach-rockchip/Makefile b/arch/arm/mach-rockchip/Makefile index 5b38526fe0..ef4898e00c 100644 --- a/arch/arm/mach-rockchip/Makefile +++ b/arch/arm/mach-rockchip/Makefile @@ -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
I would prefer to keep this instead of only available for rk3288/rk3399,
because other SoCs also support this feature.
Thanks,
- Kever
obj-$(CONFIG_ROCKCHIP_COMMON_BOARD) += board.o obj-$(CONFIG_MISC_INIT_R) += misc.o endif diff --git a/arch/arm/mach-rockchip/cpu-info.c b/arch/arm/mach-rockchip/cpu-info.c index 4b0e99299a..ee0ec3d082 100644 --- a/arch/arm/mach-rockchip/cpu-info.c +++ b/arch/arm/mach-rockchip/cpu-info.c @@ -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
participants (3)
-
Jagan Teki
-
Kever Yang
-
Suniel Mahesh