summaryrefslogtreecommitdiff
path: root/arch/arm/mach-tegra
diff options
context:
space:
mode:
authorJoshua Primero <jprimero@nvidia.com>2012-08-23 16:29:11 -0700
committerRohan Somvanshi <rsomvanshi@nvidia.com>2012-09-13 01:49:58 -0700
commit71a5f0242738cb4e7f3643960b3c2b43bba22e6a (patch)
treea29e63033f6fb1a82d4d5b9dca04c4598c29f54c /arch/arm/mach-tegra
parentf2d01ca60d3fc7e1f1d12ac03d1777c8c6006190 (diff)
ARM: tegra: thermal: Refactored thermals
1) Removed skin thermals from tegra_thermal layer 2) Removed throttle initialization from tegra_thermal layer 3) Simplified thermal device interface 4) Create a therm estimator device as a platform device Change-Id: Ic8ffd111817f03f7aadc89d6185eb749b274b830 Signed-off-by: Joshua Primero <jprimero@nvidia.com> Reviewed-on: http://git-master/r/130282 Reviewed-by: Rohan Somvanshi <rsomvanshi@nvidia.com> Tested-by: Rohan Somvanshi <rsomvanshi@nvidia.com>
Diffstat (limited to 'arch/arm/mach-tegra')
-rw-r--r--arch/arm/mach-tegra/board-cardhu-sensors.c90
-rw-r--r--arch/arm/mach-tegra/board-cardhu.c81
-rw-r--r--arch/arm/mach-tegra/board-cardhu.h2
-rw-r--r--arch/arm/mach-tegra/board-enterprise-sensors.c16
-rw-r--r--arch/arm/mach-tegra/board-enterprise.c54
-rw-r--r--arch/arm/mach-tegra/board-enterprise.h2
-rw-r--r--arch/arm/mach-tegra/board-kai-sensors.c15
-rw-r--r--arch/arm/mach-tegra/board-kai.c54
-rw-r--r--arch/arm/mach-tegra/board-kai.h2
-rw-r--r--arch/arm/mach-tegra/devices.c11
-rw-r--r--arch/arm/mach-tegra/devices.h3
-rw-r--r--arch/arm/mach-tegra/include/mach/thermal.h55
-rw-r--r--arch/arm/mach-tegra/tegra3_thermal.c132
-rw-r--r--arch/arm/mach-tegra/tegra3_throttle.c9
-rw-r--r--arch/arm/mach-tegra/tegra3_tsensor.c15
15 files changed, 164 insertions, 377 deletions
diff --git a/arch/arm/mach-tegra/board-cardhu-sensors.c b/arch/arm/mach-tegra/board-cardhu-sensors.c
index 689ae6735e27..adccac3571be 100644
--- a/arch/arm/mach-tegra/board-cardhu-sensors.c
+++ b/arch/arm/mach-tegra/board-cardhu-sensors.c
@@ -60,6 +60,7 @@
#include "gpio-names.h"
#include "board-cardhu.h"
#include "cpu-tegra.h"
+#include "devices.h"
static struct regulator *cardhu_1v8_cam1 = NULL;
static struct regulator *cardhu_1v8_cam2 = NULL;
@@ -830,12 +831,6 @@ static int nct_get_temp(void *_data, long *temp)
return nct1008_thermal_get_temp(data, temp);
}
-static int nct_get_temp_low(void *_data, long *temp)
-{
- struct nct1008_data *data = _data;
- return nct1008_thermal_get_temp_low(data, temp);
-}
-
static int nct_set_limits(void *_data,
long lo_limit_milli,
long hi_limit_milli)
@@ -854,12 +849,6 @@ static int nct_set_alert(void *_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);
-}
-
#ifdef CONFIG_TEGRA_SKIN_THROTTLE
static int nct_get_itemp(void *dev_data, long *temp)
{
@@ -882,12 +871,9 @@ static void nct1008_probe_callback(struct nct1008_data *data)
ext_nct->name = "nct_ext";
ext_nct->id = THERMAL_DEVICE_ID_NCT_EXT;
ext_nct->data = data;
- ext_nct->offset = TDIODE_OFFSET;
ext_nct->get_temp = nct_get_temp;
- ext_nct->get_temp_low = nct_get_temp_low;
ext_nct->set_limits = nct_set_limits;
ext_nct->set_alert = nct_set_alert;
- ext_nct->set_shutdown_temp = nct_set_shutdown_temp;
tegra_thermal_device_register(ext_nct);
@@ -969,6 +955,80 @@ static int cardhu_nct1008_init(void)
return ret;
}
+#ifdef CONFIG_TEGRA_SKIN_THROTTLE
+static int tegra_skin_get_temp(void *data, long *temp)
+{
+ enum thermal_device_id id = (enum thermal_device_id)data;
+ struct tegra_thermal_device *device = tegra_thermal_get_device(id);
+
+ /* if sensor has not loaded use 25C as default */
+ if (!device || device->get_temp(device->data, temp))
+ *temp = 25000;
+
+ return 0;
+}
+
+static struct therm_est_data skin_data = {
+ .toffset = 9793,
+ .polling_period = 1100,
+ .ndevs = 2,
+ .devs = {
+ {
+ .dev_data = (void *)THERMAL_DEVICE_ID_NCT_EXT,
+ .get_temp = tegra_skin_get_temp,
+ .coeffs = {
+ 2, 1, 1, 1,
+ 1, 1, 1, 1,
+ 1, 1, 1, 0,
+ 1, 1, 0, 0,
+ 0, 0, -1, -7
+ },
+ },
+ {
+ .dev_data = (void *)THERMAL_DEVICE_ID_NCT_INT,
+ .get_temp = tegra_skin_get_temp,
+ .coeffs = {
+ -11, -7, -5, -3,
+ -3, -2, -1, 0,
+ 0, 0, 1, 1,
+ 1, 2, 2, 3,
+ 4, 6, 11, 18
+ },
+ },
+ },
+ .trip_temp = 43000,
+ .tc1 = 1,
+ .tc2 = 15,
+ .passive_delay = 15000,
+};
+
+static struct balanced_throttle skin_throttle = {
+ .throt_tab_size = 6,
+ .throt_tab = {
+ { 640000, 1200 },
+ { 640000, 1200 },
+ { 760000, 1200 },
+ { 760000, 1200 },
+ {1000000, 1200 },
+ {1000000, 1200 },
+ },
+};
+
+static int __init cardhu_skin_init(void)
+{
+ struct thermal_cooling_device *skin_cdev;
+
+ skin_cdev = balanced_throttle_register(&skin_throttle);
+
+ skin_data.cdev = skin_cdev;
+ tegra_skin_therm_est_device.dev.platform_data = &skin_data;
+ platform_device_register(&tegra_skin_therm_est_device);
+
+ return 0;
+}
+late_initcall(cardhu_skin_init);
+#endif
+
#if defined(CONFIG_GPIO_PCA953X)
static struct pca953x_platform_data cardhu_pmu_tca6416_data = {
.gpio_base = PMU_TCA6416_GPIO_BASE,
diff --git a/arch/arm/mach-tegra/board-cardhu.c b/arch/arm/mach-tegra/board-cardhu.c
index ce34e17e545e..5f51a7ad5073 100644
--- a/arch/arm/mach-tegra/board-cardhu.c
+++ b/arch/arm/mach-tegra/board-cardhu.c
@@ -101,22 +101,6 @@ static struct balanced_throttle throttle_list[] = {
{1000000, 1100 },
},
},
-#ifdef CONFIG_TEGRA_SKIN_THROTTLE
- {
- .tegra_cdev = {
- .id = CDEV_BTHROT_ID_SKIN,
- },
- .throt_tab_size = 6,
- .throt_tab = {
- { 640000, 1200 },
- { 640000, 1200 },
- { 760000, 1200 },
- { 760000, 1200 },
- {1000000, 1200 },
- {1000000, 1200 },
- },
- },
-#endif
};
static struct tegra_thermal_bind thermal_binds[] = {
@@ -140,59 +124,11 @@ static struct tegra_thermal_bind thermal_binds[] = {
.get_trip_temp = tegra_edp_get_trip_temp,
.get_trip_size = tegra_edp_get_trip_size,
},
-#ifdef CONFIG_TEGRA_SKIN_THROTTLE
- /* Skin Thermal Throttling */
- {
- .tdev_id = THERMAL_DEVICE_ID_SKIN,
- .cdev_id = CDEV_BTHROT_ID_SKIN,
- .type = THERMAL_TRIP_PASSIVE,
- .passive = {
- .trip_temp = 43000,
- .tc1 = 10,
- .tc2 = 1,
- .passive_delay = 15000,
- }
- },
-#endif
{
.tdev_id = THERMAL_DEVICE_ID_NULL,
},
};
-static struct tegra_skin_data skin_data = {
-#ifdef CONFIG_TEGRA_SKIN_THROTTLE
- .skin_device_id = THERMAL_DEVICE_ID_THERM_EST_SKIN,
- .skin_temp_offset = 9793,
- .skin_period = 1100,
- .skin_devs_size = 2,
- .skin_devs = {
- {
- THERMAL_DEVICE_ID_NCT_EXT,
- {
- 2, 1, 1, 1,
- 1, 1, 1, 1,
- 1, 1, 1, 0,
- 1, 1, 0, 0,
- 0, 0, -1, -7
- }
- },
- {
- THERMAL_DEVICE_ID_NCT_INT,
- {
- -11, -7, -5, -3,
- -3, -2, -1, 0,
- 0, 0, 1, 1,
- 1, 2, 2, 3,
- 4, 6, 11, 18
- }
- },
- },
-#else
- .skin_device_id = THERMAL_DEVICE_ID_NULL,
-#endif
-};
-
-
static struct rfkill_gpio_platform_data cardhu_bt_rfkill_pdata[] = {
{
.name = "bt_rfkill",
@@ -1435,12 +1371,21 @@ static void cardhu_sata_init(void)
static void cardhu_sata_init(void) { }
#endif
+/* This needs to be inialized later hand */
+static int __init cardhu_throttle_list_init(void)
+{
+ int i;
+ for (i = 0; i < ARRAY_SIZE(throttle_list); i++)
+ if (balanced_throttle_register(&throttle_list[i]))
+ return -ENODEV;
+
+ return 0;
+}
+late_initcall(cardhu_throttle_list_init);
+
static void __init tegra_cardhu_init(void)
{
- tegra_thermal_init(thermal_binds,
- &skin_data,
- throttle_list,
- ARRAY_SIZE(throttle_list));
+ tegra_thermal_init(thermal_binds);
tegra_clk_init_from_table(cardhu_clk_init_table);
tegra_enable_pinmux();
tegra_smmu_init();
diff --git a/arch/arm/mach-tegra/board-cardhu.h b/arch/arm/mach-tegra/board-cardhu.h
index 759e69bc1e42..211dbce5358b 100644
--- a/arch/arm/mach-tegra/board-cardhu.h
+++ b/arch/arm/mach-tegra/board-cardhu.h
@@ -256,6 +256,4 @@ extern struct tegra_uart_platform_data cardhu_irda_pdata;
#define XMM_GPIO_IPC_BB_WAKE BB_GPIO_AWR
#define XMM_GPIO_IPC_AP_WAKE BB_GPIO_CWR
-#define TDIODE_OFFSET (10000) /* in millicelsius */
-
#endif
diff --git a/arch/arm/mach-tegra/board-enterprise-sensors.c b/arch/arm/mach-tegra/board-enterprise-sensors.c
index 2448cd0febe4..0b8f8d610da9 100644
--- a/arch/arm/mach-tegra/board-enterprise-sensors.c
+++ b/arch/arm/mach-tegra/board-enterprise-sensors.c
@@ -63,12 +63,6 @@ static int nct_get_temp(void *_data, long *temp)
return nct1008_thermal_get_temp(data, temp);
}
-static int nct_get_temp_low(void *_data, long *temp)
-{
- struct nct1008_data *data = _data;
- return nct1008_thermal_get_temp_low(data, temp);
-}
-
static int nct_set_limits(void *_data,
long lo_limit_milli,
long hi_limit_milli)
@@ -87,13 +81,6 @@ static int nct_set_alert(void *_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;
@@ -108,12 +95,9 @@ static void nct1008_probe_callback(struct nct1008_data *data)
thermal_device->name = "nct1008";
thermal_device->data = data;
thermal_device->id = THERMAL_DEVICE_ID_NCT_EXT;
- thermal_device->offset = TDIODE_OFFSET;
thermal_device->get_temp = nct_get_temp;
- thermal_device->get_temp_low = nct_get_temp_low;
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_device_register(thermal_device);
}
diff --git a/arch/arm/mach-tegra/board-enterprise.c b/arch/arm/mach-tegra/board-enterprise.c
index fe872bdade9b..2cb997f9501e 100644
--- a/arch/arm/mach-tegra/board-enterprise.c
+++ b/arch/arm/mach-tegra/board-enterprise.c
@@ -96,22 +96,6 @@ static struct balanced_throttle throttle_list[] = {
{1000000, 1100 },
},
},
-#ifdef CONFIG_TEGRA_SKIN_THROTTLE
- {
- .tegra_cdev = {
- .id = CDEV_BTHROT_ID_SKIN,
- },
- .throt_tab_size = 6,
- .throt_tab = {
- { 640000, 1200 },
- { 640000, 1200 },
- { 760000, 1200 },
- { 760000, 1200 },
- {1000000, 1200 },
- {1000000, 1200 },
- },
- },
-#endif
};
/* All units are in millicelsius */
@@ -127,32 +111,11 @@ static struct tegra_thermal_bind thermal_binds[] = {
.passive_delay = 2000,
}
},
-#ifdef CONFIG_TEGRA_SKIN_THROTTLE
- {
- .tdev_id = THERMAL_DEVICE_ID_SKIN,
- .cdev_id = CDEV_BTHROT_ID_SKIN,
- .type = THERMAL_TRIP_PASSIVE,
- .passive = {
- .trip_temp = 43000,
- .tc1 = 10,
- .tc2 = 1,
- .passive_delay = 15000,
- }
- },
-#endif
{
.tdev_id = THERMAL_DEVICE_ID_NULL,
},
};
-static struct tegra_skin_data skin_data = {
-#ifdef CONFIG_TEGRA_SKIN_THROTTLE
- .skin_device_id = THERMAL_DEVICE_ID_SKIN,
-#else
- .skin_device_id = THERMAL_DEVICE_ID_NULL,
-#endif
-};
-
static struct rfkill_gpio_platform_data enterprise_bt_rfkill_pdata[] = {
{
.name = "bt_rfkill",
@@ -1085,6 +1048,18 @@ static void enterprise_nfc_init(void)
}
}
+/* This needs to be inialized later hand */
+static int __init enterprise_throttle_list_init(void)
+{
+ int i;
+ for (i = 0; i < ARRAY_SIZE(throttle_list); i++)
+ if (balanced_throttle_register(&throttle_list[i]))
+ return -ENODEV;
+
+ return 0;
+}
+late_initcall(enterprise_throttle_list_init);
+
static void __init tegra_enterprise_init(void)
{
struct board_info board_info;
@@ -1094,10 +1069,7 @@ static void __init tegra_enterprise_init(void)
else
tegra_clk_init_from_table(enterprise_clk_i2s2_table);
- tegra_thermal_init(thermal_binds,
- &skin_data,
- throttle_list,
- ARRAY_SIZE(throttle_list));
+ tegra_thermal_init(thermal_binds);
tegra_clk_init_from_table(enterprise_clk_init_table);
tegra_enable_pinmux();
tegra_smmu_init();
diff --git a/arch/arm/mach-tegra/board-enterprise.h b/arch/arm/mach-tegra/board-enterprise.h
index e9bda707fed2..4903ea48ed55 100644
--- a/arch/arm/mach-tegra/board-enterprise.h
+++ b/arch/arm/mach-tegra/board-enterprise.h
@@ -146,8 +146,6 @@ void enterprise_bpc_mgmt_init(void);
#define XMM_GPIO_IPC_BB_WAKE BB_GPIO_HS1_AP2BB
#define XMM_GPIO_IPC_AP_WAKE BB_GPIO_HS1_BB2AP
-#define TDIODE_OFFSET (9000) /* in millicelsius */
-
/* Battery Peak Current Management */
#define TEGRA_BPC_TRIGGER TEGRA_GPIO_PR3
#define TEGRA_BPC_TIMEOUT 100 /* ms */
diff --git a/arch/arm/mach-tegra/board-kai-sensors.c b/arch/arm/mach-tegra/board-kai-sensors.c
index 8fae12166670..2a062ca76d70 100644
--- a/arch/arm/mach-tegra/board-kai-sensors.c
+++ b/arch/arm/mach-tegra/board-kai-sensors.c
@@ -47,12 +47,6 @@ static int nct_get_temp(void *_data, long *temp)
return nct1008_thermal_get_temp(data, temp);
}
-static int nct_get_temp_low(void *_data, long *temp)
-{
- struct nct1008_data *data = _data;
- return nct1008_thermal_get_temp_low(data, temp);
-}
-
static int nct_set_limits(void *_data,
long lo_limit_milli,
long hi_limit_milli)
@@ -71,12 +65,6 @@ static int nct_set_alert(void *_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;
@@ -91,12 +79,9 @@ static void nct1008_probe_callback(struct nct1008_data *data)
thermal_device->name = "nct72";
thermal_device->data = data;
thermal_device->id = THERMAL_DEVICE_ID_NCT_EXT;
- thermal_device->offset = TDIODE_OFFSET;
thermal_device->get_temp = nct_get_temp;
- thermal_device->get_temp_low = nct_get_temp_low;
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_device_register(thermal_device);
}
diff --git a/arch/arm/mach-tegra/board-kai.c b/arch/arm/mach-tegra/board-kai.c
index 73cf60e40aae..55ac8ba8b70d 100644
--- a/arch/arm/mach-tegra/board-kai.c
+++ b/arch/arm/mach-tegra/board-kai.c
@@ -93,22 +93,6 @@ static struct balanced_throttle throttle_list[] = {
{1000000, 1100 },
},
},
-#ifdef CONFIG_TEGRA_SKIN_THROTTLE
- {
- .tegra_cdev = {
- .id = CDEV_BTHROT_ID_SKIN,
- },
- .throt_tab_size = 6,
- .throt_tab = {
- { 640000, 1200 },
- { 640000, 1200 },
- { 760000, 1200 },
- { 760000, 1200 },
- {1000000, 1200 },
- {1000000, 1200 },
- },
- },
-#endif
};
/* All units are in millicelsius */
@@ -124,32 +108,11 @@ static struct tegra_thermal_bind thermal_binds[] = {
.passive_delay = 2000,
}
},
-#ifdef CONFIG_TEGRA_SKIN_THROTTLE
- {
- .tdev_id = THERMAL_DEVICE_ID_SKIN,
- .cdev_id = CDEV_BTHROT_ID_SKIN,
- .type = THERMAL_TRIP_PASSIVE,
- .passive = {
- .trip_temp = 43000,
- .tc1 = 10,
- .tc2 = 1,
- .passive_delay = 15000,
- }
- },
-#endif
{
.tdev_id = THERMAL_DEVICE_ID_NULL,
},
};
-static struct tegra_skin_data skin_data = {
-#ifdef CONFIG_TEGRA_SKIN_THROTTLE
- .skin_device_id = THERMAL_DEVICE_ID_SKIN,
-#else
- .skin_device_id = THERMAL_DEVICE_ID_NULL,
-#endif
-};
-
/* wl128x BT, FM, GPS connectivity chip */
struct ti_st_plat_data kai_wilink_pdata = {
.nshutdown_gpio = TEGRA_GPIO_PU0,
@@ -888,12 +851,21 @@ static void kai_audio_init(void)
}
}
+/* This needs to be inialized later hand */
+static int __init kai_throttle_list_init(void)
+{
+ int i;
+ for (i = 0; i < ARRAY_SIZE(throttle_list); i++)
+ if (balanced_throttle_register(&throttle_list[i]))
+ return -ENODEV;
+
+ return 0;
+}
+late_initcall(kai_throttle_list_init);
+
static void __init tegra_kai_init(void)
{
- tegra_thermal_init(thermal_binds,
- &skin_data,
- throttle_list,
- ARRAY_SIZE(throttle_list));
+ tegra_thermal_init(thermal_binds);
tegra_clk_init_from_table(kai_clk_init_table);
tegra_enable_pinmux();
tegra_smmu_init();
diff --git a/arch/arm/mach-tegra/board-kai.h b/arch/arm/mach-tegra/board-kai.h
index 1d874f2d728a..6000553374c7 100644
--- a/arch/arm/mach-tegra/board-kai.h
+++ b/arch/arm/mach-tegra/board-kai.h
@@ -116,6 +116,4 @@ int __init touch_init_synaptics_kai(void);
#define MPU_COMPASS_BUS_NUM 2
#define MPU_COMPASS_ORIENTATION { 0, 1, 0, 1, 0, 0, 0, 0, -1 }
-#define TDIODE_OFFSET (10000) /* in millicelsius */
-
#endif
diff --git a/arch/arm/mach-tegra/devices.c b/arch/arm/mach-tegra/devices.c
index 373cab2680fc..24cd2bd26c2d 100644
--- a/arch/arm/mach-tegra/devices.c
+++ b/arch/arm/mach-tegra/devices.c
@@ -1939,6 +1939,17 @@ struct platform_device tegra_kbc_device = {
},
};
+#if defined(CONFIG_TEGRA_SKIN_THROTTLE)
+struct platform_device tegra_skin_therm_est_device = {
+ .name = "therm_est",
+ .id = -1,
+ .num_resources = 0,
+ .dev = {
+ .platform_data = 0,
+ },
+};
+#endif
+
#if defined(CONFIG_ARCH_TEGRA_3x_SOC)
static struct resource tegra_tsensor_resources[]= {
{
diff --git a/arch/arm/mach-tegra/devices.h b/arch/arm/mach-tegra/devices.h
index 10ee5a35b91e..27d8f86268be 100644
--- a/arch/arm/mach-tegra/devices.h
+++ b/arch/arm/mach-tegra/devices.h
@@ -140,6 +140,9 @@ extern struct platform_device tegra_uarte_device;
extern struct platform_device tegra_avp_device;
extern struct nvhost_device nvavp_device;
extern struct platform_device tegra_aes_device;
+#if defined(CONFIG_TEGRA_SKIN_THROTTLE)
+extern struct platform_device tegra_skin_therm_est_device;
+#endif
#if !defined(CONFIG_ARCH_TEGRA_2x_SOC)
extern struct platform_device tegra_tsensor_device;
#endif
diff --git a/arch/arm/mach-tegra/include/mach/thermal.h b/arch/arm/mach-tegra/include/mach/thermal.h
index 6ff525264bc7..43388d2af5b0 100644
--- a/arch/arm/mach-tegra/include/mach/thermal.h
+++ b/arch/arm/mach-tegra/include/mach/thermal.h
@@ -20,22 +20,18 @@
#include <linux/therm_est.h>
#include <linux/thermal.h>
-#ifndef CONFIG_THERMAL
-#endif
-
enum thermal_device_id {
- THERMAL_DEVICE_ID_NULL = 0x0,
- THERMAL_DEVICE_ID_NCT_EXT = 0x1,
- THERMAL_DEVICE_ID_NCT_INT = 0x2,
- THERMAL_DEVICE_ID_TSENSOR = 0x4,
- THERMAL_DEVICE_ID_THERM_EST_SKIN = 0x8,
+ THERMAL_DEVICE_ID_NULL = 0,
+ THERMAL_DEVICE_ID_NCT_EXT = 1,
+ THERMAL_DEVICE_ID_NCT_INT = 2,
+ THERMAL_DEVICE_ID_TSENSOR = 3,
+ THERMAL_DEVICE_ID_THERM_EST_SKIN = 4,
};
-#define THERMAL_DEVICE_MAX (4)
+#define THERMAL_DEVICE_MAX (5)
enum cooling_device_id {
CDEV_BTHROT_ID_TJ = 0x00010000,
- CDEV_BTHROT_ID_SKIN = 0x00020000,
CDEV_EDPTABLE_ID_EDP = 0x00030000,
CDEV_EDPTABLE_ID_EDP_0 = 0x00030000,
CDEV_EDPTABLE_ID_EDP_1 = 0x00030001,
@@ -58,30 +54,13 @@ struct tegra_thermal_bind {
} passive;
};
-struct skin_therm_est_subdevice {
- enum thermal_device_id id;
- long coeffs[HIST_LEN];
-};
-
-struct tegra_skin_data {
- enum thermal_device_id skin_device_id;
-
- long skin_temp_offset;
- long skin_period;
- int skin_devs_size;
- struct skin_therm_est_subdevice skin_devs[];
-};
-
struct tegra_thermal_device {
char *name;
enum thermal_device_id id;
void *data;
- long offset;
int (*get_temp) (void *, long *);
- int (*get_temp_low)(void *, long *);
int (*set_limits) (void *, long, long);
int (*set_alert)(void *, void (*)(void *), void *);
- int (*set_shutdown_temp)(void *, long);
struct thermal_zone_device *thz;
struct list_head node;
};
@@ -108,27 +87,27 @@ struct balanced_throttle {
};
#ifdef CONFIG_TEGRA_THERMAL_THROTTLE
-int balanced_throttle_register(struct balanced_throttle *bthrot);
+struct thermal_cooling_device *balanced_throttle_register(
+ struct balanced_throttle *bthrot);
#else
-static inline int balanced_throttle_register(struct balanced_throttle *bthrot)
-{ return 0; }
+static inline struct thermal_cooling_device *balanced_throttle_register(
+ struct balanced_throttle *bthrot)
+{ return ERR_PTR(-EINVAL); }
#endif
#ifdef CONFIG_TEGRA_THERMAL
-int tegra_thermal_init(struct tegra_thermal_bind *thermal_binds,
- struct tegra_skin_data *skin_data,
- struct balanced_throttle *throttle_list,
- int throttle_list_size);
+int tegra_thermal_init(struct tegra_thermal_bind *thermal_binds);
int tegra_thermal_device_register(struct tegra_thermal_device *device);
+struct tegra_thermal_device *tegra_thermal_get_device(enum thermal_device_id id);
int tegra_thermal_exit(void);
#else
-static inline int tegra_thermal_init(struct tegra_thermal_bind *thermal_binds,
- struct tegra_skin_data *skin_data,
- struct balanced_throttle *throttle_list,
- int throttle_list_size)
+static inline int tegra_thermal_init(struct tegra_thermal_bind *thermal_binds)
{ return 0; }
static inline int tegra_thermal_device_register(struct tegra_thermal_device *device)
{ return 0; }
+static inline struct tegra_thermal_device *tegra_thermal_get_device(
+ enum thermal_device_id id)
+{ return NULL; }
static inline int tegra_thermal_exit(void)
{ return 0; }
#endif
diff --git a/arch/arm/mach-tegra/tegra3_thermal.c b/arch/arm/mach-tegra/tegra3_thermal.c
index eb319e20d5c6..f76723e1d7d6 100644
--- a/arch/arm/mach-tegra/tegra3_thermal.c
+++ b/arch/arm/mach-tegra/tegra3_thermal.c
@@ -30,25 +30,13 @@
#include <linux/slab.h>
#include <linux/suspend.h>
-#include "clock.h"
-#include "cpu-tegra.h"
-#include "dvfs.h"
-
static struct tegra_thermal_bind *thermal_binds;
-static struct tegra_skin_data *skin_therm;
-static LIST_HEAD(tegra_therm_list);
-static DEFINE_MUTEX(tegra_therm_mutex);
-static struct balanced_throttle *throttle_list;
-static int throttle_list_size;
+static struct tegra_thermal_device *devices[THERMAL_DEVICE_MAX];
+static bool tegra_thermal_suspend;
#define MAX_TEMP (120000)
-#ifdef CONFIG_TEGRA_SKIN_THROTTLE
-static int skin_devs_bitmap;
-static struct therm_est_subdevice *skin_devs[THERMAL_DEVICE_MAX];
-static int skin_devs_count;
-#endif
static bool tegra_thermal_suspend;
static int tegra_thermal_zone_bind(struct thermal_zone_device *thz,
@@ -153,9 +141,9 @@ static int tegra_thermal_zone_get_trip_temp(struct thermal_zone_device *thz,
static struct thermal_zone_device_ops tegra_thermal_zone_ops = {
.bind = tegra_thermal_zone_bind,
.unbind = tegra_thermal_zone_unbind,
- .get_temp = tegra_thermal_zone_get_temp,
.get_trip_type = tegra_thermal_zone_get_trip_type,
.get_trip_temp = tegra_thermal_zone_get_trip_temp,
+ .get_temp = tegra_thermal_zone_get_temp,
};
static int tegra_thermal_pm_notify(struct notifier_block *nb,
@@ -183,10 +171,8 @@ static void tegra_thermal_alert(void *data)
long temp, trip_temp, low_temp = 0, high_temp = MAX_TEMP;
int count;
- mutex_lock(&tegra_therm_mutex);
-
if (!device->thz)
- goto done;
+ return;
if ((!device->thz->passive) && (!tegra_thermal_suspend))
thermal_zone_device_update(device->thz);
@@ -205,60 +191,15 @@ static void tegra_thermal_alert(void *data)
if (device->set_limits && device->thz->trips)
device->set_limits(device->data, low_temp, high_temp);
-done:
- mutex_unlock(&tegra_therm_mutex);
}
-#ifdef CONFIG_TEGRA_SKIN_THROTTLE
-static int tegra_skin_device_register(struct tegra_thermal_device *device)
+struct tegra_thermal_device *tegra_thermal_get_device(enum thermal_device_id id)
{
- int i;
- struct therm_est_subdevice *skin_dev =
- kzalloc(sizeof(struct therm_est_subdevice), GFP_KERNEL);
-
- for (i = 0; i < skin_therm->skin_devs_size; i++) {
- if (skin_therm->skin_devs[i].id == device->id) {
- memcpy(skin_dev->coeffs,
- skin_therm->skin_devs[i].coeffs,
- sizeof(skin_devs[i]->coeffs));
- break;
- }
- }
-
- skin_dev->dev_data = device->data;
- skin_dev->get_temp = device->get_temp;
-
- skin_devs[skin_devs_count++] = skin_dev;
-
- /* Create skin thermal device */
- if (skin_devs_count == skin_therm->skin_devs_size) {
- struct tegra_thermal_device *thermal_skin_device;
- struct therm_estimator *skin_estimator;
-
- skin_estimator = therm_est_register(
- skin_devs,
- skin_devs_count,
- skin_therm->skin_temp_offset,
- skin_therm->skin_period);
- thermal_skin_device = kzalloc(sizeof(struct tegra_thermal_device),
- GFP_KERNEL);
- thermal_skin_device->name = "skin_pred";
- thermal_skin_device->id = THERMAL_DEVICE_ID_SKIN;
- thermal_skin_device->data = skin_estimator;
- thermal_skin_device->get_temp =
- (int (*)(void *, long *)) therm_est_get_temp;
- thermal_skin_device->set_limits =
- (int (*)(void *, long, long)) therm_est_set_limits;
- thermal_skin_device->set_alert =
- (int (*)(void *, void (*)(void *), void *))
- therm_est_set_alert;
-
- tegra_thermal_device_register(thermal_skin_device);
- }
+ if (id < 0 || id >= THERMAL_DEVICE_MAX)
+ return NULL;
- return 0;
+ return devices[id];
}
-#endif
static int passive_get_trip_temp(void *data, long trip)
{
@@ -273,17 +214,11 @@ static int passive_get_trip_size(void)
int tegra_thermal_device_register(struct tegra_thermal_device *device)
{
- struct tegra_thermal_device *dev;
struct thermal_zone_device *thz = NULL;
int i, t1 = 0, t2 = 0, pdelay = 0, trips=0;
- mutex_lock(&tegra_therm_mutex);
- list_for_each_entry(dev, &tegra_therm_list, node) {
- if (dev->id == device->id) {
- mutex_unlock(&tegra_therm_mutex);
- return -EINVAL;
- }
- }
+ if (device->id >= THERMAL_DEVICE_MAX || devices[device->id])
+ return -EINVAL;
for (i=0; thermal_binds[i].tdev_id; i++) {
if(device->id == thermal_binds[i].tdev_id) {
@@ -321,59 +256,27 @@ int tegra_thermal_device_register(struct tegra_thermal_device *device)
t2, /* throttle */
pdelay,
0); /* polling delay */
- if (IS_ERR_OR_NULL(thz))
+ if (IS_ERR_OR_NULL(thz)) {
return -ENODEV;
+ }
device->thz = thz;
}
- list_add(&device->node, &tegra_therm_list);
- mutex_unlock(&tegra_therm_mutex);
+ devices[device->id] = device;
if (thz) {
device->set_alert(device->data, tegra_thermal_alert, device);
tegra_thermal_alert(device);
}
-#ifdef CONFIG_TEGRA_SKIN_THROTTLE
- if ((skin_therm->skin_device_id == THERMAL_DEVICE_ID_SKIN) &&
- device->id && skin_devs_bitmap)
- tegra_skin_device_register(device);
-#endif
-
return 0;
}
-/* This needs to be inialized later hand */
-static int __init throttle_list_init(void)
-{
- int i;
- for (i = 0; i < throttle_list_size; i++)
- if (balanced_throttle_register(&throttle_list[i]))
- return -ENODEV;
-
- return 0;
-}
-late_initcall(throttle_list_init);
-int __init tegra_thermal_init(struct tegra_thermal_bind *binds,
- struct tegra_skin_data *skin_data,
- struct balanced_throttle *tlist,
- int tlist_size)
+int __init tegra_thermal_init(struct tegra_thermal_bind *binds)
{
thermal_binds = binds;
- skin_therm = skin_data;
-
-#ifdef CONFIG_TEGRA_SKIN_THROTTLE
- {
- int i;
- for (i = 0; i < skin_therm->skin_devs_size; i++)
- skin_devs_bitmap |= skin_therm->skin_devs[i].id;
- }
-#endif
-
- throttle_list = tlist;
- throttle_list_size = tlist_size;
register_pm_notifier(&tegra_thermal_nb);
@@ -382,13 +285,6 @@ int __init tegra_thermal_init(struct tegra_thermal_bind *binds,
int tegra_thermal_exit(void)
{
- struct tegra_thermal_device *dev;
- mutex_lock(&tegra_therm_mutex);
- list_for_each_entry(dev, &tegra_therm_list, node) {
- thermal_zone_device_unregister(dev->thz);
- }
- mutex_unlock(&tegra_therm_mutex);
-
return 0;
}
diff --git a/arch/arm/mach-tegra/tegra3_throttle.c b/arch/arm/mach-tegra/tegra3_throttle.c
index 23c02abbe790..21e2c16a63b5 100644
--- a/arch/arm/mach-tegra/tegra3_throttle.c
+++ b/arch/arm/mach-tegra/tegra3_throttle.c
@@ -246,7 +246,8 @@ static struct dentry *throttle_debugfs_root;
#endif /* CONFIG_DEBUG_FS */
-int balanced_throttle_register(struct balanced_throttle *bthrot)
+struct thermal_cooling_device *balanced_throttle_register(
+ struct balanced_throttle *bthrot)
{
#ifdef CONFIG_DEBUG_FS
char name[32];
@@ -257,7 +258,7 @@ int balanced_throttle_register(struct balanced_throttle *bthrot)
list_for_each_entry(dev, &bthrot_list, node) {
if (dev->tegra_cdev.id == bthrot->tegra_cdev.id) {
mutex_unlock(&bthrot_list_lock);
- return -EINVAL;
+ return ERR_PTR(-EINVAL);
}
}
@@ -272,7 +273,7 @@ int balanced_throttle_register(struct balanced_throttle *bthrot)
if (IS_ERR(bthrot->cdev)) {
bthrot->cdev = NULL;
- return -ENODEV;
+ return ERR_PTR(-ENODEV);
}
#ifdef CONFIG_DEBUG_FS
@@ -281,7 +282,7 @@ int balanced_throttle_register(struct balanced_throttle *bthrot)
bthrot, &table_fops);
#endif
- return 0;
+ return bthrot->cdev;
}
int __init tegra_throttle_init(struct mutex *cpu_lock)
diff --git a/arch/arm/mach-tegra/tegra3_tsensor.c b/arch/arm/mach-tegra/tegra3_tsensor.c
index 7a1c122099bc..526a355c695f 100644
--- a/arch/arm/mach-tegra/tegra3_tsensor.c
+++ b/arch/arm/mach-tegra/tegra3_tsensor.c
@@ -63,12 +63,6 @@ static int tsensor_get_temp(void *vdata, long *milli_temp)
return tsensor_thermal_get_temp(data, milli_temp);
}
-static int tsensor_get_temp_low(void *vdata, long *milli_temp)
-{
- struct tegra_tsensor_data *data = vdata;
- return tsensor_thermal_get_temp_low(data, milli_temp);
-}
-
static int tsensor_set_limits(void *vdata,
long lo_limit_milli,
long hi_limit_milli)
@@ -87,12 +81,6 @@ static int tsensor_set_alert(void *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;
@@ -108,12 +96,9 @@ static void tegra3_tsensor_probe_callback(struct tegra_tsensor_data *data)
thermal_device->name = "tsensor";
thermal_device->data = data;
thermal_device->id = THERMAL_DEVICE_ID_TSENSOR;
- thermal_device->offset = TSENSOR_OFFSET;
thermal_device->get_temp = tsensor_get_temp;
- thermal_device->get_temp_low = tsensor_get_temp_low;
thermal_device->set_limits = tsensor_set_limits;
thermal_device->set_alert = tsensor_set_alert;
- thermal_device->set_shutdown_temp = tsensor_set_shutdown_temp;
/* This should not fail */
if (tegra_thermal_device_register(thermal_device))