Lines Matching +full:wdt +full:- +full:interval
1 // SPDX-License-Identifier: GPL-2.0-or-later
7 * Copyright (C) 2001 - 2012 Paul Mundt <lethal@linux-sh.org>
9 * 14-Dec-2001 Matt Domsch <Matt_Domsch@dell.com>
12 * 19-Apr-2002 Rob Radez <rob@osinvestor.com>
35 #define DRV_NAME "sh-wdt"
39 * values, consult the asm-sh/watchdog.h. Overload this at module load
43 * something quite higher than 100 (or we need a proper high-res timer
46 * the SH-4 and SH-5, this isn't necessarily that big of a problem, though
47 * for the SH-2 and SH-3, this isn't recommended unless the WDT is absolutely
57 * HZ == 1000), and another for monitoring userspace writes to the WDT device.
59 * As such, we currently use a configurable heartbeat interval which defaults
62 * misses its deadline, the kernel timer will allow the WDT to overflow.
65 #define next_ping_period(cks) (jiffies + msecs_to_jiffies(cks - 4))
83 struct sh_wdt *wdt = watchdog_get_drvdata(wdt_dev); in sh_wdt_start() local
87 pm_runtime_get_sync(wdt->dev); in sh_wdt_start()
88 clk_enable(wdt->clk); in sh_wdt_start()
90 spin_lock_irqsave(&wdt->lock, flags); in sh_wdt_start()
93 mod_timer(&wdt->timer, next_ping_period(clock_division_ratio)); in sh_wdt_start()
103 * process.. starting with SH-3, RSTS was moved to WTCSR, and the in sh_wdt_start()
106 * On the SH-2 however, in addition with bits being in different in sh_wdt_start()
119 spin_unlock_irqrestore(&wdt->lock, flags); in sh_wdt_start()
126 struct sh_wdt *wdt = watchdog_get_drvdata(wdt_dev); in sh_wdt_stop() local
130 spin_lock_irqsave(&wdt->lock, flags); in sh_wdt_stop()
132 del_timer(&wdt->timer); in sh_wdt_stop()
138 spin_unlock_irqrestore(&wdt->lock, flags); in sh_wdt_stop()
140 clk_disable(wdt->clk); in sh_wdt_stop()
141 pm_runtime_put_sync(wdt->dev); in sh_wdt_stop()
148 struct sh_wdt *wdt = watchdog_get_drvdata(wdt_dev); in sh_wdt_keepalive() local
151 spin_lock_irqsave(&wdt->lock, flags); in sh_wdt_keepalive()
153 spin_unlock_irqrestore(&wdt->lock, flags); in sh_wdt_keepalive()
160 struct sh_wdt *wdt = watchdog_get_drvdata(wdt_dev); in sh_wdt_set_heartbeat() local
164 return -EINVAL; in sh_wdt_set_heartbeat()
166 spin_lock_irqsave(&wdt->lock, flags); in sh_wdt_set_heartbeat()
168 wdt_dev->timeout = t; in sh_wdt_set_heartbeat()
169 spin_unlock_irqrestore(&wdt->lock, flags); in sh_wdt_set_heartbeat()
176 struct sh_wdt *wdt = from_timer(wdt, t, timer); in sh_wdt_ping() local
179 spin_lock_irqsave(&wdt->lock, flags); in sh_wdt_ping()
189 mod_timer(&wdt->timer, next_ping_period(clock_division_ratio)); in sh_wdt_ping()
191 dev_warn(wdt->dev, "Heartbeat lost! Will not ping " in sh_wdt_ping()
193 spin_unlock_irqrestore(&wdt->lock, flags); in sh_wdt_ping()
200 .identity = "SH WDT",
218 struct sh_wdt *wdt; in sh_wdt_probe() local
223 * any attempts to register per-CPU watchdogs. in sh_wdt_probe()
225 if (pdev->id != -1) in sh_wdt_probe()
226 return -EINVAL; in sh_wdt_probe()
228 wdt = devm_kzalloc(&pdev->dev, sizeof(struct sh_wdt), GFP_KERNEL); in sh_wdt_probe()
229 if (unlikely(!wdt)) in sh_wdt_probe()
230 return -ENOMEM; in sh_wdt_probe()
232 wdt->dev = &pdev->dev; in sh_wdt_probe()
234 wdt->clk = devm_clk_get(&pdev->dev, NULL); in sh_wdt_probe()
235 if (IS_ERR(wdt->clk)) { in sh_wdt_probe()
240 wdt->clk = NULL; in sh_wdt_probe()
243 wdt->base = devm_platform_ioremap_resource(pdev, 0); in sh_wdt_probe()
244 if (IS_ERR(wdt->base)) in sh_wdt_probe()
245 return PTR_ERR(wdt->base); in sh_wdt_probe()
248 watchdog_set_drvdata(&sh_wdt_dev, wdt); in sh_wdt_probe()
249 sh_wdt_dev.parent = &pdev->dev; in sh_wdt_probe()
251 spin_lock_init(&wdt->lock); in sh_wdt_probe()
258 dev_warn(&pdev->dev, in sh_wdt_probe()
263 dev_info(&pdev->dev, "configured with heartbeat=%d sec (nowayout=%d)\n", in sh_wdt_probe()
268 dev_err(&pdev->dev, "Can't register watchdog (err=%d)\n", rc); in sh_wdt_probe()
272 timer_setup(&wdt->timer, sh_wdt_ping, 0); in sh_wdt_probe()
273 wdt->timer.expires = next_ping_period(clock_division_ratio); in sh_wdt_probe()
275 dev_info(&pdev->dev, "initialized.\n"); in sh_wdt_probe()
277 pm_runtime_enable(&pdev->dev); in sh_wdt_probe()
286 pm_runtime_disable(&pdev->dev); in sh_wdt_remove()
324 MODULE_AUTHOR("Paul Mundt <lethal@linux-sh.org>");