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

Commit 12214ead authored by Dipen Parmar's avatar Dipen Parmar Committed by Gerrit - the friendly Code Review server
Browse files

hwmon: qpnp-adc-voltage: Add temperature compensation for PM8909



Add VBAT and OCV temperature compensation for PM8909
v1.0 SMIC parts.

The temperature compensation is required on top of
gain/offset calibration to compensate for variations
due to chip revision, manufacturer and temperature.

Change-Id: Ic0f110ed53dba314196af31c16c1fd58d20f7f1d
Signed-off-by: default avatarDipen Parmar <dipenp@codeaurora.org>
parent 76eb1e04
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -1541,6 +1541,20 @@ int qpnp_adc_get_revid_version(struct device *dev)
		(revid_data->pmic_type == PM8916_V2P0_TYPE) &&
		(revid_data->pmic_subtype == PM8916_V2P0_SUBTYPE))
			return QPNP_REV_ID_8916_2_0;
	else if ((revid_data->rev1 == PM8909_V1P0_REV1) &&
		(revid_data->rev2 == PM8909_V1P0_REV2) &&
		(revid_data->rev3 == PM8909_V1P0_REV3) &&
		(revid_data->rev4 == PM8909_V1P0_REV4) &&
		(revid_data->pmic_type == PM8909_V1P0_TYPE) &&
		(revid_data->pmic_subtype == PM8909_V1P0_SUBTYPE))
			return QPNP_REV_ID_8909_1_0;
	else if ((revid_data->rev1 == PM8909_V1P1_REV1) &&
		(revid_data->rev2 == PM8909_V1P1_REV2) &&
		(revid_data->rev3 == PM8909_V1P1_REV3) &&
		(revid_data->rev4 == PM8909_V1P1_REV4) &&
		(revid_data->pmic_type == PM8909_V1P1_TYPE) &&
		(revid_data->pmic_subtype == PM8909_V1P1_SUBTYPE))
			return QPNP_REV_ID_8909_1_1;
	else
		return -EINVAL;
}
+21 −0
Original line number Diff line number Diff line
@@ -696,6 +696,8 @@ static int32_t qpnp_vadc_version_check(struct qpnp_vadc_chip *dev)
#define QPNP_VBAT_COEFF_46	2120
#define QPNP_VBAT_COEFF_47	3560
#define QPNP_VBAT_COEFF_48	2190
#define QPNP_VBAT_COEFF_49	4180
#define QPNP_VBAT_COEFF_50	27800000

static int32_t qpnp_ocv_comp(int64_t *result,
			struct qpnp_vadc_chip *vadc, int64_t die_temp)
@@ -861,6 +863,13 @@ static int32_t qpnp_ocv_comp(int64_t *result,
			break;
		}
		break;
	case QPNP_REV_ID_8909_1_0:
		switch (vadc->id) {
		case COMP_ID_SMIC:
			temp_var = (-QPNP_VBAT_COEFF_50);
			break;
		}
		break;
	default:
		temp_var = 0;
		break;
@@ -1032,6 +1041,18 @@ static int32_t qpnp_vbat_sns_comp(int64_t *result,
			break;
		}
		break;
	case QPNP_REV_ID_8909_1_0:
		switch (vadc->id) {
		case COMP_ID_SMIC:
			if (die_temp < 30000)
				temp_var = (-QPNP_VBAT_COEFF_50);
			else if (die_temp > 30000)
				temp_var = (((die_temp - 30000) *
					(-QPNP_VBAT_COEFF_49)) +
					(-QPNP_VBAT_COEFF_50));
			break;
		}
		break;
	default:
		temp_var = 0;
		break;
+2 −0
Original line number Diff line number Diff line
@@ -1088,6 +1088,8 @@ struct qpnp_adc_amux_properties {
#define QPNP_REV_ID_8916_1_0	10
#define QPNP_REV_ID_8916_1_1	11
#define QPNP_REV_ID_8916_2_0	12
#define QPNP_REV_ID_8909_1_0	13
#define QPNP_REV_ID_8909_1_1	14

/* Public API */
#if defined(CONFIG_SENSORS_QPNP_ADC_VOLTAGE)				\