diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2021-02-22 20:39:11 +0300 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2021-02-22 20:39:11 +0300 |
commit | 5d26c176d58bc3f9380b18ba2f51a1d863c6a5a0 (patch) | |
tree | 534a9d04ef361ee8a9f0cdf3bb9a7f87d0e27a83 /drivers/iio | |
parent | b996c10e0f5b2cfd5b2cbf048cce83982bfe662d (diff) | |
parent | a51afb13311cd85b2f638c691b2734622277d8f5 (diff) | |
download | linux-5d26c176d58bc3f9380b18ba2f51a1d863c6a5a0.tar.xz |
Merge tag 'thermal-v5.12-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/thermal/linux
Pull thermal updates from Daniel Lezcano:
- Use the newly introduced 'hot' and 'critical' ops for the acpi
thermal driver (Daniel Lezcano)
- Remove the notify ops as it is no longer used (Daniel Lezcano)
- Remove the 'forced passive' option and the unused bind/unbind
functions (Daniel Lezcano)
- Remove the THERMAL_TRIPS_NONE and the code cleanup around this macro
(Daniel Lezcano)
- Rework the delays to make them pre-computed instead of computing them
again and again at each polling interval (Daniel Lezcano)
- Remove the pointless 'thermal_zone_device_reset' function (Daniel
Lezcano)
- Use the critical and hot ops to prevent an unexpected system shutdown
on int340x (Kai-Heng Feng)
- Make the cooling device state private to the thermal subsystem
(Daniel Lezcano)
- Prevent to use not-power-aware actor devices with the power allocator
governor (Lukasz Luba)
- Remove 'zx' and 'tango' support along with the corresponding
platforms (Arnd Bergman)
- Fix several issues on the Omap thermal driver (Tony Lindgren)
- Add support for adc-tm5 PMIC thermal monitor for Qcom platforms
(Dmitry Baryshkov)
- Fix an initialization loop in the adc-tm5 (Colin Ian King)
- Fix a return error check in the cpufreq cooling device (Viresh Kumar)
* tag 'thermal-v5.12-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/thermal/linux: (26 commits)
thermal: cpufreq_cooling: freq_qos_update_request() returns < 0 on error
thermal: qcom: Fix comparison with uninitialized variable channels_available
thermal: qcom: add support for adc-tm5 PMIC thermal monitor
dt-bindings: thermal: qcom: add adc-thermal monitor bindings
thermal: ti-soc-thermal: Use non-inverted define for omap4
thermal: ti-soc-thermal: Simplify polling with iopoll
thermal: ti-soc-thermal: Fix stuck sensor with continuous mode for 4430
thermal: ti-soc-thermal: Skip pointless register access for dra7
thermal/drivers/zx: Remove zx driver
thermal/drivers/tango: Remove tango driver
thermal: power allocator: fail binding for non-power actor devices
thermal/core: Make cooling device state change private
thermal: intel: pch: Fix unexpected shutdown at critical temperature
thermal: int340x: Fix unexpected shutdown at critical temperature
thermal/core: Remove pointless thermal_zone_device_reset() function
thermal/core: Remove ms based delay fields
thermal/core: Use precomputed jiffies for the polling
thermal/core: Precompute the delays from msecs to jiffies
thermal/core: Remove unused macro THERMAL_TRIPS_NONE
thermal/core: Remove THERMAL_TRIPS_NONE test
...
Diffstat (limited to 'drivers/iio')
-rw-r--r-- | drivers/iio/adc/qcom-vadc-common.c | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/drivers/iio/adc/qcom-vadc-common.c b/drivers/iio/adc/qcom-vadc-common.c index 8682cf1e213f..14723896aab2 100644 --- a/drivers/iio/adc/qcom-vadc-common.c +++ b/drivers/iio/adc/qcom-vadc-common.c @@ -368,6 +368,28 @@ static int qcom_vadc_map_voltage_temp(const struct vadc_map_pt *pts, return 0; } +static s32 qcom_vadc_map_temp_voltage(const struct vadc_map_pt *pts, + u32 tablesize, int input) +{ + u32 i = 0; + + /* + * Table must be sorted, find the interval of 'y' which contains value + * 'input' and map it to proper 'x' value + */ + while (i < tablesize && pts[i].y < input) + i++; + + if (i == 0) + return pts[0].x; + if (i == tablesize) + return pts[tablesize - 1].x; + + /* interpolate linearly */ + return fixp_linear_interpolate(pts[i - 1].y, pts[i - 1].x, + pts[i].y, pts[i].x, input); +} + static void qcom_vadc_scale_calib(const struct vadc_linear_graph *calib_graph, u16 adc_code, bool absolute, @@ -463,6 +485,21 @@ static int qcom_vadc_scale_chg_temp(const struct vadc_linear_graph *calib_graph, return 0; } +/* convert voltage to ADC code, using 1.875V reference */ +static u16 qcom_vadc_scale_voltage_code(s32 voltage, + const struct vadc_prescale_ratio *prescale, + const u32 full_scale_code_volt, + unsigned int factor) +{ + s64 volt = voltage; + s64 adc_vdd_ref_mv = 1875; /* reference voltage */ + + volt *= prescale->num * factor * full_scale_code_volt; + volt = div64_s64(volt, (s64)prescale->den * adc_vdd_ref_mv * 1000); + + return volt; +} + static int qcom_vadc_scale_code_voltage_factor(u16 adc_code, const struct vadc_prescale_ratio *prescale, const struct adc5_data *data, @@ -627,6 +664,19 @@ int qcom_vadc_scale(enum vadc_scale_fn_type scaletype, } EXPORT_SYMBOL(qcom_vadc_scale); +u16 qcom_adc_tm5_temp_volt_scale(unsigned int prescale_ratio, + u32 full_scale_code_volt, int temp) +{ + const struct vadc_prescale_ratio *prescale = &adc5_prescale_ratios[prescale_ratio]; + s32 voltage; + + voltage = qcom_vadc_map_temp_voltage(adcmap_100k_104ef_104fb_1875_vref, + ARRAY_SIZE(adcmap_100k_104ef_104fb_1875_vref), + temp); + return qcom_vadc_scale_voltage_code(voltage, prescale, full_scale_code_volt, 1000); +} +EXPORT_SYMBOL(qcom_adc_tm5_temp_volt_scale); + int qcom_adc5_hw_scale(enum vadc_scale_fn_type scaletype, unsigned int prescale_ratio, const struct adc5_data *data, |