]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - sitara-epos/sitara-epos-kernel.git/blobdiff - arch/arm/mach-omap2/timer.c
ARM: OMAP2+: sys_timer: Add suspend/resume callback api's to sys_timer
[sitara-epos/sitara-epos-kernel.git] / arch / arm / mach-omap2 / timer.c
index e49fc7be2229badcd274038b7a308ce6def8c478..d2169c5f3b6821bf5887c0c2d5d96a6a68b1e9b4 100644 (file)
@@ -41,7 +41,7 @@
 #include <plat/dmtimer.h>
 #include <asm/localtimer.h>
 #include <asm/sched_clock.h>
-#include <plat/common.h>
+#include "common.h"
 #include <plat/omap_hwmod.h>
 #include <plat/omap_device.h>
 #include <plat/omap-pm.h>
@@ -155,6 +155,7 @@ static int __init omap_dm_timer_init_one(struct omap_dm_timer *timer,
                return -ENODEV;
 
        timer->irq = oh->mpu_irqs[0].irq;
+       timer->id = gptimer_id;
        timer->phys_base = oh->slaves[0]->addr->pa_start;
        size = oh->slaves[0]->addr->pa_end - timer->phys_base;
 
@@ -178,7 +179,7 @@ static int __init omap_dm_timer_init_one(struct omap_dm_timer *timer,
 
        omap_hwmod_enable(oh);
 
-       sys_timer_reserved |= (1 << (gptimer_id - 1));
+       sys_timer_reserved |= (1 << (gptimer_id));
 
        if (gptimer_id != 12) {
                struct clk *src;
@@ -309,6 +310,35 @@ static void __init omap2_gp_clocksource_init(int gptimer_id,
 }
 #endif
 
+static void omap_dmtimer_resume(void)
+{
+       char name[10];
+       struct omap_hwmod *oh;
+
+       sprintf(name, "timer%d", clkev.id);
+       oh = omap_hwmod_lookup(name);
+       if (!oh)
+               return;
+
+       omap_hwmod_enable(oh);
+       __omap_dm_timer_load_start(&clkev,
+                       OMAP_TIMER_CTRL_ST | OMAP_TIMER_CTRL_AR, 0, 1);
+       __omap_dm_timer_int_enable(&clkev, OMAP_TIMER_INT_OVERFLOW);
+}
+
+static void omap_dmtimer_suspend(void)
+{
+       char name[10];
+       struct omap_hwmod *oh;
+
+       sprintf(name, "timer%d", clkev.id);
+       oh = omap_hwmod_lookup(name);
+       if (!oh)
+               return;
+
+       omap_hwmod_idle(oh);
+}
+
 #define OMAP_SYS_TIMER_INIT(name, clkev_nr, clkev_src,                 \
                                clksrc_nr, clksrc_src)                  \
 static void __init omap##name##_timer_init(void)                       \
@@ -319,7 +349,9 @@ static void __init omap##name##_timer_init(void)                    \
 
 #define OMAP_SYS_TIMER(name)                                           \
 struct sys_timer omap##name##_timer = {                                        \
-       .init   = omap##name##_timer_init,                              \
+       .init           = omap##name##_timer_init,                      \
+       .suspend        = omap_dmtimer_suspend,                         \
+       .resume         = omap_dmtimer_resume,                          \
 };
 
 #ifdef CONFIG_ARCH_OMAP2
@@ -333,6 +365,8 @@ OMAP_SYS_TIMER(3)
 OMAP_SYS_TIMER_INIT(3_secure, OMAP3_SECURE_TIMER, OMAP3_CLKEV_SOURCE,
                        2, OMAP3_MPU_SOURCE)
 OMAP_SYS_TIMER(3_secure)
+OMAP_SYS_TIMER_INIT(3_am33xx, 2, OMAP4_MPU_SOURCE, 1, OMAP4_MPU_SOURCE)
+OMAP_SYS_TIMER(3_am33xx)
 #endif
 
 #ifdef CONFIG_ARCH_OMAP4
@@ -408,14 +442,6 @@ static int omap2_dm_timer_set_src(struct platform_device *pdev, int source)
        return ret;
 }
 
-struct omap_device_pm_latency omap2_dmtimer_latency[] = {
-       {
-               .deactivate_func = omap_device_idle_hwmods,
-               .activate_func   = omap_device_enable_hwmods,
-               .flags = OMAP_DEVICE_LATENCY_AUTO_ADJUST,
-       },
-};
-
 /**
  * omap_timer_init - build and register timer device with an
  * associated timer hwmod
@@ -468,7 +494,7 @@ static int __init omap_timer_init(struct omap_hwmod *oh, void *unused)
        pdata->timer_ip_version = oh->class->rev;
 
        /* Mark clocksource and clockevent timers as reserved */
-       if ((sys_timer_reserved >> (id - 1)) & 0x1)
+       if ((sys_timer_reserved & (0x1 << id)))
                pdata->reserved = 1;
 
        pwrdm = omap_hwmod_get_pwrdm(oh);
@@ -477,9 +503,7 @@ static int __init omap_timer_init(struct omap_hwmod *oh, void *unused)
        pdata->get_context_loss_count = omap_pm_get_dev_context_loss_count;
 #endif
        pdev = omap_device_build(name, id, oh, pdata, sizeof(*pdata),
-                       omap2_dmtimer_latency,
-                       ARRAY_SIZE(omap2_dmtimer_latency),
-                       0);
+                                NULL, 0, 0);
 
        if (IS_ERR(pdev)) {
                pr_err("%s: Can't build omap_device for %s: %s.\n",