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 <consumer_supply_name>-supply = <&phandle_of_regulator>
- <consumer_supply_name>-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.

Optional child nodes
- qti,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, qti,pmic-opt-curr-temp-hysteresis and
			qti,pmic-opt-curr-regs should also be defined to enable this
			feature.
- qti,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, qti,pmic-opt-curr-temp and
			qti,pmic-opt-curr-regs should also be defined to enable
			this feature.
- qti,pmic-opt-curr-regs: Name of the rails for which the optimum current should be
			requested. If this property exists, then the properties,
			qti,pmic-opt-curr-temp and qti,pmic-opt-curr-temp-hysteresis
			should also be defined to enable this feature.
- qcom,<vdd restriction child node name>: 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.

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,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,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>;
		qti,pmic-opt-curr-temp = <85>;
		qti,pmic-opt-curr-temp-hysteresis = <10>;
		qti,pmic-opt-curr-regs = "vdd-dig";
		vdd-dig-supply=<&pm8841_s2_floor_corner>

		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;
		};
	};

