Patchwork [U-Boot,V5,1/2] MX5: factor out boot cause funciton to common code

login
register
mail settings
Submitter Jason Liu
Date April 20, 2011, 10:47 a.m.
Message ID <1303296425-14806-2-git-send-email-jason.hui@linaro.org>
Download mbox | patch
Permalink /patch/92191/
State Accepted
Commit 7517a793f0d972da1f89fb0fd7855c305e9a9804
Headers show

Comments

Jason Liu - April 20, 2011, 10:47 a.m.
factor out boot cause funciton to common code to avoid
the duplicate code in each board support package

Signed-off-by: Jason Liu <jason.hui@linaro.org>
---
change since v4:
- make common code soc specific
changes since v3:
- add full boot reset cause
---
 arch/arm/cpu/armv7/mx5/soc.c |   28 ++++++++++++++++++++++++++++
 1 files changed, 28 insertions(+), 0 deletions(-)
Stefano Babic - April 21, 2011, 5:53 p.m.
On 04/20/2011 12:47 PM, Jason Liu wrote:
> factor out boot cause funciton to common code to avoid
> the duplicate code in each board support package
> 
> Signed-off-by: Jason Liu <jason.hui@linaro.org>
> ---
> change since v4:
> - make common code soc specific
> changes since v3:
> - add full boot reset cause
> ---

Applied to u-boot-imx, thanks.

Best regards,
Stefano Babic

Patch

diff --git a/arch/arm/cpu/armv7/mx5/soc.c b/arch/arm/cpu/armv7/mx5/soc.c
index 09500b3..6f4e8db 100644
--- a/arch/arm/cpu/armv7/mx5/soc.c
+++ b/arch/arm/cpu/armv7/mx5/soc.c
@@ -77,6 +77,33 @@  u32 get_cpu_rev(void)
 	return system_rev;
 }
 
+static char *get_reset_cause(void)
+{
+	u32 cause;
+	struct src *src_regs = (struct src *)SRC_BASE_ADDR;
+
+	cause = readl(&src_regs->srsr);
+	writel(cause, &src_regs->srsr);
+
+	switch (cause) {
+	case 0x00001:
+		return "POR";
+	case 0x00004:
+		return "CSU";
+	case 0x00008:
+		return "IPP USER";
+	case 0x00010:
+		return "WDOG";
+	case 0x00020:
+		return "JTAG HIGH-Z";
+	case 0x00040:
+		return "JTAG SW";
+	case 0x10000:
+		return "WARM BOOT";
+	default:
+		return "unknown reset";
+	}
+}
 
 #if defined(CONFIG_DISPLAY_CPUINFO)
 int print_cpuinfo(void)
@@ -89,6 +116,7 @@  int print_cpuinfo(void)
 		(cpurev & 0x000F0) >> 4,
 		(cpurev & 0x0000F) >> 0,
 		mxc_get_clock(MXC_ARM_CLK) / 1000000);
+	printf("Reset cause: %s\n", get_reset_cause());
 	return 0;
 }
 #endif