iTCO_wdt.c 17 KB

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