Lines Matching full:wdt
57 static void mlxreg_wdt_check_card_reset(struct mlxreg_wdt *wdt) in mlxreg_wdt_check_card_reset() argument
63 if (wdt->reset_idx == -EINVAL) in mlxreg_wdt_check_card_reset()
66 if (!(wdt->wdd.info->options & WDIOF_CARDRESET)) in mlxreg_wdt_check_card_reset()
69 reg_data = &wdt->pdata->data[wdt->reset_idx]; in mlxreg_wdt_check_card_reset()
70 rc = regmap_read(wdt->regmap, reg_data->reg, ®val); in mlxreg_wdt_check_card_reset()
73 wdt->wdd.bootstatus = WDIOF_CARDRESET; in mlxreg_wdt_check_card_reset()
74 dev_info(wdt->wdd.parent, in mlxreg_wdt_check_card_reset()
82 struct mlxreg_wdt *wdt = watchdog_get_drvdata(wdd); in mlxreg_wdt_start() local
83 struct mlxreg_core_data *reg_data = &wdt->pdata->data[wdt->action_idx]; in mlxreg_wdt_start()
85 return regmap_update_bits(wdt->regmap, reg_data->reg, ~reg_data->mask, in mlxreg_wdt_start()
91 struct mlxreg_wdt *wdt = watchdog_get_drvdata(wdd); in mlxreg_wdt_stop() local
92 struct mlxreg_core_data *reg_data = &wdt->pdata->data[wdt->action_idx]; in mlxreg_wdt_stop()
94 return regmap_update_bits(wdt->regmap, reg_data->reg, ~reg_data->mask, in mlxreg_wdt_stop()
100 struct mlxreg_wdt *wdt = watchdog_get_drvdata(wdd); in mlxreg_wdt_ping() local
101 struct mlxreg_core_data *reg_data = &wdt->pdata->data[wdt->ping_idx]; in mlxreg_wdt_ping()
103 return regmap_write_bits(wdt->regmap, reg_data->reg, ~reg_data->mask, in mlxreg_wdt_ping()
110 struct mlxreg_wdt *wdt = watchdog_get_drvdata(wdd); in mlxreg_wdt_set_timeout() local
111 struct mlxreg_core_data *reg_data = &wdt->pdata->data[wdt->timeout_idx]; in mlxreg_wdt_set_timeout()
115 switch (wdt->wdt_type) { in mlxreg_wdt_set_timeout()
117 rc = regmap_read(wdt->regmap, reg_data->reg, ®val); in mlxreg_wdt_set_timeout()
125 rc = regmap_write(wdt->regmap, reg_data->reg, regval); in mlxreg_wdt_set_timeout()
129 rc = regmap_write(wdt->regmap, reg_data->reg, timeout); in mlxreg_wdt_set_timeout()
134 if (wdt->regmap_val_sz == 1) { in mlxreg_wdt_set_timeout()
136 rc = regmap_write(wdt->regmap, reg_data->reg, regval); in mlxreg_wdt_set_timeout()
139 rc = regmap_write(wdt->regmap, in mlxreg_wdt_set_timeout()
143 rc = regmap_write(wdt->regmap, reg_data->reg, timeout); in mlxreg_wdt_set_timeout()
168 struct mlxreg_wdt *wdt = watchdog_get_drvdata(wdd); in mlxreg_wdt_get_timeleft() local
169 struct mlxreg_core_data *reg_data = &wdt->pdata->data[wdt->tleft_idx]; in mlxreg_wdt_get_timeleft()
173 if (wdt->wdt_type == MLX_WDT_TYPE2) { in mlxreg_wdt_get_timeleft()
174 rc = regmap_read(wdt->regmap, reg_data->reg, ®val); in mlxreg_wdt_get_timeleft()
177 if (wdt->regmap_val_sz == 1) { in mlxreg_wdt_get_timeleft()
178 rc = regmap_read(wdt->regmap, reg_data->reg, &lsb); in mlxreg_wdt_get_timeleft()
180 rc = regmap_read(wdt->regmap, in mlxreg_wdt_get_timeleft()
185 rc = regmap_read(wdt->regmap, reg_data->reg, ®val); in mlxreg_wdt_get_timeleft()
213 .identity = "mlx-wdt-main",
219 .identity = "mlx-wdt-aux",
222 static void mlxreg_wdt_config(struct mlxreg_wdt *wdt, in mlxreg_wdt_config() argument
228 wdt->reset_idx = -EINVAL; in mlxreg_wdt_config()
231 wdt->action_idx = i; in mlxreg_wdt_config()
233 wdt->timeout_idx = i; in mlxreg_wdt_config()
235 wdt->tleft_idx = i; in mlxreg_wdt_config()
237 wdt->ping_idx = i; in mlxreg_wdt_config()
239 wdt->reset_idx = i; in mlxreg_wdt_config()
242 wdt->pdata = pdata; in mlxreg_wdt_config()
245 wdt->wdd.info = &mlxreg_wdt_main_info; in mlxreg_wdt_config()
247 wdt->wdd.info = &mlxreg_wdt_aux_info; in mlxreg_wdt_config()
249 wdt->wdt_type = pdata->version; in mlxreg_wdt_config()
250 switch (wdt->wdt_type) { in mlxreg_wdt_config()
252 wdt->wdd.ops = &mlxreg_wdt_ops_type1; in mlxreg_wdt_config()
253 wdt->wdd.max_timeout = MLXREG_WDT_MAX_TIMEOUT_TYPE1; in mlxreg_wdt_config()
256 wdt->wdd.ops = &mlxreg_wdt_ops_type2; in mlxreg_wdt_config()
257 wdt->wdd.max_timeout = MLXREG_WDT_MAX_TIMEOUT_TYPE2; in mlxreg_wdt_config()
260 wdt->wdd.ops = &mlxreg_wdt_ops_type2; in mlxreg_wdt_config()
261 wdt->wdd.max_timeout = MLXREG_WDT_MAX_TIMEOUT_TYPE3; in mlxreg_wdt_config()
267 wdt->wdd.min_timeout = MLXREG_WDT_MIN_TIMEOUT; in mlxreg_wdt_config()
270 static int mlxreg_wdt_init_timeout(struct mlxreg_wdt *wdt, in mlxreg_wdt_init_timeout() argument
275 timeout = pdata->data[wdt->timeout_idx].health_cntr; in mlxreg_wdt_init_timeout()
276 return mlxreg_wdt_set_timeout(&wdt->wdd, timeout); in mlxreg_wdt_init_timeout()
283 struct mlxreg_wdt *wdt; in mlxreg_wdt_probe() local
291 wdt = devm_kzalloc(dev, sizeof(*wdt), GFP_KERNEL); in mlxreg_wdt_probe()
292 if (!wdt) in mlxreg_wdt_probe()
295 wdt->wdd.parent = dev; in mlxreg_wdt_probe()
296 wdt->regmap = pdata->regmap; in mlxreg_wdt_probe()
297 rc = regmap_get_val_bytes(wdt->regmap); in mlxreg_wdt_probe()
301 wdt->regmap_val_sz = rc; in mlxreg_wdt_probe()
302 mlxreg_wdt_config(wdt, pdata); in mlxreg_wdt_probe()
305 watchdog_set_nowayout(&wdt->wdd, WATCHDOG_NOWAYOUT); in mlxreg_wdt_probe()
306 watchdog_stop_on_reboot(&wdt->wdd); in mlxreg_wdt_probe()
307 watchdog_stop_on_unregister(&wdt->wdd); in mlxreg_wdt_probe()
308 watchdog_set_drvdata(&wdt->wdd, wdt); in mlxreg_wdt_probe()
309 rc = mlxreg_wdt_init_timeout(wdt, pdata); in mlxreg_wdt_probe()
314 rc = mlxreg_wdt_start(&wdt->wdd); in mlxreg_wdt_probe()
317 set_bit(WDOG_HW_RUNNING, &wdt->wdd.status); in mlxreg_wdt_probe()
319 mlxreg_wdt_check_card_reset(wdt); in mlxreg_wdt_probe()
320 rc = devm_watchdog_register_device(dev, &wdt->wdd); in mlxreg_wdt_probe()
331 .name = "mlx-wdt",
340 MODULE_ALIAS("platform:mlx-wdt");