Lines Matching +full:timeout +full:- +full:secs

1 // SPDX-License-Identifier: GPL-2.0+
5 * (c) Copyright 2006-2011 Wim Van Sebroeck <wim@iguana.be>.
9 * provided "AS-IS" and at no charge.
13 * document number 290655-003, 290677-014: 82801AA (ICH), 82801AB (ICHO)
14 * document number 290687-002, 298242-027: 82801BA (ICH2)
15 * document number 290733-003, 290739-013: 82801CA (ICH3-S)
16 * document number 290716-001, 290718-007: 82801CAM (ICH3-M)
17 * document number 290744-001, 290745-025: 82801DB (ICH4)
18 * document number 252337-001, 252663-008: 82801DBM (ICH4-M)
19 * document number 273599-001, 273645-002: 82801E (C-ICH)
20 * document number 252516-001, 252517-028: 82801EB (ICH5), 82801ER (ICH5R)
21 * document number 300641-004, 300884-013: 6300ESB
22 * document number 301473-002, 301474-026: 82801F (ICH6)
23 * document number 313082-001, 313075-006: 631xESB, 632xESB
24 * document number 307013-003, 307014-024: 82801G (ICH7)
25 * document number 322896-001, 322897-001: NM10
26 * document number 313056-003, 313057-017: 82801H (ICH8)
27 * document number 316972-004, 316973-012: 82801I (ICH9)
28 * document number 319973-002, 319974-002: 82801J (ICH10)
29 * document number 322169-001, 322170-003: 5 Series, 3400 Series (PCH)
30 * document number 320066-003, 320257-008: EP80597 (IICH)
31 * document number 324645-001, 324646-001: Cougar Point (CPT)
36 * document number TBD : Lynx Point-LP
53 #include <linux/errno.h> /* For the -ENODEV/... values */
60 #include <linux/ioport.h> /* For io-port access */
71 #define TCOBASE(p) ((p)->tco_res->start)
73 #define SMI_EN(p) ((p)->smi_res->start)
101 * NO_REBOOT flag is Memory-Mapped GCS register bit 5 (TCO version 2),
102 * or memory-mapped PMC register bit 4 (TCO version 3).
107 /* the PCI-device */
121 MODULE_PARM_DESC(heartbeat, "Watchdog timeout in seconds. "
134 "Turn off SMI clearing watchdog (depends on TCO-version)(default=1)");
146 int secs) in seconds_to_ticks() argument
148 return p->iTCO_version == 3 ? secs : (secs * 10) / 6; in seconds_to_ticks()
154 return p->iTCO_version == 3 ? ticks : (ticks * 6) / 10; in ticks_to_seconds()
161 switch (p->iTCO_version) { in no_reboot_bit()
189 pci_read_config_dword(p->pci_dev, 0xd4, &val32); in update_no_reboot_bit_pci()
194 pci_write_config_dword(p->pci_dev, 0xd4, val32); in update_no_reboot_bit_pci()
195 pci_read_config_dword(p->pci_dev, 0xd4, &newval32); in update_no_reboot_bit_pci()
199 return -EIO; in update_no_reboot_bit_pci()
209 val32 = readl(p->gcs_pmc); in update_no_reboot_bit_mem()
214 writel(val32, p->gcs_pmc); in update_no_reboot_bit_mem()
215 newval32 = readl(p->gcs_pmc); in update_no_reboot_bit_mem()
219 return -EIO; in update_no_reboot_bit_mem()
248 return val != newval ? -EIO : 0; in update_no_reboot_bit_cnt()
264 if (pdata->no_reboot_use_pmc) { in iTCO_wdt_no_reboot_bit_setup()
265 struct intel_pmc_dev *pmc = dev_get_drvdata(pdev->dev.parent); in iTCO_wdt_no_reboot_bit_setup()
267 p->update_no_reboot_bit = update_no_reboot_bit_pmc; in iTCO_wdt_no_reboot_bit_setup()
268 p->no_reboot_priv = pmc; in iTCO_wdt_no_reboot_bit_setup()
272 if (p->iTCO_version >= 6) in iTCO_wdt_no_reboot_bit_setup()
273 p->update_no_reboot_bit = update_no_reboot_bit_cnt; in iTCO_wdt_no_reboot_bit_setup()
274 else if (p->iTCO_version >= 2) in iTCO_wdt_no_reboot_bit_setup()
275 p->update_no_reboot_bit = update_no_reboot_bit_mem; in iTCO_wdt_no_reboot_bit_setup()
276 else if (p->iTCO_version == 1) in iTCO_wdt_no_reboot_bit_setup()
277 p->update_no_reboot_bit = update_no_reboot_bit_pci; in iTCO_wdt_no_reboot_bit_setup()
279 p->update_no_reboot_bit = update_no_reboot_bit_def; in iTCO_wdt_no_reboot_bit_setup()
281 p->no_reboot_priv = p; in iTCO_wdt_no_reboot_bit_setup()
289 spin_lock(&p->io_lock); in iTCO_wdt_start()
291 iTCO_vendor_pre_start(p->smi_res, wd_dev->timeout); in iTCO_wdt_start()
294 if (p->update_no_reboot_bit(p->no_reboot_priv, false)) { in iTCO_wdt_start()
295 spin_unlock(&p->io_lock); in iTCO_wdt_start()
296 dev_err(wd_dev->parent, "failed to reset NO_REBOOT flag, reboot disabled by hardware/BIOS\n"); in iTCO_wdt_start()
297 return -EIO; in iTCO_wdt_start()
302 if (p->iTCO_version >= 2) in iTCO_wdt_start()
304 else if (p->iTCO_version == 1) in iTCO_wdt_start()
307 /* Bit 11: TCO Timer Halt -> 0 = The TCO timer is enabled to count */ in iTCO_wdt_start()
312 spin_unlock(&p->io_lock); in iTCO_wdt_start()
315 return -1; in iTCO_wdt_start()
324 spin_lock(&p->io_lock); in iTCO_wdt_stop()
326 iTCO_vendor_pre_stop(p->smi_res); in iTCO_wdt_stop()
328 /* Bit 11: TCO Timer Halt -> 1 = The TCO timer is disabled */ in iTCO_wdt_stop()
335 p->update_no_reboot_bit(p->no_reboot_priv, true); in iTCO_wdt_stop()
337 spin_unlock(&p->io_lock); in iTCO_wdt_stop()
340 return -1; in iTCO_wdt_stop()
348 spin_lock(&p->io_lock); in iTCO_wdt_ping()
351 if (p->iTCO_version >= 2) { in iTCO_wdt_ping()
353 } else if (p->iTCO_version == 1) { in iTCO_wdt_ping()
354 /* Reset the timeout status bit so that the timer in iTCO_wdt_ping()
361 spin_unlock(&p->io_lock); in iTCO_wdt_ping()
375 if (p->iTCO_version == 1) in iTCO_wdt_set_timeout()
379 /* "Values of 0h-3h are ignored and should not be attempted" */ in iTCO_wdt_set_timeout()
381 return -EINVAL; in iTCO_wdt_set_timeout()
382 if ((p->iTCO_version >= 2 && tmrval > 0x3ff) || in iTCO_wdt_set_timeout()
383 (p->iTCO_version == 1 && tmrval > 0x03f)) in iTCO_wdt_set_timeout()
384 return -EINVAL; in iTCO_wdt_set_timeout()
387 if (p->iTCO_version >= 2) { in iTCO_wdt_set_timeout()
388 spin_lock(&p->io_lock); in iTCO_wdt_set_timeout()
394 spin_unlock(&p->io_lock); in iTCO_wdt_set_timeout()
397 return -EINVAL; in iTCO_wdt_set_timeout()
398 } else if (p->iTCO_version == 1) { in iTCO_wdt_set_timeout()
399 spin_lock(&p->io_lock); in iTCO_wdt_set_timeout()
405 spin_unlock(&p->io_lock); in iTCO_wdt_set_timeout()
408 return -EINVAL; in iTCO_wdt_set_timeout()
411 wd_dev->timeout = t; in iTCO_wdt_set_timeout()
423 if (p->iTCO_version >= 2) { in iTCO_wdt_get_timeleft()
424 spin_lock(&p->io_lock); in iTCO_wdt_get_timeleft()
427 spin_unlock(&p->io_lock); in iTCO_wdt_get_timeleft()
430 } else if (p->iTCO_version == 1) { in iTCO_wdt_get_timeleft()
431 spin_lock(&p->io_lock); in iTCO_wdt_get_timeleft()
436 spin_unlock(&p->io_lock); in iTCO_wdt_get_timeleft()
448 /* Bit 11: TCO Timer Halt -> 0 = The TCO timer is enabled */ in iTCO_wdt_set_running()
451 set_bit(WDOG_HW_RUNNING, &p->wddev.status); in iTCO_wdt_set_running()
483 struct device *dev = &pdev->dev; in iTCO_wdt_probe()
490 return -ENODEV; in iTCO_wdt_probe()
494 return -ENOMEM; in iTCO_wdt_probe()
496 spin_lock_init(&p->io_lock); in iTCO_wdt_probe()
498 p->tco_res = platform_get_resource(pdev, IORESOURCE_IO, ICH_RES_IO_TCO); in iTCO_wdt_probe()
499 if (!p->tco_res) in iTCO_wdt_probe()
500 return -ENODEV; in iTCO_wdt_probe()
502 p->iTCO_version = pdata->version; in iTCO_wdt_probe()
503 p->pci_dev = to_pci_dev(dev->parent); in iTCO_wdt_probe()
505 p->smi_res = platform_get_resource(pdev, IORESOURCE_IO, ICH_RES_IO_SMI); in iTCO_wdt_probe()
506 if (p->smi_res) { in iTCO_wdt_probe()
508 if (!devm_request_region(dev, p->smi_res->start, in iTCO_wdt_probe()
509 resource_size(p->smi_res), in iTCO_wdt_probe()
510 pdev->name)) { in iTCO_wdt_probe()
513 return -EBUSY; in iTCO_wdt_probe()
516 turn_SMI_watchdog_clear_off >= p->iTCO_version) { in iTCO_wdt_probe()
518 return -ENODEV; in iTCO_wdt_probe()
524 * Get the Memory-Mapped GCS or PMC register, we need it for the in iTCO_wdt_probe()
527 if (p->iTCO_version >= 2 && p->iTCO_version < 6 && in iTCO_wdt_probe()
528 !pdata->no_reboot_use_pmc) { in iTCO_wdt_probe()
529 p->gcs_pmc = devm_platform_ioremap_resource(pdev, ICH_RES_MEM_GCS_PMC); in iTCO_wdt_probe()
530 if (IS_ERR(p->gcs_pmc)) in iTCO_wdt_probe()
531 return PTR_ERR(p->gcs_pmc); in iTCO_wdt_probe()
535 if (p->update_no_reboot_bit(p->no_reboot_priv, false) && in iTCO_wdt_probe()
538 return -ENODEV; /* Cannot reset NO_REBOOT bit */ in iTCO_wdt_probe()
541 if (turn_SMI_watchdog_clear_off >= p->iTCO_version) { in iTCO_wdt_probe()
543 * Bit 13: TCO_EN -> 0 in iTCO_wdt_probe()
551 if (!devm_request_region(dev, p->tco_res->start, in iTCO_wdt_probe()
552 resource_size(p->tco_res), in iTCO_wdt_probe()
553 pdev->name)) { in iTCO_wdt_probe()
556 return -EBUSY; in iTCO_wdt_probe()
560 pdata->name, pdata->version, (u64)TCOBASE(p)); in iTCO_wdt_probe()
563 switch (p->iTCO_version) { in iTCO_wdt_probe()
582 ident.firmware_version = p->iTCO_version; in iTCO_wdt_probe()
583 p->wddev.info = &ident; in iTCO_wdt_probe()
584 p->wddev.ops = &iTCO_wdt_ops; in iTCO_wdt_probe()
585 p->wddev.bootstatus = 0; in iTCO_wdt_probe()
586 p->wddev.timeout = WATCHDOG_TIMEOUT; in iTCO_wdt_probe()
587 watchdog_set_nowayout(&p->wddev, nowayout); in iTCO_wdt_probe()
588 p->wddev.parent = dev; in iTCO_wdt_probe()
590 watchdog_set_drvdata(&p->wddev, p); in iTCO_wdt_probe()
598 p->update_no_reboot_bit(p->no_reboot_priv, true); in iTCO_wdt_probe()
603 if (iTCO_wdt_set_timeout(&p->wddev, heartbeat)) { in iTCO_wdt_probe()
604 iTCO_wdt_set_timeout(&p->wddev, WATCHDOG_TIMEOUT); in iTCO_wdt_probe()
605 dev_info(dev, "timeout value out of range, using %d\n", in iTCO_wdt_probe()
609 watchdog_stop_on_reboot(&p->wddev); in iTCO_wdt_probe()
610 watchdog_stop_on_unregister(&p->wddev); in iTCO_wdt_probe()
611 ret = devm_watchdog_register_device(dev, &p->wddev); in iTCO_wdt_probe()
622 * Suspend-to-idle requires this, because it stops the ticks and timekeeping, so
641 p->suspended = false; in iTCO_wdt_suspend_noirq()
642 if (watchdog_active(&p->wddev) && need_suspend()) { in iTCO_wdt_suspend_noirq()
643 ret = iTCO_wdt_stop(&p->wddev); in iTCO_wdt_suspend_noirq()
645 p->suspended = true; in iTCO_wdt_suspend_noirq()
654 if (p->suspended) in iTCO_wdt_resume_noirq()
655 iTCO_wdt_start(&p->wddev); in iTCO_wdt_resume_noirq()