Loading drivers/hwmon/qpnp-adc-common.c +204 −0 Original line number Diff line number Diff line Loading @@ -751,6 +751,154 @@ 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_pu30[] = { {1842, -400}, {1838, -380}, {1833, -360}, {1828, -340}, {1822, -320}, {1816, -300}, {1809, -280}, {1801, -260}, {1793, -240}, {1784, -220}, {1774, -200}, {1763, -180}, {1752, -160}, {1739, -140}, {1726, -120}, {1712, -100}, {1697, -80}, {1680, -60}, {1663, -40}, {1645, -20}, {1625, 0}, {1605, 20}, {1583, 40}, {1561, 60}, {1537, 80}, {1513, 100}, {1487, 120}, {1461, 140}, {1433, 160}, {1405, 180}, {1376, 200}, {1347, 220}, {1316, 240}, {1286, 260}, {1254, 280}, {1223, 300}, {1191, 320}, {1159, 340}, {1126, 360}, {1094, 380}, {1062, 400}, {1029, 420}, {997, 440}, {966, 460}, {934, 480}, {903, 500}, {873, 520}, {843, 540}, {813, 560}, {784, 580}, {756, 600}, {728, 620}, {702, 640}, {675, 660}, {650, 680}, {625, 700}, {601, 720}, {578, 740}, {556, 760}, {534, 780}, {513, 800}, {493, 820}, {474, 840}, {455, 860}, {437, 880}, {420, 900}, {403, 920}, {387, 940}, {372, 960}, {357, 980} }; /* Voltage to temp0erature */ static const struct qpnp_vadc_map_pt adcmap_batt_therm_pu400[] = { {1516, -400}, {1478, -380}, {1438, -360}, {1396, -340}, {1353, -320}, {1307, -300}, {1261, -280}, {1213, -260}, {1164, -240}, {1115, -220}, {1066, -200}, {1017, -180}, {968, -160}, {920, -140}, {872, -120}, {826, -100}, {781, -80}, {737, -60}, {694, -40}, {654, -20}, {615, 0}, {578, 20}, {542, 40}, {509, 60}, {477, 80}, {447, 100}, {419, 120}, {392, 140}, {367, 160}, {343, 180}, {321, 200}, {301, 220}, {282, 240}, {264, 260}, {247, 280}, {231, 300}, {216, 320}, {203, 340}, {190, 360}, {178, 380}, {167, 400}, {157, 420}, {147, 440}, {138, 460}, {130, 480}, {122, 500}, {115, 520}, {108, 540}, {102, 560}, {96, 580}, {90, 600}, {85, 620}, {80, 640}, {76, 660}, {72, 680}, {68, 700}, {64, 720}, {61, 740}, {57, 760}, {54, 780}, {52, 800}, {49, 820}, {46, 840}, {44, 860}, {42, 880}, {40, 900}, {38, 920}, {36, 940}, {34, 960}, {32, 980} }; /* * Voltage to temperature table for 100k pull up for NTCG104EF104 with * 1.875V reference. Loading Loading @@ -1120,6 +1268,62 @@ int32_t qpnp_adc_batt_therm_qrd(struct qpnp_vadc_chip *chip, } EXPORT_SYMBOL(qpnp_adc_batt_therm_qrd); int32_t qpnp_adc_batt_therm_pu30(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; /* (code * vref_vadc (1.875V) * 1000) / (scale_code * 1000) */ if (adc_code > QPNP_VADC_HC_MAX_CODE) adc_code = 0; batt_thm_voltage = (int64_t) adc_code; batt_thm_voltage *= (adc_properties->adc_vdd_reference * 1000); batt_thm_voltage = div64_s64(batt_thm_voltage, adc_properties->full_scale_code * 1000); qpnp_adc_map_voltage_temp(adcmap_batt_therm_pu30, ARRAY_SIZE(adcmap_batt_therm_pu30), batt_thm_voltage, &adc_chan_result->physical); return 0; } EXPORT_SYMBOL(qpnp_adc_batt_therm_pu30); int32_t qpnp_adc_batt_therm_pu400(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; /* (code * vref_vadc (1.875V) * 1000) / (scale_code * 1000) */ if (adc_code > QPNP_VADC_HC_MAX_CODE) adc_code = 0; batt_thm_voltage = (int64_t) adc_code; batt_thm_voltage *= (adc_properties->adc_vdd_reference * 1000); batt_thm_voltage = div64_s64(batt_thm_voltage, adc_properties->full_scale_code * 1000); qpnp_adc_map_voltage_temp(adcmap_batt_therm_pu400, ARRAY_SIZE(adcmap_batt_therm_pu400), batt_thm_voltage, &adc_chan_result->physical); return 0; } EXPORT_SYMBOL(qpnp_adc_batt_therm_pu400); int32_t qpnp_adc_scale_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 +2 −0 Original line number Diff line number Diff line Loading @@ -228,6 +228,8 @@ static struct qpnp_vadc_scale_fn vadc_scale_fn[] = { [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}, [SCALE_BATT_THERM_TEMP_PU30] = {qpnp_adc_batt_therm_pu30}, [SCALE_BATT_THERM_TEMP_PU400] = {qpnp_adc_batt_therm_pu400}, }; static struct qpnp_vadc_rscale_fn adc_vadc_rscale_fn[] = { Loading include/linux/qpnp/qpnp-adc.h +55 −1 Original line number Diff line number Diff line Loading @@ -401,6 +401,10 @@ 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_BATT_THERM_TEMP_PU30: Conversion to temperature(decidegC) for 30k * pullup. * %SCALE_BATT_THERM_TEMP_PU400: Conversion to temperature(decidegC) for 400k * pullup. * %SCALE_SMB1390_DIE_TEMP: Conversion for SMB1390 die temp * %SCALE_NONE: Do not use this scaling type. */ Loading @@ -426,6 +430,8 @@ enum qpnp_adc_scale_fn_type { SCALE_USBIN_I, SCALE_BATT_THERM_TEMP_QRD, SCALE_SMB1390_DIE_TEMP, SCALE_BATT_THERM_TEMP_PU30, SCALE_BATT_THERM_TEMP_PU400, SCALE_NONE, }; Loading Loading @@ -1465,9 +1471,10 @@ int32_t qpnp_adc_batt_therm_qrd(struct qpnp_vadc_chip *dev, 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 * qpnp_adc_batt_therm_pu30() - 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. * It uses a mapping table computed for a 30K pull-up. * @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, Loading @@ -1476,6 +1483,41 @@ int32_t qpnp_adc_batt_therm_qrd(struct qpnp_vadc_chip *dev, * slope and offset. * @chan_rslt: physical result to be stored. */ int32_t qpnp_adc_batt_therm_pu30(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_batt_therm_pu400() - 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. * It uses a mapping table computed for a 400K pull-up. * @dev: Structure device for qpnp vadc * @adc_code: pre-calibrated digital output of the ADC. * @adc_prop: adc properties of the 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_pu400(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 * gain and offset. Returns the temperature in decidegC. * @dev: Structure device for qpnp vadc * @adc_code: pre-calibrated digital output of the ADC. * @adc_prop: adc properties of the 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_batt_therm(struct qpnp_vadc_chip *dev, int32_t adc_code, const struct qpnp_adc_properties *adc_prop, Loading Loading @@ -2091,6 +2133,18 @@ static inline int32_t qpnp_adc_batt_therm_qrd(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_pu30(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_batt_therm_pu400(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 +204 −0 Original line number Diff line number Diff line Loading @@ -751,6 +751,154 @@ 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_pu30[] = { {1842, -400}, {1838, -380}, {1833, -360}, {1828, -340}, {1822, -320}, {1816, -300}, {1809, -280}, {1801, -260}, {1793, -240}, {1784, -220}, {1774, -200}, {1763, -180}, {1752, -160}, {1739, -140}, {1726, -120}, {1712, -100}, {1697, -80}, {1680, -60}, {1663, -40}, {1645, -20}, {1625, 0}, {1605, 20}, {1583, 40}, {1561, 60}, {1537, 80}, {1513, 100}, {1487, 120}, {1461, 140}, {1433, 160}, {1405, 180}, {1376, 200}, {1347, 220}, {1316, 240}, {1286, 260}, {1254, 280}, {1223, 300}, {1191, 320}, {1159, 340}, {1126, 360}, {1094, 380}, {1062, 400}, {1029, 420}, {997, 440}, {966, 460}, {934, 480}, {903, 500}, {873, 520}, {843, 540}, {813, 560}, {784, 580}, {756, 600}, {728, 620}, {702, 640}, {675, 660}, {650, 680}, {625, 700}, {601, 720}, {578, 740}, {556, 760}, {534, 780}, {513, 800}, {493, 820}, {474, 840}, {455, 860}, {437, 880}, {420, 900}, {403, 920}, {387, 940}, {372, 960}, {357, 980} }; /* Voltage to temp0erature */ static const struct qpnp_vadc_map_pt adcmap_batt_therm_pu400[] = { {1516, -400}, {1478, -380}, {1438, -360}, {1396, -340}, {1353, -320}, {1307, -300}, {1261, -280}, {1213, -260}, {1164, -240}, {1115, -220}, {1066, -200}, {1017, -180}, {968, -160}, {920, -140}, {872, -120}, {826, -100}, {781, -80}, {737, -60}, {694, -40}, {654, -20}, {615, 0}, {578, 20}, {542, 40}, {509, 60}, {477, 80}, {447, 100}, {419, 120}, {392, 140}, {367, 160}, {343, 180}, {321, 200}, {301, 220}, {282, 240}, {264, 260}, {247, 280}, {231, 300}, {216, 320}, {203, 340}, {190, 360}, {178, 380}, {167, 400}, {157, 420}, {147, 440}, {138, 460}, {130, 480}, {122, 500}, {115, 520}, {108, 540}, {102, 560}, {96, 580}, {90, 600}, {85, 620}, {80, 640}, {76, 660}, {72, 680}, {68, 700}, {64, 720}, {61, 740}, {57, 760}, {54, 780}, {52, 800}, {49, 820}, {46, 840}, {44, 860}, {42, 880}, {40, 900}, {38, 920}, {36, 940}, {34, 960}, {32, 980} }; /* * Voltage to temperature table for 100k pull up for NTCG104EF104 with * 1.875V reference. Loading Loading @@ -1120,6 +1268,62 @@ int32_t qpnp_adc_batt_therm_qrd(struct qpnp_vadc_chip *chip, } EXPORT_SYMBOL(qpnp_adc_batt_therm_qrd); int32_t qpnp_adc_batt_therm_pu30(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; /* (code * vref_vadc (1.875V) * 1000) / (scale_code * 1000) */ if (adc_code > QPNP_VADC_HC_MAX_CODE) adc_code = 0; batt_thm_voltage = (int64_t) adc_code; batt_thm_voltage *= (adc_properties->adc_vdd_reference * 1000); batt_thm_voltage = div64_s64(batt_thm_voltage, adc_properties->full_scale_code * 1000); qpnp_adc_map_voltage_temp(adcmap_batt_therm_pu30, ARRAY_SIZE(adcmap_batt_therm_pu30), batt_thm_voltage, &adc_chan_result->physical); return 0; } EXPORT_SYMBOL(qpnp_adc_batt_therm_pu30); int32_t qpnp_adc_batt_therm_pu400(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; /* (code * vref_vadc (1.875V) * 1000) / (scale_code * 1000) */ if (adc_code > QPNP_VADC_HC_MAX_CODE) adc_code = 0; batt_thm_voltage = (int64_t) adc_code; batt_thm_voltage *= (adc_properties->adc_vdd_reference * 1000); batt_thm_voltage = div64_s64(batt_thm_voltage, adc_properties->full_scale_code * 1000); qpnp_adc_map_voltage_temp(adcmap_batt_therm_pu400, ARRAY_SIZE(adcmap_batt_therm_pu400), batt_thm_voltage, &adc_chan_result->physical); return 0; } EXPORT_SYMBOL(qpnp_adc_batt_therm_pu400); int32_t qpnp_adc_scale_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 +2 −0 Original line number Diff line number Diff line Loading @@ -228,6 +228,8 @@ static struct qpnp_vadc_scale_fn vadc_scale_fn[] = { [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}, [SCALE_BATT_THERM_TEMP_PU30] = {qpnp_adc_batt_therm_pu30}, [SCALE_BATT_THERM_TEMP_PU400] = {qpnp_adc_batt_therm_pu400}, }; static struct qpnp_vadc_rscale_fn adc_vadc_rscale_fn[] = { Loading
include/linux/qpnp/qpnp-adc.h +55 −1 Original line number Diff line number Diff line Loading @@ -401,6 +401,10 @@ 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_BATT_THERM_TEMP_PU30: Conversion to temperature(decidegC) for 30k * pullup. * %SCALE_BATT_THERM_TEMP_PU400: Conversion to temperature(decidegC) for 400k * pullup. * %SCALE_SMB1390_DIE_TEMP: Conversion for SMB1390 die temp * %SCALE_NONE: Do not use this scaling type. */ Loading @@ -426,6 +430,8 @@ enum qpnp_adc_scale_fn_type { SCALE_USBIN_I, SCALE_BATT_THERM_TEMP_QRD, SCALE_SMB1390_DIE_TEMP, SCALE_BATT_THERM_TEMP_PU30, SCALE_BATT_THERM_TEMP_PU400, SCALE_NONE, }; Loading Loading @@ -1465,9 +1471,10 @@ int32_t qpnp_adc_batt_therm_qrd(struct qpnp_vadc_chip *dev, 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 * qpnp_adc_batt_therm_pu30() - 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. * It uses a mapping table computed for a 30K pull-up. * @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, Loading @@ -1476,6 +1483,41 @@ int32_t qpnp_adc_batt_therm_qrd(struct qpnp_vadc_chip *dev, * slope and offset. * @chan_rslt: physical result to be stored. */ int32_t qpnp_adc_batt_therm_pu30(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_batt_therm_pu400() - 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. * It uses a mapping table computed for a 400K pull-up. * @dev: Structure device for qpnp vadc * @adc_code: pre-calibrated digital output of the ADC. * @adc_prop: adc properties of the 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_pu400(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 * gain and offset. Returns the temperature in decidegC. * @dev: Structure device for qpnp vadc * @adc_code: pre-calibrated digital output of the ADC. * @adc_prop: adc properties of the 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_batt_therm(struct qpnp_vadc_chip *dev, int32_t adc_code, const struct qpnp_adc_properties *adc_prop, Loading Loading @@ -2091,6 +2133,18 @@ static inline int32_t qpnp_adc_batt_therm_qrd(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_pu30(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_batt_therm_pu400(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