clocksource: tegra210: save/restore timer config
Prashant Gaikwad [Mon, 12 May 2014 09:17:20 +0000 (14:17 +0530)]
Timer USEC configuration need to be saved before SC7 entry
and restore after SC7 exit.

Bug 1488026

Change-Id: I6323faa831917674d148b548f765a4090f9e8caf
Signed-off-by: Prashant Gaikwad <pgaikwad@nvidia.com>
Reviewed-on: http://git-master/r/408095
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Antti Miettinen <amiettinen@nvidia.com>
Reviewed-by: Bharat Nihalani <bnihalani@nvidia.com>

drivers/clocksource/tegra210_timer.c

index 3501314..a25d454 100644 (file)
 #include <linux/of_address.h>
 #include <linux/of_irq.h>
 #include <linux/percpu.h>
+#include <linux/syscore_ops.h>
 
 static u32 tegra210_timer_freq;
 static void __iomem *tegra210_timer_reg_base;
 phys_addr_t timer_reg_base_pa = 0x60005000;
+static u32 usec_config;
 
 #define TIMERUS_CNTR_1US 0x10
 #define TIMERUS_USEC_CFG 0x14
@@ -155,6 +157,24 @@ u32 notrace tegra_read_usec_raw(void)
        return __raw_readl(tegra210_timer_reg_base + TIMERUS_CNTR_1US);
 }
 
+static int tegra_timer_suspend(void)
+{
+       usec_config = __raw_readl(tegra210_timer_reg_base + TIMERUS_USEC_CFG);
+       return 0;
+}
+
+static void tegra_timer_resume(void)
+{
+       __raw_writel(usec_config, tegra210_timer_reg_base + TIMERUS_USEC_CFG);
+}
+
+static struct syscore_ops tegra_timer_syscore_ops = {
+       .suspend = tegra_timer_suspend,
+       .resume = tegra_timer_resume,
+       .save = tegra_timer_suspend,
+       .restore = tegra_timer_resume,
+};
+
 static void __init tegra210_timer_init(struct device_node *np)
 {
        int cpu;
@@ -237,6 +257,8 @@ static void __init tegra210_timer_init(struct device_node *np)
                BUG();
        }
 
+       register_syscore_ops(&tegra_timer_syscore_ops);
+
        of_node_put(np);
 }