summaryrefslogtreecommitdiff
path: root/arch/arm/mach-tegra/board-enterprise-sensors.c
diff options
context:
space:
mode:
authorJoshua Primero <jprimero@nvidia.com>2011-10-13 17:49:20 -0700
committerVarun Wadekar <vwadekar@nvidia.com>2011-12-08 17:03:38 +0530
commit0a892e234ce77f94973afbf2d00ea4239ee6b677 (patch)
tree60a1d541af0d8e03c93376f778caa1d9b71abf2d /arch/arm/mach-tegra/board-enterprise-sensors.c
parent99cd63f81e09e6dafcba8cb5e61a5b56b258fad5 (diff)
arm: tegra: power: Tegra Thermal refactoring
Refactored Thermal module so that thermal device drivers themselves are agnostic of the thermal framework. Also separated throttle limit constraints from EDP table. Reviewed-on: http://git-master/r/57990 Reviewed-on: http://git-master/r/63338 Cherry-picked from 8d0610bdd03c3490b718f11bc2108f45cd868533. Change-Id: I4f87889c9cdc88daac1e6173043bab1f2e7cebfd Signed-off-by: Joshua Primero <jprimero@nvidia.com> Reviewed-on: http://git-master/r/66551 Reviewed-by: Diwakar Tundlam <dtundlam@nvidia.com>
Diffstat (limited to 'arch/arm/mach-tegra/board-enterprise-sensors.c')
-rw-r--r--arch/arm/mach-tegra/board-enterprise-sensors.c61
1 files changed, 60 insertions, 1 deletions
diff --git a/arch/arm/mach-tegra/board-enterprise-sensors.c b/arch/arm/mach-tegra/board-enterprise-sensors.c
index 3ab93348571a..a0583e906b0f 100644
--- a/arch/arm/mach-tegra/board-enterprise-sensors.c
+++ b/arch/arm/mach-tegra/board-enterprise-sensors.c
@@ -34,20 +34,76 @@
#include <linux/i2c.h>
#include <linux/delay.h>
#include <linux/i2c/pca954x.h>
+#include <linux/nct1008.h>
#include <linux/err.h>
#include <linux/mpu.h>
-#include <linux/nct1008.h>
#include <linux/regulator/consumer.h>
+#include <linux/slab.h>
#include <mach/gpio.h>
#include <media/ar0832_main.h>
#include <media/tps61050.h>
#include <media/ov9726.h>
#include <mach/edp.h>
+#include <mach/thermal.h>
#include "cpu-tegra.h"
#include "gpio-names.h"
#include "board-enterprise.h"
#include "board.h"
+#ifndef CONFIG_TEGRA_INTERNAL_TSENSOR_EDP_SUPPORT
+static int nct_get_temp(void *_data, long *temp)
+{
+ struct nct1008_data *data = _data;
+ return nct1008_thermal_get_temp(data, temp);
+}
+
+static int nct_set_limits(void *_data,
+ long lo_limit_milli,
+ long hi_limit_milli)
+{
+ struct nct1008_data *data = _data;
+ return nct1008_thermal_set_limits(data,
+ lo_limit_milli,
+ hi_limit_milli);
+}
+
+static int nct_set_alert(void *_data,
+ void (*alert_func)(void *),
+ void *alert_data)
+{
+ struct nct1008_data *data = _data;
+ return nct1008_thermal_set_alert(data, alert_func, alert_data);
+}
+
+static int nct_set_shutdown_temp(void *_data, long shutdown_temp)
+{
+ struct nct1008_data *data = _data;
+ return nct1008_thermal_set_shutdown_temp(data,
+ shutdown_temp);
+}
+
+static void nct1008_probe_callback(struct nct1008_data *data)
+{
+ struct tegra_thermal_device *thermal_device;
+
+ thermal_device = kzalloc(sizeof(struct tegra_thermal_device),
+ GFP_KERNEL);
+ if (!thermal_device) {
+ pr_err("unable to allocate thermal device\n");
+ return;
+ }
+
+ thermal_device->data = data;
+ thermal_device->offset = TDIODE_OFFSET;
+ thermal_device->get_temp = nct_get_temp;
+ thermal_device->set_limits = nct_set_limits;
+ thermal_device->set_alert = nct_set_alert;
+ thermal_device->set_shutdown_temp = nct_set_shutdown_temp;
+
+ tegra_thermal_set_device(thermal_device);
+}
+#endif
+
static struct nct1008_platform_data enterprise_nct1008_pdata = {
.supported_hwrev = true,
.ext_range = true,
@@ -58,6 +114,9 @@ static struct nct1008_platform_data enterprise_nct1008_pdata = {
.shutdown_local_limit = 90,
.throttling_ext_limit = 85,
.alarm_fn = tegra_throttling_enable,
+#ifndef CONFIG_TEGRA_INTERNAL_TSENSOR_EDP_SUPPORT
+ .probe_callback = nct1008_probe_callback,
+#endif
};
static struct i2c_board_info enterprise_i2c4_nct1008_board_info[] = {