Skip to content

Commit e472085

Browse files
dlechjic23
authored andcommitted
iio: resolver: ad2s1210: add reset gpio support
This adds support for the optional reset gpio to the ad2s1210 resolver driver. If the gpio is present in the device tree, it is toggled during driver probe before the reset of the device initialization. As per the devicetree bindings, it is expected for the gpio to configured as active low. Suggested-by: Michael Hennerich <Michael.Hennerich@analog.com> Signed-off-by: David Lechner <dlechner@baylibre.com> Acked-by: Michael Hennerich <michael.hennerich@analog.com> Link: https://lore.kernel.org/r/20231016154311.38547-1-dlechner@baylibre.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
1 parent f7e1588 commit e472085

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

drivers/iio/resolver/ad2s1210.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1426,6 +1426,7 @@ static int ad2s1210_setup_gpios(struct ad2s1210_state *st)
14261426
{
14271427
struct device *dev = &st->sdev->dev;
14281428
struct gpio_descs *resolution_gpios;
1429+
struct gpio_desc *reset_gpio;
14291430
DECLARE_BITMAP(bitmap, 2);
14301431
int ret;
14311432

@@ -1481,6 +1482,17 @@ static int ad2s1210_setup_gpios(struct ad2s1210_state *st)
14811482
"failed to set resolution gpios\n");
14821483
}
14831484

1485+
/* If the optional reset GPIO is present, toggle it to do a hard reset. */
1486+
reset_gpio = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH);
1487+
if (IS_ERR(reset_gpio))
1488+
return dev_err_probe(dev, PTR_ERR(reset_gpio),
1489+
"failed to request reset GPIO\n");
1490+
1491+
if (reset_gpio) {
1492+
udelay(10);
1493+
gpiod_set_value(reset_gpio, 0);
1494+
}
1495+
14841496
return 0;
14851497
}
14861498

0 commit comments

Comments
 (0)