Lines Matching full:wdt

56 static void mlxreg_wdt_check_card_reset(struct mlxreg_wdt *wdt)  in mlxreg_wdt_check_card_reset()  argument
62 if (wdt->reset_idx == -EINVAL) in mlxreg_wdt_check_card_reset()
65 if (!(wdt->wdd.info->options & WDIOF_CARDRESET)) in mlxreg_wdt_check_card_reset()
68 reg_data = &wdt->pdata->data[wdt->reset_idx]; in mlxreg_wdt_check_card_reset()
69 rc = regmap_read(wdt->regmap, reg_data->reg, &regval); in mlxreg_wdt_check_card_reset()
72 wdt->wdd.bootstatus = WDIOF_CARDRESET; in mlxreg_wdt_check_card_reset()
73 dev_info(wdt->wdd.parent, in mlxreg_wdt_check_card_reset()
81 struct mlxreg_wdt *wdt = watchdog_get_drvdata(wdd); in mlxreg_wdt_start() local
82 struct mlxreg_core_data *reg_data = &wdt->pdata->data[wdt->action_idx]; in mlxreg_wdt_start()
84 return regmap_update_bits(wdt->regmap, reg_data->reg, ~reg_data->mask, in mlxreg_wdt_start()
90 struct mlxreg_wdt *wdt = watchdog_get_drvdata(wdd); in mlxreg_wdt_stop() local
91 struct mlxreg_core_data *reg_data = &wdt->pdata->data[wdt->action_idx]; in mlxreg_wdt_stop()
93 return regmap_update_bits(wdt->regmap, reg_data->reg, ~reg_data->mask, in mlxreg_wdt_stop()
99 struct mlxreg_wdt *wdt = watchdog_get_drvdata(wdd); in mlxreg_wdt_ping() local
100 struct mlxreg_core_data *reg_data = &wdt->pdata->data[wdt->ping_idx]; in mlxreg_wdt_ping()
102 return regmap_write_bits(wdt->regmap, reg_data->reg, ~reg_data->mask, in mlxreg_wdt_ping()
109 struct mlxreg_wdt *wdt = watchdog_get_drvdata(wdd); in mlxreg_wdt_set_timeout() local
110 struct mlxreg_core_data *reg_data = &wdt->pdata->data[wdt->timeout_idx]; in mlxreg_wdt_set_timeout()
114 switch (wdt->wdt_type) { in mlxreg_wdt_set_timeout()
116 rc = regmap_read(wdt->regmap, reg_data->reg, &regval); in mlxreg_wdt_set_timeout()
124 rc = regmap_write(wdt->regmap, reg_data->reg, regval); in mlxreg_wdt_set_timeout()
128 rc = regmap_write(wdt->regmap, reg_data->reg, timeout); in mlxreg_wdt_set_timeout()
133 if (wdt->regmap_val_sz == 1) { in mlxreg_wdt_set_timeout()
135 rc = regmap_write(wdt->regmap, reg_data->reg, regval); in mlxreg_wdt_set_timeout()
138 rc = regmap_write(wdt->regmap, in mlxreg_wdt_set_timeout()
142 rc = regmap_write(wdt->regmap, reg_data->reg, timeout); in mlxreg_wdt_set_timeout()
167 struct mlxreg_wdt *wdt = watchdog_get_drvdata(wdd); in mlxreg_wdt_get_timeleft() local
168 struct mlxreg_core_data *reg_data = &wdt->pdata->data[wdt->tleft_idx]; in mlxreg_wdt_get_timeleft()
172 if (wdt->wdt_type == MLX_WDT_TYPE2) { in mlxreg_wdt_get_timeleft()
173 rc = regmap_read(wdt->regmap, reg_data->reg, &regval); in mlxreg_wdt_get_timeleft()
176 if (wdt->regmap_val_sz == 1) { in mlxreg_wdt_get_timeleft()
177 rc = regmap_read(wdt->regmap, reg_data->reg, &lsb); in mlxreg_wdt_get_timeleft()
179 rc = regmap_read(wdt->regmap, in mlxreg_wdt_get_timeleft()
184 rc = regmap_read(wdt->regmap, reg_data->reg, &regval); in mlxreg_wdt_get_timeleft()
212 .identity = "mlx-wdt-main",
218 .identity = "mlx-wdt-aux",
221 static void mlxreg_wdt_config(struct mlxreg_wdt *wdt, in mlxreg_wdt_config() argument
227 wdt->reset_idx = -EINVAL; in mlxreg_wdt_config()
230 wdt->action_idx = i; in mlxreg_wdt_config()
232 wdt->timeout_idx = i; in mlxreg_wdt_config()
234 wdt->tleft_idx = i; in mlxreg_wdt_config()
236 wdt->ping_idx = i; in mlxreg_wdt_config()
238 wdt->reset_idx = i; in mlxreg_wdt_config()
241 wdt->pdata = pdata; in mlxreg_wdt_config()
244 wdt->wdd.info = &mlxreg_wdt_main_info; in mlxreg_wdt_config()
246 wdt->wdd.info = &mlxreg_wdt_aux_info; in mlxreg_wdt_config()
248 wdt->wdt_type = pdata->version; in mlxreg_wdt_config()
249 switch (wdt->wdt_type) { in mlxreg_wdt_config()
251 wdt->wdd.ops = &mlxreg_wdt_ops_type1; in mlxreg_wdt_config()
252 wdt->wdd.max_timeout = MLXREG_WDT_MAX_TIMEOUT_TYPE1; in mlxreg_wdt_config()
255 wdt->wdd.ops = &mlxreg_wdt_ops_type2; in mlxreg_wdt_config()
256 wdt->wdd.max_timeout = MLXREG_WDT_MAX_TIMEOUT_TYPE2; in mlxreg_wdt_config()
259 wdt->wdd.ops = &mlxreg_wdt_ops_type2; in mlxreg_wdt_config()
260 wdt->wdd.max_timeout = MLXREG_WDT_MAX_TIMEOUT_TYPE3; in mlxreg_wdt_config()
266 wdt->wdd.min_timeout = MLXREG_WDT_MIN_TIMEOUT; in mlxreg_wdt_config()
269 static int mlxreg_wdt_init_timeout(struct mlxreg_wdt *wdt, in mlxreg_wdt_init_timeout() argument
274 timeout = pdata->data[wdt->timeout_idx].health_cntr; in mlxreg_wdt_init_timeout()
275 return mlxreg_wdt_set_timeout(&wdt->wdd, timeout); in mlxreg_wdt_init_timeout()
282 struct mlxreg_wdt *wdt; in mlxreg_wdt_probe() local
290 wdt = devm_kzalloc(dev, sizeof(*wdt), GFP_KERNEL); in mlxreg_wdt_probe()
291 if (!wdt) in mlxreg_wdt_probe()
294 wdt->wdd.parent = dev; in mlxreg_wdt_probe()
295 wdt->regmap = pdata->regmap; in mlxreg_wdt_probe()
296 rc = regmap_get_val_bytes(wdt->regmap); in mlxreg_wdt_probe()
300 wdt->regmap_val_sz = rc; in mlxreg_wdt_probe()
301 mlxreg_wdt_config(wdt, pdata); in mlxreg_wdt_probe()
304 watchdog_set_nowayout(&wdt->wdd, WATCHDOG_NOWAYOUT); in mlxreg_wdt_probe()
305 watchdog_stop_on_reboot(&wdt->wdd); in mlxreg_wdt_probe()
306 watchdog_stop_on_unregister(&wdt->wdd); in mlxreg_wdt_probe()
307 watchdog_set_drvdata(&wdt->wdd, wdt); in mlxreg_wdt_probe()
308 rc = mlxreg_wdt_init_timeout(wdt, pdata); in mlxreg_wdt_probe()
313 rc = mlxreg_wdt_start(&wdt->wdd); in mlxreg_wdt_probe()
316 set_bit(WDOG_HW_RUNNING, &wdt->wdd.status); in mlxreg_wdt_probe()
318 mlxreg_wdt_check_card_reset(wdt); in mlxreg_wdt_probe()
319 rc = devm_watchdog_register_device(dev, &wdt->wdd); in mlxreg_wdt_probe()
330 .name = "mlx-wdt",
339 MODULE_ALIAS("platform:mlx-wdt");