Loading drivers/hwmon/qpnp-adc-common.c +104 −0 Original line number Diff line number Diff line Loading @@ -350,6 +350,38 @@ static const struct qpnp_vadc_map_pt adcmap_qrd_skuh_btm_threshold[] = { {880, 520}, }; static const struct qpnp_vadc_map_pt adcmap_qrd_skut1_btm_threshold[] = { {-400, 1759}, {-350, 1742}, {-300, 1720}, {-250, 1691}, {-200, 1654}, {-150, 1619}, {-100, 1556}, {-50, 1493}, {0, 1422}, {50, 1345}, {100, 1264}, {150, 1180}, {200, 1097}, {250, 1017}, {300, 942}, {350, 873}, {400, 810}, {450, 754}, {500, 706}, {550, 664}, {600, 627}, {650, 596}, {700, 570}, {750, 547}, {800, 528}, {850, 512}, {900, 499}, {950, 487}, {1000, 477}, }; /* Voltage to temperature */ static const struct qpnp_vadc_map_pt adcmap_100k_104ef_104fb[] = { {1758, -40}, Loading Loading @@ -895,6 +927,25 @@ int32_t qpnp_adc_scale_qrd_skuh_batt_therm(struct qpnp_vadc_chip *chip, } EXPORT_SYMBOL(qpnp_adc_scale_qrd_skuh_batt_therm); int32_t qpnp_adc_scale_qrd_skut1_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_skut1_btm_threshold, ARRAY_SIZE(adcmap_qrd_skut1_btm_threshold), bat_voltage, &adc_chan_result->physical); } EXPORT_SYMBOL(qpnp_adc_scale_qrd_skut1_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 Loading @@ -1372,6 +1423,59 @@ int32_t qpnp_adc_qrd_skuh_btm_scaler(struct qpnp_vadc_chip *chip, } EXPORT_SYMBOL(qpnp_adc_qrd_skuh_btm_scaler); int32_t qpnp_adc_qrd_skut1_btm_scaler(struct qpnp_vadc_chip *chip, struct qpnp_adc_tm_btm_param *param, uint32_t *low_threshold, uint32_t *high_threshold) { struct qpnp_vadc_linear_graph btm_param; int64_t low_output = 0, high_output = 0; int rc = 0; qpnp_get_vadc_gain_and_offset(chip, &btm_param, CALIB_RATIOMETRIC); pr_debug("warm_temp:%d and cool_temp:%d\n", param->high_temp, param->low_temp); rc = qpnp_adc_map_voltage_temp( adcmap_qrd_skut1_btm_threshold, ARRAY_SIZE(adcmap_qrd_skut1_btm_threshold), (param->low_temp), &low_output); if (rc) { pr_debug("low_temp mapping failed with %d\n", rc); return rc; } pr_debug("low_output:%lld\n", low_output); low_output *= btm_param.dy; do_div(low_output, btm_param.adc_vref); low_output += btm_param.adc_gnd; rc = qpnp_adc_map_voltage_temp( adcmap_qrd_skut1_btm_threshold, ARRAY_SIZE(adcmap_qrd_skut1_btm_threshold), (param->high_temp), &high_output); if (rc) { pr_debug("high temp mapping failed with %d\n", rc); return rc; } pr_debug("high_output:%lld\n", high_output); high_output *= btm_param.dy; do_div(high_output, btm_param.adc_vref); high_output += btm_param.adc_gnd; /* btm low temperature correspondes to high voltage threshold */ *low_threshold = high_output; /* btm high temperature correspondes to low voltage threshold */ *high_threshold = low_output; pr_debug("high_volt:%d, low_volt:%d\n", *high_threshold, *low_threshold); return 0; } EXPORT_SYMBOL(qpnp_adc_qrd_skut1_btm_scaler); int32_t qpnp_adc_smb_btm_rscaler(struct qpnp_vadc_chip *chip, struct qpnp_adc_tm_btm_param *param, uint32_t *low_threshold, uint32_t *high_threshold) Loading drivers/hwmon/qpnp-adc-voltage.c +1 −0 Original line number Diff line number Diff line Loading @@ -161,6 +161,7 @@ static struct qpnp_vadc_scale_fn vadc_scale_fn[] = { [SCALE_QRD_SKUG_BATT_THERM] = {qpnp_adc_scale_qrd_skug_batt_therm}, [SCALE_QRD_SKUH_BATT_THERM] = {qpnp_adc_scale_qrd_skuh_batt_therm}, [SCALE_NCP_03WF683_THERM] = {qpnp_adc_scale_therm_ncp03}, [SCALE_QRD_SKUT1_BATT_THERM] = {qpnp_adc_scale_qrd_skut1_batt_therm}, }; static struct qpnp_vadc_rscale_fn adc_vadc_rscale_fn[] = { Loading drivers/thermal/qpnp-adc-tm.c +1 −0 Original line number Diff line number Diff line Loading @@ -292,6 +292,7 @@ static struct qpnp_adc_tm_reverse_scale_fn adc_tm_rscale_fn[] = { [SCALE_R_SMB_BATT_THERM] = {qpnp_adc_smb_btm_rscaler}, [SCALE_R_ABSOLUTE] = {qpnp_adc_absolute_rthr}, [SCALE_QRD_SKUH_RBATT_THERM] = {qpnp_adc_qrd_skuh_btm_scaler}, [SCALE_QRD_SKUT1_RBATT_THERM] = {qpnp_adc_qrd_skut1_btm_scaler}, }; static int32_t qpnp_adc_tm_read_reg(struct qpnp_adc_tm_chip *chip, Loading include/linux/qpnp/qpnp-adc.h +47 −0 Original line number Diff line number Diff line Loading @@ -251,6 +251,8 @@ enum qpnp_adc_channel_scaling_param { * btm parameters for SKUG. * %SCALE_QRD_SKUH_BATT_THERM: Conversion to temperature(decidegC) based on * btm parameters for SKUH * %SCALE_QRD_SKUT1_BATT_THERM: Conversion to temperature(decidegC) based on * btm parameters for SKUT1 * %SCALE_NONE: Do not use this scaling type. */ enum qpnp_adc_scale_fn_type { Loading @@ -266,6 +268,7 @@ enum qpnp_adc_scale_fn_type { SCALE_QRD_SKUG_BATT_THERM, SCALE_QRD_SKUH_BATT_THERM, SCALE_NCP_03WF683_THERM, SCALE_QRD_SKUT1_BATT_THERM, SCALE_NONE, }; Loading @@ -288,6 +291,7 @@ enum qpnp_adc_tm_rscale_fn_type { SCALE_R_SMB_BATT_THERM, SCALE_R_ABSOLUTE, SCALE_QRD_SKUH_RBATT_THERM, SCALE_QRD_SKUT1_RBATT_THERM, SCALE_RSCALE_NONE, }; Loading Loading @@ -1250,6 +1254,23 @@ int32_t qpnp_adc_scale_qrd_skuh_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_skut1_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_skut1_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 @@ -1437,6 +1458,22 @@ int32_t qpnp_adc_btm_scaler(struct qpnp_vadc_chip *dev, int32_t qpnp_adc_qrd_skuh_btm_scaler(struct qpnp_vadc_chip *dev, struct qpnp_adc_tm_btm_param *param, uint32_t *low_threshold, uint32_t *high_threshold); /** * qpnp_adc_qrd_skut1_btm_scaler() - Performs reverse calibration on the low/high * temperature threshold values passed by the client. * The function maps the temperature to voltage and applies * ratiometric calibration on the voltage values for SKUT1 board. * @dev: Structure device for qpnp vadc * @param: The input parameters that contain the low/high temperature * values. * @low_threshold: The low threshold value that needs to be updated with * the above calibrated voltage value. * @high_threshold: The low threshold value that needs to be updated with * the above calibrated voltage value. */ int32_t qpnp_adc_qrd_skut1_btm_scaler(struct qpnp_vadc_chip *dev, struct qpnp_adc_tm_btm_param *param, uint32_t *low_threshold, uint32_t *high_threshold); /** * qpnp_adc_tm_scale_therm_voltage_pu2() - Performs reverse calibration * and convert given temperature to voltage on supported Loading Loading @@ -1662,6 +1699,12 @@ static inline int32_t qpnp_adc_scale_qrd_skuh_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_skut1_batt_therm( struct qpnp_vadc_chip *vdev, 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 @@ -1730,6 +1773,10 @@ static inline int32_t qpnp_adc_qrd_skuh_btm_scaler(struct qpnp_vadc_chip *dev, struct qpnp_adc_tm_btm_param *param, uint32_t *low_threshold, uint32_t *high_threshold) { return -ENXIO; } static inline int32_t qpnp_adc_qrd_skut1_btm_scaler(struct qpnp_vadc_chip *dev, struct qpnp_adc_tm_btm_param *param, uint32_t *low_threshold, uint32_t *high_threshold) { return -ENXIO; } static inline int32_t qpnp_adc_scale_millidegc_pmic_voltage_thr( struct qpnp_vadc_chip *dev, struct qpnp_adc_tm_btm_param *param, Loading Loading
drivers/hwmon/qpnp-adc-common.c +104 −0 Original line number Diff line number Diff line Loading @@ -350,6 +350,38 @@ static const struct qpnp_vadc_map_pt adcmap_qrd_skuh_btm_threshold[] = { {880, 520}, }; static const struct qpnp_vadc_map_pt adcmap_qrd_skut1_btm_threshold[] = { {-400, 1759}, {-350, 1742}, {-300, 1720}, {-250, 1691}, {-200, 1654}, {-150, 1619}, {-100, 1556}, {-50, 1493}, {0, 1422}, {50, 1345}, {100, 1264}, {150, 1180}, {200, 1097}, {250, 1017}, {300, 942}, {350, 873}, {400, 810}, {450, 754}, {500, 706}, {550, 664}, {600, 627}, {650, 596}, {700, 570}, {750, 547}, {800, 528}, {850, 512}, {900, 499}, {950, 487}, {1000, 477}, }; /* Voltage to temperature */ static const struct qpnp_vadc_map_pt adcmap_100k_104ef_104fb[] = { {1758, -40}, Loading Loading @@ -895,6 +927,25 @@ int32_t qpnp_adc_scale_qrd_skuh_batt_therm(struct qpnp_vadc_chip *chip, } EXPORT_SYMBOL(qpnp_adc_scale_qrd_skuh_batt_therm); int32_t qpnp_adc_scale_qrd_skut1_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_skut1_btm_threshold, ARRAY_SIZE(adcmap_qrd_skut1_btm_threshold), bat_voltage, &adc_chan_result->physical); } EXPORT_SYMBOL(qpnp_adc_scale_qrd_skut1_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 Loading @@ -1372,6 +1423,59 @@ int32_t qpnp_adc_qrd_skuh_btm_scaler(struct qpnp_vadc_chip *chip, } EXPORT_SYMBOL(qpnp_adc_qrd_skuh_btm_scaler); int32_t qpnp_adc_qrd_skut1_btm_scaler(struct qpnp_vadc_chip *chip, struct qpnp_adc_tm_btm_param *param, uint32_t *low_threshold, uint32_t *high_threshold) { struct qpnp_vadc_linear_graph btm_param; int64_t low_output = 0, high_output = 0; int rc = 0; qpnp_get_vadc_gain_and_offset(chip, &btm_param, CALIB_RATIOMETRIC); pr_debug("warm_temp:%d and cool_temp:%d\n", param->high_temp, param->low_temp); rc = qpnp_adc_map_voltage_temp( adcmap_qrd_skut1_btm_threshold, ARRAY_SIZE(adcmap_qrd_skut1_btm_threshold), (param->low_temp), &low_output); if (rc) { pr_debug("low_temp mapping failed with %d\n", rc); return rc; } pr_debug("low_output:%lld\n", low_output); low_output *= btm_param.dy; do_div(low_output, btm_param.adc_vref); low_output += btm_param.adc_gnd; rc = qpnp_adc_map_voltage_temp( adcmap_qrd_skut1_btm_threshold, ARRAY_SIZE(adcmap_qrd_skut1_btm_threshold), (param->high_temp), &high_output); if (rc) { pr_debug("high temp mapping failed with %d\n", rc); return rc; } pr_debug("high_output:%lld\n", high_output); high_output *= btm_param.dy; do_div(high_output, btm_param.adc_vref); high_output += btm_param.adc_gnd; /* btm low temperature correspondes to high voltage threshold */ *low_threshold = high_output; /* btm high temperature correspondes to low voltage threshold */ *high_threshold = low_output; pr_debug("high_volt:%d, low_volt:%d\n", *high_threshold, *low_threshold); return 0; } EXPORT_SYMBOL(qpnp_adc_qrd_skut1_btm_scaler); int32_t qpnp_adc_smb_btm_rscaler(struct qpnp_vadc_chip *chip, struct qpnp_adc_tm_btm_param *param, uint32_t *low_threshold, uint32_t *high_threshold) Loading
drivers/hwmon/qpnp-adc-voltage.c +1 −0 Original line number Diff line number Diff line Loading @@ -161,6 +161,7 @@ static struct qpnp_vadc_scale_fn vadc_scale_fn[] = { [SCALE_QRD_SKUG_BATT_THERM] = {qpnp_adc_scale_qrd_skug_batt_therm}, [SCALE_QRD_SKUH_BATT_THERM] = {qpnp_adc_scale_qrd_skuh_batt_therm}, [SCALE_NCP_03WF683_THERM] = {qpnp_adc_scale_therm_ncp03}, [SCALE_QRD_SKUT1_BATT_THERM] = {qpnp_adc_scale_qrd_skut1_batt_therm}, }; static struct qpnp_vadc_rscale_fn adc_vadc_rscale_fn[] = { Loading
drivers/thermal/qpnp-adc-tm.c +1 −0 Original line number Diff line number Diff line Loading @@ -292,6 +292,7 @@ static struct qpnp_adc_tm_reverse_scale_fn adc_tm_rscale_fn[] = { [SCALE_R_SMB_BATT_THERM] = {qpnp_adc_smb_btm_rscaler}, [SCALE_R_ABSOLUTE] = {qpnp_adc_absolute_rthr}, [SCALE_QRD_SKUH_RBATT_THERM] = {qpnp_adc_qrd_skuh_btm_scaler}, [SCALE_QRD_SKUT1_RBATT_THERM] = {qpnp_adc_qrd_skut1_btm_scaler}, }; static int32_t qpnp_adc_tm_read_reg(struct qpnp_adc_tm_chip *chip, Loading
include/linux/qpnp/qpnp-adc.h +47 −0 Original line number Diff line number Diff line Loading @@ -251,6 +251,8 @@ enum qpnp_adc_channel_scaling_param { * btm parameters for SKUG. * %SCALE_QRD_SKUH_BATT_THERM: Conversion to temperature(decidegC) based on * btm parameters for SKUH * %SCALE_QRD_SKUT1_BATT_THERM: Conversion to temperature(decidegC) based on * btm parameters for SKUT1 * %SCALE_NONE: Do not use this scaling type. */ enum qpnp_adc_scale_fn_type { Loading @@ -266,6 +268,7 @@ enum qpnp_adc_scale_fn_type { SCALE_QRD_SKUG_BATT_THERM, SCALE_QRD_SKUH_BATT_THERM, SCALE_NCP_03WF683_THERM, SCALE_QRD_SKUT1_BATT_THERM, SCALE_NONE, }; Loading @@ -288,6 +291,7 @@ enum qpnp_adc_tm_rscale_fn_type { SCALE_R_SMB_BATT_THERM, SCALE_R_ABSOLUTE, SCALE_QRD_SKUH_RBATT_THERM, SCALE_QRD_SKUT1_RBATT_THERM, SCALE_RSCALE_NONE, }; Loading Loading @@ -1250,6 +1254,23 @@ int32_t qpnp_adc_scale_qrd_skuh_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_skut1_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_skut1_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 @@ -1437,6 +1458,22 @@ int32_t qpnp_adc_btm_scaler(struct qpnp_vadc_chip *dev, int32_t qpnp_adc_qrd_skuh_btm_scaler(struct qpnp_vadc_chip *dev, struct qpnp_adc_tm_btm_param *param, uint32_t *low_threshold, uint32_t *high_threshold); /** * qpnp_adc_qrd_skut1_btm_scaler() - Performs reverse calibration on the low/high * temperature threshold values passed by the client. * The function maps the temperature to voltage and applies * ratiometric calibration on the voltage values for SKUT1 board. * @dev: Structure device for qpnp vadc * @param: The input parameters that contain the low/high temperature * values. * @low_threshold: The low threshold value that needs to be updated with * the above calibrated voltage value. * @high_threshold: The low threshold value that needs to be updated with * the above calibrated voltage value. */ int32_t qpnp_adc_qrd_skut1_btm_scaler(struct qpnp_vadc_chip *dev, struct qpnp_adc_tm_btm_param *param, uint32_t *low_threshold, uint32_t *high_threshold); /** * qpnp_adc_tm_scale_therm_voltage_pu2() - Performs reverse calibration * and convert given temperature to voltage on supported Loading Loading @@ -1662,6 +1699,12 @@ static inline int32_t qpnp_adc_scale_qrd_skuh_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_skut1_batt_therm( struct qpnp_vadc_chip *vdev, 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 @@ -1730,6 +1773,10 @@ static inline int32_t qpnp_adc_qrd_skuh_btm_scaler(struct qpnp_vadc_chip *dev, struct qpnp_adc_tm_btm_param *param, uint32_t *low_threshold, uint32_t *high_threshold) { return -ENXIO; } static inline int32_t qpnp_adc_qrd_skut1_btm_scaler(struct qpnp_vadc_chip *dev, struct qpnp_adc_tm_btm_param *param, uint32_t *low_threshold, uint32_t *high_threshold) { return -ENXIO; } static inline int32_t qpnp_adc_scale_millidegc_pmic_voltage_thr( struct qpnp_vadc_chip *dev, struct qpnp_adc_tm_btm_param *param, Loading