Skip to content

Commit

Permalink
iio: resolver: ad2s1210: add reset gpio support
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: David Lechner <[email protected]>
Acked-by: Michael Hennerich <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Jonathan Cameron <[email protected]>
  • Loading branch information
dlech committed Oct 30, 2023
1 parent 770c02b commit c8013a4
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions drivers/iio/resolver/ad2s1210.c
Original file line number Diff line number Diff line change
Expand Up @@ -1426,6 +1426,7 @@ static int ad2s1210_setup_gpios(struct ad2s1210_state *st)
{
struct device *dev = &st->sdev->dev;
struct gpio_descs *resolution_gpios;
struct gpio_desc *reset_gpio;
DECLARE_BITMAP(bitmap, 2);
int ret;

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

/* If the optional reset GPIO is present, toggle it to do a hard reset. */
reset_gpio = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH);
if (IS_ERR(reset_gpio))
return dev_err_probe(dev, PTR_ERR(reset_gpio),
"failed to request reset GPIO\n");

if (reset_gpio) {
udelay(10);
gpiod_set_value(reset_gpio, 0);
}

return 0;
}

Expand Down

0 comments on commit c8013a4

Please sign in to comment.