@@ -145,6 +145,10 @@ struct at91_adc_reg_layout {
145145#define AT91_SAMA5D2_EMR_OSR_64SAMPLES 3
146146#define AT91_SAMA5D2_EMR_OSR_256SAMPLES 4
147147
148+ /* Extended Mode Register - TRACKX */
149+ #define AT91_SAMA5D2_TRACKX_MASK GENMASK(23, 22)
150+ #define AT91_SAMA5D2_TRACKX (x ) (((x) << 22) & \
151+ AT91_SAMA5D2_TRACKX_MASK)
148152/* Extended Mode Register - Averaging on single trigger event */
149153#define AT91_SAMA5D2_EMR_ASTE (V ) ((V) << 20)
150154
@@ -747,7 +751,7 @@ static void at91_adc_eoc_ena(struct at91_adc_state *st, unsigned int channel)
747751}
748752
749753static int at91_adc_config_emr (struct at91_adc_state * st ,
750- u32 oversampling_ratio )
754+ u32 oversampling_ratio , u32 trackx )
751755{
752756 /* configure the extended mode register */
753757 unsigned int emr = at91_adc_readl (st , EMR );
@@ -758,7 +762,7 @@ static int at91_adc_config_emr(struct at91_adc_state *st,
758762 emr |= AT91_SAMA5D2_EMR_ASTE (1 );
759763
760764 /* delete leftover content if it's the case */
761- emr &= ~osr_mask ;
765+ emr &= ~( osr_mask | AT91_SAMA5D2_TRACKX_MASK ) ;
762766
763767 /* select oversampling ratio from configuration */
764768 switch (oversampling_ratio ) {
@@ -794,6 +798,8 @@ static int at91_adc_config_emr(struct at91_adc_state *st,
794798 break ;
795799 }
796800
801+ /* Update trackx. */
802+ emr |= AT91_SAMA5D2_TRACKX (trackx );
797803 at91_adc_writel (st , EMR , emr );
798804
799805 st -> oversampling_ratio = oversampling_ratio ;
@@ -1697,7 +1703,7 @@ static int at91_adc_write_raw(struct iio_dev *indio_dev,
16971703 if (val == st -> oversampling_ratio )
16981704 goto unlock ;
16991705 /* update ratio */
1700- ret = at91_adc_config_emr (st , val );
1706+ ret = at91_adc_config_emr (st , val , 0 );
17011707unlock :
17021708 mutex_unlock (& st -> lock );
17031709 return ret ;
@@ -1873,7 +1879,7 @@ static void at91_adc_hw_init(struct iio_dev *indio_dev)
18731879 at91_adc_setup_samp_freq (indio_dev , st -> soc_info .min_sample_rate );
18741880
18751881 /* configure extended mode register */
1876- at91_adc_config_emr (st , st -> oversampling_ratio );
1882+ at91_adc_config_emr (st , st -> oversampling_ratio , 0 );
18771883}
18781884
18791885static ssize_t at91_adc_get_fifo_state (struct device * dev ,
0 commit comments