public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Simon Kagstrom <simon.kagstrom@netinsight.net>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 2/2]: arm:kirkwood: Add hardware watchdog support for Marvell Kirkwood boards
Date: Wed, 28 Oct 2009 15:15:58 +0100	[thread overview]
Message-ID: <20091028151558.4b47532b@marrow.netinsight.se> (raw)
In-Reply-To: <20091028151105.2c167d01@marrow.netinsight.se>

Initialize by calling the generic API watchdog_enable() with the number
of seconds for the watchdog to timeout. It's not possible to disable the
watchdog once it's on.

Signed-off-by: Simon Kagstrom <simon.kagstrom@netinsight.net>
---
ChangeLog:

 v2: (Some of the comments from Prafulla)
   * Use readl/writel
   * Rename WATCHDOG_CNTR -> WATCHDOG_TMR

 cpu/arm926ejs/kirkwood/timer.c |   37 +++++++++++++++++++++++++++++++++++++
 1 files changed, 37 insertions(+), 0 deletions(-)

diff --git a/cpu/arm926ejs/kirkwood/timer.c b/cpu/arm926ejs/kirkwood/timer.c
index 817ff42..797ab04 100644
--- a/cpu/arm926ejs/kirkwood/timer.c
+++ b/cpu/arm926ejs/kirkwood/timer.c
@@ -23,8 +23,10 @@
 
 #include <common.h>
 #include <asm/arch/kirkwood.h>
+#include <watchdog.h>
 
 #define UBOOT_CNTR	0	/* counter to use for uboot timer */
+#define WATCHDOG_TMR	2
 
 /* Timer reload and current value registers */
 struct kwtmr_val {
@@ -166,3 +168,38 @@ int timer_init(void)
 
 	return 0;
 }
+
+#if defined(CONFIG_HW_WATCHDOG)
+static unsigned long watchdog_timeout = 5;
+void hw_watchdog_reset(void)
+{
+	u32 time = CONFIG_SYS_TCLK * watchdog_timeout;
+
+	writel(time, CNTMR_VAL_REG(WATCHDOG_TMR));
+}
+
+void watchdog_enable(unsigned int timeout_secs)
+{
+	struct kwcpu_registers *cpureg =
+		(struct kwcpu_registers *)KW_CPU_REG_BASE;
+	u32 rstoutn_mask;
+	u32 cntmrctrl;
+
+	watchdog_timeout = timeout_secs;
+	/* Enable CPU reset if watchdog expires */
+	rstoutn_mask = readl(cpureg->rstoutn_mask);
+	writel(rstoutn_mask |= WATCHDOG_TMR, &cpureg->rstoutn_mask);
+	hw_watchdog_reset();
+
+	/* Enable the watchdog */
+	cntmrctrl = readl(CNTMR_CTRL_REG);
+	cntmrctrl |= CTCR_ARM_TIMER_EN(WATCHDOG_TMR);
+	cntmrctrl |= CTCR_ARM_TIMER_AUTO_EN(WATCHDOG_TMR);
+	writel(cntmrctrl, CNTMR_CTRL_REG);
+}
+
+void watchdog_disable(void)
+{
+	/* Can't be done */
+}
+#endif
-- 
1.6.0.4

  parent reply	other threads:[~2009-10-28 14:15 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-10-28 14:11 [U-Boot] [PATCH 0/2]: Watchdog support from the command line Simon Kagstrom
2009-10-28 14:14 ` [U-Boot] [PATCH 1/2]: common: Add a watchdog CLI command Simon Kagstrom
2009-10-28 14:29   ` Prafulla Wadaskar
2009-10-28 14:49     ` Simon Kagstrom
2009-10-28 15:56       ` Wolfgang Denk
2009-10-28 14:15 ` Simon Kagstrom [this message]
2009-10-28 15:41   ` [U-Boot] [PATCH 2/2]: arm:kirkwood: Add hardware watchdog support for Marvell Kirkwood boards Prafulla Wadaskar
2009-10-29  8:07 ` [U-Boot] [PATCH v2 0/2]: Watchdog support from the command line Simon Kagstrom
2009-10-29  8:09   ` [U-Boot] [PATCH v2 1/2]: common: Add a watchdog CLI command Simon Kagstrom
2009-10-29  8:29     ` Prafulla Wadaskar
2009-11-06  9:28     ` Simon Kagstrom
2009-11-06  9:34       ` Prafulla Wadaskar
2009-11-06 11:18       ` Mike Frysinger
2009-10-29  8:11   ` [U-Boot] [PATCH v2 2/2]: arm:kirkwood: Add hardware watchdog support for Marvell Kirkwood boards Simon Kagstrom
2009-10-29  8:32     ` Prafulla Wadaskar

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=20091028151558.4b47532b@marrow.netinsight.se \
    --to=simon.kagstrom@netinsight.net \
    --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