]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/blame - Documentation/devicetree/bindings/thermal/thermal.txt
Merge branch 'work.misc' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
[mirror_ubuntu-jammy-kernel.git] / Documentation / devicetree / bindings / thermal / thermal.txt
CommitLineData
4e5e4705
EV
1* Thermal Framework Device Tree descriptor
2
3This file describes a generic binding to provide a way of
4defining hardware thermal structure using device tree.
5A thermal structure includes thermal zones and their components,
6such as trip points, polling intervals, sensors and cooling devices
7binding descriptors.
8
9The target of device tree thermal descriptors is to describe only
10the hardware thermal aspects. The thermal device tree bindings are
11not about how the system must control or which algorithm or policy
12must be taken in place.
13
14There are five types of nodes involved to describe thermal bindings:
15- thermal sensors: devices which may be used to take temperature
16 measurements.
17- cooling devices: devices which may be used to dissipate heat.
18- trip points: describe key temperatures at which cooling is recommended. The
19 set of points should be chosen based on hardware limits.
20- cooling maps: used to describe links between trip points and cooling devices;
21- thermal zones: used to describe thermal data within the hardware;
22
23The following is a description of each of these node types.
24
25* Thermal sensor devices
26
27Thermal sensor devices are nodes providing temperature sensing capabilities on
28thermal zones. Typical devices are I2C ADC converters and bandgaps. These are
29nodes providing temperature data to thermal zones. Thermal sensor devices may
30control one or more internal sensors.
31
32Required property:
33- #thermal-sensor-cells: Used to provide sensor device specific information
34 Type: unsigned while referring to it. Typically 0 on thermal sensor
35 Size: one cell nodes with only one sensor, and at least 1 on nodes
36 with several internal sensors, in order
37 to identify uniquely the sensor instances within
38 the IC. See thermal zone binding for more details
39 on how consumers refer to sensor devices.
40
41* Cooling device nodes
42
43Cooling devices are nodes providing control on power dissipation. There
44are essentially two ways to provide control on power dissipation. First
45is by means of regulating device performance, which is known as passive
46cooling. A typical passive cooling is a CPU that has dynamic voltage and
47frequency scaling (DVFS), and uses lower frequencies as cooling states.
48Second is by means of activating devices in order to remove
49the dissipated heat, which is known as active cooling, e.g. regulating
50fan speeds. In both cases, cooling devices shall have a way to determine
51the state of cooling in which the device is.
52
53Any cooling device has a range of cooling states (i.e. different levels
54of heat dissipation). For example a fan's cooling states correspond to
55the different fan speeds possible. Cooling states are referred to by
56single unsigned integers, where larger numbers mean greater heat
57dissipation. The precise set of cooling states associated with a device
eb168b70 58(as referred to by the cooling-min-level and cooling-max-level
4e5e4705
EV
59properties) should be defined in a particular device's binding.
60For more examples of cooling devices, refer to the example sections below.
61
62Required properties:
4e5e4705
EV
63- #cooling-cells: Used to provide cooling device specific information
64 Type: unsigned while referring to it. Must be at least 2, in order
55f2ac33 65 Size: one cell to specify minimum and maximum cooling state used
4e5e4705
EV
66 in the reference. The first cell is the minimum
67 cooling state requested and the second cell is
68 the maximum cooling state requested in the reference.
69 See Cooling device maps section below for more details
70 on how consumers refer to cooling devices.
71
9fa04fbe
PA
72Optional properties:
73- cooling-min-level: An integer indicating the smallest
74 Type: unsigned cooling state accepted. Typically 0.
75 Size: one cell
76
77- cooling-max-level: An integer indicating the largest
78 Type: unsigned cooling state accepted.
79 Size: one cell
80
4e5e4705
EV
81* Trip points
82
83The trip node is a node to describe a point in the temperature domain
84in which the system takes an action. This node describes just the point,
85not the action.
86
87Required properties:
88- temperature: An integer indicating the trip temperature level,
89 Type: signed in millicelsius.
90 Size: one cell
91
92- hysteresis: A low hysteresis value on temperature property (above).
93 Type: unsigned This is a relative value, in millicelsius.
94 Size: one cell
95
96- type: a string containing the trip type. Expected values are:
97 "active": A trip point to enable active cooling
98 "passive": A trip point to enable passive cooling
99 "hot": A trip point to notify emergency
100 "critical": Hardware not reliable.
101 Type: string
102
103* Cooling device maps
104
105The cooling device maps node is a node to describe how cooling devices
106get assigned to trip points of the zone. The cooling devices are expected
107to be loaded in the target system.
108
109Required properties:
110- cooling-device: A phandle of a cooling device with its specifier,
111 Type: phandle + referring to which cooling device is used in this
112 cooling specifier binding. In the cooling specifier, the first cell
113 is the minimum cooling state and the second cell
114 is the maximum cooling state used in this map.
115- trip: A phandle of a trip point node within the same thermal
116 Type: phandle of zone.
117 trip point node
118
119Optional property:
120- contribution: The cooling contribution to the thermal zone of the
121 Type: unsigned referred cooling device at the referred trip point.
55f2ac33 122 Size: one cell The contribution is a ratio of the sum
4e5e4705
EV
123 of all cooling contributions within a thermal zone.
124
125Note: Using the THERMAL_NO_LIMIT (-1UL) constant in the cooling-device phandle
126limit specifier means:
127(i) - minimum state allowed for minimum cooling state used in the reference.
128(ii) - maximum state allowed for maximum cooling state used in the reference.
129Refer to include/dt-bindings/thermal/thermal.h for definition of this constant.
130
131* Thermal zone nodes
132
133The thermal zone node is the node containing all the required info
134for describing a thermal zone, including its cooling device bindings. The
135thermal zone node must contain, apart from its own properties, one sub-node
136containing trip nodes and one sub-node containing all the zone cooling maps.
137
138Required properties:
139- polling-delay: The maximum number of milliseconds to wait between polls
140 Type: unsigned when checking this thermal zone.
141 Size: one cell
142
143- polling-delay-passive: The maximum number of milliseconds to wait
144 Type: unsigned between polls when performing passive cooling.
145 Size: one cell
146
147- thermal-sensors: A list of thermal sensor phandles and sensor specifier
55f2ac33 148 Type: list of used while monitoring the thermal zone.
4e5e4705
EV
149 phandles + sensor
150 specifier
151
152- trips: A sub-node which is a container of only trip point nodes
153 Type: sub-node required to describe the thermal zone.
154
155- cooling-maps: A sub-node which is a container of only cooling device
156 Type: sub-node map nodes, used to describe the relation between trips
157 and cooling devices.
158
159Optional property:
160- coefficients: An array of integers (one signed cell) containing
161 Type: array coefficients to compose a linear relation between
162 Elem size: one cell the sensors listed in the thermal-sensors property.
163 Elem type: signed Coefficients defaults to 1, in case this property
164 is not specified. A simple linear polynomial is used:
165 Z = c0 * x0 + c1 + x1 + ... + c(n-1) * x(n-1) + cn.
166
167 The coefficients are ordered and they match with sensors
168 by means of sensor ID. Additional coefficients are
169 interpreted as constant offset.
170
647f9925
PA
171- sustainable-power: An estimate of the sustainable power (in mW) that the
172 Type: unsigned thermal zone can dissipate at the desired
173 Size: one cell control temperature. For reference, the
174 sustainable power of a 4'' phone is typically
175 2000mW, while on a 10'' tablet is around
176 4500mW.
177
4e5e4705
EV
178Note: The delay properties are bound to the maximum dT/dt (temperature
179derivative over time) in two situations for a thermal zone:
180(i) - when passive cooling is activated (polling-delay-passive); and
181(ii) - when the zone just needs to be monitored (polling-delay) or
182when active cooling is activated.
183
184The maximum dT/dt is highly bound to hardware power consumption and dissipation
185capability. The delays should be chosen to account for said max dT/dt,
186such that a device does not cross several trip boundaries unexpectedly
187between polls. Choosing the right polling delays shall avoid having the
188device in temperature ranges that may damage the silicon structures and
189reduce silicon lifetime.
190
191* The thermal-zones node
192
193The "thermal-zones" node is a container for all thermal zone nodes. It shall
194contain only sub-nodes describing thermal zones as in the section
195"Thermal zone nodes". The "thermal-zones" node appears under "/".
196
197* Examples
198
199Below are several examples on how to use thermal data descriptors
200using device tree bindings:
201
202(a) - CPU thermal zone
203
204The CPU thermal zone example below describes how to setup one thermal zone
205using one single sensor as temperature source and many cooling devices and
206power dissipation control sources.
207
208#include <dt-bindings/thermal/thermal.h>
209
210cpus {
211 /*
212 * Here is an example of describing a cooling device for a DVFS
213 * capable CPU. The CPU node describes its four OPPs.
214 * The cooling states possible are 0..3, and they are
215 * used as OPP indexes. The minimum cooling state is 0, which means
216 * all four OPPs can be available to the system. The maximum
217 * cooling state is 3, which means only the lowest OPPs (198MHz@0.85V)
218 * can be available in the system.
219 */
220 cpu0: cpu@0 {
221 ...
222 operating-points = <
223 /* kHz uV */
224 970000 1200000
225 792000 1100000
226 396000 950000
227 198000 850000
228 >;
eb168b70
PA
229 cooling-min-level = <0>;
230 cooling-max-level = <3>;
4e5e4705
EV
231 #cooling-cells = <2>; /* min followed by max */
232 };
233 ...
234};
235
236&i2c1 {
237 ...
238 /*
239 * A simple fan controller which supports 10 speeds of operation
240 * (represented as 0-9).
241 */
4c9847b7 242 fan0: fan@48 {
4e5e4705 243 ...
eb168b70
PA
244 cooling-min-level = <0>;
245 cooling-max-level = <9>;
4e5e4705
EV
246 #cooling-cells = <2>; /* min followed by max */
247 };
248};
249
250ocp {
251 ...
252 /*
253 * A simple IC with a single bandgap temperature sensor.
254 */
4c9847b7 255 bandgap0: bandgap@0000ED00 {
4e5e4705
EV
256 ...
257 #thermal-sensor-cells = <0>;
258 };
259};
260
261thermal-zones {
252454f5 262 cpu_thermal: cpu-thermal {
4e5e4705
EV
263 polling-delay-passive = <250>; /* milliseconds */
264 polling-delay = <1000>; /* milliseconds */
265
266 thermal-sensors = <&bandgap0>;
267
268 trips {
252454f5 269 cpu_alert0: cpu-alert0 {
4e5e4705
EV
270 temperature = <90000>; /* millicelsius */
271 hysteresis = <2000>; /* millicelsius */
272 type = "active";
273 };
252454f5 274 cpu_alert1: cpu-alert1 {
4e5e4705
EV
275 temperature = <100000>; /* millicelsius */
276 hysteresis = <2000>; /* millicelsius */
277 type = "passive";
278 };
252454f5 279 cpu_crit: cpu-crit {
4e5e4705
EV
280 temperature = <125000>; /* millicelsius */
281 hysteresis = <2000>; /* millicelsius */
282 type = "critical";
283 };
284 };
285
286 cooling-maps {
287 map0 {
252454f5
SK
288 trip = <&cpu_alert0>;
289 cooling-device = <&fan0 THERMAL_NO_LIMIT 4>;
4e5e4705
EV
290 };
291 map1 {
252454f5
SK
292 trip = <&cpu_alert1>;
293 cooling-device = <&fan0 5 THERMAL_NO_LIMIT>;
4e5e4705
EV
294 };
295 map2 {
252454f5 296 trip = <&cpu_alert1>;
4e5e4705 297 cooling-device =
252454f5 298 <&cpu0 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>;
4e5e4705
EV
299 };
300 };
301 };
302};
303
304In the example above, the ADC sensor (bandgap0) at address 0x0000ED00 is
305used to monitor the zone 'cpu-thermal' using its sole sensor. A fan
306device (fan0) is controlled via I2C bus 1, at address 0x48, and has ten
307different cooling states 0-9. It is used to remove the heat out of
308the thermal zone 'cpu-thermal' using its cooling states
252454f5 309from its minimum to 4, when it reaches trip point 'cpu_alert0'
4e5e4705 310at 90C, as an example of active cooling. The same cooling device is used at
252454f5 311'cpu_alert1', but from 5 to its maximum state. The cpu@0 device is also
4e5e4705 312linked to the same thermal zone, 'cpu-thermal', as a passive cooling device,
252454f5 313using all its cooling states at trip point 'cpu_alert1',
4e5e4705 314which is a trip point at 100C. On the thermal zone 'cpu-thermal', at the
252454f5 315temperature of 125C, represented by the trip point 'cpu_crit', the silicon
4e5e4705
EV
316is not reliable anymore.
317
318(b) - IC with several internal sensors
319
320The example below describes how to deploy several thermal zones based off a
321single sensor IC, assuming it has several internal sensors. This is a common
322case on SoC designs with several internal IPs that may need different thermal
323requirements, and thus may have their own sensor to monitor or detect internal
324hotspots in their silicon.
325
326#include <dt-bindings/thermal/thermal.h>
327
328ocp {
329 ...
330 /*
331 * A simple IC with several bandgap temperature sensors.
332 */
4c9847b7 333 bandgap0: bandgap@0000ED00 {
4e5e4705
EV
334 ...
335 #thermal-sensor-cells = <1>;
336 };
337};
338
339thermal-zones {
252454f5 340 cpu_thermal: cpu-thermal {
4e5e4705
EV
341 polling-delay-passive = <250>; /* milliseconds */
342 polling-delay = <1000>; /* milliseconds */
343
344 /* sensor ID */
345 thermal-sensors = <&bandgap0 0>;
346
347 trips {
348 /* each zone within the SoC may have its own trips */
252454f5 349 cpu_alert: cpu-alert {
4e5e4705
EV
350 temperature = <100000>; /* millicelsius */
351 hysteresis = <2000>; /* millicelsius */
352 type = "passive";
353 };
252454f5 354 cpu_crit: cpu-crit {
4e5e4705
EV
355 temperature = <125000>; /* millicelsius */
356 hysteresis = <2000>; /* millicelsius */
357 type = "critical";
358 };
359 };
360
361 cooling-maps {
362 /* each zone within the SoC may have its own cooling */
363 ...
364 };
365 };
366
252454f5 367 gpu_thermal: gpu-thermal {
4e5e4705
EV
368 polling-delay-passive = <120>; /* milliseconds */
369 polling-delay = <1000>; /* milliseconds */
370
371 /* sensor ID */
372 thermal-sensors = <&bandgap0 1>;
373
374 trips {
375 /* each zone within the SoC may have its own trips */
252454f5 376 gpu_alert: gpu-alert {
4e5e4705
EV
377 temperature = <90000>; /* millicelsius */
378 hysteresis = <2000>; /* millicelsius */
379 type = "passive";
380 };
252454f5 381 gpu_crit: gpu-crit {
4e5e4705
EV
382 temperature = <105000>; /* millicelsius */
383 hysteresis = <2000>; /* millicelsius */
384 type = "critical";
385 };
386 };
387
388 cooling-maps {
389 /* each zone within the SoC may have its own cooling */
390 ...
391 };
392 };
393
252454f5 394 dsp_thermal: dsp-thermal {
4e5e4705
EV
395 polling-delay-passive = <50>; /* milliseconds */
396 polling-delay = <1000>; /* milliseconds */
397
398 /* sensor ID */
399 thermal-sensors = <&bandgap0 2>;
400
401 trips {
402 /* each zone within the SoC may have its own trips */
252454f5 403 dsp_alert: dsp-alert {
4e5e4705
EV
404 temperature = <90000>; /* millicelsius */
405 hysteresis = <2000>; /* millicelsius */
406 type = "passive";
407 };
252454f5 408 dsp_crit: gpu-crit {
4e5e4705
EV
409 temperature = <135000>; /* millicelsius */
410 hysteresis = <2000>; /* millicelsius */
411 type = "critical";
412 };
413 };
414
415 cooling-maps {
416 /* each zone within the SoC may have its own cooling */
417 ...
418 };
419 };
420};
421
422In the example above, there is one bandgap IC which has the capability to
423monitor three sensors. The hardware has been designed so that sensors are
424placed on different places in the DIE to monitor different temperature
425hotspots: one for CPU thermal zone, one for GPU thermal zone and the
426other to monitor a DSP thermal zone.
427
428Thus, there is a need to assign each sensor provided by the bandgap IC
429to different thermal zones. This is achieved by means of using the
430#thermal-sensor-cells property and using the first cell of the sensor
431specifier as sensor ID. In the example, then, <bandgap 0> is used to
432monitor CPU thermal zone, <bandgap 1> is used to monitor GPU thermal
433zone and <bandgap 2> is used to monitor DSP thermal zone. Each zone
434may be uncorrelated, having its own dT/dt requirements, trips
435and cooling maps.
436
437
438(c) - Several sensors within one single thermal zone
439
440The example below illustrates how to use more than one sensor within
441one thermal zone.
442
443#include <dt-bindings/thermal/thermal.h>
444
445&i2c1 {
446 ...
447 /*
448 * A simple IC with a single temperature sensor.
449 */
4c9847b7 450 adc: sensor@49 {
4e5e4705
EV
451 ...
452 #thermal-sensor-cells = <0>;
453 };
454};
455
456ocp {
457 ...
458 /*
459 * A simple IC with a single bandgap temperature sensor.
460 */
4c9847b7 461 bandgap0: bandgap@0000ED00 {
4e5e4705
EV
462 ...
463 #thermal-sensor-cells = <0>;
464 };
465};
466
467thermal-zones {
252454f5 468 cpu_thermal: cpu-thermal {
4e5e4705
EV
469 polling-delay-passive = <250>; /* milliseconds */
470 polling-delay = <1000>; /* milliseconds */
471
472 thermal-sensors = <&bandgap0>, /* cpu */
473 <&adc>; /* pcb north */
474
475 /* hotspot = 100 * bandgap - 120 * adc + 484 */
55f2ac33 476 coefficients = <100 -120 484>;
4e5e4705
EV
477
478 trips {
479 ...
480 };
481
482 cooling-maps {
483 ...
484 };
485 };
486};
487
488In some cases, there is a need to use more than one sensor to extrapolate
489a thermal hotspot in the silicon. The above example illustrates this situation.
490For instance, it may be the case that a sensor external to CPU IP may be placed
491close to CPU hotspot and together with internal CPU sensor, it is used
492to determine the hotspot. Assuming this is the case for the above example,
493the hypothetical extrapolation rule would be:
494 hotspot = 100 * bandgap - 120 * adc + 484
495
496In other context, the same idea can be used to add fixed offset. For instance,
497consider the hotspot extrapolation rule below:
498 hotspot = 1 * adc + 6000
499
500In the above equation, the hotspot is always 6C higher than what is read
501from the ADC sensor. The binding would be then:
502 thermal-sensors = <&adc>;
503
504 /* hotspot = 1 * adc + 6000 */
55f2ac33 505 coefficients = <1 6000>;
4e5e4705
EV
506
507(d) - Board thermal
508
509The board thermal example below illustrates how to setup one thermal zone
510with many sensors and many cooling devices.
511
512#include <dt-bindings/thermal/thermal.h>
513
514&i2c1 {
515 ...
516 /*
517 * An IC with several temperature sensor.
518 */
4c9847b7 519 adc_dummy: sensor@50 {
4e5e4705
EV
520 ...
521 #thermal-sensor-cells = <1>; /* sensor internal ID */
522 };
523};
524
525thermal-zones {
526 batt-thermal {
527 polling-delay-passive = <500>; /* milliseconds */
528 polling-delay = <2500>; /* milliseconds */
529
530 /* sensor ID */
252454f5 531 thermal-sensors = <&adc_dummy 4>;
4e5e4705
EV
532
533 trips {
534 ...
535 };
536
537 cooling-maps {
538 ...
539 };
540 };
541
252454f5 542 board_thermal: board-thermal {
4e5e4705
EV
543 polling-delay-passive = <1000>; /* milliseconds */
544 polling-delay = <2500>; /* milliseconds */
545
546 /* sensor ID */
252454f5
SK
547 thermal-sensors = <&adc_dummy 0>, /* pcb top edge */
548 <&adc_dummy 1>, /* lcd */
549 <&adc_dummy 2>; /* back cover */
4e5e4705
EV
550 /*
551 * An array of coefficients describing the sensor
552 * linear relation. E.g.:
553 * z = c1*x1 + c2*x2 + c3*x3
554 */
555 coefficients = <1200 -345 890>;
556
647f9925
PA
557 sustainable-power = <2500>;
558
4e5e4705
EV
559 trips {
560 /* Trips are based on resulting linear equation */
252454f5 561 cpu_trip: cpu-trip {
4e5e4705
EV
562 temperature = <60000>; /* millicelsius */
563 hysteresis = <2000>; /* millicelsius */
564 type = "passive";
565 };
252454f5 566 gpu_trip: gpu-trip {
4e5e4705
EV
567 temperature = <55000>; /* millicelsius */
568 hysteresis = <2000>; /* millicelsius */
569 type = "passive";
570 }
252454f5 571 lcd_trip: lcp-trip {
4e5e4705
EV
572 temperature = <53000>; /* millicelsius */
573 hysteresis = <2000>; /* millicelsius */
574 type = "passive";
575 };
252454f5 576 crit_trip: crit-trip {
4e5e4705
EV
577 temperature = <68000>; /* millicelsius */
578 hysteresis = <2000>; /* millicelsius */
579 type = "critical";
580 };
581 };
582
583 cooling-maps {
584 map0 {
252454f5 585 trip = <&cpu_trip>;
4e5e4705
EV
586 cooling-device = <&cpu0 0 2>;
587 contribution = <55>;
588 };
589 map1 {
252454f5 590 trip = <&gpu_trip>;
4e5e4705
EV
591 cooling-device = <&gpu0 0 2>;
592 contribution = <20>;
593 };
594 map2 {
252454f5 595 trip = <&lcd_trip>;
4e5e4705
EV
596 cooling-device = <&lcd0 5 10>;
597 contribution = <15>;
598 };
599 };
600 };
601};
602
603The above example is a mix of previous examples, a sensor IP with several internal
604sensors used to monitor different zones, one of them is composed by several sensors and
605with different cooling devices.