1*4882a593Smuzhiyun# SPDX-License-Identifier: (GPL-2.0) 2*4882a593Smuzhiyun# Copyright 2020 Linaro Ltd. 3*4882a593Smuzhiyun%YAML 1.2 4*4882a593Smuzhiyun--- 5*4882a593Smuzhiyun$id: http://devicetree.org/schemas/thermal/thermal-zones.yaml# 6*4882a593Smuzhiyun$schema: http://devicetree.org/meta-schemas/base.yaml# 7*4882a593Smuzhiyun 8*4882a593Smuzhiyuntitle: Thermal zone binding 9*4882a593Smuzhiyun 10*4882a593Smuzhiyunmaintainers: 11*4882a593Smuzhiyun - Amit Kucheria <amitk@kernel.org> 12*4882a593Smuzhiyun 13*4882a593Smuzhiyundescription: | 14*4882a593Smuzhiyun Thermal management is achieved in devicetree by describing the sensor hardware 15*4882a593Smuzhiyun and the software abstraction of cooling devices and thermal zones required to 16*4882a593Smuzhiyun take appropriate action to mitigate thermal overloads. 17*4882a593Smuzhiyun 18*4882a593Smuzhiyun The following node types are used to completely describe a thermal management 19*4882a593Smuzhiyun system in devicetree: 20*4882a593Smuzhiyun - thermal-sensor: device that measures temperature, has SoC-specific bindings 21*4882a593Smuzhiyun - cooling-device: device used to dissipate heat either passively or actively 22*4882a593Smuzhiyun - thermal-zones: a container of the following node types used to describe all 23*4882a593Smuzhiyun thermal data for the platform 24*4882a593Smuzhiyun 25*4882a593Smuzhiyun This binding describes the thermal-zones. 26*4882a593Smuzhiyun 27*4882a593Smuzhiyun The polling-delay properties of a thermal-zone are bound to the maximum dT/dt 28*4882a593Smuzhiyun (temperature derivative over time) in two situations for a thermal zone: 29*4882a593Smuzhiyun 1. when passive cooling is activated (polling-delay-passive) 30*4882a593Smuzhiyun 2. when the zone just needs to be monitored (polling-delay) or when 31*4882a593Smuzhiyun active cooling is activated. 32*4882a593Smuzhiyun 33*4882a593Smuzhiyun The maximum dT/dt is highly bound to hardware power consumption and 34*4882a593Smuzhiyun dissipation capability. The delays should be chosen to account for said 35*4882a593Smuzhiyun max dT/dt, such that a device does not cross several trip boundaries 36*4882a593Smuzhiyun unexpectedly between polls. Choosing the right polling delays shall avoid 37*4882a593Smuzhiyun having the device in temperature ranges that may damage the silicon structures 38*4882a593Smuzhiyun and reduce silicon lifetime. 39*4882a593Smuzhiyun 40*4882a593Smuzhiyunproperties: 41*4882a593Smuzhiyun $nodename: 42*4882a593Smuzhiyun const: thermal-zones 43*4882a593Smuzhiyun description: 44*4882a593Smuzhiyun A /thermal-zones node is required in order to use the thermal framework to 45*4882a593Smuzhiyun manage input from the various thermal zones in the system in order to 46*4882a593Smuzhiyun mitigate thermal overload conditions. It does not represent a real device 47*4882a593Smuzhiyun in the system, but acts as a container to link a thermal sensor device, 48*4882a593Smuzhiyun platform-data regarding temperature thresholds and the mitigation actions 49*4882a593Smuzhiyun to take when the temperature crosses those thresholds. 50*4882a593Smuzhiyun 51*4882a593SmuzhiyunpatternProperties: 52*4882a593Smuzhiyun "^[a-zA-Z][a-zA-Z0-9\\-]{1,12}-thermal$": 53*4882a593Smuzhiyun type: object 54*4882a593Smuzhiyun description: 55*4882a593Smuzhiyun Each thermal zone node contains information about how frequently it 56*4882a593Smuzhiyun must be checked, the sensor responsible for reporting temperature for 57*4882a593Smuzhiyun this zone, one sub-node containing the various trip points for this 58*4882a593Smuzhiyun zone and one sub-node containing all the zone cooling-maps. 59*4882a593Smuzhiyun 60*4882a593Smuzhiyun properties: 61*4882a593Smuzhiyun polling-delay: 62*4882a593Smuzhiyun $ref: /schemas/types.yaml#/definitions/uint32 63*4882a593Smuzhiyun description: 64*4882a593Smuzhiyun The maximum number of milliseconds to wait between polls when 65*4882a593Smuzhiyun checking this thermal zone. Setting this to 0 disables the polling 66*4882a593Smuzhiyun timers setup by the thermal framework and assumes that the thermal 67*4882a593Smuzhiyun sensors in this zone support interrupts. 68*4882a593Smuzhiyun 69*4882a593Smuzhiyun polling-delay-passive: 70*4882a593Smuzhiyun $ref: /schemas/types.yaml#/definitions/uint32 71*4882a593Smuzhiyun description: 72*4882a593Smuzhiyun The maximum number of milliseconds to wait between polls when 73*4882a593Smuzhiyun checking this thermal zone while doing passive cooling. Setting 74*4882a593Smuzhiyun this to 0 disables the polling timers setup by the thermal 75*4882a593Smuzhiyun framework and assumes that the thermal sensors in this zone 76*4882a593Smuzhiyun support interrupts. 77*4882a593Smuzhiyun 78*4882a593Smuzhiyun thermal-sensors: 79*4882a593Smuzhiyun $ref: /schemas/types.yaml#/definitions/phandle-array 80*4882a593Smuzhiyun maxItems: 1 81*4882a593Smuzhiyun description: 82*4882a593Smuzhiyun The thermal sensor phandle and sensor specifier used to monitor this 83*4882a593Smuzhiyun thermal zone. 84*4882a593Smuzhiyun 85*4882a593Smuzhiyun coefficients: 86*4882a593Smuzhiyun $ref: /schemas/types.yaml#/definitions/uint32-array 87*4882a593Smuzhiyun description: 88*4882a593Smuzhiyun An array of integers containing the coefficients of a linear equation 89*4882a593Smuzhiyun that binds all the sensors listed in this thermal zone. 90*4882a593Smuzhiyun 91*4882a593Smuzhiyun The linear equation used is as follows, 92*4882a593Smuzhiyun z = c0 * x0 + c1 * x1 + ... + c(n-1) * x(n-1) + cn 93*4882a593Smuzhiyun where c0, c1, .., cn are the coefficients. 94*4882a593Smuzhiyun 95*4882a593Smuzhiyun Coefficients default to 1 in case this property is not specified. The 96*4882a593Smuzhiyun coefficients are ordered and are matched with sensors by means of the 97*4882a593Smuzhiyun sensor ID. Additional coefficients are interpreted as constant offset. 98*4882a593Smuzhiyun 99*4882a593Smuzhiyun sustainable-power: 100*4882a593Smuzhiyun $ref: /schemas/types.yaml#/definitions/uint32 101*4882a593Smuzhiyun description: 102*4882a593Smuzhiyun An estimate of the sustainable power (in mW) that this thermal zone 103*4882a593Smuzhiyun can dissipate at the desired control temperature. For reference, the 104*4882a593Smuzhiyun sustainable power of a 4-inch phone is typically 2000mW, while on a 105*4882a593Smuzhiyun 10-inch tablet is around 4500mW. 106*4882a593Smuzhiyun 107*4882a593Smuzhiyun trips: 108*4882a593Smuzhiyun type: object 109*4882a593Smuzhiyun description: 110*4882a593Smuzhiyun This node describes a set of points in the temperature domain at 111*4882a593Smuzhiyun which the thermal framework needs to take action. The actions to 112*4882a593Smuzhiyun be taken are defined in another node called cooling-maps. 113*4882a593Smuzhiyun 114*4882a593Smuzhiyun patternProperties: 115*4882a593Smuzhiyun "^[a-zA-Z][a-zA-Z0-9\\-_]{0,63}$": 116*4882a593Smuzhiyun type: object 117*4882a593Smuzhiyun 118*4882a593Smuzhiyun properties: 119*4882a593Smuzhiyun temperature: 120*4882a593Smuzhiyun $ref: /schemas/types.yaml#/definitions/int32 121*4882a593Smuzhiyun minimum: -273000 122*4882a593Smuzhiyun maximum: 200000 123*4882a593Smuzhiyun description: 124*4882a593Smuzhiyun An integer expressing the trip temperature in millicelsius. 125*4882a593Smuzhiyun 126*4882a593Smuzhiyun hysteresis: 127*4882a593Smuzhiyun $ref: /schemas/types.yaml#/definitions/uint32 128*4882a593Smuzhiyun description: 129*4882a593Smuzhiyun An unsigned integer expressing the hysteresis delta with 130*4882a593Smuzhiyun respect to the trip temperature property above, also in 131*4882a593Smuzhiyun millicelsius. Any cooling action initiated by the framework is 132*4882a593Smuzhiyun maintained until the temperature falls below 133*4882a593Smuzhiyun (trip temperature - hysteresis). This potentially prevents a 134*4882a593Smuzhiyun situation where the trip gets constantly triggered soon after 135*4882a593Smuzhiyun cooling action is removed. 136*4882a593Smuzhiyun 137*4882a593Smuzhiyun type: 138*4882a593Smuzhiyun $ref: /schemas/types.yaml#/definitions/string 139*4882a593Smuzhiyun enum: 140*4882a593Smuzhiyun - active # enable active cooling e.g. fans 141*4882a593Smuzhiyun - passive # enable passive cooling e.g. throttling cpu 142*4882a593Smuzhiyun - hot # send notification to driver 143*4882a593Smuzhiyun - critical # send notification to driver, trigger shutdown 144*4882a593Smuzhiyun description: | 145*4882a593Smuzhiyun There are four valid trip types: active, passive, hot, 146*4882a593Smuzhiyun critical. 147*4882a593Smuzhiyun 148*4882a593Smuzhiyun The critical trip type is used to set the maximum 149*4882a593Smuzhiyun temperature threshold above which the HW becomes 150*4882a593Smuzhiyun unstable and underlying firmware might even trigger a 151*4882a593Smuzhiyun reboot. Hitting the critical threshold triggers a system 152*4882a593Smuzhiyun shutdown. 153*4882a593Smuzhiyun 154*4882a593Smuzhiyun The hot trip type can be used to send a notification to 155*4882a593Smuzhiyun the thermal driver (if a .notify callback is registered). 156*4882a593Smuzhiyun The action to be taken is left to the driver. 157*4882a593Smuzhiyun 158*4882a593Smuzhiyun The passive trip type can be used to slow down HW e.g. run 159*4882a593Smuzhiyun the CPU, GPU, bus at a lower frequency. 160*4882a593Smuzhiyun 161*4882a593Smuzhiyun The active trip type can be used to control other HW to 162*4882a593Smuzhiyun help in cooling e.g. fans can be sped up or slowed down 163*4882a593Smuzhiyun 164*4882a593Smuzhiyun required: 165*4882a593Smuzhiyun - temperature 166*4882a593Smuzhiyun - hysteresis 167*4882a593Smuzhiyun - type 168*4882a593Smuzhiyun additionalProperties: false 169*4882a593Smuzhiyun 170*4882a593Smuzhiyun additionalProperties: false 171*4882a593Smuzhiyun 172*4882a593Smuzhiyun cooling-maps: 173*4882a593Smuzhiyun type: object 174*4882a593Smuzhiyun description: 175*4882a593Smuzhiyun This node describes the action to be taken when a thermal zone 176*4882a593Smuzhiyun crosses one of the temperature thresholds described in the trips 177*4882a593Smuzhiyun node. The action takes the form of a mapping relation between a 178*4882a593Smuzhiyun trip and the target cooling device state. 179*4882a593Smuzhiyun 180*4882a593Smuzhiyun patternProperties: 181*4882a593Smuzhiyun "^map[-a-zA-Z0-9]*$": 182*4882a593Smuzhiyun type: object 183*4882a593Smuzhiyun 184*4882a593Smuzhiyun properties: 185*4882a593Smuzhiyun trip: 186*4882a593Smuzhiyun $ref: /schemas/types.yaml#/definitions/phandle 187*4882a593Smuzhiyun description: 188*4882a593Smuzhiyun A phandle of a trip point node within this thermal zone. 189*4882a593Smuzhiyun 190*4882a593Smuzhiyun cooling-device: 191*4882a593Smuzhiyun $ref: /schemas/types.yaml#/definitions/phandle-array 192*4882a593Smuzhiyun description: 193*4882a593Smuzhiyun A list of cooling device phandles along with the minimum 194*4882a593Smuzhiyun and maximum cooling state specifiers for each cooling 195*4882a593Smuzhiyun device. Using the THERMAL_NO_LIMIT (-1UL) constant in the 196*4882a593Smuzhiyun cooling-device phandle limit specifier lets the framework 197*4882a593Smuzhiyun use the minimum and maximum cooling state for that cooling 198*4882a593Smuzhiyun device automatically. 199*4882a593Smuzhiyun 200*4882a593Smuzhiyun contribution: 201*4882a593Smuzhiyun $ref: /schemas/types.yaml#/definitions/uint32 202*4882a593Smuzhiyun description: 203*4882a593Smuzhiyun The cooling contribution to the thermal zone of the referred 204*4882a593Smuzhiyun cooling device at the referred trip point. The contribution is 205*4882a593Smuzhiyun a ratio of the sum of all cooling contributions within a 206*4882a593Smuzhiyun thermal zone. 207*4882a593Smuzhiyun 208*4882a593Smuzhiyun required: 209*4882a593Smuzhiyun - trip 210*4882a593Smuzhiyun - cooling-device 211*4882a593Smuzhiyun additionalProperties: false 212*4882a593Smuzhiyun 213*4882a593Smuzhiyun required: 214*4882a593Smuzhiyun - polling-delay 215*4882a593Smuzhiyun - polling-delay-passive 216*4882a593Smuzhiyun - thermal-sensors 217*4882a593Smuzhiyun - trips 218*4882a593Smuzhiyun additionalProperties: false 219*4882a593Smuzhiyun 220*4882a593SmuzhiyunadditionalProperties: false 221*4882a593Smuzhiyun 222*4882a593Smuzhiyunexamples: 223*4882a593Smuzhiyun - | 224*4882a593Smuzhiyun #include <dt-bindings/interrupt-controller/arm-gic.h> 225*4882a593Smuzhiyun #include <dt-bindings/thermal/thermal.h> 226*4882a593Smuzhiyun 227*4882a593Smuzhiyun // Example 1: SDM845 TSENS 228*4882a593Smuzhiyun soc { 229*4882a593Smuzhiyun #address-cells = <2>; 230*4882a593Smuzhiyun #size-cells = <2>; 231*4882a593Smuzhiyun 232*4882a593Smuzhiyun /* ... */ 233*4882a593Smuzhiyun 234*4882a593Smuzhiyun tsens0: thermal-sensor@c263000 { 235*4882a593Smuzhiyun compatible = "qcom,sdm845-tsens", "qcom,tsens-v2"; 236*4882a593Smuzhiyun reg = <0 0x0c263000 0 0x1ff>, /* TM */ 237*4882a593Smuzhiyun <0 0x0c222000 0 0x1ff>; /* SROT */ 238*4882a593Smuzhiyun #qcom,sensors = <13>; 239*4882a593Smuzhiyun interrupts = <GIC_SPI 506 IRQ_TYPE_LEVEL_HIGH>, 240*4882a593Smuzhiyun <GIC_SPI 508 IRQ_TYPE_LEVEL_HIGH>; 241*4882a593Smuzhiyun interrupt-names = "uplow", "critical"; 242*4882a593Smuzhiyun #thermal-sensor-cells = <1>; 243*4882a593Smuzhiyun }; 244*4882a593Smuzhiyun 245*4882a593Smuzhiyun tsens1: thermal-sensor@c265000 { 246*4882a593Smuzhiyun compatible = "qcom,sdm845-tsens", "qcom,tsens-v2"; 247*4882a593Smuzhiyun reg = <0 0x0c265000 0 0x1ff>, /* TM */ 248*4882a593Smuzhiyun <0 0x0c223000 0 0x1ff>; /* SROT */ 249*4882a593Smuzhiyun #qcom,sensors = <8>; 250*4882a593Smuzhiyun interrupts = <GIC_SPI 507 IRQ_TYPE_LEVEL_HIGH>, 251*4882a593Smuzhiyun <GIC_SPI 509 IRQ_TYPE_LEVEL_HIGH>; 252*4882a593Smuzhiyun interrupt-names = "uplow", "critical"; 253*4882a593Smuzhiyun #thermal-sensor-cells = <1>; 254*4882a593Smuzhiyun }; 255*4882a593Smuzhiyun }; 256*4882a593Smuzhiyun 257*4882a593Smuzhiyun /* ... */ 258*4882a593Smuzhiyun 259*4882a593Smuzhiyun thermal-zones { 260*4882a593Smuzhiyun cpu0-thermal { 261*4882a593Smuzhiyun polling-delay-passive = <250>; 262*4882a593Smuzhiyun polling-delay = <1000>; 263*4882a593Smuzhiyun 264*4882a593Smuzhiyun thermal-sensors = <&tsens0 1>; 265*4882a593Smuzhiyun 266*4882a593Smuzhiyun trips { 267*4882a593Smuzhiyun cpu0_alert0: trip-point0 { 268*4882a593Smuzhiyun temperature = <90000>; 269*4882a593Smuzhiyun hysteresis = <2000>; 270*4882a593Smuzhiyun type = "passive"; 271*4882a593Smuzhiyun }; 272*4882a593Smuzhiyun 273*4882a593Smuzhiyun cpu0_alert1: trip-point1 { 274*4882a593Smuzhiyun temperature = <95000>; 275*4882a593Smuzhiyun hysteresis = <2000>; 276*4882a593Smuzhiyun type = "passive"; 277*4882a593Smuzhiyun }; 278*4882a593Smuzhiyun 279*4882a593Smuzhiyun cpu0_crit: cpu_crit { 280*4882a593Smuzhiyun temperature = <110000>; 281*4882a593Smuzhiyun hysteresis = <1000>; 282*4882a593Smuzhiyun type = "critical"; 283*4882a593Smuzhiyun }; 284*4882a593Smuzhiyun }; 285*4882a593Smuzhiyun 286*4882a593Smuzhiyun cooling-maps { 287*4882a593Smuzhiyun map0 { 288*4882a593Smuzhiyun trip = <&cpu0_alert0>; 289*4882a593Smuzhiyun /* Corresponds to 1400MHz in OPP table */ 290*4882a593Smuzhiyun cooling-device = <&CPU0 3 3>, <&CPU1 3 3>, 291*4882a593Smuzhiyun <&CPU2 3 3>, <&CPU3 3 3>; 292*4882a593Smuzhiyun }; 293*4882a593Smuzhiyun 294*4882a593Smuzhiyun map1 { 295*4882a593Smuzhiyun trip = <&cpu0_alert1>; 296*4882a593Smuzhiyun /* Corresponds to 1000MHz in OPP table */ 297*4882a593Smuzhiyun cooling-device = <&CPU0 5 5>, <&CPU1 5 5>, 298*4882a593Smuzhiyun <&CPU2 5 5>, <&CPU3 5 5>; 299*4882a593Smuzhiyun }; 300*4882a593Smuzhiyun }; 301*4882a593Smuzhiyun }; 302*4882a593Smuzhiyun 303*4882a593Smuzhiyun /* ... */ 304*4882a593Smuzhiyun 305*4882a593Smuzhiyun cluster0-thermal { 306*4882a593Smuzhiyun polling-delay-passive = <250>; 307*4882a593Smuzhiyun polling-delay = <1000>; 308*4882a593Smuzhiyun 309*4882a593Smuzhiyun thermal-sensors = <&tsens0 5>; 310*4882a593Smuzhiyun 311*4882a593Smuzhiyun trips { 312*4882a593Smuzhiyun cluster0_alert0: trip-point0 { 313*4882a593Smuzhiyun temperature = <90000>; 314*4882a593Smuzhiyun hysteresis = <2000>; 315*4882a593Smuzhiyun type = "hot"; 316*4882a593Smuzhiyun }; 317*4882a593Smuzhiyun cluster0_crit: cluster0_crit { 318*4882a593Smuzhiyun temperature = <110000>; 319*4882a593Smuzhiyun hysteresis = <2000>; 320*4882a593Smuzhiyun type = "critical"; 321*4882a593Smuzhiyun }; 322*4882a593Smuzhiyun }; 323*4882a593Smuzhiyun }; 324*4882a593Smuzhiyun 325*4882a593Smuzhiyun /* ... */ 326*4882a593Smuzhiyun 327*4882a593Smuzhiyun gpu-top-thermal { 328*4882a593Smuzhiyun polling-delay-passive = <250>; 329*4882a593Smuzhiyun polling-delay = <1000>; 330*4882a593Smuzhiyun 331*4882a593Smuzhiyun thermal-sensors = <&tsens0 11>; 332*4882a593Smuzhiyun 333*4882a593Smuzhiyun trips { 334*4882a593Smuzhiyun gpu1_alert0: trip-point0 { 335*4882a593Smuzhiyun temperature = <90000>; 336*4882a593Smuzhiyun hysteresis = <2000>; 337*4882a593Smuzhiyun type = "hot"; 338*4882a593Smuzhiyun }; 339*4882a593Smuzhiyun }; 340*4882a593Smuzhiyun }; 341*4882a593Smuzhiyun }; 342*4882a593Smuzhiyun... 343