Wim Van Sebroeck | 9e0ea34 | 2006-05-21 14:37:44 +0200 | [diff] [blame] | 1 | /* |
Wim Van Sebroeck | cb711a1 | 2009-11-15 13:44:54 +0000 | [diff] [blame] | 2 | * intel TCO Watchdog Driver |
Wim Van Sebroeck | 9e0ea34 | 2006-05-21 14:37:44 +0200 | [diff] [blame] | 3 | * |
Wim Van Sebroeck | deb9197 | 2011-10-19 23:59:26 +0200 | [diff] [blame] | 4 | * (c) Copyright 2006-2011 Wim Van Sebroeck <wim@iguana.be>. |
Wim Van Sebroeck | 9e0ea34 | 2006-05-21 14:37:44 +0200 | [diff] [blame] | 5 | * |
| 6 | * This program is free software; you can redistribute it and/or |
| 7 | * modify it under the terms of the GNU General Public License |
| 8 | * as published by the Free Software Foundation; either version |
| 9 | * 2 of the License, or (at your option) any later version. |
| 10 | * |
| 11 | * Neither Wim Van Sebroeck nor Iguana vzw. admit liability nor |
| 12 | * provide warranty for any of this software. This material is |
| 13 | * provided "AS-IS" and at no charge. |
| 14 | * |
| 15 | * The TCO watchdog is implemented in the following I/O controller hubs: |
| 16 | * (See the intel documentation on http://developer.intel.com.) |
Wim Van Sebroeck | cb711a1 | 2009-11-15 13:44:54 +0000 | [diff] [blame] | 17 | * document number 290655-003, 290677-014: 82801AA (ICH), 82801AB (ICHO) |
| 18 | * document number 290687-002, 298242-027: 82801BA (ICH2) |
| 19 | * document number 290733-003, 290739-013: 82801CA (ICH3-S) |
| 20 | * document number 290716-001, 290718-007: 82801CAM (ICH3-M) |
| 21 | * document number 290744-001, 290745-025: 82801DB (ICH4) |
| 22 | * document number 252337-001, 252663-008: 82801DBM (ICH4-M) |
| 23 | * document number 273599-001, 273645-002: 82801E (C-ICH) |
| 24 | * document number 252516-001, 252517-028: 82801EB (ICH5), 82801ER (ICH5R) |
| 25 | * document number 300641-004, 300884-013: 6300ESB |
| 26 | * document number 301473-002, 301474-026: 82801F (ICH6) |
| 27 | * document number 313082-001, 313075-006: 631xESB, 632xESB |
| 28 | * document number 307013-003, 307014-024: 82801G (ICH7) |
Wim Van Sebroeck | d38bd47 | 2010-12-31 14:10:45 +0000 | [diff] [blame] | 29 | * document number 322896-001, 322897-001: NM10 |
Wim Van Sebroeck | cb711a1 | 2009-11-15 13:44:54 +0000 | [diff] [blame] | 30 | * document number 313056-003, 313057-017: 82801H (ICH8) |
| 31 | * document number 316972-004, 316973-012: 82801I (ICH9) |
| 32 | * document number 319973-002, 319974-002: 82801J (ICH10) |
Seth Heasley | 3c9d8ec | 2010-01-14 20:58:05 +0000 | [diff] [blame] | 33 | * document number 322169-001, 322170-003: 5 Series, 3400 Series (PCH) |
Imre Kaloz | 4946f83 | 2009-12-07 20:42:26 +0100 | [diff] [blame] | 34 | * document number 320066-003, 320257-008: EP80597 (IICH) |
Seth Heasley | 203f8d8 | 2011-01-07 17:11:08 -0800 | [diff] [blame] | 35 | * document number 324645-001, 324646-001: Cougar Point (CPT) |
Seth Heasley | c54fb81 | 2010-11-17 12:15:08 -0700 | [diff] [blame] | 36 | * document number TBD : Patsburg (PBG) |
Seth Heasley | 203f8d8 | 2011-01-07 17:11:08 -0800 | [diff] [blame] | 37 | * document number TBD : DH89xxCC |
Seth Heasley | aa1f465 | 2011-04-20 10:56:20 -0700 | [diff] [blame] | 38 | * document number TBD : Panther Point |
Seth Heasley | 84e83c2 | 2012-01-23 16:40:55 -0800 | [diff] [blame] | 39 | * document number TBD : Lynx Point |
Wim Van Sebroeck | 9e0ea34 | 2006-05-21 14:37:44 +0200 | [diff] [blame] | 40 | */ |
| 41 | |
| 42 | /* |
| 43 | * Includes, defines, variables, module parameters, ... |
| 44 | */ |
| 45 | |
Joe Perches | 27c766a | 2012-02-15 15:06:19 -0800 | [diff] [blame] | 46 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt |
| 47 | |
Wim Van Sebroeck | 9e0ea34 | 2006-05-21 14:37:44 +0200 | [diff] [blame] | 48 | /* Module and version information */ |
Wim Van Sebroeck | 7944d3a | 2008-08-06 20:19:41 +0000 | [diff] [blame] | 49 | #define DRV_NAME "iTCO_wdt" |
Wim Van Sebroeck | bff2343 | 2012-06-09 14:10:28 +0200 | [diff] [blame] | 50 | #define DRV_VERSION "1.10" |
Wim Van Sebroeck | 9e0ea34 | 2006-05-21 14:37:44 +0200 | [diff] [blame] | 51 | |
| 52 | /* Includes */ |
Wim Van Sebroeck | 3836cc0 | 2006-06-30 08:44:53 +0200 | [diff] [blame] | 53 | #include <linux/module.h> /* For module specific items */ |
| 54 | #include <linux/moduleparam.h> /* For new moduleparam's */ |
| 55 | #include <linux/types.h> /* For standard types (like size_t) */ |
| 56 | #include <linux/errno.h> /* For the -ENODEV/... values */ |
| 57 | #include <linux/kernel.h> /* For printk/panic/... */ |
Alan Cox | 0e6fa3f | 2008-05-19 14:06:25 +0100 | [diff] [blame] | 58 | #include <linux/miscdevice.h> /* For MODULE_ALIAS_MISCDEV |
| 59 | (WATCHDOG_MINOR) */ |
Wim Van Sebroeck | 3836cc0 | 2006-06-30 08:44:53 +0200 | [diff] [blame] | 60 | #include <linux/watchdog.h> /* For the watchdog specific items */ |
Wim Van Sebroeck | 3836cc0 | 2006-06-30 08:44:53 +0200 | [diff] [blame] | 61 | #include <linux/init.h> /* For __init/__exit/... */ |
| 62 | #include <linux/fs.h> /* For file operations */ |
| 63 | #include <linux/platform_device.h> /* For platform_driver framework */ |
| 64 | #include <linux/pci.h> /* For pci functions */ |
| 65 | #include <linux/ioport.h> /* For io-port access */ |
| 66 | #include <linux/spinlock.h> /* For spin_lock/spin_unlock/... */ |
Alan Cox | 0e6fa3f | 2008-05-19 14:06:25 +0100 | [diff] [blame] | 67 | #include <linux/uaccess.h> /* For copy_to_user/put_user/... */ |
| 68 | #include <linux/io.h> /* For inb/outb/... */ |
Aaron Sierra | 887c8ec | 2012-04-20 14:14:11 -0500 | [diff] [blame] | 69 | #include <linux/mfd/core.h> |
| 70 | #include <linux/mfd/lpc_ich.h> |
Wim Van Sebroeck | 9e0ea34 | 2006-05-21 14:37:44 +0200 | [diff] [blame] | 71 | |
Alan Cox | 0e6fa3f | 2008-05-19 14:06:25 +0100 | [diff] [blame] | 72 | #include "iTCO_vendor.h" |
Wim Van Sebroeck | 9e0ea34 | 2006-05-21 14:37:44 +0200 | [diff] [blame] | 73 | |
Wim Van Sebroeck | 9e0ea34 | 2006-05-21 14:37:44 +0200 | [diff] [blame] | 74 | /* Address definitions for the TCO */ |
Alan Cox | 0e6fa3f | 2008-05-19 14:06:25 +0100 | [diff] [blame] | 75 | /* TCO base address */ |
Aaron Sierra | 887c8ec | 2012-04-20 14:14:11 -0500 | [diff] [blame] | 76 | #define TCOBASE (iTCO_wdt_private.tco_res->start) |
Alan Cox | 0e6fa3f | 2008-05-19 14:06:25 +0100 | [diff] [blame] | 77 | /* SMI Control and Enable Register */ |
Aaron Sierra | 887c8ec | 2012-04-20 14:14:11 -0500 | [diff] [blame] | 78 | #define SMI_EN (iTCO_wdt_private.smi_res->start) |
Wim Van Sebroeck | 9e0ea34 | 2006-05-21 14:37:44 +0200 | [diff] [blame] | 79 | |
Wim Van Sebroeck | 0a7e6582 | 2009-04-14 20:20:07 +0000 | [diff] [blame] | 80 | #define TCO_RLD (TCOBASE + 0x00) /* TCO Timer Reload and Curr. Value */ |
| 81 | #define TCOv1_TMR (TCOBASE + 0x01) /* TCOv1 Timer Initial Value */ |
| 82 | #define TCO_DAT_IN (TCOBASE + 0x02) /* TCO Data In Register */ |
| 83 | #define TCO_DAT_OUT (TCOBASE + 0x03) /* TCO Data Out Register */ |
| 84 | #define TCO1_STS (TCOBASE + 0x04) /* TCO1 Status Register */ |
| 85 | #define TCO2_STS (TCOBASE + 0x06) /* TCO2 Status Register */ |
| 86 | #define TCO1_CNT (TCOBASE + 0x08) /* TCO1 Control Register */ |
| 87 | #define TCO2_CNT (TCOBASE + 0x0a) /* TCO2 Control Register */ |
| 88 | #define TCOv2_TMR (TCOBASE + 0x12) /* TCOv2 Timer Initial Value */ |
Wim Van Sebroeck | 9e0ea34 | 2006-05-21 14:37:44 +0200 | [diff] [blame] | 89 | |
| 90 | /* internal variables */ |
Alan Cox | 0e6fa3f | 2008-05-19 14:06:25 +0100 | [diff] [blame] | 91 | static struct { /* this is private data for the iTCO_wdt device */ |
| 92 | /* TCO version/generation */ |
| 93 | unsigned int iTCO_version; |
Aaron Sierra | 887c8ec | 2012-04-20 14:14:11 -0500 | [diff] [blame] | 94 | struct resource *tco_res; |
| 95 | struct resource *smi_res; |
| 96 | struct resource *gcs_res; |
Alan Cox | 0e6fa3f | 2008-05-19 14:06:25 +0100 | [diff] [blame] | 97 | /* NO_REBOOT flag is Memory-Mapped GCS register bit 5 (TCO version 2)*/ |
| 98 | unsigned long __iomem *gcs; |
| 99 | /* the lock for io operations */ |
| 100 | spinlock_t io_lock; |
Aaron Sierra | 887c8ec | 2012-04-20 14:14:11 -0500 | [diff] [blame] | 101 | struct platform_device *dev; |
Alan Cox | 0e6fa3f | 2008-05-19 14:06:25 +0100 | [diff] [blame] | 102 | /* the PCI-device */ |
| 103 | struct pci_dev *pdev; |
Wim Van Sebroeck | 9e0ea34 | 2006-05-21 14:37:44 +0200 | [diff] [blame] | 104 | } iTCO_wdt_private; |
| 105 | |
| 106 | /* module parameters */ |
Wim Van Sebroeck | bff2343 | 2012-06-09 14:10:28 +0200 | [diff] [blame] | 107 | #define WATCHDOG_TIMEOUT 30 /* 30 sec default heartbeat */ |
| 108 | static int heartbeat = WATCHDOG_TIMEOUT; /* in seconds */ |
Wim Van Sebroeck | 9e0ea34 | 2006-05-21 14:37:44 +0200 | [diff] [blame] | 109 | module_param(heartbeat, int, 0); |
Pádraig Brady | 7e6811d | 2010-04-19 13:38:25 +0100 | [diff] [blame] | 110 | MODULE_PARM_DESC(heartbeat, "Watchdog timeout in seconds. " |
| 111 | "5..76 (TCO v1) or 3..614 (TCO v2), default=" |
Wim Van Sebroeck | bff2343 | 2012-06-09 14:10:28 +0200 | [diff] [blame] | 112 | __MODULE_STRING(WATCHDOG_TIMEOUT) ")"); |
Wim Van Sebroeck | 9e0ea34 | 2006-05-21 14:37:44 +0200 | [diff] [blame] | 113 | |
Wim Van Sebroeck | 86a1e18 | 2012-03-05 16:51:11 +0100 | [diff] [blame] | 114 | static bool nowayout = WATCHDOG_NOWAYOUT; |
| 115 | module_param(nowayout, bool, 0); |
Alan Cox | 0e6fa3f | 2008-05-19 14:06:25 +0100 | [diff] [blame] | 116 | MODULE_PARM_DESC(nowayout, |
| 117 | "Watchdog cannot be stopped once started (default=" |
| 118 | __MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); |
Wim Van Sebroeck | e033351 | 2006-11-12 18:05:09 +0100 | [diff] [blame] | 119 | |
Wim Van Sebroeck | 0d09858 | 2011-12-26 15:23:51 +0100 | [diff] [blame] | 120 | static int turn_SMI_watchdog_clear_off = 1; |
Wim Van Sebroeck | deb9197 | 2011-10-19 23:59:26 +0200 | [diff] [blame] | 121 | module_param(turn_SMI_watchdog_clear_off, int, 0); |
| 122 | MODULE_PARM_DESC(turn_SMI_watchdog_clear_off, |
Wim Van Sebroeck | 0d09858 | 2011-12-26 15:23:51 +0100 | [diff] [blame] | 123 | "Turn off SMI clearing watchdog (depends on TCO-version)(default=1)"); |
Wim Van Sebroeck | deb9197 | 2011-10-19 23:59:26 +0200 | [diff] [blame] | 124 | |
Wim Van Sebroeck | 9e0ea34 | 2006-05-21 14:37:44 +0200 | [diff] [blame] | 125 | /* |
| 126 | * Some TCO specific functions |
| 127 | */ |
| 128 | |
| 129 | static inline unsigned int seconds_to_ticks(int seconds) |
| 130 | { |
| 131 | /* the internal timer is stored as ticks which decrement |
| 132 | * every 0.6 seconds */ |
| 133 | return (seconds * 10) / 6; |
| 134 | } |
| 135 | |
| 136 | static void iTCO_wdt_set_NO_REBOOT_bit(void) |
| 137 | { |
| 138 | u32 val32; |
| 139 | |
| 140 | /* Set the NO_REBOOT bit: this disables reboots */ |
| 141 | if (iTCO_wdt_private.iTCO_version == 2) { |
| 142 | val32 = readl(iTCO_wdt_private.gcs); |
| 143 | val32 |= 0x00000020; |
| 144 | writel(val32, iTCO_wdt_private.gcs); |
| 145 | } else if (iTCO_wdt_private.iTCO_version == 1) { |
| 146 | pci_read_config_dword(iTCO_wdt_private.pdev, 0xd4, &val32); |
| 147 | val32 |= 0x00000002; |
| 148 | pci_write_config_dword(iTCO_wdt_private.pdev, 0xd4, val32); |
| 149 | } |
| 150 | } |
| 151 | |
| 152 | static int iTCO_wdt_unset_NO_REBOOT_bit(void) |
| 153 | { |
| 154 | int ret = 0; |
| 155 | u32 val32; |
| 156 | |
| 157 | /* Unset the NO_REBOOT bit: this enables reboots */ |
| 158 | if (iTCO_wdt_private.iTCO_version == 2) { |
| 159 | val32 = readl(iTCO_wdt_private.gcs); |
| 160 | val32 &= 0xffffffdf; |
| 161 | writel(val32, iTCO_wdt_private.gcs); |
| 162 | |
| 163 | val32 = readl(iTCO_wdt_private.gcs); |
| 164 | if (val32 & 0x00000020) |
| 165 | ret = -EIO; |
| 166 | } else if (iTCO_wdt_private.iTCO_version == 1) { |
| 167 | pci_read_config_dword(iTCO_wdt_private.pdev, 0xd4, &val32); |
| 168 | val32 &= 0xfffffffd; |
| 169 | pci_write_config_dword(iTCO_wdt_private.pdev, 0xd4, val32); |
| 170 | |
| 171 | pci_read_config_dword(iTCO_wdt_private.pdev, 0xd4, &val32); |
| 172 | if (val32 & 0x00000002) |
| 173 | ret = -EIO; |
| 174 | } |
| 175 | |
| 176 | return ret; /* returns: 0 = OK, -EIO = Error */ |
| 177 | } |
| 178 | |
Wim Van Sebroeck | bff2343 | 2012-06-09 14:10:28 +0200 | [diff] [blame] | 179 | static int iTCO_wdt_start(struct watchdog_device *wd_dev) |
Wim Van Sebroeck | 9e0ea34 | 2006-05-21 14:37:44 +0200 | [diff] [blame] | 180 | { |
| 181 | unsigned int val; |
| 182 | |
| 183 | spin_lock(&iTCO_wdt_private.io_lock); |
| 184 | |
Wim Van Sebroeck | bff2343 | 2012-06-09 14:10:28 +0200 | [diff] [blame] | 185 | iTCO_vendor_pre_start(iTCO_wdt_private.smi_res, wd_dev->timeout); |
Wim Van Sebroeck | e033351 | 2006-11-12 18:05:09 +0100 | [diff] [blame] | 186 | |
Wim Van Sebroeck | 9e0ea34 | 2006-05-21 14:37:44 +0200 | [diff] [blame] | 187 | /* disable chipset's NO_REBOOT bit */ |
| 188 | if (iTCO_wdt_unset_NO_REBOOT_bit()) { |
Roel Kluin | 2ba7d7b | 2007-10-23 03:08:27 +0200 | [diff] [blame] | 189 | spin_unlock(&iTCO_wdt_private.io_lock); |
Joe Perches | 27c766a | 2012-02-15 15:06:19 -0800 | [diff] [blame] | 190 | pr_err("failed to reset NO_REBOOT flag, reboot disabled by hardware/BIOS\n"); |
Wim Van Sebroeck | 9e0ea34 | 2006-05-21 14:37:44 +0200 | [diff] [blame] | 191 | return -EIO; |
| 192 | } |
| 193 | |
Wim Van Sebroeck | 7cd5b08 | 2008-11-19 19:39:58 +0000 | [diff] [blame] | 194 | /* Force the timer to its reload value by writing to the TCO_RLD |
| 195 | register */ |
| 196 | if (iTCO_wdt_private.iTCO_version == 2) |
| 197 | outw(0x01, TCO_RLD); |
| 198 | else if (iTCO_wdt_private.iTCO_version == 1) |
| 199 | outb(0x01, TCO_RLD); |
| 200 | |
Wim Van Sebroeck | 9e0ea34 | 2006-05-21 14:37:44 +0200 | [diff] [blame] | 201 | /* Bit 11: TCO Timer Halt -> 0 = The TCO timer is enabled to count */ |
| 202 | val = inw(TCO1_CNT); |
| 203 | val &= 0xf7ff; |
| 204 | outw(val, TCO1_CNT); |
| 205 | val = inw(TCO1_CNT); |
| 206 | spin_unlock(&iTCO_wdt_private.io_lock); |
| 207 | |
| 208 | if (val & 0x0800) |
| 209 | return -1; |
| 210 | return 0; |
| 211 | } |
| 212 | |
Wim Van Sebroeck | bff2343 | 2012-06-09 14:10:28 +0200 | [diff] [blame] | 213 | static int iTCO_wdt_stop(struct watchdog_device *wd_dev) |
Wim Van Sebroeck | 9e0ea34 | 2006-05-21 14:37:44 +0200 | [diff] [blame] | 214 | { |
| 215 | unsigned int val; |
| 216 | |
| 217 | spin_lock(&iTCO_wdt_private.io_lock); |
| 218 | |
Aaron Sierra | 887c8ec | 2012-04-20 14:14:11 -0500 | [diff] [blame] | 219 | iTCO_vendor_pre_stop(iTCO_wdt_private.smi_res); |
Wim Van Sebroeck | e033351 | 2006-11-12 18:05:09 +0100 | [diff] [blame] | 220 | |
Wim Van Sebroeck | 9e0ea34 | 2006-05-21 14:37:44 +0200 | [diff] [blame] | 221 | /* Bit 11: TCO Timer Halt -> 1 = The TCO timer is disabled */ |
| 222 | val = inw(TCO1_CNT); |
| 223 | val |= 0x0800; |
| 224 | outw(val, TCO1_CNT); |
| 225 | val = inw(TCO1_CNT); |
| 226 | |
| 227 | /* Set the NO_REBOOT bit to prevent later reboots, just for sure */ |
| 228 | iTCO_wdt_set_NO_REBOOT_bit(); |
| 229 | |
| 230 | spin_unlock(&iTCO_wdt_private.io_lock); |
| 231 | |
| 232 | if ((val & 0x0800) == 0) |
| 233 | return -1; |
| 234 | return 0; |
| 235 | } |
| 236 | |
Wim Van Sebroeck | bff2343 | 2012-06-09 14:10:28 +0200 | [diff] [blame] | 237 | static int iTCO_wdt_ping(struct watchdog_device *wd_dev) |
Wim Van Sebroeck | 9e0ea34 | 2006-05-21 14:37:44 +0200 | [diff] [blame] | 238 | { |
| 239 | spin_lock(&iTCO_wdt_private.io_lock); |
| 240 | |
Wim Van Sebroeck | bff2343 | 2012-06-09 14:10:28 +0200 | [diff] [blame] | 241 | iTCO_vendor_pre_keepalive(iTCO_wdt_private.smi_res, wd_dev->timeout); |
Wim Van Sebroeck | e033351 | 2006-11-12 18:05:09 +0100 | [diff] [blame] | 242 | |
Wim Van Sebroeck | 9e0ea34 | 2006-05-21 14:37:44 +0200 | [diff] [blame] | 243 | /* Reload the timer by writing to the TCO Timer Counter register */ |
Alan Cox | 0e6fa3f | 2008-05-19 14:06:25 +0100 | [diff] [blame] | 244 | if (iTCO_wdt_private.iTCO_version == 2) |
Wim Van Sebroeck | 9e0ea34 | 2006-05-21 14:37:44 +0200 | [diff] [blame] | 245 | outw(0x01, TCO_RLD); |
Pádraig Brady | 7e6811d | 2010-04-19 13:38:25 +0100 | [diff] [blame] | 246 | else if (iTCO_wdt_private.iTCO_version == 1) { |
| 247 | /* Reset the timeout status bit so that the timer |
| 248 | * needs to count down twice again before rebooting */ |
| 249 | outw(0x0008, TCO1_STS); /* write 1 to clear bit */ |
| 250 | |
Wim Van Sebroeck | 9e0ea34 | 2006-05-21 14:37:44 +0200 | [diff] [blame] | 251 | outb(0x01, TCO_RLD); |
Pádraig Brady | 7e6811d | 2010-04-19 13:38:25 +0100 | [diff] [blame] | 252 | } |
Wim Van Sebroeck | 9e0ea34 | 2006-05-21 14:37:44 +0200 | [diff] [blame] | 253 | |
| 254 | spin_unlock(&iTCO_wdt_private.io_lock); |
| 255 | return 0; |
| 256 | } |
| 257 | |
Wim Van Sebroeck | bff2343 | 2012-06-09 14:10:28 +0200 | [diff] [blame] | 258 | static int iTCO_wdt_set_timeout(struct watchdog_device *wd_dev, unsigned int t) |
Wim Van Sebroeck | 9e0ea34 | 2006-05-21 14:37:44 +0200 | [diff] [blame] | 259 | { |
| 260 | unsigned int val16; |
| 261 | unsigned char val8; |
| 262 | unsigned int tmrval; |
| 263 | |
| 264 | tmrval = seconds_to_ticks(t); |
Pádraig Brady | 7e6811d | 2010-04-19 13:38:25 +0100 | [diff] [blame] | 265 | |
| 266 | /* For TCO v1 the timer counts down twice before rebooting */ |
| 267 | if (iTCO_wdt_private.iTCO_version == 1) |
| 268 | tmrval /= 2; |
| 269 | |
Wim Van Sebroeck | 9e0ea34 | 2006-05-21 14:37:44 +0200 | [diff] [blame] | 270 | /* from the specs: */ |
| 271 | /* "Values of 0h-3h are ignored and should not be attempted" */ |
| 272 | if (tmrval < 0x04) |
| 273 | return -EINVAL; |
| 274 | if (((iTCO_wdt_private.iTCO_version == 2) && (tmrval > 0x3ff)) || |
| 275 | ((iTCO_wdt_private.iTCO_version == 1) && (tmrval > 0x03f))) |
| 276 | return -EINVAL; |
| 277 | |
Wim Van Sebroeck | e033351 | 2006-11-12 18:05:09 +0100 | [diff] [blame] | 278 | iTCO_vendor_pre_set_heartbeat(tmrval); |
| 279 | |
Wim Van Sebroeck | 9e0ea34 | 2006-05-21 14:37:44 +0200 | [diff] [blame] | 280 | /* Write new heartbeat to watchdog */ |
| 281 | if (iTCO_wdt_private.iTCO_version == 2) { |
| 282 | spin_lock(&iTCO_wdt_private.io_lock); |
| 283 | val16 = inw(TCOv2_TMR); |
| 284 | val16 &= 0xfc00; |
| 285 | val16 |= tmrval; |
| 286 | outw(val16, TCOv2_TMR); |
| 287 | val16 = inw(TCOv2_TMR); |
| 288 | spin_unlock(&iTCO_wdt_private.io_lock); |
| 289 | |
| 290 | if ((val16 & 0x3ff) != tmrval) |
| 291 | return -EINVAL; |
| 292 | } else if (iTCO_wdt_private.iTCO_version == 1) { |
| 293 | spin_lock(&iTCO_wdt_private.io_lock); |
| 294 | val8 = inb(TCOv1_TMR); |
| 295 | val8 &= 0xc0; |
| 296 | val8 |= (tmrval & 0xff); |
| 297 | outb(val8, TCOv1_TMR); |
| 298 | val8 = inb(TCOv1_TMR); |
| 299 | spin_unlock(&iTCO_wdt_private.io_lock); |
| 300 | |
| 301 | if ((val8 & 0x3f) != tmrval) |
| 302 | return -EINVAL; |
| 303 | } |
| 304 | |
Wim Van Sebroeck | bff2343 | 2012-06-09 14:10:28 +0200 | [diff] [blame] | 305 | wd_dev->timeout = t; |
Wim Van Sebroeck | 9e0ea34 | 2006-05-21 14:37:44 +0200 | [diff] [blame] | 306 | return 0; |
| 307 | } |
| 308 | |
Wim Van Sebroeck | bff2343 | 2012-06-09 14:10:28 +0200 | [diff] [blame] | 309 | static unsigned int iTCO_wdt_get_timeleft(struct watchdog_device *wd_dev) |
Wim Van Sebroeck | 9e0ea34 | 2006-05-21 14:37:44 +0200 | [diff] [blame] | 310 | { |
| 311 | unsigned int val16; |
| 312 | unsigned char val8; |
Wim Van Sebroeck | bff2343 | 2012-06-09 14:10:28 +0200 | [diff] [blame] | 313 | unsigned int time_left = 0; |
Wim Van Sebroeck | 9e0ea34 | 2006-05-21 14:37:44 +0200 | [diff] [blame] | 314 | |
| 315 | /* read the TCO Timer */ |
| 316 | if (iTCO_wdt_private.iTCO_version == 2) { |
| 317 | spin_lock(&iTCO_wdt_private.io_lock); |
| 318 | val16 = inw(TCO_RLD); |
| 319 | val16 &= 0x3ff; |
| 320 | spin_unlock(&iTCO_wdt_private.io_lock); |
| 321 | |
Wim Van Sebroeck | bff2343 | 2012-06-09 14:10:28 +0200 | [diff] [blame] | 322 | time_left = (val16 * 6) / 10; |
Wim Van Sebroeck | 9e0ea34 | 2006-05-21 14:37:44 +0200 | [diff] [blame] | 323 | } else if (iTCO_wdt_private.iTCO_version == 1) { |
| 324 | spin_lock(&iTCO_wdt_private.io_lock); |
| 325 | val8 = inb(TCO_RLD); |
| 326 | val8 &= 0x3f; |
Pádraig Brady | 7e6811d | 2010-04-19 13:38:25 +0100 | [diff] [blame] | 327 | if (!(inw(TCO1_STS) & 0x0008)) |
| 328 | val8 += (inb(TCOv1_TMR) & 0x3f); |
Wim Van Sebroeck | 9e0ea34 | 2006-05-21 14:37:44 +0200 | [diff] [blame] | 329 | spin_unlock(&iTCO_wdt_private.io_lock); |
| 330 | |
Wim Van Sebroeck | bff2343 | 2012-06-09 14:10:28 +0200 | [diff] [blame] | 331 | time_left = (val8 * 6) / 10; |
Wim Van Sebroeck | 9e0ea34 | 2006-05-21 14:37:44 +0200 | [diff] [blame] | 332 | } |
Wim Van Sebroeck | bff2343 | 2012-06-09 14:10:28 +0200 | [diff] [blame] | 333 | return time_left; |
Wim Van Sebroeck | 9e0ea34 | 2006-05-21 14:37:44 +0200 | [diff] [blame] | 334 | } |
| 335 | |
| 336 | /* |
Wim Van Sebroeck | 9e0ea34 | 2006-05-21 14:37:44 +0200 | [diff] [blame] | 337 | * Kernel Interfaces |
| 338 | */ |
| 339 | |
Wim Van Sebroeck | bff2343 | 2012-06-09 14:10:28 +0200 | [diff] [blame] | 340 | static const struct watchdog_info ident = { |
| 341 | .options = WDIOF_SETTIMEOUT | |
| 342 | WDIOF_KEEPALIVEPING | |
| 343 | WDIOF_MAGICCLOSE, |
| 344 | .firmware_version = 0, |
| 345 | .identity = DRV_NAME, |
Wim Van Sebroeck | 9e0ea34 | 2006-05-21 14:37:44 +0200 | [diff] [blame] | 346 | }; |
| 347 | |
Wim Van Sebroeck | bff2343 | 2012-06-09 14:10:28 +0200 | [diff] [blame] | 348 | static const struct watchdog_ops iTCO_wdt_ops = { |
| 349 | .owner = THIS_MODULE, |
| 350 | .start = iTCO_wdt_start, |
| 351 | .stop = iTCO_wdt_stop, |
| 352 | .ping = iTCO_wdt_ping, |
| 353 | .set_timeout = iTCO_wdt_set_timeout, |
| 354 | .get_timeleft = iTCO_wdt_get_timeleft, |
| 355 | }; |
| 356 | |
| 357 | static struct watchdog_device iTCO_wdt_watchdog_dev = { |
| 358 | .info = &ident, |
| 359 | .ops = &iTCO_wdt_ops, |
Wim Van Sebroeck | 9e0ea34 | 2006-05-21 14:37:44 +0200 | [diff] [blame] | 360 | }; |
| 361 | |
Wim Van Sebroeck | 9e0ea34 | 2006-05-21 14:37:44 +0200 | [diff] [blame] | 362 | /* |
| 363 | * Init & exit routines |
| 364 | */ |
| 365 | |
Aaron Sierra | 887c8ec | 2012-04-20 14:14:11 -0500 | [diff] [blame] | 366 | static void __devexit iTCO_wdt_cleanup(void) |
Wim Van Sebroeck | 9e0ea34 | 2006-05-21 14:37:44 +0200 | [diff] [blame] | 367 | { |
Aaron Sierra | 887c8ec | 2012-04-20 14:14:11 -0500 | [diff] [blame] | 368 | /* Stop the timer before we leave */ |
| 369 | if (!nowayout) |
Wim Van Sebroeck | bff2343 | 2012-06-09 14:10:28 +0200 | [diff] [blame] | 370 | iTCO_wdt_stop(&iTCO_wdt_watchdog_dev); |
Aaron Sierra | 887c8ec | 2012-04-20 14:14:11 -0500 | [diff] [blame] | 371 | |
| 372 | /* Deregister */ |
Wim Van Sebroeck | bff2343 | 2012-06-09 14:10:28 +0200 | [diff] [blame] | 373 | watchdog_unregister_device(&iTCO_wdt_watchdog_dev); |
Aaron Sierra | 887c8ec | 2012-04-20 14:14:11 -0500 | [diff] [blame] | 374 | |
| 375 | /* release resources */ |
| 376 | release_region(iTCO_wdt_private.tco_res->start, |
| 377 | resource_size(iTCO_wdt_private.tco_res)); |
| 378 | release_region(iTCO_wdt_private.smi_res->start, |
| 379 | resource_size(iTCO_wdt_private.smi_res)); |
| 380 | if (iTCO_wdt_private.iTCO_version == 2) { |
| 381 | iounmap(iTCO_wdt_private.gcs); |
| 382 | release_mem_region(iTCO_wdt_private.gcs_res->start, |
| 383 | resource_size(iTCO_wdt_private.gcs_res)); |
| 384 | } |
| 385 | |
| 386 | iTCO_wdt_private.tco_res = NULL; |
| 387 | iTCO_wdt_private.smi_res = NULL; |
| 388 | iTCO_wdt_private.gcs_res = NULL; |
| 389 | iTCO_wdt_private.gcs = NULL; |
| 390 | } |
| 391 | |
| 392 | static int __devinit iTCO_wdt_probe(struct platform_device *dev) |
| 393 | { |
| 394 | int ret = -ENODEV; |
Wim Van Sebroeck | 12d60e2 | 2009-01-28 20:51:04 +0000 | [diff] [blame] | 395 | unsigned long val32; |
Aaron Sierra | 887c8ec | 2012-04-20 14:14:11 -0500 | [diff] [blame] | 396 | struct lpc_ich_info *ich_info = dev->dev.platform_data; |
| 397 | |
| 398 | if (!ich_info) |
| 399 | goto out; |
| 400 | |
| 401 | spin_lock_init(&iTCO_wdt_private.io_lock); |
| 402 | |
| 403 | iTCO_wdt_private.tco_res = |
| 404 | platform_get_resource(dev, IORESOURCE_IO, ICH_RES_IO_TCO); |
| 405 | if (!iTCO_wdt_private.tco_res) |
| 406 | goto out; |
| 407 | |
| 408 | iTCO_wdt_private.smi_res = |
| 409 | platform_get_resource(dev, IORESOURCE_IO, ICH_RES_IO_SMI); |
| 410 | if (!iTCO_wdt_private.smi_res) |
| 411 | goto out; |
| 412 | |
| 413 | iTCO_wdt_private.iTCO_version = ich_info->iTCO_version; |
| 414 | iTCO_wdt_private.dev = dev; |
| 415 | iTCO_wdt_private.pdev = to_pci_dev(dev->dev.parent); |
Wim Van Sebroeck | 9e0ea34 | 2006-05-21 14:37:44 +0200 | [diff] [blame] | 416 | |
| 417 | /* |
Aaron Sierra | 887c8ec | 2012-04-20 14:14:11 -0500 | [diff] [blame] | 418 | * Get the Memory-Mapped GCS register, we need it for the |
| 419 | * NO_REBOOT flag (TCO v2). |
Wim Van Sebroeck | 9e0ea34 | 2006-05-21 14:37:44 +0200 | [diff] [blame] | 420 | */ |
Wim Van Sebroeck | 9e0ea34 | 2006-05-21 14:37:44 +0200 | [diff] [blame] | 421 | if (iTCO_wdt_private.iTCO_version == 2) { |
Aaron Sierra | 887c8ec | 2012-04-20 14:14:11 -0500 | [diff] [blame] | 422 | iTCO_wdt_private.gcs_res = platform_get_resource(dev, |
| 423 | IORESOURCE_MEM, |
| 424 | ICH_RES_MEM_GCS); |
| 425 | |
| 426 | if (!iTCO_wdt_private.gcs_res) |
| 427 | goto out; |
| 428 | |
| 429 | if (!request_mem_region(iTCO_wdt_private.gcs_res->start, |
| 430 | resource_size(iTCO_wdt_private.gcs_res), dev->name)) { |
| 431 | ret = -EBUSY; |
Denis V. Lunev | de8cd9a | 2009-06-05 15:13:08 +0400 | [diff] [blame] | 432 | goto out; |
| 433 | } |
Aaron Sierra | 887c8ec | 2012-04-20 14:14:11 -0500 | [diff] [blame] | 434 | iTCO_wdt_private.gcs = ioremap(iTCO_wdt_private.gcs_res->start, |
| 435 | resource_size(iTCO_wdt_private.gcs_res)); |
| 436 | if (!iTCO_wdt_private.gcs) { |
| 437 | ret = -EIO; |
| 438 | goto unreg_gcs; |
| 439 | } |
Wim Van Sebroeck | 9e0ea34 | 2006-05-21 14:37:44 +0200 | [diff] [blame] | 440 | } |
| 441 | |
| 442 | /* Check chipset's NO_REBOOT bit */ |
Wim Van Sebroeck | e033351 | 2006-11-12 18:05:09 +0100 | [diff] [blame] | 443 | if (iTCO_wdt_unset_NO_REBOOT_bit() && iTCO_vendor_check_noreboot_on()) { |
Joe Perches | 27c766a | 2012-02-15 15:06:19 -0800 | [diff] [blame] | 444 | pr_info("unable to reset NO_REBOOT flag, device disabled by hardware/BIOS\n"); |
Wim Van Sebroeck | 9e0ea34 | 2006-05-21 14:37:44 +0200 | [diff] [blame] | 445 | ret = -ENODEV; /* Cannot reset NO_REBOOT bit */ |
Aaron Sierra | 887c8ec | 2012-04-20 14:14:11 -0500 | [diff] [blame] | 446 | goto unmap_gcs; |
Wim Van Sebroeck | 9e0ea34 | 2006-05-21 14:37:44 +0200 | [diff] [blame] | 447 | } |
| 448 | |
| 449 | /* Set the NO_REBOOT bit to prevent later reboots, just for sure */ |
| 450 | iTCO_wdt_set_NO_REBOOT_bit(); |
| 451 | |
Wim Van Sebroeck | 7cd5b08 | 2008-11-19 19:39:58 +0000 | [diff] [blame] | 452 | /* The TCO logic uses the TCO_EN bit in the SMI_EN register */ |
Aaron Sierra | 887c8ec | 2012-04-20 14:14:11 -0500 | [diff] [blame] | 453 | if (!request_region(iTCO_wdt_private.smi_res->start, |
| 454 | resource_size(iTCO_wdt_private.smi_res), dev->name)) { |
| 455 | pr_err("I/O address 0x%04llx already in use, device disabled\n", |
Randy Dunlap | 4b98b32 | 2012-05-14 13:15:20 -0700 | [diff] [blame] | 456 | (u64)SMI_EN); |
Aaron Sierra | 887c8ec | 2012-04-20 14:14:11 -0500 | [diff] [blame] | 457 | ret = -EBUSY; |
| 458 | goto unmap_gcs; |
Wim Van Sebroeck | 9e0ea34 | 2006-05-21 14:37:44 +0200 | [diff] [blame] | 459 | } |
Wim Van Sebroeck | 0d09858 | 2011-12-26 15:23:51 +0100 | [diff] [blame] | 460 | if (turn_SMI_watchdog_clear_off >= iTCO_wdt_private.iTCO_version) { |
Aaron Sierra | 887c8ec | 2012-04-20 14:14:11 -0500 | [diff] [blame] | 461 | /* |
| 462 | * Bit 13: TCO_EN -> 0 |
| 463 | * Disables TCO logic generating an SMI# |
| 464 | */ |
Wim Van Sebroeck | deb9197 | 2011-10-19 23:59:26 +0200 | [diff] [blame] | 465 | val32 = inl(SMI_EN); |
| 466 | val32 &= 0xffffdfff; /* Turn off SMI clearing watchdog */ |
| 467 | outl(val32, SMI_EN); |
| 468 | } |
Wim Van Sebroeck | 9e0ea34 | 2006-05-21 14:37:44 +0200 | [diff] [blame] | 469 | |
Aaron Sierra | 887c8ec | 2012-04-20 14:14:11 -0500 | [diff] [blame] | 470 | if (!request_region(iTCO_wdt_private.tco_res->start, |
| 471 | resource_size(iTCO_wdt_private.tco_res), dev->name)) { |
| 472 | pr_err("I/O address 0x%04llx already in use, device disabled\n", |
Randy Dunlap | 4b98b32 | 2012-05-14 13:15:20 -0700 | [diff] [blame] | 473 | (u64)TCOBASE); |
Aaron Sierra | 887c8ec | 2012-04-20 14:14:11 -0500 | [diff] [blame] | 474 | ret = -EBUSY; |
| 475 | goto unreg_smi; |
Wim Van Sebroeck | 9e0ea34 | 2006-05-21 14:37:44 +0200 | [diff] [blame] | 476 | } |
| 477 | |
Aaron Sierra | 887c8ec | 2012-04-20 14:14:11 -0500 | [diff] [blame] | 478 | pr_info("Found a %s TCO device (Version=%d, TCOBASE=0x%04llx)\n", |
Randy Dunlap | 4b98b32 | 2012-05-14 13:15:20 -0700 | [diff] [blame] | 479 | ich_info->name, ich_info->iTCO_version, (u64)TCOBASE); |
Wim Van Sebroeck | 9e0ea34 | 2006-05-21 14:37:44 +0200 | [diff] [blame] | 480 | |
| 481 | /* Clear out the (probably old) status */ |
Pádraig Brady | 7e6811d | 2010-04-19 13:38:25 +0100 | [diff] [blame] | 482 | outw(0x0008, TCO1_STS); /* Clear the Time Out Status bit */ |
| 483 | outw(0x0002, TCO2_STS); /* Clear SECOND_TO_STS bit */ |
| 484 | outw(0x0004, TCO2_STS); /* Clear BOOT_STS bit */ |
Wim Van Sebroeck | 9e0ea34 | 2006-05-21 14:37:44 +0200 | [diff] [blame] | 485 | |
Wim Van Sebroeck | bff2343 | 2012-06-09 14:10:28 +0200 | [diff] [blame] | 486 | iTCO_wdt_watchdog_dev.bootstatus = 0; |
| 487 | iTCO_wdt_watchdog_dev.timeout = WATCHDOG_TIMEOUT; |
| 488 | watchdog_set_nowayout(&iTCO_wdt_watchdog_dev, nowayout); |
| 489 | iTCO_wdt_watchdog_dev.parent = dev->dev.parent; |
| 490 | |
Wim Van Sebroeck | 9e0ea34 | 2006-05-21 14:37:44 +0200 | [diff] [blame] | 491 | /* Make sure the watchdog is not running */ |
Wim Van Sebroeck | bff2343 | 2012-06-09 14:10:28 +0200 | [diff] [blame] | 492 | iTCO_wdt_stop(&iTCO_wdt_watchdog_dev); |
Wim Van Sebroeck | 9e0ea34 | 2006-05-21 14:37:44 +0200 | [diff] [blame] | 493 | |
Alan Cox | 0e6fa3f | 2008-05-19 14:06:25 +0100 | [diff] [blame] | 494 | /* Check that the heartbeat value is within it's range; |
| 495 | if not reset to the default */ |
Wim Van Sebroeck | bff2343 | 2012-06-09 14:10:28 +0200 | [diff] [blame] | 496 | if (iTCO_wdt_set_timeout(&iTCO_wdt_watchdog_dev, heartbeat)) { |
| 497 | iTCO_wdt_set_timeout(&iTCO_wdt_watchdog_dev, WATCHDOG_TIMEOUT); |
| 498 | pr_info("timeout value out of range, using %d\n", |
| 499 | WATCHDOG_TIMEOUT); |
Wim Van Sebroeck | 9e0ea34 | 2006-05-21 14:37:44 +0200 | [diff] [blame] | 500 | } |
| 501 | |
Wim Van Sebroeck | bff2343 | 2012-06-09 14:10:28 +0200 | [diff] [blame] | 502 | ret = watchdog_register_device(&iTCO_wdt_watchdog_dev); |
Wim Van Sebroeck | 9e0ea34 | 2006-05-21 14:37:44 +0200 | [diff] [blame] | 503 | if (ret != 0) { |
Wim Van Sebroeck | bff2343 | 2012-06-09 14:10:28 +0200 | [diff] [blame] | 504 | pr_err("cannot register watchdog device (err=%d)\n", ret); |
Aaron Sierra | 887c8ec | 2012-04-20 14:14:11 -0500 | [diff] [blame] | 505 | goto unreg_tco; |
Wim Van Sebroeck | 9e0ea34 | 2006-05-21 14:37:44 +0200 | [diff] [blame] | 506 | } |
| 507 | |
Joe Perches | 27c766a | 2012-02-15 15:06:19 -0800 | [diff] [blame] | 508 | pr_info("initialized. heartbeat=%d sec (nowayout=%d)\n", |
| 509 | heartbeat, nowayout); |
Wim Van Sebroeck | 9e0ea34 | 2006-05-21 14:37:44 +0200 | [diff] [blame] | 510 | |
| 511 | return 0; |
| 512 | |
Aaron Sierra | 887c8ec | 2012-04-20 14:14:11 -0500 | [diff] [blame] | 513 | unreg_tco: |
| 514 | release_region(iTCO_wdt_private.tco_res->start, |
| 515 | resource_size(iTCO_wdt_private.tco_res)); |
| 516 | unreg_smi: |
| 517 | release_region(iTCO_wdt_private.smi_res->start, |
| 518 | resource_size(iTCO_wdt_private.smi_res)); |
| 519 | unmap_gcs: |
Wim Van Sebroeck | 9e0ea34 | 2006-05-21 14:37:44 +0200 | [diff] [blame] | 520 | if (iTCO_wdt_private.iTCO_version == 2) |
| 521 | iounmap(iTCO_wdt_private.gcs); |
Aaron Sierra | 887c8ec | 2012-04-20 14:14:11 -0500 | [diff] [blame] | 522 | unreg_gcs: |
| 523 | if (iTCO_wdt_private.iTCO_version == 2) |
| 524 | release_mem_region(iTCO_wdt_private.gcs_res->start, |
| 525 | resource_size(iTCO_wdt_private.gcs_res)); |
Denis V. Lunev | de8cd9a | 2009-06-05 15:13:08 +0400 | [diff] [blame] | 526 | out: |
Aaron Sierra | 887c8ec | 2012-04-20 14:14:11 -0500 | [diff] [blame] | 527 | iTCO_wdt_private.tco_res = NULL; |
| 528 | iTCO_wdt_private.smi_res = NULL; |
| 529 | iTCO_wdt_private.gcs_res = NULL; |
| 530 | iTCO_wdt_private.gcs = NULL; |
Wim Van Sebroeck | 9e0ea34 | 2006-05-21 14:37:44 +0200 | [diff] [blame] | 531 | |
Naga Chumbalkar | ec26985 | 2010-02-09 00:42:02 +0100 | [diff] [blame] | 532 | return ret; |
Wim Van Sebroeck | 9e0ea34 | 2006-05-21 14:37:44 +0200 | [diff] [blame] | 533 | } |
| 534 | |
Wim Van Sebroeck | 08113e3 | 2007-08-31 08:15:34 +0000 | [diff] [blame] | 535 | static int __devexit iTCO_wdt_remove(struct platform_device *dev) |
Wim Van Sebroeck | 9e0ea34 | 2006-05-21 14:37:44 +0200 | [diff] [blame] | 536 | { |
Aaron Sierra | 887c8ec | 2012-04-20 14:14:11 -0500 | [diff] [blame] | 537 | if (iTCO_wdt_private.tco_res || iTCO_wdt_private.smi_res) |
Wim Van Sebroeck | 9e0ea34 | 2006-05-21 14:37:44 +0200 | [diff] [blame] | 538 | iTCO_wdt_cleanup(); |
| 539 | |
Wim Van Sebroeck | 3836cc0 | 2006-06-30 08:44:53 +0200 | [diff] [blame] | 540 | return 0; |
| 541 | } |
| 542 | |
| 543 | static void iTCO_wdt_shutdown(struct platform_device *dev) |
| 544 | { |
Wim Van Sebroeck | bff2343 | 2012-06-09 14:10:28 +0200 | [diff] [blame] | 545 | iTCO_wdt_stop(NULL); |
Wim Van Sebroeck | 3836cc0 | 2006-06-30 08:44:53 +0200 | [diff] [blame] | 546 | } |
| 547 | |
Wim Van Sebroeck | 3836cc0 | 2006-06-30 08:44:53 +0200 | [diff] [blame] | 548 | static struct platform_driver iTCO_wdt_driver = { |
| 549 | .probe = iTCO_wdt_probe, |
Wim Van Sebroeck | 08113e3 | 2007-08-31 08:15:34 +0000 | [diff] [blame] | 550 | .remove = __devexit_p(iTCO_wdt_remove), |
Wim Van Sebroeck | 3836cc0 | 2006-06-30 08:44:53 +0200 | [diff] [blame] | 551 | .shutdown = iTCO_wdt_shutdown, |
Wim Van Sebroeck | 3836cc0 | 2006-06-30 08:44:53 +0200 | [diff] [blame] | 552 | .driver = { |
| 553 | .owner = THIS_MODULE, |
| 554 | .name = DRV_NAME, |
| 555 | }, |
| 556 | }; |
| 557 | |
| 558 | static int __init iTCO_wdt_init_module(void) |
| 559 | { |
| 560 | int err; |
| 561 | |
Joe Perches | 27c766a | 2012-02-15 15:06:19 -0800 | [diff] [blame] | 562 | pr_info("Intel TCO WatchDog Timer Driver v%s\n", DRV_VERSION); |
Wim Van Sebroeck | 3836cc0 | 2006-06-30 08:44:53 +0200 | [diff] [blame] | 563 | |
| 564 | err = platform_driver_register(&iTCO_wdt_driver); |
| 565 | if (err) |
| 566 | return err; |
| 567 | |
Wim Van Sebroeck | 3836cc0 | 2006-06-30 08:44:53 +0200 | [diff] [blame] | 568 | return 0; |
Wim Van Sebroeck | 3836cc0 | 2006-06-30 08:44:53 +0200 | [diff] [blame] | 569 | } |
| 570 | |
| 571 | static void __exit iTCO_wdt_cleanup_module(void) |
| 572 | { |
Wim Van Sebroeck | 3836cc0 | 2006-06-30 08:44:53 +0200 | [diff] [blame] | 573 | platform_driver_unregister(&iTCO_wdt_driver); |
Joe Perches | 27c766a | 2012-02-15 15:06:19 -0800 | [diff] [blame] | 574 | pr_info("Watchdog Module Unloaded\n"); |
Wim Van Sebroeck | 9e0ea34 | 2006-05-21 14:37:44 +0200 | [diff] [blame] | 575 | } |
| 576 | |
| 577 | module_init(iTCO_wdt_init_module); |
| 578 | module_exit(iTCO_wdt_cleanup_module); |
| 579 | |
| 580 | MODULE_AUTHOR("Wim Van Sebroeck <wim@iguana.be>"); |
| 581 | MODULE_DESCRIPTION("Intel TCO WatchDog Timer Driver"); |
Wim Van Sebroeck | 3836cc0 | 2006-06-30 08:44:53 +0200 | [diff] [blame] | 582 | MODULE_VERSION(DRV_VERSION); |
Wim Van Sebroeck | 9e0ea34 | 2006-05-21 14:37:44 +0200 | [diff] [blame] | 583 | MODULE_LICENSE("GPL"); |
| 584 | MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR); |
Jan Beulich | e5de32e | 2012-06-22 16:41:00 +0100 | [diff] [blame] | 585 | MODULE_ALIAS("platform:" DRV_NAME); |