aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/rtc/rtc-omap.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/rtc/rtc-omap.c')
-rw-r--r--drivers/rtc/rtc-omap.c57
1 files changed, 6 insertions, 51 deletions
diff --git a/drivers/rtc/rtc-omap.c b/drivers/rtc/rtc-omap.c
index 9de8d67f4f8d..60a8a4bb8bd2 100644
--- a/drivers/rtc/rtc-omap.c
+++ b/drivers/rtc/rtc-omap.c
@@ -124,7 +124,7 @@ static void rtc_wait_not_busy(void)
124 /* now we have ~15 usec to read/write various registers */ 124 /* now we have ~15 usec to read/write various registers */
125} 125}
126 126
127static irqreturn_t rtc_irq(int irq, void *class_dev) 127static irqreturn_t rtc_irq(int irq, void *rtc)
128{ 128{
129 unsigned long events = 0; 129 unsigned long events = 0;
130 u8 irq_data; 130 u8 irq_data;
@@ -141,7 +141,7 @@ static irqreturn_t rtc_irq(int irq, void *class_dev)
141 if (irq_data & OMAP_RTC_STATUS_1S_EVENT) 141 if (irq_data & OMAP_RTC_STATUS_1S_EVENT)
142 events |= RTC_IRQF | RTC_UF; 142 events |= RTC_IRQF | RTC_UF;
143 143
144 rtc_update_irq(class_dev, 1, events); 144 rtc_update_irq(rtc, 1, events);
145 145
146 return IRQ_HANDLED; 146 return IRQ_HANDLED;
147} 147}
@@ -289,34 +289,6 @@ static int omap_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alm)
289{ 289{
290 u8 reg; 290 u8 reg;
291 291
292 /* Much userspace code uses RTC_ALM_SET, thus "don't care" for
293 * day/month/year specifies alarms up to 24 hours in the future.
294 * So we need to handle that ... but let's ignore the "don't care"
295 * values for hours/minutes/seconds.
296 */
297 if (alm->time.tm_mday <= 0
298 && alm->time.tm_mon < 0
299 && alm->time.tm_year < 0) {
300 struct rtc_time tm;
301 unsigned long now, then;
302
303 omap_rtc_read_time(dev, &tm);
304 rtc_tm_to_time(&tm, &now);
305
306 alm->time.tm_mday = tm.tm_mday;
307 alm->time.tm_mon = tm.tm_mon;
308 alm->time.tm_year = tm.tm_year;
309 rtc_tm_to_time(&alm->time, &then);
310
311 /* sometimes the alarm wraps into tomorrow */
312 if (then < now) {
313 rtc_time_to_tm(now + 24 * 60 * 60, &tm);
314 alm->time.tm_mday = tm.tm_mday;
315 alm->time.tm_mon = tm.tm_mon;
316 alm->time.tm_year = tm.tm_year;
317 }
318 }
319
320 if (tm2bcd(&alm->time) < 0) 292 if (tm2bcd(&alm->time) < 0)
321 return -EINVAL; 293 return -EINVAL;
322 294
@@ -399,7 +371,7 @@ static int __devinit omap_rtc_probe(struct platform_device *pdev)
399 goto fail; 371 goto fail;
400 } 372 }
401 platform_set_drvdata(pdev, rtc); 373 platform_set_drvdata(pdev, rtc);
402 class_set_devdata(&rtc->class_dev, mem); 374 dev_set_devdata(&rtc->dev, mem);
403 375
404 /* clear pending irqs, and set 1/second periodic, 376 /* clear pending irqs, and set 1/second periodic,
405 * which we'll use instead of update irqs 377 * which we'll use instead of update irqs
@@ -418,13 +390,13 @@ static int __devinit omap_rtc_probe(struct platform_device *pdev)
418 390
419 /* handle periodic and alarm irqs */ 391 /* handle periodic and alarm irqs */
420 if (request_irq(omap_rtc_timer, rtc_irq, IRQF_DISABLED, 392 if (request_irq(omap_rtc_timer, rtc_irq, IRQF_DISABLED,
421 rtc->class_dev.class_id, &rtc->class_dev)) { 393 rtc->dev.bus_id, rtc)) {
422 pr_debug("%s: RTC timer interrupt IRQ%d already claimed\n", 394 pr_debug("%s: RTC timer interrupt IRQ%d already claimed\n",
423 pdev->name, omap_rtc_timer); 395 pdev->name, omap_rtc_timer);
424 goto fail0; 396 goto fail0;
425 } 397 }
426 if (request_irq(omap_rtc_alarm, rtc_irq, IRQF_DISABLED, 398 if (request_irq(omap_rtc_alarm, rtc_irq, IRQF_DISABLED,
427 rtc->class_dev.class_id, &rtc->class_dev)) { 399 rtc->dev.bus_id, rtc)) {
428 pr_debug("%s: RTC alarm interrupt IRQ%d already claimed\n", 400 pr_debug("%s: RTC alarm interrupt IRQ%d already claimed\n",
429 pdev->name, omap_rtc_alarm); 401 pdev->name, omap_rtc_alarm);
430 goto fail1; 402 goto fail1;
@@ -481,26 +453,17 @@ static int __devexit omap_rtc_remove(struct platform_device *pdev)
481 free_irq(omap_rtc_timer, rtc); 453 free_irq(omap_rtc_timer, rtc);
482 free_irq(omap_rtc_alarm, rtc); 454 free_irq(omap_rtc_alarm, rtc);
483 455
484 release_resource(class_get_devdata(&rtc->class_dev)); 456 release_resource(dev_get_devdata(&rtc->dev));
485 rtc_device_unregister(rtc); 457 rtc_device_unregister(rtc);
486 return 0; 458 return 0;
487} 459}
488 460
489#ifdef CONFIG_PM 461#ifdef CONFIG_PM
490 462
491static struct timespec rtc_delta;
492static u8 irqstat; 463static u8 irqstat;
493 464
494static int omap_rtc_suspend(struct platform_device *pdev, pm_message_t state) 465static int omap_rtc_suspend(struct platform_device *pdev, pm_message_t state)
495{ 466{
496 struct rtc_time rtc_tm;
497 struct timespec time;
498
499 time.tv_nsec = 0;
500 omap_rtc_read_time(NULL, &rtc_tm);
501 rtc_tm_to_time(&rtc_tm, &time.tv_sec);
502
503 save_time_delta(&rtc_delta, &time);
504 irqstat = rtc_read(OMAP_RTC_INTERRUPTS_REG); 467 irqstat = rtc_read(OMAP_RTC_INTERRUPTS_REG);
505 468
506 /* FIXME the RTC alarm is not currently acting as a wakeup event 469 /* FIXME the RTC alarm is not currently acting as a wakeup event
@@ -517,14 +480,6 @@ static int omap_rtc_suspend(struct platform_device *pdev, pm_message_t state)
517 480
518static int omap_rtc_resume(struct platform_device *pdev) 481static int omap_rtc_resume(struct platform_device *pdev)
519{ 482{
520 struct rtc_time rtc_tm;
521 struct timespec time;
522
523 time.tv_nsec = 0;
524 omap_rtc_read_time(NULL, &rtc_tm);
525 rtc_tm_to_time(&rtc_tm, &time.tv_sec);
526
527 restore_time_delta(&rtc_delta, &time);
528 if (device_may_wakeup(&pdev->dev)) 483 if (device_may_wakeup(&pdev->dev))
529 disable_irq_wake(omap_rtc_alarm); 484 disable_irq_wake(omap_rtc_alarm);
530 else 485 else