Lines Matching +full:reset +full:- +full:gpios
1 // SPDX-License-Identifier: GPL-2.0+
34 struct gpio_desc *gpios[NUM_GPIOS]; member
44 int reset = 0; in a21_wdt_get_bootstatus() local
46 reset |= gpiod_get_value(drv->gpios[GPIO_WD_RST0]) ? (1 << 0) : 0; in a21_wdt_get_bootstatus()
47 reset |= gpiod_get_value(drv->gpios[GPIO_WD_RST1]) ? (1 << 1) : 0; in a21_wdt_get_bootstatus()
48 reset |= gpiod_get_value(drv->gpios[GPIO_WD_RST2]) ? (1 << 2) : 0; in a21_wdt_get_bootstatus()
50 return reset; in a21_wdt_get_bootstatus()
57 gpiod_set_value(drv->gpios[GPIO_WD_ENAB], 1); in a21_wdt_start()
66 gpiod_set_value(drv->gpios[GPIO_WD_ENAB], 0); in a21_wdt_stop()
75 gpiod_set_value(drv->gpios[GPIO_WD_TRIG], 0); in a21_wdt_ping()
77 gpiod_set_value(drv->gpios[GPIO_WD_TRIG], 1); in a21_wdt_ping()
88 dev_err(wdt->parent, "Only 1 and 30 allowed as timeout\n"); in a21_wdt_set_timeout()
89 return -EINVAL; in a21_wdt_set_timeout()
92 if (timeout == 30 && wdt->timeout == 1) { in a21_wdt_set_timeout()
93 dev_err(wdt->parent, in a21_wdt_set_timeout()
95 return -EINVAL; in a21_wdt_set_timeout()
99 gpiod_set_value(drv->gpios[GPIO_WD_FAST], 1); in a21_wdt_set_timeout()
101 gpiod_set_value(drv->gpios[GPIO_WD_FAST], 0); in a21_wdt_set_timeout()
103 wdt->timeout = timeout; in a21_wdt_set_timeout()
130 struct device *dev = &pdev->dev; in a21_wdt_probe()
132 unsigned int reset = 0; in a21_wdt_probe() local
139 return -ENOMEM; in a21_wdt_probe()
143 dev_err(dev, "gpios DT property wrong, got %d want %d", in a21_wdt_probe()
145 return -ENODEV; in a21_wdt_probe()
148 /* Request the used GPIOs */ in a21_wdt_probe()
156 drv->gpios[i] = devm_gpiod_get_index(dev, NULL, i, gflags); in a21_wdt_probe()
157 if (IS_ERR(drv->gpios[i])) in a21_wdt_probe()
158 return PTR_ERR(drv->gpios[i]); in a21_wdt_probe()
160 gpiod_set_consumer_name(drv->gpios[i], "MEN A21 Watchdog"); in a21_wdt_probe()
163 * Retrieve the initial value from the GPIOs that should be in a21_wdt_probe()
169 val = gpiod_get_value(drv->gpios[i]); in a21_wdt_probe()
170 gpiod_direction_output(drv->gpios[i], val); in a21_wdt_probe()
179 reset = a21_wdt_get_bootstatus(drv); in a21_wdt_probe()
180 if (reset == 2) in a21_wdt_probe()
182 else if (reset == 4) in a21_wdt_probe()
184 else if (reset == 5) in a21_wdt_probe()
186 else if (reset == 7) in a21_wdt_probe()
189 drv->wdt = a21_wdt; in a21_wdt_probe()
203 struct a21_wdt_drv *drv = dev_get_drvdata(&pdev->dev); in a21_wdt_shutdown()
205 gpiod_set_value(drv->gpios[GPIO_WD_ENAB], 0); in a21_wdt_shutdown()
209 { .compatible = "men,a021-wdt" },
218 .name = "a21-watchdog",
228 MODULE_ALIAS("platform:a21-watchdog");