Lines Matching +full:document +full:- +full:file
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)
32 * document number TBD : Patsburg (PBG)
33 * document number TBD : DH89xxCC
34 * document number TBD : Panther Point
35 * document number TBD : Lynx Point
36 * document number TBD : Lynx Point-LP
53 #include <linux/errno.h> /* For the -ENODEV/... values */
57 #include <linux/fs.h> /* For file operations */
60 #include <linux/ioport.h> /* For io-port access */
70 #define TCOBASE(p) ((p)->tco_res->start)
72 #define SMI_EN(p) ((p)->smi_res->start)
100 * NO_REBOOT flag is Memory-Mapped GCS register bit 5 (TCO version 2),
101 * or memory-mapped PMC register bit 4 (TCO version 3).
104 /* the PCI-device */
131 "Turn off SMI clearing watchdog (depends on TCO-version)(default=1)");
145 return p->iTCO_version == 3 ? secs : (secs * 10) / 6; in seconds_to_ticks()
151 return p->iTCO_version == 3 ? ticks : (ticks * 6) / 10; in ticks_to_seconds()
158 switch (p->iTCO_version) { in no_reboot_bit()
186 pci_read_config_dword(p->pci_dev, 0xd4, &val32); in update_no_reboot_bit_pci()
191 pci_write_config_dword(p->pci_dev, 0xd4, val32); in update_no_reboot_bit_pci()
192 pci_read_config_dword(p->pci_dev, 0xd4, &newval32); in update_no_reboot_bit_pci()
196 return -EIO; in update_no_reboot_bit_pci()
206 val32 = readl(p->gcs_pmc); in update_no_reboot_bit_mem()
211 writel(val32, p->gcs_pmc); in update_no_reboot_bit_mem()
212 newval32 = readl(p->gcs_pmc); in update_no_reboot_bit_mem()
216 return -EIO; in update_no_reboot_bit_mem()
245 return val != newval ? -EIO : 0; in update_no_reboot_bit_cnt()
261 if (pdata->no_reboot_use_pmc) { in iTCO_wdt_no_reboot_bit_setup()
262 struct intel_pmc_dev *pmc = dev_get_drvdata(pdev->dev.parent); in iTCO_wdt_no_reboot_bit_setup()
264 p->update_no_reboot_bit = update_no_reboot_bit_pmc; in iTCO_wdt_no_reboot_bit_setup()
265 p->no_reboot_priv = pmc; in iTCO_wdt_no_reboot_bit_setup()
269 if (p->iTCO_version >= 6) in iTCO_wdt_no_reboot_bit_setup()
270 p->update_no_reboot_bit = update_no_reboot_bit_cnt; in iTCO_wdt_no_reboot_bit_setup()
271 else if (p->iTCO_version >= 2) in iTCO_wdt_no_reboot_bit_setup()
272 p->update_no_reboot_bit = update_no_reboot_bit_mem; in iTCO_wdt_no_reboot_bit_setup()
273 else if (p->iTCO_version == 1) in iTCO_wdt_no_reboot_bit_setup()
274 p->update_no_reboot_bit = update_no_reboot_bit_pci; in iTCO_wdt_no_reboot_bit_setup()
276 p->update_no_reboot_bit = update_no_reboot_bit_def; in iTCO_wdt_no_reboot_bit_setup()
278 p->no_reboot_priv = p; in iTCO_wdt_no_reboot_bit_setup()
286 iTCO_vendor_pre_start(p->smi_res, wd_dev->timeout); in iTCO_wdt_start()
289 if (p->update_no_reboot_bit(p->no_reboot_priv, false)) { in iTCO_wdt_start()
290 dev_err(wd_dev->parent, "failed to reset NO_REBOOT flag, reboot disabled by hardware/BIOS\n"); in iTCO_wdt_start()
291 return -EIO; in iTCO_wdt_start()
296 if (p->iTCO_version >= 2) in iTCO_wdt_start()
298 else if (p->iTCO_version == 1) in iTCO_wdt_start()
301 /* Bit 11: TCO Timer Halt -> 0 = The TCO timer is enabled to count */ in iTCO_wdt_start()
308 return -1; in iTCO_wdt_start()
317 iTCO_vendor_pre_stop(p->smi_res); in iTCO_wdt_stop()
319 /* Bit 11: TCO Timer Halt -> 1 = The TCO timer is disabled */ in iTCO_wdt_stop()
326 p->update_no_reboot_bit(p->no_reboot_priv, true); in iTCO_wdt_stop()
329 return -1; in iTCO_wdt_stop()
338 if (p->iTCO_version >= 2) { in iTCO_wdt_ping()
340 } else if (p->iTCO_version == 1) { in iTCO_wdt_ping()
361 if (p->iTCO_version == 1) in iTCO_wdt_set_timeout()
365 /* "Values of 0h-3h are ignored and should not be attempted" */ in iTCO_wdt_set_timeout()
367 return -EINVAL; in iTCO_wdt_set_timeout()
368 if ((p->iTCO_version >= 2 && tmrval > 0x3ff) || in iTCO_wdt_set_timeout()
369 (p->iTCO_version == 1 && tmrval > 0x03f)) in iTCO_wdt_set_timeout()
370 return -EINVAL; in iTCO_wdt_set_timeout()
373 if (p->iTCO_version >= 2) { in iTCO_wdt_set_timeout()
381 return -EINVAL; in iTCO_wdt_set_timeout()
382 } else if (p->iTCO_version == 1) { in iTCO_wdt_set_timeout()
390 return -EINVAL; in iTCO_wdt_set_timeout()
393 wd_dev->timeout = t; in iTCO_wdt_set_timeout()
405 if (p->iTCO_version >= 2) { in iTCO_wdt_get_timeleft()
410 } else if (p->iTCO_version == 1) { in iTCO_wdt_get_timeleft()
426 /* Bit 11: TCO Timer Halt -> 0 = The TCO timer is enabled */ in iTCO_wdt_set_running()
429 set_bit(WDOG_HW_RUNNING, &p->wddev.status); in iTCO_wdt_set_running()
461 struct device *dev = &pdev->dev; in iTCO_wdt_probe()
468 return -ENODEV; in iTCO_wdt_probe()
472 return -ENOMEM; in iTCO_wdt_probe()
474 p->tco_res = platform_get_resource(pdev, IORESOURCE_IO, ICH_RES_IO_TCO); in iTCO_wdt_probe()
475 if (!p->tco_res) in iTCO_wdt_probe()
476 return -ENODEV; in iTCO_wdt_probe()
478 p->iTCO_version = pdata->version; in iTCO_wdt_probe()
479 p->pci_dev = to_pci_dev(dev->parent); in iTCO_wdt_probe()
481 p->smi_res = platform_get_resource(pdev, IORESOURCE_IO, ICH_RES_IO_SMI); in iTCO_wdt_probe()
482 if (p->smi_res) { in iTCO_wdt_probe()
484 if (!devm_request_region(dev, p->smi_res->start, in iTCO_wdt_probe()
485 resource_size(p->smi_res), in iTCO_wdt_probe()
486 pdev->name)) { in iTCO_wdt_probe()
489 return -EBUSY; in iTCO_wdt_probe()
492 turn_SMI_watchdog_clear_off >= p->iTCO_version) { in iTCO_wdt_probe()
494 return -ENODEV; in iTCO_wdt_probe()
500 * Get the Memory-Mapped GCS or PMC register, we need it for the in iTCO_wdt_probe()
503 if (p->iTCO_version >= 2 && p->iTCO_version < 6 && in iTCO_wdt_probe()
504 !pdata->no_reboot_use_pmc) { in iTCO_wdt_probe()
505 p->gcs_pmc = devm_platform_ioremap_resource(pdev, ICH_RES_MEM_GCS_PMC); in iTCO_wdt_probe()
506 if (IS_ERR(p->gcs_pmc)) in iTCO_wdt_probe()
507 return PTR_ERR(p->gcs_pmc); in iTCO_wdt_probe()
511 if (p->update_no_reboot_bit(p->no_reboot_priv, false) && in iTCO_wdt_probe()
514 return -ENODEV; /* Cannot reset NO_REBOOT bit */ in iTCO_wdt_probe()
517 if (turn_SMI_watchdog_clear_off >= p->iTCO_version) { in iTCO_wdt_probe()
519 * Bit 13: TCO_EN -> 0 in iTCO_wdt_probe()
527 if (!devm_request_region(dev, p->tco_res->start, in iTCO_wdt_probe()
528 resource_size(p->tco_res), in iTCO_wdt_probe()
529 pdev->name)) { in iTCO_wdt_probe()
532 return -EBUSY; in iTCO_wdt_probe()
536 pdata->name, pdata->version, (u64)TCOBASE(p)); in iTCO_wdt_probe()
539 switch (p->iTCO_version) { in iTCO_wdt_probe()
558 ident.firmware_version = p->iTCO_version; in iTCO_wdt_probe()
559 p->wddev.info = &ident; in iTCO_wdt_probe()
560 p->wddev.ops = &iTCO_wdt_ops; in iTCO_wdt_probe()
561 p->wddev.bootstatus = 0; in iTCO_wdt_probe()
562 p->wddev.timeout = WATCHDOG_TIMEOUT; in iTCO_wdt_probe()
563 watchdog_set_nowayout(&p->wddev, nowayout); in iTCO_wdt_probe()
564 p->wddev.parent = dev; in iTCO_wdt_probe()
566 watchdog_set_drvdata(&p->wddev, p); in iTCO_wdt_probe()
574 p->update_no_reboot_bit(p->no_reboot_priv, true); in iTCO_wdt_probe()
579 if (iTCO_wdt_set_timeout(&p->wddev, heartbeat)) { in iTCO_wdt_probe()
580 ret = iTCO_wdt_set_timeout(&p->wddev, WATCHDOG_TIMEOUT); in iTCO_wdt_probe()
590 watchdog_stop_on_reboot(&p->wddev); in iTCO_wdt_probe()
591 watchdog_stop_on_unregister(&p->wddev); in iTCO_wdt_probe()
592 ret = devm_watchdog_register_device(dev, &p->wddev); in iTCO_wdt_probe()
603 * Suspend-to-idle requires this, because it stops the ticks and timekeeping, so
622 p->suspended = false; in iTCO_wdt_suspend_noirq()
623 if (watchdog_active(&p->wddev) && need_suspend()) { in iTCO_wdt_suspend_noirq()
624 ret = iTCO_wdt_stop(&p->wddev); in iTCO_wdt_suspend_noirq()
626 p->suspended = true; in iTCO_wdt_suspend_noirq()
635 if (p->suspended) in iTCO_wdt_resume_noirq()
636 iTCO_wdt_start(&p->wddev); in iTCO_wdt_resume_noirq()