public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Alexey Ignatov <lexszero@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] mxs: add watchdog
Date: Wed,  8 Oct 2014 07:14:51 +0400	[thread overview]
Message-ID: <1412738091-28876-1-git-send-email-lexszero@gmail.com> (raw)

Use RTC watchdog feature as hardware watchdog.

Signed-off-by: Alexey Ignatov <lexszero@gmail.com>
---
 drivers/watchdog/Makefile     |  1 +
 drivers/watchdog/mxsrtc_wdt.c | 23 +++++++++++++++++++++++
 include/configs/mxs.h         |  4 ++++
 3 files changed, 28 insertions(+)
 create mode 100644 drivers/watchdog/mxsrtc_wdt.c

diff --git a/drivers/watchdog/Makefile b/drivers/watchdog/Makefile
index 0276a10..ffe42d1 100644
--- a/drivers/watchdog/Makefile
+++ b/drivers/watchdog/Makefile
@@ -16,3 +16,4 @@ obj-$(CONFIG_XILINX_TB_WATCHDOG) += xilinx_tb_wdt.o
 obj-$(CONFIG_BFIN_WATCHDOG)  += bfin_wdt.o
 obj-$(CONFIG_OMAP_WATCHDOG) += omap_wdt.o
 obj-$(CONFIG_DESIGNWARE_WATCHDOG) += designware_wdt.o
+obj-$(CONFIG_MXS_RTC_WATCHDOG) += mxsrtc_wdt.o
diff --git a/drivers/watchdog/mxsrtc_wdt.c b/drivers/watchdog/mxsrtc_wdt.c
new file mode 100644
index 0000000..33e7663
--- /dev/null
+++ b/drivers/watchdog/mxsrtc_wdt.c
@@ -0,0 +1,23 @@
+#include <common.h>
+#include <asm/io.h>
+#include <watchdog.h>
+#include <asm/arch/imx-regs.h>
+
+#ifdef CONFIG_MXS_RTC_WATCHDOG
+#ifndef CONFIG_WATCHDOG_TIMEOUT_MSECS
+#define CONFIG_WATCHDOG_TIMEOUT_MSECS 60000
+#endif
+void hw_watchdog_reset(void)
+{
+	struct mxs_rtc_regs *rtc_regs = (struct mxs_rtc_regs *)MXS_RTC_BASE;
+	writel(CONFIG_WATCHDOG_TIMEOUT_MSECS, &rtc_regs->hw_rtc_watchdog);
+}
+
+void hw_watchdog_init(void)
+{
+	struct mxs_rtc_regs *rtc_regs = (struct mxs_rtc_regs *)MXS_RTC_BASE;
+
+	hw_watchdog_reset();
+	writel(RTC_CTRL_WATCHDOGEN, &rtc_regs->hw_rtc_watchdog_set);
+}
+#endif
diff --git a/include/configs/mxs.h b/include/configs/mxs.h
index 8bce28f..1f1b87a 100644
--- a/include/configs/mxs.h
+++ b/include/configs/mxs.h
@@ -202,4 +202,8 @@
 #define CONFIG_EHCI_IS_TDI
 #endif
 
+#ifdef CONFIG_HW_WATCHDOG
+#define CONFIG_MXS_RTC_WATCHDOG
+#endif
+
 #endif	/* __CONFIGS_MXS_H__ */
-- 
1.8.5.3

             reply	other threads:[~2014-10-08  3:14 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-08  3:14 Alexey Ignatov [this message]
2014-10-30  9:21 ` [U-Boot] [PATCH] mxs: add watchdog Stefano Babic

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=1412738091-28876-1-git-send-email-lexszero@gmail.com \
    --to=lexszero@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