[U-Boot] [PATCH] imx: save reset cause in 'reset_cause' environment variable

Eric Nelson eric.nelson at boundarydevices.com
Thu Feb 5 23:58:27 CET 2015


The cause of a reset is generally useful, and shouldn't be
blindly cleared in the process of displaying it as a part
of the boot announcement.

Stash the string representation in the environment variable
"reset_cause".

Values include:
	"POR"		- power on reset
	"CSU"		- reset was the result of the csu_reset_b input
	"IPP-USER"	- ipp_user_reset_b qualified reset
	"WDOG"		- watchdog reset
	"JTAG-HIGH-Z"	- HIGH-Z reset from JTAG
	"JTAG-SW"	- software reset from JTAG
	"WARM-BOOT"	- WARM boot was initiated by software

Signed-off-by: Eric Nelson <eric.nelson at boundarydevices.com>
---
 arch/arm/imx-common/cpu.c | 25 ++++++++++++++++---------
 1 file changed, 16 insertions(+), 9 deletions(-)

diff --git a/arch/arm/imx-common/cpu.c b/arch/arm/imx-common/cpu.c
index 28ccd29..4a54051 100644
--- a/arch/arm/imx-common/cpu.c
+++ b/arch/arm/imx-common/cpu.c
@@ -28,6 +28,7 @@ char *get_reset_cause(void)
 {
 	u32 cause;
 	struct src *src_regs = (struct src *)SRC_BASE_ADDR;
+	char *rval = "unknown";
 
 	cause = readl(&src_regs->srsr);
 	writel(cause, &src_regs->srsr);
@@ -35,22 +36,28 @@ char *get_reset_cause(void)
 	switch (cause) {
 	case 0x00001:
 	case 0x00011:
-		return "POR";
+		rval = "POR";
+		break;
 	case 0x00004:
-		return "CSU";
+		rval = "CSU";
+		break;
 	case 0x00008:
-		return "IPP USER";
+		rval = "IPP-USER";
+		break;
 	case 0x00010:
-		return "WDOG";
+		rval = "WDOG";
+		break;
 	case 0x00020:
-		return "JTAG HIGH-Z";
+		rval = "JTAG-HIGH-Z";
+		break;
 	case 0x00040:
-		return "JTAG SW";
+		rval = "JTAG-SW";
+		break;
 	case 0x10000:
-		return "WARM BOOT";
-	default:
-		return "unknown reset";
+		rval = "WARM-BOOT";
 	}
+	setenv("reset_cause", rval);
+	return rval;
 }
 
 #if defined(CONFIG_MX53) || defined(CONFIG_MX6)
-- 
1.9.1



More information about the U-Boot mailing list