Lines Matching +full:wdt +full:- +full:interval
1 // SPDX-License-Identifier: GPL-2.0-or-later
33 #define DRV_NAME "sunxi-wdt"
60 * wdt_timeout_map maps the watchdog timer interval value in seconds to
86 void __iomem *wdt_base = sunxi_wdt->wdt_base; in sunxi_wdt_restart()
87 const struct sunxi_wdt_reg *regs = sunxi_wdt->wdt_regs; in sunxi_wdt_restart()
91 val = readl(wdt_base + regs->wdt_cfg); in sunxi_wdt_restart()
92 val &= ~(regs->wdt_reset_mask); in sunxi_wdt_restart()
93 val |= regs->wdt_reset_val; in sunxi_wdt_restart()
94 val |= regs->wdt_key_val; in sunxi_wdt_restart()
95 writel(val, wdt_base + regs->wdt_cfg); in sunxi_wdt_restart()
98 val = readl(wdt_base + regs->wdt_mode); in sunxi_wdt_restart()
99 val &= ~(WDT_TIMEOUT_MASK << regs->wdt_timeout_shift); in sunxi_wdt_restart()
101 val |= regs->wdt_key_val; in sunxi_wdt_restart()
102 writel(val, wdt_base + regs->wdt_mode); in sunxi_wdt_restart()
105 * Restart the watchdog. The default (and lowest) interval in sunxi_wdt_restart()
108 writel(WDT_CTRL_RELOAD, wdt_base + regs->wdt_ctrl); in sunxi_wdt_restart()
112 val = readl(wdt_base + regs->wdt_mode); in sunxi_wdt_restart()
114 val |= regs->wdt_key_val; in sunxi_wdt_restart()
115 writel(val, wdt_base + regs->wdt_mode); in sunxi_wdt_restart()
123 void __iomem *wdt_base = sunxi_wdt->wdt_base; in sunxi_wdt_ping()
124 const struct sunxi_wdt_reg *regs = sunxi_wdt->wdt_regs; in sunxi_wdt_ping()
126 writel(WDT_CTRL_RELOAD, wdt_base + regs->wdt_ctrl); in sunxi_wdt_ping()
135 void __iomem *wdt_base = sunxi_wdt->wdt_base; in sunxi_wdt_set_timeout()
136 const struct sunxi_wdt_reg *regs = sunxi_wdt->wdt_regs; in sunxi_wdt_set_timeout()
142 sunxi_wdt->wdt_dev.timeout = timeout; in sunxi_wdt_set_timeout()
144 reg = readl(wdt_base + regs->wdt_mode); in sunxi_wdt_set_timeout()
145 reg &= ~(WDT_TIMEOUT_MASK << regs->wdt_timeout_shift); in sunxi_wdt_set_timeout()
146 reg |= wdt_timeout_map[timeout] << regs->wdt_timeout_shift; in sunxi_wdt_set_timeout()
147 reg |= regs->wdt_key_val; in sunxi_wdt_set_timeout()
148 writel(reg, wdt_base + regs->wdt_mode); in sunxi_wdt_set_timeout()
158 void __iomem *wdt_base = sunxi_wdt->wdt_base; in sunxi_wdt_stop()
159 const struct sunxi_wdt_reg *regs = sunxi_wdt->wdt_regs; in sunxi_wdt_stop()
161 writel(regs->wdt_key_val, wdt_base + regs->wdt_mode); in sunxi_wdt_stop()
170 void __iomem *wdt_base = sunxi_wdt->wdt_base; in sunxi_wdt_start()
171 const struct sunxi_wdt_reg *regs = sunxi_wdt->wdt_regs; in sunxi_wdt_start()
174 ret = sunxi_wdt_set_timeout(&sunxi_wdt->wdt_dev, in sunxi_wdt_start()
175 sunxi_wdt->wdt_dev.timeout); in sunxi_wdt_start()
180 reg = readl(wdt_base + regs->wdt_cfg); in sunxi_wdt_start()
181 reg &= ~(regs->wdt_reset_mask); in sunxi_wdt_start()
182 reg |= regs->wdt_reset_val; in sunxi_wdt_start()
183 reg |= regs->wdt_key_val; in sunxi_wdt_start()
184 writel(reg, wdt_base + regs->wdt_cfg); in sunxi_wdt_start()
187 reg = readl(wdt_base + regs->wdt_mode); in sunxi_wdt_start()
189 reg |= regs->wdt_key_val; in sunxi_wdt_start()
190 writel(reg, wdt_base + regs->wdt_mode); in sunxi_wdt_start()
240 { .compatible = "allwinner,sun4i-a10-wdt", .data = &sun4i_wdt_reg },
241 { .compatible = "allwinner,sun6i-a31-wdt", .data = &sun6i_wdt_reg },
242 { .compatible = "allwinner,sun20i-d1-wdt", .data = &sun20i_wdt_reg },
249 struct device *dev = &pdev->dev; in sunxi_wdt_probe()
255 return -ENOMEM; in sunxi_wdt_probe()
257 sunxi_wdt->wdt_regs = of_device_get_match_data(dev); in sunxi_wdt_probe()
258 if (!sunxi_wdt->wdt_regs) in sunxi_wdt_probe()
259 return -ENODEV; in sunxi_wdt_probe()
261 sunxi_wdt->wdt_base = devm_platform_ioremap_resource(pdev, 0); in sunxi_wdt_probe()
262 if (IS_ERR(sunxi_wdt->wdt_base)) in sunxi_wdt_probe()
263 return PTR_ERR(sunxi_wdt->wdt_base); in sunxi_wdt_probe()
265 sunxi_wdt->wdt_dev.info = &sunxi_wdt_info; in sunxi_wdt_probe()
266 sunxi_wdt->wdt_dev.ops = &sunxi_wdt_ops; in sunxi_wdt_probe()
267 sunxi_wdt->wdt_dev.timeout = WDT_MAX_TIMEOUT; in sunxi_wdt_probe()
268 sunxi_wdt->wdt_dev.max_timeout = WDT_MAX_TIMEOUT; in sunxi_wdt_probe()
269 sunxi_wdt->wdt_dev.min_timeout = WDT_MIN_TIMEOUT; in sunxi_wdt_probe()
270 sunxi_wdt->wdt_dev.parent = dev; in sunxi_wdt_probe()
272 watchdog_init_timeout(&sunxi_wdt->wdt_dev, timeout, dev); in sunxi_wdt_probe()
273 watchdog_set_nowayout(&sunxi_wdt->wdt_dev, nowayout); in sunxi_wdt_probe()
274 watchdog_set_restart_priority(&sunxi_wdt->wdt_dev, 128); in sunxi_wdt_probe()
276 watchdog_set_drvdata(&sunxi_wdt->wdt_dev, sunxi_wdt); in sunxi_wdt_probe()
278 sunxi_wdt_stop(&sunxi_wdt->wdt_dev); in sunxi_wdt_probe()
280 watchdog_stop_on_reboot(&sunxi_wdt->wdt_dev); in sunxi_wdt_probe()
281 err = devm_watchdog_register_device(dev, &sunxi_wdt->wdt_dev); in sunxi_wdt_probe()
286 sunxi_wdt->wdt_dev.timeout, nowayout); in sunxi_wdt_probe()