xref: /openbmc/linux/Documentation/devicetree/bindings/thermal/thermal-zones.yaml (revision 7e24a55b2122746c2eef192296fc84624354f895)
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:
111202a442SAmit Kucheria  - Amit Kucheria <amitk@kernel.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*a0495607SKrzysztof Kozlowski  # Node name is limited in size due to Linux kernel requirements - 19
53*a0495607SKrzysztof Kozlowski  # characters in total (see THERMAL_NAME_LENGTH, including terminating NUL
54*a0495607SKrzysztof Kozlowski  # byte):
55*a0495607SKrzysztof 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
811202a442SAmit Kucheria      thermal-sensors:
821202a442SAmit Kucheria        $ref: /schemas/types.yaml#/definitions/phandle-array
831202a442SAmit Kucheria        maxItems: 1
841202a442SAmit Kucheria        description:
851202a442SAmit Kucheria          The thermal sensor phandle and sensor specifier used to monitor this
861202a442SAmit Kucheria          thermal zone.
871202a442SAmit Kucheria
881202a442SAmit Kucheria      coefficients:
891202a442SAmit Kucheria        $ref: /schemas/types.yaml#/definitions/uint32-array
901202a442SAmit Kucheria        description:
911202a442SAmit Kucheria          An array of integers containing the coefficients of a linear equation
921202a442SAmit Kucheria          that binds all the sensors listed in this thermal zone.
931202a442SAmit Kucheria
941202a442SAmit Kucheria          The linear equation used is as follows,
951202a442SAmit Kucheria            z = c0 * x0 + c1 * x1 + ... + c(n-1) * x(n-1) + cn
961202a442SAmit Kucheria          where c0, c1, .., cn are the coefficients.
971202a442SAmit Kucheria
981202a442SAmit Kucheria          Coefficients default to 1 in case this property is not specified. The
991202a442SAmit Kucheria          coefficients are ordered and are matched with sensors by means of the
1001202a442SAmit Kucheria          sensor ID. Additional coefficients are interpreted as constant offset.
1011202a442SAmit Kucheria
1021202a442SAmit Kucheria      sustainable-power:
1031202a442SAmit Kucheria        $ref: /schemas/types.yaml#/definitions/uint32
1041202a442SAmit Kucheria        description:
1051202a442SAmit Kucheria          An estimate of the sustainable power (in mW) that this thermal zone
1061202a442SAmit Kucheria          can dissipate at the desired control temperature. For reference, the
1071202a442SAmit Kucheria          sustainable power of a 4-inch phone is typically 2000mW, while on a
1081202a442SAmit Kucheria          10-inch tablet is around 4500mW.
1091202a442SAmit Kucheria
1101202a442SAmit Kucheria      trips:
1111202a442SAmit Kucheria        type: object
1121202a442SAmit Kucheria        description:
1131202a442SAmit Kucheria          This node describes a set of points in the temperature domain at
1141202a442SAmit Kucheria          which the thermal framework needs to take action. The actions to
1151202a442SAmit Kucheria          be taken are defined in another node called cooling-maps.
1161202a442SAmit Kucheria
1171202a442SAmit Kucheria        patternProperties:
1181202a442SAmit Kucheria          "^[a-zA-Z][a-zA-Z0-9\\-_]{0,63}$":
1191202a442SAmit Kucheria            type: object
1201202a442SAmit Kucheria
1211202a442SAmit Kucheria            properties:
1221202a442SAmit Kucheria              temperature:
1231202a442SAmit Kucheria                $ref: /schemas/types.yaml#/definitions/int32
1241202a442SAmit Kucheria                minimum: -273000
1251202a442SAmit Kucheria                maximum: 200000
1261202a442SAmit Kucheria                description:
1271202a442SAmit Kucheria                  An integer expressing the trip temperature in millicelsius.
1281202a442SAmit Kucheria
1291202a442SAmit Kucheria              hysteresis:
1301202a442SAmit Kucheria                $ref: /schemas/types.yaml#/definitions/uint32
1311202a442SAmit Kucheria                description:
1321202a442SAmit Kucheria                  An unsigned integer expressing the hysteresis delta with
1331202a442SAmit Kucheria                  respect to the trip temperature property above, also in
1341202a442SAmit Kucheria                  millicelsius. Any cooling action initiated by the framework is
1351202a442SAmit Kucheria                  maintained until the temperature falls below
1361202a442SAmit Kucheria                  (trip temperature - hysteresis). This potentially prevents a
1371202a442SAmit Kucheria                  situation where the trip gets constantly triggered soon after
1381202a442SAmit Kucheria                  cooling action is removed.
1391202a442SAmit Kucheria
1401202a442SAmit Kucheria              type:
1411202a442SAmit Kucheria                $ref: /schemas/types.yaml#/definitions/string
1421202a442SAmit Kucheria                enum:
1431202a442SAmit Kucheria                  - active   # enable active cooling e.g. fans
1441202a442SAmit Kucheria                  - passive  # enable passive cooling e.g. throttling cpu
1451202a442SAmit Kucheria                  - hot      # send notification to driver
1461202a442SAmit Kucheria                  - critical # send notification to driver, trigger shutdown
1471202a442SAmit Kucheria                description: |
1481202a442SAmit Kucheria                  There are four valid trip types: active, passive, hot,
1491202a442SAmit Kucheria                  critical.
1501202a442SAmit Kucheria
1511202a442SAmit Kucheria                  The critical trip type is used to set the maximum
1521202a442SAmit Kucheria                  temperature threshold above which the HW becomes
1531202a442SAmit Kucheria                  unstable and underlying firmware might even trigger a
1541202a442SAmit Kucheria                  reboot. Hitting the critical threshold triggers a system
1551202a442SAmit Kucheria                  shutdown.
1561202a442SAmit Kucheria
1571202a442SAmit Kucheria                  The hot trip type can be used to send a notification to
1581202a442SAmit Kucheria                  the thermal driver (if a .notify callback is registered).
1591202a442SAmit Kucheria                  The action to be taken is left to the driver.
1601202a442SAmit Kucheria
1611202a442SAmit Kucheria                  The passive trip type can be used to slow down HW e.g. run
1621202a442SAmit Kucheria                  the CPU, GPU, bus at a lower frequency.
1631202a442SAmit Kucheria
1641202a442SAmit Kucheria                  The active trip type can be used to control other HW to
1651202a442SAmit Kucheria                  help in cooling e.g. fans can be sped up or slowed down
1661202a442SAmit Kucheria
1671202a442SAmit Kucheria            required:
1681202a442SAmit Kucheria              - temperature
1691202a442SAmit Kucheria              - hysteresis
1701202a442SAmit Kucheria              - type
1711202a442SAmit Kucheria            additionalProperties: false
1721202a442SAmit Kucheria
1731202a442SAmit Kucheria        additionalProperties: false
1741202a442SAmit Kucheria
1751202a442SAmit Kucheria      cooling-maps:
1761202a442SAmit Kucheria        type: object
177e62fc182SRob Herring        additionalProperties: false
1781202a442SAmit Kucheria        description:
1791202a442SAmit Kucheria          This node describes the action to be taken when a thermal zone
1801202a442SAmit Kucheria          crosses one of the temperature thresholds described in the trips
1811202a442SAmit Kucheria          node. The action takes the form of a mapping relation between a
1821202a442SAmit Kucheria          trip and the target cooling device state.
1831202a442SAmit Kucheria
1841202a442SAmit Kucheria        patternProperties:
1851202a442SAmit Kucheria          "^map[-a-zA-Z0-9]*$":
1861202a442SAmit Kucheria            type: object
1871202a442SAmit Kucheria
1881202a442SAmit Kucheria            properties:
1891202a442SAmit Kucheria              trip:
1901202a442SAmit Kucheria                $ref: /schemas/types.yaml#/definitions/phandle
1911202a442SAmit Kucheria                description:
1921202a442SAmit Kucheria                  A phandle of a trip point node within this thermal zone.
1931202a442SAmit Kucheria
1941202a442SAmit Kucheria              cooling-device:
1951202a442SAmit Kucheria                $ref: /schemas/types.yaml#/definitions/phandle-array
1961202a442SAmit Kucheria                description:
1971202a442SAmit Kucheria                  A list of cooling device phandles along with the minimum
1981202a442SAmit Kucheria                  and maximum cooling state specifiers for each cooling
1991202a442SAmit Kucheria                  device. Using the THERMAL_NO_LIMIT (-1UL) constant in the
2001202a442SAmit Kucheria                  cooling-device phandle limit specifier lets the framework
2011202a442SAmit Kucheria                  use the minimum and maximum cooling state for that cooling
2021202a442SAmit Kucheria                  device automatically.
2031202a442SAmit Kucheria
2041202a442SAmit Kucheria              contribution:
2051202a442SAmit Kucheria                $ref: /schemas/types.yaml#/definitions/uint32
2061202a442SAmit Kucheria                description:
20749bcb150SNiklas Söderlund                  The cooling contribution to the thermal zone of the referred
20849bcb150SNiklas Söderlund                  cooling device at the referred trip point. The contribution is
20949bcb150SNiklas Söderlund                  a ratio of the sum of all cooling contributions within a
21049bcb150SNiklas Söderlund                  thermal zone.
2111202a442SAmit Kucheria
2121202a442SAmit Kucheria            required:
2131202a442SAmit Kucheria              - trip
2141202a442SAmit Kucheria              - cooling-device
2151202a442SAmit Kucheria            additionalProperties: false
2161202a442SAmit Kucheria
2171202a442SAmit Kucheria    required:
2181202a442SAmit Kucheria      - polling-delay
2191202a442SAmit Kucheria      - polling-delay-passive
2201202a442SAmit Kucheria      - thermal-sensors
2218c596324SDaniel Lezcano      - trips
22222fc8575SMaxime Ripard
2231202a442SAmit Kucheria    additionalProperties: false
2241202a442SAmit Kucheria
2255be478f9SRob HerringadditionalProperties: false
2265be478f9SRob Herring
2271202a442SAmit Kucheriaexamples:
2281202a442SAmit Kucheria  - |
2291202a442SAmit Kucheria    #include <dt-bindings/interrupt-controller/arm-gic.h>
2301202a442SAmit Kucheria    #include <dt-bindings/thermal/thermal.h>
2311202a442SAmit Kucheria
2321202a442SAmit Kucheria    // Example 1: SDM845 TSENS
23334b96106SFabio Estevam    soc {
2341202a442SAmit Kucheria            #address-cells = <2>;
2351202a442SAmit Kucheria            #size-cells = <2>;
2361202a442SAmit Kucheria
2371202a442SAmit Kucheria            /* ... */
2381202a442SAmit Kucheria
2391202a442SAmit Kucheria            tsens0: thermal-sensor@c263000 {
2401202a442SAmit Kucheria                    compatible = "qcom,sdm845-tsens", "qcom,tsens-v2";
2411202a442SAmit Kucheria                    reg = <0 0x0c263000 0 0x1ff>, /* TM */
2421202a442SAmit Kucheria                          <0 0x0c222000 0 0x1ff>; /* SROT */
2431202a442SAmit Kucheria                    #qcom,sensors = <13>;
2441202a442SAmit Kucheria                    interrupts = <GIC_SPI 506 IRQ_TYPE_LEVEL_HIGH>,
2451202a442SAmit Kucheria                                 <GIC_SPI 508 IRQ_TYPE_LEVEL_HIGH>;
2461202a442SAmit Kucheria                    interrupt-names = "uplow", "critical";
2471202a442SAmit Kucheria                    #thermal-sensor-cells = <1>;
2481202a442SAmit Kucheria            };
2491202a442SAmit Kucheria
2501202a442SAmit Kucheria            tsens1: thermal-sensor@c265000 {
2511202a442SAmit Kucheria                    compatible = "qcom,sdm845-tsens", "qcom,tsens-v2";
2521202a442SAmit Kucheria                    reg = <0 0x0c265000 0 0x1ff>, /* TM */
2531202a442SAmit Kucheria                          <0 0x0c223000 0 0x1ff>; /* SROT */
2541202a442SAmit Kucheria                    #qcom,sensors = <8>;
2551202a442SAmit Kucheria                    interrupts = <GIC_SPI 507 IRQ_TYPE_LEVEL_HIGH>,
2561202a442SAmit Kucheria                                 <GIC_SPI 509 IRQ_TYPE_LEVEL_HIGH>;
2571202a442SAmit Kucheria                    interrupt-names = "uplow", "critical";
2581202a442SAmit Kucheria                    #thermal-sensor-cells = <1>;
2591202a442SAmit Kucheria            };
2601202a442SAmit Kucheria    };
2611202a442SAmit Kucheria
2621202a442SAmit Kucheria    /* ... */
2631202a442SAmit Kucheria
2641202a442SAmit Kucheria    thermal-zones {
2651202a442SAmit Kucheria            cpu0-thermal {
2661202a442SAmit Kucheria                    polling-delay-passive = <250>;
2671202a442SAmit Kucheria                    polling-delay = <1000>;
2681202a442SAmit Kucheria
2691202a442SAmit Kucheria                    thermal-sensors = <&tsens0 1>;
2701202a442SAmit Kucheria
2711202a442SAmit Kucheria                    trips {
2721202a442SAmit Kucheria                            cpu0_alert0: trip-point0 {
2731202a442SAmit Kucheria                                    temperature = <90000>;
2741202a442SAmit Kucheria                                    hysteresis = <2000>;
2751202a442SAmit Kucheria                                    type = "passive";
2761202a442SAmit Kucheria                            };
2771202a442SAmit Kucheria
2781202a442SAmit Kucheria                            cpu0_alert1: trip-point1 {
2791202a442SAmit Kucheria                                    temperature = <95000>;
2801202a442SAmit Kucheria                                    hysteresis = <2000>;
2811202a442SAmit Kucheria                                    type = "passive";
2821202a442SAmit Kucheria                            };
2831202a442SAmit Kucheria
2841202a442SAmit Kucheria                            cpu0_crit: cpu_crit {
2851202a442SAmit Kucheria                                    temperature = <110000>;
2861202a442SAmit Kucheria                                    hysteresis = <1000>;
2871202a442SAmit Kucheria                                    type = "critical";
2881202a442SAmit Kucheria                            };
2891202a442SAmit Kucheria                    };
2901202a442SAmit Kucheria
2911202a442SAmit Kucheria                    cooling-maps {
2921202a442SAmit Kucheria                            map0 {
2931202a442SAmit Kucheria                                    trip = <&cpu0_alert0>;
2941202a442SAmit Kucheria                                    /* Corresponds to 1400MHz in OPP table */
2951202a442SAmit Kucheria                                    cooling-device = <&CPU0 3 3>, <&CPU1 3 3>,
2961202a442SAmit Kucheria                                                     <&CPU2 3 3>, <&CPU3 3 3>;
2971202a442SAmit Kucheria                            };
2981202a442SAmit Kucheria
2991202a442SAmit Kucheria                            map1 {
3001202a442SAmit Kucheria                                    trip = <&cpu0_alert1>;
3011202a442SAmit Kucheria                                    /* Corresponds to 1000MHz in OPP table */
3021202a442SAmit Kucheria                                    cooling-device = <&CPU0 5 5>, <&CPU1 5 5>,
3031202a442SAmit Kucheria                                                     <&CPU2 5 5>, <&CPU3 5 5>;
3041202a442SAmit Kucheria                            };
3051202a442SAmit Kucheria                    };
3061202a442SAmit Kucheria            };
3071202a442SAmit Kucheria
3081202a442SAmit Kucheria            /* ... */
3091202a442SAmit Kucheria
3101202a442SAmit Kucheria            cluster0-thermal {
3111202a442SAmit Kucheria                    polling-delay-passive = <250>;
3121202a442SAmit Kucheria                    polling-delay = <1000>;
3131202a442SAmit Kucheria
3141202a442SAmit Kucheria                    thermal-sensors = <&tsens0 5>;
3151202a442SAmit Kucheria
3161202a442SAmit Kucheria                    trips {
3171202a442SAmit Kucheria                            cluster0_alert0: trip-point0 {
3181202a442SAmit Kucheria                                    temperature = <90000>;
3191202a442SAmit Kucheria                                    hysteresis = <2000>;
3201202a442SAmit Kucheria                                    type = "hot";
3211202a442SAmit Kucheria                            };
3221202a442SAmit Kucheria                            cluster0_crit: cluster0_crit {
3231202a442SAmit Kucheria                                    temperature = <110000>;
3241202a442SAmit Kucheria                                    hysteresis = <2000>;
3251202a442SAmit Kucheria                                    type = "critical";
3261202a442SAmit Kucheria                            };
3271202a442SAmit Kucheria                    };
3281202a442SAmit Kucheria            };
3291202a442SAmit Kucheria
3301202a442SAmit Kucheria            /* ... */
3311202a442SAmit Kucheria
3321202a442SAmit Kucheria            gpu-top-thermal {
3331202a442SAmit Kucheria                    polling-delay-passive = <250>;
3341202a442SAmit Kucheria                    polling-delay = <1000>;
3351202a442SAmit Kucheria
3361202a442SAmit Kucheria                    thermal-sensors = <&tsens0 11>;
3371202a442SAmit Kucheria
3381202a442SAmit Kucheria                    trips {
3391202a442SAmit Kucheria                            gpu1_alert0: trip-point0 {
3401202a442SAmit Kucheria                                    temperature = <90000>;
3411202a442SAmit Kucheria                                    hysteresis = <2000>;
3421202a442SAmit Kucheria                                    type = "hot";
3431202a442SAmit Kucheria                            };
3441202a442SAmit Kucheria                    };
3451202a442SAmit Kucheria            };
3461202a442SAmit Kucheria    };
3471202a442SAmit Kucheria...
348