Loading drivers/hwmon/qpnp-adc-common.c +53 −0 Original line number Diff line number Diff line Loading @@ -1122,6 +1122,59 @@ int32_t qpnp_adc_btm_scaler(struct qpnp_vadc_chip *chip, } EXPORT_SYMBOL(qpnp_adc_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) { 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_smb_batt_therm, ARRAY_SIZE(adcmap_smb_batt_therm), (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_smb_batt_therm, ARRAY_SIZE(adcmap_smb_batt_therm), (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_smb_btm_rscaler); int32_t qpnp_vadc_check_result(int32_t *data) { if (*data < QPNP_VADC_MIN_ADC_CODE) Loading drivers/thermal/qpnp-adc-tm.c +1 −0 Original line number Diff line number Diff line Loading @@ -286,6 +286,7 @@ static struct qpnp_adc_tm_reverse_scale_fn adc_tm_rscale_fn[] = { [SCALE_RBATT_THERM] = {qpnp_adc_btm_scaler}, [SCALE_R_USB_ID] = {qpnp_adc_usb_scaler}, [SCALE_RPMIC_THERM] = {qpnp_adc_scale_millidegc_pmic_voltage_thr}, [SCALE_R_SMB_BATT_THERM] = {qpnp_adc_smb_btm_rscaler}, [SCALE_R_ABSOLUTE] = {qpnp_adc_absolute_rthr}, }; Loading include/linux/qpnp/qpnp-adc.h +20 −0 Original line number Diff line number Diff line Loading @@ -1401,6 +1401,22 @@ int32_t qpnp_adc_vbatt_rscaler(struct qpnp_vadc_chip *dev, int32_t qpnp_adc_absolute_rthr(struct qpnp_vadc_chip *dev, struct qpnp_adc_tm_btm_param *param, uint32_t *low_threshold, uint32_t *high_threshold); /** * qpnp_adc_smb_btm_rscaler() - 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. * @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_smb_btm_rscaler(struct qpnp_vadc_chip *dev, struct qpnp_adc_tm_btm_param *param, uint32_t *low_threshold, uint32_t *high_threshold); /** * qpnp_vadc_iadc_sync_request() - Performs Voltage ADC read and * locks the peripheral. When performing simultaneous Loading Loading @@ -1547,6 +1563,10 @@ static inline int32_t qpnp_adc_tm_scale_voltage_therm_pu2( struct qpnp_vadc_chip *dev, uint32_t reg, int64_t *result) { return -ENXIO; } static inline int32_t qpnp_adc_smb_btm_rscaler(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_vadc_iadc_sync_request(struct qpnp_vadc_chip *dev, enum qpnp_vadc_channels channel) { return -ENXIO; } Loading Loading
drivers/hwmon/qpnp-adc-common.c +53 −0 Original line number Diff line number Diff line Loading @@ -1122,6 +1122,59 @@ int32_t qpnp_adc_btm_scaler(struct qpnp_vadc_chip *chip, } EXPORT_SYMBOL(qpnp_adc_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) { 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_smb_batt_therm, ARRAY_SIZE(adcmap_smb_batt_therm), (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_smb_batt_therm, ARRAY_SIZE(adcmap_smb_batt_therm), (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_smb_btm_rscaler); int32_t qpnp_vadc_check_result(int32_t *data) { if (*data < QPNP_VADC_MIN_ADC_CODE) Loading
drivers/thermal/qpnp-adc-tm.c +1 −0 Original line number Diff line number Diff line Loading @@ -286,6 +286,7 @@ static struct qpnp_adc_tm_reverse_scale_fn adc_tm_rscale_fn[] = { [SCALE_RBATT_THERM] = {qpnp_adc_btm_scaler}, [SCALE_R_USB_ID] = {qpnp_adc_usb_scaler}, [SCALE_RPMIC_THERM] = {qpnp_adc_scale_millidegc_pmic_voltage_thr}, [SCALE_R_SMB_BATT_THERM] = {qpnp_adc_smb_btm_rscaler}, [SCALE_R_ABSOLUTE] = {qpnp_adc_absolute_rthr}, }; Loading
include/linux/qpnp/qpnp-adc.h +20 −0 Original line number Diff line number Diff line Loading @@ -1401,6 +1401,22 @@ int32_t qpnp_adc_vbatt_rscaler(struct qpnp_vadc_chip *dev, int32_t qpnp_adc_absolute_rthr(struct qpnp_vadc_chip *dev, struct qpnp_adc_tm_btm_param *param, uint32_t *low_threshold, uint32_t *high_threshold); /** * qpnp_adc_smb_btm_rscaler() - 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. * @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_smb_btm_rscaler(struct qpnp_vadc_chip *dev, struct qpnp_adc_tm_btm_param *param, uint32_t *low_threshold, uint32_t *high_threshold); /** * qpnp_vadc_iadc_sync_request() - Performs Voltage ADC read and * locks the peripheral. When performing simultaneous Loading Loading @@ -1547,6 +1563,10 @@ static inline int32_t qpnp_adc_tm_scale_voltage_therm_pu2( struct qpnp_vadc_chip *dev, uint32_t reg, int64_t *result) { return -ENXIO; } static inline int32_t qpnp_adc_smb_btm_rscaler(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_vadc_iadc_sync_request(struct qpnp_vadc_chip *dev, enum qpnp_vadc_channels channel) { return -ENXIO; } Loading