From patchwork Wed Apr 20 10:47:04 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Hui X-Patchwork-Id: 1122 Return-Path: Delivered-To: unknown Received: from imap.gmail.com (74.125.159.109) by localhost6.localdomain6 with IMAP4-SSL; 08 Jun 2011 14:49:19 -0000 Delivered-To: patches@linaro.org Received: by 10.224.67.148 with SMTP id r20cs109104qai; Wed, 20 Apr 2011 03:47:27 -0700 (PDT) Received: by 10.68.59.228 with SMTP id c4mr3384678pbr.520.1303296446827; Wed, 20 Apr 2011 03:47:26 -0700 (PDT) Received: from mail-pz0-f50.google.com (mail-pz0-f50.google.com [209.85.210.50]) by mx.google.com with ESMTPS id a3si2444982pbm.185.2011.04.20.03.47.26 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 20 Apr 2011 03:47:26 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.210.50 is neither permitted nor denied by best guess record for domain of jason.hui@linaro.org) client-ip=209.85.210.50; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.210.50 is neither permitted nor denied by best guess record for domain of jason.hui@linaro.org) smtp.mail=jason.hui@linaro.org Received: by mail-pz0-f50.google.com with SMTP id 2so455508pzk.37 for ; Wed, 20 Apr 2011 03:47:26 -0700 (PDT) Received: by 10.68.22.1 with SMTP id z1mr10156316pbe.36.1303296446501; Wed, 20 Apr 2011 03:47:26 -0700 (PDT) Received: from localhost.localdomain ([116.231.118.83]) by mx.google.com with ESMTPS id o6sm556867pbq.89.2011.04.20.03.47.22 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 20 Apr 2011 03:47:26 -0700 (PDT) From: Jason Liu To: u-boot@lists.denx.de Cc: sbabic@denx.de Subject: [U-Boot][PATCH V5 1/2] MX5: factor out boot cause funciton to common code Date: Wed, 20 Apr 2011 18:47:04 +0800 Message-Id: <1303296425-14806-2-git-send-email-jason.hui@linaro.org> X-Mailer: git-send-email 1.7.0.4 In-Reply-To: <1303296425-14806-1-git-send-email-jason.hui@linaro.org> References: <1303296425-14806-1-git-send-email-jason.hui@linaro.org> factor out boot cause funciton to common code to avoid the duplicate code in each board support package Signed-off-by: Jason Liu --- 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(-) 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