]>
Commit | Line | Data |
---|---|---|
1da177e4 | 1 | /* |
0e94f2ee VD |
2 | * w83627hf/thf WDT driver |
3 | * | |
4 | * (c) Copyright 2007 Vlad Drukker <[email protected]> | |
5 | * added support for W83627THF. | |
1da177e4 | 6 | * |
d36b6910 | 7 | * (c) Copyright 2003,2007 Pádraig Brady <[email protected]> |
1da177e4 LT |
8 | * |
9 | * Based on advantechwdt.c which is based on wdt.c. | |
10 | * Original copyright messages: | |
11 | * | |
12 | * (c) Copyright 2000-2001 Marek Michalkiewicz <[email protected]> | |
13 | * | |
29fa0586 AC |
14 | * (c) Copyright 1996 Alan Cox <[email protected]>, |
15 | * All Rights Reserved. | |
1da177e4 LT |
16 | * |
17 | * This program is free software; you can redistribute it and/or | |
18 | * modify it under the terms of the GNU General Public License | |
19 | * as published by the Free Software Foundation; either version | |
20 | * 2 of the License, or (at your option) any later version. | |
21 | * | |
22 | * Neither Alan Cox nor CymruNet Ltd. admit liability nor provide | |
23 | * warranty for any of this software. This material is provided | |
24 | * "AS-IS" and at no charge. | |
25 | * | |
29fa0586 | 26 | * (c) Copyright 1995 Alan Cox <[email protected]> |
1da177e4 LT |
27 | */ |
28 | ||
27c766aa JP |
29 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt |
30 | ||
1da177e4 LT |
31 | #include <linux/module.h> |
32 | #include <linux/moduleparam.h> | |
33 | #include <linux/types.h> | |
34 | #include <linux/miscdevice.h> | |
35 | #include <linux/watchdog.h> | |
36 | #include <linux/fs.h> | |
37 | #include <linux/ioport.h> | |
38 | #include <linux/notifier.h> | |
39 | #include <linux/reboot.h> | |
40 | #include <linux/init.h> | |
ab9d4414 | 41 | #include <linux/spinlock.h> |
46a3949d AC |
42 | #include <linux/io.h> |
43 | #include <linux/uaccess.h> | |
1da177e4 | 44 | |
1da177e4 | 45 | |
9c67bea4 | 46 | #define WATCHDOG_NAME "w83627hf/thf/hg/dhg WDT" |
1da177e4 LT |
47 | #define WATCHDOG_TIMEOUT 60 /* 60 sec default timeout */ |
48 | ||
49 | static unsigned long wdt_is_open; | |
50 | static char expect_close; | |
c7dfd0cc | 51 | static DEFINE_SPINLOCK(io_lock); |
1da177e4 LT |
52 | |
53 | /* You must set this - there is no sane way to probe for this board. */ | |
54 | static int wdt_io = 0x2E; | |
55 | module_param(wdt_io, int, 0); | |
0e94f2ee | 56 | MODULE_PARM_DESC(wdt_io, "w83627hf/thf WDT io port (default 0x2E)"); |
1da177e4 LT |
57 | |
58 | static int timeout = WATCHDOG_TIMEOUT; /* in seconds */ | |
59 | module_param(timeout, int, 0); | |
46a3949d AC |
60 | MODULE_PARM_DESC(timeout, |
61 | "Watchdog timeout in seconds. 1 <= timeout <= 255, default=" | |
62 | __MODULE_STRING(WATCHDOG_TIMEOUT) "."); | |
1da177e4 | 63 | |
86a1e189 WVS |
64 | static bool nowayout = WATCHDOG_NOWAYOUT; |
65 | module_param(nowayout, bool, 0); | |
46a3949d AC |
66 | MODULE_PARM_DESC(nowayout, |
67 | "Watchdog cannot be stopped once started (default=" | |
68 | __MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); | |
1da177e4 LT |
69 | |
70 | /* | |
71 | * Kernel methods. | |
72 | */ | |
73 | ||
74 | #define WDT_EFER (wdt_io+0) /* Extended Function Enable Registers */ | |
46a3949d AC |
75 | #define WDT_EFIR (wdt_io+0) /* Extended Function Index Register |
76 | (same as EFER) */ | |
1da177e4 LT |
77 | #define WDT_EFDR (WDT_EFIR+1) /* Extended Function Data Register */ |
78 | ||
46a3949d | 79 | static void w83627hf_select_wd_register(void) |
1da177e4 | 80 | { |
0e94f2ee | 81 | unsigned char c; |
1da177e4 LT |
82 | outb_p(0x87, WDT_EFER); /* Enter extended function mode */ |
83 | outb_p(0x87, WDT_EFER); /* Again according to manual */ | |
84 | ||