Lines Matching refs:wdt
85 struct sp805_wdt *wdt = watchdog_get_drvdata(wdd); in wdt_is_running() local
86 u32 wdtcontrol = readl_relaxed(wdt->base + WDTCONTROL); in wdt_is_running()
94 struct sp805_wdt *wdt = watchdog_get_drvdata(wdd); in wdt_setload() local
97 rate = wdt->rate; in wdt_setload()
110 spin_lock(&wdt->lock); in wdt_setload()
111 wdt->load_val = load; in wdt_setload()
114 spin_unlock(&wdt->lock); in wdt_setload()
122 struct sp805_wdt *wdt = watchdog_get_drvdata(wdd); in wdt_timeleft() local
125 spin_lock(&wdt->lock); in wdt_timeleft()
126 load = readl_relaxed(wdt->base + WDTVALUE); in wdt_timeleft()
129 if (!(readl_relaxed(wdt->base + WDTRIS) & INT_MASK)) in wdt_timeleft()
130 load += wdt->load_val + 1; in wdt_timeleft()
131 spin_unlock(&wdt->lock); in wdt_timeleft()
133 return div_u64(load, wdt->rate); in wdt_timeleft()
139 struct sp805_wdt *wdt = watchdog_get_drvdata(wdd); in wdt_restart() local
141 writel_relaxed(UNLOCK, wdt->base + WDTLOCK); in wdt_restart()
142 writel_relaxed(0, wdt->base + WDTCONTROL); in wdt_restart()
143 writel_relaxed(0, wdt->base + WDTLOAD); in wdt_restart()
144 writel_relaxed(INT_ENABLE | RESET_ENABLE, wdt->base + WDTCONTROL); in wdt_restart()
147 readl_relaxed(wdt->base + WDTLOCK); in wdt_restart()
154 struct sp805_wdt *wdt = watchdog_get_drvdata(wdd); in wdt_config() local
159 ret = clk_prepare_enable(wdt->clk); in wdt_config()
161 dev_err(&wdt->adev->dev, "clock enable fail"); in wdt_config()
166 spin_lock(&wdt->lock); in wdt_config()
168 writel_relaxed(UNLOCK, wdt->base + WDTLOCK); in wdt_config()
169 writel_relaxed(wdt->load_val, wdt->base + WDTLOAD); in wdt_config()
170 writel_relaxed(INT_MASK, wdt->base + WDTINTCLR); in wdt_config()
173 writel_relaxed(INT_ENABLE | RESET_ENABLE, wdt->base + in wdt_config()
176 writel_relaxed(LOCK, wdt->base + WDTLOCK); in wdt_config()
179 readl_relaxed(wdt->base + WDTLOCK); in wdt_config()
180 spin_unlock(&wdt->lock); in wdt_config()
199 struct sp805_wdt *wdt = watchdog_get_drvdata(wdd); in wdt_disable() local
201 spin_lock(&wdt->lock); in wdt_disable()
203 writel_relaxed(UNLOCK, wdt->base + WDTLOCK); in wdt_disable()
204 writel_relaxed(0, wdt->base + WDTCONTROL); in wdt_disable()
205 writel_relaxed(LOCK, wdt->base + WDTLOCK); in wdt_disable()
208 readl_relaxed(wdt->base + WDTLOCK); in wdt_disable()
209 spin_unlock(&wdt->lock); in wdt_disable()
211 clk_disable_unprepare(wdt->clk); in wdt_disable()
234 struct sp805_wdt *wdt; in sp805_wdt_probe() local
238 wdt = devm_kzalloc(&adev->dev, sizeof(*wdt), GFP_KERNEL); in sp805_wdt_probe()
239 if (!wdt) { in sp805_wdt_probe()
244 wdt->base = devm_ioremap_resource(&adev->dev, &adev->res); in sp805_wdt_probe()
245 if (IS_ERR(wdt->base)) in sp805_wdt_probe()
246 return PTR_ERR(wdt->base); in sp805_wdt_probe()
255 wdt->clk = devm_clk_get_optional(&adev->dev, NULL); in sp805_wdt_probe()
256 if (IS_ERR(wdt->clk)) in sp805_wdt_probe()
257 return dev_err_probe(&adev->dev, PTR_ERR(wdt->clk), "Clock not found\n"); in sp805_wdt_probe()
259 wdt->rate = clk_get_rate(wdt->clk); in sp805_wdt_probe()
260 if (!wdt->rate) in sp805_wdt_probe()
261 wdt->rate = rate; in sp805_wdt_probe()
262 if (!wdt->rate) { in sp805_wdt_probe()
267 wdt->adev = adev; in sp805_wdt_probe()
268 wdt->wdd.info = &wdt_info; in sp805_wdt_probe()
269 wdt->wdd.ops = &wdt_ops; in sp805_wdt_probe()
270 wdt->wdd.parent = &adev->dev; in sp805_wdt_probe()
272 spin_lock_init(&wdt->lock); in sp805_wdt_probe()
273 watchdog_set_nowayout(&wdt->wdd, nowayout); in sp805_wdt_probe()
274 watchdog_set_drvdata(&wdt->wdd, wdt); in sp805_wdt_probe()
275 watchdog_set_restart_priority(&wdt->wdd, 128); in sp805_wdt_probe()
276 watchdog_stop_on_unregister(&wdt->wdd); in sp805_wdt_probe()
282 wdt->wdd.timeout = DEFAULT_TIMEOUT; in sp805_wdt_probe()
283 watchdog_init_timeout(&wdt->wdd, 0, &adev->dev); in sp805_wdt_probe()
284 wdt_setload(&wdt->wdd, wdt->wdd.timeout); in sp805_wdt_probe()
290 if (wdt_is_running(&wdt->wdd)) { in sp805_wdt_probe()
291 wdt_enable(&wdt->wdd); in sp805_wdt_probe()
292 set_bit(WDOG_HW_RUNNING, &wdt->wdd.status); in sp805_wdt_probe()
295 watchdog_stop_on_reboot(&wdt->wdd); in sp805_wdt_probe()
296 ret = watchdog_register_device(&wdt->wdd); in sp805_wdt_probe()
299 amba_set_drvdata(adev, wdt); in sp805_wdt_probe()
311 struct sp805_wdt *wdt = amba_get_drvdata(adev); in sp805_wdt_remove() local
313 watchdog_unregister_device(&wdt->wdd); in sp805_wdt_remove()
314 watchdog_set_drvdata(&wdt->wdd, NULL); in sp805_wdt_remove()
319 struct sp805_wdt *wdt = dev_get_drvdata(dev); in sp805_wdt_suspend() local
321 if (watchdog_active(&wdt->wdd)) in sp805_wdt_suspend()
322 return wdt_disable(&wdt->wdd); in sp805_wdt_suspend()
329 struct sp805_wdt *wdt = dev_get_drvdata(dev); in sp805_wdt_resume() local
331 if (watchdog_active(&wdt->wdd)) in sp805_wdt_resume()
332 return wdt_enable(&wdt->wdd); in sp805_wdt_resume()