diff options
author | Colin Cross <ccross@android.com> | 2010-10-24 16:11:03 -0700 |
---|---|---|
committer | Colin Cross <ccross@android.com> | 2010-10-25 18:46:20 -0700 |
commit | 0ecadc39ae92523ede4100d93a7242d13565e8df (patch) | |
tree | 5192a726f132889fd2f86c9785df97cd9d56556f /arch/arm/mach-tegra/timer.c | |
parent | 683a9ff2dfd1a050f1b6db75e1b7955869a2e158 (diff) |
ARM: tegra: timer: Fix us timer time after resume from LP1
In LP1 suspend, or during a failed LP0 suspend, the core power is
not turned off and the timer register is not reset. Saving the
timer value during suspend and adding it to the offset after resume
will cause the timer value to double for each suspend cycle.
To fix, when resuming subtract the current value of the timer
register from the offset. Also, use the rtc registers to add
the time that passed during suspend.
Change-Id: I9f7ee2089b98cf66af45271f8478fbd9eb2ee250
Signed-off-by: Colin Cross <ccross@android.com>
Diffstat (limited to 'arch/arm/mach-tegra/timer.c')
-rw-r--r-- | arch/arm/mach-tegra/timer.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/arch/arm/mach-tegra/timer.c b/arch/arm/mach-tegra/timer.c index 72dc904813b2..dff49f201c7a 100644 --- a/arch/arm/mach-tegra/timer.c +++ b/arch/arm/mach-tegra/timer.c @@ -37,6 +37,7 @@ #include "board.h" #include "clock.h" +#include "power.h" #define RTC_SECONDS 0x08 #define RTC_SHADOW_SECONDS 0x0c @@ -104,12 +105,15 @@ static cycle_t tegra_clocksource_us_read(struct clocksource *cs) void tegra_clocksource_us_suspend(struct clocksource *cs) { - tegra_us_resume_offset = tegra_clocksource_us_read(cs); + tegra_us_resume_offset = tegra_clocksource_us_read(cs) - + tegra_rtc_read_ms() * 1000; } void tegra_clocksource_us_resume(struct clocksource *cs) { - tegra_us_clocksource_offset = tegra_us_resume_offset; + tegra_us_clocksource_offset += tegra_us_resume_offset + + tegra_rtc_read_ms() * 1000 - + tegra_clocksource_us_read(cs); } static struct clock_event_device tegra_clockevent = { |