• Home
  • Raw
  • Download

Lines Matching +full:watchdog +full:- +full:timeout +full:- +full:ms

1 // SPDX-License-Identifier: GPL-2.0+
3 * Watchdog driver for DA9063 PMICs.
13 #include <linux/watchdog.h>
23 * Watchdog selector to timeout in seconds.
25 * others: timeout = 2048 ms * 2^(TWDSCALE-1).
30 #define DA9063_TWDSCALE_MAX (ARRAY_SIZE(wdt_timeout) - 1)
49 * Read the currently active timeout.
50 * Zero means the watchdog is disabled.
56 regmap_read(da9063->regmap, DA9063_REG_CONTROL_D, &val); in da9063_wdt_read_timeout()
63 return regmap_update_bits(da9063->regmap, DA9063_REG_CONTROL_D, in da9063_wdt_disable_timer()
69 da9063_wdt_update_timeout(struct da9063 *da9063, unsigned int timeout) in da9063_wdt_update_timeout() argument
75 * The watchdog triggers a reboot if a timeout value is already in da9063_wdt_update_timeout()
76 * programmed because the timeout value combines two functions in da9063_wdt_update_timeout()
77 * in one: indicating the counter limit and starting the watchdog. in da9063_wdt_update_timeout()
78 * The watchdog must be disabled to be able to change the timeout in da9063_wdt_update_timeout()
79 * value if the watchdog is already running. Then we can set the in da9063_wdt_update_timeout()
80 * new timeout value which enables the watchdog again. in da9063_wdt_update_timeout()
87 regval = da9063_wdt_timeout_to_sel(timeout); in da9063_wdt_update_timeout()
89 return regmap_update_bits(da9063->regmap, DA9063_REG_CONTROL_D, in da9063_wdt_update_timeout()
98 ret = da9063_wdt_update_timeout(da9063, wdd->timeout); in da9063_wdt_start()
100 dev_err(da9063->dev, "Watchdog failed to start (err = %d)\n", in da9063_wdt_start()
113 dev_alert(da9063->dev, "Watchdog failed to stop (err = %d)\n", in da9063_wdt_stop()
124 ret = regmap_write(da9063->regmap, DA9063_REG_CONTROL_F, in da9063_wdt_ping()
127 dev_alert(da9063->dev, "Failed to ping the watchdog (err = %d)\n", in da9063_wdt_ping()
134 unsigned int timeout) in da9063_wdt_set_timeout() argument
141 * 1. The watchdog is off and someone wants to set the timeout for the in da9063_wdt_set_timeout()
143 * 2. The watchdog is already running and a new timeout value should be in da9063_wdt_set_timeout()
146 * The watchdog can't store a timeout value not equal zero without in da9063_wdt_set_timeout()
147 * enabling the watchdog, so the timeout must be buffered by the driver. in da9063_wdt_set_timeout()
150 ret = da9063_wdt_update_timeout(da9063, timeout); in da9063_wdt_set_timeout()
153 dev_err(da9063->dev, "Failed to set watchdog timeout (err = %d)\n", in da9063_wdt_set_timeout()
156 wdd->timeout = wdt_timeout[da9063_wdt_timeout_to_sel(timeout)]; in da9063_wdt_set_timeout()
167 ret = regmap_write(da9063->regmap, DA9063_REG_CONTROL_F, in da9063_wdt_restart()
170 dev_alert(da9063->dev, "Failed to shutdown (err = %d)\n", in da9063_wdt_restart()
178 .identity = "DA9063 Watchdog",
192 struct device *dev = &pdev->dev; in da9063_wdt_probe()
195 unsigned int timeout; in da9063_wdt_probe() local
197 if (!dev->parent) in da9063_wdt_probe()
198 return -EINVAL; in da9063_wdt_probe()
200 da9063 = dev_get_drvdata(dev->parent); in da9063_wdt_probe()
202 return -EINVAL; in da9063_wdt_probe()
206 return -ENOMEM; in da9063_wdt_probe()
208 wdd->info = &da9063_watchdog_info; in da9063_wdt_probe()
209 wdd->ops = &da9063_watchdog_ops; in da9063_wdt_probe()
210 wdd->min_timeout = DA9063_WDT_MIN_TIMEOUT; in da9063_wdt_probe()
211 wdd->max_timeout = DA9063_WDT_MAX_TIMEOUT; in da9063_wdt_probe()
212 wdd->min_hw_heartbeat_ms = DA9063_RESET_PROTECTION_MS; in da9063_wdt_probe()
213 wdd->parent = dev; in da9063_wdt_probe()
214 wdd->status = WATCHDOG_NOWAYOUT_INIT_STATUS; in da9063_wdt_probe()
219 wdd->timeout = DA9063_WDG_TIMEOUT; in da9063_wdt_probe()
221 /* Use pre-configured timeout if watchdog is already running. */ in da9063_wdt_probe()
222 timeout = da9063_wdt_read_timeout(da9063); in da9063_wdt_probe()
223 if (timeout) in da9063_wdt_probe()
224 wdd->timeout = timeout; in da9063_wdt_probe()
226 /* Set timeout, maybe override it with DT value, scale it */ in da9063_wdt_probe()
228 da9063_wdt_set_timeout(wdd, wdd->timeout); in da9063_wdt_probe()
230 /* Update timeout if the watchdog is already running. */ in da9063_wdt_probe()
231 if (timeout) { in da9063_wdt_probe()
232 da9063_wdt_update_timeout(da9063, wdd->timeout); in da9063_wdt_probe()
233 set_bit(WDOG_HW_RUNNING, &wdd->status); in da9063_wdt_probe()
248 MODULE_DESCRIPTION("Watchdog driver for Dialog DA9063");