Skip to content

Commit 8bef455

Browse files
larsclausenjic23
authored andcommitted
iio: xilinx-xadc: Fix sequencer configuration for aux channels in simultaneous mode
The XADC has two internal ADCs. Depending on the mode it is operating in either one or both of them are used. The device manual calls this continuous (one ADC) and simultaneous (both ADCs) mode. The meaning of the sequencing register for the aux channels changes depending on the mode. In continuous mode each bit corresponds to one of the 16 aux channels. And the single ADC will convert them one by one in order. In simultaneous mode the aux channels are split into two groups the first 8 channels are assigned to the first ADC and the other 8 channels to the second ADC. The upper 8 bits of the sequencing register are unused and the lower 8 bits control both ADCs. This means a bit needs to be set if either the corresponding channel from the first group or the second group (or both) are set. Currently the driver does not have the special handling required for simultaneous mode. Add it. Signed-off-by: Lars-Peter Clausen <[email protected]> Fixes: bdc8cda ("iio:adc: Add Xilinx XADC driver") Cc: <[email protected]> Signed-off-by: Jonathan Cameron <[email protected]>
1 parent f954b09 commit 8bef455

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

drivers/iio/adc/xilinx-xadc-core.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -798,6 +798,16 @@ static int xadc_preenable(struct iio_dev *indio_dev)
798798
if (ret)
799799
goto err;
800800

801+
/*
802+
* In simultaneous mode the upper and lower aux channels are samples at
803+
* the same time. In this mode the upper 8 bits in the sequencer
804+
* register are don't care and the lower 8 bits control two channels
805+
* each. As such we must set the bit if either the channel in the lower
806+
* group or the upper group is enabled.
807+
*/
808+
if (seq_mode == XADC_CONF1_SEQ_SIMULTANEOUS)
809+
scan_mask = ((scan_mask >> 8) | scan_mask) & 0xff0000;
810+
801811
ret = xadc_write_adc_reg(xadc, XADC_REG_SEQ(1), scan_mask >> 16);
802812
if (ret)
803813
goto err;

0 commit comments

Comments
 (0)