From patchwork Fri Apr 15 02:21:48 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabio Estevam X-Patchwork-Id: 91315 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 D58C4B6FD2 for ; Fri, 15 Apr 2011 12:22:18 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id EF0F9283B1; Fri, 15 Apr 2011 04:22:12 +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 Z9aFR-qy-eTi; Fri, 15 Apr 2011 04:22:12 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id DA413283B4; Fri, 15 Apr 2011 04:22:03 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id C87452839F for ; Fri, 15 Apr 2011 04:22:01 +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 5JvraIDQoUQN for ; Fri, 15 Apr 2011 04:22:01 +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-yx0-f172.google.com (mail-yx0-f172.google.com [209.85.213.172]) by theia.denx.de (Postfix) with ESMTPS id 05CFC283A5 for ; Fri, 15 Apr 2011 04:21:59 +0200 (CEST) Received: by yxk30 with SMTP id 30so1015325yxk.3 for ; Thu, 14 Apr 2011 19:21:58 -0700 (PDT) Received: by 10.150.68.31 with SMTP id q31mr2099009yba.149.1302834118575; Thu, 14 Apr 2011 19:21:58 -0700 (PDT) Received: from localhost.localdomain ([201.82.76.9]) by mx.google.com with ESMTPS id p28sm2956396ybk.15.2011.04.14.19.21.56 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 14 Apr 2011 19:21:58 -0700 (PDT) From: Fabio Estevam To: u-boot@lists.denx.de Date: Thu, 14 Apr 2011 23:21:48 -0300 Message-Id: <1302834109-15171-2-git-send-email-festevam@gmail.com> X-Mailer: git-send-email 1.6.0.4 In-Reply-To: <1302834109-15171-1-git-send-email-festevam@gmail.com> References: <1302834109-15171-1-git-send-email-festevam@gmail.com> Cc: albert.aribaud@free.fr, Fabio Estevam , Fabio Estevam Subject: [U-Boot] [PATCH v3 2/3] MX31: Introduce get_reset_cause() 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 Introduce get_reset_cause() function to indicate the source of the reset. Signed-off-by: Fabio Estevam --- arch/arm/cpu/arm1136/mx31/generic.c | 26 ++++++++++++++++++++++++++ arch/arm/include/asm/arch-mx31/imx-regs.h | 2 ++ 2 files changed, 28 insertions(+), 0 deletions(-) diff --git a/arch/arm/cpu/arm1136/mx31/generic.c b/arch/arm/cpu/arm1136/mx31/generic.c index 9b7a7a2..ea452a9 100644 --- a/arch/arm/cpu/arm1136/mx31/generic.c +++ b/arch/arm/cpu/arm1136/mx31/generic.c @@ -132,6 +132,32 @@ char *get_cpu_rev(void) return "unknown"; } +char *get_reset_cause(void) +{ + /* read SRS register from CCM module */ + struct clock_control_regs *ccm = + (struct clock_control_regs *)CCM_BASE; + + u32 cause = readl(&ccm->rcsr) & 0x07; + + switch (cause) { + case 0x0000: + return "POR"; + break; + case 0x0001: + return "RST"; + break; + case 0x0002: + return "WDOG"; + break; + case 0x0006: + return "JTAG"; + break; + default: + return "unknown reset"; + } +} + #if defined(CONFIG_DISPLAY_CPUINFO) int print_cpuinfo (void) { diff --git a/arch/arm/include/asm/arch-mx31/imx-regs.h b/arch/arm/include/asm/arch-mx31/imx-regs.h index 74444f2..2b0881d 100644 --- a/arch/arm/include/asm/arch-mx31/imx-regs.h +++ b/arch/arm/include/asm/arch-mx31/imx-regs.h @@ -27,6 +27,8 @@ #if !(defined(__KERNEL_STRICT_NAMES) || defined(__ASSEMBLY__)) #include +extern char *get_reset_cause(void); + /* Clock control module registers */ struct clock_control_regs { u32 ccmr;