Lines Matching +full:power +full:- +full:off +full:- +full:time +full:- +full:sec
2 * rtc-mrst.c: Driver for Moorestown virtual RTC
19 * This driver is based upon drivers/rtc/rtc-cmos.c
27 * * Alarm function is also limited to hr/min/sec.
41 #include <asm/intel-mid.h>
78 * driver chose to use 1972 (1970 is UNIX time start point) as the base,
79 * and does the translation at read/write time.
82 * make it consistent in leap year setting for both vrtc and low-level
85 * year will be parsed as 1960 which is not a valid UNIX time and will
88 static int mrst_read_time(struct device *dev, struct rtc_time *time) in mrst_read_time() argument
96 time->tm_sec = vrtc_cmos_read(RTC_SECONDS); in mrst_read_time()
97 time->tm_min = vrtc_cmos_read(RTC_MINUTES); in mrst_read_time()
98 time->tm_hour = vrtc_cmos_read(RTC_HOURS); in mrst_read_time()
99 time->tm_mday = vrtc_cmos_read(RTC_DAY_OF_MONTH); in mrst_read_time()
100 time->tm_mon = vrtc_cmos_read(RTC_MONTH); in mrst_read_time()
101 time->tm_year = vrtc_cmos_read(RTC_YEAR); in mrst_read_time()
105 time->tm_year += 72; in mrst_read_time()
106 time->tm_mon--; in mrst_read_time()
110 static int mrst_set_time(struct device *dev, struct rtc_time *time) in mrst_set_time() argument
114 unsigned char mon, day, hrs, min, sec; in mrst_set_time() local
117 yrs = time->tm_year; in mrst_set_time()
118 mon = time->tm_mon + 1; /* tm_mon starts at zero */ in mrst_set_time()
119 day = time->tm_mday; in mrst_set_time()
120 hrs = time->tm_hour; in mrst_set_time()
121 min = time->tm_min; in mrst_set_time()
122 sec = time->tm_sec; in mrst_set_time()
125 return -EINVAL; in mrst_set_time()
126 yrs -= 72; in mrst_set_time()
135 vrtc_cmos_write(sec, RTC_SECONDS); in mrst_set_time()
148 if (mrst->irq <= 0) in mrst_read_alarm()
149 return -EIO; in mrst_read_alarm()
153 t->time.tm_sec = vrtc_cmos_read(RTC_SECONDS_ALARM); in mrst_read_alarm()
154 t->time.tm_min = vrtc_cmos_read(RTC_MINUTES_ALARM); in mrst_read_alarm()
155 t->time.tm_hour = vrtc_cmos_read(RTC_HOURS_ALARM); in mrst_read_alarm()
160 t->enabled = !!(rtc_control & RTC_AIE); in mrst_read_alarm()
161 t->pending = 0; in mrst_read_alarm()
177 rtc_update_irq(mrst->rtc, 1, rtc_intr); in mrst_checkintr()
210 unsigned char hrs, min, sec; in mrst_set_alarm() local
213 if (!mrst->irq) in mrst_set_alarm()
214 return -EIO; in mrst_set_alarm()
216 hrs = t->time.tm_hour; in mrst_set_alarm()
217 min = t->time.tm_min; in mrst_set_alarm()
218 sec = t->time.tm_sec; in mrst_set_alarm()
227 vrtc_cmos_write(sec, RTC_SECONDS_ALARM); in mrst_set_alarm()
236 if (t->enabled) in mrst_set_alarm()
244 /* Currently, the vRTC doesn't support UIE ON/OFF */
276 (rtc_control & RTC_PIE) ? "on" : "off", in mrst_procfs()
277 (rtc_control & RTC_AIE) ? "on" : "off"); in mrst_procfs()
326 return -EBUSY; in vrtc_mrst_do_probe()
329 return -ENODEV; in vrtc_mrst_do_probe()
331 iomem = devm_request_mem_region(dev, iomem->start, resource_size(iomem), in vrtc_mrst_do_probe()
335 return -EBUSY; in vrtc_mrst_do_probe()
346 mrst_rtc.rtc->ops = &mrst_rtc_ops; in vrtc_mrst_do_probe()
348 rename_region(iomem, dev_name(&mrst_rtc.rtc->dev)); in vrtc_mrst_do_probe()
356 dev_dbg(dev, "TODO: support more than 24-hr BCD mode\n"); in vrtc_mrst_do_probe()
360 0, dev_name(&mrst_rtc.rtc->dev), in vrtc_mrst_do_probe()
378 dev_err(dev, "rtc-mrst: unable to initialise\n"); in vrtc_mrst_do_probe()
395 mrst->rtc = NULL; in rtc_mrst_do_remove()
396 mrst->dev = NULL; in rtc_mrst_do_remove()
407 mrst->suspend_ctrl = tmp = vrtc_cmos_read(RTC_CONTROL); in mrst_suspend()
423 mrst->enabled_wake = 1; in mrst_suspend()
424 enable_irq_wake(mrst->irq); in mrst_suspend()
427 dev_dbg(&mrst_rtc.rtc->dev, "suspend%s, ctrl %02x\n", in mrst_suspend()
435 * We want RTC alarms to wake us from the deep power saving state
445 unsigned char tmp = mrst->suspend_ctrl; in mrst_resume()
447 /* Re-enable any irqs previously active */ in mrst_resume()
451 if (mrst->enabled_wake) { in mrst_resume()
452 disable_irq_wake(mrst->irq); in mrst_resume()
453 mrst->enabled_wake = 0; in mrst_resume()
465 rtc_update_irq(mrst->rtc, 1, mask); in mrst_resume()
471 dev_dbg(&mrst_rtc.rtc->dev, "resume, ctrl %02x\n", tmp); in mrst_resume()
484 return -ENOSYS; in mrst_poweroff()
491 return vrtc_mrst_do_probe(&pdev->dev, in vrtc_mrst_platform_probe()
498 rtc_mrst_do_remove(&pdev->dev); in vrtc_mrst_platform_remove()
504 if (system_state == SYSTEM_POWER_OFF && !mrst_poweroff(&pdev->dev)) in vrtc_mrst_platform_shutdown()