Lines Matching +full:timer +full:- +full:watchdog
1 // SPDX-License-Identifier: GPL-2.0-only
3 * VIA Chipset Watchdog Driver
8 * Timer code by Wim Van Sebroeck <wim@iguana.be>
10 * Caveat: PnP must be enabled in BIOS to allow full access to watchdog
11 * control registers. If not, the watchdog must be configured in BIOS manually.
21 #include <linux/timer.h>
22 #include <linux/watchdog.h>
26 #define VIA_WDT_CONF 0xec /* watchdog enable state */
29 #define VIA_WDT_CONF_ENABLE 0x01 /* 1: enable watchdog */
30 #define VIA_WDT_CONF_MMIO 0x02 /* 1: enable watchdog MMIO */
33 * The MMIO region contains the watchdog control register and the
34 * hardware timer counter.
38 #define VIA_WDT_COUNT 4 /* MMIO addr+4: timer counter reg. */
42 #define VIA_WDT_FIRED 0x02 /* 1: restarted by expired watchdog */
44 #define VIA_WDT_DISABLED 0x08 /* 1: timer is disabled */
50 /* Timer heartbeat (500ms) */
58 MODULE_PARM_DESC(timeout, "Watchdog timeout in seconds, between 1 and 1023 "
63 MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started "
71 static DEFINE_TIMER(timer, wdt_timer_tick);
72 /* The timer that pings the watchdog */
73 static unsigned long next_heartbeat; /* the next_heartbeat for the timer */
83 * Timer tick: the timer will make sure that the watchdog timer hardware
85 * 1) the watchdog timer has been started and /dev/watchdog is open
89 * 2) the watchdog timer has been stopped by userspace.
96 mod_timer(&timer, jiffies + WDT_HEARTBEAT); in wdt_timer_tick()
104 next_heartbeat = jiffies + wdd->timeout * HZ; in wdt_ping()
112 writel(wdd->timeout, wdt_mem + VIA_WDT_COUNT); in wdt_start()
115 mod_timer(&timer, jiffies + WDT_HEARTBEAT); in wdt_start()
131 wdd->timeout = new_timeout; in wdt_set_timeout()
136 .identity = "VIA watchdog",
162 int ret = -ENODEV; in wdt_probe()
165 dev_err(&pdev->dev, "cannot enable PCI device\n"); in wdt_probe()
166 return -ENODEV; in wdt_probe()
170 * Allocate a MMIO region which contains watchdog control register in wdt_probe()
171 * and counter, then configure the watchdog to use this region. in wdt_probe()
173 * If not, the watchdog must be configured in BIOS manually. in wdt_probe()
177 dev_err(&pdev->dev, "MMIO allocation failed\n"); in wdt_probe()
188 dev_info(&pdev->dev, "VIA Chipset watchdog MMIO: %x\n", mmio); in wdt_probe()
190 dev_err(&pdev->dev, "MMIO setting failed. Check BIOS.\n"); in wdt_probe()
195 dev_err(&pdev->dev, "MMIO region busy\n"); in wdt_probe()
201 dev_err(&pdev->dev, "cannot remap VIA wdt MMIO registers\n"); in wdt_probe()
209 wdt_dev.parent = &pdev->dev; in wdt_probe()
218 /* start triggering, in case of watchdog already enabled by BIOS */ in wdt_probe()
219 mod_timer(&timer, jiffies + WDT_HEARTBEAT); in wdt_probe()
236 del_timer_sync(&timer); in wdt_remove()
260 MODULE_DESCRIPTION("Driver for watchdog timer on VIA chipset");