Sven Anders & Marcus Junker | 789fc0a | 2006-08-24 17:11:50 +0200 | [diff] [blame] | 1 | /* |
| 2 | * NS pc87413-wdt Watchdog Timer driver for Linux 2.6.x.x |
| 3 | * |
Sven Anders & Marcus Junker | 00b3b3e | 2006-10-16 18:18:09 +0200 | [diff] [blame] | 4 | * This code is based on wdt.c with original copyright. |
Sven Anders & Marcus Junker | 789fc0a | 2006-08-24 17:11:50 +0200 | [diff] [blame] | 5 | * |
Sven Anders & Marcus Junker | 00b3b3e | 2006-10-16 18:18:09 +0200 | [diff] [blame] | 6 | * (C) Copyright 2006 Sven Anders, <anders@anduras.de> |
| 7 | * and Marcus Junker, <junker@anduras.de> |
Sven Anders & Marcus Junker | 789fc0a | 2006-08-24 17:11:50 +0200 | [diff] [blame] | 8 | * |
| 9 | * This program is free software; you can redistribute it and/or |
| 10 | * modify it under the terms of the GNU General Public License |
| 11 | * as published by the Free Software Foundation; either version |
| 12 | * 2 of the License, or (at your option) any later version. |
| 13 | * |
Sven Anders & Marcus Junker | 00b3b3e | 2006-10-16 18:18:09 +0200 | [diff] [blame] | 14 | * Neither Sven Anders, Marcus Junker nor ANDURAS AG |
Sven Anders & Marcus Junker | 789fc0a | 2006-08-24 17:11:50 +0200 | [diff] [blame] | 15 | * admit liability nor provide warranty for any of this software. |
| 16 | * This material is provided "AS-IS" and at no charge. |
| 17 | * |
Sven Anders & Marcus Junker | 00b3b3e | 2006-10-16 18:18:09 +0200 | [diff] [blame] | 18 | * Release 1.1 |
Sven Anders & Marcus Junker | 789fc0a | 2006-08-24 17:11:50 +0200 | [diff] [blame] | 19 | */ |
| 20 | |
Sven Anders & Marcus Junker | 789fc0a | 2006-08-24 17:11:50 +0200 | [diff] [blame] | 21 | #include <linux/module.h> |
| 22 | #include <linux/types.h> |
| 23 | #include <linux/miscdevice.h> |
| 24 | #include <linux/watchdog.h> |
| 25 | #include <linux/ioport.h> |
| 26 | #include <linux/delay.h> |
| 27 | #include <linux/notifier.h> |
| 28 | #include <linux/fs.h> |
| 29 | #include <linux/reboot.h> |
| 30 | #include <linux/init.h> |
| 31 | #include <linux/spinlock.h> |
| 32 | #include <linux/moduleparam.h> |
| 33 | #include <linux/version.h> |
| 34 | |
| 35 | #include <asm/io.h> |
| 36 | #include <asm/uaccess.h> |
| 37 | #include <asm/system.h> |
| 38 | |
Sven Anders & Marcus Junker | 00b3b3e | 2006-10-16 18:18:09 +0200 | [diff] [blame] | 39 | /* #define DEBUG 1 */ |
Sven Anders & Marcus Junker | 789fc0a | 2006-08-24 17:11:50 +0200 | [diff] [blame] | 40 | |
Sven Anders & Marcus Junker | 00b3b3e | 2006-10-16 18:18:09 +0200 | [diff] [blame] | 41 | #define DEFAULT_TIMEOUT 1 /* 1 minute */ |
| 42 | #define MAX_TIMEOUT 255 |
| 43 | |
| 44 | #define VERSION "1.1" |
| 45 | #define MODNAME "pc87413 WDT" |
| 46 | #define PFX MODNAME ": " |
| 47 | #define DPFX MODNAME " - DEBUG: " |
| 48 | |
| 49 | #define WDT_INDEX_IO_PORT (io+0) /* I/O port base (index register) */ |
Sven Anders & Marcus Junker | 789fc0a | 2006-08-24 17:11:50 +0200 | [diff] [blame] | 50 | #define WDT_DATA_IO_PORT (WDT_INDEX_IO_PORT+1) |
Sven Anders & Marcus Junker | 00b3b3e | 2006-10-16 18:18:09 +0200 | [diff] [blame] | 51 | #define SWC_LDN 0x04 |
| 52 | #define SIOCFG2 0x22 /* Serial IO register */ |
| 53 | #define WDCTL 0x10 /* Watchdog-Timer-Controll-Register */ |
| 54 | #define WDTO 0x11 /* Watchdog timeout register */ |
| 55 | #define WDCFG 0x12 /* Watchdog config register */ |
Sven Anders & Marcus Junker | 789fc0a | 2006-08-24 17:11:50 +0200 | [diff] [blame] | 56 | |
Sven Anders & Marcus Junker | 00b3b3e | 2006-10-16 18:18:09 +0200 | [diff] [blame] | 57 | static int io = 0x2E; /* Address used on Portwell Boards */ |
Sven Anders & Marcus Junker | 789fc0a | 2006-08-24 17:11:50 +0200 | [diff] [blame] | 58 | |
Sven Anders & Marcus Junker | 00b3b3e | 2006-10-16 18:18:09 +0200 | [diff] [blame] | 59 | static int timeout = DEFAULT_TIMEOUT; /* timeout value */ |
| 60 | static unsigned long timer_enabled = 0; /* is the timer enabled? */ |
Sven Anders & Marcus Junker | 789fc0a | 2006-08-24 17:11:50 +0200 | [diff] [blame] | 61 | |
Sven Anders & Marcus Junker | 00b3b3e | 2006-10-16 18:18:09 +0200 | [diff] [blame] | 62 | static char expect_close; /* is the close expected? */ |
Sven Anders & Marcus Junker | 789fc0a | 2006-08-24 17:11:50 +0200 | [diff] [blame] | 63 | |
Alexey Dobriyan | c7dfd0c | 2007-11-01 16:27:08 -0700 | [diff] [blame^] | 64 | static DEFINE_SPINLOCK(io_lock);/* to guard the watchdog from io races */ |
Sven Anders & Marcus Junker | 789fc0a | 2006-08-24 17:11:50 +0200 | [diff] [blame] | 65 | |
Sven Anders & Marcus Junker | 00b3b3e | 2006-10-16 18:18:09 +0200 | [diff] [blame] | 66 | static int nowayout = WATCHDOG_NOWAYOUT; |
Sven Anders & Marcus Junker | 789fc0a | 2006-08-24 17:11:50 +0200 | [diff] [blame] | 67 | |
Sven Anders & Marcus Junker | 00b3b3e | 2006-10-16 18:18:09 +0200 | [diff] [blame] | 68 | /* -- Low level function ----------------------------------------*/ |
Sven Anders & Marcus Junker | 789fc0a | 2006-08-24 17:11:50 +0200 | [diff] [blame] | 69 | |
Sven Anders & Marcus Junker | 00b3b3e | 2006-10-16 18:18:09 +0200 | [diff] [blame] | 70 | /* Select pins for Watchdog output */ |
Sven Anders & Marcus Junker | 789fc0a | 2006-08-24 17:11:50 +0200 | [diff] [blame] | 71 | |
Sven Anders & Marcus Junker | 00b3b3e | 2006-10-16 18:18:09 +0200 | [diff] [blame] | 72 | static inline void pc87413_select_wdt_out (void) |
Sven Anders & Marcus Junker | 789fc0a | 2006-08-24 17:11:50 +0200 | [diff] [blame] | 73 | { |
Sven Anders & Marcus Junker | 00b3b3e | 2006-10-16 18:18:09 +0200 | [diff] [blame] | 74 | unsigned int cr_data = 0; |
Sven Anders & Marcus Junker | 789fc0a | 2006-08-24 17:11:50 +0200 | [diff] [blame] | 75 | |
Sven Anders & Marcus Junker | 00b3b3e | 2006-10-16 18:18:09 +0200 | [diff] [blame] | 76 | /* Step 1: Select multiple pin,pin55,as WDT output */ |
Sven Anders & Marcus Junker | 789fc0a | 2006-08-24 17:11:50 +0200 | [diff] [blame] | 77 | |
| 78 | outb_p(SIOCFG2, WDT_INDEX_IO_PORT); |
| 79 | |
| 80 | cr_data = inb (WDT_DATA_IO_PORT); |
| 81 | |
| 82 | cr_data |= 0x80; /* Set Bit7 to 1*/ |
| 83 | outb_p(SIOCFG2, WDT_INDEX_IO_PORT); |
| 84 | |
| 85 | outb_p(cr_data, WDT_DATA_IO_PORT); |
| 86 | |
Sven Anders & Marcus Junker | 00b3b3e | 2006-10-16 18:18:09 +0200 | [diff] [blame] | 87 | #ifdef DEBUG |
| 88 | printk(KERN_INFO DPFX "Select multiple pin,pin55,as WDT output:" |
| 89 | " Bit7 to 1: %d\n", cr_data); |
| 90 | #endif |
Sven Anders & Marcus Junker | 789fc0a | 2006-08-24 17:11:50 +0200 | [diff] [blame] | 91 | } |
| 92 | |
Sven Anders & Marcus Junker | 00b3b3e | 2006-10-16 18:18:09 +0200 | [diff] [blame] | 93 | /* Enable SWC functions */ |
Sven Anders & Marcus Junker | 789fc0a | 2006-08-24 17:11:50 +0200 | [diff] [blame] | 94 | |
Sven Anders & Marcus Junker | 00b3b3e | 2006-10-16 18:18:09 +0200 | [diff] [blame] | 95 | static inline void pc87413_enable_swc(void) |
| 96 | { |
| 97 | unsigned int cr_data=0; |
Sven Anders & Marcus Junker | 789fc0a | 2006-08-24 17:11:50 +0200 | [diff] [blame] | 98 | |
| 99 | /* Step 2: Enable SWC functions */ |
| 100 | |
| 101 | outb_p(0x07, WDT_INDEX_IO_PORT); /* Point SWC_LDN (LDN=4) */ |
| 102 | outb_p(SWC_LDN, WDT_DATA_IO_PORT); |
| 103 | |
| 104 | outb_p(0x30, WDT_INDEX_IO_PORT); /* Read Index 0x30 First */ |
Sven Anders & Marcus Junker | 00b3b3e | 2006-10-16 18:18:09 +0200 | [diff] [blame] | 105 | cr_data = inb(WDT_DATA_IO_PORT); |
Sven Anders & Marcus Junker | 789fc0a | 2006-08-24 17:11:50 +0200 | [diff] [blame] | 106 | cr_data |= 0x01; /* Set Bit0 to 1 */ |
| 107 | outb_p(0x30, WDT_INDEX_IO_PORT); |
| 108 | outb_p(cr_data, WDT_DATA_IO_PORT); /* Index0x30_bit0P1 */ |
| 109 | |
Sven Anders & Marcus Junker | 00b3b3e | 2006-10-16 18:18:09 +0200 | [diff] [blame] | 110 | #ifdef DEBUG |
Sven Anders & Marcus Junker | 789fc0a | 2006-08-24 17:11:50 +0200 | [diff] [blame] | 111 | printk(KERN_INFO DPFX "pc87413 - Enable SWC functions\n"); |
Sven Anders & Marcus Junker | 00b3b3e | 2006-10-16 18:18:09 +0200 | [diff] [blame] | 112 | #endif |
Sven Anders & Marcus Junker | 789fc0a | 2006-08-24 17:11:50 +0200 | [diff] [blame] | 113 | } |
| 114 | |
Sven Anders & Marcus Junker | 00b3b3e | 2006-10-16 18:18:09 +0200 | [diff] [blame] | 115 | /* Read SWC I/O base address */ |
| 116 | |
| 117 | static inline unsigned int pc87413_get_swc_base(void) |
Sven Anders & Marcus Junker | 789fc0a | 2006-08-24 17:11:50 +0200 | [diff] [blame] | 118 | { |
Sven Anders & Marcus Junker | 00b3b3e | 2006-10-16 18:18:09 +0200 | [diff] [blame] | 119 | unsigned int swc_base_addr = 0; |
| 120 | unsigned char addr_l, addr_h = 0; |
Sven Anders & Marcus Junker | 789fc0a | 2006-08-24 17:11:50 +0200 | [diff] [blame] | 121 | |
| 122 | /* Step 3: Read SWC I/O Base Address */ |
| 123 | |
| 124 | outb_p(0x60, WDT_INDEX_IO_PORT); /* Read Index 0x60 */ |
Sven Anders & Marcus Junker | 00b3b3e | 2006-10-16 18:18:09 +0200 | [diff] [blame] | 125 | addr_h = inb(WDT_DATA_IO_PORT); |
Sven Anders & Marcus Junker | 789fc0a | 2006-08-24 17:11:50 +0200 | [diff] [blame] | 126 | |
| 127 | outb_p(0x61, WDT_INDEX_IO_PORT); /* Read Index 0x61 */ |
| 128 | |
Sven Anders & Marcus Junker | 00b3b3e | 2006-10-16 18:18:09 +0200 | [diff] [blame] | 129 | addr_l = inb(WDT_DATA_IO_PORT); |
Sven Anders & Marcus Junker | 789fc0a | 2006-08-24 17:11:50 +0200 | [diff] [blame] | 130 | |
| 131 | swc_base_addr = (addr_h << 8) + addr_l; |
| 132 | |
Sven Anders & Marcus Junker | 00b3b3e | 2006-10-16 18:18:09 +0200 | [diff] [blame] | 133 | #ifdef DEBUG |
| 134 | printk(KERN_INFO DPFX "Read SWC I/O Base Address: low %d, high %d," |
| 135 | " res %d\n", addr_l, addr_h, swc_base_addr); |
| 136 | #endif |
Sven Anders & Marcus Junker | 789fc0a | 2006-08-24 17:11:50 +0200 | [diff] [blame] | 137 | |
| 138 | return swc_base_addr; |
| 139 | } |
| 140 | |
Sven Anders & Marcus Junker | 00b3b3e | 2006-10-16 18:18:09 +0200 | [diff] [blame] | 141 | /* Select Bank 3 of SWC */ |
| 142 | |
| 143 | static inline void pc87413_swc_bank3(unsigned int swc_base_addr) |
Sven Anders & Marcus Junker | 789fc0a | 2006-08-24 17:11:50 +0200 | [diff] [blame] | 144 | { |
| 145 | /* Step 4: Select Bank3 of SWC */ |
| 146 | |
Sven Anders & Marcus Junker | 00b3b3e | 2006-10-16 18:18:09 +0200 | [diff] [blame] | 147 | outb_p(inb(swc_base_addr + 0x0f) | 0x03, swc_base_addr + 0x0f); |
Sven Anders & Marcus Junker | 789fc0a | 2006-08-24 17:11:50 +0200 | [diff] [blame] | 148 | |
Sven Anders & Marcus Junker | 00b3b3e | 2006-10-16 18:18:09 +0200 | [diff] [blame] | 149 | #ifdef DEBUG |
Sven Anders & Marcus Junker | 789fc0a | 2006-08-24 17:11:50 +0200 | [diff] [blame] | 150 | printk(KERN_INFO DPFX "Select Bank3 of SWC\n"); |
Sven Anders & Marcus Junker | 00b3b3e | 2006-10-16 18:18:09 +0200 | [diff] [blame] | 151 | #endif |
Sven Anders & Marcus Junker | 789fc0a | 2006-08-24 17:11:50 +0200 | [diff] [blame] | 152 | } |
| 153 | |
Sven Anders & Marcus Junker | 00b3b3e | 2006-10-16 18:18:09 +0200 | [diff] [blame] | 154 | /* Set watchdog timeout to x minutes */ |
| 155 | |
| 156 | static inline void pc87413_programm_wdto(unsigned int swc_base_addr, |
| 157 | char pc87413_time) |
Sven Anders & Marcus Junker | 789fc0a | 2006-08-24 17:11:50 +0200 | [diff] [blame] | 158 | { |
| 159 | /* Step 5: Programm WDTO, Twd. */ |
| 160 | |
Sven Anders & Marcus Junker | 00b3b3e | 2006-10-16 18:18:09 +0200 | [diff] [blame] | 161 | outb_p(pc87413_time, swc_base_addr + WDTO); |
Sven Anders & Marcus Junker | 789fc0a | 2006-08-24 17:11:50 +0200 | [diff] [blame] | 162 | |
Sven Anders & Marcus Junker | 00b3b3e | 2006-10-16 18:18:09 +0200 | [diff] [blame] | 163 | #ifdef DEBUG |
Sven Anders & Marcus Junker | 789fc0a | 2006-08-24 17:11:50 +0200 | [diff] [blame] | 164 | printk(KERN_INFO DPFX "Set WDTO to %d minutes\n", pc87413_time); |
Sven Anders & Marcus Junker | 00b3b3e | 2006-10-16 18:18:09 +0200 | [diff] [blame] | 165 | #endif |
Sven Anders & Marcus Junker | 789fc0a | 2006-08-24 17:11:50 +0200 | [diff] [blame] | 166 | } |
| 167 | |
Sven Anders & Marcus Junker | 00b3b3e | 2006-10-16 18:18:09 +0200 | [diff] [blame] | 168 | /* Enable WDEN */ |
| 169 | |
| 170 | static inline void pc87413_enable_wden(unsigned int swc_base_addr) |
Sven Anders & Marcus Junker | 789fc0a | 2006-08-24 17:11:50 +0200 | [diff] [blame] | 171 | { |
| 172 | /* Step 6: Enable WDEN */ |
| 173 | |
| 174 | outb_p(inb (swc_base_addr + WDCTL) | 0x01, swc_base_addr + WDCTL); |
| 175 | |
Sven Anders & Marcus Junker | 00b3b3e | 2006-10-16 18:18:09 +0200 | [diff] [blame] | 176 | #ifdef DEBUG |
Sven Anders & Marcus Junker | 789fc0a | 2006-08-24 17:11:50 +0200 | [diff] [blame] | 177 | printk(KERN_INFO DPFX "Enable WDEN\n"); |
Sven Anders & Marcus Junker | 00b3b3e | 2006-10-16 18:18:09 +0200 | [diff] [blame] | 178 | #endif |
Sven Anders & Marcus Junker | 789fc0a | 2006-08-24 17:11:50 +0200 | [diff] [blame] | 179 | } |
| 180 | |
Sven Anders & Marcus Junker | 00b3b3e | 2006-10-16 18:18:09 +0200 | [diff] [blame] | 181 | /* Enable SW_WD_TREN */ |
| 182 | static inline void pc87413_enable_sw_wd_tren(unsigned int swc_base_addr) |
Sven Anders & Marcus Junker | 789fc0a | 2006-08-24 17:11:50 +0200 | [diff] [blame] | 183 | { |
| 184 | /* Enable SW_WD_TREN */ |
| 185 | |
| 186 | outb_p(inb (swc_base_addr + WDCFG) | 0x80, swc_base_addr + WDCFG); |
| 187 | |
Sven Anders & Marcus Junker | 00b3b3e | 2006-10-16 18:18:09 +0200 | [diff] [blame] | 188 | #ifdef DEBUG |
Sven Anders & Marcus Junker | 789fc0a | 2006-08-24 17:11:50 +0200 | [diff] [blame] | 189 | printk(KERN_INFO DPFX "Enable SW_WD_TREN\n"); |
Sven Anders & Marcus Junker | 00b3b3e | 2006-10-16 18:18:09 +0200 | [diff] [blame] | 190 | #endif |
Sven Anders & Marcus Junker | 789fc0a | 2006-08-24 17:11:50 +0200 | [diff] [blame] | 191 | } |
| 192 | |
Sven Anders & Marcus Junker | 00b3b3e | 2006-10-16 18:18:09 +0200 | [diff] [blame] | 193 | /* Disable SW_WD_TREN */ |
| 194 | |
| 195 | static inline void pc87413_disable_sw_wd_tren(unsigned int swc_base_addr) |
Sven Anders & Marcus Junker | 789fc0a | 2006-08-24 17:11:50 +0200 | [diff] [blame] | 196 | { |
| 197 | /* Disable SW_WD_TREN */ |
| 198 | |
| 199 | outb_p(inb (swc_base_addr + WDCFG) & 0x7f, swc_base_addr + WDCFG); |
| 200 | |
Sven Anders & Marcus Junker | 00b3b3e | 2006-10-16 18:18:09 +0200 | [diff] [blame] | 201 | #ifdef DEBUG |
Sven Anders & Marcus Junker | 789fc0a | 2006-08-24 17:11:50 +0200 | [diff] [blame] | 202 | printk(KERN_INFO DPFX "pc87413 - Disable SW_WD_TREN\n"); |
Sven Anders & Marcus Junker | 00b3b3e | 2006-10-16 18:18:09 +0200 | [diff] [blame] | 203 | #endif |
Sven Anders & Marcus Junker | 789fc0a | 2006-08-24 17:11:50 +0200 | [diff] [blame] | 204 | } |
| 205 | |
Sven Anders & Marcus Junker | 00b3b3e | 2006-10-16 18:18:09 +0200 | [diff] [blame] | 206 | /* Enable SW_WD_TRG */ |
Sven Anders & Marcus Junker | 789fc0a | 2006-08-24 17:11:50 +0200 | [diff] [blame] | 207 | |
Sven Anders & Marcus Junker | 00b3b3e | 2006-10-16 18:18:09 +0200 | [diff] [blame] | 208 | static inline void pc87413_enable_sw_wd_trg(unsigned int swc_base_addr) |
Sven Anders & Marcus Junker | 789fc0a | 2006-08-24 17:11:50 +0200 | [diff] [blame] | 209 | { |
Sven Anders & Marcus Junker | 789fc0a | 2006-08-24 17:11:50 +0200 | [diff] [blame] | 210 | /* Enable SW_WD_TRG */ |
| 211 | |
| 212 | outb_p(inb (swc_base_addr + WDCTL) | 0x80, swc_base_addr + WDCTL); |
| 213 | |
Sven Anders & Marcus Junker | 00b3b3e | 2006-10-16 18:18:09 +0200 | [diff] [blame] | 214 | #ifdef DEBUG |
Sven Anders & Marcus Junker | 789fc0a | 2006-08-24 17:11:50 +0200 | [diff] [blame] | 215 | printk(KERN_INFO DPFX "pc87413 - Enable SW_WD_TRG\n"); |
Sven Anders & Marcus Junker | 00b3b3e | 2006-10-16 18:18:09 +0200 | [diff] [blame] | 216 | #endif |
Sven Anders & Marcus Junker | 789fc0a | 2006-08-24 17:11:50 +0200 | [diff] [blame] | 217 | } |
| 218 | |
Sven Anders & Marcus Junker | 00b3b3e | 2006-10-16 18:18:09 +0200 | [diff] [blame] | 219 | /* Disable SW_WD_TRG */ |
Sven Anders & Marcus Junker | 789fc0a | 2006-08-24 17:11:50 +0200 | [diff] [blame] | 220 | |
Sven Anders & Marcus Junker | 00b3b3e | 2006-10-16 18:18:09 +0200 | [diff] [blame] | 221 | static inline void pc87413_disable_sw_wd_trg(unsigned int swc_base_addr) |
| 222 | { |
Sven Anders & Marcus Junker | 789fc0a | 2006-08-24 17:11:50 +0200 | [diff] [blame] | 223 | /* Disable SW_WD_TRG */ |
| 224 | |
| 225 | outb_p(inb (swc_base_addr + WDCTL) & 0x7f, swc_base_addr + WDCTL); |
| 226 | |
Sven Anders & Marcus Junker | 00b3b3e | 2006-10-16 18:18:09 +0200 | [diff] [blame] | 227 | #ifdef DEBUG |
Sven Anders & Marcus Junker | 789fc0a | 2006-08-24 17:11:50 +0200 | [diff] [blame] | 228 | printk(KERN_INFO DPFX "Disable SW_WD_TRG\n"); |
Sven Anders & Marcus Junker | 00b3b3e | 2006-10-16 18:18:09 +0200 | [diff] [blame] | 229 | #endif |
Sven Anders & Marcus Junker | 789fc0a | 2006-08-24 17:11:50 +0200 | [diff] [blame] | 230 | } |
| 231 | |
Sven Anders & Marcus Junker | 00b3b3e | 2006-10-16 18:18:09 +0200 | [diff] [blame] | 232 | /* -- Higher level functions ------------------------------------*/ |
Sven Anders & Marcus Junker | 789fc0a | 2006-08-24 17:11:50 +0200 | [diff] [blame] | 233 | |
Sven Anders & Marcus Junker | 00b3b3e | 2006-10-16 18:18:09 +0200 | [diff] [blame] | 234 | /* Enable the watchdog */ |
Sven Anders & Marcus Junker | 789fc0a | 2006-08-24 17:11:50 +0200 | [diff] [blame] | 235 | |
Sven Anders & Marcus Junker | 00b3b3e | 2006-10-16 18:18:09 +0200 | [diff] [blame] | 236 | static void pc87413_enable(void) |
Sven Anders & Marcus Junker | 789fc0a | 2006-08-24 17:11:50 +0200 | [diff] [blame] | 237 | { |
Sven Anders & Marcus Junker | 00b3b3e | 2006-10-16 18:18:09 +0200 | [diff] [blame] | 238 | unsigned int swc_base_addr; |
| 239 | |
| 240 | spin_lock(&io_lock); |
| 241 | |
| 242 | pc87413_select_wdt_out(); |
| 243 | pc87413_enable_swc(); |
| 244 | swc_base_addr = pc87413_get_swc_base(); |
| 245 | pc87413_swc_bank3(swc_base_addr); |
| 246 | pc87413_programm_wdto(swc_base_addr, timeout); |
| 247 | pc87413_enable_wden(swc_base_addr); |
| 248 | pc87413_enable_sw_wd_tren(swc_base_addr); |
| 249 | pc87413_enable_sw_wd_trg(swc_base_addr); |
| 250 | |
| 251 | spin_unlock(&io_lock); |
| 252 | } |
| 253 | |
| 254 | /* Disable the watchdog */ |
| 255 | |
| 256 | static void pc87413_disable(void) |
| 257 | { |
| 258 | unsigned int swc_base_addr; |
| 259 | |
| 260 | spin_lock(&io_lock); |
Sven Anders & Marcus Junker | 789fc0a | 2006-08-24 17:11:50 +0200 | [diff] [blame] | 261 | |
| 262 | pc87413_select_wdt_out(); |
| 263 | pc87413_enable_swc(); |
| 264 | swc_base_addr = pc87413_get_swc_base(); |
| 265 | pc87413_swc_bank3(swc_base_addr); |
| 266 | pc87413_disable_sw_wd_tren(swc_base_addr); |
| 267 | pc87413_disable_sw_wd_trg(swc_base_addr); |
| 268 | pc87413_programm_wdto(swc_base_addr, 0); |
Sven Anders & Marcus Junker | 00b3b3e | 2006-10-16 18:18:09 +0200 | [diff] [blame] | 269 | |
| 270 | spin_unlock(&io_lock); |
Sven Anders & Marcus Junker | 789fc0a | 2006-08-24 17:11:50 +0200 | [diff] [blame] | 271 | } |
| 272 | |
Sven Anders & Marcus Junker | 00b3b3e | 2006-10-16 18:18:09 +0200 | [diff] [blame] | 273 | /* Refresh the watchdog */ |
Sven Anders & Marcus Junker | 789fc0a | 2006-08-24 17:11:50 +0200 | [diff] [blame] | 274 | |
Sven Anders & Marcus Junker | 00b3b3e | 2006-10-16 18:18:09 +0200 | [diff] [blame] | 275 | static void pc87413_refresh(void) |
Sven Anders & Marcus Junker | 789fc0a | 2006-08-24 17:11:50 +0200 | [diff] [blame] | 276 | { |
Sven Anders & Marcus Junker | 00b3b3e | 2006-10-16 18:18:09 +0200 | [diff] [blame] | 277 | unsigned int swc_base_addr; |
| 278 | |
| 279 | spin_lock(&io_lock); |
Sven Anders & Marcus Junker | 789fc0a | 2006-08-24 17:11:50 +0200 | [diff] [blame] | 280 | |
| 281 | pc87413_select_wdt_out(); |
| 282 | pc87413_enable_swc(); |
| 283 | swc_base_addr = pc87413_get_swc_base(); |
| 284 | pc87413_swc_bank3(swc_base_addr); |
| 285 | pc87413_disable_sw_wd_tren(swc_base_addr); |
| 286 | pc87413_disable_sw_wd_trg(swc_base_addr); |
Sven Anders & Marcus Junker | 00b3b3e | 2006-10-16 18:18:09 +0200 | [diff] [blame] | 287 | pc87413_programm_wdto(swc_base_addr, timeout); |
Sven Anders & Marcus Junker | 789fc0a | 2006-08-24 17:11:50 +0200 | [diff] [blame] | 288 | pc87413_enable_wden(swc_base_addr); |
| 289 | pc87413_enable_sw_wd_tren(swc_base_addr); |
| 290 | pc87413_enable_sw_wd_trg(swc_base_addr); |
Sven Anders & Marcus Junker | 00b3b3e | 2006-10-16 18:18:09 +0200 | [diff] [blame] | 291 | |
| 292 | spin_unlock(&io_lock); |
Sven Anders & Marcus Junker | 789fc0a | 2006-08-24 17:11:50 +0200 | [diff] [blame] | 293 | } |
| 294 | |
Sven Anders & Marcus Junker | 00b3b3e | 2006-10-16 18:18:09 +0200 | [diff] [blame] | 295 | /* -- File operations -------------------------------------------*/ |
Sven Anders & Marcus Junker | 789fc0a | 2006-08-24 17:11:50 +0200 | [diff] [blame] | 296 | |
Sven Anders & Marcus Junker | 00b3b3e | 2006-10-16 18:18:09 +0200 | [diff] [blame] | 297 | /** |
| 298 | * pc87413_open: |
| 299 | * @inode: inode of device |
| 300 | * @file: file handle to device |
| 301 | * |
| 302 | */ |
| 303 | |
| 304 | static int pc87413_open(struct inode *inode, struct file *file) |
Sven Anders & Marcus Junker | 789fc0a | 2006-08-24 17:11:50 +0200 | [diff] [blame] | 305 | { |
Sven Anders & Marcus Junker | 00b3b3e | 2006-10-16 18:18:09 +0200 | [diff] [blame] | 306 | /* /dev/watchdog can only be opened once */ |
Sven Anders & Marcus Junker | 789fc0a | 2006-08-24 17:11:50 +0200 | [diff] [blame] | 307 | |
Sven Anders & Marcus Junker | 00b3b3e | 2006-10-16 18:18:09 +0200 | [diff] [blame] | 308 | if (test_and_set_bit(0, &timer_enabled)) |
| 309 | return -EBUSY; |
Sven Anders & Marcus Junker | 789fc0a | 2006-08-24 17:11:50 +0200 | [diff] [blame] | 310 | |
Sven Anders & Marcus Junker | 00b3b3e | 2006-10-16 18:18:09 +0200 | [diff] [blame] | 311 | if (nowayout) |
| 312 | __module_get(THIS_MODULE); |
| 313 | |
| 314 | /* Reload and activate timer */ |
| 315 | pc87413_refresh(); |
| 316 | |
| 317 | printk(KERN_INFO MODNAME "Watchdog enabled. Timeout set to" |
| 318 | " %d minute(s).\n", timeout); |
| 319 | |
| 320 | return nonseekable_open(inode, file); |
Sven Anders & Marcus Junker | 789fc0a | 2006-08-24 17:11:50 +0200 | [diff] [blame] | 321 | } |
| 322 | |
Sven Anders & Marcus Junker | 00b3b3e | 2006-10-16 18:18:09 +0200 | [diff] [blame] | 323 | /** |
| 324 | * pc87413_release: |
| 325 | * @inode: inode to board |
| 326 | * @file: file handle to board |
| 327 | * |
| 328 | * The watchdog has a configurable API. There is a religious dispute |
| 329 | * between people who want their watchdog to be able to shut down and |
| 330 | * those who want to be sure if the watchdog manager dies the machine |
| 331 | * reboots. In the former case we disable the counters, in the latter |
| 332 | * case you have to open it again very soon. |
| 333 | */ |
Sven Anders & Marcus Junker | 789fc0a | 2006-08-24 17:11:50 +0200 | [diff] [blame] | 334 | |
Sven Anders & Marcus Junker | 00b3b3e | 2006-10-16 18:18:09 +0200 | [diff] [blame] | 335 | static int pc87413_release(struct inode *inode, struct file *file) |
| 336 | { |
| 337 | /* Shut off the timer. */ |
Sven Anders & Marcus Junker | 789fc0a | 2006-08-24 17:11:50 +0200 | [diff] [blame] | 338 | |
Sven Anders & Marcus Junker | 00b3b3e | 2006-10-16 18:18:09 +0200 | [diff] [blame] | 339 | if (expect_close == 42) { |
| 340 | pc87413_disable(); |
| 341 | printk(KERN_INFO MODNAME "Watchdog disabled," |
| 342 | " sleeping again...\n"); |
| 343 | } else { |
| 344 | printk(KERN_CRIT MODNAME "Unexpected close, not stopping" |
| 345 | " watchdog!\n"); |
| 346 | pc87413_refresh(); |
| 347 | } |
| 348 | |
| 349 | clear_bit(0, &timer_enabled); |
| 350 | expect_close = 0; |
| 351 | |
| 352 | return 0; |
| 353 | } |
Sven Anders & Marcus Junker | 789fc0a | 2006-08-24 17:11:50 +0200 | [diff] [blame] | 354 | |
| 355 | /** |
| 356 | * pc87413_status: |
| 357 | * |
Sven Anders & Marcus Junker | 00b3b3e | 2006-10-16 18:18:09 +0200 | [diff] [blame] | 358 | * return, if the watchdog is enabled (timeout is set...) |
Sven Anders & Marcus Junker | 789fc0a | 2006-08-24 17:11:50 +0200 | [diff] [blame] | 359 | */ |
| 360 | |
Sven Anders & Marcus Junker | 00b3b3e | 2006-10-16 18:18:09 +0200 | [diff] [blame] | 361 | |
Sven Anders & Marcus Junker | 789fc0a | 2006-08-24 17:11:50 +0200 | [diff] [blame] | 362 | static int pc87413_status(void) |
| 363 | { |
Wim Van Sebroeck | 0835caa | 2006-10-23 18:21:52 +0200 | [diff] [blame] | 364 | return 0; /* currently not supported */ |
Sven Anders & Marcus Junker | 789fc0a | 2006-08-24 17:11:50 +0200 | [diff] [blame] | 365 | } |
| 366 | |
| 367 | /** |
| 368 | * pc87413_write: |
| 369 | * @file: file handle to the watchdog |
Sven Anders & Marcus Junker | 00b3b3e | 2006-10-16 18:18:09 +0200 | [diff] [blame] | 370 | * @data: data buffer to write |
| 371 | * @len: length in bytes |
Sven Anders & Marcus Junker | 789fc0a | 2006-08-24 17:11:50 +0200 | [diff] [blame] | 372 | * @ppos: pointer to the position to write. No seeks allowed |
| 373 | * |
| 374 | * A write to a watchdog device is defined as a keepalive signal. Any |
| 375 | * write of data will do, as we we don't define content meaning. |
| 376 | */ |
| 377 | |
Sven Anders & Marcus Junker | 00b3b3e | 2006-10-16 18:18:09 +0200 | [diff] [blame] | 378 | static ssize_t pc87413_write(struct file *file, const char __user *data, |
| 379 | size_t len, loff_t *ppos) |
Sven Anders & Marcus Junker | 789fc0a | 2006-08-24 17:11:50 +0200 | [diff] [blame] | 380 | { |
Sven Anders & Marcus Junker | 00b3b3e | 2006-10-16 18:18:09 +0200 | [diff] [blame] | 381 | /* See if we got the magic character 'V' and reload the timer */ |
| 382 | if (len) { |
| 383 | if (!nowayout) { |
| 384 | size_t i; |
| 385 | |
| 386 | /* reset expect flag */ |
| 387 | expect_close = 0; |
| 388 | |
| 389 | /* scan to see whether or not we got the magic character */ |
| 390 | for (i = 0; i != len; i++) { |
| 391 | char c; |
| 392 | if (get_user(c, data+i)) |
| 393 | return -EFAULT; |
| 394 | if (c == 'V') |
| 395 | expect_close = 42; |
| 396 | } |
| 397 | } |
| 398 | |
| 399 | /* someone wrote to us, we should reload the timer */ |
| 400 | pc87413_refresh(); |
Sven Anders & Marcus Junker | 789fc0a | 2006-08-24 17:11:50 +0200 | [diff] [blame] | 401 | } |
Sven Anders & Marcus Junker | 00b3b3e | 2006-10-16 18:18:09 +0200 | [diff] [blame] | 402 | return len; |
Sven Anders & Marcus Junker | 789fc0a | 2006-08-24 17:11:50 +0200 | [diff] [blame] | 403 | } |
| 404 | |
Sven Anders & Marcus Junker | 00b3b3e | 2006-10-16 18:18:09 +0200 | [diff] [blame] | 405 | /** |
Sven Anders & Marcus Junker | 789fc0a | 2006-08-24 17:11:50 +0200 | [diff] [blame] | 406 | * pc87413_ioctl: |
| 407 | * @inode: inode of the device |
| 408 | * @file: file handle to the device |
| 409 | * @cmd: watchdog command |
| 410 | * @arg: argument pointer |
| 411 | * |
| 412 | * The watchdog API defines a common set of functions for all watchdogs |
| 413 | * according to their available features. We only actually usefully support |
| 414 | * querying capabilities and current status. |
| 415 | */ |
| 416 | |
Sven Anders & Marcus Junker | 00b3b3e | 2006-10-16 18:18:09 +0200 | [diff] [blame] | 417 | static int pc87413_ioctl(struct inode *inode, struct file *file, |
| 418 | unsigned int cmd, unsigned long arg) |
Sven Anders & Marcus Junker | 789fc0a | 2006-08-24 17:11:50 +0200 | [diff] [blame] | 419 | { |
Sven Anders & Marcus Junker | 00b3b3e | 2006-10-16 18:18:09 +0200 | [diff] [blame] | 420 | int new_timeout; |
| 421 | |
| 422 | union { |
| 423 | struct watchdog_info __user *ident; |
| 424 | int __user *i; |
| 425 | } uarg; |
| 426 | |
| 427 | static struct watchdog_info ident = { |
| 428 | .options = WDIOF_KEEPALIVEPING | |
| 429 | WDIOF_SETTIMEOUT | |
| 430 | WDIOF_MAGICCLOSE, |
| 431 | .firmware_version = 1, |
| 432 | .identity = "PC87413(HF/F) watchdog" |
Sven Anders & Marcus Junker | 789fc0a | 2006-08-24 17:11:50 +0200 | [diff] [blame] | 433 | }; |
| 434 | |
Sven Anders & Marcus Junker | 00b3b3e | 2006-10-16 18:18:09 +0200 | [diff] [blame] | 435 | uarg.i = (int __user *)arg; |
Sven Anders & Marcus Junker | 789fc0a | 2006-08-24 17:11:50 +0200 | [diff] [blame] | 436 | |
Sven Anders & Marcus Junker | 00b3b3e | 2006-10-16 18:18:09 +0200 | [diff] [blame] | 437 | switch(cmd) { |
Sven Anders & Marcus Junker | 789fc0a | 2006-08-24 17:11:50 +0200 | [diff] [blame] | 438 | default: |
Sven Anders & Marcus Junker | 00b3b3e | 2006-10-16 18:18:09 +0200 | [diff] [blame] | 439 | return -ENOTTY; |
| 440 | |
Sven Anders & Marcus Junker | 789fc0a | 2006-08-24 17:11:50 +0200 | [diff] [blame] | 441 | case WDIOC_GETSUPPORT: |
Sven Anders & Marcus Junker | 00b3b3e | 2006-10-16 18:18:09 +0200 | [diff] [blame] | 442 | return copy_to_user(uarg.ident, &ident, |
| 443 | sizeof(ident)) ? -EFAULT : 0; |
| 444 | |
Sven Anders & Marcus Junker | 789fc0a | 2006-08-24 17:11:50 +0200 | [diff] [blame] | 445 | case WDIOC_GETSTATUS: |
Sven Anders & Marcus Junker | 00b3b3e | 2006-10-16 18:18:09 +0200 | [diff] [blame] | 446 | return put_user(pc87413_status(), uarg.i); |
| 447 | |
Sven Anders & Marcus Junker | 789fc0a | 2006-08-24 17:11:50 +0200 | [diff] [blame] | 448 | case WDIOC_GETBOOTSTATUS: |
Sven Anders & Marcus Junker | 00b3b3e | 2006-10-16 18:18:09 +0200 | [diff] [blame] | 449 | return put_user(0, uarg.i); |
| 450 | |
Sven Anders & Marcus Junker | 789fc0a | 2006-08-24 17:11:50 +0200 | [diff] [blame] | 451 | case WDIOC_KEEPALIVE: |
Sven Anders & Marcus Junker | 00b3b3e | 2006-10-16 18:18:09 +0200 | [diff] [blame] | 452 | pc87413_refresh(); |
| 453 | #ifdef DEBUG |
| 454 | printk(KERN_INFO DPFX "keepalive\n"); |
Sven Anders & Marcus Junker | 789fc0a | 2006-08-24 17:11:50 +0200 | [diff] [blame] | 455 | #endif |
Sven Anders & Marcus Junker | 00b3b3e | 2006-10-16 18:18:09 +0200 | [diff] [blame] | 456 | return 0; |
| 457 | |
| 458 | case WDIOC_SETTIMEOUT: |
| 459 | if (get_user(new_timeout, uarg.i)) |
| 460 | return -EFAULT; |
| 461 | |
| 462 | // the API states this is given in secs |
| 463 | new_timeout /= 60; |
| 464 | |
| 465 | if (new_timeout < 0 || new_timeout > MAX_TIMEOUT) |
| 466 | return -EINVAL; |
| 467 | |
| 468 | timeout = new_timeout; |
| 469 | pc87413_refresh(); |
| 470 | |
| 471 | // fall through and return the new timeout... |
| 472 | |
| 473 | case WDIOC_GETTIMEOUT: |
| 474 | |
| 475 | new_timeout = timeout * 60; |
| 476 | |
| 477 | return put_user(new_timeout, uarg.i); |
| 478 | |
| 479 | case WDIOC_SETOPTIONS: |
| 480 | { |
| 481 | int options, retval = -EINVAL; |
| 482 | |
| 483 | if (get_user(options, uarg.i)) |
| 484 | return -EFAULT; |
| 485 | |
| 486 | if (options & WDIOS_DISABLECARD) { |
| 487 | pc87413_disable(); |
| 488 | retval = 0; |
| 489 | } |
| 490 | |
| 491 | if (options & WDIOS_ENABLECARD) { |
| 492 | pc87413_enable(); |
| 493 | retval = 0; |
| 494 | } |
| 495 | |
| 496 | return retval; |
| 497 | } |
Sven Anders & Marcus Junker | 789fc0a | 2006-08-24 17:11:50 +0200 | [diff] [blame] | 498 | } |
Sven Anders & Marcus Junker | 789fc0a | 2006-08-24 17:11:50 +0200 | [diff] [blame] | 499 | } |
| 500 | |
Sven Anders & Marcus Junker | 00b3b3e | 2006-10-16 18:18:09 +0200 | [diff] [blame] | 501 | /* -- Notifier funtions -----------------------------------------*/ |
| 502 | |
Sven Anders & Marcus Junker | 789fc0a | 2006-08-24 17:11:50 +0200 | [diff] [blame] | 503 | /** |
| 504 | * notify_sys: |
| 505 | * @this: our notifier block |
| 506 | * @code: the event being reported |
| 507 | * @unused: unused |
| 508 | * |
| 509 | * Our notifier is called on system shutdowns. We want to turn the card |
| 510 | * off at reboot otherwise the machine will reboot again during memory |
| 511 | * test or worse yet during the following fsck. This would suck, in fact |
| 512 | * trust me - if it happens it does suck. |
| 513 | */ |
| 514 | |
Sven Anders & Marcus Junker | 00b3b3e | 2006-10-16 18:18:09 +0200 | [diff] [blame] | 515 | static int pc87413_notify_sys(struct notifier_block *this, |
| 516 | unsigned long code, |
| 517 | void *unused) |
Sven Anders & Marcus Junker | 789fc0a | 2006-08-24 17:11:50 +0200 | [diff] [blame] | 518 | { |
Sven Anders & Marcus Junker | 00b3b3e | 2006-10-16 18:18:09 +0200 | [diff] [blame] | 519 | if (code == SYS_DOWN || code == SYS_HALT) |
Sven Anders & Marcus Junker | 789fc0a | 2006-08-24 17:11:50 +0200 | [diff] [blame] | 520 | { |
| 521 | /* Turn the card off */ |
| 522 | pc87413_disable(); |
| 523 | } |
| 524 | return NOTIFY_DONE; |
| 525 | } |
| 526 | |
Sven Anders & Marcus Junker | 00b3b3e | 2006-10-16 18:18:09 +0200 | [diff] [blame] | 527 | /* -- Module's structures ---------------------------------------*/ |
Sven Anders & Marcus Junker | 789fc0a | 2006-08-24 17:11:50 +0200 | [diff] [blame] | 528 | |
Arjan van de Ven | 2b8693c | 2007-02-12 00:55:32 -0800 | [diff] [blame] | 529 | static const struct file_operations pc87413_fops = { |
Sven Anders & Marcus Junker | 789fc0a | 2006-08-24 17:11:50 +0200 | [diff] [blame] | 530 | .owner = THIS_MODULE, |
Sven Anders & Marcus Junker | 00b3b3e | 2006-10-16 18:18:09 +0200 | [diff] [blame] | 531 | .llseek = no_llseek, |
Sven Anders & Marcus Junker | 789fc0a | 2006-08-24 17:11:50 +0200 | [diff] [blame] | 532 | .write = pc87413_write, |
| 533 | .ioctl = pc87413_ioctl, |
| 534 | .open = pc87413_open, |
| 535 | .release = pc87413_release, |
| 536 | }; |
| 537 | |
Sven Anders & Marcus Junker | 00b3b3e | 2006-10-16 18:18:09 +0200 | [diff] [blame] | 538 | static struct notifier_block pc87413_notifier = |
| 539 | { |
| 540 | .notifier_call = pc87413_notify_sys, |
| 541 | }; |
| 542 | |
Sven Anders & Marcus Junker | 789fc0a | 2006-08-24 17:11:50 +0200 | [diff] [blame] | 543 | static struct miscdevice pc87413_miscdev= |
| 544 | { |
Sven Anders & Marcus Junker | 00b3b3e | 2006-10-16 18:18:09 +0200 | [diff] [blame] | 545 | .minor = WATCHDOG_MINOR, |
| 546 | .name = "watchdog", |
| 547 | .fops = &pc87413_fops |
Sven Anders & Marcus Junker | 789fc0a | 2006-08-24 17:11:50 +0200 | [diff] [blame] | 548 | }; |
| 549 | |
Sven Anders & Marcus Junker | 00b3b3e | 2006-10-16 18:18:09 +0200 | [diff] [blame] | 550 | /* -- Module init functions -------------------------------------*/ |
Sven Anders & Marcus Junker | 789fc0a | 2006-08-24 17:11:50 +0200 | [diff] [blame] | 551 | |
| 552 | /** |
Sven Anders & Marcus Junker | 00b3b3e | 2006-10-16 18:18:09 +0200 | [diff] [blame] | 553 | * pc87413_init: module's "constructor" |
| 554 | * |
| 555 | * Set up the WDT watchdog board. All we have to do is grab the |
| 556 | * resources we require and bitch if anyone beat us to them. |
| 557 | * The open() function will actually kick the board off. |
| 558 | */ |
| 559 | |
| 560 | static int __init pc87413_init(void) |
| 561 | { |
| 562 | int ret; |
| 563 | |
Sven Anders & Marcus Junker | 00b3b3e | 2006-10-16 18:18:09 +0200 | [diff] [blame] | 564 | printk(KERN_INFO PFX "Version " VERSION " at io 0x%X\n", WDT_INDEX_IO_PORT); |
| 565 | |
| 566 | /* request_region(io, 2, "pc87413"); */ |
| 567 | |
| 568 | ret = register_reboot_notifier(&pc87413_notifier); |
| 569 | if (ret != 0) { |
| 570 | printk(KERN_ERR PFX "cannot register reboot notifier (err=%d)\n", |
| 571 | ret); |
| 572 | } |
| 573 | |
| 574 | ret = misc_register(&pc87413_miscdev); |
| 575 | |
| 576 | if (ret != 0) { |
| 577 | printk(KERN_ERR PFX "cannot register miscdev on minor=%d (err=%d)\n", |
| 578 | WATCHDOG_MINOR, ret); |
| 579 | unregister_reboot_notifier(&pc87413_notifier); |
| 580 | return ret; |
| 581 | } |
| 582 | |
| 583 | printk(KERN_INFO PFX "initialized. timeout=%d min \n", timeout); |
| 584 | |
| 585 | pc87413_enable(); |
| 586 | |
| 587 | return 0; |
| 588 | } |
| 589 | |
| 590 | /** |
| 591 | * pc87413_exit: module's "destructor" |
Sven Anders & Marcus Junker | 789fc0a | 2006-08-24 17:11:50 +0200 | [diff] [blame] | 592 | * |
| 593 | * Unload the watchdog. You cannot do this with any file handles open. |
| 594 | * If your watchdog is set to continue ticking on close and you unload |
| 595 | * it, well it keeps ticking. We won't get the interrupt but the board |
| 596 | * will not touch PC memory so all is fine. You just have to load a new |
| 597 | * module in 60 seconds or reboot. |
| 598 | */ |
| 599 | |
Sven Anders & Marcus Junker | 00b3b3e | 2006-10-16 18:18:09 +0200 | [diff] [blame] | 600 | static void __exit pc87413_exit(void) |
Sven Anders & Marcus Junker | 789fc0a | 2006-08-24 17:11:50 +0200 | [diff] [blame] | 601 | { |
Sven Anders & Marcus Junker | 00b3b3e | 2006-10-16 18:18:09 +0200 | [diff] [blame] | 602 | /* Stop the timer before we leave */ |
| 603 | if (!nowayout) |
| 604 | { |
| 605 | pc87413_disable(); |
| 606 | printk(KERN_INFO MODNAME "Watchdog disabled.\n"); |
| 607 | } |
| 608 | |
Sven Anders & Marcus Junker | 789fc0a | 2006-08-24 17:11:50 +0200 | [diff] [blame] | 609 | misc_deregister(&pc87413_miscdev); |
| 610 | unregister_reboot_notifier(&pc87413_notifier); |
| 611 | /* release_region(io,2); */ |
Sven Anders & Marcus Junker | 00b3b3e | 2006-10-16 18:18:09 +0200 | [diff] [blame] | 612 | |
| 613 | printk(MODNAME " watchdog component driver removed.\n"); |
Sven Anders & Marcus Junker | 789fc0a | 2006-08-24 17:11:50 +0200 | [diff] [blame] | 614 | } |
| 615 | |
Sven Anders & Marcus Junker | 789fc0a | 2006-08-24 17:11:50 +0200 | [diff] [blame] | 616 | module_init(pc87413_init); |
| 617 | module_exit(pc87413_exit); |
| 618 | |
Sven Anders & Marcus Junker | 00b3b3e | 2006-10-16 18:18:09 +0200 | [diff] [blame] | 619 | MODULE_AUTHOR("Sven Anders <anders@anduras.de>, Marcus Junker <junker@anduras.de>,"); |
Sven Anders & Marcus Junker | 789fc0a | 2006-08-24 17:11:50 +0200 | [diff] [blame] | 620 | MODULE_DESCRIPTION("PC87413 WDT driver"); |
Sven Anders & Marcus Junker | 00b3b3e | 2006-10-16 18:18:09 +0200 | [diff] [blame] | 621 | MODULE_LICENSE("GPL"); |
| 622 | |
Sven Anders & Marcus Junker | 789fc0a | 2006-08-24 17:11:50 +0200 | [diff] [blame] | 623 | MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR); |
| 624 | |
Sven Anders & Marcus Junker | 00b3b3e | 2006-10-16 18:18:09 +0200 | [diff] [blame] | 625 | module_param(io, int, 0); |
Wim Van Sebroeck | 0835caa | 2006-10-23 18:21:52 +0200 | [diff] [blame] | 626 | MODULE_PARM_DESC(io, MODNAME " I/O port (default: " __MODULE_STRING(io) ")."); |
Sven Anders & Marcus Junker | 00b3b3e | 2006-10-16 18:18:09 +0200 | [diff] [blame] | 627 | |
| 628 | module_param(timeout, int, 0); |
| 629 | MODULE_PARM_DESC(timeout, "Watchdog timeout in minutes (default=" __MODULE_STRING(timeout) ")."); |
| 630 | |
| 631 | module_param(nowayout, int, 0); |
Wim Van Sebroeck | bffda5c | 2007-01-27 20:54:24 +0100 | [diff] [blame] | 632 | MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=" __MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); |
Sven Anders & Marcus Junker | 00b3b3e | 2006-10-16 18:18:09 +0200 | [diff] [blame] | 633 | |