RTC: Initialize kernel state from RTC
[deliverable/linux.git] / drivers / rtc / class.c
index e6539cbabb35fb8f143f1710a004744fa1abe745..09b4437b3e616aa57cdfec861b2b2ddf0ff9dd59 100644 (file)
@@ -16,6 +16,7 @@
 #include <linux/kdev_t.h>
 #include <linux/idr.h>
 #include <linux/slab.h>
+#include <linux/workqueue.h>
 
 #include "rtc-core.h"
 
@@ -116,6 +117,7 @@ struct rtc_device *rtc_device_register(const char *name, struct device *dev,
                                        struct module *owner)
 {
        struct rtc_device *rtc;
+       struct rtc_wkalrm alrm;
        int id, err;
 
        if (idr_pre_get(&rtc_idr, GFP_KERNEL) == 0) {
@@ -142,6 +144,7 @@ struct rtc_device *rtc_device_register(const char *name, struct device *dev,
        rtc->id = id;
        rtc->ops = ops;
        rtc->owner = owner;
+       rtc->irq_freq = 1;
        rtc->max_user_freq = 64;
        rtc->dev.parent = dev;
        rtc->dev.class = rtc_class;
@@ -152,6 +155,24 @@ struct rtc_device *rtc_device_register(const char *name, struct device *dev,
        spin_lock_init(&rtc->irq_task_lock);
        init_waitqueue_head(&rtc->irq_queue);
 
+       /* Init timerqueue */
+       timerqueue_init_head(&rtc->timerqueue);
+       INIT_WORK(&rtc->irqwork, rtc_timer_do_work);
+       /* Init aie timer */
+       rtc_timer_init(&rtc->aie_timer, rtc_aie_update_irq, (void *)rtc);
+       /* Init uie timer */
+       rtc_timer_init(&rtc->uie_rtctimer, rtc_uie_update_irq, (void *)rtc);
+       /* Init pie timer */
+       hrtimer_init(&rtc->pie_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
+       rtc->pie_timer.function = rtc_pie_update_irq;
+       rtc->pie_enabled = 0;
+
+       /* Check to see if there is an ALARM already set in hw */
+       err = __rtc_read_alarm(rtc, &alrm);
+
+       if (!err && !rtc_valid_tm(&alrm.time))
+               rtc_set_alarm(rtc, &alrm);
+
        strlcpy(rtc->name, name, RTC_DEVICE_NAME_SIZE);
        dev_set_name(&rtc->dev, "rtc%d", id);
 
This page took 0.024737 seconds and 5 git commands to generate.