Skip to content

Commit 96f39ba

Browse files
committed
iio: adc: ad7768-1: Fix device Synchronization
The synchronization method using GPIO requires the generated pulse to be truly synchronous with the base MCLK signal. Since this cannot be achieved in hardware, the datasheet recommends using synchronization over SPI, where the generated pulse is already synchronous with MCLK. This requires the SYNC_OUT pin to be connected to SYNC_IN. To avoid conflicts with the SYNC_OUT, sync-in GPIO is configured as input. Fixes: e9517df ("iio: adc: ad7768-1: Add support for setting the sampling frequency") Signed-off-by: Jonathan Santos <Jonathan.Santos@analog.com>
1 parent 5e64125 commit 96f39ba

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

drivers/iio/adc/ad7768-1.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -372,10 +372,9 @@ static int ad7768_set_dig_fil(struct ad7768_state *st,
372372
return ret;
373373

374374
/* A sync-in pulse is required every time the filter dec rate changes */
375-
gpiod_set_value(st->gpio_sync_in, 1);
376-
gpiod_set_value(st->gpio_sync_in, 0);
375+
ret = ad7768_spi_reg_write(st, AD7768_REG_SYNC_RESET, 0x00);
377376

378-
return 0;
377+
return ret;
379378
}
380379

381380
int ad7768_gpio_direction_input(struct gpio_chip *chip, unsigned int offset)
@@ -690,7 +689,7 @@ static int ad7768_setup(struct ad7768_state *st)
690689
return ret;
691690

692691
st->gpio_sync_in = devm_gpiod_get(&st->spi->dev, "adi,sync-in",
693-
GPIOD_OUT_LOW);
692+
GPIOD_IN);
694693
if (IS_ERR(st->gpio_sync_in))
695694
return PTR_ERR(st->gpio_sync_in);
696695

0 commit comments

Comments
 (0)