mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-07 12:25:00 -04:00
iio: adc: Add support to read ADC5 current channels
Add scaling function required to read PMIC5 current ADC channels so that channel 0xA5 (ADC5_PARALLEL_ISENSE) can use that. Change-Id: I55ede0c736c6f350df8ac92ea8661db4129da13c Signed-off-by: Jishnu Prakash <jprakash@codeaurora.org>
This commit is contained in:
parent
858cd7768a
commit
348ea390bc
3 changed files with 35 additions and 2 deletions
|
|
@ -695,8 +695,8 @@ static const struct adc5_channels adc5_chans_pmic[ADC5_MAX_CHANNEL] = {
|
|||
SCALE_HW_CALIB_THERM_100K_PULLUP)
|
||||
[ADC5_AMUX_THM2] = ADC5_CHAN_TEMP("amux_thm2", 0,
|
||||
SCALE_HW_CALIB_PM5_SMB_TEMP)
|
||||
[ADC5_PARALLEL_ISENSE] = ADC5_CHAN_VOLT("parallel_isense", 1,
|
||||
SCALE_HW_CALIB_CUR)
|
||||
[ADC5_PARALLEL_ISENSE] = ADC5_CHAN_VOLT("parallel_isense", 0,
|
||||
SCALE_HW_CALIB_PM5_CUR)
|
||||
[ADC5_GPIO1_100K_PU] = ADC5_CHAN_TEMP("gpio1_100k_pu", 0,
|
||||
SCALE_HW_CALIB_THERM_100K_PULLUP)
|
||||
[ADC5_GPIO2_100K_PU] = ADC5_CHAN_TEMP("gpio2_100k_pu", 0,
|
||||
|
|
|
|||
|
|
@ -512,14 +512,21 @@ static int qcom_vadc_scale_hw_calib_volt(
|
|||
const struct vadc_prescale_ratio *prescale,
|
||||
const struct adc5_data *data,
|
||||
u16 adc_code, int *result_uv);
|
||||
/* Current scaling for PMIC7 */
|
||||
static int qcom_vadc_scale_hw_calib_current(
|
||||
const struct vadc_prescale_ratio *prescale,
|
||||
const struct adc5_data *data,
|
||||
u16 adc_code, int *result_ua);
|
||||
/* Raw current for PMIC7 */
|
||||
static int qcom_vadc_scale_hw_calib_current_raw(
|
||||
const struct vadc_prescale_ratio *prescale,
|
||||
const struct adc5_data *data,
|
||||
u16 adc_code, int *result_ua);
|
||||
/* Current scaling for PMIC5 */
|
||||
static int qcom_vadc5_scale_hw_calib_current(
|
||||
const struct vadc_prescale_ratio *prescale,
|
||||
const struct adc5_data *data,
|
||||
u16 adc_code, int *result_ua);
|
||||
static int qcom_vadc_scale_hw_calib_therm(
|
||||
const struct vadc_prescale_ratio *prescale,
|
||||
const struct adc5_data *data,
|
||||
|
|
@ -577,6 +584,7 @@ static struct qcom_adc5_scale_type scale_adc5_fn[] = {
|
|||
[SCALE_HW_CALIB_DEFAULT] = {qcom_vadc_scale_hw_calib_volt},
|
||||
[SCALE_HW_CALIB_CUR] = {qcom_vadc_scale_hw_calib_current},
|
||||
[SCALE_HW_CALIB_CUR_RAW] = {qcom_vadc_scale_hw_calib_current_raw},
|
||||
[SCALE_HW_CALIB_PM5_CUR] = {qcom_vadc5_scale_hw_calib_current},
|
||||
[SCALE_HW_CALIB_THERM_100K_PULLUP] = {qcom_vadc_scale_hw_calib_therm},
|
||||
[SCALE_HW_CALIB_BATT_THERM_100K] = {
|
||||
qcom_vadc_scale_hw_calib_batt_therm_100},
|
||||
|
|
@ -835,6 +843,30 @@ static int qcom_vadc_scale_hw_calib_current(
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int qcom_vadc5_scale_hw_calib_current(
|
||||
const struct vadc_prescale_ratio *prescale,
|
||||
const struct adc5_data *data,
|
||||
u16 adc_code, int *result_ua)
|
||||
{
|
||||
s64 voltage = 0, result = 0;
|
||||
bool positive = true;
|
||||
|
||||
if (adc_code & ADC5_USR_DATA_CHECK) {
|
||||
adc_code = ~adc_code + 1;
|
||||
positive = false;
|
||||
}
|
||||
|
||||
voltage = (s64)(s16) adc_code * data->full_scale_code_cur * 1000;
|
||||
voltage = div64_s64(voltage, VADC5_MAX_CODE);
|
||||
result = div64_s64(voltage * prescale->den, prescale->num);
|
||||
*result_ua = result;
|
||||
|
||||
if (!positive)
|
||||
*result_ua = -result;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int qcom_vadc_scale_hw_calib_volt(
|
||||
const struct vadc_prescale_ratio *prescale,
|
||||
const struct adc5_data *data,
|
||||
|
|
|
|||
|
|
@ -179,6 +179,7 @@ enum vadc_scale_fn_type {
|
|||
SCALE_HW_CALIB_PM7_CHG_TEMP,
|
||||
SCALE_HW_CALIB_CUR_RAW,
|
||||
SCALE_HW_CALIB_PM2250_S3_DIE_TEMP,
|
||||
SCALE_HW_CALIB_PM5_CUR,
|
||||
SCALE_HW_CALIB_INVALID,
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue