From 344fc0637ade58d0dee983234777d11e869c98e1 Mon Sep 17 00:00:00 2001 From: Joshua Primero Date: Thu, 31 May 2012 18:11:23 -0700 Subject: drivers: misc: Thermal estimator driver Added driver which estimates temperature based on a linear formula from other temperature sensors. bug 1007726 Change-Id: Ic0d3ba7f0d369d4321f55b03e6326ff4efbb512e Signed-off-by: Joshua Primero Reviewed-on: http://git-master/r/105988 Reviewed-by: Automatic_Commit_Validation_User GVS: Gerrit_Virtual_Submit Reviewed-by: Sachin Nikam --- include/linux/therm_est.h | 77 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 include/linux/therm_est.h (limited to 'include') diff --git a/include/linux/therm_est.h b/include/linux/therm_est.h new file mode 100644 index 000000000000..035b08fa9813 --- /dev/null +++ b/include/linux/therm_est.h @@ -0,0 +1,77 @@ +/* + * include/linux/therm_est.h + * + * Copyright (c) 2010-2012, NVIDIA Corporation. + * + * This software is licensed under the terms of the GNU General Public + * License version 2, as published by the Free Software Foundation, and + * may be copied, distributed, and modified under those terms. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +#ifndef _LINUX_THERM_EST_H +#define _LINUX_THERM_EST_H + +#include + +#define HIST_LEN (20) + +struct therm_est_subdevice { + void *dev_data; + int (*get_temp)(void *, long *); + long coeffs[HIST_LEN]; + long hist[HIST_LEN]; +}; + +struct therm_estimator { + long therm_est_lo_limit; + long therm_est_hi_limit; + void (*callback)(void *); + void *callback_data; + long cur_temp; + long polling_period; + struct workqueue_struct *workqueue; + struct delayed_work therm_est_work; + long toffset; + int ntemp; + int ndevs; + struct therm_est_subdevice **devs; +}; + +#ifdef CONFIG_THERM_EST +struct therm_estimator *therm_est_register( + struct therm_est_subdevice **devs, + int ndevs, + long toffset, + long pperiod); +int therm_est_get_temp(struct therm_estimator *est, long *temp); +int therm_est_set_limits(struct therm_estimator *est, + long lo_limit, + long hi_limit); +int therm_est_set_alert(struct therm_estimator *est, + void (*cb)(void *), + void *cb_data); +#else +static inline struct therm_estimator *therm_est_register( + struct therm_est_subdevice **devs, + int ndevs, + long toffset, + long pperiod) +{ return NULL; } +static inline int therm_est_get_temp(struct therm_estimator *est, long *temp) +{ return -EINVAL; } +static inline int therm_est_set_limits(struct therm_estimator *est, + long lo_limit, + long hi_limit) +{ return -EINVAL; } +static inline int therm_est_set_alert(struct therm_estimator *est, + void (*cb)(void *), + void *cb_data) +{ return -EINVAL; } +#endif +#endif /* _LINUX_THERM_EST_H */ -- cgit v1.2.3