From: Wadim Egorov <w.egorov@phytec.de>
To: barebox@lists.infradead.org
Subject: [PATCH v3: For next 2/2] ARM: am33xx: Add support for reset reason detection
Date: Tue, 10 Feb 2015 15:13:58 +0100 [thread overview]
Message-ID: <1423577638-27907-2-git-send-email-w.egorov@phytec.de> (raw)
In-Reply-To: <1423577638-27907-1-git-send-email-w.egorov@phytec.de>
Also activate in defconfig.
Signed-off-by: Wadim Egorov <w.egorov@phytec.de>
---
v3: Remove init wrapper
---
arch/arm/configs/am335x_defconfig | 1 +
arch/arm/mach-omap/am33xx_generic.c | 39 ++++++++++++++++++++++++
arch/arm/mach-omap/include/mach/am33xx-silicon.h | 1 +
3 files changed, 41 insertions(+)
diff --git a/arch/arm/configs/am335x_defconfig b/arch/arm/configs/am335x_defconfig
index f34a4c6..0b8f58d 100644
--- a/arch/arm/configs/am335x_defconfig
+++ b/arch/arm/configs/am335x_defconfig
@@ -24,6 +24,7 @@ CONFIG_MENU=y
CONFIG_BLSPEC=y
CONFIG_CONSOLE_ACTIVATE_NONE=y
CONFIG_DEFAULT_ENVIRONMENT_GENERIC_NEW=y
+CONFIG_RESET_SOURCE=y
CONFIG_DEBUG_INFO=y
CONFIG_LONGHELP=y
CONFIG_CMD_IOMEM=y
diff --git a/arch/arm/mach-omap/am33xx_generic.c b/arch/arm/mach-omap/am33xx_generic.c
index 912138d..21e1bd1 100644
--- a/arch/arm/mach-omap/am33xx_generic.c
+++ b/arch/arm/mach-omap/am33xx_generic.c
@@ -26,6 +26,7 @@
#include <mach/sys_info.h>
#include <mach/am33xx-generic.h>
#include <mach/gpmc.h>
+#include <reset_source.h>
void __noreturn am33xx_reset_cpu(unsigned long addr)
{
@@ -152,6 +153,44 @@ static int am33xx_bootsource(void)
return 0;
}
+static int am33xx_detect_reset_reason(void)
+{
+ uint32_t val = 0;
+
+ if (!IS_ENABLED(CONFIG_RESET_SOURCE))
+ return 0;
+
+ val = readl(AM33XX_PRM_RSTST);
+ /* clear AM33XX_PRM_RSTST - must be cleared by software
+ * (warm reset insensitive) */
+ writel(val, AM33XX_PRM_RSTST);
+
+ switch (val) {
+ case (1 << 9):
+ reset_source_set(RESET_JTAG);
+ break;
+ case (1 << 5):
+ reset_source_set(RESET_EXT);
+ break;
+ case (1 << 4):
+ case (1 << 3):
+ reset_source_set(RESET_WDG);
+ break;
+ case (1 << 1):
+ reset_source_set(RESET_RST);
+ break;
+ case (1 << 0):
+ reset_source_set(RESET_POR);
+ break;
+ default:
+ reset_source_set(RESET_UKWN);
+ break;
+ }
+
+ return 0;
+}
+device_initcall(am33xx_detect_reset_reason);
+
int am33xx_register_ethaddr(int eth_id, int mac_id)
{
void __iomem *mac_id_low = (void *)AM33XX_MAC_ID0_LO + mac_id * 8;
diff --git a/arch/arm/mach-omap/include/mach/am33xx-silicon.h b/arch/arm/mach-omap/include/mach/am33xx-silicon.h
index 4e63b43..7c209ec 100644
--- a/arch/arm/mach-omap/include/mach/am33xx-silicon.h
+++ b/arch/arm/mach-omap/include/mach/am33xx-silicon.h
@@ -68,6 +68,7 @@
#define AM33XX_PRM_RSTCTRL (AM33XX_PRM_BASE + 0x0f00)
#define AM33XX_PRM_RSTCTRL_RESET 0x1
+#define AM33XX_PRM_RSTST (AM33XX_PRM_BASE + 0x0f08)
/* CTRL */
#define AM33XX_CTRL_BASE (AM33XX_L4_WKUP_BASE + 0x210000)
--
1.9.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2015-02-10 14:15 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-02-10 14:13 [PATCH v3: For next 1/2] reset_source: Add external reset Wadim Egorov
2015-02-10 14:13 ` Wadim Egorov [this message]
2015-02-11 7:39 ` [PATCH v3: For next 2/2] ARM: am33xx: Add support for reset reason detection Sascha Hauer
2015-02-11 9:57 ` Wadim Egorov
2015-02-12 8:30 ` Sascha Hauer
2015-02-12 9:03 ` Wadim Egorov
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=1423577638-27907-2-git-send-email-w.egorov@phytec.de \
--to=w.egorov@phytec.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