mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-14 00:24:41 -04:00
iio: qcom-spmi-adc5: add SMB_TEMP channel for PMIC7
Add support to read SMB_TEMP channel on PM8350B that is output by charge pump (smb139x). When this virtual channel is read for one of SMB139x charger pumps, PBS does the configuration for that SMB139x appropriately. Change-Id: Ia9af1ef78571c56898057d567117fcd9b7d28172 Signed-off-by: Subbaraman Narayanamurthy <subbaram@codeaurora.org>
This commit is contained in:
parent
522ef8875f
commit
b6d73800a7
3 changed files with 35 additions and 4 deletions
|
|
@ -673,6 +673,8 @@ static const struct adc5_channels adc7_chans_pmic[ADC5_MAX_CHANNEL] = {
|
|||
SCALE_HW_CALIB_DEFAULT)
|
||||
[ADC7_VBAT_SNS] = ADC5_CHAN_VOLT("vbat_sns", 3,
|
||||
SCALE_HW_CALIB_DEFAULT)
|
||||
[ADC7_AMUX_THM3] = ADC5_CHAN_TEMP("smb_temp", 0,
|
||||
SCALE_HW_CALIB_PM7_SMB_TEMP)
|
||||
[ADC7_DIE_TEMP] = ADC5_CHAN_TEMP("die_temp", 0,
|
||||
SCALE_HW_CALIB_PMIC_THERM_PM7)
|
||||
[ADC7_AMUX_THM1_100K_PU] = ADC5_CHAN_TEMP("amux_thm1_pu2", 0,
|
||||
|
|
|
|||
|
|
@ -536,6 +536,10 @@ static int qcom_vadc_scale_hw_smb_temp(
|
|||
const struct vadc_prescale_ratio *prescale,
|
||||
const struct adc5_data *data,
|
||||
u16 adc_code, int *result_mdec);
|
||||
static int qcom_vadc_scale_hw_pm7_smb_temp(
|
||||
const struct vadc_prescale_ratio *prescale,
|
||||
const struct adc5_data *data,
|
||||
u16 adc_code, int *result_mdec);
|
||||
static int qcom_vadc_scale_hw_smb1398_temp(
|
||||
const struct vadc_prescale_ratio *prescale,
|
||||
const struct adc5_data *data,
|
||||
|
|
@ -571,6 +575,7 @@ static struct qcom_adc5_scale_type scale_adc5_fn[] = {
|
|||
[SCALE_HW_CALIB_PM5_CHG_TEMP] = {qcom_vadc_scale_hw_chg5_temp},
|
||||
[SCALE_HW_CALIB_PM5_SMB_TEMP] = {qcom_vadc_scale_hw_smb_temp},
|
||||
[SCALE_HW_CALIB_PM5_SMB1398_TEMP] = {qcom_vadc_scale_hw_smb1398_temp},
|
||||
[SCALE_HW_CALIB_PM7_SMB_TEMP] = {qcom_vadc_scale_hw_pm7_smb_temp},
|
||||
};
|
||||
|
||||
static int qcom_vadc_map_voltage_temp(const struct vadc_map_pt *pts,
|
||||
|
|
@ -892,6 +897,27 @@ static int qcom_vadc7_scale_hw_calib_die_temp(
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int qcom_vadc_scale_hw_pm7_smb_temp(
|
||||
const struct vadc_prescale_ratio *prescale,
|
||||
const struct adc5_data *data,
|
||||
u16 adc_code, int *result_mdec)
|
||||
{
|
||||
s64 temp;
|
||||
int result_uv;
|
||||
|
||||
result_uv = qcom_vadc_scale_code_voltage_factor(adc_code,
|
||||
prescale, data, 1);
|
||||
|
||||
/* T(C) = 25 + (25*Vadc - 24.885) / 0.0894 */
|
||||
temp = div_s64(((25000LL * result_uv) - (24885 * 1000000LL)) * 10000,
|
||||
894 * 1000000) + 25000;
|
||||
pr_debug("adc_code: %#x result_uv: %d temp: %lld\n", adc_code,
|
||||
result_uv, temp);
|
||||
*result_mdec = temp > 0 ? temp : 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int qcom_vadc_scale_hw_smb_temp(
|
||||
const struct vadc_prescale_ratio *prescale,
|
||||
const struct adc5_data *data,
|
||||
|
|
|
|||
|
|
@ -121,12 +121,8 @@ struct vadc_prescale_ratio {
|
|||
* lookup table. The hardware applies offset/slope to adc code.
|
||||
* SCALE_HW_CALIB_XOTHERM: Returns XO thermistor voltage in millidegC using
|
||||
* 100k pullup. The hardware applies offset/slope to adc code.
|
||||
* SCALE_HW_CALIB_THERM_100K_PU_PM7: Returns temperature in millidegC using
|
||||
* lookup table for PMIC7. The hardware applies offset/slope to adc code.
|
||||
* SCALE_HW_CALIB_PMIC_THERM: Returns result in milli degree's Centigrade.
|
||||
* The hardware applies offset/slope to adc code.
|
||||
* SCALE_HW_CALIB_PMIC_THERM_PM7: Returns result in milli degree's Centigrade.
|
||||
* The hardware applies offset/slope to adc code. This is for PMIC7.
|
||||
* SCALE_HW_CALIB_PM5_CHG_TEMP: Returns result in millidegrees for PMIC5
|
||||
* charger temperature.
|
||||
* SCALE_HW_CALIB_PM5_SMB_TEMP: Returns result in millidegrees for PMIC5
|
||||
|
|
@ -142,6 +138,12 @@ struct vadc_prescale_ratio {
|
|||
* code.
|
||||
* SCALE_HW_CALIB_PM5_SMB1398_TEMP: Returns result in millidegrees for PMIC5
|
||||
* SMB1398 temperature.
|
||||
* SCALE_HW_CALIB_THERM_100K_PU_PM7: Returns temperature in millidegC using
|
||||
* lookup table for PMIC7. The hardware applies offset/slope to adc code.
|
||||
* SCALE_HW_CALIB_PMIC_THERM_PM7: Returns result in milli degree's Centigrade.
|
||||
* The hardware applies offset/slope to adc code. This is for PMIC7.
|
||||
* SCALE_HW_CALIB_PM7_SMB_TEMP: Returns result in millidegrees for PMIC7
|
||||
* SMB139x temperature.
|
||||
*/
|
||||
enum vadc_scale_fn_type {
|
||||
SCALE_DEFAULT = 0,
|
||||
|
|
@ -162,6 +164,7 @@ enum vadc_scale_fn_type {
|
|||
SCALE_HW_CALIB_PM5_SMB1398_TEMP,
|
||||
SCALE_HW_CALIB_THERM_100K_PU_PM7,
|
||||
SCALE_HW_CALIB_PMIC_THERM_PM7,
|
||||
SCALE_HW_CALIB_PM7_SMB_TEMP,
|
||||
SCALE_HW_CALIB_INVALID,
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue