]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
MX5: factor out boot cause funciton to common code
authorJason Liu <jason.hui@linaro.org>
Wed, 20 Apr 2011 00:47:04 +0000 (00:47 +0000)
committerAlbert ARIBAUD <albert.u.boot@aribaud.net>
Wed, 27 Apr 2011 17:38:05 +0000 (19:38 +0200)
factor out boot cause function to common code to avoid
the duplicate code in each board support package

Signed-off-by: Jason Liu <jason.hui@linaro.org>
arch/arm/cpu/armv7/mx5/soc.c

index 09500b3b9f4d0eaa5a98dfaf62e19f10a82425f6..6f4e8db74d0ffa589e40274230b2fe93c465aa8e 100644 (file)
@@ -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