Lines Matching +full:timeout +full:- +full:secs
1 // SPDX-License-Identifier: GPL-2.0+
26 #define DA9062_TWDSCALE_MAX (ARRAY_SIZE(wdt_timeout) - 1)
29 #define DA9062_WDG_DEFAULT_TIMEOUT wdt_timeout[DA9062_TWDSCALE_MAX-1]
42 regmap_read(wdt->hw->regmap, DA9062AA_CONTROL_D, &val); in da9062_wdt_read_timeout()
47 static unsigned int da9062_wdt_timeout_to_sel(unsigned int secs) in da9062_wdt_timeout_to_sel() argument
52 if (wdt_timeout[i] >= secs) in da9062_wdt_timeout_to_sel()
61 return regmap_update_bits(wdt->hw->regmap, DA9062AA_CONTROL_F, in da9062_reset_watchdog_timer()
69 struct da9062 *chip = wdt->hw; in da9062_wdt_update_timeout_register()
71 regmap_update_bits(chip->regmap, in da9062_wdt_update_timeout_register()
78 return regmap_update_bits(chip->regmap, in da9062_wdt_update_timeout_register()
90 selector = da9062_wdt_timeout_to_sel(wdt->wdtdev.timeout); in da9062_wdt_start()
93 dev_err(wdt->hw->dev, "Watchdog failed to start (err = %d)\n", in da9062_wdt_start()
104 ret = regmap_update_bits(wdt->hw->regmap, in da9062_wdt_stop()
109 dev_err(wdt->hw->dev, "Watchdog failed to stop (err = %d)\n", in da9062_wdt_stop()
129 dev_err(wdt->hw->dev, "Failed to ping the watchdog (err = %d)\n", in da9062_wdt_ping()
136 unsigned int timeout) in da9062_wdt_set_timeout() argument
142 selector = da9062_wdt_timeout_to_sel(timeout); in da9062_wdt_set_timeout()
145 dev_err(wdt->hw->dev, "Failed to set watchdog timeout (err = %d)\n", in da9062_wdt_set_timeout()
148 wdd->timeout = wdt_timeout[selector]; in da9062_wdt_set_timeout()
157 struct i2c_client *client = to_i2c_client(wdt->hw->dev); in da9062_wdt_restart()
168 ret = __i2c_smbus_xfer(client->adapter, client->addr, client->flags, in da9062_wdt_restart()
173 dev_alert(wdt->hw->dev, "Failed to shutdown (err = %d)\n", in da9062_wdt_restart()
197 { .compatible = "dlg,da9062-watchdog", },
205 struct device *dev = &pdev->dev; in da9062_wdt_probe()
206 unsigned int timeout; in da9062_wdt_probe() local
210 chip = dev_get_drvdata(dev->parent); in da9062_wdt_probe()
212 return -EINVAL; in da9062_wdt_probe()
216 return -ENOMEM; in da9062_wdt_probe()
218 wdt->use_sw_pm = device_property_present(dev, "dlg,use-sw-pm"); in da9062_wdt_probe()
220 wdt->hw = chip; in da9062_wdt_probe()
222 wdt->wdtdev.info = &da9062_watchdog_info; in da9062_wdt_probe()
223 wdt->wdtdev.ops = &da9062_watchdog_ops; in da9062_wdt_probe()
224 wdt->wdtdev.min_timeout = DA9062_WDT_MIN_TIMEOUT; in da9062_wdt_probe()
225 wdt->wdtdev.max_timeout = DA9062_WDT_MAX_TIMEOUT; in da9062_wdt_probe()
226 wdt->wdtdev.min_hw_heartbeat_ms = DA9062_RESET_PROTECTION_MS; in da9062_wdt_probe()
227 wdt->wdtdev.timeout = DA9062_WDG_DEFAULT_TIMEOUT; in da9062_wdt_probe()
228 wdt->wdtdev.status = WATCHDOG_NOWAYOUT_INIT_STATUS; in da9062_wdt_probe()
229 wdt->wdtdev.parent = dev; in da9062_wdt_probe()
231 watchdog_set_restart_priority(&wdt->wdtdev, 128); in da9062_wdt_probe()
233 watchdog_set_drvdata(&wdt->wdtdev, wdt); in da9062_wdt_probe()
234 dev_set_drvdata(dev, &wdt->wdtdev); in da9062_wdt_probe()
236 timeout = da9062_wdt_read_timeout(wdt); in da9062_wdt_probe()
237 if (timeout) in da9062_wdt_probe()
238 wdt->wdtdev.timeout = timeout; in da9062_wdt_probe()
240 /* Set timeout from DT value if available */ in da9062_wdt_probe()
241 watchdog_init_timeout(&wdt->wdtdev, 0, dev); in da9062_wdt_probe()
243 if (timeout) { in da9062_wdt_probe()
244 da9062_wdt_set_timeout(&wdt->wdtdev, wdt->wdtdev.timeout); in da9062_wdt_probe()
245 set_bit(WDOG_HW_RUNNING, &wdt->wdtdev.status); in da9062_wdt_probe()
248 return devm_watchdog_register_device(dev, &wdt->wdtdev); in da9062_wdt_probe()
256 if (!wdt->use_sw_pm) in da9062_wdt_suspend()
270 if (!wdt->use_sw_pm) in da9062_wdt_resume()
285 .name = "da9062-watchdog",
295 MODULE_ALIAS("platform:da9062-watchdog");