History

Merge tag 'thermal-5.16-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm

Pull thermal control updates from Rafael Wysocki: "These extend the thermal trip point crossing notifications sent via netlink to contain the temperature causing the trip point to be crossed, deprecate the user space thermal governor, add new DT bindings to drivers, move ABI documentation to Documentation/ABI, fix assorted issues and clean up code. Specifics: - Constify a variable in thermal MMIO driver (Rikard Falkeborn). - Add the current temperature in the netlink message when crossing a trip point in order to prevent useless back and forth reading from userspace (Daniel Lezcano). - Add support for the 'HC' variant on PM8998 PMIC in order to support VADC channels on recent QCom boards (Bjorn Andersson). - Add support for calibration values from hardware when they are fused (Niklas Söderlund). - Fix NULL pointer dereference in the thermal_release callback when an error occurs in the thermal_zone_device_register() (Yuanzheng Song). - Fix use-after-free in __thermal_cooling_device_register() in the error path (Ziyang Xuan). - Fix compilation of the LMh driver when CONFIG_QCOM_SCM is not set (Jackie Liu). - Add timeout when reading a register that can block forever in certain circumstances in the tsens driver (Ansuel Smith). - Add DT binding for the reset lines and use them in the rockchip sensor driver (Johan Jonker). - Add new uniphier NX1 SoC temperature sensor (Kunihiko Hayashi). - Save and restore the TCC value in the int340x driver (Antoine Tenart). - Deprecate the writability of the cooling device state sysfs file and the user space governor (Daniel Lezcano). - Delete bogus length check in int340x (Dan Carpenter). - Use bitmap_zalloc/bitmap_free when applicable in intel_powerclamp (Christophe JAILLET). - Move thermal ABI documentation to Documentation/ABI (Mauro Carvalho Chehab)" * tag 'thermal-5.16-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm: (21 commits) thermal/core: Deprecate changing cooling device state from userspace thermal/core: Make the userspace governor deprecated thermal/drivers/int340x: Improve the tcc offset saving for suspend/resume thermal/drivers/uniphier: Add compatible string for NX1 SoC dt-bindings: thermal: uniphier: Add binding for NX1 SoC thermal/drivers/rockchip_thermal: Allow more resets for tsadc node dt-bindings: thermal: remove redundant comments from rockchip-thermal.yaml dt-bindings: thermal: allow more resets for tsadc node in rockchip-thermal.yaml thermal/drivers/tsens: Add timeout to get_temp_tsens_valid thermal/drivers/qcom/lmh: make QCOM_LMH depends on QCOM_SCM thermal/core: fix a UAF bug in __thermal_cooling_device_register() thermal/core: Fix null pointer dereference in thermal_release() thermal: rcar_gen3_thermal: Read calibration from hardware thermal: rcar_gen3_thermal: Store thcode and ptat in priv data thermal/drivers/qcom/spmi-adc-tm5: Add support for HC variant dt-bindings: thermal: qcom: add HC variant of adc-thermal monitor bindings thermal: Move ABI documentation to Documentation/ABI thermal/drivers/netlink: Add the temperature when crossing a trip point thermal/drivers/thermal_mmio: Constify static struct thermal_mmio_ops thermal: int340x: delete bogus length check ...

Linus Torvalds committed 5 years ago

Commit f73cd9c2 parents 833db72 46e9f9225 files · +679 −314Browse files

Unified · Split

25 files
  1. Documentation/ABI/testing/sysfs-class-thermal +259 −0
  2. Documentation/devicetree/bindings/thermal/qcom-spmi-adc-tm-hc.yaml +149 −0
  3. Documentation/devicetree/bindings/thermal/rockchip-thermal.yaml +13 −10
  4. Documentation/devicetree/bindings/thermal/socionext,uniphier-thermal.yaml +1 −0
  5. Documentation/driver-api/thermal/sysfs-api.rst +3 −222
  6. MAINTAINERS +2 −0
  7. drivers/thermal/gov_user_space.c +9 −0
  8. drivers/thermal/intel/int340x_thermal/int3400_thermal.c +4 −5
  9. drivers/thermal/intel/int340x_thermal/int3401_thermal.c +7 −1
  10. drivers/thermal/intel/int340x_thermal/processor_thermal_device.c +28 −8
  11. drivers/thermal/intel/int340x_thermal/processor_thermal_device.h +1 −0
  12. drivers/thermal/intel/int340x_thermal/processor_thermal_device_pci.c +17 −1
  13. drivers/thermal/intel/int340x_thermal/processor_thermal_device_pci_legacy.c +7 −1
  14. drivers/thermal/intel/intel_powerclamp.c +3 −5
  15. drivers/thermal/qcom/Kconfig +1 −1
  16. drivers/thermal/qcom/qcom-spmi-adc-tm5.c +40 −1
  17. drivers/thermal/qcom/tsens.c +14 −15
  18. drivers/thermal/rcar_gen3_thermal.c +86 −27
  19. drivers/thermal/rockchip_thermal.c +1 −1
  20. drivers/thermal/thermal_core.c +16 −6
  21. drivers/thermal/thermal_mmio.c +1 −1
  22. drivers/thermal/thermal_netlink.c +6 −5
  23. drivers/thermal/thermal_netlink.h +4 −4
  24. drivers/thermal/thermal_sysfs.c +3 −0
  25. drivers/thermal/uniphier_thermal.c +4 −0
Documentation/ABI/testing/sysfs-class-thermal+259−0
@@ -0,0 +1,259 @@
1+What: /sys/class/thermal/thermal_zoneX/type
2+Description:
3+ Strings which represent the thermal zone type.
4+ This is given by thermal zone driver as part of registration.
5+ E.g: "acpitz" indicates it's an ACPI thermal device.
6+ In order to keep it consistent with hwmon sys attribute; this
7+ shouldbe a short, lowercase string, not containing spaces nor
8+ dashes.
9+
10+ RO, Required
11+
12+What: /sys/class/thermal/thermal_zoneX/temp
13+Description:
14+ Current temperature as reported by thermal zone (sensor).
15+
16+ Unit: millidegree Celsius
17+
18+ RO, Required
19+
20+What: /sys/class/thermal/thermal_zoneX/mode
21+Description:
22+ One of the predefined values in [enabled, disabled].
23+ This file gives information about the algorithm that is
24+ currently managing the thermal zone. It can be either default
25+ kernel based algorithm or user space application.
26+
27+ enabled
28+ enable Kernel Thermal management.
29+ disabled
30+ Preventing kernel thermal zone driver actions upon
31+ trip points so that user application can take full
32+ charge of the thermal management.
33+
34+ RW, Optional
35+
36+What: /sys/class/thermal/thermal_zoneX/policy
37+Description:
38+ One of the various thermal governors used for a particular zone.
39+
40+ RW, Required
41+
42+What: /sys/class/thermal/thermal_zoneX/available_policies
43+Description:
44+ Available thermal governors which can be used for a
45+ particular zone.
46+
47+ RO, Required
48+
49+What: /sys/class/thermal/thermal_zoneX/trip_point_Y_temp
50+Description:
51+ The temperature above which trip point will be fired.
52+
53+ Unit: millidegree Celsius
54+
55+ RO, Optional
56+
57+What: /sys/class/thermal/thermal_zoneX/trip_point_Y_type
58+Description:
59+ Strings which indicate the type of the trip point.
60+
61+ E.g. it can be one of critical, hot, passive, `active[0-*]`
62+ for ACPI thermal zone.
63+
64+ RO, Optional
65+
66+What: /sys/class/thermal/thermal_zoneX/trip_point_Y_hyst
67+Description:
68+ The hysteresis value for a trip point, represented as an
69+ integer.
70+
71+ Unit: Celsius
72+
73+ RW, Optional
74+
75+What: /sys/class/thermal/thermal_zoneX/cdevY
76+Description:
77+ Sysfs link to the thermal cooling device node where the sys I/F
78+ for cooling device throttling control represents.
79+
80+ RO, Optional
81+
82+What: /sys/class/thermal/thermal_zoneX/cdevY_trip_point
83+Description:
84+ The trip point in this thermal zone which `cdev[0-*]` is
85+ associated with; -1 means the cooling device is not
86+ associated with any trip point.
87+
88+ RO, Optional
89+
90+What: /sys/class/thermal/thermal_zoneX/cdevY_weight
91+Description:
92+ The influence of `cdev[0-*]` in this thermal zone. This value
93+ is relative to the rest of cooling devices in the thermal
94+ zone. For example, if a cooling device has a weight double
95+ than that of other, it's twice as effective in cooling the
96+ thermal zone.
97+
98+ RW, Optional
99+
100+What: /sys/class/thermal/thermal_zoneX/emul_temp
101+Description:
102+ Interface to set the emulated temperature method in thermal zone
103+ (sensor). After setting this temperature, the thermal zone may
104+ pass this temperature to platform emulation function if
105+ registered or cache it locally. This is useful in debugging
106+ different temperature threshold and its associated cooling
107+ action. This is write only node and writing 0 on this node
108+ should disable emulation.
109+
110+ Unit: millidegree Celsius
111+
112+ WO, Optional
113+
114+ WARNING:
115+ Be careful while enabling this option on production systems,
116+ because userland can easily disable the thermal policy by simply
117+ flooding this sysfs node with low temperature values.
118+
119+
120+What: /sys/class/thermal/thermal_zoneX/k_d
121+Description:
122+ The derivative term of the power allocator governor's PID
123+ controller. For more information see
124+ Documentation/driver-api/thermal/power_allocator.rst
125+
126+ RW, Optional
127+
128+What: /sys/class/thermal/thermal_zoneX/k_i
129+Description:
130+ The integral term of the power allocator governor's PID
131+ controller. This term allows the PID controller to compensate
132+ for long term drift. For more information see
133+ Documentation/driver-api/thermal/power_allocator.rst
134+
135+ RW, Optional
136+
137+What: /sys/class/thermal/thermal_zoneX/k_po
138+Description:
139+ The proportional term of the power allocator governor's PID
140+ controller during temperature overshoot. Temperature overshoot
141+ is when the current temperature is above the "desired
142+ temperature" trip point. For more information see
143+ Documentation/driver-api/thermal/power_allocator.rst
144+
145+ RW, Optional
146+
147+What: /sys/class/thermal/thermal_zoneX/k_pu
148+Description:
149+ The proportional term of the power allocator governor's PID
150+ controller during temperature undershoot. Temperature undershoot
151+ is when the current temperature is below the "desired
152+ temperature" trip point. For more information see
153+ Documentation/driver-api/thermal/power_allocator.rst
154+
155+ RW, Optional
156+
157+What: /sys/class/thermal/thermal_zoneX/integral_cutoff
158+Description:
159+ Temperature offset from the desired temperature trip point
160+ above which the integral term of the power allocator
161+ governor's PID controller starts accumulating errors. For
162+ example, if integral_cutoff is 0, then the integral term only
163+ accumulates error when temperature is above the desired
164+ temperature trip point. For more information see
165+ Documentation/driver-api/thermal/power_allocator.rst
166+
167+ Unit: millidegree Celsius
168+
169+ RW, Optional
170+
171+What: /sys/class/thermal/thermal_zoneX/slope
172+Description:
173+ The slope constant used in a linear extrapolation model
174+ to determine a hotspot temperature based off the sensor's
175+ raw readings. It is up to the device driver to determine
176+ the usage of these values.
177+
178+ RW, Optional
179+
180+What: /sys/class/thermal/thermal_zoneX/offset
181+Description:
182+ The offset constant used in a linear extrapolation model
183+ to determine a hotspot temperature based off the sensor's
184+ raw readings. It is up to the device driver to determine
185+ the usage of these values.
186+
187+ RW, Optional
188+
189+What: /sys/class/thermal/thermal_zoneX/sustainable_power
190+Description:
191+ An estimate of the sustained power that can be dissipated by
192+ the thermal zone. Used by the power allocator governor. For
193+ more information see
194+ Documentation/driver-api/thermal/power_allocator.rst
195+
196+ Unit: milliwatts
197+
198+ RW, Optional
199+
200+What: /sys/class/thermal/cooling_deviceX/type
201+Description:
202+ String which represents the type of device, e.g:
203+
204+ - for generic ACPI: should be "Fan", "Processor" or "LCD"
205+ - for memory controller device on intel_menlow platform:
206+ should be "Memory controller".
207+
208+ RO, Required
209+
210+What: /sys/class/thermal/cooling_deviceX/max_state
211+Description:
212+ The maximum permissible cooling state of this cooling device.
213+
214+ RO, Required
215+
216+What: /sys/class/thermal/cooling_deviceX/cur_state
217+Description:
218+ The current cooling state of this cooling device.
219+ The value can any integer numbers between 0 and max_state:
220+
221+ - cur_state == 0 means no cooling
222+ - cur_state == max_state means the maximum cooling.
223+
224+ RW, Required
225+
226+What: /sys/class/thermal/cooling_deviceX/stats/reset
227+Description:
228+ Writing any value resets the cooling device's statistics.
229+
230+ WO, Required
231+
232+What: /sys/class/thermal/cooling_deviceX/stats/time_in_state_ms:
233+Description:
234+ The amount of time spent by the cooling device in various
235+ cooling states. The output will have "<state> <time>" pair
236+ in each line, which will mean this cooling device spent <time>
237+ msec of time at <state>.
238+
239+ Output will have one line for each of the supported states.
240+
241+ RO, Required
242+
243+What: /sys/class/thermal/cooling_deviceX/stats/total_trans
244+Description:
245+ A single positive value showing the total number of times
246+ the state of a cooling device is changed.
247+
248+ RO, Required
249+
250+What: /sys/class/thermal/cooling_deviceX/stats/trans_table
251+Description:
252+ This gives fine grained information about all the cooling state
253+ transitions. The cat output here is a two dimensional matrix,
254+ where an entry <i,j> (row i, column j) represents the number
255+ of transitions from State_i to State_j. If the transition
256+ table is bigger than PAGE_SIZE, reading this will return
257+ an -EFBIG error.
258+
259+ RO, Required
Documentation/devicetree/bindings/thermal/qcom-spmi-adc-tm-hc.yaml+149−0
@@ -0,0 +1,149 @@
1+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
2+%YAML 1.2
3+---
4+$id: http://devicetree.org/schemas/thermal/qcom-spmi-adc-tm-hc.yaml#
5+$schema: http://devicetree.org/meta-schemas/core.yaml#
6+
7+title: Qualcomm's SPMI PMIC ADC HC Thermal Monitoring
8+maintainers:
9+ - Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
10+
11+properties:
12+ compatible:
13+ const: qcom,spmi-adc-tm-hc
14+
15+ reg:
16+ maxItems: 1
17+
18+ interrupts:
19+ maxItems: 1
20+
21+ "#thermal-sensor-cells":
22+ const: 1
23+ description:
24+ Number of cells required to uniquely identify the thermal sensors. Since
25+ we have multiple sensors this is set to 1
26+
27+ "#address-cells":
28+ const: 1
29+
30+ "#size-cells":
31+ const: 0
32+
33+ qcom,avg-samples:
34+ $ref: /schemas/types.yaml#/definitions/uint32
35+ description: Number of samples to be used for measurement.
36+ enum:
37+ - 1
38+ - 2
39+ - 4
40+ - 8
41+ - 16
42+ default: 1
43+
44+ qcom,decimation:
45+ $ref: /schemas/types.yaml#/definitions/uint32
46+ description: This parameter is used to decrease ADC sampling rate.
47+ Quicker measurements can be made by reducing decimation ratio.
48+ enum:
49+ - 256
50+ - 512
51+ - 1024
52+ default: 1024
53+
54+patternProperties:
55+ "^([-a-z0-9]*)@[0-7]$":
56+ type: object
57+ description:
58+ Represent one thermal sensor.
59+
60+ properties:
61+ reg:
62+ description: Specify the sensor channel. There are 8 channels in PMIC5's ADC TM
63+ minimum: 0
64+ maximum: 7
65+
66+ io-channels:
67+ description:
68+ From common IIO binding. Used to pipe PMIC ADC channel to thermal monitor
69+
70+ qcom,ratiometric:
71+ $ref: /schemas/types.yaml#/definitions/flag
72+ description:
73+ Channel calibration type.
74+ If this property is specified VADC will use the VDD reference
75+ (1.875V) and GND for channel calibration. If property is not found,
76+ channel will be calibrated with 0V and 1.25V reference channels,
77+ also known as absolute calibration.
78+
79+ qcom,hw-settle-time-us:
80+ description: Time between AMUX getting configured and the ADC starting conversion.
81+ enum: [0, 100, 200, 300, 400, 500, 600, 700, 1000, 2000, 4000, 6000, 8000, 10000]
82+
83+ qcom,pre-scaling:
84+ $ref: /schemas/types.yaml#/definitions/uint32-array
85+ description: Used for scaling the channel input signal before the
86+ signal is fed to VADC. The configuration for this node is to know the
87+ pre-determined ratio and use it for post scaling. It is a pair of
88+ integers, denoting the numerator and denominator of the fraction by
89+ which input signal is multiplied. For example, <1 3> indicates the
90+ signal is scaled down to 1/3 of its value before ADC measurement. If
91+ property is not found default value depending on chip will be used.
92+ items:
93+ - const: 1
94+ - enum: [ 1, 3, 4, 6, 20, 8, 10 ]
95+
96+ required:
97+ - reg
98+ - io-channels
99+
100+ additionalProperties:
101+ false
102+
103+required:
104+ - compatible
105+ - reg
106+ - interrupts
107+ - "#address-cells"
108+ - "#size-cells"
109+ - "#thermal-sensor-cells"
110+
111+additionalProperties: false
112+
113+examples:
114+ - |
115+ #include <dt-bindings/iio/qcom,spmi-vadc.h>
116+ #include <dt-bindings/interrupt-controller/irq.h>
117+ spmi_bus {
118+ #address-cells = <1>;
119+ #size-cells = <0>;
120+ pm8998_adc: adc@3100 {
121+ reg = <0x3100>;
122+ compatible = "qcom,spmi-adc-rev2";
123+ #address-cells = <1>;
124+ #size-cells = <0>;
125+ #io-channel-cells = <1>;
126+
127+ /* Other propreties are omitted */
128+ adc-chan@4c {
129+ reg = <ADC5_XO_THERM_100K_PU>;
130+ };
131+ };
132+
133+ pm8998_adc_tm: adc-tm@3400 {
134+ compatible = "qcom,spmi-adc-tm-hc";
135+ reg = <0x3400>;
136+ interrupts = <0x2 0x34 0x0 IRQ_TYPE_EDGE_RISING>;
137+ #thermal-sensor-cells = <1>;
138+ #address-cells = <1>;
139+ #size-cells = <0>;
140+
141+ thermistor@1 {
142+ reg = <1>;
143+ io-channels = <&pm8998_adc ADC5_XO_THERM_100K_PU>;
144+ qcom,ratiometric;
145+ qcom,hw-settle-time-us = <200>;
146+ };
147+ };
148+ };
149+...
Documentation/devicetree/bindings/thermal/rockchip-thermal.yaml+13−10
@@ -12,14 +12,14 @@ maintainers: · 11 unmodified lines
1212 properties:
1313 compatible:
1414 enum:
15− - rockchip,px30-tsadc # PX30 SoCs
16− - rockchip,rv1108-tsadc # RV1108 SoCs
17− - rockchip,rk3228-tsadc # RK3228 SoCs
18− - rockchip,rk3288-tsadc # RK3288 SoCs
19− - rockchip,rk3328-tsadc # RK3328 SoCs
20− - rockchip,rk3368-tsadc # RK3368 SoCs
21− - rockchip,rk3399-tsadc # RK3399 SoCs
22− - rockchip,rk3568-tsadc # RK3568 SoCs
15+ - rockchip,px30-tsadc
16+ - rockchip,rk3228-tsadc
17+ - rockchip,rk3288-tsadc
18+ - rockchip,rk3328-tsadc
19+ - rockchip,rk3368-tsadc
20+ - rockchip,rk3399-tsadc
21+ - rockchip,rk3568-tsadc
22+ - rockchip,rv1108-tsadc
2323
2424 reg:
2525 maxItems: 1
@@ -37,11 +37,15 @@ properties: · 11 unmodified lines
3737 - const: apb_pclk
3838
3939 resets:
40− maxItems: 1
40+ minItems: 1
41+ maxItems: 3
4142
4243 reset-names:
44+ minItems: 1
4345 items:
4446 - const: tsadc-apb
47+ - const: tsadc
48+ - const: tsadc-phy
4549
4650 "#thermal-sensor-cells":
4751 const: 1
@@ -71,7 +75,6 @@ required: · 23 unmodified lines
7175 - clocks
7276 - clock-names
7377 - resets
74− - reset-names
7578 - "#thermal-sensor-cells"
7679
7780 additionalProperties: false
Documentation/devicetree/bindings/thermal/socionext,uniphier-thermal.yaml+1−0
@@ -20,6 +20,7 @@ properties: · 19 unmodified lines
2020 - socionext,uniphier-pxs2-thermal
2121 - socionext,uniphier-ld20-thermal
2222 - socionext,uniphier-pxs3-thermal
23+ - socionext,uniphier-nx1-thermal
2324
2425 interrupts:
2526 maxItems: 1
Documentation/driver-api/thermal/sysfs-api.rst+3−222
@@ -428,6 +428,9 @@ of thermal zone device. E.g. the generic thermal driver registers one hwmon · 427 unmodified lines
428428 class device and build the associated hwmon sysfs I/F for all the registered
429429 ACPI thermal zones.
430430
431+Please read Documentation/ABI/testing/sysfs-class-thermal for thermal
432+zone and cooling device attribute details.
433+
431434 ::
432435
433436 /sys/class/hwmon/hwmon[0-*]:
@@ -437,228 +440,6 @@ ACPI thermal zones. · 3 unmodified lines
437440
438441 Please read Documentation/hwmon/sysfs-interface.rst for additional information.
439442
440−Thermal zone attributes
441−-----------------------
442−
443−type
444− Strings which represent the thermal zone type.
445− This is given by thermal zone driver as part of registration.
446− E.g: "acpitz" indicates it's an ACPI thermal device.
447− In order to keep it consistent with hwmon sys attribute; this should
448− be a short, lowercase string, not containing spaces nor dashes.
449− RO, Required
450−
451−temp
452− Current temperature as reported by thermal zone (sensor).
453− Unit: millidegree Celsius
454− RO, Required
455−
456−mode
457− One of the predefined values in [enabled, disabled].
458− This file gives information about the algorithm that is currently
459− managing the thermal zone. It can be either default kernel based
460− algorithm or user space application.
461−
462− enabled
463− enable Kernel Thermal management.
464− disabled
465− Preventing kernel thermal zone driver actions upon
466− trip points so that user application can take full
467− charge of the thermal management.
468−
469− RW, Optional
470−
471−policy
472− One of the various thermal governors used for a particular zone.
473−
474− RW, Required
475−
476−available_policies
477− Available thermal governors which can be used for a particular zone.
478−
479− RO, Required
480−
481−`trip_point_[0-*]_temp`
482− The temperature above which trip point will be fired.
483−
484− Unit: millidegree Celsius
485−
486− RO, Optional
487−
488−`trip_point_[0-*]_type`
489− Strings which indicate the type of the trip point.
490−
491− E.g. it can be one of critical, hot, passive, `active[0-*]` for ACPI
492− thermal zone.
493−
494− RO, Optional
495−
496−`trip_point_[0-*]_hyst`
497− The hysteresis value for a trip point, represented as an integer
498− Unit: Celsius
499− RW, Optional
500−
501−`cdev[0-*]`
502− Sysfs link to the thermal cooling device node where the sys I/F
503− for cooling device throttling control represents.
504−
505− RO, Optional
506−
507−`cdev[0-*]_trip_point`
508− The trip point in this thermal zone which `cdev[0-*]` is associated
509− with; -1 means the cooling device is not associated with any trip
510− point.
511−
512− RO, Optional
513−
514−`cdev[0-*]_weight`
515− The influence of `cdev[0-*]` in this thermal zone. This value
516− is relative to the rest of cooling devices in the thermal
517− zone. For example, if a cooling device has a weight double
518− than that of other, it's twice as effective in cooling the
519− thermal zone.
520−
521− RW, Optional
522−
523−emul_temp
524− Interface to set the emulated temperature method in thermal zone
525− (sensor). After setting this temperature, the thermal zone may pass
526− this temperature to platform emulation function if registered or
527− cache it locally. This is useful in debugging different temperature
528− threshold and its associated cooling action. This is write only node
529− and writing 0 on this node should disable emulation.
530− Unit: millidegree Celsius
531−
532− WO, Optional
533−
534− WARNING:
535− Be careful while enabling this option on production systems,
536− because userland can easily disable the thermal policy by simply
537− flooding this sysfs node with low temperature values.
538−
539−sustainable_power
540− An estimate of the sustained power that can be dissipated by
541− the thermal zone. Used by the power allocator governor. For
542− more information see Documentation/driver-api/thermal/power_allocator.rst
543−
544− Unit: milliwatts
545−
546− RW, Optional
547−
548−k_po
549− The proportional term of the power allocator governor's PID
550− controller during temperature overshoot. Temperature overshoot
551− is when the current temperature is above the "desired
552− temperature" trip point. For more information see
553− Documentation/driver-api/thermal/power_allocator.rst
554−
555− RW, Optional
556−
557−k_pu
558− The proportional term of the power allocator governor's PID
559− controller during temperature undershoot. Temperature undershoot
560− is when the current temperature is below the "desired
561− temperature" trip point. For more information see
562− Documentation/driver-api/thermal/power_allocator.rst
563−
564− RW, Optional
565−
566−k_i
567− The integral term of the power allocator governor's PID
568− controller. This term allows the PID controller to compensate
569− for long term drift. For more information see
570− Documentation/driver-api/thermal/power_allocator.rst
571−
572− RW, Optional
573−
574−k_d
575− The derivative term of the power allocator governor's PID
576− controller. For more information see
577− Documentation/driver-api/thermal/power_allocator.rst
578−
579− RW, Optional
580−
581−integral_cutoff
582− Temperature offset from the desired temperature trip point
583− above which the integral term of the power allocator
584− governor's PID controller starts accumulating errors. For
585− example, if integral_cutoff is 0, then the integral term only
586− accumulates error when temperature is above the desired
587− temperature trip point. For more information see
588− Documentation/driver-api/thermal/power_allocator.rst
589−
590− Unit: millidegree Celsius
591−
592− RW, Optional
593−
594−slope
595− The slope constant used in a linear extrapolation model
596− to determine a hotspot temperature based off the sensor's
597− raw readings. It is up to the device driver to determine
598− the usage of these values.
599−
600− RW, Optional
601−
602−offset
603− The offset constant used in a linear extrapolation model
604− to determine a hotspot temperature based off the sensor's
605− raw readings. It is up to the device driver to determine
606− the usage of these values.
607−
608− RW, Optional
609−
610−Cooling device attributes
611−-------------------------
612−
613−type
614− String which represents the type of device, e.g:
615−
616− - for generic ACPI: should be "Fan", "Processor" or "LCD"
617− - for memory controller device on intel_menlow platform:
618− should be "Memory controller".
619−
620− RO, Required
621−
622−max_state
623− The maximum permissible cooling state of this cooling device.
624−
625− RO, Required
626−
627−cur_state
628− The current cooling state of this cooling device.
629− The value can any integer numbers between 0 and max_state:
630−
631− - cur_state == 0 means no cooling
632− - cur_state == max_state means the maximum cooling.
633−
634− RW, Required
635−
636−stats/reset
637− Writing any value resets the cooling device's statistics.
638− WO, Required
639−
640−stats/time_in_state_ms:
641− The amount of time spent by the cooling device in various cooling
642− states. The output will have "<state> <time>" pair in each line, which
643− will mean this cooling device spent <time> msec of time at <state>.
644− Output will have one line for each of the supported states.
645− RO, Required
646−
647−
648−stats/total_trans:
649− A single positive value showing the total number of times the state of a
650− cooling device is changed.
651−
652− RO, Required
653−
654−stats/trans_table:
655− This gives fine grained information about all the cooling state
656− transitions. The cat output here is a two dimensional matrix, where an
657− entry <i,j> (row i, column j) represents the number of transitions from
658− State_i to State_j. If the transition table is bigger than PAGE_SIZE,
659− reading this will return an -EFBIG error.
660− RO, Required
661−
662443 3. A simple implementation
663444 ==========================
664445
MAINTAINERS+2−0
@@ -18649,7 +18649,9 @@ L: linux-pm@vger.kernel.org · 18648 unmodified lines
1864918649 S: Supported
1865018650 Q: https://patchwork.kernel.org/project/linux-pm/list/
1865118651 T: git git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git thermal
18652+F: Documentation/ABI/testing/sysfs-class-thermal
1865218653 F: Documentation/devicetree/bindings/thermal/
18654+F: Documentation/driver-api/thermal/
1865318655 F: drivers/thermal/
1865418656 F: include/linux/cpu_cooling.h
1865518657 F: include/linux/thermal.h
drivers/thermal/gov_user_space.c+9−0
@@ -15,6 +15,14 @@ · 14 unmodified lines
1515
1616 #include "thermal_core.h"
1717
18+static int user_space_bind(struct thermal_zone_device *tz)
19+{
20+ pr_warn("Userspace governor deprecated: use thermal netlink " \
21+ "notification instead\n");
22+
23+ return 0;
24+}
25+
1826 /**
1927 * notify_user_space - Notifies user space about thermal events
2028 * @tz: thermal_zone_device
@@ -43,5 +51,6 @@ static int notify_user_space(struct thermal_zone_device *tz, int trip) · 22 unmodified lines
4351 static struct thermal_governor thermal_gov_user_space = {
4452 .name = "user_space",
4553 .throttle = notify_user_space,
54+ .bind_to_tz = user_space_bind,
4655 };
4756 THERMAL_GOVERNOR_DECLARE(thermal_gov_user_space);
drivers/thermal/intel/int340x_thermal/int3400_thermal.c+4−5
@@ -129,11 +129,10 @@ static ssize_t available_uuids_show(struct device *dev, · 128 unmodified lines
129129
130130 for (i = 0; i < INT3400_THERMAL_MAXIMUM_UUID; i++) {
131131 if (priv->uuid_bitmap & (1 << i))
132− if (PAGE_SIZE - length > 0)
133− length += scnprintf(&buf[length],
134− PAGE_SIZE - length,
135− "%s\n",
136− int3400_thermal_uuids[i]);
132+ length += scnprintf(&buf[length],
133+ PAGE_SIZE - length,
134+ "%s\n",
135+ int3400_thermal_uuids[i]);
137136 }
138137
139138 return length;
drivers/thermal/intel/int340x_thermal/int3401_thermal.c+7−1
@@ -44,15 +44,21 @@ static int int3401_remove(struct platform_device *pdev) · 43 unmodified lines
4444 }
4545
4646 #ifdef CONFIG_PM_SLEEP
47+static int int3401_thermal_suspend(struct device *dev)
48+{
49+ return proc_thermal_suspend(dev);
50+}
4751 static int int3401_thermal_resume(struct device *dev)
4852 {
4953 return proc_thermal_resume(dev);
5054 }
5155 #else
56+#define int3401_thermal_suspend NULL
5257 #define int3401_thermal_resume NULL
5358 #endif
5459
55−static SIMPLE_DEV_PM_OPS(int3401_proc_thermal_pm, NULL, int3401_thermal_resume);
60+static SIMPLE_DEV_PM_OPS(int3401_proc_thermal_pm, int3401_thermal_suspend,
61+ int3401_thermal_resume);
5662
5763 static struct platform_driver int3401_driver = {
5864 .probe = int3401_add,
drivers/thermal/intel/int340x_thermal/processor_thermal_device.c+28−8
@@ -68,8 +68,7 @@ static const struct attribute_group power_limit_attribute_group = { · 67 unmodified lines
6868 .name = "power_limits"
6969 };
7070
71−static ssize_t tcc_offset_degree_celsius_show(struct device *dev,
72− struct device_attribute *attr, char *buf)
71+static int tcc_get_offset(void)
7372 {
7473 u64 val;
7574 int err;
@@ -78,8 +77,20 @@ static ssize_t tcc_offset_degree_celsius_show(struct device *dev, · 2 unmodified lines
7877 if (err)
7978 return err;
8079
81− val = (val >> 24) & 0x3f;
82− return sprintf(buf, "%d\n", (int)val);
80+ return (val >> 24) & 0x3f;
81+}
82+
83+static ssize_t tcc_offset_degree_celsius_show(struct device *dev,
84+ struct device_attribute *attr,
85+ char *buf)
86+{
87+ int tcc;
88+
89+ tcc = tcc_get_offset();
90+ if (tcc < 0)
91+ return tcc;
92+
93+ return sprintf(buf, "%d\n", tcc);
8394 }
8495
8596 static int tcc_offset_update(unsigned int tcc)
@@ -107,8 +118,6 @@ static int tcc_offset_update(unsigned int tcc) · 21 unmodified lines
107118 return 0;
108119 }
109120
110−static int tcc_offset_save = -1;
111−
112121 static ssize_t tcc_offset_degree_celsius_store(struct device *dev,
113122 struct device_attribute *attr, const char *buf,
114123 size_t count)
@@ -131,8 +140,6 @@ static ssize_t tcc_offset_degree_celsius_store(struct device *dev, · 16 unmodified lines
131140 if (err)
132141 return err;
133142
134− tcc_offset_save = tcc;
135−
136143 return count;
137144 }
138145
@@ -345,6 +352,18 @@ void proc_thermal_remove(struct proc_thermal_device *proc_priv) · 206 unmodified lines
345352 }
346353 EXPORT_SYMBOL_GPL(proc_thermal_remove);
347354
355+static int tcc_offset_save = -1;
356+
357+int proc_thermal_suspend(struct device *dev)
358+{
359+ tcc_offset_save = tcc_get_offset();
360+ if (tcc_offset_save < 0)
361+ dev_warn(dev, "failed to save offset (%d)\n", tcc_offset_save);
362+
363+ return 0;
364+}
365+EXPORT_SYMBOL_GPL(proc_thermal_suspend);
366+
348367 int proc_thermal_resume(struct device *dev)
349368 {
350369 struct proc_thermal_device *proc_dev;
@@ -352,6 +371,7 @@ int proc_thermal_resume(struct device *dev) · 1 unmodified line
352371 proc_dev = dev_get_drvdata(dev);
353372 proc_thermal_read_ppcc(proc_dev);
354373
374+ /* Do not update if saving failed */
355375 if (tcc_offset_save >= 0)
356376 tcc_offset_update(tcc_offset_save);
357377
drivers/thermal/intel/int340x_thermal/processor_thermal_device.h+1−0
@@ -83,6 +83,7 @@ void proc_thermal_mbox_remove(struct pci_dev *pdev); · 82 unmodified lines
8383 int processor_thermal_send_mbox_cmd(struct pci_dev *pdev, u16 cmd_id, u32 cmd_data, u32 *cmd_resp);
8484 int proc_thermal_add(struct device *dev, struct proc_thermal_device *priv);
8585 void proc_thermal_remove(struct proc_thermal_device *proc_priv);
86+int proc_thermal_suspend(struct device *dev);
8687 int proc_thermal_resume(struct device *dev);
8788 int proc_thermal_mmio_add(struct pci_dev *pdev,
8889 struct proc_thermal_device *proc_priv,
drivers/thermal/intel/int340x_thermal/processor_thermal_device_pci.c+17−1
@@ -314,6 +314,20 @@ static void proc_thermal_pci_remove(struct pci_dev *pdev) · 313 unmodified lines
314314 }
315315
316316 #ifdef CONFIG_PM_SLEEP
317+static int proc_thermal_pci_suspend(struct device *dev)
318+{
319+ struct pci_dev *pdev = to_pci_dev(dev);
320+ struct proc_thermal_device *proc_priv;
321+ struct proc_thermal_pci *pci_info;
322+
323+ proc_priv = pci_get_drvdata(pdev);
324+ pci_info = proc_priv->priv_data;
325+
326+ if (!pci_info->no_legacy)
327+ return proc_thermal_suspend(dev);
328+
329+ return 0;
330+}
317331 static int proc_thermal_pci_resume(struct device *dev)
318332 {
319333 struct pci_dev *pdev = to_pci_dev(dev);
@@ -335,10 +349,12 @@ static int proc_thermal_pci_resume(struct device *dev) · 15 unmodified lines
335349 return 0;
336350 }
337351 #else
352+#define proc_thermal_pci_suspend NULL
338353 #define proc_thermal_pci_resume NULL
339354 #endif
340355
341−static SIMPLE_DEV_PM_OPS(proc_thermal_pci_pm, NULL, proc_thermal_pci_resume);
356+static SIMPLE_DEV_PM_OPS(proc_thermal_pci_pm, proc_thermal_pci_suspend,
357+ proc_thermal_pci_resume);
342358
343359 static const struct pci_device_id proc_thermal_pci_ids[] = {
344360 { PCI_DEVICE_DATA(INTEL, ADL_THERMAL, PROC_THERMAL_FEATURE_RAPL | PROC_THERMAL_FEATURE_FIVR | PROC_THERMAL_FEATURE_DVFS | PROC_THERMAL_FEATURE_MBOX) },
drivers/thermal/intel/int340x_thermal/processor_thermal_device_pci_legacy.c+7−1
@@ -107,15 +107,21 @@ static void proc_thermal_pci_remove(struct pci_dev *pdev) · 106 unmodified lines
107107 }
108108
109109 #ifdef CONFIG_PM_SLEEP
110+static int proc_thermal_pci_suspend(struct device *dev)
111+{
112+ return proc_thermal_suspend(dev);
113+}
110114 static int proc_thermal_pci_resume(struct device *dev)
111115 {
112116 return proc_thermal_resume(dev);
113117 }
114118 #else
119+#define proc_thermal_pci_suspend NULL
115120 #define proc_thermal_pci_resume NULL
116121 #endif
117122
118−static SIMPLE_DEV_PM_OPS(proc_thermal_pci_pm, NULL, proc_thermal_pci_resume);
123+static SIMPLE_DEV_PM_OPS(proc_thermal_pci_pm, proc_thermal_pci_suspend,
124+ proc_thermal_pci_resume);
119125
120126 static const struct pci_device_id proc_thermal_pci_ids[] = {
121127 { PCI_DEVICE_DATA(INTEL, BDW_THERMAL, 0) },
drivers/thermal/intel/intel_powerclamp.c+3−5
@@ -705,10 +705,8 @@ static enum cpuhp_state hp_state; · 704 unmodified lines
705705 static int __init powerclamp_init(void)
706706 {
707707 int retval;
708− int bitmap_size;
709708
710− bitmap_size = BITS_TO_LONGS(num_possible_cpus()) * sizeof(long);
711− cpu_clamping_mask = kzalloc(bitmap_size, GFP_KERNEL);
709+ cpu_clamping_mask = bitmap_zalloc(num_possible_cpus(), GFP_KERNEL);
712710 if (!cpu_clamping_mask)
713711 return -ENOMEM;
714712
@@ -753,7 +751,7 @@ exit_free_thread: · 38 unmodified lines
753751 exit_unregister:
754752 cpuhp_remove_state_nocalls(hp_state);
755753 exit_free:
756− kfree(cpu_clamping_mask);
754+ bitmap_free(cpu_clamping_mask);
757755 return retval;
758756 }
759757 module_init(powerclamp_init);
@@ -764,7 +762,7 @@ static void __exit powerclamp_exit(void) · 4 unmodified lines
764762 cpuhp_remove_state_nocalls(hp_state);
765763 free_percpu(worker_data);
766764 thermal_cooling_device_unregister(cooling_dev);
767− kfree(cpu_clamping_mask);
765+ bitmap_free(cpu_clamping_mask);
768766
769767 cancel_delayed_work_sync(&poll_pkg_cstate_work);
770768 debugfs_remove_recursive(debug_dir);
drivers/thermal/qcom/Kconfig+1−1
@@ -34,7 +34,7 @@ config QCOM_SPMI_TEMP_ALARM · 33 unmodified lines
3434
3535 config QCOM_LMH
3636 tristate "Qualcomm Limits Management Hardware"
37− depends on ARCH_QCOM
37+ depends on ARCH_QCOM && QCOM_SCM
3838 help
3939 This enables initialization of Qualcomm limits management
4040 hardware(LMh). LMh allows for hardware-enforced mitigation for cpus based on
drivers/thermal/qcom/qcom-spmi-adc-tm5.c+40−1
@@ -82,6 +82,7 @@ struct adc_tm5_data { · 81 unmodified lines
8282 const u32 full_scale_code_volt;
8383 unsigned int *decimation;
8484 unsigned int *hw_settle;
85+ bool is_hc;
8586 };
8687
8788 enum adc_tm5_cal_method {
@@ -146,6 +147,14 @@ static const struct adc_tm5_data adc_tm5_data_pmic = { · 58 unmodified lines
146147 64000, 128000 },
147148 };
148149
150+static const struct adc_tm5_data adc_tm_hc_data_pmic = {
151+ .full_scale_code_volt = 0x70e4,
152+ .decimation = (unsigned int []) { 256, 512, 1024 },
153+ .hw_settle = (unsigned int []) { 0, 100, 200, 300, 400, 500, 600, 700,
154+ 1000, 2000, 4000, 6000, 8000, 10000 },
155+ .is_hc = true,
156+};
157+
149158 static int adc_tm5_read(struct adc_tm5_chip *adc_tm, u16 offset, u8 *data, int len)
150159 {
151160 return regmap_bulk_read(adc_tm->regmap, adc_tm->base + offset, data, len);
@@ -375,6 +384,29 @@ static int adc_tm5_register_tzd(struct adc_tm5_chip *adc_tm) · 223 unmodified lines
375384 return 0;
376385 }
377386
387+static int adc_tm_hc_init(struct adc_tm5_chip *chip)
388+{
389+ unsigned int i;
390+ u8 buf[2];
391+ int ret;
392+
393+ for (i = 0; i < chip->nchannels; i++) {
394+ if (chip->channels[i].channel >= ADC_TM5_NUM_CHANNELS) {
395+ dev_err(chip->dev, "Invalid channel %d\n", chip->channels[i].channel);
396+ return -EINVAL;
397+ }
398+ }
399+
400+ buf[0] = chip->decimation;
401+ buf[1] = chip->avg_samples | ADC_TM5_FAST_AVG_EN;
402+
403+ ret = adc_tm5_write(chip, ADC_TM5_ADC_DIG_PARAM, buf, sizeof(buf));
404+ if (ret)
405+ dev_err(chip->dev, "block write failed: %d\n", ret);
406+
407+ return ret;
408+}
409+
378410 static int adc_tm5_init(struct adc_tm5_chip *chip)
379411 {
380412 u8 buf[4], channels_available;
@@ -591,7 +623,10 @@ static int adc_tm5_probe(struct platform_device *pdev) · 210 unmodified lines
591623 return ret;
592624 }
593625
594− ret = adc_tm5_init(adc_tm);
626+ if (adc_tm->data->is_hc)
627+ ret = adc_tm_hc_init(adc_tm);
628+ else
629+ ret = adc_tm5_init(adc_tm);
595630 if (ret) {
596631 dev_err(dev, "adc-tm init failed\n");
597632 return ret;
@@ -612,6 +647,10 @@ static const struct of_device_id adc_tm5_match_table[] = { · 14 unmodified lines
612647 .compatible = "qcom,spmi-adc-tm5",
613648 .data = &adc_tm5_data_pmic,
614649 },
650+ {
651+ .compatible = "qcom,spmi-adc-tm-hc",
652+ .data = &adc_tm_hc_data_pmic,
653+ },
615654 { }
616655 };
617656 MODULE_DEVICE_TABLE(of, adc_tm5_match_table);
drivers/thermal/qcom/tsens.c+14−15
@@ -603,22 +603,21 @@ int get_temp_tsens_valid(const struct tsens_sensor *s, int *temp) · 602 unmodified lines
603603 int ret;
604604
605605 /* VER_0 doesn't have VALID bit */
606− if (tsens_version(priv) >= VER_0_1) {
607− ret = regmap_field_read(priv->rf[valid_idx], &valid);
608− if (ret)
609− return ret;
610− while (!valid) {
611− /* Valid bit is 0 for 6 AHB clock cycles.
612− * At 19.2MHz, 1 AHB clock is ~60ns.
613− * We should enter this loop very, very rarely.
614− */
615− ndelay(400);
616− ret = regmap_field_read(priv->rf[valid_idx], &valid);
617− if (ret)
618− return ret;
619− }
620− }
606+ if (tsens_version(priv) == VER_0)
607+ goto get_temp;
608+
609+ /* Valid bit is 0 for 6 AHB clock cycles.
610+ * At 19.2MHz, 1 AHB clock is ~60ns.
611+ * We should enter this loop very, very rarely.
612+ * Wait 1 us since it's the min of poll_timeout macro.
613+ * Old value was 400 ns.
614+ */
615+ ret = regmap_field_read_poll_timeout(priv->rf[valid_idx], valid,
616+ valid, 1, 20 * USEC_PER_MSEC);
617+ if (ret)
618+ return ret;
621619
620+get_temp:
622621 /* Valid bit is set, OK to read the temperature */
623622 *temp = tsens_hw_to_mC(s, temp_idx);
624623
drivers/thermal/rcar_gen3_thermal.c+86−27
@@ -34,6 +34,10 @@ · 33 unmodified lines
3434 #define REG_GEN3_THCODE1 0x50
3535 #define REG_GEN3_THCODE2 0x54
3636 #define REG_GEN3_THCODE3 0x58
37+#define REG_GEN3_PTAT1 0x5c
38+#define REG_GEN3_PTAT2 0x60
39+#define REG_GEN3_PTAT3 0x64
40+#define REG_GEN3_THSCP 0x68
3741
3842 /* IRQ{STR,MSK,EN} bits */
3943 #define IRQ_TEMP1 BIT(0)
@@ -55,6 +59,9 @@ · 15 unmodified lines
5559 #define THCTR_PONM BIT(6)
5660 #define THCTR_THSST BIT(0)
5761
62+/* THSCP bits */
63+#define THSCP_COR_PARA_VLD (BIT(15) | BIT(14))
64+
5865 #define CTEMP_MASK 0xFFF
5966
6067 #define MCELSIUS(temp) ((temp) * 1000)
@@ -62,15 +69,6 @@ · 1 unmodified line
6269
6370 #define TSC_MAX_NUM 5
6471
65−/* default THCODE values if FUSEs are missing */
66−static const int thcodes[TSC_MAX_NUM][3] = {
67− { 3397, 2800, 2221 },
68− { 3393, 2795, 2216 },
69− { 3389, 2805, 2237 },
70− { 3415, 2694, 2195 },
71− { 3356, 2724, 2244 },
72−};
73−
7472 /* Structure for thermal temperature calculation */
7573 struct equation_coefs {
7674 int a1;
@@ -84,13 +82,14 @@ struct rcar_gen3_thermal_tsc { · 7 unmodified lines
8482 struct thermal_zone_device *zone;
8583 struct equation_coefs coef;
8684 int tj_t;
87− unsigned int id; /* thermal channel id */
85+ int thcode[3];
8886 };
8987
9088 struct rcar_gen3_thermal_priv {
9189 struct rcar_gen3_thermal_tsc *tscs[TSC_MAX_NUM];
9290 unsigned int num_tscs;
9391 void (*thermal_init)(struct rcar_gen3_thermal_tsc *tsc);
92+ int ptat[3];
9493 };
9594
9695 static inline u32 rcar_gen3_thermal_read(struct rcar_gen3_thermal_tsc *tsc,
@@ -133,8 +132,8 @@ static inline void rcar_gen3_thermal_write(struct rcar_gen3_thermal_tsc *tsc, · 36 unmodified lines
133132 /* no idea where these constants come from */
134133 #define TJ_3 -41
135134
136−static void rcar_gen3_thermal_calc_coefs(struct rcar_gen3_thermal_tsc *tsc,
137− int *ptat, const int *thcode,
135+static void rcar_gen3_thermal_calc_coefs(struct rcar_gen3_thermal_priv *priv,
136+ struct rcar_gen3_thermal_tsc *tsc,
138137 int ths_tj_1)
139138 {
140139 /* TODO: Find documentation and document constant calculation formula */
@@ -143,16 +142,16 @@ static void rcar_gen3_thermal_calc_coefs(struct rcar_gen3_thermal_tsc *tsc, · 2 unmodified lines
143142 * Division is not scaled in BSP and if scaled it might overflow
144143 * the dividend (4095 * 4095 << 14 > INT_MAX) so keep it unscaled
145144 */
146− tsc->tj_t = (FIXPT_INT((ptat[1] - ptat[2]) * (ths_tj_1 - TJ_3))
147− / (ptat[0] - ptat[2])) + FIXPT_INT(TJ_3);
145+ tsc->tj_t = (FIXPT_INT((priv->ptat[1] - priv->ptat[2]) * (ths_tj_1 - TJ_3))
146+ / (priv->ptat[0] - priv->ptat[2])) + FIXPT_INT(TJ_3);
148147
149− tsc->coef.a1 = FIXPT_DIV(FIXPT_INT(thcode[1] - thcode[2]),
148+ tsc->coef.a1 = FIXPT_DIV(FIXPT_INT(tsc->thcode[1] - tsc->thcode[2]),
150149 tsc->tj_t - FIXPT_INT(TJ_3));
151− tsc->coef.b1 = FIXPT_INT(thcode[2]) - tsc->coef.a1 * TJ_3;
150+ tsc->coef.b1 = FIXPT_INT(tsc->thcode[2]) - tsc->coef.a1 * TJ_3;
152151
153− tsc->coef.a2 = FIXPT_DIV(FIXPT_INT(thcode[1] - thcode[0]),
152+ tsc->coef.a2 = FIXPT_DIV(FIXPT_INT(tsc->thcode[1] - tsc->thcode[0]),
154153 tsc->tj_t - FIXPT_INT(ths_tj_1));
155− tsc->coef.b2 = FIXPT_INT(thcode[0]) - tsc->coef.a2 * ths_tj_1;
154+ tsc->coef.b2 = FIXPT_INT(tsc->thcode[0]) - tsc->coef.a2 * ths_tj_1;
156155 }
157156
158157 static int rcar_gen3_thermal_round(int temp)
@@ -174,7 +173,7 @@ static int rcar_gen3_thermal_get_temp(void *devdata, int *temp) · 15 unmodified lines
174173 /* Read register and convert to mili Celsius */
175174 reg = rcar_gen3_thermal_read(tsc, REG_GEN3_TEMP) & CTEMP_MASK;
176175
177− if (reg <= thcodes[tsc->id][1])
176+ if (reg <= tsc->thcode[1])
178177 val = FIXPT_DIV(FIXPT_INT(reg) - tsc->coef.b1,
179178 tsc->coef.a1);
180179 else
@@ -253,6 +252,64 @@ static const struct soc_device_attribute r8a7795es1[] = { · 72 unmodified lines
253252 { /* sentinel */ }
254253 };
255254
255+static bool rcar_gen3_thermal_read_fuses(struct rcar_gen3_thermal_priv *priv)
256+{
257+ unsigned int i;
258+ u32 thscp;
259+
260+ /* If fuses are not set, fallback to pseudo values. */
261+ thscp = rcar_gen3_thermal_read(priv->tscs[0], REG_GEN3_THSCP);
262+ if ((thscp & THSCP_COR_PARA_VLD) != THSCP_COR_PARA_VLD) {
263+ /* Default THCODE values in case FUSEs are not set. */
264+ static const int thcodes[TSC_MAX_NUM][3] = {
265+ { 3397, 2800, 2221 },
266+ { 3393, 2795, 2216 },
267+ { 3389, 2805, 2237 },
268+ { 3415, 2694, 2195 },
269+ { 3356, 2724, 2244 },
270+ };
271+
272+ priv->ptat[0] = 2631;
273+ priv->ptat[1] = 1509;
274+ priv->ptat[2] = 435;
275+
276+ for (i = 0; i < priv->num_tscs; i++) {
277+ struct rcar_gen3_thermal_tsc *tsc = priv->tscs[i];
278+
279+ tsc->thcode[0] = thcodes[i][0];
280+ tsc->thcode[1] = thcodes[i][1];
281+ tsc->thcode[2] = thcodes[i][2];
282+ }
283+
284+ return false;
285+ }
286+
287+ /*
288+ * Set the pseudo calibration points with fused values.
289+ * PTAT is shared between all TSCs but only fused for the first
290+ * TSC while THCODEs are fused for each TSC.
291+ */
292+ priv->ptat[0] = rcar_gen3_thermal_read(priv->tscs[0], REG_GEN3_PTAT1) &
293+ GEN3_FUSE_MASK;
294+ priv->ptat[1] = rcar_gen3_thermal_read(priv->tscs[0], REG_GEN3_PTAT2) &
295+ GEN3_FUSE_MASK;
296+ priv->ptat[2] = rcar_gen3_thermal_read(priv->tscs[0], REG_GEN3_PTAT3) &
297+ GEN3_FUSE_MASK;
298+
299+ for (i = 0; i < priv->num_tscs; i++) {
300+ struct rcar_gen3_thermal_tsc *tsc = priv->tscs[i];
301+
302+ tsc->thcode[0] = rcar_gen3_thermal_read(tsc, REG_GEN3_THCODE1) &
303+ GEN3_FUSE_MASK;
304+ tsc->thcode[1] = rcar_gen3_thermal_read(tsc, REG_GEN3_THCODE2) &
305+ GEN3_FUSE_MASK;
306+ tsc->thcode[2] = rcar_gen3_thermal_read(tsc, REG_GEN3_THCODE3) &
307+ GEN3_FUSE_MASK;
308+ }
309+
310+ return true;
311+}
312+
256313 static void rcar_gen3_thermal_init_r8a7795es1(struct rcar_gen3_thermal_tsc *tsc)
257314 {
258315 rcar_gen3_thermal_write(tsc, REG_GEN3_CTSR, CTSR_THBGR);
@@ -401,10 +458,6 @@ static int rcar_gen3_thermal_probe(struct platform_device *pdev) · 142 unmodified lines
401458 unsigned int i;
402459 int ret;
403460
404− /* default values if FUSEs are missing */
405− /* TODO: Read values from hardware on supported platforms */
406− int ptat[3] = { 2631, 1509, 435 };
407−
408461 priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
409462 if (!priv)
410463 return -ENOMEM;
@@ -439,9 +492,17 @@ static int rcar_gen3_thermal_probe(struct platform_device *pdev) · 28 unmodified lines
439492 ret = PTR_ERR(tsc->base);
440493 goto error_unregister;
441494 }
442− tsc->id = i;
443495
444496 priv->tscs[i] = tsc;
497+ }
498+
499+ priv->num_tscs = i;
500+
501+ if (!rcar_gen3_thermal_read_fuses(priv))
502+ dev_info(dev, "No calibration values fused, fallback to driver values\n");
503+
504+ for (i = 0; i < priv->num_tscs; i++) {
505+ struct rcar_gen3_thermal_tsc *tsc = priv->tscs[i];
445506
446507 zone = devm_thermal_zone_of_sensor_register(dev, i, tsc,
447508 &rcar_gen3_tz_of_ops);
@@ -453,7 +514,7 @@ static int rcar_gen3_thermal_probe(struct platform_device *pdev) · 5 unmodified lines
453514 tsc->zone = zone;
454515
455516 priv->thermal_init(tsc);
456− rcar_gen3_thermal_calc_coefs(tsc, ptat, thcodes[i], *ths_tj_1);
517+ rcar_gen3_thermal_calc_coefs(priv, tsc, *ths_tj_1);
457518
458519 tsc->zone->tzp->no_hwmon = false;
459520 ret = thermal_add_hwmon_sysfs(tsc->zone);
@@ -471,8 +532,6 @@ static int rcar_gen3_thermal_probe(struct platform_device *pdev) · 11 unmodified lines
471532 dev_info(dev, "TSC%u: Loaded %d trip points\n", i, ret);
472533 }
473534
474− priv->num_tscs = i;
475−
476535 if (!priv->num_tscs) {
477536 ret = -ENODEV;
478537 goto error_unregister;
drivers/thermal/rockchip_thermal.c+1−1
@@ -1383,7 +1383,7 @@ static int rockchip_thermal_probe(struct platform_device *pdev) · 1382 unmodified lines
13831383 if (IS_ERR(thermal->regs))
13841384 return PTR_ERR(thermal->regs);
13851385
1386− thermal->reset = devm_reset_control_get(&pdev->dev, "tsadc-apb");
1386+ thermal->reset = devm_reset_control_array_get(&pdev->dev, false, false);
13871387 if (IS_ERR(thermal->reset)) {
13881388 error = PTR_ERR(thermal->reset);
13891389 dev_err(&pdev->dev, "failed to get tsadc reset: %d\n", error);
drivers/thermal/thermal_core.c+16−6
@@ -375,10 +375,12 @@ static void handle_thermal_trip(struct thermal_zone_device *tz, int trip) · 374 unmodified lines
375375 if (tz->last_temperature != THERMAL_TEMP_INVALID) {
376376 if (tz->last_temperature < trip_temp &&
377377 tz->temperature >= trip_temp)
378− thermal_notify_tz_trip_up(tz->id, trip);
378+ thermal_notify_tz_trip_up(tz->id, trip,
379+ tz->temperature);
379380 if (tz->last_temperature >= trip_temp &&
380381 tz->temperature < (trip_temp - hyst))
381− thermal_notify_tz_trip_down(tz->id, trip);
382+ thermal_notify_tz_trip_down(tz->id, trip,
383+ tz->temperature);
382384 }
383385
384386 if (type == THERMAL_TRIP_CRITICAL || type == THERMAL_TRIP_HOT)
@@ -887,7 +889,7 @@ __thermal_cooling_device_register(struct device_node *np, · 502 unmodified lines
887889 {
888890 struct thermal_cooling_device *cdev;
889891 struct thermal_zone_device *pos = NULL;
890− int ret;
892+ int id, ret;
891893
892894 if (!ops || !ops->get_max_state || !ops->get_cur_state ||
893895 !ops->set_cur_state)
@@ -901,6 +903,11 @@ __thermal_cooling_device_register(struct device_node *np, · 7 unmodified lines
901903 if (ret < 0)
902904 goto out_kfree_cdev;
903905 cdev->id = ret;
906+ id = ret;
907+
908+ ret = dev_set_name(&cdev->device, "cooling_device%d", cdev->id);
909+ if (ret)
910+ goto out_ida_remove;
904911
905912 cdev->type = kstrdup(type ? type : "", GFP_KERNEL);
906913 if (!cdev->type) {
@@ -916,7 +923,6 @@ __thermal_cooling_device_register(struct device_node *np, · 9 unmodified lines
916923 cdev->device.class = &thermal_class;
917924 cdev->devdata = devdata;
918925 thermal_cooling_device_setup_sysfs(cdev);
919− dev_set_name(&cdev->device, "cooling_device%d", cdev->id);
920926 ret = device_register(&cdev->device);
921927 if (ret)
922928 goto out_kfree_type;
@@ -941,8 +947,9 @@ __thermal_cooling_device_register(struct device_node *np, · 18 unmodified lines
941947 out_kfree_type:
942948 kfree(cdev->type);
943949 put_device(&cdev->device);
950+ cdev = NULL;
944951 out_ida_remove:
945− ida_simple_remove(&thermal_cdev_ida, cdev->id);
952+ ida_simple_remove(&thermal_cdev_ida, id);
946953 out_kfree_cdev:
947954 kfree(cdev);
948955 return ERR_PTR(ret);
@@ -1227,6 +1234,10 @@ thermal_zone_device_register(const char *type, int trips, int mask, · 278 unmodified lines
12271234 tz->id = id;
12281235 strlcpy(tz->type, type, sizeof(tz->type));
12291236
1237+ result = dev_set_name(&tz->device, "thermal_zone%d", tz->id);
1238+ if (result)
1239+ goto remove_id;
1240+
12301241 if (!ops->critical)
12311242 ops->critical = thermal_zone_device_critical;
12321243
@@ -1248,7 +1259,6 @@ thermal_zone_device_register(const char *type, int trips, int mask, · 15 unmodified lines
12481259 /* A new thermal zone needs to be updated anyway. */
12491260 atomic_set(&tz->need_update, 1);
12501261
1251− dev_set_name(&tz->device, "thermal_zone%d", tz->id);
12521262 result = device_register(&tz->device);
12531263 if (result)
12541264 goto release_device;
drivers/thermal/thermal_mmio.c+1−1
@@ -34,7 +34,7 @@ static int thermal_mmio_get_temperature(void *private, int *temp) · 33 unmodified lines
3434 return 0;
3535 }
3636
37−static struct thermal_zone_of_device_ops thermal_mmio_ops = {
37+static const struct thermal_zone_of_device_ops thermal_mmio_ops = {
3838 .get_temp = thermal_mmio_get_temperature,
3939 };
4040
drivers/thermal/thermal_netlink.c+6−5
@@ -121,7 +121,8 @@ static int thermal_genl_event_tz(struct param *p) · 120 unmodified lines
121121 static int thermal_genl_event_tz_trip_up(struct param *p)
122122 {
123123 if (nla_put_u32(p->msg, THERMAL_GENL_ATTR_TZ_ID, p->tz_id) ||
124− nla_put_u32(p->msg, THERMAL_GENL_ATTR_TZ_TRIP_ID, p->trip_id))
124+ nla_put_u32(p->msg, THERMAL_GENL_ATTR_TZ_TRIP_ID, p->trip_id) ||
125+ nla_put_u32(p->msg, THERMAL_GENL_ATTR_TZ_TEMP, p->temp))
125126 return -EMSGSIZE;
126127
127128 return 0;
@@ -285,16 +286,16 @@ int thermal_notify_tz_disable(int tz_id) · 157 unmodified lines
285286 return thermal_genl_send_event(THERMAL_GENL_EVENT_TZ_DISABLE, &p);
286287 }
287288
288−int thermal_notify_tz_trip_down(int tz_id, int trip_id)
289+int thermal_notify_tz_trip_down(int tz_id, int trip_id, int temp)
289290 {
290− struct param p = { .tz_id = tz_id, .trip_id = trip_id };
291+ struct param p = { .tz_id = tz_id, .trip_id = trip_id, .temp = temp };
291292
292293 return thermal_genl_send_event(THERMAL_GENL_EVENT_TZ_TRIP_DOWN, &p);
293294 }
294295
295−int thermal_notify_tz_trip_up(int tz_id, int trip_id)
296+int thermal_notify_tz_trip_up(int tz_id, int trip_id, int temp)
296297 {
297− struct param p = { .tz_id = tz_id, .trip_id = trip_id };
298+ struct param p = { .tz_id = tz_id, .trip_id = trip_id, .temp = temp };
298299
299300 return thermal_genl_send_event(THERMAL_GENL_EVENT_TZ_TRIP_UP, &p);
300301 }
drivers/thermal/thermal_netlink.h+4−4
@@ -11,8 +11,8 @@ int thermal_notify_tz_create(int tz_id, const char *name); · 10 unmodified lines
1111 int thermal_notify_tz_delete(int tz_id);
1212 int thermal_notify_tz_enable(int tz_id);
1313 int thermal_notify_tz_disable(int tz_id);
14−int thermal_notify_tz_trip_down(int tz_id, int id);
15−int thermal_notify_tz_trip_up(int tz_id, int id);
14+int thermal_notify_tz_trip_down(int tz_id, int id, int temp);
15+int thermal_notify_tz_trip_up(int tz_id, int id, int temp);
1616 int thermal_notify_tz_trip_delete(int tz_id, int id);
1717 int thermal_notify_tz_trip_add(int tz_id, int id, int type,
1818 int temp, int hyst);
@@ -49,12 +49,12 @@ static inline int thermal_notify_tz_disable(int tz_id) · 30 unmodified lines
4949 return 0;
5050 }
5151
52−static inline int thermal_notify_tz_trip_down(int tz_id, int id)
52+static inline int thermal_notify_tz_trip_down(int tz_id, int id, int temp)
5353 {
5454 return 0;
5555 }
5656
57−static inline int thermal_notify_tz_trip_up(int tz_id, int id)
57+static inline int thermal_notify_tz_trip_up(int tz_id, int id, int temp)
5858 {
5959 return 0;
6060 }
drivers/thermal/thermal_sysfs.c+3−0
@@ -610,6 +610,9 @@ cur_state_store(struct device *dev, struct device_attribute *attr, · 609 unmodified lines
610610 unsigned long state;
611611 int result;
612612
613+ dev_warn_once(&cdev->device,
614+ "Setting cooling device state is deprecated\n");
615+
613616 if (sscanf(buf, "%ld\n", &state) != 1)
614617 return -EINVAL;
615618
drivers/thermal/uniphier_thermal.c+4−0
@@ -358,6 +358,10 @@ static const struct of_device_id uniphier_tm_dt_ids[] = { · 357 unmodified lines
358358 .compatible = "socionext,uniphier-pxs3-thermal",
359359 .data = &uniphier_ld20_tm_data,
360360 },
361+ {
362+ .compatible = "socionext,uniphier-nx1-thermal",
363+ .data = &uniphier_ld20_tm_data,
364+ },
361365 { /* sentinel */ }
362366 };
363367 MODULE_DEVICE_TABLE(of, uniphier_tm_dt_ids);