hwmon: qpnp-adc-voltage: Add version check for VADC thermistor channels

pa-therm, xo_therm channels are used for reading the temperature.
Calibration type for above thermistor channels has to be absolute
for PM8950 1.0 and ratiometric for PM8950 2.0. Add version check to
detect the PMIC used and update the calibration type accordingly.

Change-Id: Ie2ab723152eb0a94a163e484c0d694e8bc327e5d
Signed-off-by: Rama Krishna Phani A <rphani@codeaurora.org>
This commit is contained in:
Rama Krishna Phani A 2015-05-20 20:25:11 +05:30 committed by Gerrit - the friendly Code Review server
parent a72a21a4e3
commit 18e1a9e525
3 changed files with 31 additions and 0 deletions

View File

@ -2035,6 +2035,10 @@ int qpnp_adc_get_revid_version(struct device *dev)
(revid_data->pmic_type == PMI8994_V1P0_TYPE) &&
(revid_data->pmic_subtype == PMI8994_V1P0_SUBTYPE))
return QPNP_REV_ID_PMI8994_1_0;
else if ((revid_data->rev4 == PM8950_V1P0_REV4) &&
(revid_data->pmic_type == PM8950_V1P0_TYPE) &&
(revid_data->pmic_subtype == PM8950_V1P0_SUBTYPE))
return QPNP_REV_ID_PM8950_1_0;
else
return -EINVAL;
}

View File

@ -665,6 +665,28 @@ static int32_t qpnp_vadc_version_check(struct qpnp_vadc_chip *dev)
return 0;
}
static int32_t
qpnp_vadc_channel_post_scaling_calib_check(struct qpnp_vadc_chip *vadc,
int channel)
{
int version, rc = 0;
version = qpnp_adc_get_revid_version(vadc->dev);
if (version == QPNP_REV_ID_PM8950_1_0) {
if ((channel == LR_MUX7_HW_ID) ||
(channel == P_MUX2_1_1) ||
(channel == LR_MUX3_XO_THERM) ||
(channel == LR_MUX3_BUF_XO_THERM_BUF)) {
vadc->adc->amux_prop->chan_prop->calib_type =
CALIB_ABSOLUTE;
return rc;
}
}
return -EINVAL;
}
#define QPNP_VBAT_COEFF_1 3000
#define QPNP_VBAT_COEFF_2 45810000
#define QPNP_VBAT_COEFF_3 100000
@ -1734,6 +1756,10 @@ recalibrate:
goto fail_unlock;
}
rc = qpnp_vadc_channel_post_scaling_calib_check(vadc, channel);
if (rc < 0)
pr_debug("Post scaling calib type not updated\n");
vadc_scale_fn[scale_type].chan(vadc, result->adc_code,
vadc->adc->adc_prop, vadc->adc->amux_prop->chan_prop, result);

View File

@ -1111,6 +1111,7 @@ struct qpnp_adc_amux_properties {
#define QPNP_REV_ID_8909_1_0 13
#define QPNP_REV_ID_8909_1_1 14
#define QPNP_REV_ID_PMI8994_1_0 15
#define QPNP_REV_ID_PM8950_1_0 16
/* Public API */
#if defined(CONFIG_SENSORS_QPNP_ADC_VOLTAGE) \