From be98d35b06c52310e8a5cdb22f0ba454c30313c2 Mon Sep 17 00:00:00 2001 From: Alex Frid Date: Wed, 28 Sep 2011 22:42:06 -0700 Subject: ARM: tegra: power: Update Tegra3 LP2 time prediction Use local timer count to predict time to be spent by secondary CPU in LP2 state instead of scheduler timing. This is more accurate, as local timer wakes CPU after counts down to zero. Change-Id: I28fe6c3153e1c527abf4cf66b556d64516582a35 Reviewed-on: http://git-master/r/55629 Reviewed-by: Aleksandr Frid Tested-by: Aleksandr Frid Reviewed-by: Scott Williams Reviewed-by: Yu-Huan Hsu Reviewed-by: Antti Miettinen Rebase-Id: R577246dfe6bce06bf7a1f87d0ab488322d98b631 --- arch/arm/mach-tegra/cpuidle-t3.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'arch/arm/mach-tegra/cpuidle-t3.c') diff --git a/arch/arm/mach-tegra/cpuidle-t3.c b/arch/arm/mach-tegra/cpuidle-t3.c index e8e552c7717c..8ef8ed45e8bd 100644 --- a/arch/arm/mach-tegra/cpuidle-t3.c +++ b/arch/arm/mach-tegra/cpuidle-t3.c @@ -37,6 +37,7 @@ #include #include #include +#include #include #include @@ -67,6 +68,7 @@ static s64 tegra_cpu_wake_by_time[4] = { #endif static struct clk *cpu_clk_for_dvfs; +static struct clk *twd_clk; static struct { unsigned int cpu_ready_count[5]; @@ -268,6 +270,17 @@ static void tegra3_idle_enter_lp2_cpu_n(struct cpuidle_device *dev, struct cpuidle_state *state, s64 request) { #ifdef CONFIG_SMP + + u32 twd_cnt; + u32 twd_ctrl = readl(twd_base + TWD_TIMER_CONTROL); + unsigned long twd_rate = clk_get_rate(twd_clk); + + if ((twd_ctrl & TWD_TIMER_CONTROL_ENABLE) && + (twd_ctrl & TWD_TIMER_CONTROL_IT_ENABLE)) { + twd_cnt = readl(twd_base + TWD_TIMER_COUNTER); + request = div_u64((u64)twd_cnt * 1000000, twd_rate); + } + if (request < tegra_lp2_exit_latency) { /* * Not enough time left to enter LP2 @@ -307,9 +320,10 @@ void tegra3_idle_lp2(struct cpuidle_device *dev, tegra_clear_cpu_in_lp2(dev->cpu); } -int tegra_cpudile_init_soc(void) +int tegra3_cpudile_init_soc(void) { cpu_clk_for_dvfs = tegra_get_clock_by_name("cpu_g"); + twd_clk = tegra_get_clock_by_name("twd"); return 0; } -- cgit v1.2.3