summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHyungwoo Yang <hyungwooy@nvidia.com>2013-01-03 19:33:36 -0500
committerNicolin Chen <nicolinc@nvidia.com>2017-08-14 21:38:52 -0400
commitde4dbca70de6809b3681a36a8ac5c4c19244ebca (patch)
tree1b9093f9fbba51325941bdf5ba7c40dc17f3e160
parente7ebdf7eee0366c986bb4264ce03daf2cf7d15a3 (diff)
drivers: misc: therm_est: add get_trend using dT/dt
Added get_trend to use dTemp/dTime in trend calculation. Bug 1158323 Change-Id: I7a3e80a768e3ebd72f657222eb0d3b546a3fabba Signed-off-by: Hyungwoo Yang <hyungwooy@nvidia.com> Reviewed-on: http://git-master/r/188582
-rw-r--r--drivers/misc/therm_est.c27
-rw-r--r--include/linux/therm_est.h2
2 files changed, 29 insertions, 0 deletions
diff --git a/drivers/misc/therm_est.c b/drivers/misc/therm_est.c
index 553764d66..81270480f 100644
--- a/drivers/misc/therm_est.c
+++ b/drivers/misc/therm_est.c
@@ -45,6 +45,8 @@ struct therm_estimator {
45 struct thermal_zone_device *thz; 45 struct thermal_zone_device *thz;
46 char *cdev_type; 46 char *cdev_type;
47 long trip_temp; 47 long trip_temp;
48 int tc1;
49 int tc2;
48#ifdef CONFIG_PM 50#ifdef CONFIG_PM
49 struct notifier_block pm_nb; 51 struct notifier_block pm_nb;
50#endif 52#endif
@@ -148,6 +150,28 @@ static int therm_est_get_temp(struct thermal_zone_device *thz,
148 return 0; 150 return 0;
149} 151}
150 152
153static int therm_est_get_trend(struct thermal_zone_device *thz,
154 int trip,
155 enum thermal_trend *trend)
156{
157 struct therm_estimator *est = thz->devdata;
158 int new_trend;
159 int cur_temp;
160
161 cur_temp = thz->temperature;
162 new_trend = (est->tc1 * (cur_temp - thz->last_temperature)) +
163 (est->tc2 * (cur_temp - est->trip_temp));
164
165 if (new_trend > 0)
166 *trend = THERMAL_TREND_RAISING;
167 else if (new_trend < 0)
168 *trend = THERMAL_TREND_DROPPING;
169 else
170 *trend = THERMAL_TREND_STABLE;
171
172 return 0;
173}
174
151static struct thermal_zone_device_ops therm_est_ops = { 175static struct thermal_zone_device_ops therm_est_ops = {
152 .bind = therm_est_bind, 176 .bind = therm_est_bind,
153 .unbind = therm_est_unbind, 177 .unbind = therm_est_unbind,
@@ -155,6 +179,7 @@ static struct thermal_zone_device_ops therm_est_ops = {
155 .get_trip_temp = therm_est_get_trip_temp, 179 .get_trip_temp = therm_est_get_trip_temp,
156 .set_trip_temp = therm_est_set_trip_temp, 180 .set_trip_temp = therm_est_set_trip_temp,
157 .get_temp = therm_est_get_temp, 181 .get_temp = therm_est_get_temp,
182 .get_trend = therm_est_get_trend,
158}; 183};
159 184
160static ssize_t show_coeff(struct device *dev, 185static ssize_t show_coeff(struct device *dev,
@@ -341,6 +366,8 @@ static int __devinit therm_est_probe(struct platform_device *pdev)
341 est->ndevs = data->ndevs; 366 est->ndevs = data->ndevs;
342 est->toffset = data->toffset; 367 est->toffset = data->toffset;
343 est->polling_period = data->polling_period; 368 est->polling_period = data->polling_period;
369 est->tc1 = data->tc1;
370 est->tc2 = data->tc2;
344 371
345 /* initialize history */ 372 /* initialize history */
346 therm_est_init_history(est); 373 therm_est_init_history(est);
diff --git a/include/linux/therm_est.h b/include/linux/therm_est.h
index 8d48ed1db..514c5aeac 100644
--- a/include/linux/therm_est.h
+++ b/include/linux/therm_est.h
@@ -40,6 +40,8 @@ struct therm_est_data {
40 long polling_period; 40 long polling_period;
41 int passive_delay; 41 int passive_delay;
42 int ndevs; 42 int ndevs;
43 int tc1;
44 int tc2;
43 struct therm_est_subdevice devs[]; 45 struct therm_est_subdevice devs[];
44}; 46};
45 47