Lines Matching full:wdt

84 	struct sprd_wdt *wdt = (struct sprd_wdt *)dev_id;  in sprd_wdt_isr()  local
86 sprd_wdt_unlock(wdt->base); in sprd_wdt_isr()
87 writel_relaxed(SPRD_WDT_INT_CLEAR_BIT, wdt->base + SPRD_WDT_INT_CLR); in sprd_wdt_isr()
88 sprd_wdt_lock(wdt->base); in sprd_wdt_isr()
89 watchdog_notify_pretimeout(&wdt->wdd); in sprd_wdt_isr()
93 static u32 sprd_wdt_get_cnt_value(struct sprd_wdt *wdt) in sprd_wdt_get_cnt_value() argument
97 val = readl_relaxed(wdt->base + SPRD_WDT_CNT_HIGH) << in sprd_wdt_get_cnt_value()
99 val |= readl_relaxed(wdt->base + SPRD_WDT_CNT_LOW) & in sprd_wdt_get_cnt_value()
105 static int sprd_wdt_load_value(struct sprd_wdt *wdt, u32 timeout, in sprd_wdt_load_value() argument
119 val = readl_relaxed(wdt->base + SPRD_WDT_INT_RAW); in sprd_wdt_load_value()
129 sprd_wdt_unlock(wdt->base); in sprd_wdt_load_value()
131 SPRD_WDT_LOW_VALUE_MASK, wdt->base + SPRD_WDT_LOAD_HIGH); in sprd_wdt_load_value()
133 wdt->base + SPRD_WDT_LOAD_LOW); in sprd_wdt_load_value()
136 wdt->base + SPRD_WDT_IRQ_LOAD_HIGH); in sprd_wdt_load_value()
138 wdt->base + SPRD_WDT_IRQ_LOAD_LOW); in sprd_wdt_load_value()
139 sprd_wdt_lock(wdt->base); in sprd_wdt_load_value()
144 static int sprd_wdt_enable(struct sprd_wdt *wdt) in sprd_wdt_enable() argument
149 ret = clk_prepare_enable(wdt->enable); in sprd_wdt_enable()
152 ret = clk_prepare_enable(wdt->rtc_enable); in sprd_wdt_enable()
154 clk_disable_unprepare(wdt->enable); in sprd_wdt_enable()
158 sprd_wdt_unlock(wdt->base); in sprd_wdt_enable()
159 val = readl_relaxed(wdt->base + SPRD_WDT_CTRL); in sprd_wdt_enable()
161 writel_relaxed(val, wdt->base + SPRD_WDT_CTRL); in sprd_wdt_enable()
162 sprd_wdt_lock(wdt->base); in sprd_wdt_enable()
168 struct sprd_wdt *wdt = _data; in sprd_wdt_disable() local
170 sprd_wdt_unlock(wdt->base); in sprd_wdt_disable()
171 writel_relaxed(0x0, wdt->base + SPRD_WDT_CTRL); in sprd_wdt_disable()
172 sprd_wdt_lock(wdt->base); in sprd_wdt_disable()
174 clk_disable_unprepare(wdt->rtc_enable); in sprd_wdt_disable()
175 clk_disable_unprepare(wdt->enable); in sprd_wdt_disable()
180 struct sprd_wdt *wdt = to_sprd_wdt(wdd); in sprd_wdt_start() local
184 ret = sprd_wdt_load_value(wdt, wdd->timeout, wdd->pretimeout); in sprd_wdt_start()
188 sprd_wdt_unlock(wdt->base); in sprd_wdt_start()
189 val = readl_relaxed(wdt->base + SPRD_WDT_CTRL); in sprd_wdt_start()
191 writel_relaxed(val, wdt->base + SPRD_WDT_CTRL); in sprd_wdt_start()
192 sprd_wdt_lock(wdt->base); in sprd_wdt_start()
200 struct sprd_wdt *wdt = to_sprd_wdt(wdd); in sprd_wdt_stop() local
203 sprd_wdt_unlock(wdt->base); in sprd_wdt_stop()
204 val = readl_relaxed(wdt->base + SPRD_WDT_CTRL); in sprd_wdt_stop()
207 writel_relaxed(val, wdt->base + SPRD_WDT_CTRL); in sprd_wdt_stop()
208 sprd_wdt_lock(wdt->base); in sprd_wdt_stop()
215 struct sprd_wdt *wdt = to_sprd_wdt(wdd); in sprd_wdt_set_timeout() local
222 return sprd_wdt_load_value(wdt, timeout, wdd->pretimeout); in sprd_wdt_set_timeout()
228 struct sprd_wdt *wdt = to_sprd_wdt(wdd); in sprd_wdt_set_pretimeout() local
235 return sprd_wdt_load_value(wdt, wdd->timeout, new_pretimeout); in sprd_wdt_set_pretimeout()
240 struct sprd_wdt *wdt = to_sprd_wdt(wdd); in sprd_wdt_get_timeleft() local
243 val = sprd_wdt_get_cnt_value(wdt); in sprd_wdt_get_timeleft()
267 struct sprd_wdt *wdt; in sprd_wdt_probe() local
270 wdt = devm_kzalloc(dev, sizeof(*wdt), GFP_KERNEL); in sprd_wdt_probe()
271 if (!wdt) in sprd_wdt_probe()
274 wdt->base = devm_platform_ioremap_resource(pdev, 0); in sprd_wdt_probe()
275 if (IS_ERR(wdt->base)) in sprd_wdt_probe()
276 return PTR_ERR(wdt->base); in sprd_wdt_probe()
278 wdt->enable = devm_clk_get(dev, "enable"); in sprd_wdt_probe()
279 if (IS_ERR(wdt->enable)) { in sprd_wdt_probe()
281 return PTR_ERR(wdt->enable); in sprd_wdt_probe()
284 wdt->rtc_enable = devm_clk_get(dev, "rtc_enable"); in sprd_wdt_probe()
285 if (IS_ERR(wdt->rtc_enable)) { in sprd_wdt_probe()
287 return PTR_ERR(wdt->rtc_enable); in sprd_wdt_probe()
290 wdt->irq = platform_get_irq(pdev, 0); in sprd_wdt_probe()
291 if (wdt->irq < 0) in sprd_wdt_probe()
292 return wdt->irq; in sprd_wdt_probe()
294 ret = devm_request_irq(dev, wdt->irq, sprd_wdt_isr, IRQF_NO_SUSPEND, in sprd_wdt_probe()
295 "sprd-wdt", (void *)wdt); in sprd_wdt_probe()
301 wdt->wdd.info = &sprd_wdt_info; in sprd_wdt_probe()
302 wdt->wdd.ops = &sprd_wdt_ops; in sprd_wdt_probe()
303 wdt->wdd.parent = dev; in sprd_wdt_probe()
304 wdt->wdd.min_timeout = SPRD_WDT_MIN_TIMEOUT; in sprd_wdt_probe()
305 wdt->wdd.max_timeout = SPRD_WDT_MAX_TIMEOUT; in sprd_wdt_probe()
306 wdt->wdd.timeout = SPRD_WDT_MAX_TIMEOUT; in sprd_wdt_probe()
308 ret = sprd_wdt_enable(wdt); in sprd_wdt_probe()
310 dev_err(dev, "failed to enable wdt\n"); in sprd_wdt_probe()
313 ret = devm_add_action_or_reset(dev, sprd_wdt_disable, wdt); in sprd_wdt_probe()
315 dev_err(dev, "Failed to add wdt disable action\n"); in sprd_wdt_probe()
319 watchdog_set_nowayout(&wdt->wdd, WATCHDOG_NOWAYOUT); in sprd_wdt_probe()
320 watchdog_init_timeout(&wdt->wdd, 0, dev); in sprd_wdt_probe()
322 ret = devm_watchdog_register_device(dev, &wdt->wdd); in sprd_wdt_probe()
324 sprd_wdt_disable(wdt); in sprd_wdt_probe()
327 platform_set_drvdata(pdev, wdt); in sprd_wdt_probe()
334 struct sprd_wdt *wdt = dev_get_drvdata(dev); in sprd_wdt_pm_suspend() local
336 if (watchdog_active(&wdt->wdd)) in sprd_wdt_pm_suspend()
337 sprd_wdt_stop(&wdt->wdd); in sprd_wdt_pm_suspend()
338 sprd_wdt_disable(wdt); in sprd_wdt_pm_suspend()
345 struct sprd_wdt *wdt = dev_get_drvdata(dev); in sprd_wdt_pm_resume() local
348 ret = sprd_wdt_enable(wdt); in sprd_wdt_pm_resume()
352 if (watchdog_active(&wdt->wdd)) in sprd_wdt_pm_resume()
353 ret = sprd_wdt_start(&wdt->wdd); in sprd_wdt_pm_resume()
364 { .compatible = "sprd,sp9860-wdt", },
372 .name = "sprd-wdt",