Patchwork [U-Boot,v2,2/2] ARM: mx25: Print the source of reset

login
register
mail settings
Submitter Fabio Estevam
Date Sept. 2, 2011, 3:38 p.m.
Message ID <1314977935-2653-2-git-send-email-fabio.estevam@freescale.com>
Download mbox | patch
Permalink /patch/113163/
State Accepted
Delegated to: Stefano Babic
Headers show

Comments

Fabio Estevam - Sept. 2, 2011, 3:38 p.m.
Print the source of reset during boot.

Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
---
Changes since v1:
- Fix the logic for detecting the reset cause

 arch/arm/cpu/arm926ejs/mx25/generic.c |   25 ++++++++++++++++++++++++-
 1 files changed, 24 insertions(+), 1 deletions(-)
Stefano Babic - Sept. 9, 2011, 4:01 p.m.
On 09/02/2011 05:38 PM, Fabio Estevam wrote:
> Print the source of reset during boot.
> 
> Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
> ---
> Changes since v1:
> - Fix the logic for detecting the reset cause
> 
>  arch/arm/cpu/arm926ejs/mx25/generic.c |   25 ++++++++++++++++++++++++-
>  1 files changed, 24 insertions(+), 1 deletions(-)
> 

Applied to u-boot-imx as a fix, thanks.

Best regards,
Stefano Babic

Patch

diff --git a/arch/arm/cpu/arm926ejs/mx25/generic.c b/arch/arm/cpu/arm926ejs/mx25/generic.c
index dca8d98..ed4b3e0 100644
--- a/arch/arm/cpu/arm926ejs/mx25/generic.c
+++ b/arch/arm/cpu/arm926ejs/mx25/generic.c
@@ -105,6 +105,28 @@  ulong imx_get_perclk (int clk)
 	return lldiv (fref, div);
 }
 
+static char *get_reset_cause(void)
+{
+	/* read RCSR register from CCM module */
+	struct ccm_regs *ccm =
+		(struct ccm_regs *)IMX_CCM_BASE;
+
+	u32 cause = readl(&ccm->rcsr) & 0x0f;
+
+	if (cause == 0)
+		return "POR";
+	else if (cause == 1)
+		return "RST";
+	else if ((cause & 2) == 2)
+		return "WDOG";
+	else if ((cause & 4) == 4)
+		return "SW RESET";
+	else if ((cause & 8) == 8)
+		return "JTAG";
+	else
+		return "unknown reset";
+
+}
 
 u32 get_cpu_rev(void)
 {
@@ -136,10 +158,11 @@  int print_cpuinfo (void)
 	char buf[32];
 	u32 cpurev = get_cpu_rev();
 		
-	printf("CPU:   Freescale i.MX25 rev%d.%d%s at %s MHz\n\n",
+	printf("CPU:   Freescale i.MX25 rev%d.%d%s at %s MHz\n",
 		(cpurev & 0xF0) >> 4, (cpurev & 0x0F),
 		((cpurev & 0x8000) ? " unknown" : ""),
 		strmhz (buf, imx_get_armclk ()));
+	printf("Reset cause: %s\n\n", get_reset_cause());
 	return 0;
 }
 #endif