11202a442SAmit Kucheria# SPDX-License-Identifier: (GPL-2.0) 21202a442SAmit Kucheria# Copyright 2020 Linaro Ltd. 31202a442SAmit Kucheria%YAML 1.2 41202a442SAmit Kucheria--- 51202a442SAmit Kucheria$id: http://devicetree.org/schemas/thermal/thermal-zones.yaml# 61202a442SAmit Kucheria$schema: http://devicetree.org/meta-schemas/base.yaml# 71202a442SAmit Kucheria 884e85359SKrzysztof Kozlowskititle: Thermal zone 91202a442SAmit Kucheria 101202a442SAmit Kucheriamaintainers: 11b0e82ae3SRafael J. Wysocki - Daniel Lezcano <daniel.lezcano@linaro.org> 121202a442SAmit Kucheria 131202a442SAmit Kucheriadescription: | 141202a442SAmit Kucheria Thermal management is achieved in devicetree by describing the sensor hardware 151202a442SAmit Kucheria and the software abstraction of cooling devices and thermal zones required to 161202a442SAmit Kucheria take appropriate action to mitigate thermal overloads. 171202a442SAmit Kucheria 181202a442SAmit Kucheria The following node types are used to completely describe a thermal management 191202a442SAmit Kucheria system in devicetree: 201202a442SAmit Kucheria - thermal-sensor: device that measures temperature, has SoC-specific bindings 211202a442SAmit Kucheria - cooling-device: device used to dissipate heat either passively or actively 221202a442SAmit Kucheria - thermal-zones: a container of the following node types used to describe all 231202a442SAmit Kucheria thermal data for the platform 241202a442SAmit Kucheria 251202a442SAmit Kucheria This binding describes the thermal-zones. 261202a442SAmit Kucheria 271202a442SAmit Kucheria The polling-delay properties of a thermal-zone are bound to the maximum dT/dt 281202a442SAmit Kucheria (temperature derivative over time) in two situations for a thermal zone: 291202a442SAmit Kucheria 1. when passive cooling is activated (polling-delay-passive) 301202a442SAmit Kucheria 2. when the zone just needs to be monitored (polling-delay) or when 311202a442SAmit Kucheria active cooling is activated. 321202a442SAmit Kucheria 331202a442SAmit Kucheria The maximum dT/dt is highly bound to hardware power consumption and 341202a442SAmit Kucheria dissipation capability. The delays should be chosen to account for said 351202a442SAmit Kucheria max dT/dt, such that a device does not cross several trip boundaries 361202a442SAmit Kucheria unexpectedly between polls. Choosing the right polling delays shall avoid 371202a442SAmit Kucheria having the device in temperature ranges that may damage the silicon structures 381202a442SAmit Kucheria and reduce silicon lifetime. 391202a442SAmit Kucheria 401202a442SAmit Kucheriaproperties: 411202a442SAmit Kucheria $nodename: 421202a442SAmit Kucheria const: thermal-zones 431202a442SAmit Kucheria description: 441202a442SAmit Kucheria A /thermal-zones node is required in order to use the thermal framework to 451202a442SAmit Kucheria manage input from the various thermal zones in the system in order to 461202a442SAmit Kucheria mitigate thermal overload conditions. It does not represent a real device 471202a442SAmit Kucheria in the system, but acts as a container to link a thermal sensor device, 481202a442SAmit Kucheria platform-data regarding temperature thresholds and the mitigation actions 491202a442SAmit Kucheria to take when the temperature crosses those thresholds. 501202a442SAmit Kucheria 511202a442SAmit KucheriapatternProperties: 52*97e32381SKrzysztof Kozlowski # Node name is limited in size due to Linux kernel requirements - 19 53*97e32381SKrzysztof Kozlowski # characters in total (see THERMAL_NAME_LENGTH, including terminating NUL 54*97e32381SKrzysztof Kozlowski # byte): 55*97e32381SKrzysztof Kozlowski "^[a-zA-Z][a-zA-Z0-9\\-]{1,10}-thermal$": 561202a442SAmit Kucheria type: object 571202a442SAmit Kucheria description: 581202a442SAmit Kucheria Each thermal zone node contains information about how frequently it 591202a442SAmit Kucheria must be checked, the sensor responsible for reporting temperature for 601202a442SAmit Kucheria this zone, one sub-node containing the various trip points for this 611202a442SAmit Kucheria zone and one sub-node containing all the zone cooling-maps. 621202a442SAmit Kucheria 631202a442SAmit Kucheria properties: 641202a442SAmit Kucheria polling-delay: 651202a442SAmit Kucheria $ref: /schemas/types.yaml#/definitions/uint32 661202a442SAmit Kucheria description: 671202a442SAmit Kucheria The maximum number of milliseconds to wait between polls when 681202a442SAmit Kucheria checking this thermal zone. Setting this to 0 disables the polling 691202a442SAmit Kucheria timers setup by the thermal framework and assumes that the thermal 701202a442SAmit Kucheria sensors in this zone support interrupts. 711202a442SAmit Kucheria 721202a442SAmit Kucheria polling-delay-passive: 731202a442SAmit Kucheria $ref: /schemas/types.yaml#/definitions/uint32 741202a442SAmit Kucheria description: 751202a442SAmit Kucheria The maximum number of milliseconds to wait between polls when 761202a442SAmit Kucheria checking this thermal zone while doing passive cooling. Setting 771202a442SAmit Kucheria this to 0 disables the polling timers setup by the thermal 781202a442SAmit Kucheria framework and assumes that the thermal sensors in this zone 791202a442SAmit Kucheria support interrupts. 801202a442SAmit Kucheria 8187f67d17SFabio Estevam critical-action: 8287f67d17SFabio Estevam $ref: /schemas/types.yaml#/definitions/string 8387f67d17SFabio Estevam description: | 8487f67d17SFabio Estevam The action the OS should perform after the critical temperature is reached. 8587f67d17SFabio Estevam By default the system will shutdown as a safe action to prevent damage 8687f67d17SFabio Estevam to the hardware, if the property is not set. 8787f67d17SFabio Estevam The shutdown action should be always the default and preferred one. 8887f67d17SFabio Estevam Choose 'reboot' with care, as the hardware may be in thermal stress, 8987f67d17SFabio Estevam thus leading to infinite reboots that may cause damage to the hardware. 9087f67d17SFabio Estevam Make sure the firmware/bootloader will act as the last resort and take 9187f67d17SFabio Estevam over the thermal control. 9287f67d17SFabio Estevam 9387f67d17SFabio Estevam enum: 9487f67d17SFabio Estevam - shutdown 9587f67d17SFabio Estevam - reboot 9687f67d17SFabio Estevam 971202a442SAmit Kucheria thermal-sensors: 981202a442SAmit Kucheria $ref: /schemas/types.yaml#/definitions/phandle-array 991202a442SAmit Kucheria maxItems: 1 1001202a442SAmit Kucheria description: 1011202a442SAmit Kucheria The thermal sensor phandle and sensor specifier used to monitor this 1021202a442SAmit Kucheria thermal zone. 1031202a442SAmit Kucheria 1041202a442SAmit Kucheria coefficients: 1051202a442SAmit Kucheria $ref: /schemas/types.yaml#/definitions/uint32-array 1061202a442SAmit Kucheria description: 1071202a442SAmit Kucheria An array of integers containing the coefficients of a linear equation 1081202a442SAmit Kucheria that binds all the sensors listed in this thermal zone. 1091202a442SAmit Kucheria 1101202a442SAmit Kucheria The linear equation used is as follows, 1111202a442SAmit Kucheria z = c0 * x0 + c1 * x1 + ... + c(n-1) * x(n-1) + cn 1121202a442SAmit Kucheria where c0, c1, .., cn are the coefficients. 1131202a442SAmit Kucheria 1141202a442SAmit Kucheria Coefficients default to 1 in case this property is not specified. The 1151202a442SAmit Kucheria coefficients are ordered and are matched with sensors by means of the 1161202a442SAmit Kucheria sensor ID. Additional coefficients are interpreted as constant offset. 1171202a442SAmit Kucheria 1181202a442SAmit Kucheria sustainable-power: 1191202a442SAmit Kucheria $ref: /schemas/types.yaml#/definitions/uint32 1201202a442SAmit Kucheria description: 1211202a442SAmit Kucheria An estimate of the sustainable power (in mW) that this thermal zone 1221202a442SAmit Kucheria can dissipate at the desired control temperature. For reference, the 1231202a442SAmit Kucheria sustainable power of a 4-inch phone is typically 2000mW, while on a 1241202a442SAmit Kucheria 10-inch tablet is around 4500mW. 1251202a442SAmit Kucheria 1261202a442SAmit Kucheria trips: 1271202a442SAmit Kucheria type: object 1281202a442SAmit Kucheria description: 1291202a442SAmit Kucheria This node describes a set of points in the temperature domain at 1301202a442SAmit Kucheria which the thermal framework needs to take action. The actions to 1311202a442SAmit Kucheria be taken are defined in another node called cooling-maps. 1321202a442SAmit Kucheria 1331202a442SAmit Kucheria patternProperties: 1341202a442SAmit Kucheria "^[a-zA-Z][a-zA-Z0-9\\-_]{0,63}$": 1351202a442SAmit Kucheria type: object 1361202a442SAmit Kucheria 1371202a442SAmit Kucheria properties: 1381202a442SAmit Kucheria temperature: 1391202a442SAmit Kucheria $ref: /schemas/types.yaml#/definitions/int32 1401202a442SAmit Kucheria minimum: -273000 1411202a442SAmit Kucheria maximum: 200000 1421202a442SAmit Kucheria description: 1431202a442SAmit Kucheria An integer expressing the trip temperature in millicelsius. 1441202a442SAmit Kucheria 1451202a442SAmit Kucheria hysteresis: 1461202a442SAmit Kucheria $ref: /schemas/types.yaml#/definitions/uint32 1471202a442SAmit Kucheria description: 1481202a442SAmit Kucheria An unsigned integer expressing the hysteresis delta with 1491202a442SAmit Kucheria respect to the trip temperature property above, also in 1501202a442SAmit Kucheria millicelsius. Any cooling action initiated by the framework is 1511202a442SAmit Kucheria maintained until the temperature falls below 1521202a442SAmit Kucheria (trip temperature - hysteresis). This potentially prevents a 1531202a442SAmit Kucheria situation where the trip gets constantly triggered soon after 1541202a442SAmit Kucheria cooling action is removed. 1551202a442SAmit Kucheria 1561202a442SAmit Kucheria type: 1571202a442SAmit Kucheria $ref: /schemas/types.yaml#/definitions/string 1581202a442SAmit Kucheria enum: 1591202a442SAmit Kucheria - active # enable active cooling e.g. fans 1601202a442SAmit Kucheria - passive # enable passive cooling e.g. throttling cpu 1611202a442SAmit Kucheria - hot # send notification to driver 1621202a442SAmit Kucheria - critical # send notification to driver, trigger shutdown 1631202a442SAmit Kucheria description: | 1641202a442SAmit Kucheria There are four valid trip types: active, passive, hot, 1651202a442SAmit Kucheria critical. 1661202a442SAmit Kucheria 1671202a442SAmit Kucheria The critical trip type is used to set the maximum 1681202a442SAmit Kucheria temperature threshold above which the HW becomes 1691202a442SAmit Kucheria unstable and underlying firmware might even trigger a 1701202a442SAmit Kucheria reboot. Hitting the critical threshold triggers a system 1711202a442SAmit Kucheria shutdown. 1721202a442SAmit Kucheria 1731202a442SAmit Kucheria The hot trip type can be used to send a notification to 1741202a442SAmit Kucheria the thermal driver (if a .notify callback is registered). 1751202a442SAmit Kucheria The action to be taken is left to the driver. 1761202a442SAmit Kucheria 1771202a442SAmit Kucheria The passive trip type can be used to slow down HW e.g. run 1781202a442SAmit Kucheria the CPU, GPU, bus at a lower frequency. 1791202a442SAmit Kucheria 1801202a442SAmit Kucheria The active trip type can be used to control other HW to 1811202a442SAmit Kucheria help in cooling e.g. fans can be sped up or slowed down 1821202a442SAmit Kucheria 1831202a442SAmit Kucheria required: 1841202a442SAmit Kucheria - temperature 1851202a442SAmit Kucheria - hysteresis 1861202a442SAmit Kucheria - type 1871202a442SAmit Kucheria additionalProperties: false 1881202a442SAmit Kucheria 1891202a442SAmit Kucheria additionalProperties: false 1901202a442SAmit Kucheria 1911202a442SAmit Kucheria cooling-maps: 1921202a442SAmit Kucheria type: object 193e62fc182SRob Herring additionalProperties: false 1941202a442SAmit Kucheria description: 1951202a442SAmit Kucheria This node describes the action to be taken when a thermal zone 1961202a442SAmit Kucheria crosses one of the temperature thresholds described in the trips 1971202a442SAmit Kucheria node. The action takes the form of a mapping relation between a 1981202a442SAmit Kucheria trip and the target cooling device state. 1991202a442SAmit Kucheria 2001202a442SAmit Kucheria patternProperties: 2011202a442SAmit Kucheria "^map[-a-zA-Z0-9]*$": 2021202a442SAmit Kucheria type: object 2031202a442SAmit Kucheria 2041202a442SAmit Kucheria properties: 2051202a442SAmit Kucheria trip: 2061202a442SAmit Kucheria $ref: /schemas/types.yaml#/definitions/phandle 2071202a442SAmit Kucheria description: 2081202a442SAmit Kucheria A phandle of a trip point node within this thermal zone. 2091202a442SAmit Kucheria 2101202a442SAmit Kucheria cooling-device: 2111202a442SAmit Kucheria $ref: /schemas/types.yaml#/definitions/phandle-array 2121202a442SAmit Kucheria description: 2131202a442SAmit Kucheria A list of cooling device phandles along with the minimum 2141202a442SAmit Kucheria and maximum cooling state specifiers for each cooling 2151202a442SAmit Kucheria device. Using the THERMAL_NO_LIMIT (-1UL) constant in the 2161202a442SAmit Kucheria cooling-device phandle limit specifier lets the framework 2171202a442SAmit Kucheria use the minimum and maximum cooling state for that cooling 2181202a442SAmit Kucheria device automatically. 2191202a442SAmit Kucheria 2201202a442SAmit Kucheria contribution: 2211202a442SAmit Kucheria $ref: /schemas/types.yaml#/definitions/uint32 2221202a442SAmit Kucheria description: 22349bcb150SNiklas Söderlund The cooling contribution to the thermal zone of the referred 22449bcb150SNiklas Söderlund cooling device at the referred trip point. The contribution is 22549bcb150SNiklas Söderlund a ratio of the sum of all cooling contributions within a 22649bcb150SNiklas Söderlund thermal zone. 2271202a442SAmit Kucheria 2281202a442SAmit Kucheria required: 2291202a442SAmit Kucheria - trip 2301202a442SAmit Kucheria - cooling-device 2311202a442SAmit Kucheria additionalProperties: false 2321202a442SAmit Kucheria 2331202a442SAmit Kucheria required: 2341202a442SAmit Kucheria - thermal-sensors 23522fc8575SMaxime Ripard 2361202a442SAmit Kucheria additionalProperties: false 2371202a442SAmit Kucheria 2385be478f9SRob HerringadditionalProperties: false 2395be478f9SRob Herring 2401202a442SAmit Kucheriaexamples: 2411202a442SAmit Kucheria - | 2421202a442SAmit Kucheria #include <dt-bindings/interrupt-controller/arm-gic.h> 2431202a442SAmit Kucheria #include <dt-bindings/thermal/thermal.h> 2441202a442SAmit Kucheria 2451202a442SAmit Kucheria // Example 1: SDM845 TSENS 24634b96106SFabio Estevam soc { 2471202a442SAmit Kucheria #address-cells = <2>; 2481202a442SAmit Kucheria #size-cells = <2>; 2491202a442SAmit Kucheria 2501202a442SAmit Kucheria /* ... */ 2511202a442SAmit Kucheria 2521202a442SAmit Kucheria tsens0: thermal-sensor@c263000 { 2531202a442SAmit Kucheria compatible = "qcom,sdm845-tsens", "qcom,tsens-v2"; 2541202a442SAmit Kucheria reg = <0 0x0c263000 0 0x1ff>, /* TM */ 2551202a442SAmit Kucheria <0 0x0c222000 0 0x1ff>; /* SROT */ 2561202a442SAmit Kucheria #qcom,sensors = <13>; 2571202a442SAmit Kucheria interrupts = <GIC_SPI 506 IRQ_TYPE_LEVEL_HIGH>, 2581202a442SAmit Kucheria <GIC_SPI 508 IRQ_TYPE_LEVEL_HIGH>; 2591202a442SAmit Kucheria interrupt-names = "uplow", "critical"; 2601202a442SAmit Kucheria #thermal-sensor-cells = <1>; 2611202a442SAmit Kucheria }; 2621202a442SAmit Kucheria 2631202a442SAmit Kucheria tsens1: thermal-sensor@c265000 { 2641202a442SAmit Kucheria compatible = "qcom,sdm845-tsens", "qcom,tsens-v2"; 2651202a442SAmit Kucheria reg = <0 0x0c265000 0 0x1ff>, /* TM */ 2661202a442SAmit Kucheria <0 0x0c223000 0 0x1ff>; /* SROT */ 2671202a442SAmit Kucheria #qcom,sensors = <8>; 2681202a442SAmit Kucheria interrupts = <GIC_SPI 507 IRQ_TYPE_LEVEL_HIGH>, 2691202a442SAmit Kucheria <GIC_SPI 509 IRQ_TYPE_LEVEL_HIGH>; 2701202a442SAmit Kucheria interrupt-names = "uplow", "critical"; 2711202a442SAmit Kucheria #thermal-sensor-cells = <1>; 2721202a442SAmit Kucheria }; 2731202a442SAmit Kucheria }; 2741202a442SAmit Kucheria 2751202a442SAmit Kucheria /* ... */ 2761202a442SAmit Kucheria 2771202a442SAmit Kucheria thermal-zones { 2781202a442SAmit Kucheria cpu0-thermal { 2791202a442SAmit Kucheria polling-delay-passive = <250>; 2801202a442SAmit Kucheria polling-delay = <1000>; 2811202a442SAmit Kucheria 2821202a442SAmit Kucheria thermal-sensors = <&tsens0 1>; 2831202a442SAmit Kucheria 2841202a442SAmit Kucheria trips { 2851202a442SAmit Kucheria cpu0_alert0: trip-point0 { 2861202a442SAmit Kucheria temperature = <90000>; 2871202a442SAmit Kucheria hysteresis = <2000>; 2881202a442SAmit Kucheria type = "passive"; 2891202a442SAmit Kucheria }; 2901202a442SAmit Kucheria 2911202a442SAmit Kucheria cpu0_alert1: trip-point1 { 2921202a442SAmit Kucheria temperature = <95000>; 2931202a442SAmit Kucheria hysteresis = <2000>; 2941202a442SAmit Kucheria type = "passive"; 2951202a442SAmit Kucheria }; 2961202a442SAmit Kucheria 2971202a442SAmit Kucheria cpu0_crit: cpu_crit { 2981202a442SAmit Kucheria temperature = <110000>; 2991202a442SAmit Kucheria hysteresis = <1000>; 3001202a442SAmit Kucheria type = "critical"; 3011202a442SAmit Kucheria }; 3021202a442SAmit Kucheria }; 3031202a442SAmit Kucheria 3041202a442SAmit Kucheria cooling-maps { 3051202a442SAmit Kucheria map0 { 3061202a442SAmit Kucheria trip = <&cpu0_alert0>; 3071202a442SAmit Kucheria /* Corresponds to 1400MHz in OPP table */ 3081202a442SAmit Kucheria cooling-device = <&CPU0 3 3>, <&CPU1 3 3>, 3091202a442SAmit Kucheria <&CPU2 3 3>, <&CPU3 3 3>; 3101202a442SAmit Kucheria }; 3111202a442SAmit Kucheria 3121202a442SAmit Kucheria map1 { 3131202a442SAmit Kucheria trip = <&cpu0_alert1>; 3141202a442SAmit Kucheria /* Corresponds to 1000MHz in OPP table */ 3151202a442SAmit Kucheria cooling-device = <&CPU0 5 5>, <&CPU1 5 5>, 3161202a442SAmit Kucheria <&CPU2 5 5>, <&CPU3 5 5>; 3171202a442SAmit Kucheria }; 3181202a442SAmit Kucheria }; 3191202a442SAmit Kucheria }; 3201202a442SAmit Kucheria 3211202a442SAmit Kucheria /* ... */ 3221202a442SAmit Kucheria 3231202a442SAmit Kucheria cluster0-thermal { 3241202a442SAmit Kucheria polling-delay-passive = <250>; 3251202a442SAmit Kucheria polling-delay = <1000>; 3261202a442SAmit Kucheria 3271202a442SAmit Kucheria thermal-sensors = <&tsens0 5>; 3281202a442SAmit Kucheria 3291202a442SAmit Kucheria trips { 3301202a442SAmit Kucheria cluster0_alert0: trip-point0 { 3311202a442SAmit Kucheria temperature = <90000>; 3321202a442SAmit Kucheria hysteresis = <2000>; 3331202a442SAmit Kucheria type = "hot"; 3341202a442SAmit Kucheria }; 3351202a442SAmit Kucheria cluster0_crit: cluster0_crit { 3361202a442SAmit Kucheria temperature = <110000>; 3371202a442SAmit Kucheria hysteresis = <2000>; 3381202a442SAmit Kucheria type = "critical"; 3391202a442SAmit Kucheria }; 3401202a442SAmit Kucheria }; 3411202a442SAmit Kucheria }; 3421202a442SAmit Kucheria 3431202a442SAmit Kucheria /* ... */ 3441202a442SAmit Kucheria 3451202a442SAmit Kucheria gpu-top-thermal { 3461202a442SAmit Kucheria polling-delay-passive = <250>; 3471202a442SAmit Kucheria polling-delay = <1000>; 3481202a442SAmit Kucheria 3491202a442SAmit Kucheria thermal-sensors = <&tsens0 11>; 3501202a442SAmit Kucheria 3511202a442SAmit Kucheria trips { 3521202a442SAmit Kucheria gpu1_alert0: trip-point0 { 3531202a442SAmit Kucheria temperature = <90000>; 3541202a442SAmit Kucheria hysteresis = <2000>; 3551202a442SAmit Kucheria type = "hot"; 3561202a442SAmit Kucheria }; 3571202a442SAmit Kucheria }; 3581202a442SAmit Kucheria }; 3591202a442SAmit Kucheria }; 3601202a442SAmit Kucheria... 361