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
DW: Add export.h include
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 86ba81f..8fec3e3 100644 (file)
@@ -141,6 +141,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 240540b..058bdcd 100644 (file)
@@ -27,6 +27,7 @@
 #include <linux/clk.h>
 #include <linux/io.h>
 #include <linux/syscore_ops.h>
+#include <linux/export.h>
 
 #include <asm/mach/time.h>
 #include <asm/delay.h>
@@ -286,3 +287,18 @@ void __init tegra_init_timer(void)
        arm_delay_ops.const_udelay      = __tegra_const_udelay;
        arm_delay_ops.udelay            = __tegra_udelay;
 }
+
+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;
+}