Re: AT91SAM9/CAP9 watchdog driver

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Andrew Victor <avictor.za@...>
Cc: <linux-arm-kernel@...>, <akpm@...>, <wim@...>, Linux Kernel list <linux-kernel@...>
Date: Saturday, June 7, 2008 - 2:39 am

I thought I'd finally get around to trying this driver.
No luck.

The proximate cause is that Atmel's second stage "at91boot"
loader disables the watchdog.  That's because the reset state
of this watchdog is "reset after 16 seconds" ... so it must
be tended carefully until the Linux "watchdog" daemon takes
over.  Since there's no code in at91boot, U-Boot, or Linux to
do that, it gets disabled.  (How was this driver tested??)

Needless to say, this isn't exactly my model of how to make
a useful watchdog.  That "write once" rule is pure trouble.

I suggest merging the following patch, to reduce confusion.

- Dave


======== CUT HERE
The at91sam9 watchdog is a kind of annoying bit of hardware:  since its
mode register is write-once, it can't be reconfigured.  Moreover, Atmel's
standard second stage loader "at91boot" always this watchdog (at least
on Atmel's reference boards), ensuring that Linux normally can't use it.

This patch removes some confusion by not registering the watchdog device
on systems where it was disabled before Linux starts.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>

--- a/arch/arm/mach-at91/at91sam9260_devices.c	2008-06-06 15:00:06.000000000 -0700
+++ b/arch/arm/mach-at91/at91sam9260_devices.c	2008-06-06 20:40:38.000000000 -0700
@@ -21,6 +21,7 @@
 #include <asm/arch/at91sam9260.h>
 #include <asm/arch/at91sam9260_matrix.h>
 #include <asm/arch/at91sam9_smc.h>
+#include <asm/arch/at91_wdt.h>
 
 #include "generic.h"
 
@@ -666,6 +667,9 @@ static struct platform_device at91sam926
 
 static void __init at91_add_device_watchdog(void)
 {
+	/* WDT_MR is write-once; if it was disabled, we're stuck */
+	if (at91_sys_read(AT91_WDT_MR) & AT91_WDT_WDDIS)
+		return;
 	platform_device_register(&at91sam9260_wdt_device);
 }
 #else
--- a/arch/arm/mach-at91/at91sam9261_devices.c	2008-06-06 15:00:06.000000000 -0700
+++ b/arch/arm/mach-at91/at91sam9261_devices.c	2008-06-06 20:40:45.000000000 -0700
@@ -25,6 +25,7 @@
 #include <asm/arch/at91sam9261.h>
 #include <asm/arch/at91sam9261_matrix.h>
 #include <asm/arch/at91sam9_smc.h>
+#include <asm/arch/at91_wdt.h>
 
 #include "generic.h"
 
@@ -654,6 +655,9 @@ static struct platform_device at91sam926
 
 static void __init at91_add_device_watchdog(void)
 {
+	/* WDT_MR is write-once; if it was disabled, we're stuck */
+	if (at91_sys_read(AT91_WDT_MR) & AT91_WDT_WDDIS)
+		return;
 	platform_device_register(&at91sam9261_wdt_device);
 }
 #else
--- a/arch/arm/mach-at91/at91sam9263_devices.c	2008-06-06 15:00:06.000000000 -0700
+++ b/arch/arm/mach-at91/at91sam9263_devices.c	2008-06-06 20:40:48.000000000 -0700
@@ -24,6 +24,7 @@
 #include <asm/arch/at91sam9263.h>
 #include <asm/arch/at91sam9263_matrix.h>
 #include <asm/arch/at91sam9_smc.h>
+#include <asm/arch/at91_wdt.h>
 
 #include "generic.h"
 
@@ -911,6 +912,9 @@ static struct platform_device at91sam926
 
 static void __init at91_add_device_watchdog(void)
 {
+	/* WDT_MR is write-once; if it was disabled, we're stuck */
+	if (at91_sys_read(AT91_WDT_MR) & AT91_WDT_WDDIS)
+		return;
 	platform_device_register(&at91sam9263_wdt_device);
 }
 #else
--- a/arch/arm/mach-at91/at91sam9rl_devices.c	2008-06-06 15:00:06.000000000 -0700
+++ b/arch/arm/mach-at91/at91sam9rl_devices.c	2008-06-06 20:40:52.000000000 -0700
@@ -21,6 +21,7 @@
 #include <asm/arch/at91sam9rl.h>
 #include <asm/arch/at91sam9rl_matrix.h>
 #include <asm/arch/at91sam9_smc.h>
+#include <asm/arch/at91_wdt.h>
 
 #include "generic.h"
 
@@ -501,6 +502,9 @@ static struct platform_device at91sam9rl
 
 static void __init at91_add_device_watchdog(void)
 {
+	/* WDT_MR is write-once; if it was disabled, we're stuck */
+	if (at91_sys_read(AT91_WDT_MR) & AT91_WDT_WDDIS)
+		return;
 	platform_device_register(&at91sam9rl_wdt_device);
 }
 #else


--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
AT91SAM9/CAP9 watchdog driver, Andrew Victor, (Sun Jun 1, 12:40 pm)
Re: AT91SAM9/CAP9 watchdog driver, David Brownell, (Sat Jun 7, 2:39 am)
Re: AT91SAM9/CAP9 watchdog driver, Andrew Morton, (Tue Jun 3, 5:23 pm)
Re: AT91SAM9/CAP9 watchdog driver, Andrew Victor, (Wed Jun 4, 3:31 am)
Re: AT91SAM9/CAP9 watchdog driver, Alan Cox, (Wed Jun 4, 7:36 am)
Re: AT91SAM9/CAP9 watchdog driver, Andrew Victor, (Wed Jun 4, 2:36 pm)
Re: AT91SAM9/CAP9 watchdog driver, Alan Cox, (Wed Jun 4, 2:24 pm)
Re: AT91SAM9/CAP9 watchdog driver, Andrew Victor, (Wed Jun 4, 3:02 pm)
Re: AT91SAM9/CAP9 watchdog driver, Alan Cox, (Wed Jun 4, 3:18 pm)
Re: AT91SAM9/CAP9 watchdog driver, Alan Cox, (Mon Jun 2, 2:58 am)