Lines Matching +full:wdt +full:- +full:enable +full:- +full:once
1 // SPDX-License-Identifier: GPL-2.0-only
5 * Copyright (C) 2017 Hauke Mehrtens <hauke@hauke-m.de>
6 * Based on EP93xx wdt driver
33 * The password sequence protects the WDT control register from unintended
34 * write actions, which might cause malfunction of the WDT.
37 * IO access to the WDT core
43 #define LTQ_WDT_CR_GEN BIT(31) /* enable bit */
44 /* Pre-warning limit set to 1/16 of max WDT period */
49 #define LTQ_WDT_CR_MAX_TIMEOUT ((1 << 16) - 1) /* The reload field is 16 bit */
51 #define LTQ_WDT_SR_EN BIT(31) /* Enable */
63 struct watchdog_device wdt; member
70 return __raw_readl(priv->membase + offset); in ltq_wdt_r32()
75 __raw_writel(val, priv->membase + offset); in ltq_wdt_w32()
88 static struct ltq_wdt_priv *ltq_wdt_get_priv(struct watchdog_device *wdt) in ltq_wdt_get_priv() argument
90 return container_of(wdt, struct ltq_wdt_priv, wdt); in ltq_wdt_get_priv()
99 static int ltq_wdt_start(struct watchdog_device *wdt) in ltq_wdt_start() argument
101 struct ltq_wdt_priv *priv = ltq_wdt_get_priv(wdt); in ltq_wdt_start()
104 timeout = wdt->timeout * priv->clk_rate; in ltq_wdt_start()
116 static int ltq_wdt_stop(struct watchdog_device *wdt) in ltq_wdt_stop() argument
118 struct ltq_wdt_priv *priv = ltq_wdt_get_priv(wdt); in ltq_wdt_stop()
127 static int ltq_wdt_ping(struct watchdog_device *wdt) in ltq_wdt_ping() argument
129 struct ltq_wdt_priv *priv = ltq_wdt_get_priv(wdt); in ltq_wdt_ping()
132 timeout = wdt->timeout * priv->clk_rate; in ltq_wdt_ping()
142 static unsigned int ltq_wdt_get_timeleft(struct watchdog_device *wdt) in ltq_wdt_get_timeleft() argument
144 struct ltq_wdt_priv *priv = ltq_wdt_get_priv(wdt); in ltq_wdt_get_timeleft()
148 return do_div(timeout, priv->clk_rate); in ltq_wdt_get_timeleft()
165 rcu_regmap = syscon_regmap_lookup_by_phandle(dev->of_node, "regmap"); in ltq_wdt_xrx_bootstatus_get()
185 rcu_regmap = syscon_regmap_lookup_by_phandle(dev->of_node, in ltq_wdt_falcon_bootstatus_get()
202 struct device *dev = &pdev->dev; in ltq_wdt_probe()
204 struct watchdog_device *wdt; in ltq_wdt_probe() local
212 return -ENOMEM; in ltq_wdt_probe()
214 priv->membase = devm_platform_ioremap_resource(pdev, 0); in ltq_wdt_probe()
215 if (IS_ERR(priv->membase)) in ltq_wdt_probe()
216 return PTR_ERR(priv->membase); in ltq_wdt_probe()
218 /* we do not need to enable the clock as it is always running */ in ltq_wdt_probe()
220 priv->clk_rate = clk_get_rate(clk) / LTQ_WDT_DIVIDER; in ltq_wdt_probe()
221 if (!priv->clk_rate) { in ltq_wdt_probe()
224 return -EINVAL; in ltq_wdt_probe()
227 wdt = &priv->wdt; in ltq_wdt_probe()
228 wdt->info = <q_wdt_info; in ltq_wdt_probe()
229 wdt->ops = <q_wdt_ops; in ltq_wdt_probe()
230 wdt->min_timeout = 1; in ltq_wdt_probe()
231 wdt->max_timeout = LTQ_WDT_CR_MAX_TIMEOUT / priv->clk_rate; in ltq_wdt_probe()
232 wdt->timeout = wdt->max_timeout; in ltq_wdt_probe()
233 wdt->parent = dev; in ltq_wdt_probe()
236 if (ltq_wdt_hw && ltq_wdt_hw->bootstatus_get) { in ltq_wdt_probe()
237 ret = ltq_wdt_hw->bootstatus_get(dev); in ltq_wdt_probe()
239 wdt->bootstatus = ret; in ltq_wdt_probe()
242 watchdog_set_nowayout(wdt, nowayout); in ltq_wdt_probe()
243 watchdog_init_timeout(wdt, 0, dev); in ltq_wdt_probe()
252 ltq_wdt_start(wdt); in ltq_wdt_probe()
253 set_bit(WDOG_HW_RUNNING, &wdt->status); in ltq_wdt_probe()
256 return devm_watchdog_register_device(dev, wdt); in ltq_wdt_probe()
268 { .compatible = "lantiq,wdt", .data = NULL },
269 { .compatible = "lantiq,xrx100-wdt", .data = <q_wdt_xrx100 },
270 { .compatible = "lantiq,falcon-wdt", .data = <q_wdt_falcon },
278 .name = "wdt",
286 MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started");