Fix kevent's childs priority greediness
[firewire-audio.git] / drivers / rtc / rtc-cmos.c
blob7c0d609100775148dfe6da456f6eee7af7755e96
1 /*
2 * RTC class driver for "CMOS RTC": PCs, ACPI, etc
4 * Copyright (C) 1996 Paul Gortmaker (drivers/char/rtc.c)
5 * Copyright (C) 2006 David Brownell (convert to new framework)
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version
10 * 2 of the License, or (at your option) any later version.
14 * The original "cmos clock" chip was an MC146818 chip, now obsolete.
15 * That defined the register interface now provided by all PCs, some
16 * non-PC systems, and incorporated into ACPI. Modern PC chipsets
17 * integrate an MC146818 clone in their southbridge, and boards use
18 * that instead of discrete clones like the DS12887 or M48T86. There
19 * are also clones that connect using the LPC bus.
21 * That register API is also used directly by various other drivers
22 * (notably for integrated NVRAM), infrastructure (x86 has code to
23 * bypass the RTC framework, directly reading the RTC during boot
24 * and updating minutes/seconds for systems using NTP synch) and
25 * utilities (like userspace 'hwclock', if no /dev node exists).
27 * So **ALL** calls to CMOS_READ and CMOS_WRITE must be done with
28 * interrupts disabled, holding the global rtc_lock, to exclude those
29 * other drivers and utilities on correctly configured systems.
31 #include <linux/kernel.h>
32 #include <linux/module.h>
33 #include <linux/init.h>
34 #include <linux/interrupt.h>
35 #include <linux/spinlock.h>
36 #include <linux/platform_device.h>
37 #include <linux/mod_devicetable.h>
39 /* this is for "generic access to PC-style RTC" using CMOS_READ/CMOS_WRITE */
40 #include <asm-generic/rtc.h>
43 struct cmos_rtc {
44 struct rtc_device *rtc;
45 struct device *dev;
46 int irq;
47 struct resource *iomem;
49 u8 suspend_ctrl;
51 /* newer hardware extends the original register set */
52 u8 day_alrm;
53 u8 mon_alrm;
54 u8 century;
57 /* both platform and pnp busses use negative numbers for invalid irqs */
58 #define is_valid_irq(n) ((n) >= 0)
60 static const char driver_name[] = "rtc_cmos";
62 /* The RTC_INTR register may have e.g. RTC_PF set even if RTC_PIE is clear;
63 * always mask it against the irq enable bits in RTC_CONTROL. Bit values
64 * are the same: PF==PIE, AF=AIE, UF=UIE; so RTC_IRQMASK works with both.
66 #define RTC_IRQMASK (RTC_PF | RTC_AF | RTC_UF)
68 static inline int is_intr(u8 rtc_intr)
70 if (!(rtc_intr & RTC_IRQF))
71 return 0;
72 return rtc_intr & RTC_IRQMASK;
75 /*----------------------------------------------------------------*/
77 static int cmos_read_time(struct device *dev, struct rtc_time *t)
79 /* REVISIT: if the clock has a "century" register, use
80 * that instead of the heuristic in get_rtc_time().
81 * That'll make Y3K compatility (year > 2070) easy!
83 get_rtc_time(t);
84 return 0;
87 static int cmos_set_time(struct device *dev, struct rtc_time *t)
89 /* REVISIT: set the "century" register if available
91 * NOTE: this ignores the issue whereby updating the seconds
92 * takes effect exactly 500ms after we write the register.
93 * (Also queueing and other delays before we get this far.)
95 return set_rtc_time(t);
98 static int cmos_read_alarm(struct device *dev, struct rtc_wkalrm *t)
100 struct cmos_rtc *cmos = dev_get_drvdata(dev);
101 unsigned char rtc_control;
103 if (!is_valid_irq(cmos->irq))
104 return -EIO;
106 /* Basic alarms only support hour, minute, and seconds fields.
107 * Some also support day and month, for alarms up to a year in
108 * the future.
110 t->time.tm_mday = -1;
111 t->time.tm_mon = -1;
113 spin_lock_irq(&rtc_lock);
114 t->time.tm_sec = CMOS_READ(RTC_SECONDS_ALARM);
115 t->time.tm_min = CMOS_READ(RTC_MINUTES_ALARM);
116 t->time.tm_hour = CMOS_READ(RTC_HOURS_ALARM);
118 if (cmos->day_alrm) {
119 t->time.tm_mday = CMOS_READ(cmos->day_alrm);
120 if (!t->time.tm_mday)
121 t->time.tm_mday = -1;
123 if (cmos->mon_alrm) {
124 t->time.tm_mon = CMOS_READ(cmos->mon_alrm);
125 if (!t->time.tm_mon)
126 t->time.tm_mon = -1;
130 rtc_control = CMOS_READ(RTC_CONTROL);
131 spin_unlock_irq(&rtc_lock);
133 /* REVISIT this assumes PC style usage: always BCD */
135 if (((unsigned)t->time.tm_sec) < 0x60)
136 t->time.tm_sec = BCD2BIN(t->time.tm_sec);
137 else
138 t->time.tm_sec = -1;
139 if (((unsigned)t->time.tm_min) < 0x60)
140 t->time.tm_min = BCD2BIN(t->time.tm_min);
141 else
142 t->time.tm_min = -1;
143 if (((unsigned)t->time.tm_hour) < 0x24)
144 t->time.tm_hour = BCD2BIN(t->time.tm_hour);
145 else
146 t->time.tm_hour = -1;
148 if (cmos->day_alrm) {
149 if (((unsigned)t->time.tm_mday) <= 0x31)
150 t->time.tm_mday = BCD2BIN(t->time.tm_mday);
151 else
152 t->time.tm_mday = -1;
153 if (cmos->mon_alrm) {
154 if (((unsigned)t->time.tm_mon) <= 0x12)
155 t->time.tm_mon = BCD2BIN(t->time.tm_mon) - 1;
156 else
157 t->time.tm_mon = -1;
160 t->time.tm_year = -1;
162 t->enabled = !!(rtc_control & RTC_AIE);
163 t->pending = 0;
165 return 0;
168 static int cmos_set_alarm(struct device *dev, struct rtc_wkalrm *t)
170 struct cmos_rtc *cmos = dev_get_drvdata(dev);
171 unsigned char mon, mday, hrs, min, sec;
172 unsigned char rtc_control, rtc_intr;
174 if (!is_valid_irq(cmos->irq))
175 return -EIO;
177 /* REVISIT this assumes PC style usage: always BCD */
179 /* Writing 0xff means "don't care" or "match all". */
181 mon = t->time.tm_mon;
182 mon = (mon < 12) ? BIN2BCD(mon) : 0xff;
183 mon++;
185 mday = t->time.tm_mday;
186 mday = (mday >= 1 && mday <= 31) ? BIN2BCD(mday) : 0xff;
188 hrs = t->time.tm_hour;
189 hrs = (hrs < 24) ? BIN2BCD(hrs) : 0xff;
191 min = t->time.tm_min;
192 min = (min < 60) ? BIN2BCD(min) : 0xff;
194 sec = t->time.tm_sec;
195 sec = (sec < 60) ? BIN2BCD(sec) : 0xff;
197 spin_lock_irq(&rtc_lock);
199 /* next rtc irq must not be from previous alarm setting */
200 rtc_control = CMOS_READ(RTC_CONTROL);
201 rtc_control &= ~RTC_AIE;
202 CMOS_WRITE(rtc_control, RTC_CONTROL);
203 rtc_intr = CMOS_READ(RTC_INTR_FLAGS);
204 rtc_intr &= (rtc_control & RTC_IRQMASK) | RTC_IRQF;
205 if (is_intr(rtc_intr))
206 rtc_update_irq(&cmos->rtc->class_dev, 1, rtc_intr);
208 /* update alarm */
209 CMOS_WRITE(hrs, RTC_HOURS_ALARM);
210 CMOS_WRITE(min, RTC_MINUTES_ALARM);
211 CMOS_WRITE(sec, RTC_SECONDS_ALARM);
213 /* the system may support an "enhanced" alarm */
214 if (cmos->day_alrm) {
215 CMOS_WRITE(mday, cmos->day_alrm);
216 if (cmos->mon_alrm)
217 CMOS_WRITE(mon, cmos->mon_alrm);
220 if (t->enabled) {
221 rtc_control |= RTC_AIE;
222 CMOS_WRITE(rtc_control, RTC_CONTROL);
223 rtc_intr = CMOS_READ(RTC_INTR_FLAGS);
224 rtc_intr &= (rtc_control & RTC_IRQMASK) | RTC_IRQF;
225 if (is_intr(rtc_intr))
226 rtc_update_irq(&cmos->rtc->class_dev, 1, rtc_intr);
229 spin_unlock_irq(&rtc_lock);
231 return 0;
234 static int cmos_set_freq(struct device *dev, int freq)
236 struct cmos_rtc *cmos = dev_get_drvdata(dev);
237 int f;
238 unsigned long flags;
240 if (!is_valid_irq(cmos->irq))
241 return -ENXIO;
243 /* 0 = no irqs; 1 = 2^15 Hz ... 15 = 2^0 Hz */
244 f = ffs(freq);
245 if (f != 0) {
246 if (f-- > 16 || freq != (1 << f))
247 return -EINVAL;
248 f = 16 - f;
251 spin_lock_irqsave(&rtc_lock, flags);
252 CMOS_WRITE(RTC_REF_CLCK_32KHZ | f, RTC_FREQ_SELECT);
253 spin_unlock_irqrestore(&rtc_lock, flags);
255 return 0;
258 #if defined(CONFIG_RTC_INTF_DEV) || defined(CONFIG_RTC_INTF_DEV_MODULE)
260 static int
261 cmos_rtc_ioctl(struct device *dev, unsigned int cmd, unsigned long arg)
263 struct cmos_rtc *cmos = dev_get_drvdata(dev);
264 unsigned char rtc_control, rtc_intr;
265 unsigned long flags;
267 switch (cmd) {
268 case RTC_AIE_OFF:
269 case RTC_AIE_ON:
270 case RTC_UIE_OFF:
271 case RTC_UIE_ON:
272 case RTC_PIE_OFF:
273 case RTC_PIE_ON:
274 if (!is_valid_irq(cmos->irq))
275 return -EINVAL;
276 break;
277 default:
278 return -ENOIOCTLCMD;
281 spin_lock_irqsave(&rtc_lock, flags);
282 rtc_control = CMOS_READ(RTC_CONTROL);
283 switch (cmd) {
284 case RTC_AIE_OFF: /* alarm off */
285 rtc_control &= ~RTC_AIE;
286 break;
287 case RTC_AIE_ON: /* alarm on */
288 rtc_control |= RTC_AIE;
289 break;
290 case RTC_UIE_OFF: /* update off */
291 rtc_control &= ~RTC_UIE;
292 break;
293 case RTC_UIE_ON: /* update on */
294 rtc_control |= RTC_UIE;
295 break;
296 case RTC_PIE_OFF: /* periodic off */
297 rtc_control &= ~RTC_PIE;
298 break;
299 case RTC_PIE_ON: /* periodic on */
300 rtc_control |= RTC_PIE;
301 break;
303 CMOS_WRITE(rtc_control, RTC_CONTROL);
304 rtc_intr = CMOS_READ(RTC_INTR_FLAGS);
305 rtc_intr &= (rtc_control & RTC_IRQMASK) | RTC_IRQF;
306 if (is_intr(rtc_intr))
307 rtc_update_irq(&cmos->rtc->class_dev, 1, rtc_intr);
308 spin_unlock_irqrestore(&rtc_lock, flags);
309 return 0;
312 #else
313 #define cmos_rtc_ioctl NULL
314 #endif
316 #if defined(CONFIG_RTC_INTF_PROC) || defined(CONFIG_RTC_INTF_PROC_MODULE)
318 static int cmos_procfs(struct device *dev, struct seq_file *seq)
320 struct cmos_rtc *cmos = dev_get_drvdata(dev);
321 unsigned char rtc_control, valid;
323 spin_lock_irq(&rtc_lock);
324 rtc_control = CMOS_READ(RTC_CONTROL);
325 valid = CMOS_READ(RTC_VALID);
326 spin_unlock_irq(&rtc_lock);
328 /* NOTE: at least ICH6 reports battery status using a different
329 * (non-RTC) bit; and SQWE is ignored on many current systems.
331 return seq_printf(seq,
332 "periodic_IRQ\t: %s\n"
333 "update_IRQ\t: %s\n"
334 // "square_wave\t: %s\n"
335 // "BCD\t\t: %s\n"
336 "DST_enable\t: %s\n"
337 "periodic_freq\t: %d\n"
338 "batt_status\t: %s\n",
339 (rtc_control & RTC_PIE) ? "yes" : "no",
340 (rtc_control & RTC_UIE) ? "yes" : "no",
341 // (rtc_control & RTC_SQWE) ? "yes" : "no",
342 // (rtc_control & RTC_DM_BINARY) ? "no" : "yes",
343 (rtc_control & RTC_DST_EN) ? "yes" : "no",
344 cmos->rtc->irq_freq,
345 (valid & RTC_VRT) ? "okay" : "dead");
348 #else
349 #define cmos_procfs NULL
350 #endif
352 static const struct rtc_class_ops cmos_rtc_ops = {
353 .ioctl = cmos_rtc_ioctl,
354 .read_time = cmos_read_time,
355 .set_time = cmos_set_time,
356 .read_alarm = cmos_read_alarm,
357 .set_alarm = cmos_set_alarm,
358 .proc = cmos_procfs,
359 .irq_set_freq = cmos_set_freq,
362 /*----------------------------------------------------------------*/
364 static struct cmos_rtc cmos_rtc;
366 static irqreturn_t cmos_interrupt(int irq, void *p)
368 u8 irqstat;
370 spin_lock(&rtc_lock);
371 irqstat = CMOS_READ(RTC_INTR_FLAGS);
372 irqstat &= (CMOS_READ(RTC_CONTROL) & RTC_IRQMASK) | RTC_IRQF;
373 spin_unlock(&rtc_lock);
375 if (is_intr(irqstat)) {
376 rtc_update_irq(p, 1, irqstat);
377 return IRQ_HANDLED;
378 } else
379 return IRQ_NONE;
382 #ifdef CONFIG_PNPACPI
383 #define is_pnpacpi() 1
384 #define INITSECTION
386 #else
387 #define is_pnpacpi() 0
388 #define INITSECTION __init
389 #endif
391 static int INITSECTION
392 cmos_do_probe(struct device *dev, struct resource *ports, int rtc_irq)
394 struct cmos_rtc_board_info *info = dev->platform_data;
395 int retval = 0;
396 unsigned char rtc_control;
398 /* there can be only one ... */
399 if (cmos_rtc.dev)
400 return -EBUSY;
402 if (!ports)
403 return -ENODEV;
405 cmos_rtc.irq = rtc_irq;
406 cmos_rtc.iomem = ports;
408 /* For ACPI systems the info comes from the FADT. On others,
409 * board specific setup provides it as appropriate.
411 if (info) {
412 cmos_rtc.day_alrm = info->rtc_day_alarm;
413 cmos_rtc.mon_alrm = info->rtc_mon_alarm;
414 cmos_rtc.century = info->rtc_century;
417 cmos_rtc.rtc = rtc_device_register(driver_name, dev,
418 &cmos_rtc_ops, THIS_MODULE);
419 if (IS_ERR(cmos_rtc.rtc))
420 return PTR_ERR(cmos_rtc.rtc);
422 cmos_rtc.dev = dev;
423 dev_set_drvdata(dev, &cmos_rtc);
425 /* platform and pnp busses handle resources incompatibly.
427 * REVISIT for non-x86 systems we may need to handle io memory
428 * resources: ioremap them, and request_mem_region().
430 if (is_pnpacpi()) {
431 retval = request_resource(&ioport_resource, ports);
432 if (retval < 0) {
433 dev_dbg(dev, "i/o registers already in use\n");
434 goto cleanup0;
437 rename_region(ports, cmos_rtc.rtc->class_dev.class_id);
439 spin_lock_irq(&rtc_lock);
441 /* force periodic irq to CMOS reset default of 1024Hz;
443 * REVISIT it's been reported that at least one x86_64 ALI mobo
444 * doesn't use 32KHz here ... for portability we might need to
445 * do something about other clock frequencies.
447 CMOS_WRITE(RTC_REF_CLCK_32KHZ | 0x06, RTC_FREQ_SELECT);
448 cmos_rtc.rtc->irq_freq = 1024;
450 /* disable irqs.
452 * NOTE after changing RTC_xIE bits we always read INTR_FLAGS;
453 * allegedly some older rtcs need that to handle irqs properly
455 rtc_control = CMOS_READ(RTC_CONTROL);
456 rtc_control &= ~(RTC_PIE | RTC_AIE | RTC_UIE);
457 CMOS_WRITE(rtc_control, RTC_CONTROL);
458 CMOS_READ(RTC_INTR_FLAGS);
460 spin_unlock_irq(&rtc_lock);
462 /* FIXME teach the alarm code how to handle binary mode;
463 * <asm-generic/rtc.h> doesn't know 12-hour mode either.
465 if (!(rtc_control & RTC_24H) || (rtc_control & (RTC_DM_BINARY))) {
466 dev_dbg(dev, "only 24-hr BCD mode supported\n");
467 retval = -ENXIO;
468 goto cleanup1;
471 if (is_valid_irq(rtc_irq))
472 retval = request_irq(rtc_irq, cmos_interrupt, IRQF_DISABLED,
473 cmos_rtc.rtc->class_dev.class_id,
474 &cmos_rtc.rtc->class_dev);
475 if (retval < 0) {
476 dev_dbg(dev, "IRQ %d is already in use\n", rtc_irq);
477 goto cleanup1;
480 /* REVISIT optionally make 50 or 114 bytes NVRAM available,
481 * like rtc-ds1553, rtc-ds1742 ... this will often include
482 * registers for century, and day/month alarm.
485 pr_info("%s: alarms up to one %s%s\n",
486 cmos_rtc.rtc->class_dev.class_id,
487 is_valid_irq(rtc_irq)
488 ? (cmos_rtc.mon_alrm
489 ? "year"
490 : (cmos_rtc.day_alrm
491 ? "month" : "day"))
492 : "no",
493 cmos_rtc.century ? ", y3k" : ""
496 return 0;
498 cleanup1:
499 rename_region(ports, NULL);
500 cleanup0:
501 rtc_device_unregister(cmos_rtc.rtc);
502 return retval;
505 static void cmos_do_shutdown(void)
507 unsigned char rtc_control;
509 spin_lock_irq(&rtc_lock);
510 rtc_control = CMOS_READ(RTC_CONTROL);
511 rtc_control &= ~(RTC_PIE|RTC_AIE|RTC_UIE);
512 CMOS_WRITE(rtc_control, RTC_CONTROL);
513 CMOS_READ(RTC_INTR_FLAGS);
514 spin_unlock_irq(&rtc_lock);
517 static void __exit cmos_do_remove(struct device *dev)
519 struct cmos_rtc *cmos = dev_get_drvdata(dev);
521 cmos_do_shutdown();
523 if (is_pnpacpi())
524 release_resource(cmos->iomem);
525 rename_region(cmos->iomem, NULL);
527 if (is_valid_irq(cmos->irq))
528 free_irq(cmos->irq, &cmos_rtc.rtc->class_dev);
530 rtc_device_unregister(cmos_rtc.rtc);
532 cmos_rtc.dev = NULL;
533 dev_set_drvdata(dev, NULL);
536 #ifdef CONFIG_PM
538 static int cmos_suspend(struct device *dev, pm_message_t mesg)
540 struct cmos_rtc *cmos = dev_get_drvdata(dev);
541 int do_wake = device_may_wakeup(dev);
542 unsigned char tmp;
544 /* only the alarm might be a wakeup event source */
545 spin_lock_irq(&rtc_lock);
546 cmos->suspend_ctrl = tmp = CMOS_READ(RTC_CONTROL);
547 if (tmp & (RTC_PIE|RTC_AIE|RTC_UIE)) {
548 unsigned char irqstat;
550 if (do_wake)
551 tmp &= ~(RTC_PIE|RTC_UIE);
552 else
553 tmp &= ~(RTC_PIE|RTC_AIE|RTC_UIE);
554 CMOS_WRITE(tmp, RTC_CONTROL);
555 irqstat = CMOS_READ(RTC_INTR_FLAGS);
556 irqstat &= (tmp & RTC_IRQMASK) | RTC_IRQF;
557 if (is_intr(irqstat))
558 rtc_update_irq(&cmos->rtc->class_dev, 1, irqstat);
560 spin_unlock_irq(&rtc_lock);
562 /* ACPI HOOK: enable ACPI_EVENT_RTC when (tmp & RTC_AIE)
563 * ... it'd be best if we could do that under rtc_lock.
566 pr_debug("%s: suspend%s, ctrl %02x\n",
567 cmos_rtc.rtc->class_dev.class_id,
568 (tmp & RTC_AIE) ? ", alarm may wake" : "",
569 tmp);
571 return 0;
574 static int cmos_resume(struct device *dev)
576 struct cmos_rtc *cmos = dev_get_drvdata(dev);
577 unsigned char tmp = cmos->suspend_ctrl;
579 /* REVISIT: a mechanism to resync the system clock (jiffies)
580 * on resume should be portable between platforms ...
583 /* re-enable any irqs previously active */
584 if (tmp & (RTC_PIE|RTC_AIE|RTC_UIE)) {
586 /* ACPI HOOK: disable ACPI_EVENT_RTC when (tmp & RTC_AIE) */
588 spin_lock_irq(&rtc_lock);
589 CMOS_WRITE(tmp, RTC_CONTROL);
590 tmp = CMOS_READ(RTC_INTR_FLAGS);
591 tmp &= (cmos->suspend_ctrl & RTC_IRQMASK) | RTC_IRQF;
592 if (is_intr(tmp))
593 rtc_update_irq(&cmos->rtc->class_dev, 1, tmp);
594 spin_unlock_irq(&rtc_lock);
597 pr_debug("%s: resume, ctrl %02x\n",
598 cmos_rtc.rtc->class_dev.class_id,
599 cmos->suspend_ctrl);
602 return 0;
605 #else
606 #define cmos_suspend NULL
607 #define cmos_resume NULL
608 #endif
610 /*----------------------------------------------------------------*/
612 /* The "CMOS" RTC normally lives on the platform_bus. On ACPI systems,
613 * the device node will always be created as a PNPACPI device.
616 #ifdef CONFIG_PNPACPI
618 #include <linux/pnp.h>
620 static int __devinit
621 cmos_pnp_probe(struct pnp_dev *pnp, const struct pnp_device_id *id)
623 /* REVISIT paranoia argues for a shutdown notifier, since PNP
624 * drivers can't provide shutdown() methods to disable IRQs.
625 * Or better yet, fix PNP to allow those methods...
627 return cmos_do_probe(&pnp->dev,
628 &pnp->res.port_resource[0],
629 pnp->res.irq_resource[0].start);
632 static void __exit cmos_pnp_remove(struct pnp_dev *pnp)
634 cmos_do_remove(&pnp->dev);
637 #ifdef CONFIG_PM
639 static int cmos_pnp_suspend(struct pnp_dev *pnp, pm_message_t mesg)
641 return cmos_suspend(&pnp->dev, mesg);
644 static int cmos_pnp_resume(struct pnp_dev *pnp)
646 return cmos_resume(&pnp->dev);
649 #else
650 #define cmos_pnp_suspend NULL
651 #define cmos_pnp_resume NULL
652 #endif
655 static const struct pnp_device_id rtc_ids[] = {
656 { .id = "PNP0b00", },
657 { .id = "PNP0b01", },
658 { .id = "PNP0b02", },
659 { },
661 MODULE_DEVICE_TABLE(pnp, rtc_ids);
663 static struct pnp_driver cmos_pnp_driver = {
664 .name = (char *) driver_name,
665 .id_table = rtc_ids,
666 .probe = cmos_pnp_probe,
667 .remove = __exit_p(cmos_pnp_remove),
669 /* flag ensures resume() gets called, and stops syslog spam */
670 .flags = PNP_DRIVER_RES_DO_NOT_CHANGE,
671 .suspend = cmos_pnp_suspend,
672 .resume = cmos_pnp_resume,
675 static int __init cmos_init(void)
677 return pnp_register_driver(&cmos_pnp_driver);
679 module_init(cmos_init);
681 static void __exit cmos_exit(void)
683 pnp_unregister_driver(&cmos_pnp_driver);
685 module_exit(cmos_exit);
687 #else /* no PNPACPI */
689 /*----------------------------------------------------------------*/
691 /* Platform setup should have set up an RTC device, when PNPACPI is
692 * unavailable ... this could happen even on (older) PCs.
695 static int __init cmos_platform_probe(struct platform_device *pdev)
697 return cmos_do_probe(&pdev->dev,
698 platform_get_resource(pdev, IORESOURCE_IO, 0),
699 platform_get_irq(pdev, 0));
702 static int __exit cmos_platform_remove(struct platform_device *pdev)
704 cmos_do_remove(&pdev->dev);
705 return 0;
708 static void cmos_platform_shutdown(struct platform_device *pdev)
710 cmos_do_shutdown();
713 static struct platform_driver cmos_platform_driver = {
714 .remove = __exit_p(cmos_platform_remove),
715 .shutdown = cmos_platform_shutdown,
716 .driver = {
717 .name = (char *) driver_name,
718 .suspend = cmos_suspend,
719 .resume = cmos_resume,
723 static int __init cmos_init(void)
725 return platform_driver_probe(&cmos_platform_driver,
726 cmos_platform_probe);
728 module_init(cmos_init);
730 static void __exit cmos_exit(void)
732 platform_driver_unregister(&cmos_platform_driver);
734 module_exit(cmos_exit);
737 #endif /* !PNPACPI */
739 MODULE_AUTHOR("David Brownell");
740 MODULE_DESCRIPTION("Driver for PC-style 'CMOS' RTCs");
741 MODULE_LICENSE("GPL");