Commit 919726c9 authored by Nuno Sá's avatar Nuno Sá Committed by Jonathan Cameron
Browse files

iio: ltc2983: add support for optional reset gpio



Check if an optional reset gpio is present and if so, make sure to reset
the device.

Signed-off-by: default avatarNuno Sá <nuno.sa@analog.com>
Link: https://lore.kernel.org/r/20210825084149.11587-1-nuno.sa@analog.com


Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
parent 26df977a
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -1470,6 +1470,7 @@ static int ltc2983_probe(struct spi_device *spi)
{
	struct ltc2983_data *st;
	struct iio_dev *indio_dev;
	struct gpio_desc *gpio;
	const char *name = spi_get_device_id(spi)->name;
	int ret;

@@ -1494,6 +1495,16 @@ static int ltc2983_probe(struct spi_device *spi)
	if (ret)
		return ret;

	gpio = devm_gpiod_get_optional(&st->spi->dev, "reset", GPIOD_OUT_HIGH);
	if (IS_ERR(gpio))
		return PTR_ERR(gpio);

	if (gpio) {
		/* bring the device out of reset */
		usleep_range(1000, 1200);
		gpiod_set_value_cansleep(gpio, 0);
	}

	ret = ltc2983_setup(st, true);
	if (ret)
		return ret;