iTCO_wdt.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583
  1. /*
  2. * intel TCO Watchdog Driver
  3. *
  4. * (c) Copyright 2006-2011 Wim Van Sebroeck <wim@iguana.be>.
  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.)
  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)
  29. * document number 322896-001, 322897-001: NM10
  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)
  33. * document number 322169-001, 322170-003: 5 Series, 3400 Series (PCH)
  34. * document number 320066-003, 320257-008: EP80597 (IICH)
  35. * document number 324645-001, 324646-001: Cougar Point (CPT)
  36. * document number TBD : Patsburg (PBG)
  37. * document number TBD : DH89xxCC
  38. * document number TBD : Panther Point
  39. * document number TBD : Lynx Point
  40. * document number TBD : Lynx Point-LP
  41. */
  42. /*
  43. * Includes, defines, variables, module parameters, ...
  44. */
  45. #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
  46. /* Module and version information */
  47. #define DRV_NAME "iTCO_wdt"
  48. #define DRV_VERSION "1.10"
  49. /* Includes */
  50. #include <linux/module.h> /* For module specific items */
  51. #include <linux/moduleparam.h> /* For new moduleparam's */
  52. #include <linux/types.h> /* For standard types (like size_t) */
  53. #include <linux/errno.h> /* For the -ENODEV/... values */
  54. #include <linux/kernel.h> /* For printk/panic/... */
  55. #include <linux/watchdog.h> /* For the watchdog specific items */
  56. #include <linux/init.h> /* For __init/__exit/... */
  57. #include <linux/fs.h> /* For file operations */
  58. #include <linux/platform_device.h> /* For platform_driver framework */
  59. #include <linux/pci.h> /* For pci functions */
  60. #include <linux/ioport.h> /* For io-port access */
  61. #include <linux/spinlock.h> /* For spin_lock/spin_unlock/... */
  62. #include <linux/uaccess.h> /* For copy_to_user/put_user/... */
  63. #include <linux/io.h> /* For inb/outb/... */
  64. #include <linux/mfd/core.h>
  65. #include <linux/mfd/lpc_ich.h>
  66. #include "iTCO_vendor.h"
  67. /* Address definitions for the TCO */
  68. /* TCO base address */
  69. #define TCOBASE (iTCO_wdt_private.tco_res->start)
  70. /* SMI Control and Enable Register */
  71. #define SMI_EN (iTCO_wdt_private.smi_res->start)
  72. #define TCO_RLD (TCOBASE + 0x00) /* TCO Timer Reload and Curr. Value */
  73. #define TCOv1_TMR (TCOBASE + 0x01) /* TCOv1 Timer Initial Value */
  74. #define TCO_DAT_IN (TCOBASE + 0x02) /* TCO Data In Register */
  75. #define TCO_DAT_OUT (TCOBASE + 0x03) /* TCO Data Out Register */
  76. #define TCO1_STS (TCOBASE + 0x04) /* TCO1 Status Register */
  77. #define TCO2_STS (TCOBASE + 0x06) /* TCO2 Status Register */
  78. #define TCO1_CNT (TCOBASE + 0x08) /* TCO1 Control Register */
  79. #define TCO2_CNT (TCOBASE + 0x0a) /* TCO2 Control Register */
  80. #define TCOv2_TMR (TCOBASE + 0x12) /* TCOv2 Timer Initial Value */
  81. /* internal variables */
  82. static struct { /* this is private data for the iTCO_wdt device */
  83. /* TCO version/generation */
  84. unsigned int iTCO_version;
  85. struct resource *tco_res;
  86. struct resource *smi_res;
  87. struct resource *gcs_res;
  88. /* NO_REBOOT flag is Memory-Mapped GCS register bit 5 (TCO version 2)*/
  89. unsigned long __iomem *gcs;
  90. /* the lock for io operations */
  91. spinlock_t io_lock;
  92. struct platform_device *dev;
  93. /* the PCI-device */
  94. struct pci_dev *pdev;
  95. } iTCO_wdt_private;
  96. /* module parameters */
  97. #define WATCHDOG_TIMEOUT 30 /* 30 sec default heartbeat */
  98. static int heartbeat = WATCHDOG_TIMEOUT; /* in seconds */
  99. module_param(heartbeat, int, 0);
  100. MODULE_PARM_DESC(heartbeat, "Watchdog timeout in seconds. "
  101. "5..76 (TCO v1) or 3..614 (TCO v2), default="
  102. __MODULE_STRING(WATCHDOG_TIMEOUT) ")");
  103. static bool nowayout = WATCHDOG_NOWAYOUT;
  104. module_param(nowayout, bool, 0);
  105. MODULE_PARM_DESC(nowayout,
  106. "Watchdog cannot be stopped once started (default="
  107. __MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
  108. static int turn_SMI_watchdog_clear_off = 1;
  109. module_param(turn_SMI_watchdog_clear_off, int, 0);
  110. MODULE_PARM_DESC(turn_SMI_watchdog_clear_off,
  111. "Turn off SMI clearing watchdog (depends on TCO-version)(default=1)");
  112. /*
  113. * Some TCO specific functions
  114. */
  115. static inline unsigned int seconds_to_ticks(int seconds)
  116. {
  117. /* the internal timer is stored as ticks which decrement
  118. * every 0.6 seconds */
  119. return (seconds * 10) / 6;
  120. }
  121. static void iTCO_wdt_set_NO_REBOOT_bit(void)
  122. {
  123. u32 val32;
  124. /* Set the NO_REBOOT bit: this disables reboots */
  125. if (iTCO_wdt_private.iTCO_version == 2) {
  126. val32 = readl(iTCO_wdt_private.gcs);
  127. val32 |= 0x00000020;
  128. writel(val32, iTCO_wdt_private.gcs);
  129. } else if (iTCO_wdt_private.iTCO_version == 1) {
  130. pci_read_config_dword(iTCO_wdt_private.pdev, 0xd4, &val32);
  131. val32 |= 0x00000002;
  132. pci_write_config_dword(iTCO_wdt_private.pdev, 0xd4, val32);
  133. }
  134. }
  135. static int iTCO_wdt_unset_NO_REBOOT_bit(void)
  136. {
  137. int ret = 0;
  138. u32 val32;
  139. /* Unset the NO_REBOOT bit: this enables reboots */
  140. if (iTCO_wdt_private.iTCO_version == 2) {
  141. val32 = readl(iTCO_wdt_private.gcs);
  142. val32 &= 0xffffffdf;
  143. writel(val32, iTCO_wdt_private.gcs);
  144. val32 = readl(iTCO_wdt_private.gcs);
  145. if (val32 & 0x00000020)
  146. ret = -EIO;
  147. } else if (iTCO_wdt_private.iTCO_version == 1) {
  148. pci_read_config_dword(iTCO_wdt_private.pdev, 0xd4, &val32);
  149. val32 &= 0xfffffffd;
  150. pci_write_config_dword(iTCO_wdt_private.pdev, 0xd4, val32);
  151. pci_read_config_dword(iTCO_wdt_private.pdev, 0xd4, &val32);
  152. if (val32 & 0x00000002)
  153. ret = -EIO;
  154. }
  155. return ret; /* returns: 0 = OK, -EIO = Error */
  156. }
  157. static int iTCO_wdt_start(struct watchdog_device *wd_dev)
  158. {
  159. unsigned int val;
  160. spin_lock(&iTCO_wdt_private.io_lock);
  161. iTCO_vendor_pre_start(iTCO_wdt_private.smi_res, wd_dev->timeout);
  162. /* disable chipset's NO_REBOOT bit */
  163. if (iTCO_wdt_unset_NO_REBOOT_bit()) {
  164. spin_unlock(&iTCO_wdt_private.io_lock);
  165. pr_err("failed to reset NO_REBOOT flag, reboot disabled by hardware/BIOS\n");
  166. return -EIO;
  167. }
  168. /* Force the timer to its reload value by writing to the TCO_RLD
  169. register */
  170. if (iTCO_wdt_private.iTCO_version == 2)
  171. outw(0x01, TCO_RLD);
  172. else if (iTCO_wdt_private.iTCO_version == 1)
  173. outb(0x01, TCO_RLD);
  174. /* Bit 11: TCO Timer Halt -> 0 = The TCO timer is enabled to count */
  175. val = inw(TCO1_CNT);
  176. val &= 0xf7ff;
  177. outw(val, TCO1_CNT);
  178. val = inw(TCO1_CNT);
  179. spin_unlock(&iTCO_wdt_private.io_lock);
  180. if (val & 0x0800)
  181. return -1;
  182. return 0;
  183. }
  184. static int iTCO_wdt_stop(struct watchdog_device *wd_dev)
  185. {
  186. unsigned int val;
  187. spin_lock(&iTCO_wdt_private.io_lock);
  188. iTCO_vendor_pre_stop(iTCO_wdt_private.smi_res);
  189. /* Bit 11: TCO Timer Halt -> 1 = The TCO timer is disabled */
  190. val = inw(TCO1_CNT);
  191. val |= 0x0800;
  192. outw(val, TCO1_CNT);
  193. val = inw(TCO1_CNT);
  194. /* Set the NO_REBOOT bit to prevent later reboots, just for sure */
  195. iTCO_wdt_set_NO_REBOOT_bit();
  196. spin_unlock(&iTCO_wdt_private.io_lock);
  197. if ((val & 0x0800) == 0)
  198. return -1;
  199. return 0;
  200. }
  201. static int iTCO_wdt_ping(struct watchdog_device *wd_dev)
  202. {
  203. spin_lock(&iTCO_wdt_private.io_lock);
  204. iTCO_vendor_pre_keepalive(iTCO_wdt_private.smi_res, wd_dev->timeout);
  205. /* Reload the timer by writing to the TCO Timer Counter register */
  206. if (iTCO_wdt_private.iTCO_version == 2)
  207. outw(0x01, TCO_RLD);
  208. else if (iTCO_wdt_private.iTCO_version == 1) {
  209. /* Reset the timeout status bit so that the timer
  210. * needs to count down twice again before rebooting */
  211. outw(0x0008, TCO1_STS); /* write 1 to clear bit */
  212. outb(0x01, TCO_RLD);
  213. }
  214. spin_unlock(&iTCO_wdt_private.io_lock);
  215. return 0;
  216. }
  217. static int iTCO_wdt_set_timeout(struct watchdog_device *wd_dev, unsigned int t)
  218. {
  219. unsigned int val16;
  220. unsigned char val8;
  221. unsigned int tmrval;
  222. tmrval = seconds_to_ticks(t);
  223. /* For TCO v1 the timer counts down twice before rebooting */
  224. if (iTCO_wdt_private.iTCO_version == 1)
  225. tmrval /= 2;
  226. /* from the specs: */
  227. /* "Values of 0h-3h are ignored and should not be attempted" */
  228. if (tmrval < 0x04)
  229. return -EINVAL;
  230. if (((iTCO_wdt_private.iTCO_version == 2) && (tmrval > 0x3ff)) ||
  231. ((iTCO_wdt_private.iTCO_version == 1) && (tmrval > 0x03f)))
  232. return -EINVAL;
  233. iTCO_vendor_pre_set_heartbeat(tmrval);
  234. /* Write new heartbeat to watchdog */
  235. if (iTCO_wdt_private.iTCO_version == 2) {
  236. spin_lock(&iTCO_wdt_private.io_lock);
  237. val16 = inw(TCOv2_TMR);
  238. val16 &= 0xfc00;
  239. val16 |= tmrval;
  240. outw(val16, TCOv2_TMR);
  241. val16 = inw(TCOv2_TMR);
  242. spin_unlock(&iTCO_wdt_private.io_lock);
  243. if ((val16 & 0x3ff) != tmrval)
  244. return -EINVAL;
  245. } else if (iTCO_wdt_private.iTCO_version == 1) {
  246. spin_lock(&iTCO_wdt_private.io_lock);
  247. val8 = inb(TCOv1_TMR);
  248. val8 &= 0xc0;
  249. val8 |= (tmrval & 0xff);
  250. outb(val8, TCOv1_TMR);
  251. val8 = inb(TCOv1_TMR);
  252. spin_unlock(&iTCO_wdt_private.io_lock);
  253. if ((val8 & 0x3f) != tmrval)
  254. return -EINVAL;
  255. }
  256. wd_dev->timeout = t;
  257. return 0;
  258. }
  259. static unsigned int iTCO_wdt_get_timeleft(struct watchdog_device *wd_dev)
  260. {
  261. unsigned int val16;
  262. unsigned char val8;
  263. unsigned int time_left = 0;
  264. /* read the TCO Timer */
  265. if (iTCO_wdt_private.iTCO_version == 2) {
  266. spin_lock(&iTCO_wdt_private.io_lock);
  267. val16 = inw(TCO_RLD);
  268. val16 &= 0x3ff;
  269. spin_unlock(&iTCO_wdt_private.io_lock);
  270. time_left = (val16 * 6) / 10;
  271. } else if (iTCO_wdt_private.iTCO_version == 1) {
  272. spin_lock(&iTCO_wdt_private.io_lock);
  273. val8 = inb(TCO_RLD);
  274. val8 &= 0x3f;
  275. if (!(inw(TCO1_STS) & 0x0008))
  276. val8 += (inb(TCOv1_TMR) & 0x3f);
  277. spin_unlock(&iTCO_wdt_private.io_lock);
  278. time_left = (val8 * 6) / 10;
  279. }
  280. return time_left;
  281. }
  282. /*
  283. * Kernel Interfaces
  284. */
  285. static const struct watchdog_info ident = {
  286. .options = WDIOF_SETTIMEOUT |
  287. WDIOF_KEEPALIVEPING |
  288. WDIOF_MAGICCLOSE,
  289. .firmware_version = 0,
  290. .identity = DRV_NAME,
  291. };
  292. static const struct watchdog_ops iTCO_wdt_ops = {
  293. .owner = THIS_MODULE,
  294. .start = iTCO_wdt_start,
  295. .stop = iTCO_wdt_stop,
  296. .ping = iTCO_wdt_ping,
  297. .set_timeout = iTCO_wdt_set_timeout,
  298. .get_timeleft = iTCO_wdt_get_timeleft,
  299. };
  300. static struct watchdog_device iTCO_wdt_watchdog_dev = {
  301. .info = &ident,
  302. .ops = &iTCO_wdt_ops,
  303. };
  304. /*
  305. * Init & exit routines
  306. */
  307. static void iTCO_wdt_cleanup(void)
  308. {
  309. /* Stop the timer before we leave */
  310. if (!nowayout)
  311. iTCO_wdt_stop(&iTCO_wdt_watchdog_dev);
  312. /* Deregister */
  313. watchdog_unregister_device(&iTCO_wdt_watchdog_dev);
  314. /* release resources */
  315. release_region(iTCO_wdt_private.tco_res->start,
  316. resource_size(iTCO_wdt_private.tco_res));
  317. release_region(iTCO_wdt_private.smi_res->start,
  318. resource_size(iTCO_wdt_private.smi_res));
  319. if (iTCO_wdt_private.iTCO_version == 2) {
  320. iounmap(iTCO_wdt_private.gcs);
  321. release_mem_region(iTCO_wdt_private.gcs_res->start,
  322. resource_size(iTCO_wdt_private.gcs_res));
  323. }
  324. iTCO_wdt_private.tco_res = NULL;
  325. iTCO_wdt_private.smi_res = NULL;
  326. iTCO_wdt_private.gcs_res = NULL;
  327. iTCO_wdt_private.gcs = NULL;
  328. }
  329. static int iTCO_wdt_probe(struct platform_device *dev)
  330. {
  331. int ret = -ENODEV;
  332. unsigned long val32;
  333. struct lpc_ich_info *ich_info = dev_get_platdata(&dev->dev);
  334. if (!ich_info)
  335. goto out;
  336. spin_lock_init(&iTCO_wdt_private.io_lock);
  337. iTCO_wdt_private.tco_res =
  338. platform_get_resource(dev, IORESOURCE_IO, ICH_RES_IO_TCO);
  339. if (!iTCO_wdt_private.tco_res)
  340. goto out;
  341. iTCO_wdt_private.smi_res =
  342. platform_get_resource(dev, IORESOURCE_IO, ICH_RES_IO_SMI);
  343. if (!iTCO_wdt_private.smi_res)
  344. goto out;
  345. iTCO_wdt_private.iTCO_version = ich_info->iTCO_version;
  346. iTCO_wdt_private.dev = dev;
  347. iTCO_wdt_private.pdev = to_pci_dev(dev->dev.parent);
  348. /*
  349. * Get the Memory-Mapped GCS register, we need it for the
  350. * NO_REBOOT flag (TCO v2).
  351. */
  352. if (iTCO_wdt_private.iTCO_version == 2) {
  353. iTCO_wdt_private.gcs_res = platform_get_resource(dev,
  354. IORESOURCE_MEM,
  355. ICH_RES_MEM_GCS);
  356. if (!iTCO_wdt_private.gcs_res)
  357. goto out;
  358. if (!request_mem_region(iTCO_wdt_private.gcs_res->start,
  359. resource_size(iTCO_wdt_private.gcs_res), dev->name)) {
  360. ret = -EBUSY;
  361. goto out;
  362. }
  363. iTCO_wdt_private.gcs = ioremap(iTCO_wdt_private.gcs_res->start,
  364. resource_size(iTCO_wdt_private.gcs_res));
  365. if (!iTCO_wdt_private.gcs) {
  366. ret = -EIO;
  367. goto unreg_gcs;
  368. }
  369. }
  370. /* Check chipset's NO_REBOOT bit */
  371. if (iTCO_wdt_unset_NO_REBOOT_bit() && iTCO_vendor_check_noreboot_on()) {
  372. pr_info("unable to reset NO_REBOOT flag, device disabled by hardware/BIOS\n");
  373. ret = -ENODEV; /* Cannot reset NO_REBOOT bit */
  374. goto unmap_gcs;
  375. }
  376. /* Set the NO_REBOOT bit to prevent later reboots, just for sure */
  377. iTCO_wdt_set_NO_REBOOT_bit();
  378. /* The TCO logic uses the TCO_EN bit in the SMI_EN register */
  379. if (!request_region(iTCO_wdt_private.smi_res->start,
  380. resource_size(iTCO_wdt_private.smi_res), dev->name)) {
  381. pr_err("I/O address 0x%04llx already in use, device disabled\n",
  382. (u64)SMI_EN);
  383. ret = -EBUSY;
  384. goto unmap_gcs;
  385. }
  386. if (turn_SMI_watchdog_clear_off >= iTCO_wdt_private.iTCO_version) {
  387. /*
  388. * Bit 13: TCO_EN -> 0
  389. * Disables TCO logic generating an SMI#
  390. */
  391. val32 = inl(SMI_EN);
  392. val32 &= 0xffffdfff; /* Turn off SMI clearing watchdog */
  393. outl(val32, SMI_EN);
  394. }
  395. if (!request_region(iTCO_wdt_private.tco_res->start,
  396. resource_size(iTCO_wdt_private.tco_res), dev->name)) {
  397. pr_err("I/O address 0x%04llx already in use, device disabled\n",
  398. (u64)TCOBASE);
  399. ret = -EBUSY;
  400. goto unreg_smi;
  401. }
  402. pr_info("Found a %s TCO device (Version=%d, TCOBASE=0x%04llx)\n",
  403. ich_info->name, ich_info->iTCO_version, (u64)TCOBASE);
  404. /* Clear out the (probably old) status */
  405. outw(0x0008, TCO1_STS); /* Clear the Time Out Status bit */
  406. outw(0x0002, TCO2_STS); /* Clear SECOND_TO_STS bit */
  407. outw(0x0004, TCO2_STS); /* Clear BOOT_STS bit */
  408. iTCO_wdt_watchdog_dev.bootstatus = 0;
  409. iTCO_wdt_watchdog_dev.timeout = WATCHDOG_TIMEOUT;
  410. watchdog_set_nowayout(&iTCO_wdt_watchdog_dev, nowayout);
  411. iTCO_wdt_watchdog_dev.parent = dev->dev.parent;
  412. /* Make sure the watchdog is not running */
  413. iTCO_wdt_stop(&iTCO_wdt_watchdog_dev);
  414. /* Check that the heartbeat value is within it's range;
  415. if not reset to the default */
  416. if (iTCO_wdt_set_timeout(&iTCO_wdt_watchdog_dev, heartbeat)) {
  417. iTCO_wdt_set_timeout(&iTCO_wdt_watchdog_dev, WATCHDOG_TIMEOUT);
  418. pr_info("timeout value out of range, using %d\n",
  419. WATCHDOG_TIMEOUT);
  420. }
  421. ret = watchdog_register_device(&iTCO_wdt_watchdog_dev);
  422. if (ret != 0) {
  423. pr_err("cannot register watchdog device (err=%d)\n", ret);
  424. goto unreg_tco;
  425. }
  426. pr_info("initialized. heartbeat=%d sec (nowayout=%d)\n",
  427. heartbeat, nowayout);
  428. return 0;
  429. unreg_tco:
  430. release_region(iTCO_wdt_private.tco_res->start,
  431. resource_size(iTCO_wdt_private.tco_res));
  432. unreg_smi:
  433. release_region(iTCO_wdt_private.smi_res->start,
  434. resource_size(iTCO_wdt_private.smi_res));
  435. unmap_gcs:
  436. if (iTCO_wdt_private.iTCO_version == 2)
  437. iounmap(iTCO_wdt_private.gcs);
  438. unreg_gcs:
  439. if (iTCO_wdt_private.iTCO_version == 2)
  440. release_mem_region(iTCO_wdt_private.gcs_res->start,
  441. resource_size(iTCO_wdt_private.gcs_res));
  442. out:
  443. iTCO_wdt_private.tco_res = NULL;
  444. iTCO_wdt_private.smi_res = NULL;
  445. iTCO_wdt_private.gcs_res = NULL;
  446. iTCO_wdt_private.gcs = NULL;
  447. return ret;
  448. }
  449. static int iTCO_wdt_remove(struct platform_device *dev)
  450. {
  451. if (iTCO_wdt_private.tco_res || iTCO_wdt_private.smi_res)
  452. iTCO_wdt_cleanup();
  453. return 0;
  454. }
  455. static void iTCO_wdt_shutdown(struct platform_device *dev)
  456. {
  457. iTCO_wdt_stop(NULL);
  458. }
  459. static struct platform_driver iTCO_wdt_driver = {
  460. .probe = iTCO_wdt_probe,
  461. .remove = iTCO_wdt_remove,
  462. .shutdown = iTCO_wdt_shutdown,
  463. .driver = {
  464. .owner = THIS_MODULE,
  465. .name = DRV_NAME,
  466. },
  467. };
  468. static int __init iTCO_wdt_init_module(void)
  469. {
  470. int err;
  471. pr_info("Intel TCO WatchDog Timer Driver v%s\n", DRV_VERSION);
  472. err = platform_driver_register(&iTCO_wdt_driver);
  473. if (err)
  474. return err;
  475. return 0;
  476. }
  477. static void __exit iTCO_wdt_cleanup_module(void)
  478. {
  479. platform_driver_unregister(&iTCO_wdt_driver);
  480. pr_info("Watchdog Module Unloaded\n");
  481. }
  482. module_init(iTCO_wdt_init_module);
  483. module_exit(iTCO_wdt_cleanup_module);
  484. MODULE_AUTHOR("Wim Van Sebroeck <wim@iguana.be>");
  485. MODULE_DESCRIPTION("Intel TCO WatchDog Timer Driver");
  486. MODULE_VERSION(DRV_VERSION);
  487. MODULE_LICENSE("GPL");
  488. MODULE_ALIAS("platform:" DRV_NAME);