From f9d1658833bbd2dfd5b24bb8cfff4da88db658ce Mon Sep 17 00:00:00 2001 From: mkarthik Date: Wed, 17 Jun 2020 17:31:11 +0530 Subject: therm-fan-est: Add support for Tmargin to drive fan Why? Tmargin method of fan control allows multiple groups of therma-fan-est devices temperatures to be considered for the fan control algorithm/fan curve. The limitation of the existing max temp algorithm in therm-fan-est driver is that devices with different fan curves cannot be accomodated in the driver. In case, there are multple fan curves, the device which has the steepest curve wins the algoritm. Hence, taking the temperatures as a reference from their respective critical temperatures and using that value to drive the fan will help in accomodating both the devices' fan curves. How? * Calculate the effective crit temp of all the thermal zones during probe. * In the polling cycles, calculate the effective temperatures of the individual groups and use the tmargin formula to calculate the current temperature. * Since the Tmargin temp trip values are in reverse order, we need to use the reverse order in the pwm-fan dt profile. * The hysterysis is subtracted from the temp in cooling scenario to avoid frequent switching at trip temps. Since the tmargin trip values are taken in the decending order, hysterysis temps in dt should be given as negative values. Bug 200627962 Change-Id: Ideba4bfdb3d3306d1b4aff15093bcfac13d7bb86 Signed-off-by: Mantravadi Karthik Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2362354 Reviewed-by: automaticguardword Reviewed-by: Rajkumar Kasirajan Reviewed-by: Bibek Basu Reviewed-by: mobile promotions Tested-by: Rajkumar Kasirajan Tested-by: mobile promotions GVS: Gerrit_Virtual_Submit --- include/linux/therm_est.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'include') diff --git a/include/linux/therm_est.h b/include/linux/therm_est.h index fa1ea7ffc..8b1786ea8 100644 --- a/include/linux/therm_est.h +++ b/include/linux/therm_est.h @@ -235,6 +235,8 @@ struct therm_fan_estimator { /* allow cooling device to turn off at higher temperature if sleep */ bool sleep_mode; int nonsleep_hyst; + bool use_tmargin; + long crit_temp[MAX_SUBDEVICE_GROUP]; bool is_continuous_gov; }; -- cgit v1.2.2