From: Jason Liu Date: Fri, 15 Apr 2011 15:08:26 +0800 Subject: [U-Boot] [PATCH V3 1/2] MX5: factor out boot cause funciton to common code Message-ID: <1302851307-22244-1-git-send-email-r64343@freescale.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de From: Liu Hui-R64343 factor out boot cause funciton to common code to avoid the duplicate code in each board support package Signed-off-by: Jason Liu --- arch/arm/cpu/armv7/mx5/soc.c | 18 ++++++++++++++++++ arch/arm/include/asm/arch-mx5/sys_proto.h | 1 + 2 files changed, 19 insertions(+), 0 deletions(-) diff --git a/arch/arm/cpu/armv7/mx5/soc.c b/arch/arm/cpu/armv7/mx5/soc.c index 09500b3..dddda08 100644 --- a/arch/arm/cpu/armv7/mx5/soc.c +++ b/arch/arm/cpu/armv7/mx5/soc.c @@ -77,6 +77,24 @@ u32 get_cpu_rev(void) return system_rev; } +char *get_reset_cause(void) +{ + u32 cause; + struct src *src_regs = (struct src *)SRC_BASE_ADDR; + + cause = readl(&src_regs->srsr); + switch (cause) { + case 0x0001: + return "POR"; + case 0x0009: + return "RST"; + case 0x0010: + case 0x0011: + return "WDOG"; + default: + return "unknown reset"; + } +} #if defined(CONFIG_DISPLAY_CPUINFO) int print_cpuinfo(void) diff --git a/arch/arm/include/asm/arch-mx5/sys_proto.h b/arch/arm/include/asm/arch-mx5/sys_proto.h index f687503..00c2c5d 100644 --- a/arch/arm/include/asm/arch-mx5/sys_proto.h +++ b/arch/arm/include/asm/arch-mx5/sys_proto.h @@ -27,5 +27,6 @@ u32 get_cpu_rev(void); #define is_soc_rev(rev) ((get_cpu_rev() & 0xFF) - rev) void sdelay(unsigned long); +char *get_reset_cause(void); #endif -- 1.7.1