[U-Boot-Users] RFC/patch: watchdog for MCF532x/537x

w.wegner at astro-kom.de w.wegner at astro-kom.de
Tue Mar 25 14:05:52 CET 2008


Hi,

I made some small fixes for the watchdog of MCF532x/537x.

According to the data sheet (and my MCF5373L showing this
behaviour), the HALTED bit in WTM_WCR does only affect
watchdog counting during external (BDM) processor halt state,
for disabling the watchdog, the WTM_WCR_EN has to be
cleared.
Furthermore, setting WTM_WCR during "watchdog enable"
cleared all other bits that had probably been set by a debugger.

Last but not least, I added a check to produce an error if an
out-of-range watchdog timeout is set - I do not know if such
a thing is wanted or not.

Another thing I find confusing but can not confirm is that a
different modulo is used for MCF5329 and MCF537x - I know
the 8192 was present in an old version of the MCF5329 data
sheet, but current revision shows 4096 like the MCF537x has.

Any comments are welcome.

Best regards,
Wolfgang

diff --git a/cpu/mcf532x/cpu.c b/cpu/mcf532x/cpu.c
index 61541ab..f43464a 100644
--- a/cpu/mcf532x/cpu.c
+++ b/cpu/mcf532x/cpu.c
@@ -6,6 +6,9 @@
  * Copyright (C) 2004-2007 Freescale Semiconductor, Inc.
  * TsiChung Liew (Tsi-Chung.Liew at freescale.com)
  *
+ * Wolfgang Wegner <w.wegner at astro-kom.de>
+ * (fixed watchdog functions)
+ *
  * See file CREDITS for list of people who contributed to this
  * project.
  *
@@ -95,8 +98,8 @@ void watchdog_reset(void)
 {
 	volatile wdog_t *wdp = (wdog_t *) (MMAP_WDOG);
 
-	wdp->sr = 0x5555;	/* Count register */
-	wdp->sr = 0xAAAA;	/* Count register */
+	wdp->sr = 0x5555;	/* service register */
+	wdp->sr = 0xAAAA;	/* service register */
 }
 
 int watchdog_disable(void)
@@ -104,7 +107,7 @@ int watchdog_disable(void)
 	volatile wdog_t *wdp = (wdog_t *) (MMAP_WDOG);
 
 	/* UserManual, once the wdog is disabled, wdog cannot be re-enabled */
-	wdp->cr |= WTM_WCR_HALTED;	/* halted watchdog timer */
+	wdp->cr = 0;	/* disable watchdog timer */
 
 	puts("WATCHDOG:disabled\n");
 	return (0);
@@ -115,6 +118,9 @@ int watchdog_init(void)
 	volatile wdog_t *wdp = (wdog_t *) (MMAP_WDOG);
 	u32 wdog_module = 0;
 
+#if CONFIG_WATCHDOG_TIMEOUT > 3355
+#error CONFIG_WATCHDOG_TIMEOUT too large!
+#endif
 	/* set timeout and enable watchdog */
 	wdog_module = ((CFG_CLK / 1000) * CONFIG_WATCHDOG_TIMEOUT);
 #ifdef CONFIG_M5329
@@ -123,7 +129,11 @@ int watchdog_init(void)
 	wdp->mr = (wdog_module / 4096);
 #endif
 
-	wdp->cr = WTM_WCR_EN;
+	/*
+	 * setting the bit is not strictly necessary (wd is enabled
+	 * by default), but leave alone the other bits
+	 */
+	wdp->cr |= WTM_WCR_EN;
 	puts("WATCHDOG:enabled\n");
 
 	return (0);






More information about the U-Boot mailing list