Skip to content

Commit 78367c3

Browse files
Demon000jic23
authored andcommitted
iio: adc: ad4130: only set GPIO_CTRL if pin is unused
Currently, GPIO_CTRL bits are set even if the pins are used for measurements. GPIO_CTRL bits should only be set if the pin is not used for other functionality. Fix this by only setting the GPIO_CTRL bits if the pin has no other function. Fixes: 6209406 ("iio: adc: ad4130: add AD4130 driver") Signed-off-by: Cosmin Tanislav <demonsingur@gmail.com> Reviewed-by: Nuno Sa <nuno.sa@analog.com> Link: https://lore.kernel.org/r/20240207132007.253768-2-demonsingur@gmail.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
1 parent a22b0a2 commit 78367c3

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

drivers/iio/adc/ad4130.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1891,10 +1891,14 @@ static int ad4130_setup(struct iio_dev *indio_dev)
18911891
return ret;
18921892

18931893
/*
1894-
* Configure all GPIOs for output. If configured, the interrupt function
1895-
* of P2 takes priority over the GPIO out function.
1894+
* Configure unused GPIOs for output. If configured, the interrupt
1895+
* function of P2 takes priority over the GPIO out function.
18961896
*/
1897-
val = AD4130_IO_CONTROL_GPIO_CTRL_MASK;
1897+
val = 0;
1898+
for (i = 0; i < AD4130_MAX_GPIOS; i++)
1899+
if (st->pins_fn[i + AD4130_AIN2_P1] == AD4130_PIN_FN_NONE)
1900+
val |= FIELD_PREP(AD4130_IO_CONTROL_GPIO_CTRL_MASK, BIT(i));
1901+
18981902
val |= FIELD_PREP(AD4130_IO_CONTROL_INT_PIN_SEL_MASK, st->int_pin_sel);
18991903

19001904
ret = regmap_write(st->regmap, AD4130_IO_CONTROL_REG, val);

0 commit comments

Comments
 (0)