Lines Matching +full:watchdog +full:- +full:enable
1 // SPDX-License-Identifier: GPL-2.0-or-later
14 * AMD Publication 45482 "AMD SB800-Series Southbridges Register
17 * for AMD Family 16h Models 00h-0Fh Processors"
20 * for AMD Family 16h Models 30h-3Fh Processors"
21 * AMD Publication 55570-B1-PUB "Processor Programming Reference (PPR)
24 * AMD Publication 55772-A1-PUB "Processor Programming Reference (PPR)
43 #include <linux/watchdog.h>
47 #define TCO_DRIVER_NAME "sp5100-tco"
61 /* the watchdog platform device */
71 MODULE_PARM_DESC(action, "Action taken when watchdog expires, 0 to reset, 1 to poweroff (default="
77 MODULE_PARM_DESC(heartbeat, "Watchdog heartbeat in seconds. (default="
82 MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started."
91 if (dev->vendor == PCI_VENDOR_ID_ATI && in tco_reg_layout()
92 dev->device == PCI_DEVICE_ID_ATI_SBX00_SMBUS && in tco_reg_layout()
93 dev->revision < 0x40) { in tco_reg_layout()
95 } else if (dev->vendor == PCI_VENDOR_ID_AMD && in tco_reg_layout()
96 sp5100_tco_pci->device == PCI_DEVICE_ID_AMD_KERNCZ_SMBUS && in tco_reg_layout()
97 sp5100_tco_pci->revision >= AMD_ZEN_SMBUS_PCI_REV) { in tco_reg_layout()
99 } else if ((dev->vendor == PCI_VENDOR_ID_AMD || dev->vendor == PCI_VENDOR_ID_HYGON) && in tco_reg_layout()
100 ((dev->device == PCI_DEVICE_ID_AMD_HUDSON2_SMBUS && in tco_reg_layout()
101 dev->revision >= 0x41) || in tco_reg_layout()
102 (dev->device == PCI_DEVICE_ID_AMD_KERNCZ_SMBUS && in tco_reg_layout()
103 dev->revision >= 0x49))) { in tco_reg_layout()
114 val = readl(SP5100_WDT_CONTROL(tco->tcobase)); in tco_timer_start()
116 writel(val, SP5100_WDT_CONTROL(tco->tcobase)); in tco_timer_start()
120 writel(val, SP5100_WDT_CONTROL(tco->tcobase)); in tco_timer_start()
130 val = readl(SP5100_WDT_CONTROL(tco->tcobase)); in tco_timer_stop()
132 writel(val, SP5100_WDT_CONTROL(tco->tcobase)); in tco_timer_stop()
142 val = readl(SP5100_WDT_CONTROL(tco->tcobase)); in tco_timer_ping()
144 writel(val, SP5100_WDT_CONTROL(tco->tcobase)); in tco_timer_ping()
154 /* Write new heartbeat to watchdog */ in tco_timer_set_timeout()
155 writel(t, SP5100_WDT_COUNT(tco->tcobase)); in tco_timer_set_timeout()
157 wdd->timeout = t; in tco_timer_set_timeout()
166 return readl(SP5100_WDT_COUNT(tco->tcobase)); in tco_timer_get_timeleft()
190 switch (tco->tco_reg_layout) { in tco_timer_enable()
193 /* Set the Watchdog timer resolution to 1 sec */ in tco_timer_enable()
197 /* Enable watchdog decode bit and watchdog timer */ in tco_timer_enable()
204 /* Enable watchdog decode bit */ in tco_timer_enable()
215 /* Enable Watchdog timer and set the resolution to 1 sec */ in tco_timer_enable()
221 /* Set the Watchdog timer resolution to 1 sec and enable */ in tco_timer_enable()
236 for (i = 3; i >= 0; i--) in sp5100_tco_read_pm_reg32()
260 struct device *dev = tco->wdd.parent; in sp5100_tco_prepare_base()
265 return -ENODEV; in sp5100_tco_prepare_base()
276 return -EBUSY; in sp5100_tco_prepare_base()
279 tco->tcobase = devm_ioremap(dev, mmio_addr, SP5100_WDT_MEM_MAP_SIZE); in sp5100_tco_prepare_base()
280 if (!tco->tcobase) { in sp5100_tco_prepare_base()
283 return -ENOMEM; in sp5100_tco_prepare_base()
286 dev_info(dev, "Using 0x%08x for watchdog MMIO address\n", mmio_addr); in sp5100_tco_prepare_base()
293 struct watchdog_device *wdd = &tco->wdd; in sp5100_tco_timer_init()
294 struct device *dev = wdd->parent; in sp5100_tco_timer_init()
297 val = readl(SP5100_WDT_CONTROL(tco->tcobase)); in sp5100_tco_timer_init()
299 dev_err(dev, "Watchdog hardware is disabled\n"); in sp5100_tco_timer_init()
300 return -ENODEV; in sp5100_tco_timer_init()
308 wdd->bootstatus = WDIOF_CARDRESET; in sp5100_tco_timer_init()
310 /* Set watchdog action */ in sp5100_tco_timer_init()
315 writel(val, SP5100_WDT_CONTROL(tco->tcobase)); in sp5100_tco_timer_init()
318 tco_timer_set_timeout(wdd, wdd->timeout); in sp5100_tco_timer_init()
370 return -EBUSY; in sp5100_tco_setupdevice_mmio()
376 ret = -ENOMEM; in sp5100_tco_setupdevice_mmio()
383 * also starts the timer operation. Enable if not already enabled. in sp5100_tco_setupdevice_mmio()
394 dev_err(dev, "Failed to enable the timer\n"); in sp5100_tco_setupdevice_mmio()
395 ret = -EFAULT; in sp5100_tco_setupdevice_mmio()
432 if (tco->tco_reg_layout == efch_mmio) in sp5100_tco_setupdevice()
440 return -EBUSY; in sp5100_tco_setupdevice()
446 switch (tco->tco_reg_layout) { in sp5100_tco_setupdevice()
453 * Secondly, find the watchdog timer MMIO address in sp5100_tco_setupdevice()
490 return -ENODEV; in sp5100_tco_setupdevice()
495 /* Setup the watchdog timer */ in sp5100_tco_setupdevice()
520 struct device *dev = &pdev->dev; in sp5100_tco_probe()
527 return -ENOMEM; in sp5100_tco_probe()
529 tco->tco_reg_layout = tco_reg_layout(sp5100_tco_pci); in sp5100_tco_probe()
531 wdd = &tco->wdd; in sp5100_tco_probe()
532 wdd->parent = dev; in sp5100_tco_probe()
533 wdd->info = &sp5100_tco_wdt_info; in sp5100_tco_probe()
534 wdd->ops = &sp5100_tco_wdt_ops; in sp5100_tco_probe()
535 wdd->timeout = WATCHDOG_HEARTBEAT; in sp5100_tco_probe()
536 wdd->min_timeout = 1; in sp5100_tco_probe()
537 wdd->max_timeout = 0xffff; in sp5100_tco_probe()
555 wdd->timeout, nowayout); in sp5100_tco_probe()
602 return -ENODEV; in sp5100_tco_init()
604 pr_info("SP5100/SB800 TCO WatchDog Timer Driver\n"); in sp5100_tco_init()
611 platform_device_register_simple(TCO_DRIVER_NAME, -1, NULL, 0); in sp5100_tco_init()