public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] arm:kirkwood: Add hardware watchdog support for Marvell Kirkwood boards
@ 2009-09-28  7:06 Simon Kagstrom
  2009-09-28 12:36 ` Tom
                   ` (2 more replies)
  0 siblings, 3 replies; 16+ messages in thread
From: Simon Kagstrom @ 2009-09-28  7:06 UTC (permalink / raw)
  To: u-boot

Initialize by calling kw_watchdog_init() with the number of seconds for
the watchdog to timeout.

Signed-off-by: Simon Kagstrom <simon.kagstrom@netinsight.net>
---
 cpu/arm926ejs/kirkwood/timer.c      |   29 +++++++++++++++++++++++++++++
 include/asm-arm/arch-kirkwood/cpu.h |    2 ++
 2 files changed, 31 insertions(+), 0 deletions(-)

diff --git a/cpu/arm926ejs/kirkwood/timer.c b/cpu/arm926ejs/kirkwood/timer.c
index 817ff42..f3397e7 100644
--- a/cpu/arm926ejs/kirkwood/timer.c
+++ b/cpu/arm926ejs/kirkwood/timer.c
@@ -25,6 +25,7 @@
 #include <asm/arch/kirkwood.h>
 
 #define UBOOT_CNTR	0	/* counter to use for uboot timer */
+#define WATCHDOG_CNTR	2
 
 /* Timer reload and current value registers */
 struct kwtmr_val {
@@ -166,3 +167,31 @@ int timer_init(void)
 
 	return 0;
 }
+
+#if defined(CONFIG_HW_WATCHDOG)
+static unsigned long watchdog_timeout = 5;
+void hw_watchdog_reset(void)
+{
+	unsigned long time = CONFIG_SYS_TCLK * watchdog_timeout;
+
+	writel(time, CNTMR_VAL_REG(WATCHDOG_CNTR));
+}
+
+void kw_watchdog_init(unsigned long timeout_secs)
+{
+	struct kwcpu_registers *cpureg =
+		(struct kwcpu_registers *)KW_CPU_REG_BASE;
+	unsigned int cntmrctrl;
+
+	watchdog_timeout = timeout_secs;
+	/* Enable CPU reset if watchdog expires */
+	cpureg->rstoutn_mask |= WATCHDOG_CNTR;
+	hw_watchdog_reset();
+
+	/* Enable the watchdog */
+	cntmrctrl = readl(CNTMR_CTRL_REG);
+	cntmrctrl |= CTCR_ARM_TIMER_EN(WATCHDOG_CNTR);
+	cntmrctrl |= CTCR_ARM_TIMER_AUTO_EN(WATCHDOG_CNTR);
+	writel(cntmrctrl, CNTMR_CTRL_REG);
+}
+#endif
diff --git a/include/asm-arm/arch-kirkwood/cpu.h b/include/asm-arm/arch-kirkwood/cpu.h
index b3022a3..df49c3f 100644
--- a/include/asm-arm/arch-kirkwood/cpu.h
+++ b/include/asm-arm/arch-kirkwood/cpu.h
@@ -165,5 +165,7 @@ int kw_config_mpp(unsigned int mpp0_7, unsigned int mpp8_15,
 		unsigned int mpp32_39, unsigned int mpp40_47,
 		unsigned int mpp48_55);
 unsigned int kw_winctrl_calcsize(unsigned int sizeval);
+void kw_watchdog_init(unsigned long timeout_secs);
+
 #endif /* __ASSEMBLY__ */
 #endif /* _KWCPU_H */
-- 
1.6.0.4

^ permalink raw reply related	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2009-10-28 13:05 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-09-28  7:06 [U-Boot] [PATCH] arm:kirkwood: Add hardware watchdog support for Marvell Kirkwood boards Simon Kagstrom
2009-09-28 12:36 ` Tom
2009-09-28 13:36   ` Simon Kagstrom
2009-09-28 14:28     ` Tom
2009-09-29  2:16 ` Prafulla Wadaskar
2009-09-29  8:28   ` Simon Kagstrom
2009-09-29 13:45     ` Prafulla Wadaskar
2009-09-29 13:59       ` Stefan Roese
2009-09-29 14:01       ` Simon Kagstrom
2009-10-28  8:17 ` Simon Kagstrom
2009-10-28  9:24   ` Prafulla Wadaskar
2009-10-28  9:53     ` Simon Kagstrom
2009-10-28 11:34       ` Prafulla Wadaskar
2009-10-28 12:44         ` Simon Kagstrom
2009-10-28 12:57           ` Prafulla Wadaskar
2009-10-28 13:05             ` Simon Kagstrom

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox