[U-Boot] [PATCH] rockchip: rk3288: Add reset reason detection

Wadim Egorov w.egorov at phytec.de
Tue Jun 13 11:20:42 UTC 2017


Sometimes it's helpful to know the reset reason caused in the SoC.
Add reset reason detection for the RK3288 SoC.
This will set an environemt variable which represents the reset reason.

Signed-off-by: Wadim Egorov <w.egorov at phytec.de>
---
 arch/arm/mach-rockchip/rk3288-board.c | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/arch/arm/mach-rockchip/rk3288-board.c b/arch/arm/mach-rockchip/rk3288-board.c
index a354d99..8cdc7dc 100644
--- a/arch/arm/mach-rockchip/rk3288-board.c
+++ b/arch/arm/mach-rockchip/rk3288-board.c
@@ -11,6 +11,7 @@
 #include <syscon.h>
 #include <asm/io.h>
 #include <asm/arch/clock.h>
+#include <asm/arch/cru_rk3288.h>
 #include <asm/arch/periph.h>
 #include <asm/arch/pmu_rk3288.h>
 #include <asm/arch/qos_rk3288.h>
@@ -70,10 +71,37 @@ int rk3288_qos_init(void)
 	return 0;
 }
 
+static void rk3288_detect_reset_reason(void)
+{
+	struct rk3288_cru *cru = rockchip_get_cru();
+	if (IS_ERR(cru))
+		return;
+
+	switch (cru->cru_glb_rst_st) {
+	case (1 << 0):
+		setenv("reset_reason", "POR");
+		break;
+	case (1 << 1):
+		setenv("reset_reason", "RST");
+		break;
+	case (1 << 2):
+	case (1 << 3):
+		setenv("reset_reason", "THERMAL");
+		break;
+	case (1 << 4):
+	case (1 << 5):
+		setenv("reset_reason", "WDOG");
+		break;
+	default:
+		setenv("reset_reason", "unknown reset");
+	}
+}
+
 int board_late_init(void)
 {
 	setup_boot_mode();
 	rk3288_qos_init();
+	rk3288_detect_reset_reason();
 
 	return rk_board_late_init();
 }
-- 
1.9.1



More information about the U-Boot mailing list