24 #include <linux/module.h>
26 #include <linux/types.h>
27 #include <linux/errno.h>
36 #include <linux/watchdog.h>
41 #define RDC_WDT_MASK 0x80000000
42 #define RDC_WDT_EN 0x00800000
43 #define RDC_WDT_WTI 0x00200000
44 #define RDC_WDT_RST 0x00100000
45 #define RDC_WDT_WIF 0x00040000
46 #define RDC_WDT_IRT 0x00000100
47 #define RDC_WDT_CNT 0x00000001
49 #define RDC_CLS_TMR 0x80003844
51 #define RDC_WDT_INTERVAL (HZ/10+1)
53 static int ticks = 1000;
71 static void rdc321x_wdt_trigger(
unsigned long unused)
76 if (rdc321x_wdt_device.running)
81 pci_read_config_dword(rdc321x_wdt_device.sb_pdev,
82 rdc321x_wdt_device.base_reg, &val);
84 pci_write_config_dword(rdc321x_wdt_device.sb_pdev,
85 rdc321x_wdt_device.base_reg, val);
86 spin_unlock_irqrestore(&rdc321x_wdt_device.lock, flags);
89 if (rdc321x_wdt_device.queue &&
ticks)
99 static void rdc321x_wdt_reset(
void)
101 ticks = rdc321x_wdt_device.default_ticks;
104 static void rdc321x_wdt_start(
void)
108 if (!rdc321x_wdt_device.queue) {
109 rdc321x_wdt_device.queue = 1;
113 pci_write_config_dword(rdc321x_wdt_device.sb_pdev,
117 pci_write_config_dword(rdc321x_wdt_device.sb_pdev,
118 rdc321x_wdt_device.base_reg,
120 spin_unlock_irqrestore(&rdc321x_wdt_device.lock, flags);
127 rdc321x_wdt_device.running++;
130 static int rdc321x_wdt_stop(
void)
132 if (rdc321x_wdt_device.running)
133 rdc321x_wdt_device.running = 0;
135 ticks = rdc321x_wdt_device.default_ticks;
149 static int rdc321x_wdt_release(
struct inode *inode,
struct file *file)
155 static long rdc321x_wdt_ioctl(
struct file *file,
unsigned int cmd,
162 .identity =
"RDC321x WDT",
173 pci_read_config_dword(rdc321x_wdt_device.sb_pdev,
174 rdc321x_wdt_device.base_reg, &value);
175 spin_unlock_irqrestore(&rdc321x_wdt_device.lock, flags);
191 return rdc321x_wdt_stop();
202 static ssize_t rdc321x_wdt_write(
struct file *file,
const char __user *
buf,
203 size_t count, loff_t *ppos)
216 .unlocked_ioctl = rdc321x_wdt_ioctl,
217 .open = rdc321x_wdt_open,
218 .write = rdc321x_wdt_write,
219 .release = rdc321x_wdt_release,
225 .fops = &rdc321x_wdt_fops,
234 pdata = pdev->
dev.platform_data;
236 dev_err(&pdev->
dev,
"no platform data supplied\n");
242 dev_err(&pdev->
dev,
"failed to get wdt-reg resource\n");
246 rdc321x_wdt_device.sb_pdev = pdata->
sb_pdev;
247 rdc321x_wdt_device.base_reg = r->
start;
251 dev_err(&pdev->
dev,
"misc_register failed\n");
258 pci_write_config_dword(rdc321x_wdt_device.sb_pdev,
261 init_completion(&rdc321x_wdt_device.stop);
262 rdc321x_wdt_device.queue = 0;
266 setup_timer(&rdc321x_wdt_device.timer, rdc321x_wdt_trigger, 0);
268 rdc321x_wdt_device.default_ticks =
ticks;
277 if (rdc321x_wdt_device.queue) {
278 rdc321x_wdt_device.queue = 0;
288 .probe = rdc321x_wdt_probe,
292 .name =
"rdc321x-wdt",