Lines Matching +full:wdt +full:- +full:gpio
1 // SPDX-License-Identifier: GPL-2.0-or-later
9 #include <linux/gpio/consumer.h>
10 #include <linux/mfd/rohm-bd957x.h>
37 gpiod_set_value_cansleep(priv->gpiod_en, 0); in bd9576_wdt_disable()
45 gpiod_set_value_cansleep(priv->gpiod_ping, 1); in bd9576_wdt_ping()
46 gpiod_set_value_cansleep(priv->gpiod_ping, 0); in bd9576_wdt_ping()
55 gpiod_set_value_cansleep(priv->gpiod_en, 1); in bd9576_wdt_start()
97 return -EINVAL; in find_closest_fast()
113 return -EINVAL; in find_closest_slow_by_fast()
141 return -EINVAL; in find_closest_slow()
156 struct device *dev = priv->dev; in bd957x_set_wdt_mode()
168 dev_err(dev, "bad WDT window for fast timeout\n"); in bd957x_set_wdt_mode()
174 dev_err(dev, "bad WDT window\n"); in bd957x_set_wdt_mode()
183 dev_err(dev, "bad WDT window\n"); in bd957x_set_wdt_mode()
188 slowng <<= ffs(BD957X_WDG_NG_RATIO_MASK) - 1; in bd957x_set_wdt_mode()
192 ret = regmap_update_bits(priv->regmap, BD957X_REG_WDT_CONF, in bd957x_set_wdt_mode()
200 struct device *dev = &pdev->dev; in bd9576_wdt_probe()
209 return -ENOMEM; in bd9576_wdt_probe()
213 priv->dev = dev; in bd9576_wdt_probe()
214 priv->regmap = dev_get_regmap(dev->parent, NULL); in bd9576_wdt_probe()
215 if (!priv->regmap) { in bd9576_wdt_probe()
217 return -ENODEV; in bd9576_wdt_probe()
220 priv->gpiod_en = devm_fwnode_gpiod_get(dev, dev_fwnode(dev->parent), in bd9576_wdt_probe()
221 "rohm,watchdog-enable", in bd9576_wdt_probe()
223 "watchdog-enable"); in bd9576_wdt_probe()
224 if (IS_ERR(priv->gpiod_en)) in bd9576_wdt_probe()
225 return dev_err_probe(dev, PTR_ERR(priv->gpiod_en), in bd9576_wdt_probe()
226 "getting watchdog-enable GPIO failed\n"); in bd9576_wdt_probe()
228 priv->gpiod_ping = devm_fwnode_gpiod_get(dev, dev_fwnode(dev->parent), in bd9576_wdt_probe()
229 "rohm,watchdog-ping", in bd9576_wdt_probe()
231 "watchdog-ping"); in bd9576_wdt_probe()
232 if (IS_ERR(priv->gpiod_ping)) in bd9576_wdt_probe()
233 return dev_err_probe(dev, PTR_ERR(priv->gpiod_ping), in bd9576_wdt_probe()
234 "getting watchdog-ping GPIO failed\n"); in bd9576_wdt_probe()
236 count = device_property_count_u32(dev->parent, "rohm,hw-timeout-ms"); in bd9576_wdt_probe()
237 if (count < 0 && count != -EINVAL) in bd9576_wdt_probe()
242 return -EINVAL; in bd9576_wdt_probe()
244 ret = device_property_read_u32_array(dev->parent, in bd9576_wdt_probe()
245 "rohm,hw-timeout-ms", in bd9576_wdt_probe()
263 watchdog_set_drvdata(&priv->wdd, priv); in bd9576_wdt_probe()
265 priv->wdd.info = &bd957x_wdt_ident; in bd9576_wdt_probe()
266 priv->wdd.ops = &bd957x_wdt_ops; in bd9576_wdt_probe()
267 priv->wdd.min_hw_heartbeat_ms = hw_margin_min; in bd9576_wdt_probe()
268 priv->wdd.max_hw_heartbeat_ms = hw_margin_max; in bd9576_wdt_probe()
269 priv->wdd.parent = dev; in bd9576_wdt_probe()
270 priv->wdd.timeout = WATCHDOG_TIMEOUT; in bd9576_wdt_probe()
272 watchdog_init_timeout(&priv->wdd, 0, dev); in bd9576_wdt_probe()
273 watchdog_set_nowayout(&priv->wdd, nowayout); in bd9576_wdt_probe()
275 watchdog_stop_on_reboot(&priv->wdd); in bd9576_wdt_probe()
277 return devm_watchdog_register_device(dev, &priv->wdd); in bd9576_wdt_probe()
282 .name = "bd9576-wdt",
292 MODULE_ALIAS("platform:bd9576-wdt");