ARM: tegra2: Add LP2 Timers
Scott Williams [Tue, 19 Jul 2011 00:42:46 +0000 (17:42 -0700)]
Restore the Tegra2 LP2 timers that were dropped in the port to Linux
2.6.39.

Change-Id: Ie3958fa3c89886d5dc5a5858c694400bd1421741
Signed-off-by: Scott Williams <scwilliams@nvidia.com>
DW: Split into logical changes
Signed-off-by: Dan Willemsen <dwillemsen@nvidia.com>

Rebase-Id: R63ede668965d11ac2b2114ffa817b690a616205a

arch/arm/mach-tegra/pm.h
arch/arm/mach-tegra/timer-t2.c

index 8729f12..9617fcd 100644 (file)
@@ -148,6 +148,25 @@ void tegra_lp0_suspend_mc(void);
 void tegra_lp0_resume_mc(void);
 #endif
 
+#ifdef CONFIG_ARCH_TEGRA_2x_SOC
+void tegra2_lp2_set_trigger(unsigned long cycles);
+unsigned long tegra2_lp2_timer_remain(void);
+#endif
+
+static inline void tegra_lp2_set_trigger(unsigned long cycles)
+{
+#ifdef CONFIG_ARCH_TEGRA_2x_SOC
+       tegra2_lp2_set_trigger(cycles);
+#endif
+}
+
+static inline unsigned long tegra_lp2_timer_remain(void)
+{
+#ifdef CONFIG_ARCH_TEGRA_2x_SOC
+       return tegra2_lp2_timer_remain();
+#endif
+}
+
 #if DEBUG_CLUSTER_SWITCH
 extern unsigned int tegra_cluster_debug;
 #define DEBUG_CLUSTER(x) do { if (tegra_cluster_debug) printk x; } while (0)
index 00550ae..0ee51b6 100644 (file)
@@ -283,3 +283,18 @@ static void __init tegra_init_timer(void)
 struct sys_timer tegra_timer = {
        .init = tegra_init_timer,
 };
+
+void tegra2_lp2_set_trigger(unsigned long cycles)
+{
+       timer_writel(0, TIMER4_OFFSET + TIMER_PTV);
+       if (cycles) {
+               u32 reg = 0x80000000ul | min(0x1ffffffful, cycles);
+               timer_writel(reg, TIMER4_OFFSET + TIMER_PTV);
+       }
+}
+EXPORT_SYMBOL(tegra2_lp2_set_trigger);
+
+unsigned long tegra2_lp2_timer_remain(void)
+{
+       return timer_readl(TIMER4_OFFSET + TIMER_PCR) & 0x1ffffffful;
+}