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