adc: mchp_xec: right justify ADC output data under 10-bit res

This enables the ADC output data to be shifted right when using
10-bit resolution. Or else, data would be left justified as if
it's doing 12-bit ADC with the right 2 bits filled with zeroes.

Fixes #23202

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
This commit is contained in:
Daniel Leung 2020-03-02 11:06:55 -08:00 committed by Johan Hedberg
commit c3701f51d7

View file

@ -168,12 +168,14 @@ static int adc_xec_start_read(struct device *dev,
/* Setup ADC resolution */
reg = adc_regs->sar_control_reg;
reg &= ~MCHP_ADC_SAR_CTRL_RES_MASK;
reg &= ~(MCHP_ADC_SAR_CTRL_RES_MASK |
(1 << MCHP_ADC_SAR_CTRL_SHIFTD_POS));
if (sequence->resolution == 12) {
reg |= MCHP_ADC_SAR_CTRL_RES_12_BITS;
} else if (sequence->resolution == 10) {
reg |= MCHP_ADC_SAR_CTRL_RES_10_BITS;
reg |= MCHP_ADC_SAR_CTRL_SHIFTD_EN;
} else {
return -EINVAL;
}