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 Liu X-Patchwork-Id: 92191 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 7239DB6FF3 for ; Wed, 20 Apr 2011 20:47:47 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 28059280B6; Wed, 20 Apr 2011 12:47:40 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id DJy5HLtVy3Mh; Wed, 20 Apr 2011 12:47:39 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 135BD280AB; Wed, 20 Apr 2011 12:47:37 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 43B5328085 for ; Wed, 20 Apr 2011 12:47:35 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 0zy12KMXZBXp for ; Wed, 20 Apr 2011 12:47:34 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mail-px0-f177.google.com (mail-px0-f177.google.com [209.85.212.177]) by theia.denx.de (Postfix) with ESMTPS id 11D6D28088 for ; Wed, 20 Apr 2011 12:47:28 +0200 (CEST) Received: by pxi10 with SMTP id 10so379579pxi.22 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 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> Subject: [U-Boot] [PATCH V5 1/2] MX5: factor out boot cause funciton to common code X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.9 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de 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