Skip to content

Commit ac290f7

Browse files
committed
iio: adc: at91-sama5d2_adc: fix differential channels in triggered mode
The differential channels require writing the channel offset register (COR). Otherwise they do not work in differential mode. The configuration of COR is missing in triggered mode. Fixes: 5e1a1da ("iio: adc: at91-sama5d2_adc: add hw trigger and buffer support") Signed-off-by: Eugen Hristev <eugen.hristev@microchip.com> Cc: <Stable@vger.kernel.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
1 parent d57e558 commit ac290f7

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

drivers/iio/adc/at91-sama5d2_adc.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -723,6 +723,7 @@ static int at91_adc_configure_trigger(struct iio_trigger *trig, bool state)
723723

724724
for_each_set_bit(bit, indio->active_scan_mask, indio->num_channels) {
725725
struct iio_chan_spec const *chan = at91_adc_chan_get(indio, bit);
726+
u32 cor;
726727

727728
if (!chan)
728729
continue;
@@ -731,6 +732,20 @@ static int at91_adc_configure_trigger(struct iio_trigger *trig, bool state)
731732
chan->type == IIO_PRESSURE)
732733
continue;
733734

735+
if (state) {
736+
cor = at91_adc_readl(st, AT91_SAMA5D2_COR);
737+
738+
if (chan->differential)
739+
cor |= (BIT(chan->channel) |
740+
BIT(chan->channel2)) <<
741+
AT91_SAMA5D2_COR_DIFF_OFFSET;
742+
else
743+
cor &= ~(BIT(chan->channel) <<
744+
AT91_SAMA5D2_COR_DIFF_OFFSET);
745+
746+
at91_adc_writel(st, AT91_SAMA5D2_COR, cor);
747+
}
748+
734749
if (state) {
735750
at91_adc_writel(st, AT91_SAMA5D2_CHER,
736751
BIT(chan->channel));

0 commit comments

Comments
 (0)