]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
[PATCH] ARM: OMAP: Restore system time after suspend/resume
authorVladimir A. Barinov <vbarinov@ru.mvista.com>
Thu, 28 Jul 2005 10:59:27 +0000 (03:59 -0700)
committerTony Lindgren <tony@atomide.com>
Thu, 28 Jul 2005 10:59:27 +0000 (03:59 -0700)
Add code to restore system time after suspend/resume.

Signed-off-by: Vladimir A. Barinov <vbarinov@ru.mvista.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>
drivers/char/omap-rtc.c

index e2c06c7ebbe13dd56c4bb49e50125089bbe04739..36eedffd3b94b09b18aa685f55e4c4c5abdece85 100644 (file)
@@ -64,6 +64,8 @@
 #include <asm/system.h>
 #include <asm/hardware.h>
 #include <asm/irq.h>
+#include <asm/rtc.h>
+#include <asm/mach/time.h>
 
 #include "omap-rtc.h"
 
@@ -704,11 +706,54 @@ static void set_rtc_irq_bit(unsigned char bit)
        spin_unlock_irq(&rtc_lock);
 }
 
+#ifdef CONFIG_PM
+static struct timespec rtc_delta;
+
+static int rtc_suspend(struct device *dev, u32 state, u32 level)
+{
+       struct rtc_time rtc_tm;
+       struct timespec time;
+
+       if (level == SUSPEND_POWER_DOWN)
+       {
+               time.tv_nsec = 0;
+               get_rtc_time(&rtc_tm);
+               rtc_tm_to_time(&rtc_tm, &time.tv_sec);
+
+               save_time_delta(&rtc_delta, &time);
+       }
+
+       return 0;
+}
+
+static int rtc_resume(struct device *dev, u32 level)
+{
+       struct rtc_time rtc_tm;
+       struct timespec time;
+
+       if (level == RESUME_POWER_ON)
+       {
+               time.tv_nsec = 0;
+               get_rtc_time(&rtc_tm);
+               rtc_tm_to_time(&rtc_tm, &time.tv_sec);
+
+               restore_time_delta(&rtc_delta, &time);
+       }
+
+       return 0;
+}
+#else
+#define rtc_suspend NULL
+#define rtc_resume  NULL
+#endif
+
 static struct device_driver omap_rtc_driver = {
        .name           = "omap_rtc",
        .bus            = &platform_bus_type,
        .probe          = omap_rtc_probe,
        .remove         = __exit_p(omap_rtc_remove),
+       .suspend        = rtc_suspend,
+       .resume         = rtc_resume,
 };
 
 static int __init rtc_init(void)