summaryrefslogtreecommitdiffstats
path: root/drivers/watchdog
diff options
context:
space:
mode:
authorJuergen Beisert <jbe@pengutronix.de>2012-07-18 10:46:50 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2012-07-18 16:21:43 +0200
commit15d989e83d84ba13c100fbfe60980d22bf807fea (patch)
tree4a3d5475a1876380c68d8081f48d826cfd0b7057 /drivers/watchdog
parent67e4d52b4070fe66a680aae4aebf221561e81808 (diff)
downloadbarebox-15d989e83d84ba13c100fbfe60980d22bf807fea.tar.gz
ARM/MXS: add reset cause detection
Signed-off-by: Juergen Beisert <jbe@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers/watchdog')
-rw-r--r--drivers/watchdog/im28wd.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/drivers/watchdog/im28wd.c b/drivers/watchdog/im28wd.c
index b016910..1f987de 100644
--- a/drivers/watchdog/im28wd.c
+++ b/drivers/watchdog/im28wd.c
@@ -21,6 +21,7 @@
#include <errno.h>
#include <malloc.h>
#include <watchdog.h>
+#include <reset_source.h>
#define MXS_RTC_CTRL 0x0
#define MXS_RTC_SET_ADDR 0x4
@@ -73,6 +74,27 @@ static int imx28_watchdog_set_timeout(struct watchdog *wd, unsigned timeout)
return 0;
}
+static void __maybe_unused imx28_detect_reset_source(const struct imx28_wd *p)
+{
+ u32 reg;
+
+ reg = readl(p->regs + MXS_RTC_PERSISTENT0);
+ if (reg & MXS_RTC_PERSISTENT0_EXT_RST) {
+ writel(MXS_RTC_PERSISTENT0_EXT_RST,
+ p->regs + MXS_RTC_PERSISTENT0 + MXS_RTC_CLR_ADDR);
+ set_reset_source(RESET_POR);
+ return;
+ }
+ if (reg & MXS_RTC_PERSISTENT0_THM_RST) {
+ writel(MXS_RTC_PERSISTENT0_THM_RST,
+ p->regs + MXS_RTC_PERSISTENT0 + MXS_RTC_CLR_ADDR);
+ set_reset_source(RESET_RST);
+ return;
+ }
+
+ set_reset_source(RESET_RST);
+}
+
static int imx28_wd_probe(struct device_d *dev)
{
struct imx28_wd *priv;
@@ -94,6 +116,9 @@ static int imx28_wd_probe(struct device_d *dev)
if (rc != 0)
goto on_error;
+ if (IS_ENABLED(CONFIG_RESET_SOURCE))
+ imx28_detect_reset_source(priv);
+
dev->priv = priv;
return 0;