ARM: tegra: soctherm: Fix many soctherm instances
Joshua Primero [Wed, 31 Oct 2012 01:19:03 +0000 (18:19 -0700)]
Fixed the bug where there were multiple soctherm instances
being initialized.

bug 1169070

Signed-off-by: Joshua Primero <jprimero@nvidia.com>
Change-Id: I99dfa0d884c028dd5876652ae638fa0c2358dda6
Reviewed-on: http://git-master/r/160087
Reviewed-by: Simone Willett <swillett@nvidia.com>
Tested-by: Simone Willett <swillett@nvidia.com>

arch/arm/mach-tegra/board-dalmore-power.c
arch/arm/mach-tegra/board-dalmore.c
arch/arm/mach-tegra/board-dalmore.h
arch/arm/mach-tegra/board-pluto-power.c
arch/arm/mach-tegra/board-pluto.c
arch/arm/mach-tegra/board-pluto.h
arch/arm/mach-tegra/tegra11_soctherm.c

index 1a35943..9e7fa81 100644 (file)
@@ -1233,27 +1233,7 @@ static struct soctherm_platform_data dalmore_soctherm_data = {
        },
 };
 
-static struct balanced_throttle tj_throttle = {
-       .throt_tab_size = 10,
-       .throt_tab = {
-               {      0, 1000 },
-               { 640000, 1000 },
-               { 640000, 1000 },
-               { 640000, 1000 },
-               { 640000, 1000 },
-               { 640000, 1000 },
-               { 760000, 1000 },
-               { 760000, 1050 },
-               {1000000, 1050 },
-               {1000000, 1100 },
-       },
-};
-
-static int __init dalmore_soctherm_init(void)
+int __init dalmore_soctherm_init(void)
 {
-       dalmore_soctherm_data.therm[THERM_CPU].cdev =
-                       balanced_throttle_register(&tj_throttle);
-
        return tegra11_soctherm_init(&dalmore_soctherm_data);
 }
-module_init(dalmore_soctherm_init);
index 6711a9f..0bf681c 100644 (file)
@@ -708,6 +708,7 @@ static void __init tegra_dalmore_init(void)
 #endif
        tegra_serial_debug_init(TEGRA_UARTD_BASE, INT_WDT_CPU, NULL, -1, -1);
        dalmore_sensors_init();
+       dalmore_soctherm_init();
 }
 
 static void __init dalmore_ramconsole_reserve(unsigned long size)
index 5b8af00..ac071b6 100644 (file)
@@ -110,5 +110,6 @@ int dalmore_edp_init(void);
 int dalmore_panel_init(void);
 int dalmore_kbc_init(void);
 int dalmore_pmon_init(void);
+int dalmore_soctherm_init(void);
 
 #endif
index 96ca4e4..8637f09 100644 (file)
@@ -794,27 +794,7 @@ static struct soctherm_platform_data pluto_soctherm_data = {
        },
 };
 
-static struct balanced_throttle tj_throttle = {
-       .throt_tab_size = 10,
-       .throt_tab = {
-               {      0, 1000 },
-               { 640000, 1000 },
-               { 640000, 1000 },
-               { 640000, 1000 },
-               { 640000, 1000 },
-               { 640000, 1000 },
-               { 760000, 1000 },
-               { 760000, 1050 },
-               {1000000, 1050 },
-               {1000000, 1100 },
-       },
-};
-
-static int __init pluto_soctherm_init(void)
+int __init pluto_soctherm_init(void)
 {
-       pluto_soctherm_data.therm[THERM_CPU].cdev =
-                       balanced_throttle_register(&tj_throttle);
-
        return tegra11_soctherm_init(&pluto_soctherm_data);
 }
-module_init(pluto_soctherm_init);
index 0e9ffa3..fe94b12 100644 (file)
@@ -869,6 +869,7 @@ static void __init tegra_pluto_init(void)
 #endif
        pluto_sensors_init();
        tegra_serial_debug_init(TEGRA_UARTD_BASE, INT_WDT_CPU, NULL, -1, -1);
+       pluto_soctherm_init();
 }
 
 static void __init pluto_ramconsole_reserve(unsigned long size)
index a61e2f6..b616d56 100644 (file)
@@ -104,6 +104,7 @@ int pluto_panel_init(void);
 int pluto_kbc_init(void);
 int pluto_baseband_init(void);
 int pluto_pmon_init(void);
+int pluto_soctherm_init(void);
 
 /* PCA954x I2C bus expander bus addresses */
 #define PCA954x_I2C_BUS_BASE   5
index 0582798..26ceb2c 100644 (file)
@@ -442,6 +442,45 @@ static struct thermal_zone_device_ops soctherm_ops = {
        .get_trip_temp = soctherm_get_trip_temp,
        .set_trip_temp = soctherm_set_trip_temp,
 };
+
+static int __init soctherm_thermal_init(void)
+{
+       char name[64];
+       int i;
+
+#if 0
+       for (i = 0; i < TSENSE_SIZE; i++) {
+               if (plat_data.sensor_data[i].enable) {
+                       /* Let's avoid this for now */
+                       sprintf(name, "%s-tsensor", sensor_names[i]);
+                       /* Create a thermal zone device for each sensor */
+                       thermal_zone_device_register(
+                                       name,
+                                       0,
+                                       0,
+                                       (void *)i,
+                                       &soctherm_ops,
+                                       0, 0, 0, 0);
+               }
+       }
+#endif
+
+       for (i = 0; i < THERM_SIZE; i++) {
+               sprintf(name, "%s-therm", therm_names[i]);
+               thz[i] = thermal_zone_device_register(
+                                       name,
+                                       plat_data.therm[i].cdev ? 1 : 0,
+                                       plat_data.therm[i].cdev ? 0x1 : 0,
+                                       (void *)TSENSE_SIZE + i,
+                                       &soctherm_ops,
+                                       plat_data.therm[i].passive_delay,
+                                       0);
+       }
+
+       return 0;
+}
+module_init(soctherm_thermal_init);
+
 #else
 static void soctherm_update(void)
 {
@@ -574,7 +613,6 @@ int __init tegra11_soctherm_init(struct soctherm_platform_data *data)
        int err, i;
        u32 r;
        u32 reg_off;
-       char name[64];
        struct soctherm_therm *therm;
 
        memcpy(&plat_data, data, sizeof(struct soctherm_platform_data));
@@ -589,25 +627,9 @@ int __init tegra11_soctherm_init(struct soctherm_platform_data *data)
                BUG();
 
        /* Thermal Sensing programming */
-       for (i = 0; i < TSENSE_SIZE; i++) {
-               if (plat_data.sensor_data[i].enable) {
+       for (i = 0; i < TSENSE_SIZE; i++)
+               if (plat_data.sensor_data[i].enable)
                        soctherm_tsense_program(i, &plat_data.sensor_data[i]);
-                       sprintf(name, "%s-tsensor", sensor_names[i]);
-#ifdef CONFIG_THERMAL
-/* Let's avoid this for now */
-#if 0
-                       /* Create a thermal zone device for each sensor */
-                       thermal_zone_device_register(
-                                       name,
-                                       0,
-                                       0,
-                                       (void *)i,
-                                       &soctherm_ops,
-                                       0, 0, 0, 0);
-#endif
-#endif
-               }
-       }
 
        /* Pdiv */
        r = soctherm_readl(TS_PDIV);
@@ -618,17 +640,6 @@ int __init tegra11_soctherm_init(struct soctherm_platform_data *data)
        soctherm_writel(r, TS_PDIV);
 
        for (i = 0; i < THERM_SIZE; i++) {
-#ifdef CONFIG_THERMAL
-               sprintf(name, "%s-therm", therm_names[i]);
-               thz[i] = thermal_zone_device_register(
-                                       name,
-                                       data->therm[i].cdev ? 1 : 0,
-                                       data->therm[i].cdev ? 0x1 : 0,
-                                       (void *)TSENSE_SIZE + i,
-                                       &soctherm_ops,
-                                       data->therm[i].passive_delay,
-                                       0);
-#endif
                if (data->therm[i].hw_backstop) {
                        reg_off = CTL_LVL_CPU0(1) + i * 4;
                        r = soctherm_readl(reg_off);
@@ -685,6 +696,7 @@ int __init tegra11_soctherm_init(struct soctherm_platform_data *data)
        return 0;
 }
 
+
 #ifdef CONFIG_DEBUG_FS
 static int cpu0_show(struct seq_file *s, void *data)
 {