iio: adc: xilinx-xadc: Fix sequencer mode in postdisable for dual mux
commit 852534744c2d35626a604f128ff0b8ec12805591 upstream.
xadc_postdisable() unconditionally sets the sequencer to continuous
mode. For dual external multiplexer configurations this is incorrect:
simultaneous sampling mode is required so that ADC-A samples through
the mux on VAUX[0-7] while ADC-B simultaneously samples through the
mux on VAUX[8-15]. In continuous mode only ADC-A is active, so
VAUX[8-15] channels return incorrect data.
Since postdisable is also called from xadc_probe() to set the initial
idle state, the wrong sequencer mode is active from the moment the
driver loads.
The preenable path already uses xadc_get_seq_mode() which returns
SIMULTANEOUS for dual mux. Fix postdisable to do the same.
Fixes: bdc8cda1d0 ("iio:adc: Add Xilinx XADC driver")
Cc: stable@vger.kernel.org
Signed-off-by: Christofer Jonason <christofer.jonason@guidelinegeo.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
Reviewed-by: Nuno Sá <nuno.sa@analog.com>
Reviewed-by: Salih Erim <salih.erim@amd.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Ulrich Hecht <uli@kernel.org>
This commit is contained in:
1 parent
3839f5d8f8
commit
b4520a38d4
1 file changed
+9
-2
@@ -766,6 +766,7 @@ static int xadc_postdisable(struct iio_dev *indio_dev)
|
||||
{
|
||||
struct xadc *xadc = iio_priv(indio_dev);
|
||||
unsigned long scan_mask;
|
||||
int seq_mode;
|
||||
int ret;
|
||||
int i;
|
||||
|
||||
@@ -773,6 +774,12 @@ static int xadc_postdisable(struct iio_dev *indio_dev)
|
||||
for (i = 0; i < indio_dev->num_channels; i++)
|
||||
scan_mask |= BIT(indio_dev->channels[i].scan_index);
|
||||
|
||||
/*
|
||||
* Use the correct sequencer mode for the idle state: simultaneous
|
||||
* mode for dual external mux configurations, continuous otherwise.
|
||||
*/
|
||||
seq_mode = xadc_get_seq_mode(xadc, scan_mask);
|
||||
|
||||
/* Enable all channels and calibration */
|
||||
ret = xadc_write_adc_reg(xadc, XADC_REG_SEQ(0), scan_mask & 0xffff);
|
||||
if (ret)
|
||||
@@ -783,11 +790,11 @@ static int xadc_postdisable(struct iio_dev *indio_dev)
|
||||
return ret;
|
||||
|
||||
ret = xadc_update_adc_reg(xadc, XADC_REG_CONF1, XADC_CONF1_SEQ_MASK,
|
||||
XADC_CONF1_SEQ_CONTINUOUS);
|
||||
seq_mode);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
return xadc_power_adc_b(xadc, XADC_CONF1_SEQ_CONTINUOUS);
|
||||
return xadc_power_adc_b(xadc, seq_mode);
|
||||
}
|
||||
|
||||
static int xadc_preenable(struct iio_dev *indio_dev)
|
||||
|
||||
Reference in new issue
Block a user