iio: adc: xilinx-ams: Fix single channel switching sequence
authorRobert Hancock <robert.hancock@calian.com>
Thu, 27 Jan 2022 17:34:50 +0000 (11:34 -0600)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Mon, 28 Feb 2022 18:23:38 +0000 (18:23 +0000)
commit123d838c4e7deedebe29cc63c1098db1a810f1f8
tree4028bc01667b7bce5ee0d689b32544853061af73
parent23fe22f04b000b9370cf5d253317b29413ca5316
iio: adc: xilinx-ams: Fix single channel switching sequence

Some of the AMS channels need to be read by switching into single-channel
mode from the normal polling sequence. There was a logic issue in this
switching code that could cause the first read of these channels to read
back as zero.

It appears that the sequencer should be set back to default mode before
changing the channel selection, and the channel should be set before
switching the sequencer back into single-channel mode.

Also, write 1 to the EOC bit in the status register to clear it before
waiting for it to become set, so that we actually wait for a new
conversion to complete, and don't proceed based on a previous conversion
completing.

Fixes: d5c70627a794 ("iio: adc: Add Xilinx AMS driver")
Signed-off-by: Robert Hancock <robert.hancock@calian.com>
Acked-by: Michal Simek <michal.simek@xilinx.com>
Link: https://lore.kernel.org/r/20220127173450.3684318-5-robert.hancock@calian.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
drivers/iio/adc/xilinx-ams.c