thermal.txt 19 KB

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