Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ee478019 authored by qctecmdr's avatar qctecmdr Committed by Gerrit - the friendly Code Review server
Browse files

Merge "iio: adc: Increase VADC polling delay for EOC to 300ms"

parents 21a50b61 4aad74e4
Loading
Loading
Loading
Loading
+12 −8
Original line number Diff line number Diff line
@@ -85,9 +85,10 @@
 * clock rate, fast average samples with no measurement in queue.
 * Set the timeout to a max of 100ms.
 */
#define ADC_CONV_TIME_MIN_US			263
#define ADC_CONV_TIME_MAX_US			264
#define ADC_CONV_TIME_RETRY			400
#define ADC_POLL_DELAY_MIN_US			10000
#define ADC_POLL_DELAY_MAX_US			10001
#define ADC_CONV_TIME_RETRY_POLL		40
#define ADC_CONV_TIME_RETRY			30
#define ADC_CONV_TIMEOUT			msecs_to_jiffies(100)

/* CAL peripheral */
@@ -274,12 +275,15 @@ static int adc_read_voltage_data(struct adc_chip *adc, u16 *data)
	return ret;
}

static int adc_poll_wait_eoc(struct adc_chip *adc)
static int adc_poll_wait_eoc(struct adc_chip *adc, bool poll_only)
{
	unsigned int count, retry;
	u8 status1;
	int ret;

	if (poll_only)
		retry = ADC_CONV_TIME_RETRY_POLL;
	else
		retry = ADC_CONV_TIME_RETRY;

	for (count = 0; count < retry; count++) {
@@ -290,7 +294,7 @@ static int adc_poll_wait_eoc(struct adc_chip *adc)
		status1 &= ADC_USR_STATUS1_REQ_STS_EOC_MASK;
		if (status1 == ADC_USR_STATUS1_EOC)
			return 0;
		usleep_range(ADC_CONV_TIME_MIN_US, ADC_CONV_TIME_MAX_US);
		usleep_range(ADC_POLL_DELAY_MIN_US, ADC_POLL_DELAY_MAX_US);
	}

	return -ETIMEDOUT;
@@ -301,7 +305,7 @@ static int adc_wait_eoc(struct adc_chip *adc)
	int ret;

	if (adc->poll_eoc) {
		ret = adc_poll_wait_eoc(adc);
		ret = adc_poll_wait_eoc(adc, true);
		if (ret < 0) {
			pr_err("EOC bit not set\n");
			return ret;
@@ -311,7 +315,7 @@ static int adc_wait_eoc(struct adc_chip *adc)
							ADC_CONV_TIMEOUT);
		if (!ret) {
			pr_debug("Did not get completion timeout.\n");
			ret = adc_poll_wait_eoc(adc);
			ret = adc_poll_wait_eoc(adc, false);
			if (ret < 0) {
				pr_err("EOC bit not set\n");
				return ret;