diff options
author | David Brownell <david-b@pacbell.net> | 2006-10-01 02:28:17 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-10-01 03:39:25 -0400 |
commit | 90b4d648f02a653b192be7f0feb0a933b7525e6a (patch) | |
tree | b3a99a94f4b5f494776cd0d341040f20d55faeb0 /drivers/rtc | |
parent | ff8371ac9a5a55c956991fed8e5f58640c7a32f3 (diff) |
[PATCH] AT91rm9200 RTC can issue system wakeup events
This lets the at91rm9200 RTC alarm be a system wakeup irq, according to the
setting of /sys/devices/platform/at91_rtc/power/wakeup. User code can set the
alarm, put the system into a low power mode, and then rely on it waking up no
later than the specified moment.
Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Cc: Alessandro Zummo <a.zummo@towertech.it>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers/rtc')
-rw-r--r-- | drivers/rtc/rtc-at91.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/drivers/rtc/rtc-at91.c b/drivers/rtc/rtc-at91.c index 3cf3529888c7..c0714da44920 100644 --- a/drivers/rtc/rtc-at91.c +++ b/drivers/rtc/rtc-at91.c | |||
@@ -307,6 +307,7 @@ static int __init at91_rtc_probe(struct platform_device *pdev) | |||
307 | return PTR_ERR(rtc); | 307 | return PTR_ERR(rtc); |
308 | } | 308 | } |
309 | platform_set_drvdata(pdev, rtc); | 309 | platform_set_drvdata(pdev, rtc); |
310 | device_init_wakeup(&pdev->dev, 1); | ||
310 | 311 | ||
311 | printk(KERN_INFO "AT91 Real Time Clock driver.\n"); | 312 | printk(KERN_INFO "AT91 Real Time Clock driver.\n"); |
312 | return 0; | 313 | return 0; |
@@ -327,6 +328,7 @@ static int __devexit at91_rtc_remove(struct platform_device *pdev) | |||
327 | 328 | ||
328 | rtc_device_unregister(rtc); | 329 | rtc_device_unregister(rtc); |
329 | platform_set_drvdata(pdev, NULL); | 330 | platform_set_drvdata(pdev, NULL); |
331 | device_init_wakeup(&pdev->dev, 0); | ||
330 | 332 | ||
331 | return 0; | 333 | return 0; |
332 | } | 334 | } |
@@ -336,6 +338,7 @@ static int __devexit at91_rtc_remove(struct platform_device *pdev) | |||
336 | /* AT91RM9200 RTC Power management control */ | 338 | /* AT91RM9200 RTC Power management control */ |
337 | 339 | ||
338 | static struct timespec at91_rtc_delta; | 340 | static struct timespec at91_rtc_delta; |
341 | static u32 at91_rtc_imr; | ||
339 | 342 | ||
340 | static int at91_rtc_suspend(struct platform_device *pdev, pm_message_t state) | 343 | static int at91_rtc_suspend(struct platform_device *pdev, pm_message_t state) |
341 | { | 344 | { |
@@ -349,6 +352,18 @@ static int at91_rtc_suspend(struct platform_device *pdev, pm_message_t state) | |||
349 | rtc_tm_to_time(&tm, &time.tv_sec); | 352 | rtc_tm_to_time(&tm, &time.tv_sec); |
350 | save_time_delta(&at91_rtc_delta, &time); | 353 | save_time_delta(&at91_rtc_delta, &time); |
351 | 354 | ||
355 | /* this IRQ is shared with DBGU and other hardware which isn't | ||
356 | * necessarily doing PM like we are... | ||
357 | */ | ||
358 | at91_rtc_imr = at91_sys_read(AT91_RTC_IMR) | ||
359 | & (AT91_RTC_ALARM|AT91_RTC_SECEV); | ||
360 | if (at91_rtc_imr) { | ||
361 | if (device_may_wakeup(&pdev->dev)) | ||
362 | enable_irq_wake(AT91_ID_SYS); | ||
363 | else | ||
364 | at91_sys_write(AT91_RTC_IDR, at91_rtc_imr); | ||
365 | } | ||
366 | |||
352 | pr_debug("%s(): %4d-%02d-%02d %02d:%02d:%02d\n", __FUNCTION__, | 367 | pr_debug("%s(): %4d-%02d-%02d %02d:%02d:%02d\n", __FUNCTION__, |
353 | 1900 + tm.tm_year, tm.tm_mon, tm.tm_mday, | 368 | 1900 + tm.tm_year, tm.tm_mon, tm.tm_mday, |
354 | tm.tm_hour, tm.tm_min, tm.tm_sec); | 369 | tm.tm_hour, tm.tm_min, tm.tm_sec); |
@@ -367,6 +382,13 @@ static int at91_rtc_resume(struct platform_device *pdev) | |||
367 | rtc_tm_to_time(&tm, &time.tv_sec); | 382 | rtc_tm_to_time(&tm, &time.tv_sec); |
368 | restore_time_delta(&at91_rtc_delta, &time); | 383 | restore_time_delta(&at91_rtc_delta, &time); |
369 | 384 | ||
385 | if (at91_rtc_imr) { | ||
386 | if (device_may_wakeup(&pdev->dev)) | ||
387 | disable_irq_wake(AT91_ID_SYS); | ||
388 | else | ||
389 | at91_sys_write(AT91_RTC_IER, at91_rtc_imr); | ||
390 | } | ||
391 | |||
370 | pr_debug("%s(): %4d-%02d-%02d %02d:%02d:%02d\n", __FUNCTION__, | 392 | pr_debug("%s(): %4d-%02d-%02d %02d:%02d:%02d\n", __FUNCTION__, |
371 | 1900 + tm.tm_year, tm.tm_mon, tm.tm_mday, | 393 | 1900 + tm.tm_year, tm.tm_mon, tm.tm_mday, |
372 | tm.tm_hour, tm.tm_min, tm.tm_sec); | 394 | tm.tm_hour, tm.tm_min, tm.tm_sec); |