From 7783d907b43816ecc091f0bf17046ee6d2582477 Mon Sep 17 00:00:00 2001 From: "Vladimir A. Barinov" Date: Thu, 28 Jul 2005 03:59:27 -0700 Subject: [PATCH] [PATCH] ARM: OMAP: Restore system time after suspend/resume Add code to restore system time after suspend/resume. Signed-off-by: Vladimir A. Barinov Signed-off-by: Tony Lindgren --- drivers/char/omap-rtc.c | 45 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/drivers/char/omap-rtc.c b/drivers/char/omap-rtc.c index e2c06c7ebbe..36eedffd3b9 100644 --- a/drivers/char/omap-rtc.c +++ b/drivers/char/omap-rtc.c @@ -64,6 +64,8 @@ #include #include #include +#include +#include #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) -- 2.41.1