public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Fabio Estevam <festevam@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v3 2/3] MX31: Introduce get_reset_cause()
Date: Thu, 14 Apr 2011 23:21:48 -0300	[thread overview]
Message-ID: <1302834109-15171-2-git-send-email-festevam@gmail.com> (raw)
In-Reply-To: <1302834109-15171-1-git-send-email-festevam@gmail.com>

Introduce get_reset_cause() function to indicate the source of the reset.

Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
---
 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 <asm/types.h>
 
+extern char *get_reset_cause(void);
+
 /* Clock control module registers */
 struct clock_control_regs {
 	u32 ccmr;
-- 
1.6.0.4

  reply	other threads:[~2011-04-15  2:21 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-15  2:21 [U-Boot] [PATCH v3 1/3] ARM: MX31: Fix file name label Fabio Estevam
2011-04-15  2:21 ` Fabio Estevam [this message]
2011-04-15  2:21   ` [U-Boot] [PATCH v3 3/3] MX31: mx31pdk: Print the cause of reset Fabio Estevam
2011-04-15 18:18   ` [U-Boot] [PATCH v3 2/3] MX31: Introduce get_reset_cause() Stefano Babic
2011-04-18  9:02     ` Detlev Zundel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1302834109-15171-2-git-send-email-festevam@gmail.com \
    --to=festevam@gmail.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox