aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/ar7/patches-2.6.30/140-watchdog_bootcr.patch
blob: 21c95a7652d3e712b4551aa7f38d8f26dc5187a1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
--- a/drivers/watchdog/ar7_wdt.c
+++ b/drivers/watchdog/ar7_wdt.c
@@ -298,14 +298,28 @@ static struct miscdevice ar7_wdt_miscdev
 	.fops		= &ar7_wdt_fops,
 };
 
+#define AR7_WDT_HARDWARE_ENABLE 0x10
+
 static int __init ar7_wdt_init(void)
 {
 	int rc;
+	u32 *bootcr;
+	u32 bootcr_value;
 
 	spin_lock_init(&wdt_lock);
 
 	ar7_wdt_get_regs();
 
+	/* arch/mips/ar7/clocks.c is the only other thing that reads this */
+	bootcr = (u32 *)ioremap_nocache(AR7_REGS_DCL, 4);
+	bootcr_value = *bootcr;
+	iounmap(bootcr);
+
+	if (!(bootcr_value & AR7_WDT_HARDWARE_ENABLE)) { 
+		printk(KERN_INFO DRVNAME ": watchdog disabled in hardware (bootcr=%#x)\n", bootcr_value);
+		return -ENODEV; 
+        } 
+
 	if (!request_mem_region(ar7_regs_wdt, sizeof(struct ar7_wdt),
 							LONGNAME)) {
 		printk(KERN_WARNING DRVNAME ": watchdog I/O region busy\n");