Loading Documentation/devicetree/bindings/hwmon/qpnp-adc-voltage.txt +2 −0 Original line number Diff line number Diff line Loading @@ -68,6 +68,8 @@ Required properties: 3 : Returns current across 0.1 ohm resistor. 4 : Returns XO thermistor voltage in degree's Centigrade. 5 : Returns result in degC for 150k pull-up. 9 : Conversion to temperature based on -15~55 allowable battery charging tempeature setting for btm parameters. - qcom,hw-settle-time : Settling period for the channel before ADC read. Select from the following unsigned int. 0 : 0us Loading arch/arm/boot/dts/qti/msm8926-qrd-skug-pvt.dts +7 −0 Original line number Diff line number Diff line Loading @@ -18,3 +18,10 @@ compatible = "qcom,msm8926-qrd", "qcom,msm8926", "qcom,qrd"; qcom,board-id = <0x2000b 5>; }; &pm8226_vadc { chan@30 { label = "batt_therm"; qcom,scale-function = <9>; }; }; drivers/hwmon/qpnp-adc-common.c +73 −0 Original line number Diff line number Diff line Loading @@ -238,6 +238,60 @@ static const struct qpnp_vadc_map_pt adcmap_qrd_skuaa_btm_threshold[] = { {800, 549}, }; static const struct qpnp_vadc_map_pt adcmap_qrd_skug_btm_threshold[] = { {-200, 1338}, {-180, 1307}, {-160, 1276}, {-140, 1244}, {-120, 1213}, {-100, 1182}, {-80, 1151}, {-60, 1121}, {-40, 1092}, {-20, 1063}, {0, 1035}, {20, 1008}, {40, 982}, {60, 957}, {80, 933}, {100, 910}, {120, 889}, {140, 868}, {160, 848}, {180, 830}, {200, 812}, {220, 795}, {240, 780}, {260, 765}, {280, 751}, {300, 738}, {320, 726}, {340, 714}, {360, 704}, {380, 694}, {400, 684}, {420, 675}, {440, 667}, {460, 659}, {480, 652}, {500, 645}, {520, 639}, {540, 633}, {560, 627}, {580, 622}, {600, 617}, {620, 613}, {640, 608}, {660, 604}, {680, 600}, {700, 597}, {720, 593}, {740, 590}, {760, 587}, {780, 585}, {800, 582}, }; /* Voltage to temperature */ static const struct qpnp_vadc_map_pt adcmap_100k_104ef_104fb[] = { {1758, -40}, Loading Loading @@ -699,6 +753,25 @@ int32_t qpnp_adc_scale_qrd_skuaa_batt_therm(struct qpnp_vadc_chip *chip, } EXPORT_SYMBOL(qpnp_adc_scale_qrd_skuaa_batt_therm); int32_t qpnp_adc_scale_qrd_skug_batt_therm(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 bat_voltage = 0; bat_voltage = qpnp_adc_scale_ratiometric_calib(adc_code, adc_properties, chan_properties); return qpnp_adc_map_temp_voltage( adcmap_qrd_skug_btm_threshold, ARRAY_SIZE(adcmap_qrd_skug_btm_threshold), bat_voltage, &adc_chan_result->physical); } EXPORT_SYMBOL(qpnp_adc_scale_qrd_skug_batt_therm); int32_t qpnp_adc_scale_smb_batt_therm(struct qpnp_vadc_chip *chip, int32_t adc_code, const struct qpnp_adc_properties *adc_properties, Loading drivers/hwmon/qpnp-adc-voltage.c +1 −0 Original line number Diff line number Diff line Loading @@ -130,6 +130,7 @@ static struct qpnp_vadc_scale_fn vadc_scale_fn[] = { [SCALE_QRD_BATT_THERM] = {qpnp_adc_scale_qrd_batt_therm}, [SCALE_QRD_SKUAA_BATT_THERM] = {qpnp_adc_scale_qrd_skuaa_batt_therm}, [SCALE_SMB_BATT_THERM] = {qpnp_adc_scale_smb_batt_therm}, [SCALE_QRD_SKUG_BATT_THERM] = {qpnp_adc_scale_qrd_skug_batt_therm}, }; static int32_t qpnp_vadc_read_reg(struct qpnp_vadc_chip *vadc, int16_t reg, Loading include/linux/qpnp/qpnp-adc.h +26 −0 Original line number Diff line number Diff line Loading @@ -223,6 +223,8 @@ enum qpnp_adc_channel_scaling_param { * btm parameters for SKUAA. * %SCALE_SMB_BATT_THERM: Conversion to temperature(decidegC) based on * btm parameters for SMB. * %SCALE_QRD_SKUG_BATT_THERM: Conversion to temperature(decidegC) based on * btm parametersi for SKUG. * %SCALE_NONE: Do not use this scaling type. */ enum qpnp_adc_scale_fn_type { Loading @@ -235,6 +237,7 @@ enum qpnp_adc_scale_fn_type { SCALE_QRD_BATT_THERM, SCALE_QRD_SKUAA_BATT_THERM, SCALE_SMB_BATT_THERM, SCALE_QRD_SKUG_BATT_THERM, SCALE_NONE, }; Loading Loading @@ -1149,6 +1152,23 @@ int32_t qpnp_adc_scale_qrd_skuaa_batt_therm(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_scale_qrd_skug_batt_therm() - 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. * @dev: Structure device for qpnp vadc * @adc_code: pre-calibrated digital ouput 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_scale_qrd_skug_batt_therm(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_smb_batt_therm() - Scales the pre-calibrated digital output * of an ADC to the ADC reference and compensates for the Loading Loading @@ -1427,6 +1447,12 @@ static inline int32_t qpnp_adc_scale_qrd_skuaa_batt_therm( const struct qpnp_vadc_chan_properties *chan_prop, struct qpnp_vadc_result *chan_rslt) { return -ENXIO; } static inline int32_t qpnp_adc_scale_qrd_skug_batt_therm( 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_smb_batt_therm(struct qpnp_vadc_chip *vadc, int32_t adc_code, const struct qpnp_adc_properties *adc_prop, Loading Loading
Documentation/devicetree/bindings/hwmon/qpnp-adc-voltage.txt +2 −0 Original line number Diff line number Diff line Loading @@ -68,6 +68,8 @@ Required properties: 3 : Returns current across 0.1 ohm resistor. 4 : Returns XO thermistor voltage in degree's Centigrade. 5 : Returns result in degC for 150k pull-up. 9 : Conversion to temperature based on -15~55 allowable battery charging tempeature setting for btm parameters. - qcom,hw-settle-time : Settling period for the channel before ADC read. Select from the following unsigned int. 0 : 0us Loading
arch/arm/boot/dts/qti/msm8926-qrd-skug-pvt.dts +7 −0 Original line number Diff line number Diff line Loading @@ -18,3 +18,10 @@ compatible = "qcom,msm8926-qrd", "qcom,msm8926", "qcom,qrd"; qcom,board-id = <0x2000b 5>; }; &pm8226_vadc { chan@30 { label = "batt_therm"; qcom,scale-function = <9>; }; };
drivers/hwmon/qpnp-adc-common.c +73 −0 Original line number Diff line number Diff line Loading @@ -238,6 +238,60 @@ static const struct qpnp_vadc_map_pt adcmap_qrd_skuaa_btm_threshold[] = { {800, 549}, }; static const struct qpnp_vadc_map_pt adcmap_qrd_skug_btm_threshold[] = { {-200, 1338}, {-180, 1307}, {-160, 1276}, {-140, 1244}, {-120, 1213}, {-100, 1182}, {-80, 1151}, {-60, 1121}, {-40, 1092}, {-20, 1063}, {0, 1035}, {20, 1008}, {40, 982}, {60, 957}, {80, 933}, {100, 910}, {120, 889}, {140, 868}, {160, 848}, {180, 830}, {200, 812}, {220, 795}, {240, 780}, {260, 765}, {280, 751}, {300, 738}, {320, 726}, {340, 714}, {360, 704}, {380, 694}, {400, 684}, {420, 675}, {440, 667}, {460, 659}, {480, 652}, {500, 645}, {520, 639}, {540, 633}, {560, 627}, {580, 622}, {600, 617}, {620, 613}, {640, 608}, {660, 604}, {680, 600}, {700, 597}, {720, 593}, {740, 590}, {760, 587}, {780, 585}, {800, 582}, }; /* Voltage to temperature */ static const struct qpnp_vadc_map_pt adcmap_100k_104ef_104fb[] = { {1758, -40}, Loading Loading @@ -699,6 +753,25 @@ int32_t qpnp_adc_scale_qrd_skuaa_batt_therm(struct qpnp_vadc_chip *chip, } EXPORT_SYMBOL(qpnp_adc_scale_qrd_skuaa_batt_therm); int32_t qpnp_adc_scale_qrd_skug_batt_therm(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 bat_voltage = 0; bat_voltage = qpnp_adc_scale_ratiometric_calib(adc_code, adc_properties, chan_properties); return qpnp_adc_map_temp_voltage( adcmap_qrd_skug_btm_threshold, ARRAY_SIZE(adcmap_qrd_skug_btm_threshold), bat_voltage, &adc_chan_result->physical); } EXPORT_SYMBOL(qpnp_adc_scale_qrd_skug_batt_therm); int32_t qpnp_adc_scale_smb_batt_therm(struct qpnp_vadc_chip *chip, int32_t adc_code, const struct qpnp_adc_properties *adc_properties, Loading
drivers/hwmon/qpnp-adc-voltage.c +1 −0 Original line number Diff line number Diff line Loading @@ -130,6 +130,7 @@ static struct qpnp_vadc_scale_fn vadc_scale_fn[] = { [SCALE_QRD_BATT_THERM] = {qpnp_adc_scale_qrd_batt_therm}, [SCALE_QRD_SKUAA_BATT_THERM] = {qpnp_adc_scale_qrd_skuaa_batt_therm}, [SCALE_SMB_BATT_THERM] = {qpnp_adc_scale_smb_batt_therm}, [SCALE_QRD_SKUG_BATT_THERM] = {qpnp_adc_scale_qrd_skug_batt_therm}, }; static int32_t qpnp_vadc_read_reg(struct qpnp_vadc_chip *vadc, int16_t reg, Loading
include/linux/qpnp/qpnp-adc.h +26 −0 Original line number Diff line number Diff line Loading @@ -223,6 +223,8 @@ enum qpnp_adc_channel_scaling_param { * btm parameters for SKUAA. * %SCALE_SMB_BATT_THERM: Conversion to temperature(decidegC) based on * btm parameters for SMB. * %SCALE_QRD_SKUG_BATT_THERM: Conversion to temperature(decidegC) based on * btm parametersi for SKUG. * %SCALE_NONE: Do not use this scaling type. */ enum qpnp_adc_scale_fn_type { Loading @@ -235,6 +237,7 @@ enum qpnp_adc_scale_fn_type { SCALE_QRD_BATT_THERM, SCALE_QRD_SKUAA_BATT_THERM, SCALE_SMB_BATT_THERM, SCALE_QRD_SKUG_BATT_THERM, SCALE_NONE, }; Loading Loading @@ -1149,6 +1152,23 @@ int32_t qpnp_adc_scale_qrd_skuaa_batt_therm(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_scale_qrd_skug_batt_therm() - 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. * @dev: Structure device for qpnp vadc * @adc_code: pre-calibrated digital ouput 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_scale_qrd_skug_batt_therm(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_smb_batt_therm() - Scales the pre-calibrated digital output * of an ADC to the ADC reference and compensates for the Loading Loading @@ -1427,6 +1447,12 @@ static inline int32_t qpnp_adc_scale_qrd_skuaa_batt_therm( const struct qpnp_vadc_chan_properties *chan_prop, struct qpnp_vadc_result *chan_rslt) { return -ENXIO; } static inline int32_t qpnp_adc_scale_qrd_skug_batt_therm( 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_smb_batt_therm(struct qpnp_vadc_chip *vadc, int32_t adc_code, const struct qpnp_adc_properties *adc_prop, Loading