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

Commit d6a33287 authored by Jishnu Prakash's avatar Jishnu Prakash
Browse files

iio: qcom-rradc: Force conversion for die_temp channel on RRADC



Force conversion for die_temp channel instead of keeping die_temp
reading dependent on presence of USB for trigger.

Change-Id: I7f31ddc701102fb1e5e52ec3c073c90d4fee6adb
Signed-off-by: default avatarJishnu Prakash <jprakash@codeaurora.org>
parent 917f9c5b
Loading
Loading
Loading
Loading
+26 −3
Original line number Diff line number Diff line
/*
 * Copyright (c) 2016-2017, The Linux Foundation. All rights reserved.
 * Copyright (c) 2016-2017, 2019, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
@@ -767,8 +767,7 @@ static int rradc_check_status_ready_with_retry(struct rradc_chip *chip,

		if (((prop->channel == RR_ADC_CHG_TEMP) ||
			(prop->channel == RR_ADC_SKIN_TEMP) ||
			(prop->channel == RR_ADC_USBIN_I) ||
			(prop->channel == RR_ADC_DIE_TEMP)) &&
			(prop->channel == RR_ADC_USBIN_I)) &&
					((!rradc_is_usb_present(chip)))) {
			pr_debug("USB not present for %d\n", prop->channel);
			rc = -ENODATA;
@@ -938,6 +937,30 @@ static int rradc_do_conversion(struct rradc_chip *chip,
			goto fail;
		}
		break;
	case RR_ADC_DIE_TEMP:
		/* Force conversion every cycle */
		rc = rradc_masked_write(chip, FG_ADC_RR_PMI_DIE_TEMP_TRIGGER,
				FG_ADC_RR_USB_IN_V_EVERY_CYCLE_MASK,
				FG_ADC_RR_USB_IN_V_EVERY_CYCLE);
		if (rc < 0) {
			pr_err("Force every cycle update failed:%d\n", rc);
			goto fail;
		}

		rc = rradc_read_channel_with_continuous_mode(chip, prop, buf);
		if (rc < 0) {
			pr_err("Error reading in continuous mode:%d\n", rc);
			goto fail;
		}

		/* Restore aux_therm trigger */
		rc = rradc_masked_write(chip, FG_ADC_RR_PMI_DIE_TEMP_TRIGGER,
				FG_ADC_RR_USB_IN_V_EVERY_CYCLE_MASK, 0);
		if (rc < 0) {
			pr_err("Restore every cycle update failed:%d\n", rc);
			goto fail;
		}
		break;
	case RR_ADC_CHG_HOT_TEMP:
	case RR_ADC_CHG_TOO_HOT_TEMP:
	case RR_ADC_SKIN_HOT_TEMP: