From: Juergen Beisert <jbe@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH 3/4] ARM/i.MX: add support to detect the reset source
Date: Fri, 13 Jul 2012 08:04:48 +0200 [thread overview]
Message-ID: <1342159489-1474-4-git-send-email-jbe@pengutronix.de> (raw)
In-Reply-To: <1342159489-1474-1-git-send-email-jbe@pengutronix.de>
Signed-off-by: Juergen Beisert <jbe@pengutronix.de>
---
arch/arm/mach-imx/Makefile | 1 +
arch/arm/mach-imx/reset_source.c | 72 ++++++++++++++++++++++++++++++++++++++
2 files changed, 73 insertions(+)
create mode 100644 arch/arm/mach-imx/reset_source.c
diff --git a/arch/arm/mach-imx/Makefile b/arch/arm/mach-imx/Makefile
index 89a8946..d6380ba 100644
--- a/arch/arm/mach-imx/Makefile
+++ b/arch/arm/mach-imx/Makefile
@@ -1,4 +1,5 @@
obj-y += clocksource.o gpio.o
+obj-$(CONFIG_GLOBALVAR) += reset_source.o
obj-$(CONFIG_ARCH_IMX1) += speed-imx1.o imx1.o iomux-v1.o
obj-$(CONFIG_ARCH_IMX25) += speed-imx25.o imx25.o iomux-v3.o
obj-$(CONFIG_ARCH_IMX21) += speed-imx21.o imx21.o iomux-v1.o
diff --git a/arch/arm/mach-imx/reset_source.c b/arch/arm/mach-imx/reset_source.c
new file mode 100644
index 0000000..e7b2a90
--- /dev/null
+++ b/arch/arm/mach-imx/reset_source.c
@@ -0,0 +1,72 @@
+/*
+ * (C) Copyright 2012 Juergen Beisert - <kernel@pengutronix.de>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+#include <common.h>
+#include <init.h>
+#include <io.h>
+#include <reset_source.h>
+#include <mach/imx-regs.h>
+
+#ifdef CONFIG_ARCH_IMX1
+# define IMX_RESET_SRC_WDOG (1 << 1)
+# define IMX_RESET_SRC_HRDRESET (1 << 0)
+/* let the compiler sort out useless code on this arch */
+# define IMX_RESET_SRC_WARMSTART 0
+# define IMX_RESET_SRC_COLDSTART 0
+#else
+ /* WRSR checked for i.MX25, i.MX27, i.MX31, i.MX35 and i.MX51 */
+# define WDOG_WRSR 0x04
+ /* valid for i.MX25, i.MX27, i.MX31, i.MX35, i.MX51 */
+# define IMX_RESET_SRC_WARMSTART (1 << 0)
+ /* valid for i.MX25, i.MX27, i.MX31, i.MX35, i.MX51 */
+# define IMX_RESET_SRC_WDOG (1 << 1)
+ /* valid for i.MX27, i.MX31, always '0' on i.MX25, i.MX35, i.MX51 */
+# define IMX_RESET_SRC_HRDRESET (1 << 3)
+ /* valid for i.MX27, i.MX31, always '0' on i.MX25, i.MX35, i.MX51 */
+# define IMX_RESET_SRC_COLDSTART (1 << 4)
+#endif
+
+static unsigned read_detection_register(void)
+{
+#ifdef CONFIG_ARCH_IMX1
+ return readl(IMX_SYSCTRL_BASE);
+#else
+ return readw(IMX_WDT_BASE + WDOG_WRSR);
+#endif
+}
+
+static int imx_detect_reset_source(void)
+{
+ unsigned reg = read_detection_register();
+
+ if (reg & IMX_RESET_SRC_COLDSTART) {
+ set_reset_source(RESET_POR);
+ return 0;
+ }
+
+ if (reg & (IMX_RESET_SRC_HRDRESET | IMX_RESET_SRC_WARMSTART)) {
+ set_reset_source(RESET_RST);
+ return 0;
+ }
+
+ if (reg & IMX_RESET_SRC_WDOG) {
+ set_reset_source(RESET_WDG);
+ return 0;
+ }
+
+ /* else keep the default 'unknown' state */
+ return 0;
+}
+
+device_initcall(imx_detect_reset_source);
--
1.7.10.4
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2012-07-13 6:04 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-07-13 6:04 [PATCHv4] Enable a way to provide the reason for "being here" Juergen Beisert
2012-07-13 6:04 ` [PATCH 1/4] " Juergen Beisert
2012-07-16 8:37 ` Sascha Hauer
2012-07-13 6:04 ` [PATCH 2/4] ARM/Samsung: add support to detect the reset source Juergen Beisert
2012-07-13 6:04 ` Juergen Beisert [this message]
2012-07-13 6:04 ` [PATCH 4/4] ARM/MXS: add reset cause detection Juergen Beisert
-- strict thread matches above, loose matches on Subject: below --
2012-07-18 8:46 [PATCHv5] Enable a way to provide the reason for "being here" Juergen Beisert
2012-07-18 8:46 ` [PATCH 3/4] ARM/i.MX: add support to detect the reset source Juergen Beisert
2012-07-12 13:47 [PATCHv3] Enable a way to provide the reason for "being here" Juergen Beisert
2012-07-12 13:47 ` [PATCH 3/4] ARM/i.MX: add support to detect the reset source Juergen Beisert
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=1342159489-1474-4-git-send-email-jbe@pengutronix.de \
--to=jbe@pengutronix.de \
--cc=barebox@lists.infradead.org \
/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