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