Lines Matching refs:p
71 #define TCOBASE(p) ((p)->tco_res->start) argument
73 #define SMI_EN(p) ((p)->smi_res->start) argument
75 #define TCO_RLD(p) (TCOBASE(p) + 0x00) /* TCO Timer Reload/Curr. Value */ argument
76 #define TCOv1_TMR(p) (TCOBASE(p) + 0x01) /* TCOv1 Timer Initial Value*/ argument
77 #define TCO_DAT_IN(p) (TCOBASE(p) + 0x02) /* TCO Data In Register */ argument
78 #define TCO_DAT_OUT(p) (TCOBASE(p) + 0x03) /* TCO Data Out Register */ argument
79 #define TCO1_STS(p) (TCOBASE(p) + 0x04) /* TCO1 Status Register */ argument
80 #define TCO2_STS(p) (TCOBASE(p) + 0x06) /* TCO2 Status Register */ argument
81 #define TCO1_CNT(p) (TCOBASE(p) + 0x08) /* TCO1 Control Register */ argument
82 #define TCO2_CNT(p) (TCOBASE(p) + 0x0a) /* TCO2 Control Register */ argument
83 #define TCOv2_TMR(p) (TCOBASE(p) + 0x12) /* TCOv2 Timer Initial Value*/ argument
107 int (*update_no_reboot_bit)(void *p, bool set);
138 static inline unsigned int seconds_to_ticks(struct iTCO_wdt_private *p, in seconds_to_ticks() argument
141 return p->iTCO_version == 3 ? secs : (secs * 10) / 6; in seconds_to_ticks()
144 static inline unsigned int ticks_to_seconds(struct iTCO_wdt_private *p, in ticks_to_seconds() argument
147 return p->iTCO_version == 3 ? ticks : (ticks * 6) / 10; in ticks_to_seconds()
150 static inline u32 no_reboot_bit(struct iTCO_wdt_private *p) in no_reboot_bit() argument
154 switch (p->iTCO_version) { in no_reboot_bit()
179 struct iTCO_wdt_private *p = priv; in update_no_reboot_bit_pci() local
182 pci_read_config_dword(p->pci_dev, 0xd4, &val32); in update_no_reboot_bit_pci()
184 val32 |= no_reboot_bit(p); in update_no_reboot_bit_pci()
186 val32 &= ~no_reboot_bit(p); in update_no_reboot_bit_pci()
187 pci_write_config_dword(p->pci_dev, 0xd4, val32); in update_no_reboot_bit_pci()
188 pci_read_config_dword(p->pci_dev, 0xd4, &newval32); in update_no_reboot_bit_pci()
199 struct iTCO_wdt_private *p = priv; in update_no_reboot_bit_mem() local
202 val32 = readl(p->gcs_pmc); in update_no_reboot_bit_mem()
204 val32 |= no_reboot_bit(p); in update_no_reboot_bit_mem()
206 val32 &= ~no_reboot_bit(p); in update_no_reboot_bit_mem()
207 writel(val32, p->gcs_pmc); in update_no_reboot_bit_mem()
208 newval32 = readl(p->gcs_pmc); in update_no_reboot_bit_mem()
219 struct iTCO_wdt_private *p = priv; in update_no_reboot_bit_cnt() local
222 val = inw(TCO1_CNT(p)); in update_no_reboot_bit_cnt()
227 outw(val, TCO1_CNT(p)); in update_no_reboot_bit_cnt()
228 newval = inw(TCO1_CNT(p)); in update_no_reboot_bit_cnt()
243 static void iTCO_wdt_no_reboot_bit_setup(struct iTCO_wdt_private *p, in iTCO_wdt_no_reboot_bit_setup() argument
250 p->update_no_reboot_bit = update_no_reboot_bit_pmc; in iTCO_wdt_no_reboot_bit_setup()
251 p->no_reboot_priv = pmc; in iTCO_wdt_no_reboot_bit_setup()
255 if (p->iTCO_version >= 6) in iTCO_wdt_no_reboot_bit_setup()
256 p->update_no_reboot_bit = update_no_reboot_bit_cnt; in iTCO_wdt_no_reboot_bit_setup()
257 else if (p->iTCO_version >= 2) in iTCO_wdt_no_reboot_bit_setup()
258 p->update_no_reboot_bit = update_no_reboot_bit_mem; in iTCO_wdt_no_reboot_bit_setup()
259 else if (p->iTCO_version == 1) in iTCO_wdt_no_reboot_bit_setup()
260 p->update_no_reboot_bit = update_no_reboot_bit_pci; in iTCO_wdt_no_reboot_bit_setup()
262 p->update_no_reboot_bit = update_no_reboot_bit_def; in iTCO_wdt_no_reboot_bit_setup()
264 p->no_reboot_priv = p; in iTCO_wdt_no_reboot_bit_setup()
269 struct iTCO_wdt_private *p = watchdog_get_drvdata(wd_dev); in iTCO_wdt_start() local
272 spin_lock(&p->io_lock); in iTCO_wdt_start()
274 iTCO_vendor_pre_start(p->smi_res, wd_dev->timeout); in iTCO_wdt_start()
277 if (p->update_no_reboot_bit(p->no_reboot_priv, false)) { in iTCO_wdt_start()
278 spin_unlock(&p->io_lock); in iTCO_wdt_start()
285 if (p->iTCO_version >= 2) in iTCO_wdt_start()
286 outw(0x01, TCO_RLD(p)); in iTCO_wdt_start()
287 else if (p->iTCO_version == 1) in iTCO_wdt_start()
288 outb(0x01, TCO_RLD(p)); in iTCO_wdt_start()
291 val = inw(TCO1_CNT(p)); in iTCO_wdt_start()
293 outw(val, TCO1_CNT(p)); in iTCO_wdt_start()
294 val = inw(TCO1_CNT(p)); in iTCO_wdt_start()
295 spin_unlock(&p->io_lock); in iTCO_wdt_start()
304 struct iTCO_wdt_private *p = watchdog_get_drvdata(wd_dev); in iTCO_wdt_stop() local
307 spin_lock(&p->io_lock); in iTCO_wdt_stop()
309 iTCO_vendor_pre_stop(p->smi_res); in iTCO_wdt_stop()
312 val = inw(TCO1_CNT(p)); in iTCO_wdt_stop()
314 outw(val, TCO1_CNT(p)); in iTCO_wdt_stop()
315 val = inw(TCO1_CNT(p)); in iTCO_wdt_stop()
318 p->update_no_reboot_bit(p->no_reboot_priv, true); in iTCO_wdt_stop()
320 spin_unlock(&p->io_lock); in iTCO_wdt_stop()
329 struct iTCO_wdt_private *p = watchdog_get_drvdata(wd_dev); in iTCO_wdt_ping() local
331 spin_lock(&p->io_lock); in iTCO_wdt_ping()
334 if (p->iTCO_version >= 2) { in iTCO_wdt_ping()
335 outw(0x01, TCO_RLD(p)); in iTCO_wdt_ping()
336 } else if (p->iTCO_version == 1) { in iTCO_wdt_ping()
339 outw(0x0008, TCO1_STS(p)); /* write 1 to clear bit */ in iTCO_wdt_ping()
341 outb(0x01, TCO_RLD(p)); in iTCO_wdt_ping()
344 spin_unlock(&p->io_lock); in iTCO_wdt_ping()
350 struct iTCO_wdt_private *p = watchdog_get_drvdata(wd_dev); in iTCO_wdt_set_timeout() local
355 tmrval = seconds_to_ticks(p, t); in iTCO_wdt_set_timeout()
358 if (p->iTCO_version == 1) in iTCO_wdt_set_timeout()
365 if ((p->iTCO_version >= 2 && tmrval > 0x3ff) || in iTCO_wdt_set_timeout()
366 (p->iTCO_version == 1 && tmrval > 0x03f)) in iTCO_wdt_set_timeout()
370 if (p->iTCO_version >= 2) { in iTCO_wdt_set_timeout()
371 spin_lock(&p->io_lock); in iTCO_wdt_set_timeout()
372 val16 = inw(TCOv2_TMR(p)); in iTCO_wdt_set_timeout()
375 outw(val16, TCOv2_TMR(p)); in iTCO_wdt_set_timeout()
376 val16 = inw(TCOv2_TMR(p)); in iTCO_wdt_set_timeout()
377 spin_unlock(&p->io_lock); in iTCO_wdt_set_timeout()
381 } else if (p->iTCO_version == 1) { in iTCO_wdt_set_timeout()
382 spin_lock(&p->io_lock); in iTCO_wdt_set_timeout()
383 val8 = inb(TCOv1_TMR(p)); in iTCO_wdt_set_timeout()
386 outb(val8, TCOv1_TMR(p)); in iTCO_wdt_set_timeout()
387 val8 = inb(TCOv1_TMR(p)); in iTCO_wdt_set_timeout()
388 spin_unlock(&p->io_lock); in iTCO_wdt_set_timeout()
400 struct iTCO_wdt_private *p = watchdog_get_drvdata(wd_dev); in iTCO_wdt_get_timeleft() local
406 if (p->iTCO_version >= 2) { in iTCO_wdt_get_timeleft()
407 spin_lock(&p->io_lock); in iTCO_wdt_get_timeleft()
408 val16 = inw(TCO_RLD(p)); in iTCO_wdt_get_timeleft()
410 spin_unlock(&p->io_lock); in iTCO_wdt_get_timeleft()
412 time_left = ticks_to_seconds(p, val16); in iTCO_wdt_get_timeleft()
413 } else if (p->iTCO_version == 1) { in iTCO_wdt_get_timeleft()
414 spin_lock(&p->io_lock); in iTCO_wdt_get_timeleft()
415 val8 = inb(TCO_RLD(p)); in iTCO_wdt_get_timeleft()
417 if (!(inw(TCO1_STS(p)) & 0x0008)) in iTCO_wdt_get_timeleft()
418 val8 += (inb(TCOv1_TMR(p)) & 0x3f); in iTCO_wdt_get_timeleft()
419 spin_unlock(&p->io_lock); in iTCO_wdt_get_timeleft()
421 time_left = ticks_to_seconds(p, val8); in iTCO_wdt_get_timeleft()
426 static void iTCO_wdt_set_running(struct iTCO_wdt_private *p) in iTCO_wdt_set_running() argument
431 val = inw(TCO1_CNT(p)); in iTCO_wdt_set_running()
433 set_bit(WDOG_HW_RUNNING, &p->wddev.status); in iTCO_wdt_set_running()
465 struct iTCO_wdt_private *p; in iTCO_wdt_probe() local
472 p = devm_kzalloc(dev, sizeof(*p), GFP_KERNEL); in iTCO_wdt_probe()
473 if (!p) in iTCO_wdt_probe()
476 spin_lock_init(&p->io_lock); in iTCO_wdt_probe()
478 p->tco_res = platform_get_resource(pdev, IORESOURCE_IO, ICH_RES_IO_TCO); in iTCO_wdt_probe()
479 if (!p->tco_res) in iTCO_wdt_probe()
482 p->iTCO_version = pdata->version; in iTCO_wdt_probe()
483 p->pci_dev = to_pci_dev(dev->parent); in iTCO_wdt_probe()
485 p->smi_res = platform_get_resource(pdev, IORESOURCE_IO, ICH_RES_IO_SMI); in iTCO_wdt_probe()
486 if (p->smi_res) { in iTCO_wdt_probe()
488 if (!devm_request_region(dev, p->smi_res->start, in iTCO_wdt_probe()
489 resource_size(p->smi_res), in iTCO_wdt_probe()
492 (u64)SMI_EN(p)); in iTCO_wdt_probe()
496 turn_SMI_watchdog_clear_off >= p->iTCO_version) { in iTCO_wdt_probe()
501 iTCO_wdt_no_reboot_bit_setup(p, pdev, pdata); in iTCO_wdt_probe()
507 if (p->iTCO_version >= 2 && p->iTCO_version < 6 && in iTCO_wdt_probe()
509 p->gcs_pmc = devm_platform_ioremap_resource(pdev, ICH_RES_MEM_GCS_PMC); in iTCO_wdt_probe()
510 if (IS_ERR(p->gcs_pmc)) in iTCO_wdt_probe()
511 return PTR_ERR(p->gcs_pmc); in iTCO_wdt_probe()
515 if (p->update_no_reboot_bit(p->no_reboot_priv, false) && in iTCO_wdt_probe()
522 p->update_no_reboot_bit(p->no_reboot_priv, true); in iTCO_wdt_probe()
524 if (turn_SMI_watchdog_clear_off >= p->iTCO_version) { in iTCO_wdt_probe()
529 val32 = inl(SMI_EN(p)); in iTCO_wdt_probe()
531 outl(val32, SMI_EN(p)); in iTCO_wdt_probe()
534 if (!devm_request_region(dev, p->tco_res->start, in iTCO_wdt_probe()
535 resource_size(p->tco_res), in iTCO_wdt_probe()
538 (u64)TCOBASE(p)); in iTCO_wdt_probe()
543 pdata->name, pdata->version, (u64)TCOBASE(p)); in iTCO_wdt_probe()
546 switch (p->iTCO_version) { in iTCO_wdt_probe()
550 outw(0x0008, TCO1_STS(p)); /* Clear the Time Out Status bit */ in iTCO_wdt_probe()
551 outw(0x0002, TCO2_STS(p)); /* Clear SECOND_TO_STS bit */ in iTCO_wdt_probe()
554 outl(0x20008, TCO1_STS(p)); in iTCO_wdt_probe()
559 outw(0x0008, TCO1_STS(p)); /* Clear the Time Out Status bit */ in iTCO_wdt_probe()
560 outw(0x0002, TCO2_STS(p)); /* Clear SECOND_TO_STS bit */ in iTCO_wdt_probe()
561 outw(0x0004, TCO2_STS(p)); /* Clear BOOT_STS bit */ in iTCO_wdt_probe()
565 p->wddev.info = &ident, in iTCO_wdt_probe()
566 p->wddev.ops = &iTCO_wdt_ops, in iTCO_wdt_probe()
567 p->wddev.bootstatus = 0; in iTCO_wdt_probe()
568 p->wddev.timeout = WATCHDOG_TIMEOUT; in iTCO_wdt_probe()
569 watchdog_set_nowayout(&p->wddev, nowayout); in iTCO_wdt_probe()
570 p->wddev.parent = dev; in iTCO_wdt_probe()
572 watchdog_set_drvdata(&p->wddev, p); in iTCO_wdt_probe()
573 platform_set_drvdata(pdev, p); in iTCO_wdt_probe()
575 iTCO_wdt_set_running(p); in iTCO_wdt_probe()
579 if (iTCO_wdt_set_timeout(&p->wddev, heartbeat)) { in iTCO_wdt_probe()
580 iTCO_wdt_set_timeout(&p->wddev, WATCHDOG_TIMEOUT); in iTCO_wdt_probe()
585 watchdog_stop_on_reboot(&p->wddev); in iTCO_wdt_probe()
586 watchdog_stop_on_unregister(&p->wddev); in iTCO_wdt_probe()
587 ret = devm_watchdog_register_device(dev, &p->wddev); in iTCO_wdt_probe()
617 struct iTCO_wdt_private *p = dev_get_drvdata(dev); in iTCO_wdt_suspend_noirq() local
620 p->suspended = false; in iTCO_wdt_suspend_noirq()
621 if (watchdog_active(&p->wddev) && need_suspend()) { in iTCO_wdt_suspend_noirq()
622 ret = iTCO_wdt_stop(&p->wddev); in iTCO_wdt_suspend_noirq()
624 p->suspended = true; in iTCO_wdt_suspend_noirq()
631 struct iTCO_wdt_private *p = dev_get_drvdata(dev); in iTCO_wdt_resume_noirq() local
633 if (p->suspended) in iTCO_wdt_resume_noirq()
634 iTCO_wdt_start(&p->wddev); in iTCO_wdt_resume_noirq()