summaryrefslogtreecommitdiff
path: root/arch/arm/mach-tegra/tegra3_tsensor.c
diff options
context:
space:
mode:
authorJoshua Primero <jprimero@nvidia.com>2011-11-02 22:18:30 -0700
committerVarun Wadekar <vwadekar@nvidia.com>2011-12-21 12:06:25 +0530
commit8ffa26ef0f2b5b832481670b60babf1372d4dbd1 (patch)
tree0e3cad10832772b14a878aaa9467c9e482c36613 /arch/arm/mach-tegra/tegra3_tsensor.c
parent2d81fbf0c7fd7d938117025b3c83b79f5151b5bf (diff)
arm: tegra: power: tsensor to therm framework
Hooked up tsensor to thermal framework. Cleaned up some unnessary tsensor code as well. Bug 848755 Reviewed-on: http://git-master/r/62021 (cherry picked from commit 307f53a36bd1bdfaabddfdd80f9de5445d805786) Change-Id: If4156c35f78575bc67b48d1d87fa82a4e32751c5 Reviewed-on: http://git-master/r/63344 Signed-off-by: Joshua Primero <jprimero@nvidia.com> Reviewed-on: http://git-master/r/67238 Reviewed-by: Automatic_Commit_Validation_User Reviewed-by: Diwakar Tundlam <dtundlam@nvidia.com>
Diffstat (limited to 'arch/arm/mach-tegra/tegra3_tsensor.c')
-rw-r--r--arch/arm/mach-tegra/tegra3_tsensor.c83
1 files changed, 68 insertions, 15 deletions
diff --git a/arch/arm/mach-tegra/tegra3_tsensor.c b/arch/arm/mach-tegra/tegra3_tsensor.c
index c498a2db2282..a5160733fd2f 100644
--- a/arch/arm/mach-tegra/tegra3_tsensor.c
+++ b/arch/arm/mach-tegra/tegra3_tsensor.c
@@ -18,23 +18,14 @@
#include <linux/init.h>
#ifdef CONFIG_SENSORS_TEGRA_TSENSOR
-#include <linux/io.h>
-#include <linux/ioport.h>
-
-#include <mach/iomap.h>
#include <mach/tsensor.h>
#include <mach/tegra_fuse.h>
-
-#include "board.h"
-#include "devices.h"
-#include "fuse.h"
-
-static struct tegra_tsensor_platform_data tsensor_data = {
- .hysteresis = 5,
- .sw_intr_temperature = 75,
- .hw_clk_div_temperature = 80,
- .hw_reset_temperature = 90,
-};
+#include <devices.h>
+#include <mach/iomap.h>
+#include <mach/thermal.h>
+#include <linux/io.h>
+#include <linux/ioport.h>
+#include <linux/slab.h>
/* fuse revision constants used for tsensor */
#define TSENSOR_FUSE_REVISION_DECIMAL 8
@@ -62,6 +53,68 @@ static struct tegra_tsensor_platform_data tsensor_data = {
#define CHECKSUM_MASK 0xff
#define PMU_16BIT_SUPPORT_MASK 0x1
+#define TSENSOR_OFFSET (4000 + 5000)
+
+#ifdef CONFIG_TEGRA_INTERNAL_TSENSOR_EDP_SUPPORT
+static int tsensor_get_temp(void *vdata, long *milli_temp)
+{
+ struct tegra_tsensor_data *data = vdata;
+ return tsensor_thermal_get_temp(data, milli_temp);
+}
+
+static int tsensor_set_limits(void *vdata,
+ long lo_limit_milli,
+ long hi_limit_milli)
+{
+ struct tegra_tsensor_data *data = vdata;
+ return tsensor_thermal_set_limits(data,
+ lo_limit_milli,
+ hi_limit_milli);
+}
+
+static int tsensor_set_alert(void *vdata,
+ void (*alert_func)(void *),
+ void *alert_data)
+{
+ struct tegra_tsensor_data *data = vdata;
+ return tsensor_thermal_set_alert(data, alert_func, alert_data);
+}
+
+static int tsensor_set_shutdown_temp(void *vdata, long shutdown_temp_milli)
+{
+ struct tegra_tsensor_data *data = vdata;
+ return tsensor_thermal_set_shutdown_temp(data, shutdown_temp_milli);
+}
+
+static void tegra3_tsensor_probe_callback(struct tegra_tsensor_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 = TSENSOR_OFFSET;
+ thermal_device->get_temp = tsensor_get_temp;
+ thermal_device->set_limits = tsensor_set_limits;
+ thermal_device->set_alert = tsensor_set_alert;
+ thermal_device->set_shutdown_temp = tsensor_set_shutdown_temp;
+
+ if (tegra_thermal_set_device(thermal_device)) /* This should not fail */
+ BUG();
+}
+#endif
+
+static struct tegra_tsensor_platform_data tsensor_data = {
+#ifdef CONFIG_TEGRA_INTERNAL_TSENSOR_EDP_SUPPORT
+ .probe_callback = tegra3_tsensor_probe_callback,
+#endif
+};
void __init tegra3_tsensor_init(struct tegra_tsensor_pmu_data *data)
{