Loading drivers/hwmon/qpnp-adc-common.c +89 −19 Original line number Diff line number Diff line Loading @@ -751,6 +751,61 @@ static const struct qpnp_vadc_map_pt adcmap_batt_therm_qrd[] = { {107, 980} }; /* Voltage to temperature */ static const struct qpnp_vadc_map_pt adcmap_batt_therm_qrd_215[] = { {1575, -200}, {1549, -180}, {1522, -160}, {1493, -140}, {1463, -120}, {1431, -100}, {1398, -80}, {1364, -60}, {1329, -40}, {1294, -20}, {1258, 0}, {1222, 20}, {1187, 40}, {1151, 60}, {1116, 80}, {1082, 100}, {1049, 120}, {1016, 140}, {985, 160}, {955, 180}, {926, 200}, {899, 220}, {873, 240}, {849, 260}, {825, 280}, {804, 300}, {783, 320}, {764, 340}, {746, 360}, {729, 380}, {714, 400}, {699, 420}, {686, 440}, {673, 460}, {662, 480}, {651, 500}, {641, 520}, {632, 540}, {623, 560}, {615, 580}, {608, 600}, {601, 620}, {595, 640}, {589, 660}, {583, 680}, {578, 700}, {574, 720}, {569, 740}, {565, 760}, {562, 780}, {558, 800} }; /* Voltage to temperature */ static const struct qpnp_vadc_map_pt adcmap_batt_therm_pu30[] = { {1842, -400}, Loading Loading @@ -1263,19 +1318,6 @@ int32_t qpnp_adc_batt_therm_qrd(struct qpnp_vadc_chip *chip, qpnp_adc_map_voltage_temp(adcmap_batt_therm_qrd, ARRAY_SIZE(adcmap_batt_therm_qrd), batt_thm_voltage, &adc_chan_result->physical); } else { qpnp_adc_scale_with_calib_param(adc_code, adc_properties, chan_properties, &batt_thm_voltage); adc_chan_result->measurement = batt_thm_voltage; return qpnp_adc_map_voltage_temp( adcmap_batt_therm_qrd, ARRAY_SIZE(adcmap_batt_therm_qrd), batt_thm_voltage, &adc_chan_result->physical); } return 0; } Loading Loading @@ -1337,6 +1379,34 @@ int32_t qpnp_adc_batt_therm_pu400(struct qpnp_vadc_chip *chip, } EXPORT_SYMBOL(qpnp_adc_batt_therm_pu400); int32_t qpnp_adc_batt_therm_qrd_215(struct qpnp_vadc_chip *chip, int32_t adc_code, const struct qpnp_adc_properties *adc_properties, const struct qpnp_vadc_chan_properties *chan_properties, struct qpnp_vadc_result *adc_chan_result) { int64_t batt_thm_voltage = 0; if (!chan_properties || !chan_properties->offset_gain_numerator || !chan_properties->offset_gain_denominator || !adc_properties || !adc_chan_result) return -EINVAL; qpnp_adc_scale_with_calib_param(adc_code, adc_properties, chan_properties, &batt_thm_voltage); adc_chan_result->measurement = batt_thm_voltage; return qpnp_adc_map_voltage_temp( adcmap_batt_therm_qrd_215, ARRAY_SIZE(adcmap_batt_therm_qrd_215), batt_thm_voltage, &adc_chan_result->physical); return 0; } EXPORT_SYMBOL(qpnp_adc_batt_therm_qrd_215); int32_t qpnp_adc_scale_batt_therm(struct qpnp_vadc_chip *chip, int32_t adc_code, const struct qpnp_adc_properties *adc_properties, Loading Loading @@ -2182,9 +2252,9 @@ int32_t qpnp_adc_qrd_215_btm_scaler(struct qpnp_vadc_chip *chip, pr_debug("warm_temp:%d and cool_temp:%d\n", param->high_temp, param->low_temp); rc = qpnp_adc_map_voltage_temp( adcmap_batt_therm_qrd, ARRAY_SIZE(adcmap_batt_therm_qrd), rc = qpnp_adc_map_temp_voltage( adcmap_batt_therm_qrd_215, ARRAY_SIZE(adcmap_batt_therm_qrd_215), (param->low_temp), &low_output); if (rc) { Loading @@ -2197,9 +2267,9 @@ int32_t qpnp_adc_qrd_215_btm_scaler(struct qpnp_vadc_chip *chip, low_output = div64_s64(low_output, btm_param.adc_vref); low_output += btm_param.adc_gnd; rc = qpnp_adc_map_voltage_temp( adcmap_batt_therm_qrd, ARRAY_SIZE(adcmap_batt_therm_qrd), rc = qpnp_adc_map_temp_voltage( adcmap_batt_therm_qrd_215, ARRAY_SIZE(adcmap_batt_therm_qrd_215), (param->high_temp), &high_output); if (rc) { Loading drivers/hwmon/qpnp-adc-voltage.c +1 −0 Original line number Diff line number Diff line Loading @@ -232,6 +232,7 @@ static struct qpnp_vadc_scale_fn vadc_scale_fn[] = { [SCALE_SMB1390_DIE_TEMP] = {qpnp_adc_scale_die_temp_1390}, [SCALE_BATT_THERM_TEMP_PU30] = {qpnp_adc_batt_therm_pu30}, [SCALE_BATT_THERM_TEMP_PU400] = {qpnp_adc_batt_therm_pu400}, [SCALE_BATT_THERM_TEMP_QRD_215] = {qpnp_adc_batt_therm_qrd_215} }; static struct qpnp_vadc_rscale_fn adc_vadc_rscale_fn[] = { Loading include/linux/qpnp/qpnp-adc.h +26 −0 Original line number Diff line number Diff line Loading @@ -406,6 +406,8 @@ enum qpnp_adc_channel_scaling_param { * %SCALE_BATT_THERM_TEMP_PU400: Conversion to temperature(decidegC) for 400k * pullup. * %SCALE_SMB1390_DIE_TEMP: Conversion for SMB1390 die temp * %SCALE_BATT_THERM_TEMP_QRD_215: Conversion to temperature(decidegC) based on * btm parameters for QRD. * %SCALE_NONE: Do not use this scaling type. */ enum qpnp_adc_scale_fn_type { Loading @@ -432,6 +434,7 @@ enum qpnp_adc_scale_fn_type { SCALE_SMB1390_DIE_TEMP, SCALE_BATT_THERM_TEMP_PU30, SCALE_BATT_THERM_TEMP_PU400, SCALE_BATT_THERM_TEMP_QRD_215, SCALE_NONE, }; Loading Loading @@ -1509,6 +1512,23 @@ int32_t qpnp_adc_batt_therm_pu400(struct qpnp_vadc_chip *dev, const struct qpnp_adc_properties *adc_prop, const struct qpnp_vadc_chan_properties *chan_prop, struct qpnp_vadc_result *chan_rslt); /** * qpnp_adc_batt_therm_qrd_215() - Scales the pre-calibrated digital output * of an ADC to the ADC reference and compensates for the * gain and offset. Returns the temperature in decidegC for QRD. * @dev: Structure device for qpnp vadc * @adc_code: pre-calibrated digital output of the ADC. * @adc_prop: adc properties of the pm8xxx adc such as bit resolution, * reference voltage. * @chan_prop: individual channel properties to compensate the i/p scaling, * slope and offset. * @chan_rslt: physical result to be stored. */ int32_t qpnp_adc_batt_therm_qrd_215(struct qpnp_vadc_chip *dev, int32_t adc_code, const struct qpnp_adc_properties *adc_prop, const struct qpnp_vadc_chan_properties *chan_prop, struct qpnp_vadc_result *chan_rslt); /** * qpnp_adc_scale_batt_therm() - Scales the pre-calibrated digital output * of an ADC to the ADC reference and compensates for the Loading Loading @@ -2164,6 +2184,12 @@ static inline int32_t qpnp_adc_batt_therm_pu400(struct qpnp_vadc_chip *vadc, const struct qpnp_vadc_chan_properties *chan_prop, struct qpnp_vadc_result *chan_rslt) { return -ENXIO; } static inline int32_t qpnp_adc_batt_therm_qrd_215(struct qpnp_vadc_chip *vadc, int32_t adc_code, const struct qpnp_adc_properties *adc_prop, const struct qpnp_vadc_chan_properties *chan_prop, struct qpnp_vadc_result *chan_rslt) { return -ENXIO; } static inline int32_t qpnp_adc_scale_batt_therm(struct qpnp_vadc_chip *vadc, int32_t adc_code, const struct qpnp_adc_properties *adc_prop, Loading Loading
drivers/hwmon/qpnp-adc-common.c +89 −19 Original line number Diff line number Diff line Loading @@ -751,6 +751,61 @@ static const struct qpnp_vadc_map_pt adcmap_batt_therm_qrd[] = { {107, 980} }; /* Voltage to temperature */ static const struct qpnp_vadc_map_pt adcmap_batt_therm_qrd_215[] = { {1575, -200}, {1549, -180}, {1522, -160}, {1493, -140}, {1463, -120}, {1431, -100}, {1398, -80}, {1364, -60}, {1329, -40}, {1294, -20}, {1258, 0}, {1222, 20}, {1187, 40}, {1151, 60}, {1116, 80}, {1082, 100}, {1049, 120}, {1016, 140}, {985, 160}, {955, 180}, {926, 200}, {899, 220}, {873, 240}, {849, 260}, {825, 280}, {804, 300}, {783, 320}, {764, 340}, {746, 360}, {729, 380}, {714, 400}, {699, 420}, {686, 440}, {673, 460}, {662, 480}, {651, 500}, {641, 520}, {632, 540}, {623, 560}, {615, 580}, {608, 600}, {601, 620}, {595, 640}, {589, 660}, {583, 680}, {578, 700}, {574, 720}, {569, 740}, {565, 760}, {562, 780}, {558, 800} }; /* Voltage to temperature */ static const struct qpnp_vadc_map_pt adcmap_batt_therm_pu30[] = { {1842, -400}, Loading Loading @@ -1263,19 +1318,6 @@ int32_t qpnp_adc_batt_therm_qrd(struct qpnp_vadc_chip *chip, qpnp_adc_map_voltage_temp(adcmap_batt_therm_qrd, ARRAY_SIZE(adcmap_batt_therm_qrd), batt_thm_voltage, &adc_chan_result->physical); } else { qpnp_adc_scale_with_calib_param(adc_code, adc_properties, chan_properties, &batt_thm_voltage); adc_chan_result->measurement = batt_thm_voltage; return qpnp_adc_map_voltage_temp( adcmap_batt_therm_qrd, ARRAY_SIZE(adcmap_batt_therm_qrd), batt_thm_voltage, &adc_chan_result->physical); } return 0; } Loading Loading @@ -1337,6 +1379,34 @@ int32_t qpnp_adc_batt_therm_pu400(struct qpnp_vadc_chip *chip, } EXPORT_SYMBOL(qpnp_adc_batt_therm_pu400); int32_t qpnp_adc_batt_therm_qrd_215(struct qpnp_vadc_chip *chip, int32_t adc_code, const struct qpnp_adc_properties *adc_properties, const struct qpnp_vadc_chan_properties *chan_properties, struct qpnp_vadc_result *adc_chan_result) { int64_t batt_thm_voltage = 0; if (!chan_properties || !chan_properties->offset_gain_numerator || !chan_properties->offset_gain_denominator || !adc_properties || !adc_chan_result) return -EINVAL; qpnp_adc_scale_with_calib_param(adc_code, adc_properties, chan_properties, &batt_thm_voltage); adc_chan_result->measurement = batt_thm_voltage; return qpnp_adc_map_voltage_temp( adcmap_batt_therm_qrd_215, ARRAY_SIZE(adcmap_batt_therm_qrd_215), batt_thm_voltage, &adc_chan_result->physical); return 0; } EXPORT_SYMBOL(qpnp_adc_batt_therm_qrd_215); int32_t qpnp_adc_scale_batt_therm(struct qpnp_vadc_chip *chip, int32_t adc_code, const struct qpnp_adc_properties *adc_properties, Loading Loading @@ -2182,9 +2252,9 @@ int32_t qpnp_adc_qrd_215_btm_scaler(struct qpnp_vadc_chip *chip, pr_debug("warm_temp:%d and cool_temp:%d\n", param->high_temp, param->low_temp); rc = qpnp_adc_map_voltage_temp( adcmap_batt_therm_qrd, ARRAY_SIZE(adcmap_batt_therm_qrd), rc = qpnp_adc_map_temp_voltage( adcmap_batt_therm_qrd_215, ARRAY_SIZE(adcmap_batt_therm_qrd_215), (param->low_temp), &low_output); if (rc) { Loading @@ -2197,9 +2267,9 @@ int32_t qpnp_adc_qrd_215_btm_scaler(struct qpnp_vadc_chip *chip, low_output = div64_s64(low_output, btm_param.adc_vref); low_output += btm_param.adc_gnd; rc = qpnp_adc_map_voltage_temp( adcmap_batt_therm_qrd, ARRAY_SIZE(adcmap_batt_therm_qrd), rc = qpnp_adc_map_temp_voltage( adcmap_batt_therm_qrd_215, ARRAY_SIZE(adcmap_batt_therm_qrd_215), (param->high_temp), &high_output); if (rc) { Loading
drivers/hwmon/qpnp-adc-voltage.c +1 −0 Original line number Diff line number Diff line Loading @@ -232,6 +232,7 @@ static struct qpnp_vadc_scale_fn vadc_scale_fn[] = { [SCALE_SMB1390_DIE_TEMP] = {qpnp_adc_scale_die_temp_1390}, [SCALE_BATT_THERM_TEMP_PU30] = {qpnp_adc_batt_therm_pu30}, [SCALE_BATT_THERM_TEMP_PU400] = {qpnp_adc_batt_therm_pu400}, [SCALE_BATT_THERM_TEMP_QRD_215] = {qpnp_adc_batt_therm_qrd_215} }; static struct qpnp_vadc_rscale_fn adc_vadc_rscale_fn[] = { Loading
include/linux/qpnp/qpnp-adc.h +26 −0 Original line number Diff line number Diff line Loading @@ -406,6 +406,8 @@ enum qpnp_adc_channel_scaling_param { * %SCALE_BATT_THERM_TEMP_PU400: Conversion to temperature(decidegC) for 400k * pullup. * %SCALE_SMB1390_DIE_TEMP: Conversion for SMB1390 die temp * %SCALE_BATT_THERM_TEMP_QRD_215: Conversion to temperature(decidegC) based on * btm parameters for QRD. * %SCALE_NONE: Do not use this scaling type. */ enum qpnp_adc_scale_fn_type { Loading @@ -432,6 +434,7 @@ enum qpnp_adc_scale_fn_type { SCALE_SMB1390_DIE_TEMP, SCALE_BATT_THERM_TEMP_PU30, SCALE_BATT_THERM_TEMP_PU400, SCALE_BATT_THERM_TEMP_QRD_215, SCALE_NONE, }; Loading Loading @@ -1509,6 +1512,23 @@ int32_t qpnp_adc_batt_therm_pu400(struct qpnp_vadc_chip *dev, const struct qpnp_adc_properties *adc_prop, const struct qpnp_vadc_chan_properties *chan_prop, struct qpnp_vadc_result *chan_rslt); /** * qpnp_adc_batt_therm_qrd_215() - Scales the pre-calibrated digital output * of an ADC to the ADC reference and compensates for the * gain and offset. Returns the temperature in decidegC for QRD. * @dev: Structure device for qpnp vadc * @adc_code: pre-calibrated digital output of the ADC. * @adc_prop: adc properties of the pm8xxx adc such as bit resolution, * reference voltage. * @chan_prop: individual channel properties to compensate the i/p scaling, * slope and offset. * @chan_rslt: physical result to be stored. */ int32_t qpnp_adc_batt_therm_qrd_215(struct qpnp_vadc_chip *dev, int32_t adc_code, const struct qpnp_adc_properties *adc_prop, const struct qpnp_vadc_chan_properties *chan_prop, struct qpnp_vadc_result *chan_rslt); /** * qpnp_adc_scale_batt_therm() - Scales the pre-calibrated digital output * of an ADC to the ADC reference and compensates for the Loading Loading @@ -2164,6 +2184,12 @@ static inline int32_t qpnp_adc_batt_therm_pu400(struct qpnp_vadc_chip *vadc, const struct qpnp_vadc_chan_properties *chan_prop, struct qpnp_vadc_result *chan_rslt) { return -ENXIO; } static inline int32_t qpnp_adc_batt_therm_qrd_215(struct qpnp_vadc_chip *vadc, int32_t adc_code, const struct qpnp_adc_properties *adc_prop, const struct qpnp_vadc_chan_properties *chan_prop, struct qpnp_vadc_result *chan_rslt) { return -ENXIO; } static inline int32_t qpnp_adc_scale_batt_therm(struct qpnp_vadc_chip *vadc, int32_t adc_code, const struct qpnp_adc_properties *adc_prop, Loading