Loading drivers/hwmon/qpnp-adc-common.c +28 −0 Original line number Diff line number Diff line Loading @@ -2033,6 +2033,34 @@ int32_t qpnp_adc_scale_pmi_chg_temp(struct qpnp_vadc_chip *vadc, } EXPORT_SYMBOL(qpnp_adc_scale_pmi_chg_temp); int32_t qpnp_adc_scale_die_temp_1390(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) { int rc = 0; if (!chan_properties || !chan_properties->offset_gain_numerator || !chan_properties->offset_gain_denominator || !adc_properties || !adc_chan_result) return -EINVAL; rc = qpnp_adc_scale_default(chip, adc_code, adc_properties, chan_properties, adc_chan_result); if (rc < 0) return rc; pr_debug("raw_code:%x, v_adc:%lld\n", adc_code, adc_chan_result->physical); /* T = (1.49322 – V) / 0.00356 */ adc_chan_result->physical = 1493220 - adc_chan_result->physical; adc_chan_result->physical = div64_s64(adc_chan_result->physical, 356); return 0; } EXPORT_SYMBOL(qpnp_adc_scale_die_temp_1390); int32_t qpnp_adc_enable_voltage(struct qpnp_adc_drv *adc) { int rc = 0; Loading drivers/hwmon/qpnp-adc-voltage.c +1 −0 Original line number Diff line number Diff line Loading @@ -225,6 +225,7 @@ static struct qpnp_vadc_scale_fn vadc_scale_fn[] = { [SCALE_I_DEFAULT] = {qpnp_iadc_scale_default}, [SCALE_USBIN_I] = {qpnp_adc_scale_usbin_curr}, [SCALE_BATT_THERM_TEMP_QRD] = {qpnp_adc_batt_therm_qrd}, [SCALE_SMB1390_DIE_TEMP] = {qpnp_adc_scale_die_temp_1390}, }; static struct qpnp_vadc_rscale_fn adc_vadc_rscale_fn[] = { Loading include/linux/qpnp/qpnp-adc.h +27 −0 Original line number Diff line number Diff line Loading @@ -390,6 +390,7 @@ enum qpnp_adc_channel_scaling_param { * %SCALE_USBIN_I: Conversion for USB input current. * %SCALE_BATT_THERM_TEMP_QRD: Conversion to temperature(decidegC) based on btm * parameters for QRD. * %SCALE_SMB1390_DIE_TEMP: Conversion for SMB1390 die temp * %SCALE_NONE: Do not use this scaling type. */ enum qpnp_adc_scale_fn_type { Loading @@ -413,6 +414,7 @@ enum qpnp_adc_scale_fn_type { SCALE_I_DEFAULT, SCALE_USBIN_I, SCALE_BATT_THERM_TEMP_QRD, SCALE_SMB1390_DIE_TEMP, SCALE_NONE, }; Loading Loading @@ -1711,6 +1713,25 @@ int32_t qpnp_adc_scale_therm_ncp03(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_die_temp_1390() - Scales the pre-calibrated digital output * of an ADC to the ADC reference and compensates for the * gain and offset. The voltage measured by HKADC is related to * the junction temperature according to * V_adc = 1.496 – 0.00381*Tj * @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_scale_die_temp_1390(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_get_vadc() - Clients need to register with the vadc using the * corresponding device instance it wants to read the channels Loading Loading @@ -2149,6 +2170,12 @@ static inline int32_t qpnp_adc_scale_therm_ncp03(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_scale_die_temp_1390(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 struct qpnp_vadc_chip *qpnp_get_vadc(struct device *dev, const char *name) { return ERR_PTR(-ENXIO); } Loading Loading
drivers/hwmon/qpnp-adc-common.c +28 −0 Original line number Diff line number Diff line Loading @@ -2033,6 +2033,34 @@ int32_t qpnp_adc_scale_pmi_chg_temp(struct qpnp_vadc_chip *vadc, } EXPORT_SYMBOL(qpnp_adc_scale_pmi_chg_temp); int32_t qpnp_adc_scale_die_temp_1390(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) { int rc = 0; if (!chan_properties || !chan_properties->offset_gain_numerator || !chan_properties->offset_gain_denominator || !adc_properties || !adc_chan_result) return -EINVAL; rc = qpnp_adc_scale_default(chip, adc_code, adc_properties, chan_properties, adc_chan_result); if (rc < 0) return rc; pr_debug("raw_code:%x, v_adc:%lld\n", adc_code, adc_chan_result->physical); /* T = (1.49322 – V) / 0.00356 */ adc_chan_result->physical = 1493220 - adc_chan_result->physical; adc_chan_result->physical = div64_s64(adc_chan_result->physical, 356); return 0; } EXPORT_SYMBOL(qpnp_adc_scale_die_temp_1390); int32_t qpnp_adc_enable_voltage(struct qpnp_adc_drv *adc) { int rc = 0; Loading
drivers/hwmon/qpnp-adc-voltage.c +1 −0 Original line number Diff line number Diff line Loading @@ -225,6 +225,7 @@ static struct qpnp_vadc_scale_fn vadc_scale_fn[] = { [SCALE_I_DEFAULT] = {qpnp_iadc_scale_default}, [SCALE_USBIN_I] = {qpnp_adc_scale_usbin_curr}, [SCALE_BATT_THERM_TEMP_QRD] = {qpnp_adc_batt_therm_qrd}, [SCALE_SMB1390_DIE_TEMP] = {qpnp_adc_scale_die_temp_1390}, }; static struct qpnp_vadc_rscale_fn adc_vadc_rscale_fn[] = { Loading
include/linux/qpnp/qpnp-adc.h +27 −0 Original line number Diff line number Diff line Loading @@ -390,6 +390,7 @@ enum qpnp_adc_channel_scaling_param { * %SCALE_USBIN_I: Conversion for USB input current. * %SCALE_BATT_THERM_TEMP_QRD: Conversion to temperature(decidegC) based on btm * parameters for QRD. * %SCALE_SMB1390_DIE_TEMP: Conversion for SMB1390 die temp * %SCALE_NONE: Do not use this scaling type. */ enum qpnp_adc_scale_fn_type { Loading @@ -413,6 +414,7 @@ enum qpnp_adc_scale_fn_type { SCALE_I_DEFAULT, SCALE_USBIN_I, SCALE_BATT_THERM_TEMP_QRD, SCALE_SMB1390_DIE_TEMP, SCALE_NONE, }; Loading Loading @@ -1711,6 +1713,25 @@ int32_t qpnp_adc_scale_therm_ncp03(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_die_temp_1390() - Scales the pre-calibrated digital output * of an ADC to the ADC reference and compensates for the * gain and offset. The voltage measured by HKADC is related to * the junction temperature according to * V_adc = 1.496 – 0.00381*Tj * @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_scale_die_temp_1390(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_get_vadc() - Clients need to register with the vadc using the * corresponding device instance it wants to read the channels Loading Loading @@ -2149,6 +2170,12 @@ static inline int32_t qpnp_adc_scale_therm_ncp03(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_scale_die_temp_1390(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 struct qpnp_vadc_chip *qpnp_get_vadc(struct device *dev, const char *name) { return ERR_PTR(-ENXIO); } Loading