iio: qcom-spmi-adc5-gen3: update API for immediate conversions

When requesting immediate conversion for an ADC channel which
has TM functionality configured on channel 0 of second or
further SDAM, if the same channel 0 is used for immediate
conversion request, it will override the TM configuration
done earlier on that channel. To avoid this, use channel 0
of first SDAM alone for immediate conversion requests.

Change-Id: Iebcd324df999df736f997c106d57e454088ec54d
Signed-off-by: Jishnu Prakash <quic_jprakash@quicinc.com>
This commit is contained in:
Jishnu Prakash 2022-08-14 11:06:31 +05:30 committed by Gerrit - the friendly Code Review server
parent 03de227439
commit 040b690e9f

View File

@ -351,8 +351,13 @@ static int adc5_gen3_configure(struct adc5_chip *adc,
{
int ret;
u8 conv_req = 0, buf[7];
u8 sdam_index = prop->sdam_index;
ret = adc5_read(adc, prop->sdam_index, ADC5_GEN3_SID, buf, sizeof(buf));
/* Reserve channel 0 of first SDAM for immediate conversions */
if (prop->adc_tm)
sdam_index = 0;
ret = adc5_read(adc, sdam_index, ADC5_GEN3_SID, buf, sizeof(buf));
if (ret < 0)
return ret;
@ -383,12 +388,12 @@ static int adc5_gen3_configure(struct adc5_chip *adc,
reinit_completion(&adc->complete);
ret = adc5_write(adc, prop->sdam_index, ADC5_GEN3_SID, buf, sizeof(buf));
ret = adc5_write(adc, sdam_index, ADC5_GEN3_SID, buf, sizeof(buf));
if (ret < 0)
return ret;
conv_req = ADC5_GEN3_CONV_REQ_REQ;
ret = adc5_write(adc, prop->sdam_index, ADC5_GEN3_CONV_REQ, &conv_req, 1);
ret = adc5_write(adc, sdam_index, ADC5_GEN3_CONV_REQ, &conv_req, 1);
return ret;
}