ARM: tegra: thermal: Cleaned up thermal framework
Joshua Primero [Thu, 9 Aug 2012 23:44:29 +0000 (16:44 -0700)]
Removed shutdown and tc1,tc2,passive delay parameters from
thermal state.

Change-Id: Icd97afaf912a9fb7ab930c95d52d0e1dee42ce5a
Signed-off-by: Joshua Primero <jprimero@nvidia.com>
Reviewed-on: http://git-master/r/124500
Reviewed-by: Varun Colbert <vcolbert@nvidia.com>
Tested-by: Varun Colbert <vcolbert@nvidia.com>

arch/arm/mach-tegra/board-cardhu.c
arch/arm/mach-tegra/board-enterprise.c
arch/arm/mach-tegra/board-kai.c
arch/arm/mach-tegra/include/mach/thermal.h
arch/arm/mach-tegra/tegra3_thermal.c
arch/arm/mach-tegra/tegra3_throttle.c

index 7a55f7f..c0b890e 100644 (file)
@@ -42,6 +42,7 @@
 #include <linux/nfc/pn544.h>
 #include <linux/rfkill-gpio.h>
 
+
 #include <sound/wm8903.h>
 #include <sound/max98095.h>
 #include <media/tegra_dtv.h>
@@ -63,6 +64,7 @@
 #include <mach/pci.h>
 #include <mach/gpio-tegra.h>
 #include <mach/tegra_fiq_debugger.h>
+#include <linux/thermal.h>
 
 #include <asm/hardware/gic.h>
 #include <asm/mach-types.h>
@@ -82,7 +84,9 @@
 
 static struct balanced_throttle throttle_list[] = {
        {
-               .id = BALANCED_THROTTLE_ID_TJ,
+               .tegra_cdev = {
+                       .id = CDEV_BTHROT_ID_TJ,
+               },
                .throt_tab_size = 10,
                .throt_tab = {
                        {      0, 1000 },
@@ -99,7 +103,9 @@ static struct balanced_throttle throttle_list[] = {
        },
 #ifdef CONFIG_TEGRA_SKIN_THROTTLE
        {
-               .id = BALANCED_THROTTLE_ID_SKIN,
+               .tegra_cdev = {
+                       .id = CDEV_BTHROT_ID_SKIN,
+               },
                .throt_tab_size = 6,
                .throt_tab = {
                        { 640000, 1200 },
@@ -115,26 +121,49 @@ static struct balanced_throttle throttle_list[] = {
 
 /* All units are in millicelsius */
 static struct tegra_thermal_data thermal_data = {
-       .shutdown_device_id = THERMAL_DEVICE_ID_NCT_EXT,
-       .temp_shutdown = 90000,
        .throttle_edp_device_id = THERMAL_DEVICE_ID_NCT_EXT,
 #ifdef CONFIG_TEGRA_EDP_LIMITS
        .edp_offset = TDIODE_OFFSET,  /* edp based on tdiode */
        .hysteresis_edp = 3000,
 #endif
        .temp_throttle = 85000,
-       .tc1 = 0,
-       .tc2 = 1,
-       .passive_delay = 2000,
+       .binds = {
+               /* Thermal Throttling */
+               {
+                       .tdev_id = THERMAL_DEVICE_ID_NCT_EXT,
+                       .cdev_id = CDEV_BTHROT_ID_TJ,
+                       .type = THERMAL_TRIP_PASSIVE,
+                       .passive = {
+                               .trip_temp = 85000,
+                               .tc1 = 0,
+                               .tc2 = 1,
+                               .passive_delay = 2000,
+                       }
+               },
+#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_SKIN,
+       .skin_device_id = THERMAL_DEVICE_ID_THERM_EST_SKIN,
        .temp_throttle_skin = 43000,
-       .tc1_skin = 0,
-       .tc2_skin = 1,
-       .passive_delay_skin = 5000,
        .skin_temp_offset = 9793,
        .skin_period = 1100,
        .skin_devs_size = 2,
index 22bbdb1..ec462b9 100644 (file)
@@ -75,7 +75,9 @@
 
 static struct balanced_throttle throttle_list[] = {
        {
-               .id = BALANCED_THROTTLE_ID_TJ,
+               .tegra_cdev = {
+                       .id = CDEV_BTHROT_ID_TJ,
+               },
                .throt_tab_size = 10,
                .throt_tab = {
                        {      0, 1000 },
@@ -92,7 +94,9 @@ static struct balanced_throttle throttle_list[] = {
        },
 #ifdef CONFIG_TEGRA_SKIN_THROTTLE
        {
-               .id = BALANCED_THROTTLE_ID_SKIN,
+               .tegra_cdev = {
+                       .id = CDEV_BTHROT_ID_SKIN,
+               },
                .throt_tab_size = 6,
                .throt_tab = {
                        { 640000, 1200 },
@@ -108,17 +112,42 @@ static struct balanced_throttle throttle_list[] = {
 
 /* All units are in millicelsius */
 static struct tegra_thermal_data thermal_data = {
-       .shutdown_device_id = THERMAL_DEVICE_ID_NCT_EXT,
-       .temp_shutdown = 90000,
        .throttle_edp_device_id = THERMAL_DEVICE_ID_NCT_EXT,
 #ifdef CONFIG_TEGRA_EDP_LIMITS
        .edp_offset = TDIODE_OFFSET,  /* edp based on tdiode */
        .hysteresis_edp = 3000,
 #endif
        .temp_throttle = 85000,
-       .tc1 = 0,
-       .tc2 = 1,
-       .passive_delay = 2000,
+       .binds = {
+               {
+                       .tdev_id = THERMAL_DEVICE_ID_NCT_EXT,
+                       .cdev_id = CDEV_BTHROT_ID_TJ,
+                       .type = THERMAL_TRIP_PASSIVE,
+                       .passive = {
+                               .trip_temp = 85000,
+                               .tc1 = 0,
+                               .tc2 = 1,
+                               .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 = {
index 1cd51e7..1370814 100644 (file)
@@ -76,7 +76,9 @@
 
 static struct balanced_throttle throttle_list[] = {
        {
-               .id = BALANCED_THROTTLE_ID_TJ,
+               .tegra_cdev = {
+                       .id = CDEV_BTHROT_ID_TJ,
+               },
                .throt_tab_size = 10,
                .throt_tab = {
                        {      0, 1000 },
@@ -93,7 +95,9 @@ static struct balanced_throttle throttle_list[] = {
        },
 #ifdef CONFIG_TEGRA_SKIN_THROTTLE
        {
-               .id = BALANCED_THROTTLE_ID_SKIN,
+               .tegra_cdev = {
+                       .id = CDEV_BTHROT_ID_SKIN,
+               },
                .throt_tab_size = 6,
                .throt_tab = {
                        { 640000, 1200 },
@@ -109,17 +113,41 @@ static struct balanced_throttle throttle_list[] = {
 
 /* All units are in millicelsius */
 static struct tegra_thermal_data thermal_data = {
-       .shutdown_device_id = THERMAL_DEVICE_ID_NCT_EXT,
-       .temp_shutdown = 90000,
        .throttle_edp_device_id = THERMAL_DEVICE_ID_NCT_EXT,
 #ifdef CONFIG_TEGRA_EDP_LIMITS
        .edp_offset = TDIODE_OFFSET,  /* edp based on tdiode */
        .hysteresis_edp = 3000,
 #endif
        .temp_throttle = 85000,
-       .tc1 = 0,
-       .tc2 = 1,
-       .passive_delay = 2000,
+       .binds = {
+               {
+                       .tdev_id = THERMAL_DEVICE_ID_NCT_EXT,
+                       .cdev_id = CDEV_BTHROT_ID_TJ,
+                       .type = THERMAL_TRIP_PASSIVE,
+                       .passive = {
+                               .trip_temp = 85000,
+                               .tc1 = 0,
+                               .tc2 = 1,
+                               .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 = {
index 589f7ad..e8497bd 100644 (file)
@@ -18,6 +18,7 @@
 #define __MACH_THERMAL_H
 
 #include <linux/therm_est.h>
+#include <linux/thermal.h>
 
 #ifndef CONFIG_THERMAL
 #endif
@@ -27,42 +28,55 @@ enum thermal_device_id {
        THERMAL_DEVICE_ID_NCT_EXT = 0x1,
        THERMAL_DEVICE_ID_NCT_INT = 0x2,
        THERMAL_DEVICE_ID_TSENSOR = 0x4,
-       THERMAL_DEVICE_ID_SKIN = 0x8,
+       THERMAL_DEVICE_ID_THERM_EST_SKIN = 0x8,
 };
 
 #define THERMAL_DEVICE_MAX     (4)
 
-enum balanced_throttle_id {
-       BALANCED_THROTTLE_ID_TJ,
-       BALANCED_THROTTLE_ID_SKIN,
+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,
+       CDEV_EDPTABLE_ID_EDP_2 = 0x00030002,
+       CDEV_EDPTABLE_ID_EDP_3 = 0x00030003,
+       CDEV_EDPTABLE_ID_EDP_4 = 0x00030004,
 };
 
-struct skin_therm_est_subdevice {
-       enum thermal_device_id id;
-       long coeffs[HIST_LEN];
+struct tegra_thermal_bind {
+       enum thermal_device_id tdev_id;
+       enum cooling_device_id cdev_id;
+       int type;
+       int (*get_trip_temp) (void *, long);
+       int (*get_trip_size) (void);
+       struct passive_params {
+               long trip_temp;
+               int tc1;
+               int tc2;
+               long passive_delay;
+       } passive;
 };
 
 /* All units in millicelsius */
 struct tegra_thermal_data {
-       enum thermal_device_id shutdown_device_id;
-       long temp_shutdown;
        enum thermal_device_id throttle_edp_device_id;
 #ifdef CONFIG_TEGRA_EDP_LIMITS
        long edp_offset;
        long hysteresis_edp;
 #endif
        long temp_throttle;
-       int tc1;
-       int tc2;
-       long passive_delay;
+       struct tegra_thermal_bind binds[];
+};
+
+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 temp_throttle_skin;
-       int tc1_skin;
-       int tc2_skin;
-       int passive_delay_skin;
 
        long skin_temp_offset;
        long skin_period;
@@ -84,6 +98,10 @@ struct tegra_thermal_device {
        struct list_head node;
 };
 
+struct tegra_cooling_device {
+       enum cooling_device_id id;
+};
+
 struct throttle_table {
        unsigned int cpu_freq;
        int core_cap_level;
@@ -92,14 +110,11 @@ struct throttle_table {
 #define MAX_THROT_TABLE_SIZE   (32)
 
 struct balanced_throttle {
-       enum balanced_throttle_id id;
-
-       int is_throttling;
-       int throttle_index;
+       struct tegra_cooling_device tegra_cdev;
        struct thermal_cooling_device *cdev;
-
        struct list_head node;
-
+       int is_throttling;
+       int throttle_index;
        int throt_tab_size;
        struct throttle_table throt_tab[MAX_THROT_TABLE_SIZE];
 };
index ae01442..56be98e 100644 (file)
@@ -43,6 +43,8 @@ static DEFINE_MUTEX(tegra_therm_mutex);
 static struct balanced_throttle *throttle_list;
 static int throttle_list_size;
 
+#define MAX_TEMP (120000)
+
 #ifdef CONFIG_TEGRA_EDP_LIMITS
 static long edp_thermal_zone_val;
 #endif
@@ -92,38 +94,46 @@ static int tegra_thermal_get_temp_unlocked(long *tj_temp, bool offsetted)
 }
 
 static int tegra_thermal_zone_bind(struct thermal_zone_device *thz,
-                               struct thermal_cooling_device *cdevice) {
-
-       struct balanced_throttle *bthrot = cdevice->devdata;
+                               struct thermal_cooling_device *cdevice)
+{
+       int i, j, trip=0, trip_size, index;
+       struct tegra_cooling_device *tegra_cdev = cdevice->devdata;
        struct tegra_thermal_device *device = thz->devdata;
 
-       if ((bthrot->id == BALANCED_THROTTLE_ID_TJ) &&
-               (device->id == therm->throttle_edp_device_id))
-               return thermal_zone_bind_cooling_device(thz, 0, cdevice);
+       for (i=0; therm->binds[i].tdev_id; i++) {
+               if(device->id == therm->binds[i].tdev_id) {
+                       trip_size = therm->binds[i].get_trip_size();
+                       index = tegra_cdev->id & 0xffff;
+
+                       if (therm->binds[i].cdev_id  == (tegra_cdev->id & 0xffff0000)) {
+                               for (j=0; j < trip_size; j++) {
+                                       thermal_zone_bind_cooling_device(
+                                                       thz,
+                                                       trip + index,
+                                                       cdevice);
+                               }
+                       }
 
-#ifdef CONFIG_TEGRA_SKIN_THROTTLE
-       if ((bthrot->id == BALANCED_THROTTLE_ID_SKIN) &&
-               (device->id == skin_therm->skin_device_id))
-               return thermal_zone_bind_cooling_device(thz, 0, cdevice);
-#endif
+                       trip += trip_size;
+               }
+       }
 
        return 0;
 }
 
 static int tegra_thermal_zone_unbind(struct thermal_zone_device *thz,
                                struct thermal_cooling_device *cdevice) {
-       struct balanced_throttle *bthrot = cdevice->devdata;
+       int i, trip = 0;
+       struct tegra_cooling_device *tegra_cdev = cdevice->devdata;
        struct tegra_thermal_device *device = thz->devdata;
 
-       if ((bthrot->id == BALANCED_THROTTLE_ID_TJ) &&
-               (device->id == therm->throttle_edp_device_id))
-               return thermal_zone_unbind_cooling_device(thz, 0, cdevice);
-
-#ifdef CONFIG_TEGRA_SKIN_THROTTLE
-       if ((bthrot->id == BALANCED_THROTTLE_ID_SKIN) &&
-               (device->id == skin_therm->skin_device_id))
-               return thermal_zone_unbind_cooling_device(thz, 0, cdevice);
-#endif
+       for (i=0; therm->binds[i].tdev_id; i++) {
+               if(device->id == therm->binds[i].tdev_id) {
+                       if (tegra_cdev->id == therm->binds[i].cdev_id)
+                               thermal_zone_unbind_cooling_device(thz, trip, cdevice);
+                       trip += therm->binds[i].get_trip_size();
+               }
+       }
 
        return 0;
 }
@@ -140,35 +150,46 @@ static int tegra_thermal_zone_get_temp(struct thermal_zone_device *thz,
 }
 
 static int tegra_thermal_zone_get_trip_type(
-                       struct thermal_zone_device *thermal,
+                       struct thermal_zone_device *thz,
                        int trip,
                        enum thermal_trip_type *type) {
-       if (trip != 0)
-               return -EINVAL;
+       int i, trip_count = 0;
+       struct tegra_thermal_device *device = thz->devdata;
 
-       *type = THERMAL_TRIP_PASSIVE;
+       for (i=0; therm->binds[i].tdev_id; i++) {
+               if(device->id == therm->binds[i].tdev_id) {
+                       trip_count += therm->binds[i].get_trip_size();
+                       if (trip < trip_count) {
+                               *type = therm->binds[i].type;
+                               return 0;
+                       }
+               }
+       }
 
-       return 0;
+       return -EINVAL;
 }
 
 static int tegra_thermal_zone_get_trip_temp(struct thermal_zone_device *thz,
                                        int trip,
                                        unsigned long *temp) {
+       int i, j, trip_size, trip_count = 0;
        struct tegra_thermal_device *device = thz->devdata;
 
-       if (trip != 0)
-               return -EINVAL;
-
-       if (device->id == therm->throttle_edp_device_id)
-               *temp = therm->temp_throttle;
-#ifdef CONFIG_TEGRA_SKIN_THROTTLE
-       else if (device->id == skin_therm->skin_device_id)
-               *temp = skin_therm->temp_throttle_skin;
-#endif
-       else
-               return -EINVAL;
+       for (i=0; therm->binds[i].tdev_id; i++) {
+               if(device->id == therm->binds[i].tdev_id) {
+                       trip_size = therm->binds[i].get_trip_size();
+                       for (j=0; j < trip_size; j++) {
+                               if (trip == trip_count) {
+                                       *temp = therm->binds[i].get_trip_temp(
+                                                       &therm->binds[i], j);
+                                       return 0;
+                               }
+                               trip_count++;
+                       }
+               }
+       }
 
-       return 0;
+       return -EINVAL;
 }
 
 static struct thermal_zone_device_ops tegra_thermal_zone_ops = {
@@ -198,7 +219,7 @@ static struct notifier_block tegra_thermal_nb = {
        .notifier_call = tegra_thermal_pm_notify,
 };
 
-static void tegra_thermal_alert_unlocked(void *data)
+static void tegra_thermal_alert(void *data)
 {
        struct tegra_thermal_device *device = data;
        long temp_tj;
@@ -212,27 +233,28 @@ static void tegra_thermal_alert_unlocked(void *data)
        int i;
 #endif
 
-       if (device->thz) {
+       mutex_lock(&tegra_therm_mutex);
+
+       if (device->thz)
                if ((!device->thz->passive) && (!tegra_thermal_suspend))
                        thermal_zone_device_update(device->thz);
-       }
-
 
        /* Convert all temps to tj and then do all work/logic in terms of
           tj in order to avoid confusion */
        if (tegra_thermal_get_temp_unlocked(&temp_tj, true))
-               return;
+               goto done;
+
        device->get_temp_low(device, &temp_low_dev);
        temp_low_tj = dev2tj(device, temp_low_dev);
 
        lo_limit_throttle_tj = temp_low_tj;
-       hi_limit_throttle_tj = dev2tj(device, therm->temp_shutdown);
+       hi_limit_throttle_tj = dev2tj(device, MAX_TEMP);
 
        hi_limit_throttle_tj = dev2tj(device, therm->temp_throttle);
 
        if (temp_tj > dev2tj(device, therm->temp_throttle)) {
                lo_limit_throttle_tj = dev2tj(device, therm->temp_throttle);
-               hi_limit_throttle_tj = dev2tj(device, therm->temp_shutdown);
+               hi_limit_throttle_tj = dev2tj(device, MAX_TEMP);
        }
 
 #ifdef CONFIG_TEGRA_EDP_LIMITS
@@ -247,7 +269,7 @@ static void tegra_thermal_alert_unlocked(void *data)
        } else if (temp_tj >= EDP_TEMP_TJ(zones_sz-1)) {
                lo_limit_edp_tj = EDP_TEMP_TJ(zones_sz-1) -
                                        therm->hysteresis_edp;
-               hi_limit_edp_tj = dev2tj(device, therm->temp_shutdown);
+               hi_limit_edp_tj = dev2tj(device, MAX_TEMP);
        } else {
                for (i = 0; (i + 1) < zones_sz; i++) {
                        if ((temp_tj >= EDP_TEMP_TJ(i)) &&
@@ -262,7 +284,7 @@ static void tegra_thermal_alert_unlocked(void *data)
 #undef EDP_TEMP_TJ
 #else
        lo_limit_edp_tj = temp_low_tj;
-       hi_limit_edp_tj = dev2tj(device, therm->temp_shutdown);
+       hi_limit_edp_tj = dev2tj(device, MAX_TEMP);
 #endif
 
        /* Get smallest window size */
@@ -283,11 +305,7 @@ static void tegra_thermal_alert_unlocked(void *data)
 #endif
 }
 
-/* Make sure this function remains stateless */
-static void tegra_thermal_alert(void *data)
-{
-       mutex_lock(&tegra_therm_mutex);
-       tegra_thermal_alert_unlocked(data);
+done:
        mutex_unlock(&tegra_therm_mutex);
 }
 
@@ -350,12 +368,22 @@ static int tegra_skin_device_register(struct tegra_thermal_device *device)
 }
 #endif
 
+static int passive_get_trip_temp(void *data, long trip)
+{
+       struct tegra_thermal_bind *bind = data;
+       return bind->passive.trip_temp;
+}
+
+static int passive_get_trip_size(void)
+{
+       return 1;
+}
+
 int tegra_thermal_device_register(struct tegra_thermal_device *device)
 {
        struct tegra_thermal_device *dev;
        struct thermal_zone_device *thz;
-       int t1 = 0, t2 = 0, pdelay = 0;
-       bool create_thz = false;
+       int i, t1 = 0, t2 = 0, pdelay = 0, trips=0;
 
        mutex_lock(&tegra_therm_mutex);
        list_for_each_entry(dev, &tegra_therm_list, node) {
@@ -365,32 +393,42 @@ int tegra_thermal_device_register(struct tegra_thermal_device *device)
                }
        }
 
-       if (device->id == therm->throttle_edp_device_id) {
-               t1 = therm->tc1;
-               t2 = therm->tc2;
-               pdelay = therm->passive_delay;
-               create_thz = true;
-       }
+       for (i=0; therm->binds[i].tdev_id; i++) {
+               if(device->id == therm->binds[i].tdev_id) {
+                       switch(therm->binds[i].type) {
+                       case THERMAL_TRIP_PASSIVE:
+                               /* only one passive type allowed for now */
+                               if (pdelay)
+                                       return -EINVAL;
+
+                               /* These should be set only for ACTIVE types */
+                               if (therm->binds[i].get_trip_temp ||
+                                       therm->binds[i].get_trip_size)
+                                       return -EINVAL;
+
+                               t1 = therm->binds[i].passive.tc1;
+                               t2 = therm->binds[i].passive.tc2;
+                               pdelay = therm->binds[i].passive.passive_delay;
+
+                               therm->binds[i].get_trip_temp = passive_get_trip_temp;
+                               therm->binds[i].get_trip_size = passive_get_trip_size;
+                               break;
+                       }
 
-#ifdef CONFIG_TEGRA_SKIN_THROTTLE
-       if (device->id == skin_therm->skin_device_id) {
-               t1 = 0;
-               t2 = 1;
-               pdelay = 5000;
-               create_thz = true;
+                       trips += therm->binds[i].get_trip_size();
+               }
        }
-#endif
 
-       if (create_thz) {
+       if (trips) {
                thz = thermal_zone_device_register(
-                                               device->name,
-                                               1, /* trips */
-                                               device,
-                                               &tegra_thermal_zone_ops,
-                                               t1, /* dT/dt */
-                                               t2, /* throttle */
-                                               pdelay,
-                                               0); /* polling delay */
+                                       device->name,
+                                       trips, /* trips */
+                                       device,
+                                       &tegra_thermal_zone_ops,
+                                       t1, /* dT/dt */
+                                       t2, /* throttle */
+                                       pdelay,
+                                       0); /* polling delay */
                if (IS_ERR_OR_NULL(thz))
                        return -ENODEV;
 
@@ -400,10 +438,6 @@ int tegra_thermal_device_register(struct tegra_thermal_device *device)
        list_add(&device->node, &tegra_therm_list);
        mutex_unlock(&tegra_therm_mutex);
 
-       if (device->id == therm->shutdown_device_id) {
-               device->set_shutdown_temp(device->data, therm->temp_shutdown);
-       }
-
 #ifdef CONFIG_TEGRA_SKIN_THROTTLE
        if (device->id == skin_therm->skin_device_id) {
                if (create_thz)
@@ -509,47 +543,6 @@ static int __init temp_tj_debug_init(void)
 }
 late_initcall(temp_tj_debug_init);
 
-
-#define TEGRA_THERM_DEBUGFS(_name, _device_id, throttle, shutdown) \
-       static int tegra_thermal_##_name##_set(void *data, u64 val) \
-       { \
-               struct tegra_thermal_device *dev; \
-               mutex_lock(&tegra_therm_mutex); \
-               therm->_name = val; \
-               list_for_each_entry(dev, &tegra_therm_list, node) \
-                       if (dev->id == therm->_device_id) \
-                               break; \
-               if (dev) { \
-                       if (throttle) \
-                               tegra_thermal_alert_unlocked(dev); \
-                       if (shutdown) \
-                               dev->set_shutdown_temp(dev->data, \
-                                                       therm->temp_shutdown); \
-               } \
-               mutex_unlock(&tegra_therm_mutex); \
-               return 0; \
-       } \
-       static int tegra_thermal_##_name##_get(void *data, u64 *val) \
-       { \
-               *val = (u64)therm->_name; \
-               return 0; \
-       } \
-       DEFINE_SIMPLE_ATTRIBUTE(_name##_fops, \
-                               tegra_thermal_##_name##_get, \
-                               tegra_thermal_##_name##_set, \
-                               "%llu\n"); \
-       static int __init _name##_debug_init(void) \
-       { \
-               debugfs_create_file(#_name, 0644, thermal_debugfs_root, \
-                       NULL, &_name##_fops); \
-               return 0; \
-       } \
-       late_initcall(_name##_debug_init);
-
-
-TEGRA_THERM_DEBUGFS(temp_shutdown, shutdown_device_id, false, true);
-TEGRA_THERM_DEBUGFS(temp_throttle, throttle_edp_device_id, true, false);
-
 #define THERM_DEBUGFS(_name) \
        static int tegra_thermal_##_name##_set(void *data, u64 val) \
        { \
index 2d3f1fd..23c02ab 100644 (file)
@@ -255,7 +255,7 @@ int balanced_throttle_register(struct balanced_throttle *bthrot)
 
        mutex_lock(&bthrot_list_lock);
        list_for_each_entry(dev, &bthrot_list, node) {
-               if (dev->id == bthrot->id) {
+               if (dev->tegra_cdev.id == bthrot->tegra_cdev.id) {
                        mutex_unlock(&bthrot_list_lock);
                        return -EINVAL;
                }
@@ -276,7 +276,7 @@ int balanced_throttle_register(struct balanced_throttle *bthrot)
        }
 
 #ifdef CONFIG_DEBUG_FS
-       sprintf(name, "throttle_table%d", bthrot->id);
+       sprintf(name, "throttle_table%d", bthrot->tegra_cdev.id);
        debugfs_create_file(name,0644, throttle_debugfs_root,
                                bthrot, &table_fops);
 #endif