thermal.txt 18 KB

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