ARM: tegra11: Include temperature offset to CPU EDP management
Diwakar Tundlam [Tue, 12 Feb 2013 19:55:09 +0000 (11:55 -0800)]
Fixed setting of DOWN threshold by adjusting hysteresis correctly for
precision. Made temperatures array be at 4 degree intervals above 70C
because of 2C rounding required for soctherm temperature thresholds.

Bug 1233302

Change-Id: I2dc0966fdc3ba81d6e29b8dd0095b165bf2ae7bc
Signed-off-by: Diwakar Tundlam <dtundlam@nvidia.com>
Reviewed-on: http://git-master/r/200216
(cherry picked from commit 33b146ef361242ba1d6752f7de3bfde49056896b)
Reviewed-on: http://git-master/r/201983
Reviewed-by: Mrutyunjay Sawant <msawant@nvidia.com>
Tested-by: Mrutyunjay Sawant <msawant@nvidia.com>

arch/arm/mach-tegra/board-dalmore-power.c
arch/arm/mach-tegra/board-pismo-power.c
arch/arm/mach-tegra/board-pluto-power.c
arch/arm/mach-tegra/board-roth-sensors.c
arch/arm/mach-tegra/edp.c
arch/arm/mach-tegra/include/mach/edp.h
arch/arm/mach-tegra/tegra11_soctherm.c

index fb720b8..0baeceb 100644 (file)
@@ -1258,7 +1258,8 @@ int __init dalmore_soctherm_init(void)
                dalmore_soctherm_data.tshut_pmu_trip_data = &tpdata_max77663;
 
        tegra_platform_edp_init(dalmore_soctherm_data.therm[THERM_CPU].trips,
-                       &dalmore_soctherm_data.therm[THERM_CPU].num_trips);
+                       &dalmore_soctherm_data.therm[THERM_CPU].num_trips,
+                       8000); /* edp temperature margin */
        tegra_add_tj_trips(dalmore_soctherm_data.therm[THERM_CPU].trips,
                        &dalmore_soctherm_data.therm[THERM_CPU].num_trips);
 
index 6b6a1d9..2bd4012 100644 (file)
@@ -880,7 +880,8 @@ static struct soctherm_platform_data pismo_soctherm_data = {
 int __init pismo_soctherm_init(void)
 {
        tegra_platform_edp_init(pismo_soctherm_data.therm[THERM_CPU].trips,
-                       &pismo_soctherm_data.therm[THERM_CPU].num_trips);
+                       &pismo_soctherm_data.therm[THERM_CPU].num_trips,
+                       8000); /* edp temperature margin */
        tegra_add_tj_trips(pismo_soctherm_data.therm[THERM_CPU].trips,
                        &pismo_soctherm_data.therm[THERM_CPU].num_trips);
 
index 52ab0dd..9fcad37 100644 (file)
@@ -783,7 +783,8 @@ static struct soctherm_platform_data pluto_soctherm_data = {
 int __init pluto_soctherm_init(void)
 {
        tegra_platform_edp_init(pluto_soctherm_data.therm[THERM_CPU].trips,
-                       &pluto_soctherm_data.therm[THERM_CPU].num_trips);
+                       &pluto_soctherm_data.therm[THERM_CPU].num_trips,
+                       8000);  /* edp temperature margin */
        tegra_add_tj_trips(pluto_soctherm_data.therm[THERM_CPU].trips,
                        &pluto_soctherm_data.therm[THERM_CPU].num_trips);
 
index 0ede5ec..e5b7855 100644 (file)
@@ -227,7 +227,8 @@ static int roth_nct1008_init(void)
        int ret = 0;
 
        tegra_platform_edp_init(roth_nct1008_pdata.trips,
-                               &roth_nct1008_pdata.num_trips);
+                               &roth_nct1008_pdata.num_trips,
+                               0); /* edp temperature margin */
        tegra_add_cdev_trips(roth_nct1008_pdata.trips,
                                &roth_nct1008_pdata.num_trips);
        tegra_add_tj_trips(roth_nct1008_pdata.trips,
index f789d8b..3ceebe7 100644 (file)
@@ -333,7 +333,7 @@ static struct tegra_system_edp_entry power_edp_default_limits[] = {
 
 /* Constants for EDP calculations */
 static const int temperatures[] = { /* degree celcius (C) */
-       23, 40, 50, 60, 70, 75, 80, 85, 90, 95, 100, 105,
+       23, 40, 50, 60, 70, 74, 78, 82, 86, 90, 94, 98, 102,
 };
 static const int power_cap_levels[] = { /* milliwatts (mW) */
        500, 1000, 1500, 2000, 2500, 3000, 3500,
@@ -626,7 +626,7 @@ static int init_cpu_edp_limits_calculated(void)
        for (n_cores_idx = 0; n_cores_idx < NR_CPUS; n_cores_idx++) {
                for (temp_idx = 0;
                     temp_idx < ARRAY_SIZE(temperatures); temp_idx++) {
-                       edp_calculated_limits[temp_idx]. temperature =
+                       edp_calculated_limits[temp_idx].temperature =
                                temperatures[temp_idx];
                        limit = edp_calculate_maxf(params,
                                                   temperatures[temp_idx],
@@ -831,7 +831,8 @@ void tegra_get_system_edp_limits(const unsigned int **limits)
        *limits = system_edp_limits;
 }
 
-void tegra_platform_edp_init(struct thermal_trip_info *trips, int *num_trips)
+void tegra_platform_edp_init(struct thermal_trip_info *trips,
+                               int *num_trips, int margin)
 {
        const struct tegra_edp_limits *cpu_edp_limits;
        struct thermal_trip_info *trip_state;
@@ -851,7 +852,7 @@ void tegra_platform_edp_init(struct thermal_trip_info *trips, int *num_trips)
 
                trip_state->cdev_type = "cpu_edp";
                trip_state->trip_temp =
-                       cpu_edp_limits[i].temperature * 1000;
+                       (cpu_edp_limits[i].temperature * 1000) - margin;
                trip_state->trip_type = THERMAL_TRIP_ACTIVE;
                trip_state->upper = trip_state->lower = i + 1;
                trip_state->hysteresis = 1000;
index e2560a2..988eb0d 100644 (file)
@@ -85,7 +85,8 @@ void tegra_get_cpu_edp_limits(const struct tegra_edp_limits **limits, int *size)
 unsigned int tegra_get_edp_limit(int *get_edp_thermal_index);
 void tegra_get_system_edp_limits(const unsigned int **limits);
 int tegra_system_edp_alarm(bool alarm);
-void tegra_platform_edp_init(struct thermal_trip_info *trips, int *num_trips);
+void tegra_platform_edp_init(struct thermal_trip_info *trips,
+                                       int *num_trips, int margin);
 struct tegra_system_edp_entry *tegra_get_system_edp_entries(int *size);
 #else
 static inline struct thermal_cooling_device *edp_cooling_device_create(
@@ -107,7 +108,7 @@ static inline void tegra_get_system_edp_limits(unsigned int **limits)
 static inline int tegra_system_edp_alarm(bool alarm)
 { return -1; }
 static inline void tegra_platform_edp_init(struct thermal_trip_info *trips,
-                                          int *num_trips)
+                                          int *num_trips, int margin)
 {}
 static inline struct tegra_system_edp_entry
                *tegra_get_system_edp_entries(int *size) { return NULL; }
index b5af9d8..d04dd77 100644 (file)
@@ -552,7 +552,7 @@ static inline void prog_hw_threshold(struct thermal_trip_info *trip_state,
 
        trip_state->hysteresis = trip_state->hysteresis ?:
                LOWER_PRECISION_FOR_CONV(1000);
-       trip_temp -= (trip_state->hysteresis / 1000);
+       trip_temp -= LOWER_PRECISION_FOR_TEMP(trip_state->hysteresis / 1000);
 
        r = REG_SET(r, CTL_LVL0_CPU0_DN_THRESH, trip_temp);
        r = REG_SET(r, CTL_LVL0_CPU0_EN, 1);