From 8be727fa296bab8f352007142e0b3b51d8faff17 Mon Sep 17 00:00:00 2001 From: Alex Frid Date: Tue, 24 May 2011 19:02:16 -0700 Subject: ARM: tegra: power: Update CPU EDP initialization Do not overwrite thermal zone and preserve boot CPU rate settings if thermal sensor is initialized before edp governor. Original-Change-Id: Ia705d5f453003c204459f594ffb95152ff74145f Reviewed-on: http://git-master/r/32861 Tested-by: Aleksandr Frid Reviewed-by: Varun Wadekar Reviewed-by: Scott Williams Rebase-Id: Rfae7a16b2a93b9b294d8b70191c57a9a2e7374fc --- arch/arm/mach-tegra/cpu-tegra.c | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) (limited to 'arch/arm/mach-tegra/cpu-tegra.c') diff --git a/arch/arm/mach-tegra/cpu-tegra.c b/arch/arm/mach-tegra/cpu-tegra.c index 7b90dcb107f1..2680a304f079 100644 --- a/arch/arm/mach-tegra/cpu-tegra.c +++ b/arch/arm/mach-tegra/cpu-tegra.c @@ -197,13 +197,13 @@ static unsigned int edp_limit; static void edp_update_limit(void) { int i; - unsigned int limit; + unsigned int limit = cpumask_weight(&edp_cpumask); if (!cpu_edp_limits) return; - limit = cpu_edp_limits[edp_thermal_index].freq_limits[ - cpumask_weight(&edp_cpumask) - 1]; + BUG_ON((edp_thermal_index >= cpu_edp_limits_size) || (limit == 0)); + limit = cpu_edp_limits[edp_thermal_index].freq_limits[limit - 1]; for (i = 0; freq_table[i].frequency != CPUFREQ_TABLE_END; i++) { if (freq_table[i].frequency > limit) { @@ -247,13 +247,13 @@ int tegra_edp_update_thermal_zone(int temperature) } mutex_lock(&tegra_cpu_lock); - edp_thermal_index = index; - edp_update_limit(); - ret = tegra_cpu_cap_highest_speed(NULL); - if (ret) - pr_err("%s: update cpu speed fail(%d)", __func__, ret); + /* Update cpu rate if cpufreq (at least on cpu0) is already started */ + if (target_cpu_speed[0]) { + edp_update_limit(); + tegra_cpu_cap_highest_speed(NULL); + } mutex_unlock(&tegra_cpu_lock); return ret; @@ -291,6 +291,7 @@ static int tegra_cpu_edp_notify( mutex_lock(&tegra_cpu_lock); cpu_clear(cpu, edp_cpumask); edp_update_limit(); + tegra_cpu_cap_highest_speed(NULL); mutex_unlock(&tegra_cpu_lock); break; } @@ -305,18 +306,22 @@ static void tegra_cpu_edp_init(bool resume) { if (!cpu_edp_limits) { if (!resume) - pr_info("tegra CPU: no EDP table is provided\n"); + pr_info("cpu-tegra: no EDP table is provided\n"); return; } - edp_thermal_index = 0; + /* FIXME: use the highest temperature limits if sensor is not on-line? + * If thermal zone is not set yet by the sensor, edp_thermal_index = 0. + * Boot frequency allowed SoC to get here, should work till sensor is + * initialized. + */ edp_cpumask = *cpu_online_mask; edp_update_limit(); - if (!resume) + if (!resume) { register_hotcpu_notifier(&tegra_cpu_edp_notifier); - - pr_info("tegra CPU: set EDP limit %u MHz\n", edp_limit / 1000); + pr_info("cpu-tegra: init EDP limit: %u MHz\n", edp_limit/1000); + } } static void tegra_cpu_edp_exit(void) -- cgit v1.2.3