Skip to contentSkip to conversation

rockchip: Separate the reset cause from display cpuinfo

PATCH New Jagan Teki 3 participants 11 messages Mar 19, 2020 – Apr 2, 2020

Subsystems (3)
lore
Share & tools
lore

Jagan Teki

author
#0 lore raw

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.

---
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(-)
arch/arm/include/asm/arch-rockchip/cru.h +2 -0
index 5cf2aec11a..b2ffc57c7d 100644
@@ -27,4 +27,6 @@ enum {
 
 #define MHz		1000000
 
+char *get_reset_cause(void);
+
 #endif /* _ROCKCHIP_CLOCK_H */
arch/arm/mach-rockchip/Makefile +4 -1
index 5b38526fe0..ef4898e00c 100644
@@ -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
index 4b0e99299a..ee0ec3d082 100644
@@ -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
author
#1 lore raw

PATCH v2 2/5 roc-rk3399-pc: Set low power leds, power key only if 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 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.

---
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(-)
board/firefly/roc-pc-rk3399/roc-pc-rk3399.c +14 -10
index de9185a7ce..6cc81952d8 100644
@@ -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;
Signature · 1 line
2.17.1
#2 lore raw

PATCH v2 2/5 roc-rk3399-pc: Set low power leds, power key only if POR

Quoted 68 lines · Jagan Teki

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.

---
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(-)
board/firefly/roc-pc-rk3399/roc-pc-rk3399.c +14 -11
index de9185a7ce..6cc81952d8 100644
@@ -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;
--
Quoted 2 lines

2.17.1

author
#3 lore raw

PATCH v2 3/5 rockchip: tpl: Move board_early_init_f after cpu timer

In reply to Jagan Teki

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.

---
Changes for v2:
- none

 arch/arm/mach-rockchip/tpl.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
arch/arm/mach-rockchip/tpl.c +3 -2
index a2b8d31cbd..fab85dff7d 100644
@@ -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
#4 lore raw

PATCH v2 3/5 rockchip: tpl: Move board_early_init_f after cpu timer

Quoted 45 lines · Jagan Teki

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.

---
Changes for v2:
- none

 arch/arm/mach-rockchip/tpl.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
arch/arm/mach-rockchip/tpl.c +3 -3
index a2b8d31cbd..fab85dff7d 100644
@@ -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);
--
Quoted 2 lines

2.17.1

author
#5 lore raw

PATCH v2 4/5 rockchip: tpl: Print TPL banner at end-of board_init_f

In reply to Jagan Teki

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.

---
Changes for v2:
- none

 arch/arm/mach-rockchip/tpl.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
arch/arm/mach-rockchip/tpl.c +6 -4
index fab85dff7d..a9eb27d788 100644
@@ -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
#6 lore raw

PATCH v2 4/5 rockchip: tpl: Print TPL banner at end-of board_init_f

Quoted 66 lines · Jagan Teki

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.

---
Changes for v2:
- none

 arch/arm/mach-rockchip/tpl.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
arch/arm/mach-rockchip/tpl.c +6 -5
index fab85dff7d..a9eb27d788 100644
@@ -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,
--
Quoted 2 lines

2.17.1

author
#7 lore raw

PATCH v2 5/5 rockchip: spl: Move board_early_init_f after cpu timer

In reply to Jagan Teki

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.

---
Changes for v2:
- none

 arch/arm/mach-rockchip/spl.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
arch/arm/mach-rockchip/spl.c +3 -2
index 48ab0e60c6..4b4e756247 100644
@@ -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
#8 lore raw

PATCH v2 5/5 rockchip: spl: Move board_early_init_f after cpu timer

Quoted 45 lines · Jagan Teki

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.

---
Changes for v2:
- none

 arch/arm/mach-rockchip/spl.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
arch/arm/mach-rockchip/spl.c +3 -3
index 48ab0e60c6..4b4e756247 100644
@@ -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);
--
Quoted 2 lines

2.17.1

#9 lore raw

PATCH v2 1/5 rockchip: Separate the reset cause from display cpuinfo

In reply to Jagan Teki
Quoted 109 lines · Jagan Teki

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.

---
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(-)
arch/arm/include/asm/arch-rockchip/cru.h +2 -0
index 5cf2aec11a..b2ffc57c7d 100644
@@ -27,4 +27,6 @@ enum {
 
 #define MHz            1000000
 
+char *get_reset_cause(void);
+
 #endif /* _ROCKCHIP_CLOCK_H */
arch/arm/mach-rockchip/Makefile +4 -1
index 5b38526fe0..ef4898e00c 100644
@@ -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 -9
index 4b0e99299a..ee0ec3d082 100644
@@ -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
--
Quoted 2 lines

2.17.1

#10 lore raw

PATCH v2 1/5 rockchip: Separate the reset cause from display cpuinfo

In reply to Jagan Teki
Quoted 50 lines · Jagan Teki

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.

---
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(-)
arch/arm/include/asm/arch-rockchip/cru.h +2 -0
index 5cf2aec11a..b2ffc57c7d 100644
@@ -27,4 +27,6 @@ enum {
 
  #define MHz		1000000
 
+char *get_reset_cause(void);
+
  #endif /* _ROCKCHIP_CLOCK_H */
arch/arm/mach-rockchip/Makefile +4 -0
index 5b38526fe0..ef4898e00c 100644
@@ -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)

arch/arm/mach-rockchip/Makefile ifeq ($(CONFIG_SPL_BUILD)$(CONFIG_TPL_BUILD),) · line 25

Quoted 4 lines
arch/arm/mach-rockchip/Makefile +0 -1
@@ -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

Quoted 53 lines
arch/arm/mach-rockchip/Makefile +0 -0
  obj-$(CONFIG_ROCKCHIP_COMMON_BOARD) += board.o
  obj-$(CONFIG_MISC_INIT_R) += misc.o
  endif
arch/arm/mach-rockchip/cpu-info.c +12 -8
index 4b0e99299a..ee0ec3d082 100644
@@ -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