MSM thermal driver (MSM_THERMAL) MSM_THERMAL is a kernel platform driver which regulates thermal conditions on the device during kernel boot. The goal of MSM_THERMAL is to prevent the temperature of the system from exceeding a thermal limit at which it cannot operate. Examples are CPU junction thermal limit, or POP memory thermal limit. The MSM_THERMAL driver polls the TSENS sensor hardware during boot, and reduces the maximum CPU frequency allowed in steps, to limit power/thermal output when a threshold temperature is crossed. It restores the maximum CPU frequency allowed in the same stepwise fashion when the threshold temperature (with hysteresis gap) is cleared. The devicetree representation of the MSM_THERMAL block should be: Required properties - compatible: "qcom,msm-thermal" - qcom,sensor-id: The id of the TSENS sensor polled for temperature. Typically the sensor closest to CPU0. - qcom,poll-ms: Sampling interval to read sensor, in ms. - qcom,limit-temp: Threshold temperature to start stepping CPU down, in degC. - qcom,temp-hysteresis: Degrees C below threshold temperature to step CPU up. - qcom,freq-step: Number of frequency steps to take on each CPU mitigation. Optional properties - qcom,freq-control-mask: The cpu mask that will be used to determine if a core can be used for freq control. - qcom,core-limit-temp: Threshold temperature to start shutting down cores in degC - qcom,core-temp-hysteresis: Degrees C below which the cores will be brought online in sequence. - qcom,core-control-mask: The cpu mask that will be used to determine if a core can be controlled or not. A mask of 0 indicates the feature is disabled. - qcom,hotplug-temp: Threshold temperature to start shutting down cores in degC. This will be used when polling based core control is disabled. The difference between hotplug-temp and core-limit-temp is that core-limit-temp is used during early boot prior to thermal_sys being available for hotplug. - qcom,hotplug-temp-hysteresis: Degrees C below which thermal will not force the cores to be offlined. Cores can be brought online if needed. - qcpm,cpu-sensors: List of type names in thermal zone device struct which maps to cpu0, cpu1, cpu2, cpu3 in sequence depending on how many cpus there are. - qcom,freq-mitigation-temp: Threshold temperature to mitigate the CPU max frequency in degC. This will be used when polling based frequency control is disabled. The difference between freq-mitigation-temp and limit-temp is that limit-temp is used during early boot prior to thermal_sys being available for registering temperature thresholds. Also, this emergency frequency mitigation is a single step frequency mitigation to a predefined value as opposed to the step by step frequency mitigation during boot-up. - qcom,freq-mitigation-temp-hysteresis: Degrees C below which thermal will not mitigate the cpu max frequency. - qcom,freq-mitigation-value: The frequency value (in kHz) to which the thermal should mitigate the CPU, when the freq-mitigation-temp threshold is reached. - qcom,freq-mitigation-control-mask: The frequency mitigation bitmask that will be used to determine if KTM should do emergency frequency mitigation for a core or not. A mask of 0x00 indicates the mitigation is disabled for all the cores and a mask of 0x05 indicates this mitigation is enabled for cpu-0 and cpu-2. Note: For KTM's frequency mitigation to work, the data for all the above four properties (qcom,freq-mitigation-temp; qcom, freq-mitigation-temp-hysteresis; qcom,freq-mitigation-value and qcom,freq-mitigation-control-mask) should be populated. - qcom,vdd-restriction-temp: When temperature is below this threshold, will enable vdd restriction which will set higher voltage on key voltage rails, in degC. - qcom,vdd-restriction-temp-hysteresis: When temperature is above this threshold will disable vdd restriction on key rails, in degC. - qcom,pmic-sw-mode-temp: Threshold temperature to disable auto mode on the rail, in degC. If this property exists, qcom,pmic-sw-mode-temp-hysteresis and qcom,pmic-sw-mode-regs need to exist, otherwise return error. - qcom,pmic-sw-mode-temp-hysteresis: Degree below threshold temperature to enable auto mode on the rail, in degC. If this property exists, qcom,pmic-sw-mode-temp and qcom,pmic-sw-mode-regs need to exist, otherwise return error. - qcom,pmic-sw-mode-regs: Array of the regulator names that will want to disable/enable automode based on the threshold. If this property exists, qcom,pmic-sw-mode-temp and qcom,pmic-sw-mode-temp-hysteresis need to exist, otherwise return error. Also, if this property is defined, will have to define -supply = <&phandle_of_regulator> - -supply = <&phandle_of_regulator>: consumer_supply_name is the name that's defined in thermal driver. phandle_of_regulator is defined by reuglator device tree. - qcom,online-hotplug-core: This property should be defined in targets where KTM should online cores, which are hotplugged due to thermal condition. - qcom,synchronous-cluster-id: This property specifies an array of synchronous cluster-ID's. This property will be used by KTM to optimize the synchronous cluster frequency update. - qcom,synchronous-cluster-map: This property specifies an array of cluster-ID and its associated cpumask value pair. This property should be defined in targets where the kernel topology module is not present. In the older kernel version, where the kernel topology module is not available, KTM gets the mapping information from this property. Optional child nodes - qcom,pmic-opt-curr-temp: Threshold temperature for requesting optimum current (request dual phase) for rails with PMIC, in degC. If this property exists, then the properties, qcom,pmic-opt-curr-temp-hysteresis and qcom,pmic-opt-curr-regs should also be defined to enable this feature. - qcom,pmic-opt-curr-temp-hysteresis: Degree below the threshold to disable the optimum current request for a rail, in degC. If this property exists, then the properties, qcom,pmic-opt-curr-temp and qcom,pmic-opt-curr-regs should also be defined to enable this feature. - qcom,pmic-opt-curr-regs: Name of the rails for which the optimum current should be requested. If this property exists, then the properties, qcom,pmic-opt-curr-temp and qcom,pmic-opt-curr-temp-hysteresis should also be defined to enable this feature. - qcom,pmic-opt-curr-sensor-id: Sensor, which needs to be monitored for requesting OCR when qcom,pmic-opt-curr-temp threshold is reached. It is an optional property, if it is configured, msm_thermal will monitor only this sensor, otherwise it will monitor all TSENS for this feature. If this property exists, then the properties, qcom,pmic-opt-curr-temp, qcom,pmic-opt-curr-temp-hysteresis and qcom,pmic-opt-curr-regs should also be defined to enable this feature. - qcom,: Define the name of the child node. If this property exisits, qcom,vdd-rstr-reg, qcom,levels need to exist. qcom,min-level is optional if qcom,freq-req exists, otherwise it's required. - qcom,vdd-rstr-reg: Name of the rail - qcom,levels: Array of the level values. Unit is corner voltage for voltage request or kHz for frequency request. - qcom,min-level: Request this level as minimum level when disabling voltage restriction. Unit is corner voltage for voltage request. This will not be required if qcom,freq-req exists. - qcom,freq-req: Flag to determine if we should restrict frequency on this rail instead of voltage. - qcom,cx-phase-hot-crit-temp: Threshold temperature for sending the 'HOT_CRITICAL' temperature band to RPM, in degC. This will aid RPM in deciding the number of phases required for CX rail. If this property exists, then the property, qcom,cx-phase-hot-crit-temp-hyst should also be defined to enable this feature. - qcom,cx-phase-hot-crit-temp-hyst: Degree below the threshold to send the 'WARM' temperature band to RPM, in degC. This will aid RPM in deciding the number of phases required for CX. If this property exists, then the property, qcom,cx-phase-hot-crit-temp should also be defined to enable this feature. - qcom,cx-phase-resource-key: The key name to be used for sending the CX temperature band message to RPM. This property should be defined along with the other properties required for CX phase selection feature. - qcom,gfx-phase-hot-crit-temp: Threshold temperature for sending the 'HOT_CRITICAL' temperature band to RPM, in degC. This will aid RPM in deciding the number of phases required for GFX rail. If this property exists, then the properties, qcom,gfx-phase-hot-crit-temp-hyst and qcom,gfx-sensor-id should also be defined to enable this feature. - qcom,gfx-phase-hot-crit-temp-hyst: Degree below the threshold to clear the 'HOT_CRITICAL' band and send the 'WARM' temperature band to RPM, in degC. This will aid RPM in deciding the number of phases required for GFX rail. If this property exists, then the properties, qcom,gfx-phase-hot-crit-temp and qcom,gfx-sensor-id should also be defined to enable this feature. - qcom,gfx-phase-warm-temp: Threshold temperature for sending the 'WARM' temperature band to RPM, in degC. This will aid RPM in deciding the number of phases required for GFX rail. If this property exists, then the properties, qcom,gfx-sensor-id and qcom,gfx-phase-warm-temp-hyst should also be defined to enable this feature. - qcom,gfx-phase-warm-temp-hyst: Degree below the threshold to clear the 'WARM' band and send the 'NORMAL' temperature band to RPM, in degC. This will aid RPM in deciding the number of phases required for GFX rail. If this property exists, then the property, qcom,gfx-sensor-id and qcom,gfx-phase-warm-temp should also be defined to enable this feature. -qcom,gfx-sensor-id: The ID of the TSENS sensor, which is closest to graphics processor, monitoring the GPU temperature. If this property exists, then the property, qcom,gfx-phase-hot-crit-temp and qcom,gfx-phase-hot-crit-temp-hyst or/and qcom,gfx-phase-warm-temp and qcom,gfx-phase-warm-temp-hyst should also be defined to enable this feature. - qcom,gfx-phase-resource-key: The key name to be used for sending the GFX temperature band message to RPM. This property should be defined along with the other properties required for GFX phase selection feature. - qcom,rpm-phase-resource-type: The RPM resource type name to be used for sending temperature bands for CX and GFX phase selection. This property should be defined along with the other properties required for CX and GFX phase selection feature. - qcom,rpm-phase-resource-id: The RPM resource ID to be used for sending temperature bands for CX and GFX phase selection. This property should be defined along with the other properties required for CX and GFX phase selection feature. - qcom,mx-restriction-temp: Threshold temperature below which the module votes for higher data retention voltage of MX supply. If and only if this property exists, then the property qcom,mx-restriction-temp-hysteresis, qcom,mx-retention-min should also be present. Also, if this property is defined, will have to define vdd-mx-supply = <&phandle_of_regulator> - qcom,mx-restriction-temp-hysteresis: Degree above the threshold to remove MX vote. If this property exists, then the property qcom,mx-restriction-temp, qcom,mx-retention-min should also be present.Also, if this property is defined, will have to define vdd-mx-supply = <&phandle_of_regulator> - qcom,mx-retention-min: Minimum data retention voltage to be applied to MX rail if the low threshold is crossed. If this property exists, then the property qcom,mx-restriction-temp and qcom,mx-restriction-temp-hysteresis should also be present. Also, if this property is defined, will have to define vdd-mx-supply = <&phandle_of_regulator> - qcom,therm-reset-temp: Degree above which the KTM will initiate a secure watchdog reset. When this property is defined, KTM will monitor all the tsens from boot time and will initiate a secure watchdog reset if any of the tsens temperature reaches this threshold. This reset helps in generating more informative crash dumps opposed to the crash dump generated by the hardware reset. Example: qcom,msm-thermal { compatible = "qcom,msm-thermal"; qcom,sensor-id = <0>; qcom,poll-ms = <250>; qcom,limit-temp = <60>; qcom,temp-hysteresis = <10>; qcom,freq-step = <2>; qcom,freq-control-mask = <0xf> qcom,therm-reset-temp = <115>; qcom,core-limit-temp = <90>; qcom,core-temp-hysteresis = <10>; qcom,core-control-mask = <7>; qcom,hotplug-temp = <110>; qcom,hotplug-temp-hysteresis = <20>; qcom,cpu-sensors = "tsens_tz_sensor5", "tsens_tz_sensor6", "tsens_tz_sensor7", "tsens_tz_sensor8"; qcom,freq-mitigation-temp = <110>; qcom,freq-mitigation-temp-hysteresis = <20>; qcom,freq-mitigation-value = <960000>; qcom,freq-mitigation-control-mask = <0x01>; qcom,rpm-phase-resource-type = "misc"; qcom,rpm-phase-resource-id = <0>; qcom,cx-phase-resource-key = "tmpc"; qcom,cx-phase-hot-crit-temp = <75>; qcom,cx-phase-hot-crit-temp-hyst = <15>; qcom,gfx-phase-warm-temp = <60>; qcom,gfx-phase-warm-temp-hyst = <10>; qcom,gfx-phase-hot-crit-temp = <85>; qcom,gfx-phase-hot-crit-temp-hyst = <15>; qcom,gfx-sensor-id = <4>; qcom,gfx-phase-resource-key = "tmpg"; qcom,pmic-sw-mode-temp = <90>; qcom,pmic-sw-mode-temp-hysteresis = <80>; qcom,pmic-sw-mode-regs = "vdd-dig"; qcom,vdd-restriction-temp = <5>; qcom,vdd-restriction-temp-hysteresis = <10>; vdd-dig-supply=<&pm8841_s2_floor_corner> qcom,mx-restriction-temp = <5>; qcom,mx-restriction-temp-hysteresis = <10>; qcom,mx-retention-min = <710000>; vdd-mx-supply = <&pma8084_s1>; qcom,online-hotplug-core; qcom,synchronous-cluster-id = <0 1>; /* Indicates cluster 0 and 1 are synchronous */ qcom,synchronous-cluster-map = <0 0x0F>, <1 0xF0>; /* . */ /* The 0x0F is a bitmap indicating that ** core 0, 1, 2, 3 belongs to cluster ID 0. ** The 0xF0 is a bitmap indicating that core 4, 5, 6, 7 ** belongs to cluster ID 1. */ qcom,vdd-dig-rstr{ qcom,vdd-rstr-reg = "vdd-dig"; qcom,levels = <5 7 7>; /* Nominal, Super Turbo, Super Turbo */ qcom,min-level = <1>; /* No Request */ }; qcom,vdd-apps-rstr{ qcom,vdd-rstr-reg = "vdd-apps"; qcom,levels = <1881600 1958400 2265600>; qcom,freq-req; }; }; The sensor information node is an optional node that holds information about thermal sensors on a target. The information includes sensor type, sensor name, sensor alias and sensor scaling factor. The parent node name is qcom,sensor-information. It has a list of optional child nodes, each representing a sensor. The child node is named as qcom,sensor-information@. The id takes values sequentially from 0 to N-1 where N is the number of sensors. This id doesn't relate to zone id or sensor id. The devicetree representation of sensor information node should be: 1.0 Required properties: - compatible: "qcom,sensor-information" 1.1 Optional nodes: qcom,sensor-information@ The below properties belong to the child node qcom,sensor-information@. Following are the required and optional properties of a child node. 1.1.a Required properties: - qcom,sensor-type: Type of a sensor. A sensor can be of type tsens, alarm or adc. tsens: Sensors that are on MSM die. alarm: Sensors that are on PMIC die. adc: Sensors that are usually thermistors placed out of the die. - qcom,sensor-name: Name of a sensor as defined by low level sensor driver. 1.1.b Optional properties: - qcom,alias-name: Alias name for a sensor. The alias name corresponds to a device such as cpu/gpu/pop-mem whose temperature is relative to the sensor temperature defined in the child node. - qcom,scaling-factor: The unit that needs to be multiplied to the sensor temperature to get temperature unit in degree centigrade. If this property is not present, a default scaling factor of 1 is assigned to a sensor. Example: qcom,sensor-information { compatible = "qcom,sensor-information"; sensor_information0: qcom,sensor-information@0 { qcom,sensor-type = "tsens"; qcom,sensor-name = "tsens_tz_sensor0"; }; sensor_information1: qcom,sensor-information@1 { qcom,sensor-type = "tsens"; qcom,sensor-name = "tsens_tz_sensor1"; }; sensor_information2: qcom,sensor-information@2 { qcom,sensor-type = "tsens"; qcom,sensor-name = "tsens_tz_sensor2"; }; sensor_information3: qcom,sensor-information@3 { qcom,sensor-type = "tsens"; qcom,sensor-name = "tsens_tz_sensor3"; }; sensor_information4: qcom,sensor-information@4 { qcom,sensor-type = "tsens"; qcom,sensor-name = "tsens_tz_sensor4"; }; sensor_information5: qcom,sensor-information@5 { qcom,sensor-type = "tsens"; qcom,sensor-name = "tsens_tz_sensor5"; }; sensor_information6: qcom,sensor-information@6 { qcom,sensor-type = "tsens"; qcom,sensor-name = "tsens_tz_sensor6"; qcom,alias-name = "cpu7"; } sensor_information7: qcom,sensor-information@7 { qcom,sensor-type = "alarm"; qcom,sensor-name = "pm8994_tz"; qcom,scaling-factor = <1000>; }; };