rtc: rtc interfaces don't use class_device
[linux-2.6.git] / drivers / rtc / rtc-at91rm9200.c
index 5c8addc..2f06b5f 100644 (file)
@@ -33,6 +33,8 @@
 
 #include <asm/mach/time.h>
 
+#include <asm/arch/at91_rtc.h>
+
 
 #define AT91_RTC_FREQ          1
 #define AT91_RTC_EPOCH         1900UL  /* just like arch/arm/common/rtctime.c */
@@ -137,6 +139,9 @@ static int at91_rtc_readalarm(struct device *dev, struct rtc_wkalrm *alrm)
        tm->tm_yday = rtc_year_days(tm->tm_mday, tm->tm_mon, tm->tm_year);
        tm->tm_year = at91_alarm_year - 1900;
 
+       alrm->enabled = (at91_sys_read(AT91_RTC_IMR) & AT91_RTC_ALARM)
+                       ? 1 : 0;
+
        pr_debug("%s(): %4d-%02d-%02d %02d:%02d:%02d\n", __FUNCTION__,
                1900 + tm->tm_year, tm->tm_mon, tm->tm_mday,
                tm->tm_hour, tm->tm_min, tm->tm_sec);
@@ -159,6 +164,7 @@ static int at91_rtc_setalarm(struct device *dev, struct rtc_wkalrm *alrm)
        tm.tm_min = alrm->time.tm_min;
        tm.tm_sec = alrm->time.tm_sec;
 
+       at91_sys_write(AT91_RTC_IDR, AT91_RTC_ALARM);
        at91_sys_write(AT91_RTC_TIMALR,
                  BIN2BCD(tm.tm_sec) << 0
                | BIN2BCD(tm.tm_min) << 8
@@ -169,6 +175,9 @@ static int at91_rtc_setalarm(struct device *dev, struct rtc_wkalrm *alrm)
                | BIN2BCD(tm.tm_mday) << 24
                | AT91_RTC_DATEEN | AT91_RTC_MTHEN);
 
+       if (alrm->enabled)
+               at91_sys_write(AT91_RTC_IER, AT91_RTC_ALARM);
+
        pr_debug("%s(): %4d-%02d-%02d %02d:%02d:%02d\n", __FUNCTION__,
                at91_alarm_year, tm.tm_mon, tm.tm_mday, tm.tm_hour,
                tm.tm_min, tm.tm_sec);
@@ -223,8 +232,6 @@ static int at91_rtc_proc(struct device *dev, struct seq_file *seq)
 {
        unsigned long imr = at91_sys_read(AT91_RTC_IMR);
 
-       seq_printf(seq, "alarm_IRQ\t: %s\n",
-                       (imr & AT91_RTC_ALARM) ? "yes" : "no");
        seq_printf(seq, "update_IRQ\t: %s\n",
                        (imr & AT91_RTC_ACKUPD) ? "yes" : "no");
        seq_printf(seq, "periodic_IRQ\t: %s\n",
@@ -256,7 +263,7 @@ static irqreturn_t at91_rtc_interrupt(int irq, void *dev_id)
 
                at91_sys_write(AT91_RTC_SCCR, rtsr);    /* clear status reg */
 
-               rtc_update_irq(&rtc->class_dev, 1, events);
+               rtc_update_irq(rtc, 1, events);
 
                pr_debug("%s(): num=%ld, events=0x%02lx\n", __FUNCTION__,
                        events >> 8, events & 0x000000FF);
@@ -300,6 +307,12 @@ static int __init at91_rtc_probe(struct platform_device *pdev)
                return ret;
        }
 
+       /* cpu init code should really have flagged this device as
+        * being wake-capable; if it didn't, do that here.
+        */
+       if (!device_can_wakeup(&pdev->dev))
+               device_init_wakeup(&pdev->dev, 1);
+
        rtc = rtc_device_register(pdev->name, &pdev->dev,
                                &at91_rtc_ops, THIS_MODULE);
        if (IS_ERR(rtc)) {
@@ -307,7 +320,6 @@ static int __init at91_rtc_probe(struct platform_device *pdev)
                return PTR_ERR(rtc);
        }
        platform_set_drvdata(pdev, rtc);
-       device_init_wakeup(&pdev->dev, 1);
 
        printk(KERN_INFO "AT91 Real Time Clock driver.\n");
        return 0;
@@ -316,7 +328,7 @@ static int __init at91_rtc_probe(struct platform_device *pdev)
 /*
  * Disable and remove the RTC driver
  */
-static int __devexit at91_rtc_remove(struct platform_device *pdev)
+static int __exit at91_rtc_remove(struct platform_device *pdev)
 {
        struct rtc_device *rtc = platform_get_drvdata(pdev);
 
@@ -328,7 +340,6 @@ static int __devexit at91_rtc_remove(struct platform_device *pdev)
 
        rtc_device_unregister(rtc);
        platform_set_drvdata(pdev, NULL);
-       device_init_wakeup(&pdev->dev, 0);
 
        return 0;
 }
@@ -401,8 +412,7 @@ static int at91_rtc_resume(struct platform_device *pdev)
 #endif
 
 static struct platform_driver at91_rtc_driver = {
-       .probe          = at91_rtc_probe,
-       .remove         = at91_rtc_remove,
+       .remove         = __exit_p(at91_rtc_remove),
        .suspend        = at91_rtc_suspend,
        .resume         = at91_rtc_resume,
        .driver         = {
@@ -413,7 +423,7 @@ static struct platform_driver at91_rtc_driver = {
 
 static int __init at91_rtc_init(void)
 {
-       return platform_driver_register(&at91_rtc_driver);
+       return platform_driver_probe(&at91_rtc_driver, at91_rtc_probe);
 }
 
 static void __exit at91_rtc_exit(void)