18c2ecf20Sopenharmony_ci# SPDX-License-Identifier: (GPL-2.0) 28c2ecf20Sopenharmony_ci# Copyright 2020 Linaro Ltd. 38c2ecf20Sopenharmony_ci%YAML 1.2 48c2ecf20Sopenharmony_ci--- 58c2ecf20Sopenharmony_ci$id: http://devicetree.org/schemas/thermal/thermal-zones.yaml# 68c2ecf20Sopenharmony_ci$schema: http://devicetree.org/meta-schemas/base.yaml# 78c2ecf20Sopenharmony_ci 88c2ecf20Sopenharmony_cititle: Thermal zone binding 98c2ecf20Sopenharmony_ci 108c2ecf20Sopenharmony_cimaintainers: 118c2ecf20Sopenharmony_ci - Amit Kucheria <amitk@kernel.org> 128c2ecf20Sopenharmony_ci 138c2ecf20Sopenharmony_cidescription: | 148c2ecf20Sopenharmony_ci Thermal management is achieved in devicetree by describing the sensor hardware 158c2ecf20Sopenharmony_ci and the software abstraction of cooling devices and thermal zones required to 168c2ecf20Sopenharmony_ci take appropriate action to mitigate thermal overloads. 178c2ecf20Sopenharmony_ci 188c2ecf20Sopenharmony_ci The following node types are used to completely describe a thermal management 198c2ecf20Sopenharmony_ci system in devicetree: 208c2ecf20Sopenharmony_ci - thermal-sensor: device that measures temperature, has SoC-specific bindings 218c2ecf20Sopenharmony_ci - cooling-device: device used to dissipate heat either passively or actively 228c2ecf20Sopenharmony_ci - thermal-zones: a container of the following node types used to describe all 238c2ecf20Sopenharmony_ci thermal data for the platform 248c2ecf20Sopenharmony_ci 258c2ecf20Sopenharmony_ci This binding describes the thermal-zones. 268c2ecf20Sopenharmony_ci 278c2ecf20Sopenharmony_ci The polling-delay properties of a thermal-zone are bound to the maximum dT/dt 288c2ecf20Sopenharmony_ci (temperature derivative over time) in two situations for a thermal zone: 298c2ecf20Sopenharmony_ci 1. when passive cooling is activated (polling-delay-passive) 308c2ecf20Sopenharmony_ci 2. when the zone just needs to be monitored (polling-delay) or when 318c2ecf20Sopenharmony_ci active cooling is activated. 328c2ecf20Sopenharmony_ci 338c2ecf20Sopenharmony_ci The maximum dT/dt is highly bound to hardware power consumption and 348c2ecf20Sopenharmony_ci dissipation capability. The delays should be chosen to account for said 358c2ecf20Sopenharmony_ci max dT/dt, such that a device does not cross several trip boundaries 368c2ecf20Sopenharmony_ci unexpectedly between polls. Choosing the right polling delays shall avoid 378c2ecf20Sopenharmony_ci having the device in temperature ranges that may damage the silicon structures 388c2ecf20Sopenharmony_ci and reduce silicon lifetime. 398c2ecf20Sopenharmony_ci 408c2ecf20Sopenharmony_ciproperties: 418c2ecf20Sopenharmony_ci $nodename: 428c2ecf20Sopenharmony_ci const: thermal-zones 438c2ecf20Sopenharmony_ci description: 448c2ecf20Sopenharmony_ci A /thermal-zones node is required in order to use the thermal framework to 458c2ecf20Sopenharmony_ci manage input from the various thermal zones in the system in order to 468c2ecf20Sopenharmony_ci mitigate thermal overload conditions. It does not represent a real device 478c2ecf20Sopenharmony_ci in the system, but acts as a container to link a thermal sensor device, 488c2ecf20Sopenharmony_ci platform-data regarding temperature thresholds and the mitigation actions 498c2ecf20Sopenharmony_ci to take when the temperature crosses those thresholds. 508c2ecf20Sopenharmony_ci 518c2ecf20Sopenharmony_cipatternProperties: 528c2ecf20Sopenharmony_ci "^[a-zA-Z][a-zA-Z0-9\\-]{1,12}-thermal$": 538c2ecf20Sopenharmony_ci type: object 548c2ecf20Sopenharmony_ci description: 558c2ecf20Sopenharmony_ci Each thermal zone node contains information about how frequently it 568c2ecf20Sopenharmony_ci must be checked, the sensor responsible for reporting temperature for 578c2ecf20Sopenharmony_ci this zone, one sub-node containing the various trip points for this 588c2ecf20Sopenharmony_ci zone and one sub-node containing all the zone cooling-maps. 598c2ecf20Sopenharmony_ci 608c2ecf20Sopenharmony_ci properties: 618c2ecf20Sopenharmony_ci polling-delay: 628c2ecf20Sopenharmony_ci $ref: /schemas/types.yaml#/definitions/uint32 638c2ecf20Sopenharmony_ci description: 648c2ecf20Sopenharmony_ci The maximum number of milliseconds to wait between polls when 658c2ecf20Sopenharmony_ci checking this thermal zone. Setting this to 0 disables the polling 668c2ecf20Sopenharmony_ci timers setup by the thermal framework and assumes that the thermal 678c2ecf20Sopenharmony_ci sensors in this zone support interrupts. 688c2ecf20Sopenharmony_ci 698c2ecf20Sopenharmony_ci polling-delay-passive: 708c2ecf20Sopenharmony_ci $ref: /schemas/types.yaml#/definitions/uint32 718c2ecf20Sopenharmony_ci description: 728c2ecf20Sopenharmony_ci The maximum number of milliseconds to wait between polls when 738c2ecf20Sopenharmony_ci checking this thermal zone while doing passive cooling. Setting 748c2ecf20Sopenharmony_ci this to 0 disables the polling timers setup by the thermal 758c2ecf20Sopenharmony_ci framework and assumes that the thermal sensors in this zone 768c2ecf20Sopenharmony_ci support interrupts. 778c2ecf20Sopenharmony_ci 788c2ecf20Sopenharmony_ci thermal-sensors: 798c2ecf20Sopenharmony_ci $ref: /schemas/types.yaml#/definitions/phandle-array 808c2ecf20Sopenharmony_ci maxItems: 1 818c2ecf20Sopenharmony_ci description: 828c2ecf20Sopenharmony_ci The thermal sensor phandle and sensor specifier used to monitor this 838c2ecf20Sopenharmony_ci thermal zone. 848c2ecf20Sopenharmony_ci 858c2ecf20Sopenharmony_ci coefficients: 868c2ecf20Sopenharmony_ci $ref: /schemas/types.yaml#/definitions/uint32-array 878c2ecf20Sopenharmony_ci description: 888c2ecf20Sopenharmony_ci An array of integers containing the coefficients of a linear equation 898c2ecf20Sopenharmony_ci that binds all the sensors listed in this thermal zone. 908c2ecf20Sopenharmony_ci 918c2ecf20Sopenharmony_ci The linear equation used is as follows, 928c2ecf20Sopenharmony_ci z = c0 * x0 + c1 * x1 + ... + c(n-1) * x(n-1) + cn 938c2ecf20Sopenharmony_ci where c0, c1, .., cn are the coefficients. 948c2ecf20Sopenharmony_ci 958c2ecf20Sopenharmony_ci Coefficients default to 1 in case this property is not specified. The 968c2ecf20Sopenharmony_ci coefficients are ordered and are matched with sensors by means of the 978c2ecf20Sopenharmony_ci sensor ID. Additional coefficients are interpreted as constant offset. 988c2ecf20Sopenharmony_ci 998c2ecf20Sopenharmony_ci sustainable-power: 1008c2ecf20Sopenharmony_ci $ref: /schemas/types.yaml#/definitions/uint32 1018c2ecf20Sopenharmony_ci description: 1028c2ecf20Sopenharmony_ci An estimate of the sustainable power (in mW) that this thermal zone 1038c2ecf20Sopenharmony_ci can dissipate at the desired control temperature. For reference, the 1048c2ecf20Sopenharmony_ci sustainable power of a 4-inch phone is typically 2000mW, while on a 1058c2ecf20Sopenharmony_ci 10-inch tablet is around 4500mW. 1068c2ecf20Sopenharmony_ci 1078c2ecf20Sopenharmony_ci trips: 1088c2ecf20Sopenharmony_ci type: object 1098c2ecf20Sopenharmony_ci description: 1108c2ecf20Sopenharmony_ci This node describes a set of points in the temperature domain at 1118c2ecf20Sopenharmony_ci which the thermal framework needs to take action. The actions to 1128c2ecf20Sopenharmony_ci be taken are defined in another node called cooling-maps. 1138c2ecf20Sopenharmony_ci 1148c2ecf20Sopenharmony_ci patternProperties: 1158c2ecf20Sopenharmony_ci "^[a-zA-Z][a-zA-Z0-9\\-_]{0,63}$": 1168c2ecf20Sopenharmony_ci type: object 1178c2ecf20Sopenharmony_ci 1188c2ecf20Sopenharmony_ci properties: 1198c2ecf20Sopenharmony_ci temperature: 1208c2ecf20Sopenharmony_ci $ref: /schemas/types.yaml#/definitions/int32 1218c2ecf20Sopenharmony_ci minimum: -273000 1228c2ecf20Sopenharmony_ci maximum: 200000 1238c2ecf20Sopenharmony_ci description: 1248c2ecf20Sopenharmony_ci An integer expressing the trip temperature in millicelsius. 1258c2ecf20Sopenharmony_ci 1268c2ecf20Sopenharmony_ci hysteresis: 1278c2ecf20Sopenharmony_ci $ref: /schemas/types.yaml#/definitions/uint32 1288c2ecf20Sopenharmony_ci description: 1298c2ecf20Sopenharmony_ci An unsigned integer expressing the hysteresis delta with 1308c2ecf20Sopenharmony_ci respect to the trip temperature property above, also in 1318c2ecf20Sopenharmony_ci millicelsius. Any cooling action initiated by the framework is 1328c2ecf20Sopenharmony_ci maintained until the temperature falls below 1338c2ecf20Sopenharmony_ci (trip temperature - hysteresis). This potentially prevents a 1348c2ecf20Sopenharmony_ci situation where the trip gets constantly triggered soon after 1358c2ecf20Sopenharmony_ci cooling action is removed. 1368c2ecf20Sopenharmony_ci 1378c2ecf20Sopenharmony_ci type: 1388c2ecf20Sopenharmony_ci $ref: /schemas/types.yaml#/definitions/string 1398c2ecf20Sopenharmony_ci enum: 1408c2ecf20Sopenharmony_ci - active # enable active cooling e.g. fans 1418c2ecf20Sopenharmony_ci - passive # enable passive cooling e.g. throttling cpu 1428c2ecf20Sopenharmony_ci - hot # send notification to driver 1438c2ecf20Sopenharmony_ci - critical # send notification to driver, trigger shutdown 1448c2ecf20Sopenharmony_ci description: | 1458c2ecf20Sopenharmony_ci There are four valid trip types: active, passive, hot, 1468c2ecf20Sopenharmony_ci critical. 1478c2ecf20Sopenharmony_ci 1488c2ecf20Sopenharmony_ci The critical trip type is used to set the maximum 1498c2ecf20Sopenharmony_ci temperature threshold above which the HW becomes 1508c2ecf20Sopenharmony_ci unstable and underlying firmware might even trigger a 1518c2ecf20Sopenharmony_ci reboot. Hitting the critical threshold triggers a system 1528c2ecf20Sopenharmony_ci shutdown. 1538c2ecf20Sopenharmony_ci 1548c2ecf20Sopenharmony_ci The hot trip type can be used to send a notification to 1558c2ecf20Sopenharmony_ci the thermal driver (if a .notify callback is registered). 1568c2ecf20Sopenharmony_ci The action to be taken is left to the driver. 1578c2ecf20Sopenharmony_ci 1588c2ecf20Sopenharmony_ci The passive trip type can be used to slow down HW e.g. run 1598c2ecf20Sopenharmony_ci the CPU, GPU, bus at a lower frequency. 1608c2ecf20Sopenharmony_ci 1618c2ecf20Sopenharmony_ci The active trip type can be used to control other HW to 1628c2ecf20Sopenharmony_ci help in cooling e.g. fans can be sped up or slowed down 1638c2ecf20Sopenharmony_ci 1648c2ecf20Sopenharmony_ci required: 1658c2ecf20Sopenharmony_ci - temperature 1668c2ecf20Sopenharmony_ci - hysteresis 1678c2ecf20Sopenharmony_ci - type 1688c2ecf20Sopenharmony_ci additionalProperties: false 1698c2ecf20Sopenharmony_ci 1708c2ecf20Sopenharmony_ci additionalProperties: false 1718c2ecf20Sopenharmony_ci 1728c2ecf20Sopenharmony_ci cooling-maps: 1738c2ecf20Sopenharmony_ci type: object 1748c2ecf20Sopenharmony_ci description: 1758c2ecf20Sopenharmony_ci This node describes the action to be taken when a thermal zone 1768c2ecf20Sopenharmony_ci crosses one of the temperature thresholds described in the trips 1778c2ecf20Sopenharmony_ci node. The action takes the form of a mapping relation between a 1788c2ecf20Sopenharmony_ci trip and the target cooling device state. 1798c2ecf20Sopenharmony_ci 1808c2ecf20Sopenharmony_ci patternProperties: 1818c2ecf20Sopenharmony_ci "^map[-a-zA-Z0-9]*$": 1828c2ecf20Sopenharmony_ci type: object 1838c2ecf20Sopenharmony_ci 1848c2ecf20Sopenharmony_ci properties: 1858c2ecf20Sopenharmony_ci trip: 1868c2ecf20Sopenharmony_ci $ref: /schemas/types.yaml#/definitions/phandle 1878c2ecf20Sopenharmony_ci description: 1888c2ecf20Sopenharmony_ci A phandle of a trip point node within this thermal zone. 1898c2ecf20Sopenharmony_ci 1908c2ecf20Sopenharmony_ci cooling-device: 1918c2ecf20Sopenharmony_ci $ref: /schemas/types.yaml#/definitions/phandle-array 1928c2ecf20Sopenharmony_ci description: 1938c2ecf20Sopenharmony_ci A list of cooling device phandles along with the minimum 1948c2ecf20Sopenharmony_ci and maximum cooling state specifiers for each cooling 1958c2ecf20Sopenharmony_ci device. Using the THERMAL_NO_LIMIT (-1UL) constant in the 1968c2ecf20Sopenharmony_ci cooling-device phandle limit specifier lets the framework 1978c2ecf20Sopenharmony_ci use the minimum and maximum cooling state for that cooling 1988c2ecf20Sopenharmony_ci device automatically. 1998c2ecf20Sopenharmony_ci 2008c2ecf20Sopenharmony_ci contribution: 2018c2ecf20Sopenharmony_ci $ref: /schemas/types.yaml#/definitions/uint32 2028c2ecf20Sopenharmony_ci description: 2038c2ecf20Sopenharmony_ci The cooling contribution to the thermal zone of the referred 2048c2ecf20Sopenharmony_ci cooling device at the referred trip point. The contribution is 2058c2ecf20Sopenharmony_ci a ratio of the sum of all cooling contributions within a 2068c2ecf20Sopenharmony_ci thermal zone. 2078c2ecf20Sopenharmony_ci 2088c2ecf20Sopenharmony_ci required: 2098c2ecf20Sopenharmony_ci - trip 2108c2ecf20Sopenharmony_ci - cooling-device 2118c2ecf20Sopenharmony_ci additionalProperties: false 2128c2ecf20Sopenharmony_ci 2138c2ecf20Sopenharmony_ci required: 2148c2ecf20Sopenharmony_ci - polling-delay 2158c2ecf20Sopenharmony_ci - polling-delay-passive 2168c2ecf20Sopenharmony_ci - thermal-sensors 2178c2ecf20Sopenharmony_ci - trips 2188c2ecf20Sopenharmony_ci additionalProperties: false 2198c2ecf20Sopenharmony_ci 2208c2ecf20Sopenharmony_ciadditionalProperties: false 2218c2ecf20Sopenharmony_ci 2228c2ecf20Sopenharmony_ciexamples: 2238c2ecf20Sopenharmony_ci - | 2248c2ecf20Sopenharmony_ci #include <dt-bindings/interrupt-controller/arm-gic.h> 2258c2ecf20Sopenharmony_ci #include <dt-bindings/thermal/thermal.h> 2268c2ecf20Sopenharmony_ci 2278c2ecf20Sopenharmony_ci // Example 1: SDM845 TSENS 2288c2ecf20Sopenharmony_ci soc { 2298c2ecf20Sopenharmony_ci #address-cells = <2>; 2308c2ecf20Sopenharmony_ci #size-cells = <2>; 2318c2ecf20Sopenharmony_ci 2328c2ecf20Sopenharmony_ci /* ... */ 2338c2ecf20Sopenharmony_ci 2348c2ecf20Sopenharmony_ci tsens0: thermal-sensor@c263000 { 2358c2ecf20Sopenharmony_ci compatible = "qcom,sdm845-tsens", "qcom,tsens-v2"; 2368c2ecf20Sopenharmony_ci reg = <0 0x0c263000 0 0x1ff>, /* TM */ 2378c2ecf20Sopenharmony_ci <0 0x0c222000 0 0x1ff>; /* SROT */ 2388c2ecf20Sopenharmony_ci #qcom,sensors = <13>; 2398c2ecf20Sopenharmony_ci interrupts = <GIC_SPI 506 IRQ_TYPE_LEVEL_HIGH>, 2408c2ecf20Sopenharmony_ci <GIC_SPI 508 IRQ_TYPE_LEVEL_HIGH>; 2418c2ecf20Sopenharmony_ci interrupt-names = "uplow", "critical"; 2428c2ecf20Sopenharmony_ci #thermal-sensor-cells = <1>; 2438c2ecf20Sopenharmony_ci }; 2448c2ecf20Sopenharmony_ci 2458c2ecf20Sopenharmony_ci tsens1: thermal-sensor@c265000 { 2468c2ecf20Sopenharmony_ci compatible = "qcom,sdm845-tsens", "qcom,tsens-v2"; 2478c2ecf20Sopenharmony_ci reg = <0 0x0c265000 0 0x1ff>, /* TM */ 2488c2ecf20Sopenharmony_ci <0 0x0c223000 0 0x1ff>; /* SROT */ 2498c2ecf20Sopenharmony_ci #qcom,sensors = <8>; 2508c2ecf20Sopenharmony_ci interrupts = <GIC_SPI 507 IRQ_TYPE_LEVEL_HIGH>, 2518c2ecf20Sopenharmony_ci <GIC_SPI 509 IRQ_TYPE_LEVEL_HIGH>; 2528c2ecf20Sopenharmony_ci interrupt-names = "uplow", "critical"; 2538c2ecf20Sopenharmony_ci #thermal-sensor-cells = <1>; 2548c2ecf20Sopenharmony_ci }; 2558c2ecf20Sopenharmony_ci }; 2568c2ecf20Sopenharmony_ci 2578c2ecf20Sopenharmony_ci /* ... */ 2588c2ecf20Sopenharmony_ci 2598c2ecf20Sopenharmony_ci thermal-zones { 2608c2ecf20Sopenharmony_ci cpu0-thermal { 2618c2ecf20Sopenharmony_ci polling-delay-passive = <250>; 2628c2ecf20Sopenharmony_ci polling-delay = <1000>; 2638c2ecf20Sopenharmony_ci 2648c2ecf20Sopenharmony_ci thermal-sensors = <&tsens0 1>; 2658c2ecf20Sopenharmony_ci 2668c2ecf20Sopenharmony_ci trips { 2678c2ecf20Sopenharmony_ci cpu0_alert0: trip-point0 { 2688c2ecf20Sopenharmony_ci temperature = <90000>; 2698c2ecf20Sopenharmony_ci hysteresis = <2000>; 2708c2ecf20Sopenharmony_ci type = "passive"; 2718c2ecf20Sopenharmony_ci }; 2728c2ecf20Sopenharmony_ci 2738c2ecf20Sopenharmony_ci cpu0_alert1: trip-point1 { 2748c2ecf20Sopenharmony_ci temperature = <95000>; 2758c2ecf20Sopenharmony_ci hysteresis = <2000>; 2768c2ecf20Sopenharmony_ci type = "passive"; 2778c2ecf20Sopenharmony_ci }; 2788c2ecf20Sopenharmony_ci 2798c2ecf20Sopenharmony_ci cpu0_crit: cpu_crit { 2808c2ecf20Sopenharmony_ci temperature = <110000>; 2818c2ecf20Sopenharmony_ci hysteresis = <1000>; 2828c2ecf20Sopenharmony_ci type = "critical"; 2838c2ecf20Sopenharmony_ci }; 2848c2ecf20Sopenharmony_ci }; 2858c2ecf20Sopenharmony_ci 2868c2ecf20Sopenharmony_ci cooling-maps { 2878c2ecf20Sopenharmony_ci map0 { 2888c2ecf20Sopenharmony_ci trip = <&cpu0_alert0>; 2898c2ecf20Sopenharmony_ci /* Corresponds to 1400MHz in OPP table */ 2908c2ecf20Sopenharmony_ci cooling-device = <&CPU0 3 3>, <&CPU1 3 3>, 2918c2ecf20Sopenharmony_ci <&CPU2 3 3>, <&CPU3 3 3>; 2928c2ecf20Sopenharmony_ci }; 2938c2ecf20Sopenharmony_ci 2948c2ecf20Sopenharmony_ci map1 { 2958c2ecf20Sopenharmony_ci trip = <&cpu0_alert1>; 2968c2ecf20Sopenharmony_ci /* Corresponds to 1000MHz in OPP table */ 2978c2ecf20Sopenharmony_ci cooling-device = <&CPU0 5 5>, <&CPU1 5 5>, 2988c2ecf20Sopenharmony_ci <&CPU2 5 5>, <&CPU3 5 5>; 2998c2ecf20Sopenharmony_ci }; 3008c2ecf20Sopenharmony_ci }; 3018c2ecf20Sopenharmony_ci }; 3028c2ecf20Sopenharmony_ci 3038c2ecf20Sopenharmony_ci /* ... */ 3048c2ecf20Sopenharmony_ci 3058c2ecf20Sopenharmony_ci cluster0-thermal { 3068c2ecf20Sopenharmony_ci polling-delay-passive = <250>; 3078c2ecf20Sopenharmony_ci polling-delay = <1000>; 3088c2ecf20Sopenharmony_ci 3098c2ecf20Sopenharmony_ci thermal-sensors = <&tsens0 5>; 3108c2ecf20Sopenharmony_ci 3118c2ecf20Sopenharmony_ci trips { 3128c2ecf20Sopenharmony_ci cluster0_alert0: trip-point0 { 3138c2ecf20Sopenharmony_ci temperature = <90000>; 3148c2ecf20Sopenharmony_ci hysteresis = <2000>; 3158c2ecf20Sopenharmony_ci type = "hot"; 3168c2ecf20Sopenharmony_ci }; 3178c2ecf20Sopenharmony_ci cluster0_crit: cluster0_crit { 3188c2ecf20Sopenharmony_ci temperature = <110000>; 3198c2ecf20Sopenharmony_ci hysteresis = <2000>; 3208c2ecf20Sopenharmony_ci type = "critical"; 3218c2ecf20Sopenharmony_ci }; 3228c2ecf20Sopenharmony_ci }; 3238c2ecf20Sopenharmony_ci }; 3248c2ecf20Sopenharmony_ci 3258c2ecf20Sopenharmony_ci /* ... */ 3268c2ecf20Sopenharmony_ci 3278c2ecf20Sopenharmony_ci gpu-top-thermal { 3288c2ecf20Sopenharmony_ci polling-delay-passive = <250>; 3298c2ecf20Sopenharmony_ci polling-delay = <1000>; 3308c2ecf20Sopenharmony_ci 3318c2ecf20Sopenharmony_ci thermal-sensors = <&tsens0 11>; 3328c2ecf20Sopenharmony_ci 3338c2ecf20Sopenharmony_ci trips { 3348c2ecf20Sopenharmony_ci gpu1_alert0: trip-point0 { 3358c2ecf20Sopenharmony_ci temperature = <90000>; 3368c2ecf20Sopenharmony_ci hysteresis = <2000>; 3378c2ecf20Sopenharmony_ci type = "hot"; 3388c2ecf20Sopenharmony_ci }; 3398c2ecf20Sopenharmony_ci }; 3408c2ecf20Sopenharmony_ci }; 3418c2ecf20Sopenharmony_ci }; 3428c2ecf20Sopenharmony_ci... 343