diff options
Diffstat (limited to 'drivers/rtc')
58 files changed, 999 insertions, 712 deletions
diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig index 3a125b835546..8c8377d50c4c 100644 --- a/drivers/rtc/Kconfig +++ b/drivers/rtc/Kconfig | |||
@@ -554,6 +554,13 @@ config RTC_DRV_DS1742 | |||
554 | This driver can also be built as a module. If so, the module | 554 | This driver can also be built as a module. If so, the module |
555 | will be called rtc-ds1742. | 555 | will be called rtc-ds1742. |
556 | 556 | ||
557 | config RTC_DRV_DA9052 | ||
558 | tristate "Dialog DA9052/DA9053 RTC" | ||
559 | depends on PMIC_DA9052 | ||
560 | help | ||
561 | Say y here to support the RTC driver for Dialog Semiconductor | ||
562 | DA9052-BC and DA9053-AA/Bx PMICs. | ||
563 | |||
557 | config RTC_DRV_EFI | 564 | config RTC_DRV_EFI |
558 | tristate "EFI RTC" | 565 | tristate "EFI RTC" |
559 | depends on IA64 | 566 | depends on IA64 |
@@ -748,7 +755,7 @@ config HAVE_S3C_RTC | |||
748 | 755 | ||
749 | config RTC_DRV_S3C | 756 | config RTC_DRV_S3C |
750 | tristate "Samsung S3C series SoC RTC" | 757 | tristate "Samsung S3C series SoC RTC" |
751 | depends on ARCH_S3C2410 || ARCH_S3C64XX || HAVE_S3C_RTC | 758 | depends on ARCH_S3C64XX || HAVE_S3C_RTC |
752 | help | 759 | help |
753 | RTC (Realtime Clock) driver for the clock inbuilt into the | 760 | RTC (Realtime Clock) driver for the clock inbuilt into the |
754 | Samsung S3C24XX series of SoCs. This can provide periodic | 761 | Samsung S3C24XX series of SoCs. This can provide periodic |
@@ -773,8 +780,8 @@ config RTC_DRV_EP93XX | |||
773 | will be called rtc-ep93xx. | 780 | will be called rtc-ep93xx. |
774 | 781 | ||
775 | config RTC_DRV_SA1100 | 782 | config RTC_DRV_SA1100 |
776 | tristate "SA11x0/PXA2xx" | 783 | tristate "SA11x0/PXA2xx/PXA910" |
777 | depends on ARCH_SA1100 || ARCH_PXA | 784 | depends on ARCH_SA1100 || ARCH_PXA || ARCH_MMP |
778 | help | 785 | help |
779 | If you say Y here you will get access to the real time clock | 786 | If you say Y here you will get access to the real time clock |
780 | built into your SA11x0 or PXA2xx CPU. | 787 | built into your SA11x0 or PXA2xx CPU. |
@@ -1070,4 +1077,14 @@ config RTC_DRV_PUV3 | |||
1070 | This drive can also be built as a module. If so, the module | 1077 | This drive can also be built as a module. If so, the module |
1071 | will be called rtc-puv3. | 1078 | will be called rtc-puv3. |
1072 | 1079 | ||
1080 | config RTC_DRV_LOONGSON1 | ||
1081 | tristate "loongson1 RTC support" | ||
1082 | depends on MACH_LOONGSON1 | ||
1083 | help | ||
1084 | This is a driver for the loongson1 on-chip Counter0 (Time-Of-Year | ||
1085 | counter) to be used as a RTC. | ||
1086 | |||
1087 | This driver can also be built as a module. If so, the module | ||
1088 | will be called rtc-ls1x. | ||
1089 | |||
1073 | endif # RTC_CLASS | 1090 | endif # RTC_CLASS |
diff --git a/drivers/rtc/Makefile b/drivers/rtc/Makefile index 6e6982335c10..727ae7786e6c 100644 --- a/drivers/rtc/Makefile +++ b/drivers/rtc/Makefile | |||
@@ -27,6 +27,7 @@ obj-$(CONFIG_RTC_DRV_BQ32K) += rtc-bq32k.o | |||
27 | obj-$(CONFIG_RTC_DRV_BQ4802) += rtc-bq4802.o | 27 | obj-$(CONFIG_RTC_DRV_BQ4802) += rtc-bq4802.o |
28 | obj-$(CONFIG_RTC_DRV_CMOS) += rtc-cmos.o | 28 | obj-$(CONFIG_RTC_DRV_CMOS) += rtc-cmos.o |
29 | obj-$(CONFIG_RTC_DRV_COH901331) += rtc-coh901331.o | 29 | obj-$(CONFIG_RTC_DRV_COH901331) += rtc-coh901331.o |
30 | obj-$(CONFIG_RTC_DRV_DA9052) += rtc-da9052.o | ||
30 | obj-$(CONFIG_RTC_DRV_DAVINCI) += rtc-davinci.o | 31 | obj-$(CONFIG_RTC_DRV_DAVINCI) += rtc-davinci.o |
31 | obj-$(CONFIG_RTC_DRV_DM355EVM) += rtc-dm355evm.o | 32 | obj-$(CONFIG_RTC_DRV_DM355EVM) += rtc-dm355evm.o |
32 | obj-$(CONFIG_RTC_DRV_VRTC) += rtc-mrst.o | 33 | obj-$(CONFIG_RTC_DRV_VRTC) += rtc-mrst.o |
@@ -53,6 +54,7 @@ obj-$(CONFIG_RTC_DRV_ISL1208) += rtc-isl1208.o | |||
53 | obj-$(CONFIG_RTC_DRV_ISL12022) += rtc-isl12022.o | 54 | obj-$(CONFIG_RTC_DRV_ISL12022) += rtc-isl12022.o |
54 | obj-$(CONFIG_RTC_DRV_JZ4740) += rtc-jz4740.o | 55 | obj-$(CONFIG_RTC_DRV_JZ4740) += rtc-jz4740.o |
55 | obj-$(CONFIG_RTC_DRV_LPC32XX) += rtc-lpc32xx.o | 56 | obj-$(CONFIG_RTC_DRV_LPC32XX) += rtc-lpc32xx.o |
57 | obj-$(CONFIG_RTC_DRV_LOONGSON1) += rtc-ls1x.o | ||
56 | obj-$(CONFIG_RTC_DRV_M41T80) += rtc-m41t80.o | 58 | obj-$(CONFIG_RTC_DRV_M41T80) += rtc-m41t80.o |
57 | obj-$(CONFIG_RTC_DRV_M41T93) += rtc-m41t93.o | 59 | obj-$(CONFIG_RTC_DRV_M41T93) += rtc-m41t93.o |
58 | obj-$(CONFIG_RTC_DRV_M41T94) += rtc-m41t94.o | 60 | obj-$(CONFIG_RTC_DRV_M41T94) += rtc-m41t94.o |
diff --git a/drivers/rtc/interface.c b/drivers/rtc/interface.c index 8a1c031391d6..dc87eda65814 100644 --- a/drivers/rtc/interface.c +++ b/drivers/rtc/interface.c | |||
@@ -73,6 +73,8 @@ int rtc_set_time(struct rtc_device *rtc, struct rtc_time *tm) | |||
73 | err = -EINVAL; | 73 | err = -EINVAL; |
74 | 74 | ||
75 | mutex_unlock(&rtc->ops_lock); | 75 | mutex_unlock(&rtc->ops_lock); |
76 | /* A timer might have just expired */ | ||
77 | schedule_work(&rtc->irqwork); | ||
76 | return err; | 78 | return err; |
77 | } | 79 | } |
78 | EXPORT_SYMBOL_GPL(rtc_set_time); | 80 | EXPORT_SYMBOL_GPL(rtc_set_time); |
@@ -112,6 +114,8 @@ int rtc_set_mmss(struct rtc_device *rtc, unsigned long secs) | |||
112 | err = -EINVAL; | 114 | err = -EINVAL; |
113 | 115 | ||
114 | mutex_unlock(&rtc->ops_lock); | 116 | mutex_unlock(&rtc->ops_lock); |
117 | /* A timer might have just expired */ | ||
118 | schedule_work(&rtc->irqwork); | ||
115 | 119 | ||
116 | return err; | 120 | return err; |
117 | } | 121 | } |
@@ -380,18 +384,27 @@ EXPORT_SYMBOL_GPL(rtc_set_alarm); | |||
380 | int rtc_initialize_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm) | 384 | int rtc_initialize_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm) |
381 | { | 385 | { |
382 | int err; | 386 | int err; |
387 | struct rtc_time now; | ||
383 | 388 | ||
384 | err = rtc_valid_tm(&alarm->time); | 389 | err = rtc_valid_tm(&alarm->time); |
385 | if (err != 0) | 390 | if (err != 0) |
386 | return err; | 391 | return err; |
387 | 392 | ||
393 | err = rtc_read_time(rtc, &now); | ||
394 | if (err) | ||
395 | return err; | ||
396 | |||
388 | err = mutex_lock_interruptible(&rtc->ops_lock); | 397 | err = mutex_lock_interruptible(&rtc->ops_lock); |
389 | if (err) | 398 | if (err) |
390 | return err; | 399 | return err; |
391 | 400 | ||
392 | rtc->aie_timer.node.expires = rtc_tm_to_ktime(alarm->time); | 401 | rtc->aie_timer.node.expires = rtc_tm_to_ktime(alarm->time); |
393 | rtc->aie_timer.period = ktime_set(0, 0); | 402 | rtc->aie_timer.period = ktime_set(0, 0); |
394 | if (alarm->enabled) { | 403 | |
404 | /* Alarm has to be enabled & in the futrure for us to enqueue it */ | ||
405 | if (alarm->enabled && (rtc_tm_to_ktime(now).tv64 < | ||
406 | rtc->aie_timer.node.expires.tv64)) { | ||
407 | |||
395 | rtc->aie_timer.enabled = 1; | 408 | rtc->aie_timer.enabled = 1; |
396 | timerqueue_add(&rtc->timerqueue, &rtc->aie_timer.node); | 409 | timerqueue_add(&rtc->timerqueue, &rtc->aie_timer.node); |
397 | } | 410 | } |
@@ -763,6 +776,14 @@ static int rtc_timer_enqueue(struct rtc_device *rtc, struct rtc_timer *timer) | |||
763 | return 0; | 776 | return 0; |
764 | } | 777 | } |
765 | 778 | ||
779 | static void rtc_alarm_disable(struct rtc_device *rtc) | ||
780 | { | ||
781 | if (!rtc->ops || !rtc->ops->alarm_irq_enable) | ||
782 | return; | ||
783 | |||
784 | rtc->ops->alarm_irq_enable(rtc->dev.parent, false); | ||
785 | } | ||
786 | |||
766 | /** | 787 | /** |
767 | * rtc_timer_remove - Removes a rtc_timer from the rtc_device timerqueue | 788 | * rtc_timer_remove - Removes a rtc_timer from the rtc_device timerqueue |
768 | * @rtc rtc device | 789 | * @rtc rtc device |
@@ -784,8 +805,10 @@ static void rtc_timer_remove(struct rtc_device *rtc, struct rtc_timer *timer) | |||
784 | struct rtc_wkalrm alarm; | 805 | struct rtc_wkalrm alarm; |
785 | int err; | 806 | int err; |
786 | next = timerqueue_getnext(&rtc->timerqueue); | 807 | next = timerqueue_getnext(&rtc->timerqueue); |
787 | if (!next) | 808 | if (!next) { |
809 | rtc_alarm_disable(rtc); | ||
788 | return; | 810 | return; |
811 | } | ||
789 | alarm.time = rtc_ktime_to_tm(next->expires); | 812 | alarm.time = rtc_ktime_to_tm(next->expires); |
790 | alarm.enabled = 1; | 813 | alarm.enabled = 1; |
791 | err = __rtc_set_alarm(rtc, &alarm); | 814 | err = __rtc_set_alarm(rtc, &alarm); |
@@ -847,7 +870,8 @@ again: | |||
847 | err = __rtc_set_alarm(rtc, &alarm); | 870 | err = __rtc_set_alarm(rtc, &alarm); |
848 | if (err == -ETIME) | 871 | if (err == -ETIME) |
849 | goto again; | 872 | goto again; |
850 | } | 873 | } else |
874 | rtc_alarm_disable(rtc); | ||
851 | 875 | ||
852 | mutex_unlock(&rtc->ops_lock); | 876 | mutex_unlock(&rtc->ops_lock); |
853 | } | 877 | } |
diff --git a/drivers/rtc/rtc-at91sam9.c b/drivers/rtc/rtc-at91sam9.c index a3ad957507dc..831868904e02 100644 --- a/drivers/rtc/rtc-at91sam9.c +++ b/drivers/rtc/rtc-at91sam9.c | |||
@@ -57,6 +57,7 @@ struct sam9_rtc { | |||
57 | void __iomem *rtt; | 57 | void __iomem *rtt; |
58 | struct rtc_device *rtcdev; | 58 | struct rtc_device *rtcdev; |
59 | u32 imr; | 59 | u32 imr; |
60 | void __iomem *gpbr; | ||
60 | }; | 61 | }; |
61 | 62 | ||
62 | #define rtt_readl(rtc, field) \ | 63 | #define rtt_readl(rtc, field) \ |
@@ -65,9 +66,9 @@ struct sam9_rtc { | |||
65 | __raw_writel((val), (rtc)->rtt + AT91_RTT_ ## field) | 66 | __raw_writel((val), (rtc)->rtt + AT91_RTT_ ## field) |
66 | 67 | ||
67 | #define gpbr_readl(rtc) \ | 68 | #define gpbr_readl(rtc) \ |
68 | at91_sys_read(AT91_GPBR + 4 * CONFIG_RTC_DRV_AT91SAM9_GPBR) | 69 | __raw_readl((rtc)->gpbr) |
69 | #define gpbr_writel(rtc, val) \ | 70 | #define gpbr_writel(rtc, val) \ |
70 | at91_sys_write(AT91_GPBR + 4 * CONFIG_RTC_DRV_AT91SAM9_GPBR, (val)) | 71 | __raw_writel((val), (rtc)->gpbr) |
71 | 72 | ||
72 | /* | 73 | /* |
73 | * Read current time and date in RTC | 74 | * Read current time and date in RTC |
@@ -287,16 +288,19 @@ static const struct rtc_class_ops at91_rtc_ops = { | |||
287 | /* | 288 | /* |
288 | * Initialize and install RTC driver | 289 | * Initialize and install RTC driver |
289 | */ | 290 | */ |
290 | static int __init at91_rtc_probe(struct platform_device *pdev) | 291 | static int __devinit at91_rtc_probe(struct platform_device *pdev) |
291 | { | 292 | { |
292 | struct resource *r; | 293 | struct resource *r, *r_gpbr; |
293 | struct sam9_rtc *rtc; | 294 | struct sam9_rtc *rtc; |
294 | int ret; | 295 | int ret; |
295 | u32 mr; | 296 | u32 mr; |
296 | 297 | ||
297 | r = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 298 | r = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
298 | if (!r) | 299 | r_gpbr = platform_get_resource(pdev, IORESOURCE_MEM, 1); |
300 | if (!r || !r_gpbr) { | ||
301 | dev_err(&pdev->dev, "need 2 ressources\n"); | ||
299 | return -ENODEV; | 302 | return -ENODEV; |
303 | } | ||
300 | 304 | ||
301 | rtc = kzalloc(sizeof *rtc, GFP_KERNEL); | 305 | rtc = kzalloc(sizeof *rtc, GFP_KERNEL); |
302 | if (!rtc) | 306 | if (!rtc) |
@@ -307,8 +311,19 @@ static int __init at91_rtc_probe(struct platform_device *pdev) | |||
307 | device_init_wakeup(&pdev->dev, 1); | 311 | device_init_wakeup(&pdev->dev, 1); |
308 | 312 | ||
309 | platform_set_drvdata(pdev, rtc); | 313 | platform_set_drvdata(pdev, rtc); |
310 | rtc->rtt = (void __force __iomem *) (AT91_VA_BASE_SYS - AT91_BASE_SYS); | 314 | rtc->rtt = ioremap(r->start, resource_size(r)); |
311 | rtc->rtt += r->start; | 315 | if (!rtc->rtt) { |
316 | dev_err(&pdev->dev, "failed to map registers, aborting.\n"); | ||
317 | ret = -ENOMEM; | ||
318 | goto fail; | ||
319 | } | ||
320 | |||
321 | rtc->gpbr = ioremap(r_gpbr->start, resource_size(r_gpbr)); | ||
322 | if (!rtc->gpbr) { | ||
323 | dev_err(&pdev->dev, "failed to map gpbr registers, aborting.\n"); | ||
324 | ret = -ENOMEM; | ||
325 | goto fail_gpbr; | ||
326 | } | ||
312 | 327 | ||
313 | mr = rtt_readl(rtc, MR); | 328 | mr = rtt_readl(rtc, MR); |
314 | 329 | ||
@@ -326,17 +341,17 @@ static int __init at91_rtc_probe(struct platform_device *pdev) | |||
326 | &at91_rtc_ops, THIS_MODULE); | 341 | &at91_rtc_ops, THIS_MODULE); |
327 | if (IS_ERR(rtc->rtcdev)) { | 342 | if (IS_ERR(rtc->rtcdev)) { |
328 | ret = PTR_ERR(rtc->rtcdev); | 343 | ret = PTR_ERR(rtc->rtcdev); |
329 | goto fail; | 344 | goto fail_register; |
330 | } | 345 | } |
331 | 346 | ||
332 | /* register irq handler after we know what name we'll use */ | 347 | /* register irq handler after we know what name we'll use */ |
333 | ret = request_irq(AT91_ID_SYS, at91_rtc_interrupt, | 348 | ret = request_irq(AT91_ID_SYS, at91_rtc_interrupt, |
334 | IRQF_DISABLED | IRQF_SHARED, | 349 | IRQF_SHARED, |
335 | dev_name(&rtc->rtcdev->dev), rtc); | 350 | dev_name(&rtc->rtcdev->dev), rtc); |
336 | if (ret) { | 351 | if (ret) { |
337 | dev_dbg(&pdev->dev, "can't share IRQ %d?\n", AT91_ID_SYS); | 352 | dev_dbg(&pdev->dev, "can't share IRQ %d?\n", AT91_ID_SYS); |
338 | rtc_device_unregister(rtc->rtcdev); | 353 | rtc_device_unregister(rtc->rtcdev); |
339 | goto fail; | 354 | goto fail_register; |
340 | } | 355 | } |
341 | 356 | ||
342 | /* NOTE: sam9260 rev A silicon has a ROM bug which resets the | 357 | /* NOTE: sam9260 rev A silicon has a ROM bug which resets the |
@@ -351,6 +366,10 @@ static int __init at91_rtc_probe(struct platform_device *pdev) | |||
351 | 366 | ||
352 | return 0; | 367 | return 0; |
353 | 368 | ||
369 | fail_register: | ||
370 | iounmap(rtc->gpbr); | ||
371 | fail_gpbr: | ||
372 | iounmap(rtc->rtt); | ||
354 | fail: | 373 | fail: |
355 | platform_set_drvdata(pdev, NULL); | 374 | platform_set_drvdata(pdev, NULL); |
356 | kfree(rtc); | 375 | kfree(rtc); |
@@ -360,7 +379,7 @@ fail: | |||
360 | /* | 379 | /* |
361 | * Disable and remove the RTC driver | 380 | * Disable and remove the RTC driver |
362 | */ | 381 | */ |
363 | static int __exit at91_rtc_remove(struct platform_device *pdev) | 382 | static int __devexit at91_rtc_remove(struct platform_device *pdev) |
364 | { | 383 | { |
365 | struct sam9_rtc *rtc = platform_get_drvdata(pdev); | 384 | struct sam9_rtc *rtc = platform_get_drvdata(pdev); |
366 | u32 mr = rtt_readl(rtc, MR); | 385 | u32 mr = rtt_readl(rtc, MR); |
@@ -371,6 +390,8 @@ static int __exit at91_rtc_remove(struct platform_device *pdev) | |||
371 | 390 | ||
372 | rtc_device_unregister(rtc->rtcdev); | 391 | rtc_device_unregister(rtc->rtcdev); |
373 | 392 | ||
393 | iounmap(rtc->gpbr); | ||
394 | iounmap(rtc->rtt); | ||
374 | platform_set_drvdata(pdev, NULL); | 395 | platform_set_drvdata(pdev, NULL); |
375 | kfree(rtc); | 396 | kfree(rtc); |
376 | return 0; | 397 | return 0; |
@@ -433,63 +454,20 @@ static int at91_rtc_resume(struct platform_device *pdev) | |||
433 | #endif | 454 | #endif |
434 | 455 | ||
435 | static struct platform_driver at91_rtc_driver = { | 456 | static struct platform_driver at91_rtc_driver = { |
436 | .driver.name = "rtc-at91sam9", | 457 | .probe = at91_rtc_probe, |
437 | .driver.owner = THIS_MODULE, | 458 | .remove = __devexit_p(at91_rtc_remove), |
438 | .remove = __exit_p(at91_rtc_remove), | ||
439 | .shutdown = at91_rtc_shutdown, | 459 | .shutdown = at91_rtc_shutdown, |
440 | .suspend = at91_rtc_suspend, | 460 | .suspend = at91_rtc_suspend, |
441 | .resume = at91_rtc_resume, | 461 | .resume = at91_rtc_resume, |
462 | .driver = { | ||
463 | .name = "rtc-at91sam9", | ||
464 | .owner = THIS_MODULE, | ||
465 | }, | ||
442 | }; | 466 | }; |
443 | 467 | ||
444 | /* Chips can have more than one RTT module, and they can be used for more | ||
445 | * than just RTCs. So we can't just register as "the" RTT driver. | ||
446 | * | ||
447 | * A normal approach in such cases is to create a library to allocate and | ||
448 | * free the modules. Here we just use bus_find_device() as like such a | ||
449 | * library, binding directly ... no runtime "library" footprint is needed. | ||
450 | */ | ||
451 | static int __init at91_rtc_match(struct device *dev, void *v) | ||
452 | { | ||
453 | struct platform_device *pdev = to_platform_device(dev); | ||
454 | int ret; | ||
455 | |||
456 | /* continue searching if this isn't the RTT we need */ | ||
457 | if (strcmp("at91_rtt", pdev->name) != 0 | ||
458 | || pdev->id != CONFIG_RTC_DRV_AT91SAM9_RTT) | ||
459 | goto fail; | ||
460 | |||
461 | /* else we found it ... but fail unless we can bind to the RTC driver */ | ||
462 | if (dev->driver) { | ||
463 | dev_dbg(dev, "busy, can't use as RTC!\n"); | ||
464 | goto fail; | ||
465 | } | ||
466 | dev->driver = &at91_rtc_driver.driver; | ||
467 | if (device_attach(dev) == 0) { | ||
468 | dev_dbg(dev, "can't attach RTC!\n"); | ||
469 | goto fail; | ||
470 | } | ||
471 | ret = at91_rtc_probe(pdev); | ||
472 | if (ret == 0) | ||
473 | return true; | ||
474 | |||
475 | dev_dbg(dev, "RTC probe err %d!\n", ret); | ||
476 | fail: | ||
477 | return false; | ||
478 | } | ||
479 | |||
480 | static int __init at91_rtc_init(void) | 468 | static int __init at91_rtc_init(void) |
481 | { | 469 | { |
482 | int status; | 470 | return platform_driver_register(&at91_rtc_driver); |
483 | struct device *rtc; | ||
484 | |||
485 | status = platform_driver_register(&at91_rtc_driver); | ||
486 | if (status) | ||
487 | return status; | ||
488 | rtc = bus_find_device(&platform_bus_type, NULL, | ||
489 | NULL, at91_rtc_match); | ||
490 | if (!rtc) | ||
491 | platform_driver_unregister(&at91_rtc_driver); | ||
492 | return rtc ? 0 : -ENODEV; | ||
493 | } | 471 | } |
494 | module_init(at91_rtc_init); | 472 | module_init(at91_rtc_init); |
495 | 473 | ||
diff --git a/drivers/rtc/rtc-bq32k.c b/drivers/rtc/rtc-bq32k.c index 408cc8f735be..f090159dce4a 100644 --- a/drivers/rtc/rtc-bq32k.c +++ b/drivers/rtc/rtc-bq32k.c | |||
@@ -187,17 +187,7 @@ static struct i2c_driver bq32k_driver = { | |||
187 | .id_table = bq32k_id, | 187 | .id_table = bq32k_id, |
188 | }; | 188 | }; |
189 | 189 | ||
190 | static __init int bq32k_init(void) | 190 | module_i2c_driver(bq32k_driver); |
191 | { | ||
192 | return i2c_add_driver(&bq32k_driver); | ||
193 | } | ||
194 | module_init(bq32k_init); | ||
195 | |||
196 | static __exit void bq32k_exit(void) | ||
197 | { | ||
198 | i2c_del_driver(&bq32k_driver); | ||
199 | } | ||
200 | module_exit(bq32k_exit); | ||
201 | 191 | ||
202 | MODULE_AUTHOR("Semihalf, Piotr Ziecik <kosmo@semihalf.com>"); | 192 | MODULE_AUTHOR("Semihalf, Piotr Ziecik <kosmo@semihalf.com>"); |
203 | MODULE_DESCRIPTION("TI BQ32000 I2C RTC driver"); | 193 | MODULE_DESCRIPTION("TI BQ32000 I2C RTC driver"); |
diff --git a/drivers/rtc/rtc-cmos.c b/drivers/rtc/rtc-cmos.c index d7782aa09943..7d5f56edb8ef 100644 --- a/drivers/rtc/rtc-cmos.c +++ b/drivers/rtc/rtc-cmos.c | |||
@@ -714,7 +714,7 @@ cmos_do_probe(struct device *dev, struct resource *ports, int rtc_irq) | |||
714 | rtc_cmos_int_handler = cmos_interrupt; | 714 | rtc_cmos_int_handler = cmos_interrupt; |
715 | 715 | ||
716 | retval = request_irq(rtc_irq, rtc_cmos_int_handler, | 716 | retval = request_irq(rtc_irq, rtc_cmos_int_handler, |
717 | IRQF_DISABLED, dev_name(&cmos_rtc.rtc->dev), | 717 | 0, dev_name(&cmos_rtc.rtc->dev), |
718 | cmos_rtc.rtc); | 718 | cmos_rtc.rtc); |
719 | if (retval < 0) { | 719 | if (retval < 0) { |
720 | dev_dbg(dev, "IRQ %d is already in use\n", rtc_irq); | 720 | dev_dbg(dev, "IRQ %d is already in use\n", rtc_irq); |
diff --git a/drivers/rtc/rtc-coh901331.c b/drivers/rtc/rtc-coh901331.c index 80f9c88214c5..a5b8a0c4ea84 100644 --- a/drivers/rtc/rtc-coh901331.c +++ b/drivers/rtc/rtc-coh901331.c | |||
@@ -199,7 +199,7 @@ static int __init coh901331_probe(struct platform_device *pdev) | |||
199 | } | 199 | } |
200 | 200 | ||
201 | rtap->irq = platform_get_irq(pdev, 0); | 201 | rtap->irq = platform_get_irq(pdev, 0); |
202 | if (request_irq(rtap->irq, coh901331_interrupt, IRQF_DISABLED, | 202 | if (request_irq(rtap->irq, coh901331_interrupt, 0, |
203 | "RTC COH 901 331 Alarm", rtap)) { | 203 | "RTC COH 901 331 Alarm", rtap)) { |
204 | ret = -EIO; | 204 | ret = -EIO; |
205 | goto out_no_irq; | 205 | goto out_no_irq; |
diff --git a/drivers/rtc/rtc-da9052.c b/drivers/rtc/rtc-da9052.c new file mode 100644 index 000000000000..da6ab5291a41 --- /dev/null +++ b/drivers/rtc/rtc-da9052.c | |||
@@ -0,0 +1,293 @@ | |||
1 | /* | ||
2 | * Real time clock driver for DA9052 | ||
3 | * | ||
4 | * Copyright(c) 2012 Dialog Semiconductor Ltd. | ||
5 | * | ||
6 | * Author: Dajun Dajun Chen <dajun.chen@diasemi.com> | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify | ||
9 | * it under the terms of the GNU General Public License as published by | ||
10 | * the Free Software Foundation; either version 2 of the License, or | ||
11 | * (at your option) any later version. | ||
12 | * | ||
13 | */ | ||
14 | |||
15 | #include <linux/module.h> | ||
16 | #include <linux/platform_device.h> | ||
17 | #include <linux/rtc.h> | ||
18 | |||
19 | #include <linux/mfd/da9052/da9052.h> | ||
20 | #include <linux/mfd/da9052/reg.h> | ||
21 | |||
22 | #define rtc_err(da9052, fmt, ...) \ | ||
23 | dev_err(da9052->dev, "%s: " fmt, __func__, ##__VA_ARGS__) | ||
24 | |||
25 | struct da9052_rtc { | ||
26 | struct rtc_device *rtc; | ||
27 | struct da9052 *da9052; | ||
28 | int irq; | ||
29 | }; | ||
30 | |||
31 | static int da9052_rtc_enable_alarm(struct da9052 *da9052, bool enable) | ||
32 | { | ||
33 | int ret; | ||
34 | if (enable) { | ||
35 | ret = da9052_reg_update(da9052, DA9052_ALARM_Y_REG, | ||
36 | DA9052_ALARM_Y_ALARM_ON, | ||
37 | DA9052_ALARM_Y_ALARM_ON); | ||
38 | if (ret != 0) | ||
39 | rtc_err(da9052, "Failed to enable ALM: %d\n", ret); | ||
40 | } else { | ||
41 | ret = da9052_reg_update(da9052, DA9052_ALARM_Y_REG, | ||
42 | DA9052_ALARM_Y_ALARM_ON, 0); | ||
43 | if (ret != 0) | ||
44 | rtc_err(da9052, "Write error: %d\n", ret); | ||
45 | } | ||
46 | return ret; | ||
47 | } | ||
48 | |||
49 | static irqreturn_t da9052_rtc_irq(int irq, void *data) | ||
50 | { | ||
51 | struct da9052_rtc *rtc = data; | ||
52 | int ret; | ||
53 | |||
54 | ret = da9052_reg_read(rtc->da9052, DA9052_ALARM_MI_REG); | ||
55 | if (ret < 0) { | ||
56 | rtc_err(rtc->da9052, "Read error: %d\n", ret); | ||
57 | return IRQ_NONE; | ||
58 | } | ||
59 | |||
60 | if (ret & DA9052_ALARMMI_ALARMTYPE) { | ||
61 | da9052_rtc_enable_alarm(rtc->da9052, 0); | ||
62 | rtc_update_irq(rtc->rtc, 1, RTC_IRQF | RTC_AF); | ||
63 | } else | ||
64 | rtc_update_irq(rtc->rtc, 1, RTC_IRQF | RTC_PF); | ||
65 | |||
66 | return IRQ_HANDLED; | ||
67 | } | ||
68 | |||
69 | static int da9052_read_alarm(struct da9052 *da9052, struct rtc_time *rtc_tm) | ||
70 | { | ||
71 | int ret; | ||
72 | uint8_t v[5]; | ||
73 | |||
74 | ret = da9052_group_read(da9052, DA9052_ALARM_MI_REG, 5, v); | ||
75 | if (ret != 0) { | ||
76 | rtc_err(da9052, "Failed to group read ALM: %d\n", ret); | ||
77 | return ret; | ||
78 | } | ||
79 | |||
80 | rtc_tm->tm_year = (v[4] & DA9052_RTC_YEAR) + 100; | ||
81 | rtc_tm->tm_mon = (v[3] & DA9052_RTC_MONTH) - 1; | ||
82 | rtc_tm->tm_mday = v[2] & DA9052_RTC_DAY; | ||
83 | rtc_tm->tm_hour = v[1] & DA9052_RTC_HOUR; | ||
84 | rtc_tm->tm_min = v[0] & DA9052_RTC_MIN; | ||
85 | |||
86 | ret = rtc_valid_tm(rtc_tm); | ||
87 | if (ret != 0) | ||
88 | return ret; | ||
89 | return ret; | ||
90 | } | ||
91 | |||
92 | static int da9052_set_alarm(struct da9052 *da9052, struct rtc_time *rtc_tm) | ||
93 | { | ||
94 | int ret; | ||
95 | uint8_t v[3]; | ||
96 | |||
97 | rtc_tm->tm_year -= 100; | ||
98 | rtc_tm->tm_mon += 1; | ||
99 | |||
100 | ret = da9052_reg_update(da9052, DA9052_ALARM_MI_REG, | ||
101 | DA9052_RTC_MIN, rtc_tm->tm_min); | ||
102 | if (ret != 0) { | ||
103 | rtc_err(da9052, "Failed to write ALRM MIN: %d\n", ret); | ||
104 | return ret; | ||
105 | } | ||
106 | |||
107 | v[0] = rtc_tm->tm_hour; | ||
108 | v[1] = rtc_tm->tm_mday; | ||
109 | v[2] = rtc_tm->tm_mon; | ||
110 | |||
111 | ret = da9052_group_write(da9052, DA9052_ALARM_H_REG, 3, v); | ||
112 | if (ret < 0) | ||
113 | return ret; | ||
114 | |||
115 | ret = da9052_reg_update(da9052, DA9052_ALARM_Y_REG, | ||
116 | DA9052_RTC_YEAR, rtc_tm->tm_year); | ||
117 | if (ret != 0) | ||
118 | rtc_err(da9052, "Failed to write ALRM YEAR: %d\n", ret); | ||
119 | |||
120 | return ret; | ||
121 | } | ||
122 | |||
123 | static int da9052_rtc_get_alarm_status(struct da9052 *da9052) | ||
124 | { | ||
125 | int ret; | ||
126 | |||
127 | ret = da9052_reg_read(da9052, DA9052_ALARM_Y_REG); | ||
128 | if (ret < 0) { | ||
129 | rtc_err(da9052, "Failed to read ALM: %d\n", ret); | ||
130 | return ret; | ||
131 | } | ||
132 | ret &= DA9052_ALARM_Y_ALARM_ON; | ||
133 | return (ret > 0) ? 1 : 0; | ||
134 | } | ||
135 | |||
136 | static int da9052_rtc_read_time(struct device *dev, struct rtc_time *rtc_tm) | ||
137 | { | ||
138 | struct da9052_rtc *rtc = dev_get_drvdata(dev); | ||
139 | uint8_t v[6]; | ||
140 | int ret; | ||
141 | |||
142 | ret = da9052_group_read(rtc->da9052, DA9052_COUNT_S_REG, 6, v); | ||
143 | if (ret < 0) { | ||
144 | rtc_err(rtc->da9052, "Failed to read RTC time : %d\n", ret); | ||
145 | return ret; | ||
146 | } | ||
147 | |||
148 | rtc_tm->tm_year = (v[5] & DA9052_RTC_YEAR) + 100; | ||
149 | rtc_tm->tm_mon = (v[4] & DA9052_RTC_MONTH) - 1; | ||
150 | rtc_tm->tm_mday = v[3] & DA9052_RTC_DAY; | ||
151 | rtc_tm->tm_hour = v[2] & DA9052_RTC_HOUR; | ||
152 | rtc_tm->tm_min = v[1] & DA9052_RTC_MIN; | ||
153 | rtc_tm->tm_sec = v[0] & DA9052_RTC_SEC; | ||
154 | |||
155 | ret = rtc_valid_tm(rtc_tm); | ||
156 | if (ret != 0) { | ||
157 | rtc_err(rtc->da9052, "rtc_valid_tm failed: %d\n", ret); | ||
158 | return ret; | ||
159 | } | ||
160 | |||
161 | return 0; | ||
162 | } | ||
163 | |||
164 | static int da9052_rtc_set_time(struct device *dev, struct rtc_time *tm) | ||
165 | { | ||
166 | struct da9052_rtc *rtc; | ||
167 | uint8_t v[6]; | ||
168 | |||
169 | rtc = dev_get_drvdata(dev); | ||
170 | |||
171 | v[0] = tm->tm_sec; | ||
172 | v[1] = tm->tm_min; | ||
173 | v[2] = tm->tm_hour; | ||
174 | v[3] = tm->tm_mday; | ||
175 | v[4] = tm->tm_mon + 1; | ||
176 | v[5] = tm->tm_year - 100; | ||
177 | |||
178 | return da9052_group_write(rtc->da9052, DA9052_COUNT_S_REG, 6, v); | ||
179 | } | ||
180 | |||
181 | static int da9052_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm) | ||
182 | { | ||
183 | int ret; | ||
184 | struct rtc_time *tm = &alrm->time; | ||
185 | struct da9052_rtc *rtc = dev_get_drvdata(dev); | ||
186 | |||
187 | ret = da9052_read_alarm(rtc->da9052, tm); | ||
188 | |||
189 | if (ret) | ||
190 | return ret; | ||
191 | |||
192 | alrm->enabled = da9052_rtc_get_alarm_status(rtc->da9052); | ||
193 | |||
194 | return 0; | ||
195 | } | ||
196 | |||
197 | static int da9052_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm) | ||
198 | { | ||
199 | int ret; | ||
200 | struct rtc_time *tm = &alrm->time; | ||
201 | struct da9052_rtc *rtc = dev_get_drvdata(dev); | ||
202 | |||
203 | ret = da9052_rtc_enable_alarm(rtc->da9052, 0); | ||
204 | if (ret < 0) | ||
205 | return ret; | ||
206 | |||
207 | ret = da9052_set_alarm(rtc->da9052, tm); | ||
208 | if (ret) | ||
209 | return ret; | ||
210 | |||
211 | ret = da9052_rtc_enable_alarm(rtc->da9052, 1); | ||
212 | |||
213 | return ret; | ||
214 | } | ||
215 | |||
216 | static int da9052_rtc_alarm_irq_enable(struct device *dev, unsigned int enabled) | ||
217 | { | ||
218 | struct da9052_rtc *rtc = dev_get_drvdata(dev); | ||
219 | |||
220 | return da9052_rtc_enable_alarm(rtc->da9052, enabled); | ||
221 | } | ||
222 | |||
223 | static const struct rtc_class_ops da9052_rtc_ops = { | ||
224 | .read_time = da9052_rtc_read_time, | ||
225 | .set_time = da9052_rtc_set_time, | ||
226 | .read_alarm = da9052_rtc_read_alarm, | ||
227 | .set_alarm = da9052_rtc_set_alarm, | ||
228 | .alarm_irq_enable = da9052_rtc_alarm_irq_enable, | ||
229 | }; | ||
230 | |||
231 | static int __devinit da9052_rtc_probe(struct platform_device *pdev) | ||
232 | { | ||
233 | struct da9052_rtc *rtc; | ||
234 | int ret; | ||
235 | |||
236 | rtc = devm_kzalloc(&pdev->dev, sizeof(struct da9052_rtc), GFP_KERNEL); | ||
237 | if (!rtc) | ||
238 | return -ENOMEM; | ||
239 | |||
240 | rtc->da9052 = dev_get_drvdata(pdev->dev.parent); | ||
241 | platform_set_drvdata(pdev, rtc); | ||
242 | rtc->irq = platform_get_irq_byname(pdev, "ALM"); | ||
243 | ret = request_threaded_irq(rtc->irq, NULL, da9052_rtc_irq, | ||
244 | IRQF_TRIGGER_LOW | IRQF_ONESHOT, | ||
245 | "ALM", rtc); | ||
246 | if (ret != 0) { | ||
247 | rtc_err(rtc->da9052, "irq registration failed: %d\n", ret); | ||
248 | goto err_mem; | ||
249 | } | ||
250 | |||
251 | rtc->rtc = rtc_device_register(pdev->name, &pdev->dev, | ||
252 | &da9052_rtc_ops, THIS_MODULE); | ||
253 | if (IS_ERR(rtc->rtc)) { | ||
254 | ret = PTR_ERR(rtc->rtc); | ||
255 | goto err_free_irq; | ||
256 | } | ||
257 | |||
258 | return 0; | ||
259 | |||
260 | err_free_irq: | ||
261 | free_irq(rtc->irq, rtc); | ||
262 | err_mem: | ||
263 | devm_kfree(&pdev->dev, rtc); | ||
264 | return ret; | ||
265 | } | ||
266 | |||
267 | static int __devexit da9052_rtc_remove(struct platform_device *pdev) | ||
268 | { | ||
269 | struct da9052_rtc *rtc = pdev->dev.platform_data; | ||
270 | |||
271 | rtc_device_unregister(rtc->rtc); | ||
272 | free_irq(rtc->irq, rtc); | ||
273 | platform_set_drvdata(pdev, NULL); | ||
274 | devm_kfree(&pdev->dev, rtc); | ||
275 | |||
276 | return 0; | ||
277 | } | ||
278 | |||
279 | static struct platform_driver da9052_rtc_driver = { | ||
280 | .probe = da9052_rtc_probe, | ||
281 | .remove = __devexit_p(da9052_rtc_remove), | ||
282 | .driver = { | ||
283 | .name = "da9052-rtc", | ||
284 | .owner = THIS_MODULE, | ||
285 | }, | ||
286 | }; | ||
287 | |||
288 | module_platform_driver(da9052_rtc_driver); | ||
289 | |||
290 | MODULE_AUTHOR("David Dajun Chen <dchen@diasemi.com>"); | ||
291 | MODULE_DESCRIPTION("RTC driver for Dialog DA9052 PMIC"); | ||
292 | MODULE_LICENSE("GPL"); | ||
293 | MODULE_ALIAS("platform:da9052-rtc"); | ||
diff --git a/drivers/rtc/rtc-davinci.c b/drivers/rtc/rtc-davinci.c index 755e1fe914af..14c2109dbaa3 100644 --- a/drivers/rtc/rtc-davinci.c +++ b/drivers/rtc/rtc-davinci.c | |||
@@ -542,7 +542,7 @@ static int __init davinci_rtc_probe(struct platform_device *pdev) | |||
542 | rtcss_write(davinci_rtc, 0, PRTCSS_RTC_CCTRL); | 542 | rtcss_write(davinci_rtc, 0, PRTCSS_RTC_CCTRL); |
543 | 543 | ||
544 | ret = request_irq(davinci_rtc->irq, davinci_rtc_interrupt, | 544 | ret = request_irq(davinci_rtc->irq, davinci_rtc_interrupt, |
545 | IRQF_DISABLED, "davinci_rtc", davinci_rtc); | 545 | 0, "davinci_rtc", davinci_rtc); |
546 | if (ret < 0) { | 546 | if (ret < 0) { |
547 | dev_err(dev, "unable to register davinci RTC interrupt\n"); | 547 | dev_err(dev, "unable to register davinci RTC interrupt\n"); |
548 | goto fail4; | 548 | goto fail4; |
diff --git a/drivers/rtc/rtc-ds1305.c b/drivers/rtc/rtc-ds1305.c index 3a33b1fdbe0f..686a865913e1 100644 --- a/drivers/rtc/rtc-ds1305.c +++ b/drivers/rtc/rtc-ds1305.c | |||
@@ -814,17 +814,7 @@ static struct spi_driver ds1305_driver = { | |||
814 | /* REVISIT add suspend/resume */ | 814 | /* REVISIT add suspend/resume */ |
815 | }; | 815 | }; |
816 | 816 | ||
817 | static int __init ds1305_init(void) | 817 | module_spi_driver(ds1305_driver); |
818 | { | ||
819 | return spi_register_driver(&ds1305_driver); | ||
820 | } | ||
821 | module_init(ds1305_init); | ||
822 | |||
823 | static void __exit ds1305_exit(void) | ||
824 | { | ||
825 | spi_unregister_driver(&ds1305_driver); | ||
826 | } | ||
827 | module_exit(ds1305_exit); | ||
828 | 818 | ||
829 | MODULE_DESCRIPTION("RTC driver for DS1305 and DS1306 chips"); | 819 | MODULE_DESCRIPTION("RTC driver for DS1305 and DS1306 chips"); |
830 | MODULE_LICENSE("GPL"); | 820 | MODULE_LICENSE("GPL"); |
diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c index 62b0763b7b9a..cd188ab72f79 100644 --- a/drivers/rtc/rtc-ds1307.c +++ b/drivers/rtc/rtc-ds1307.c | |||
@@ -20,7 +20,8 @@ | |||
20 | 20 | ||
21 | 21 | ||
22 | 22 | ||
23 | /* We can't determine type by probing, but if we expect pre-Linux code | 23 | /* |
24 | * We can't determine type by probing, but if we expect pre-Linux code | ||
24 | * to have set the chip up as a clock (turning on the oscillator and | 25 | * to have set the chip up as a clock (turning on the oscillator and |
25 | * setting the date and time), Linux can ignore the non-clock features. | 26 | * setting the date and time), Linux can ignore the non-clock features. |
26 | * That's a natural job for a factory or repair bench. | 27 | * That's a natural job for a factory or repair bench. |
@@ -36,7 +37,8 @@ enum ds_type { | |||
36 | m41t00, | 37 | m41t00, |
37 | mcp7941x, | 38 | mcp7941x, |
38 | rx_8025, | 39 | rx_8025, |
39 | // rs5c372 too? different address... | 40 | last_ds_type /* always last */ |
41 | /* rs5c372 too? different address... */ | ||
40 | }; | 42 | }; |
41 | 43 | ||
42 | 44 | ||
@@ -58,7 +60,8 @@ enum ds_type { | |||
58 | # define DS1337_BIT_CENTURY 0x80 /* in REG_MONTH */ | 60 | # define DS1337_BIT_CENTURY 0x80 /* in REG_MONTH */ |
59 | #define DS1307_REG_YEAR 0x06 /* 00-99 */ | 61 | #define DS1307_REG_YEAR 0x06 /* 00-99 */ |
60 | 62 | ||
61 | /* Other registers (control, status, alarms, trickle charge, NVRAM, etc) | 63 | /* |
64 | * Other registers (control, status, alarms, trickle charge, NVRAM, etc) | ||
62 | * start at 7, and they differ a LOT. Only control and status matter for | 65 | * start at 7, and they differ a LOT. Only control and status matter for |
63 | * basic RTC date and time functionality; be careful using them. | 66 | * basic RTC date and time functionality; be careful using them. |
64 | */ | 67 | */ |
@@ -102,6 +105,8 @@ enum ds_type { | |||
102 | struct ds1307 { | 105 | struct ds1307 { |
103 | u8 offset; /* register's offset */ | 106 | u8 offset; /* register's offset */ |
104 | u8 regs[11]; | 107 | u8 regs[11]; |
108 | u16 nvram_offset; | ||
109 | struct bin_attribute *nvram; | ||
105 | enum ds_type type; | 110 | enum ds_type type; |
106 | unsigned long flags; | 111 | unsigned long flags; |
107 | #define HAS_NVRAM 0 /* bit 0 == sysfs file active */ | 112 | #define HAS_NVRAM 0 /* bit 0 == sysfs file active */ |
@@ -116,34 +121,35 @@ struct ds1307 { | |||
116 | }; | 121 | }; |
117 | 122 | ||
118 | struct chip_desc { | 123 | struct chip_desc { |
119 | unsigned nvram56:1; | ||
120 | unsigned alarm:1; | 124 | unsigned alarm:1; |
125 | u16 nvram_offset; | ||
126 | u16 nvram_size; | ||
121 | }; | 127 | }; |
122 | 128 | ||
123 | static const struct chip_desc chips[] = { | 129 | static const struct chip_desc chips[last_ds_type] = { |
124 | [ds_1307] = { | 130 | [ds_1307] = { |
125 | .nvram56 = 1, | 131 | .nvram_offset = 8, |
126 | }, | 132 | .nvram_size = 56, |
127 | [ds_1337] = { | 133 | }, |
128 | .alarm = 1, | 134 | [ds_1337] = { |
129 | }, | 135 | .alarm = 1, |
130 | [ds_1338] = { | 136 | }, |
131 | .nvram56 = 1, | 137 | [ds_1338] = { |
132 | }, | 138 | .nvram_offset = 8, |
133 | [ds_1339] = { | 139 | .nvram_size = 56, |
134 | .alarm = 1, | 140 | }, |
135 | }, | 141 | [ds_1339] = { |
136 | [ds_1340] = { | 142 | .alarm = 1, |
137 | }, | 143 | }, |
138 | [ds_3231] = { | 144 | [ds_3231] = { |
139 | .alarm = 1, | 145 | .alarm = 1, |
140 | }, | 146 | }, |
141 | [m41t00] = { | 147 | [mcp7941x] = { |
142 | }, | 148 | /* this is battery backed SRAM */ |
143 | [mcp7941x] = { | 149 | .nvram_offset = 0x20, |
144 | }, | 150 | .nvram_size = 0x40, |
145 | [rx_8025] = { | 151 | }, |
146 | }, }; | 152 | }; |
147 | 153 | ||
148 | static const struct i2c_device_id ds1307_id[] = { | 154 | static const struct i2c_device_id ds1307_id[] = { |
149 | { "ds1307", ds_1307 }, | 155 | { "ds1307", ds_1307 }, |
@@ -372,6 +378,11 @@ static int ds1307_set_time(struct device *dev, struct rtc_time *t) | |||
372 | | DS1340_BIT_CENTURY; | 378 | | DS1340_BIT_CENTURY; |
373 | break; | 379 | break; |
374 | case mcp7941x: | 380 | case mcp7941x: |
381 | /* | ||
382 | * these bits were cleared when preparing the date/time | ||
383 | * values and need to be set again before writing the | ||
384 | * buffer out to the device. | ||
385 | */ | ||
375 | buf[DS1307_REG_SECS] |= MCP7941X_BIT_ST; | 386 | buf[DS1307_REG_SECS] |= MCP7941X_BIT_ST; |
376 | buf[DS1307_REG_WDAY] |= MCP7941X_BIT_VBATEN; | 387 | buf[DS1307_REG_WDAY] |= MCP7941X_BIT_VBATEN; |
377 | break; | 388 | break; |
@@ -417,7 +428,8 @@ static int ds1337_read_alarm(struct device *dev, struct rtc_wkalrm *t) | |||
417 | ds1307->regs[6], ds1307->regs[7], | 428 | ds1307->regs[6], ds1307->regs[7], |
418 | ds1307->regs[8]); | 429 | ds1307->regs[8]); |
419 | 430 | ||
420 | /* report alarm time (ALARM1); assume 24 hour and day-of-month modes, | 431 | /* |
432 | * report alarm time (ALARM1); assume 24 hour and day-of-month modes, | ||
421 | * and that all four fields are checked matches | 433 | * and that all four fields are checked matches |
422 | */ | 434 | */ |
423 | t->time.tm_sec = bcd2bin(ds1307->regs[0] & 0x7f); | 435 | t->time.tm_sec = bcd2bin(ds1307->regs[0] & 0x7f); |
@@ -445,7 +457,7 @@ static int ds1337_read_alarm(struct device *dev, struct rtc_wkalrm *t) | |||
445 | 457 | ||
446 | static int ds1337_set_alarm(struct device *dev, struct rtc_wkalrm *t) | 458 | static int ds1337_set_alarm(struct device *dev, struct rtc_wkalrm *t) |
447 | { | 459 | { |
448 | struct i2c_client *client = to_i2c_client(dev); | 460 | struct i2c_client *client = to_i2c_client(dev); |
449 | struct ds1307 *ds1307 = i2c_get_clientdata(client); | 461 | struct ds1307 *ds1307 = i2c_get_clientdata(client); |
450 | unsigned char *buf = ds1307->regs; | 462 | unsigned char *buf = ds1307->regs; |
451 | u8 control, status; | 463 | u8 control, status; |
@@ -541,8 +553,6 @@ static const struct rtc_class_ops ds13xx_rtc_ops = { | |||
541 | 553 | ||
542 | /*----------------------------------------------------------------------*/ | 554 | /*----------------------------------------------------------------------*/ |
543 | 555 | ||
544 | #define NVRAM_SIZE 56 | ||
545 | |||
546 | static ssize_t | 556 | static ssize_t |
547 | ds1307_nvram_read(struct file *filp, struct kobject *kobj, | 557 | ds1307_nvram_read(struct file *filp, struct kobject *kobj, |
548 | struct bin_attribute *attr, | 558 | struct bin_attribute *attr, |
@@ -555,14 +565,15 @@ ds1307_nvram_read(struct file *filp, struct kobject *kobj, | |||
555 | client = kobj_to_i2c_client(kobj); | 565 | client = kobj_to_i2c_client(kobj); |
556 | ds1307 = i2c_get_clientdata(client); | 566 | ds1307 = i2c_get_clientdata(client); |
557 | 567 | ||
558 | if (unlikely(off >= NVRAM_SIZE)) | 568 | if (unlikely(off >= ds1307->nvram->size)) |
559 | return 0; | 569 | return 0; |
560 | if ((off + count) > NVRAM_SIZE) | 570 | if ((off + count) > ds1307->nvram->size) |
561 | count = NVRAM_SIZE - off; | 571 | count = ds1307->nvram->size - off; |
562 | if (unlikely(!count)) | 572 | if (unlikely(!count)) |
563 | return count; | 573 | return count; |
564 | 574 | ||
565 | result = ds1307->read_block_data(client, 8 + off, count, buf); | 575 | result = ds1307->read_block_data(client, ds1307->nvram_offset + off, |
576 | count, buf); | ||
566 | if (result < 0) | 577 | if (result < 0) |
567 | dev_err(&client->dev, "%s error %d\n", "nvram read", result); | 578 | dev_err(&client->dev, "%s error %d\n", "nvram read", result); |
568 | return result; | 579 | return result; |
@@ -580,14 +591,15 @@ ds1307_nvram_write(struct file *filp, struct kobject *kobj, | |||
580 | client = kobj_to_i2c_client(kobj); | 591 | client = kobj_to_i2c_client(kobj); |
581 | ds1307 = i2c_get_clientdata(client); | 592 | ds1307 = i2c_get_clientdata(client); |
582 | 593 | ||
583 | if (unlikely(off >= NVRAM_SIZE)) | 594 | if (unlikely(off >= ds1307->nvram->size)) |
584 | return -EFBIG; | 595 | return -EFBIG; |
585 | if ((off + count) > NVRAM_SIZE) | 596 | if ((off + count) > ds1307->nvram->size) |
586 | count = NVRAM_SIZE - off; | 597 | count = ds1307->nvram->size - off; |
587 | if (unlikely(!count)) | 598 | if (unlikely(!count)) |
588 | return count; | 599 | return count; |
589 | 600 | ||
590 | result = ds1307->write_block_data(client, 8 + off, count, buf); | 601 | result = ds1307->write_block_data(client, ds1307->nvram_offset + off, |
602 | count, buf); | ||
591 | if (result < 0) { | 603 | if (result < 0) { |
592 | dev_err(&client->dev, "%s error %d\n", "nvram write", result); | 604 | dev_err(&client->dev, "%s error %d\n", "nvram write", result); |
593 | return result; | 605 | return result; |
@@ -595,21 +607,8 @@ ds1307_nvram_write(struct file *filp, struct kobject *kobj, | |||
595 | return count; | 607 | return count; |
596 | } | 608 | } |
597 | 609 | ||
598 | static struct bin_attribute nvram = { | ||
599 | .attr = { | ||
600 | .name = "nvram", | ||
601 | .mode = S_IRUGO | S_IWUSR, | ||
602 | }, | ||
603 | |||
604 | .read = ds1307_nvram_read, | ||
605 | .write = ds1307_nvram_write, | ||
606 | .size = NVRAM_SIZE, | ||
607 | }; | ||
608 | |||
609 | /*----------------------------------------------------------------------*/ | 610 | /*----------------------------------------------------------------------*/ |
610 | 611 | ||
611 | static struct i2c_driver ds1307_driver; | ||
612 | |||
613 | static int __devinit ds1307_probe(struct i2c_client *client, | 612 | static int __devinit ds1307_probe(struct i2c_client *client, |
614 | const struct i2c_device_id *id) | 613 | const struct i2c_device_id *id) |
615 | { | 614 | { |
@@ -630,7 +629,8 @@ static int __devinit ds1307_probe(struct i2c_client *client, | |||
630 | && !i2c_check_functionality(adapter, I2C_FUNC_SMBUS_I2C_BLOCK)) | 629 | && !i2c_check_functionality(adapter, I2C_FUNC_SMBUS_I2C_BLOCK)) |
631 | return -EIO; | 630 | return -EIO; |
632 | 631 | ||
633 | if (!(ds1307 = kzalloc(sizeof(struct ds1307), GFP_KERNEL))) | 632 | ds1307 = kzalloc(sizeof(struct ds1307), GFP_KERNEL); |
633 | if (!ds1307) | ||
634 | return -ENOMEM; | 634 | return -ENOMEM; |
635 | 635 | ||
636 | i2c_set_clientdata(client, ds1307); | 636 | i2c_set_clientdata(client, ds1307); |
@@ -652,11 +652,6 @@ static int __devinit ds1307_probe(struct i2c_client *client, | |||
652 | case ds_1337: | 652 | case ds_1337: |
653 | case ds_1339: | 653 | case ds_1339: |
654 | case ds_3231: | 654 | case ds_3231: |
655 | /* has IRQ? */ | ||
656 | if (ds1307->client->irq > 0 && chip->alarm) { | ||
657 | INIT_WORK(&ds1307->work, ds1307_work); | ||
658 | want_irq = true; | ||
659 | } | ||
660 | /* get registers that the "rtc" read below won't read... */ | 655 | /* get registers that the "rtc" read below won't read... */ |
661 | tmp = ds1307->read_block_data(ds1307->client, | 656 | tmp = ds1307->read_block_data(ds1307->client, |
662 | DS1337_REG_CONTROL, 2, buf); | 657 | DS1337_REG_CONTROL, 2, buf); |
@@ -670,14 +665,19 @@ static int __devinit ds1307_probe(struct i2c_client *client, | |||
670 | if (ds1307->regs[0] & DS1337_BIT_nEOSC) | 665 | if (ds1307->regs[0] & DS1337_BIT_nEOSC) |
671 | ds1307->regs[0] &= ~DS1337_BIT_nEOSC; | 666 | ds1307->regs[0] &= ~DS1337_BIT_nEOSC; |
672 | 667 | ||
673 | /* Using IRQ? Disable the square wave and both alarms. | 668 | /* |
669 | * Using IRQ? Disable the square wave and both alarms. | ||
674 | * For some variants, be sure alarms can trigger when we're | 670 | * For some variants, be sure alarms can trigger when we're |
675 | * running on Vbackup (BBSQI/BBSQW) | 671 | * running on Vbackup (BBSQI/BBSQW) |
676 | */ | 672 | */ |
677 | if (want_irq) { | 673 | if (ds1307->client->irq > 0 && chip->alarm) { |
674 | INIT_WORK(&ds1307->work, ds1307_work); | ||
675 | |||
678 | ds1307->regs[0] |= DS1337_BIT_INTCN | 676 | ds1307->regs[0] |= DS1337_BIT_INTCN |
679 | | bbsqi_bitpos[ds1307->type]; | 677 | | bbsqi_bitpos[ds1307->type]; |
680 | ds1307->regs[0] &= ~(DS1337_BIT_A2IE | DS1337_BIT_A1IE); | 678 | ds1307->regs[0] &= ~(DS1337_BIT_A2IE | DS1337_BIT_A1IE); |
679 | |||
680 | want_irq = true; | ||
681 | } | 681 | } |
682 | 682 | ||
683 | i2c_smbus_write_byte_data(client, DS1337_REG_CONTROL, | 683 | i2c_smbus_write_byte_data(client, DS1337_REG_CONTROL, |
@@ -772,7 +772,8 @@ read_rtc: | |||
772 | goto exit_free; | 772 | goto exit_free; |
773 | } | 773 | } |
774 | 774 | ||
775 | /* minimal sanity checking; some chips (like DS1340) don't | 775 | /* |
776 | * minimal sanity checking; some chips (like DS1340) don't | ||
776 | * specify the extra bits as must-be-zero, but there are | 777 | * specify the extra bits as must-be-zero, but there are |
777 | * still a few values that are clearly out-of-range. | 778 | * still a few values that are clearly out-of-range. |
778 | */ | 779 | */ |
@@ -836,11 +837,7 @@ read_rtc: | |||
836 | } | 837 | } |
837 | 838 | ||
838 | break; | 839 | break; |
839 | case rx_8025: | 840 | default: |
840 | case ds_1337: | ||
841 | case ds_1339: | ||
842 | case ds_1388: | ||
843 | case ds_3231: | ||
844 | break; | 841 | break; |
845 | } | 842 | } |
846 | 843 | ||
@@ -848,7 +845,8 @@ read_rtc: | |||
848 | switch (ds1307->type) { | 845 | switch (ds1307->type) { |
849 | case ds_1340: | 846 | case ds_1340: |
850 | case m41t00: | 847 | case m41t00: |
851 | /* NOTE: ignores century bits; fix before deploying | 848 | /* |
849 | * NOTE: ignores century bits; fix before deploying | ||
852 | * systems that will run through year 2100. | 850 | * systems that will run through year 2100. |
853 | */ | 851 | */ |
854 | break; | 852 | break; |
@@ -858,7 +856,8 @@ read_rtc: | |||
858 | if (!(tmp & DS1307_BIT_12HR)) | 856 | if (!(tmp & DS1307_BIT_12HR)) |
859 | break; | 857 | break; |
860 | 858 | ||
861 | /* Be sure we're in 24 hour mode. Multi-master systems | 859 | /* |
860 | * Be sure we're in 24 hour mode. Multi-master systems | ||
862 | * take note... | 861 | * take note... |
863 | */ | 862 | */ |
864 | tmp = bcd2bin(tmp & 0x1f); | 863 | tmp = bcd2bin(tmp & 0x1f); |
@@ -894,16 +893,31 @@ read_rtc: | |||
894 | dev_dbg(&client->dev, "got IRQ %d\n", client->irq); | 893 | dev_dbg(&client->dev, "got IRQ %d\n", client->irq); |
895 | } | 894 | } |
896 | 895 | ||
897 | if (chip->nvram56) { | 896 | if (chip->nvram_size) { |
898 | err = sysfs_create_bin_file(&client->dev.kobj, &nvram); | 897 | ds1307->nvram = kzalloc(sizeof(struct bin_attribute), |
899 | if (err == 0) { | 898 | GFP_KERNEL); |
900 | set_bit(HAS_NVRAM, &ds1307->flags); | 899 | if (!ds1307->nvram) { |
901 | dev_info(&client->dev, "56 bytes nvram\n"); | 900 | err = -ENOMEM; |
901 | goto exit_nvram; | ||
902 | } | ||
903 | ds1307->nvram->attr.name = "nvram"; | ||
904 | ds1307->nvram->attr.mode = S_IRUGO | S_IWUSR; | ||
905 | ds1307->nvram->read = ds1307_nvram_read, | ||
906 | ds1307->nvram->write = ds1307_nvram_write, | ||
907 | ds1307->nvram->size = chip->nvram_size; | ||
908 | ds1307->nvram_offset = chip->nvram_offset; | ||
909 | err = sysfs_create_bin_file(&client->dev.kobj, ds1307->nvram); | ||
910 | if (err) { | ||
911 | kfree(ds1307->nvram); | ||
912 | goto exit_nvram; | ||
902 | } | 913 | } |
914 | set_bit(HAS_NVRAM, &ds1307->flags); | ||
915 | dev_info(&client->dev, "%zu bytes nvram\n", ds1307->nvram->size); | ||
903 | } | 916 | } |
904 | 917 | ||
905 | return 0; | 918 | return 0; |
906 | 919 | ||
920 | exit_nvram: | ||
907 | exit_irq: | 921 | exit_irq: |
908 | rtc_device_unregister(ds1307->rtc); | 922 | rtc_device_unregister(ds1307->rtc); |
909 | exit_free: | 923 | exit_free: |
@@ -913,15 +927,17 @@ exit_free: | |||
913 | 927 | ||
914 | static int __devexit ds1307_remove(struct i2c_client *client) | 928 | static int __devexit ds1307_remove(struct i2c_client *client) |
915 | { | 929 | { |
916 | struct ds1307 *ds1307 = i2c_get_clientdata(client); | 930 | struct ds1307 *ds1307 = i2c_get_clientdata(client); |
917 | 931 | ||
918 | if (test_and_clear_bit(HAS_ALARM, &ds1307->flags)) { | 932 | if (test_and_clear_bit(HAS_ALARM, &ds1307->flags)) { |
919 | free_irq(client->irq, client); | 933 | free_irq(client->irq, client); |
920 | cancel_work_sync(&ds1307->work); | 934 | cancel_work_sync(&ds1307->work); |
921 | } | 935 | } |
922 | 936 | ||
923 | if (test_and_clear_bit(HAS_NVRAM, &ds1307->flags)) | 937 | if (test_and_clear_bit(HAS_NVRAM, &ds1307->flags)) { |
924 | sysfs_remove_bin_file(&client->dev.kobj, &nvram); | 938 | sysfs_remove_bin_file(&client->dev.kobj, ds1307->nvram); |
939 | kfree(ds1307->nvram); | ||
940 | } | ||
925 | 941 | ||
926 | rtc_device_unregister(ds1307->rtc); | 942 | rtc_device_unregister(ds1307->rtc); |
927 | kfree(ds1307); | 943 | kfree(ds1307); |
@@ -938,17 +954,7 @@ static struct i2c_driver ds1307_driver = { | |||
938 | .id_table = ds1307_id, | 954 | .id_table = ds1307_id, |
939 | }; | 955 | }; |
940 | 956 | ||
941 | static int __init ds1307_init(void) | 957 | module_i2c_driver(ds1307_driver); |
942 | { | ||
943 | return i2c_add_driver(&ds1307_driver); | ||
944 | } | ||
945 | module_init(ds1307_init); | ||
946 | |||
947 | static void __exit ds1307_exit(void) | ||
948 | { | ||
949 | i2c_del_driver(&ds1307_driver); | ||
950 | } | ||
951 | module_exit(ds1307_exit); | ||
952 | 958 | ||
953 | MODULE_DESCRIPTION("RTC driver for DS1307 and similar chips"); | 959 | MODULE_DESCRIPTION("RTC driver for DS1307 and similar chips"); |
954 | MODULE_LICENSE("GPL"); | 960 | MODULE_LICENSE("GPL"); |
diff --git a/drivers/rtc/rtc-ds1374.c b/drivers/rtc/rtc-ds1374.c index e6e71deb188f..966316088b7f 100644 --- a/drivers/rtc/rtc-ds1374.c +++ b/drivers/rtc/rtc-ds1374.c | |||
@@ -446,18 +446,7 @@ static struct i2c_driver ds1374_driver = { | |||
446 | .id_table = ds1374_id, | 446 | .id_table = ds1374_id, |
447 | }; | 447 | }; |
448 | 448 | ||
449 | static int __init ds1374_init(void) | 449 | module_i2c_driver(ds1374_driver); |
450 | { | ||
451 | return i2c_add_driver(&ds1374_driver); | ||
452 | } | ||
453 | |||
454 | static void __exit ds1374_exit(void) | ||
455 | { | ||
456 | i2c_del_driver(&ds1374_driver); | ||
457 | } | ||
458 | |||
459 | module_init(ds1374_init); | ||
460 | module_exit(ds1374_exit); | ||
461 | 450 | ||
462 | MODULE_AUTHOR("Scott Wood <scottwood@freescale.com>"); | 451 | MODULE_AUTHOR("Scott Wood <scottwood@freescale.com>"); |
463 | MODULE_DESCRIPTION("Maxim/Dallas DS1374 RTC Driver"); | 452 | MODULE_DESCRIPTION("Maxim/Dallas DS1374 RTC Driver"); |
diff --git a/drivers/rtc/rtc-ds1390.c b/drivers/rtc/rtc-ds1390.c index b038d2cfef26..b0a99e1b25be 100644 --- a/drivers/rtc/rtc-ds1390.c +++ b/drivers/rtc/rtc-ds1390.c | |||
@@ -175,17 +175,7 @@ static struct spi_driver ds1390_driver = { | |||
175 | .remove = __devexit_p(ds1390_remove), | 175 | .remove = __devexit_p(ds1390_remove), |
176 | }; | 176 | }; |
177 | 177 | ||
178 | static __init int ds1390_init(void) | 178 | module_spi_driver(ds1390_driver); |
179 | { | ||
180 | return spi_register_driver(&ds1390_driver); | ||
181 | } | ||
182 | module_init(ds1390_init); | ||
183 | |||
184 | static __exit void ds1390_exit(void) | ||
185 | { | ||
186 | spi_unregister_driver(&ds1390_driver); | ||
187 | } | ||
188 | module_exit(ds1390_exit); | ||
189 | 179 | ||
190 | MODULE_DESCRIPTION("Dallas/Maxim DS1390/93/94 SPI RTC driver"); | 180 | MODULE_DESCRIPTION("Dallas/Maxim DS1390/93/94 SPI RTC driver"); |
191 | MODULE_AUTHOR("Mark Jackson <mpfj@mimc.co.uk>"); | 181 | MODULE_AUTHOR("Mark Jackson <mpfj@mimc.co.uk>"); |
diff --git a/drivers/rtc/rtc-ds1511.c b/drivers/rtc/rtc-ds1511.c index 761f36bc83a9..1f675f5294f5 100644 --- a/drivers/rtc/rtc-ds1511.c +++ b/drivers/rtc/rtc-ds1511.c | |||
@@ -532,7 +532,7 @@ ds1511_rtc_probe(struct platform_device *pdev) | |||
532 | if (pdata->irq > 0) { | 532 | if (pdata->irq > 0) { |
533 | rtc_read(RTC_CMD1); | 533 | rtc_read(RTC_CMD1); |
534 | if (devm_request_irq(&pdev->dev, pdata->irq, ds1511_interrupt, | 534 | if (devm_request_irq(&pdev->dev, pdata->irq, ds1511_interrupt, |
535 | IRQF_DISABLED | IRQF_SHARED, pdev->name, pdev) < 0) { | 535 | IRQF_SHARED, pdev->name, pdev) < 0) { |
536 | 536 | ||
537 | dev_warn(&pdev->dev, "interrupt not available.\n"); | 537 | dev_warn(&pdev->dev, "interrupt not available.\n"); |
538 | pdata->irq = 0; | 538 | pdata->irq = 0; |
diff --git a/drivers/rtc/rtc-ds1553.c b/drivers/rtc/rtc-ds1553.c index 6f0a1b530f2e..6ccedbbf923c 100644 --- a/drivers/rtc/rtc-ds1553.c +++ b/drivers/rtc/rtc-ds1553.c | |||
@@ -320,7 +320,7 @@ static int __devinit ds1553_rtc_probe(struct platform_device *pdev) | |||
320 | writeb(0, ioaddr + RTC_INTERRUPTS); | 320 | writeb(0, ioaddr + RTC_INTERRUPTS); |
321 | if (devm_request_irq(&pdev->dev, pdata->irq, | 321 | if (devm_request_irq(&pdev->dev, pdata->irq, |
322 | ds1553_rtc_interrupt, | 322 | ds1553_rtc_interrupt, |
323 | IRQF_DISABLED, pdev->name, pdev) < 0) { | 323 | 0, pdev->name, pdev) < 0) { |
324 | dev_warn(&pdev->dev, "interrupt not available.\n"); | 324 | dev_warn(&pdev->dev, "interrupt not available.\n"); |
325 | pdata->irq = 0; | 325 | pdata->irq = 0; |
326 | } | 326 | } |
diff --git a/drivers/rtc/rtc-ds1672.c b/drivers/rtc/rtc-ds1672.c index a319402a5447..7fa67d0df172 100644 --- a/drivers/rtc/rtc-ds1672.c +++ b/drivers/rtc/rtc-ds1672.c | |||
@@ -202,20 +202,9 @@ static struct i2c_driver ds1672_driver = { | |||
202 | .id_table = ds1672_id, | 202 | .id_table = ds1672_id, |
203 | }; | 203 | }; |
204 | 204 | ||
205 | static int __init ds1672_init(void) | 205 | module_i2c_driver(ds1672_driver); |
206 | { | ||
207 | return i2c_add_driver(&ds1672_driver); | ||
208 | } | ||
209 | |||
210 | static void __exit ds1672_exit(void) | ||
211 | { | ||
212 | i2c_del_driver(&ds1672_driver); | ||
213 | } | ||
214 | 206 | ||
215 | MODULE_AUTHOR("Alessandro Zummo <a.zummo@towertech.it>"); | 207 | MODULE_AUTHOR("Alessandro Zummo <a.zummo@towertech.it>"); |
216 | MODULE_DESCRIPTION("Dallas/Maxim DS1672 timekeeper driver"); | 208 | MODULE_DESCRIPTION("Dallas/Maxim DS1672 timekeeper driver"); |
217 | MODULE_LICENSE("GPL"); | 209 | MODULE_LICENSE("GPL"); |
218 | MODULE_VERSION(DRV_VERSION); | 210 | MODULE_VERSION(DRV_VERSION); |
219 | |||
220 | module_init(ds1672_init); | ||
221 | module_exit(ds1672_exit); | ||
diff --git a/drivers/rtc/rtc-ds3232.c b/drivers/rtc/rtc-ds3232.c index 27b7bf672ac6..e1945095814e 100644 --- a/drivers/rtc/rtc-ds3232.c +++ b/drivers/rtc/rtc-ds3232.c | |||
@@ -473,18 +473,7 @@ static struct i2c_driver ds3232_driver = { | |||
473 | .id_table = ds3232_id, | 473 | .id_table = ds3232_id, |
474 | }; | 474 | }; |
475 | 475 | ||
476 | static int __init ds3232_init(void) | 476 | module_i2c_driver(ds3232_driver); |
477 | { | ||
478 | return i2c_add_driver(&ds3232_driver); | ||
479 | } | ||
480 | |||
481 | static void __exit ds3232_exit(void) | ||
482 | { | ||
483 | i2c_del_driver(&ds3232_driver); | ||
484 | } | ||
485 | |||
486 | module_init(ds3232_init); | ||
487 | module_exit(ds3232_exit); | ||
488 | 477 | ||
489 | MODULE_AUTHOR("Srikanth Srinivasan <srikanth.srinivasan@freescale.com>"); | 478 | MODULE_AUTHOR("Srikanth Srinivasan <srikanth.srinivasan@freescale.com>"); |
490 | MODULE_DESCRIPTION("Maxim/Dallas DS3232 RTC Driver"); | 479 | MODULE_DESCRIPTION("Maxim/Dallas DS3232 RTC Driver"); |
diff --git a/drivers/rtc/rtc-ds3234.c b/drivers/rtc/rtc-ds3234.c index bbd26228f532..fda707926f02 100644 --- a/drivers/rtc/rtc-ds3234.c +++ b/drivers/rtc/rtc-ds3234.c | |||
@@ -173,17 +173,7 @@ static struct spi_driver ds3234_driver = { | |||
173 | .remove = __devexit_p(ds3234_remove), | 173 | .remove = __devexit_p(ds3234_remove), |
174 | }; | 174 | }; |
175 | 175 | ||
176 | static __init int ds3234_init(void) | 176 | module_spi_driver(ds3234_driver); |
177 | { | ||
178 | return spi_register_driver(&ds3234_driver); | ||
179 | } | ||
180 | module_init(ds3234_init); | ||
181 | |||
182 | static __exit void ds3234_exit(void) | ||
183 | { | ||
184 | spi_unregister_driver(&ds3234_driver); | ||
185 | } | ||
186 | module_exit(ds3234_exit); | ||
187 | 177 | ||
188 | MODULE_DESCRIPTION("DS3234 SPI RTC driver"); | 178 | MODULE_DESCRIPTION("DS3234 SPI RTC driver"); |
189 | MODULE_AUTHOR("Dennis Aberilla <denzzzhome@yahoo.com>"); | 179 | MODULE_AUTHOR("Dennis Aberilla <denzzzhome@yahoo.com>"); |
diff --git a/drivers/rtc/rtc-em3027.c b/drivers/rtc/rtc-em3027.c index 8414dea5fb14..0104ea7ebe50 100644 --- a/drivers/rtc/rtc-em3027.c +++ b/drivers/rtc/rtc-em3027.c | |||
@@ -144,19 +144,8 @@ static struct i2c_driver em3027_driver = { | |||
144 | .id_table = em3027_id, | 144 | .id_table = em3027_id, |
145 | }; | 145 | }; |
146 | 146 | ||
147 | static int __init em3027_init(void) | 147 | module_i2c_driver(em3027_driver); |
148 | { | ||
149 | return i2c_add_driver(&em3027_driver); | ||
150 | } | ||
151 | |||
152 | static void __exit em3027_exit(void) | ||
153 | { | ||
154 | i2c_del_driver(&em3027_driver); | ||
155 | } | ||
156 | 148 | ||
157 | MODULE_AUTHOR("Mike Rapoport <mike@compulab.co.il>"); | 149 | MODULE_AUTHOR("Mike Rapoport <mike@compulab.co.il>"); |
158 | MODULE_DESCRIPTION("EM Microelectronic EM3027 RTC driver"); | 150 | MODULE_DESCRIPTION("EM Microelectronic EM3027 RTC driver"); |
159 | MODULE_LICENSE("GPL"); | 151 | MODULE_LICENSE("GPL"); |
160 | |||
161 | module_init(em3027_init); | ||
162 | module_exit(em3027_exit); | ||
diff --git a/drivers/rtc/rtc-fm3130.c b/drivers/rtc/rtc-fm3130.c index 4cf2e70c5078..86b6ecce99f0 100644 --- a/drivers/rtc/rtc-fm3130.c +++ b/drivers/rtc/rtc-fm3130.c | |||
@@ -565,17 +565,7 @@ static struct i2c_driver fm3130_driver = { | |||
565 | .id_table = fm3130_id, | 565 | .id_table = fm3130_id, |
566 | }; | 566 | }; |
567 | 567 | ||
568 | static int __init fm3130_init(void) | 568 | module_i2c_driver(fm3130_driver); |
569 | { | ||
570 | return i2c_add_driver(&fm3130_driver); | ||
571 | } | ||
572 | module_init(fm3130_init); | ||
573 | |||
574 | static void __exit fm3130_exit(void) | ||
575 | { | ||
576 | i2c_del_driver(&fm3130_driver); | ||
577 | } | ||
578 | module_exit(fm3130_exit); | ||
579 | 569 | ||
580 | MODULE_DESCRIPTION("RTC driver for FM3130"); | 570 | MODULE_DESCRIPTION("RTC driver for FM3130"); |
581 | MODULE_AUTHOR("Sergey Lapin <slapin@ossfans.org>"); | 571 | MODULE_AUTHOR("Sergey Lapin <slapin@ossfans.org>"); |
diff --git a/drivers/rtc/rtc-isl12022.c b/drivers/rtc/rtc-isl12022.c index 6186833973ee..1850104705c0 100644 --- a/drivers/rtc/rtc-isl12022.c +++ b/drivers/rtc/rtc-isl12022.c | |||
@@ -309,18 +309,7 @@ static struct i2c_driver isl12022_driver = { | |||
309 | .id_table = isl12022_id, | 309 | .id_table = isl12022_id, |
310 | }; | 310 | }; |
311 | 311 | ||
312 | static int __init isl12022_init(void) | 312 | module_i2c_driver(isl12022_driver); |
313 | { | ||
314 | return i2c_add_driver(&isl12022_driver); | ||
315 | } | ||
316 | |||
317 | static void __exit isl12022_exit(void) | ||
318 | { | ||
319 | i2c_del_driver(&isl12022_driver); | ||
320 | } | ||
321 | |||
322 | module_init(isl12022_init); | ||
323 | module_exit(isl12022_exit); | ||
324 | 313 | ||
325 | MODULE_AUTHOR("roman.fietze@telemotive.de"); | 314 | MODULE_AUTHOR("roman.fietze@telemotive.de"); |
326 | MODULE_DESCRIPTION("ISL 12022 RTC driver"); | 315 | MODULE_DESCRIPTION("ISL 12022 RTC driver"); |
diff --git a/drivers/rtc/rtc-isl1208.c b/drivers/rtc/rtc-isl1208.c index da8beb8cae51..dd2aeee6c66a 100644 --- a/drivers/rtc/rtc-isl1208.c +++ b/drivers/rtc/rtc-isl1208.c | |||
@@ -710,22 +710,9 @@ static struct i2c_driver isl1208_driver = { | |||
710 | .id_table = isl1208_id, | 710 | .id_table = isl1208_id, |
711 | }; | 711 | }; |
712 | 712 | ||
713 | static int __init | 713 | module_i2c_driver(isl1208_driver); |
714 | isl1208_init(void) | ||
715 | { | ||
716 | return i2c_add_driver(&isl1208_driver); | ||
717 | } | ||
718 | |||
719 | static void __exit | ||
720 | isl1208_exit(void) | ||
721 | { | ||
722 | i2c_del_driver(&isl1208_driver); | ||
723 | } | ||
724 | 714 | ||
725 | MODULE_AUTHOR("Herbert Valerio Riedel <hvr@gnu.org>"); | 715 | MODULE_AUTHOR("Herbert Valerio Riedel <hvr@gnu.org>"); |
726 | MODULE_DESCRIPTION("Intersil ISL1208 RTC driver"); | 716 | MODULE_DESCRIPTION("Intersil ISL1208 RTC driver"); |
727 | MODULE_LICENSE("GPL"); | 717 | MODULE_LICENSE("GPL"); |
728 | MODULE_VERSION(DRV_VERSION); | 718 | MODULE_VERSION(DRV_VERSION); |
729 | |||
730 | module_init(isl1208_init); | ||
731 | module_exit(isl1208_exit); | ||
diff --git a/drivers/rtc/rtc-lpc32xx.c b/drivers/rtc/rtc-lpc32xx.c index ecc1713b2b4f..63c72189c64b 100644 --- a/drivers/rtc/rtc-lpc32xx.c +++ b/drivers/rtc/rtc-lpc32xx.c | |||
@@ -287,7 +287,7 @@ static int __devinit lpc32xx_rtc_probe(struct platform_device *pdev) | |||
287 | if (rtc->irq >= 0) { | 287 | if (rtc->irq >= 0) { |
288 | if (devm_request_irq(&pdev->dev, rtc->irq, | 288 | if (devm_request_irq(&pdev->dev, rtc->irq, |
289 | lpc32xx_rtc_alarm_interrupt, | 289 | lpc32xx_rtc_alarm_interrupt, |
290 | IRQF_DISABLED, pdev->name, rtc) < 0) { | 290 | 0, pdev->name, rtc) < 0) { |
291 | dev_warn(&pdev->dev, "Can't request interrupt.\n"); | 291 | dev_warn(&pdev->dev, "Can't request interrupt.\n"); |
292 | rtc->irq = -1; | 292 | rtc->irq = -1; |
293 | } else { | 293 | } else { |
diff --git a/drivers/rtc/rtc-ls1x.c b/drivers/rtc/rtc-ls1x.c new file mode 100644 index 000000000000..07e81c5f8247 --- /dev/null +++ b/drivers/rtc/rtc-ls1x.c | |||
@@ -0,0 +1,210 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2011 Zhao Zhang <zhzhl555@gmail.com> | ||
3 | * | ||
4 | * Derived from driver/rtc/rtc-au1xxx.c | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify it | ||
7 | * under the terms of the GNU General Public License as published by the | ||
8 | * Free Software Foundation; either version 2 of the License, or (at your | ||
9 | * option) any later version. | ||
10 | */ | ||
11 | |||
12 | #include <linux/module.h> | ||
13 | #include <linux/kernel.h> | ||
14 | #include <linux/rtc.h> | ||
15 | #include <linux/init.h> | ||
16 | #include <linux/platform_device.h> | ||
17 | #include <linux/delay.h> | ||
18 | #include <linux/types.h> | ||
19 | #include <linux/io.h> | ||
20 | #include <asm/mach-loongson1/loongson1.h> | ||
21 | |||
22 | #define LS1X_RTC_REG_OFFSET (LS1X_RTC_BASE + 0x20) | ||
23 | #define LS1X_RTC_REGS(x) \ | ||
24 | ((void __iomem *)KSEG1ADDR(LS1X_RTC_REG_OFFSET + (x))) | ||
25 | |||
26 | /*RTC programmable counters 0 and 1*/ | ||
27 | #define SYS_COUNTER_CNTRL (LS1X_RTC_REGS(0x20)) | ||
28 | #define SYS_CNTRL_ERS (1 << 23) | ||
29 | #define SYS_CNTRL_RTS (1 << 20) | ||
30 | #define SYS_CNTRL_RM2 (1 << 19) | ||
31 | #define SYS_CNTRL_RM1 (1 << 18) | ||
32 | #define SYS_CNTRL_RM0 (1 << 17) | ||
33 | #define SYS_CNTRL_RS (1 << 16) | ||
34 | #define SYS_CNTRL_BP (1 << 14) | ||
35 | #define SYS_CNTRL_REN (1 << 13) | ||
36 | #define SYS_CNTRL_BRT (1 << 12) | ||
37 | #define SYS_CNTRL_TEN (1 << 11) | ||
38 | #define SYS_CNTRL_BTT (1 << 10) | ||
39 | #define SYS_CNTRL_E0 (1 << 8) | ||
40 | #define SYS_CNTRL_ETS (1 << 7) | ||
41 | #define SYS_CNTRL_32S (1 << 5) | ||
42 | #define SYS_CNTRL_TTS (1 << 4) | ||
43 | #define SYS_CNTRL_TM2 (1 << 3) | ||
44 | #define SYS_CNTRL_TM1 (1 << 2) | ||
45 | #define SYS_CNTRL_TM0 (1 << 1) | ||
46 | #define SYS_CNTRL_TS (1 << 0) | ||
47 | |||
48 | /* Programmable Counter 0 Registers */ | ||
49 | #define SYS_TOYTRIM (LS1X_RTC_REGS(0)) | ||
50 | #define SYS_TOYWRITE0 (LS1X_RTC_REGS(4)) | ||
51 | #define SYS_TOYWRITE1 (LS1X_RTC_REGS(8)) | ||
52 | #define SYS_TOYREAD0 (LS1X_RTC_REGS(0xC)) | ||
53 | #define SYS_TOYREAD1 (LS1X_RTC_REGS(0x10)) | ||
54 | #define SYS_TOYMATCH0 (LS1X_RTC_REGS(0x14)) | ||
55 | #define SYS_TOYMATCH1 (LS1X_RTC_REGS(0x18)) | ||
56 | #define SYS_TOYMATCH2 (LS1X_RTC_REGS(0x1C)) | ||
57 | |||
58 | /* Programmable Counter 1 Registers */ | ||
59 | #define SYS_RTCTRIM (LS1X_RTC_REGS(0x40)) | ||
60 | #define SYS_RTCWRITE0 (LS1X_RTC_REGS(0x44)) | ||
61 | #define SYS_RTCREAD0 (LS1X_RTC_REGS(0x48)) | ||
62 | #define SYS_RTCMATCH0 (LS1X_RTC_REGS(0x4C)) | ||
63 | #define SYS_RTCMATCH1 (LS1X_RTC_REGS(0x50)) | ||
64 | #define SYS_RTCMATCH2 (LS1X_RTC_REGS(0x54)) | ||
65 | |||
66 | #define LS1X_SEC_OFFSET (4) | ||
67 | #define LS1X_MIN_OFFSET (10) | ||
68 | #define LS1X_HOUR_OFFSET (16) | ||
69 | #define LS1X_DAY_OFFSET (21) | ||
70 | #define LS1X_MONTH_OFFSET (26) | ||
71 | |||
72 | |||
73 | #define LS1X_SEC_MASK (0x3f) | ||
74 | #define LS1X_MIN_MASK (0x3f) | ||
75 | #define LS1X_HOUR_MASK (0x1f) | ||
76 | #define LS1X_DAY_MASK (0x1f) | ||
77 | #define LS1X_MONTH_MASK (0x3f) | ||
78 | #define LS1X_YEAR_MASK (0xffffffff) | ||
79 | |||
80 | #define ls1x_get_sec(t) (((t) >> LS1X_SEC_OFFSET) & LS1X_SEC_MASK) | ||
81 | #define ls1x_get_min(t) (((t) >> LS1X_MIN_OFFSET) & LS1X_MIN_MASK) | ||
82 | #define ls1x_get_hour(t) (((t) >> LS1X_HOUR_OFFSET) & LS1X_HOUR_MASK) | ||
83 | #define ls1x_get_day(t) (((t) >> LS1X_DAY_OFFSET) & LS1X_DAY_MASK) | ||
84 | #define ls1x_get_month(t) (((t) >> LS1X_MONTH_OFFSET) & LS1X_MONTH_MASK) | ||
85 | |||
86 | #define RTC_CNTR_OK (SYS_CNTRL_E0 | SYS_CNTRL_32S) | ||
87 | |||
88 | static int ls1x_rtc_read_time(struct device *dev, struct rtc_time *rtm) | ||
89 | { | ||
90 | unsigned long v, t; | ||
91 | |||
92 | v = readl(SYS_TOYREAD0); | ||
93 | t = readl(SYS_TOYREAD1); | ||
94 | |||
95 | memset(rtm, 0, sizeof(struct rtc_time)); | ||
96 | t = mktime((t & LS1X_YEAR_MASK), ls1x_get_month(v), | ||
97 | ls1x_get_day(v), ls1x_get_hour(v), | ||
98 | ls1x_get_min(v), ls1x_get_sec(v)); | ||
99 | rtc_time_to_tm(t, rtm); | ||
100 | |||
101 | return rtc_valid_tm(rtm); | ||
102 | } | ||
103 | |||
104 | static int ls1x_rtc_set_time(struct device *dev, struct rtc_time *rtm) | ||
105 | { | ||
106 | unsigned long v, t, c; | ||
107 | int ret = -ETIMEDOUT; | ||
108 | |||
109 | v = ((rtm->tm_mon + 1) << LS1X_MONTH_OFFSET) | ||
110 | | (rtm->tm_mday << LS1X_DAY_OFFSET) | ||
111 | | (rtm->tm_hour << LS1X_HOUR_OFFSET) | ||
112 | | (rtm->tm_min << LS1X_MIN_OFFSET) | ||
113 | | (rtm->tm_sec << LS1X_SEC_OFFSET); | ||
114 | |||
115 | writel(v, SYS_TOYWRITE0); | ||
116 | c = 0x10000; | ||
117 | /* add timeout check counter, for more safe */ | ||
118 | while ((readl(SYS_COUNTER_CNTRL) & SYS_CNTRL_TS) && --c) | ||
119 | usleep_range(1000, 3000); | ||
120 | |||
121 | if (!c) { | ||
122 | dev_err(dev, "set time timeout!\n"); | ||
123 | goto err; | ||
124 | } | ||
125 | |||
126 | t = rtm->tm_year + 1900; | ||
127 | writel(t, SYS_TOYWRITE1); | ||
128 | c = 0x10000; | ||
129 | while ((readl(SYS_COUNTER_CNTRL) & SYS_CNTRL_TS) && --c) | ||
130 | usleep_range(1000, 3000); | ||
131 | |||
132 | if (!c) { | ||
133 | dev_err(dev, "set time timeout!\n"); | ||
134 | goto err; | ||
135 | } | ||
136 | return 0; | ||
137 | err: | ||
138 | return ret; | ||
139 | } | ||
140 | |||
141 | static struct rtc_class_ops ls1x_rtc_ops = { | ||
142 | .read_time = ls1x_rtc_read_time, | ||
143 | .set_time = ls1x_rtc_set_time, | ||
144 | }; | ||
145 | |||
146 | static int __devinit ls1x_rtc_probe(struct platform_device *pdev) | ||
147 | { | ||
148 | struct rtc_device *rtcdev; | ||
149 | unsigned long v; | ||
150 | int ret; | ||
151 | |||
152 | v = readl(SYS_COUNTER_CNTRL); | ||
153 | if (!(v & RTC_CNTR_OK)) { | ||
154 | dev_err(&pdev->dev, "rtc counters not working\n"); | ||
155 | ret = -ENODEV; | ||
156 | goto err; | ||
157 | } | ||
158 | ret = -ETIMEDOUT; | ||
159 | /* set to 1 HZ if needed */ | ||
160 | if (readl(SYS_TOYTRIM) != 32767) { | ||
161 | v = 0x100000; | ||
162 | while ((readl(SYS_COUNTER_CNTRL) & SYS_CNTRL_TTS) && --v) | ||
163 | usleep_range(1000, 3000); | ||
164 | |||
165 | if (!v) { | ||
166 | dev_err(&pdev->dev, "time out\n"); | ||
167 | goto err; | ||
168 | } | ||
169 | writel(32767, SYS_TOYTRIM); | ||
170 | } | ||
171 | /* this loop coundn't be endless */ | ||
172 | while (readl(SYS_COUNTER_CNTRL) & SYS_CNTRL_TTS) | ||
173 | usleep_range(1000, 3000); | ||
174 | |||
175 | rtcdev = rtc_device_register("ls1x-rtc", &pdev->dev, | ||
176 | &ls1x_rtc_ops , THIS_MODULE); | ||
177 | if (IS_ERR(rtcdev)) { | ||
178 | ret = PTR_ERR(rtcdev); | ||
179 | goto err; | ||
180 | } | ||
181 | |||
182 | platform_set_drvdata(pdev, rtcdev); | ||
183 | return 0; | ||
184 | err: | ||
185 | return ret; | ||
186 | } | ||
187 | |||
188 | static int __devexit ls1x_rtc_remove(struct platform_device *pdev) | ||
189 | { | ||
190 | struct rtc_device *rtcdev = platform_get_drvdata(pdev); | ||
191 | |||
192 | rtc_device_unregister(rtcdev); | ||
193 | platform_set_drvdata(pdev, NULL); | ||
194 | |||
195 | return 0; | ||
196 | } | ||
197 | |||
198 | static struct platform_driver ls1x_rtc_driver = { | ||
199 | .driver = { | ||
200 | .name = "ls1x-rtc", | ||
201 | .owner = THIS_MODULE, | ||
202 | }, | ||
203 | .remove = __devexit_p(ls1x_rtc_remove), | ||
204 | .probe = ls1x_rtc_probe, | ||
205 | }; | ||
206 | |||
207 | module_platform_driver(ls1x_rtc_driver); | ||
208 | |||
209 | MODULE_AUTHOR("zhao zhang <zhzhl555@gmail.com>"); | ||
210 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/rtc/rtc-m41t80.c b/drivers/rtc/rtc-m41t80.c index 64aedd8cc095..4e0f84af99a7 100644 --- a/drivers/rtc/rtc-m41t80.c +++ b/drivers/rtc/rtc-m41t80.c | |||
@@ -900,20 +900,9 @@ static struct i2c_driver m41t80_driver = { | |||
900 | .id_table = m41t80_id, | 900 | .id_table = m41t80_id, |
901 | }; | 901 | }; |
902 | 902 | ||
903 | static int __init m41t80_rtc_init(void) | 903 | module_i2c_driver(m41t80_driver); |
904 | { | ||
905 | return i2c_add_driver(&m41t80_driver); | ||
906 | } | ||
907 | |||
908 | static void __exit m41t80_rtc_exit(void) | ||
909 | { | ||
910 | i2c_del_driver(&m41t80_driver); | ||
911 | } | ||
912 | 904 | ||
913 | MODULE_AUTHOR("Alexander Bigga <ab@mycable.de>"); | 905 | MODULE_AUTHOR("Alexander Bigga <ab@mycable.de>"); |
914 | MODULE_DESCRIPTION("ST Microelectronics M41T80 series RTC I2C Client Driver"); | 906 | MODULE_DESCRIPTION("ST Microelectronics M41T80 series RTC I2C Client Driver"); |
915 | MODULE_LICENSE("GPL"); | 907 | MODULE_LICENSE("GPL"); |
916 | MODULE_VERSION(DRV_VERSION); | 908 | MODULE_VERSION(DRV_VERSION); |
917 | |||
918 | module_init(m41t80_rtc_init); | ||
919 | module_exit(m41t80_rtc_exit); | ||
diff --git a/drivers/rtc/rtc-m41t93.c b/drivers/rtc/rtc-m41t93.c index ef71132ff205..10f1c29436ec 100644 --- a/drivers/rtc/rtc-m41t93.c +++ b/drivers/rtc/rtc-m41t93.c | |||
@@ -206,17 +206,7 @@ static struct spi_driver m41t93_driver = { | |||
206 | .remove = __devexit_p(m41t93_remove), | 206 | .remove = __devexit_p(m41t93_remove), |
207 | }; | 207 | }; |
208 | 208 | ||
209 | static __init int m41t93_init(void) | 209 | module_spi_driver(m41t93_driver); |
210 | { | ||
211 | return spi_register_driver(&m41t93_driver); | ||
212 | } | ||
213 | module_init(m41t93_init); | ||
214 | |||
215 | static __exit void m41t93_exit(void) | ||
216 | { | ||
217 | spi_unregister_driver(&m41t93_driver); | ||
218 | } | ||
219 | module_exit(m41t93_exit); | ||
220 | 210 | ||
221 | MODULE_AUTHOR("Nikolaus Voss <n.voss@weinmann.de>"); | 211 | MODULE_AUTHOR("Nikolaus Voss <n.voss@weinmann.de>"); |
222 | MODULE_DESCRIPTION("Driver for ST M41T93 SPI RTC"); | 212 | MODULE_DESCRIPTION("Driver for ST M41T93 SPI RTC"); |
diff --git a/drivers/rtc/rtc-m41t94.c b/drivers/rtc/rtc-m41t94.c index 2a4721f61797..6e78193e026b 100644 --- a/drivers/rtc/rtc-m41t94.c +++ b/drivers/rtc/rtc-m41t94.c | |||
@@ -153,19 +153,7 @@ static struct spi_driver m41t94_driver = { | |||
153 | .remove = __devexit_p(m41t94_remove), | 153 | .remove = __devexit_p(m41t94_remove), |
154 | }; | 154 | }; |
155 | 155 | ||
156 | static __init int m41t94_init(void) | 156 | module_spi_driver(m41t94_driver); |
157 | { | ||
158 | return spi_register_driver(&m41t94_driver); | ||
159 | } | ||
160 | |||
161 | module_init(m41t94_init); | ||
162 | |||
163 | static __exit void m41t94_exit(void) | ||
164 | { | ||
165 | spi_unregister_driver(&m41t94_driver); | ||
166 | } | ||
167 | |||
168 | module_exit(m41t94_exit); | ||
169 | 157 | ||
170 | MODULE_AUTHOR("Kim B. Heino <Kim.Heino@bluegiga.com>"); | 158 | MODULE_AUTHOR("Kim B. Heino <Kim.Heino@bluegiga.com>"); |
171 | MODULE_DESCRIPTION("Driver for ST M41T94 SPI RTC"); | 159 | MODULE_DESCRIPTION("Driver for ST M41T94 SPI RTC"); |
diff --git a/drivers/rtc/rtc-max6900.c b/drivers/rtc/rtc-max6900.c index 486142c2637a..a00e33204b91 100644 --- a/drivers/rtc/rtc-max6900.c +++ b/drivers/rtc/rtc-max6900.c | |||
@@ -261,20 +261,9 @@ static struct i2c_driver max6900_driver = { | |||
261 | .id_table = max6900_id, | 261 | .id_table = max6900_id, |
262 | }; | 262 | }; |
263 | 263 | ||
264 | static int __init max6900_init(void) | 264 | module_i2c_driver(max6900_driver); |
265 | { | ||
266 | return i2c_add_driver(&max6900_driver); | ||
267 | } | ||
268 | |||
269 | static void __exit max6900_exit(void) | ||
270 | { | ||
271 | i2c_del_driver(&max6900_driver); | ||
272 | } | ||
273 | 265 | ||
274 | MODULE_DESCRIPTION("Maxim MAX6900 RTC driver"); | 266 | MODULE_DESCRIPTION("Maxim MAX6900 RTC driver"); |
275 | MODULE_AUTHOR("Dale Farnsworth <dale@farnsworth.org>"); | 267 | MODULE_AUTHOR("Dale Farnsworth <dale@farnsworth.org>"); |
276 | MODULE_LICENSE("GPL"); | 268 | MODULE_LICENSE("GPL"); |
277 | MODULE_VERSION(DRV_VERSION); | 269 | MODULE_VERSION(DRV_VERSION); |
278 | |||
279 | module_init(max6900_init); | ||
280 | module_exit(max6900_exit); | ||
diff --git a/drivers/rtc/rtc-max6902.c b/drivers/rtc/rtc-max6902.c index 1f6b3cc58e8a..36c74d22e8b5 100644 --- a/drivers/rtc/rtc-max6902.c +++ b/drivers/rtc/rtc-max6902.c | |||
@@ -160,17 +160,7 @@ static struct spi_driver max6902_driver = { | |||
160 | .remove = __devexit_p(max6902_remove), | 160 | .remove = __devexit_p(max6902_remove), |
161 | }; | 161 | }; |
162 | 162 | ||
163 | static __init int max6902_init(void) | 163 | module_spi_driver(max6902_driver); |
164 | { | ||
165 | return spi_register_driver(&max6902_driver); | ||
166 | } | ||
167 | module_init(max6902_init); | ||
168 | |||
169 | static __exit void max6902_exit(void) | ||
170 | { | ||
171 | spi_unregister_driver(&max6902_driver); | ||
172 | } | ||
173 | module_exit(max6902_exit); | ||
174 | 164 | ||
175 | MODULE_DESCRIPTION ("max6902 spi RTC driver"); | 165 | MODULE_DESCRIPTION ("max6902 spi RTC driver"); |
176 | MODULE_AUTHOR ("Raphael Assenat"); | 166 | MODULE_AUTHOR ("Raphael Assenat"); |
diff --git a/drivers/rtc/rtc-max8925.c b/drivers/rtc/rtc-max8925.c index 2d71943bc436..1459055a83aa 100644 --- a/drivers/rtc/rtc-max8925.c +++ b/drivers/rtc/rtc-max8925.c | |||
@@ -193,10 +193,17 @@ static int max8925_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm) | |||
193 | ret = max8925_reg_read(info->rtc, MAX8925_RTC_IRQ_MASK); | 193 | ret = max8925_reg_read(info->rtc, MAX8925_RTC_IRQ_MASK); |
194 | if (ret < 0) | 194 | if (ret < 0) |
195 | goto out; | 195 | goto out; |
196 | if ((ret & ALARM0_IRQ) == 0) | 196 | if (ret & ALARM0_IRQ) { |
197 | alrm->enabled = 1; | ||
198 | else | ||
199 | alrm->enabled = 0; | 197 | alrm->enabled = 0; |
198 | } else { | ||
199 | ret = max8925_reg_read(info->rtc, MAX8925_ALARM0_CNTL); | ||
200 | if (ret < 0) | ||
201 | goto out; | ||
202 | if (!ret) | ||
203 | alrm->enabled = 0; | ||
204 | else | ||
205 | alrm->enabled = 1; | ||
206 | } | ||
200 | ret = max8925_reg_read(info->rtc, MAX8925_RTC_STATUS); | 207 | ret = max8925_reg_read(info->rtc, MAX8925_RTC_STATUS); |
201 | if (ret < 0) | 208 | if (ret < 0) |
202 | goto out; | 209 | goto out; |
@@ -204,6 +211,7 @@ static int max8925_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm) | |||
204 | alrm->pending = 1; | 211 | alrm->pending = 1; |
205 | else | 212 | else |
206 | alrm->pending = 0; | 213 | alrm->pending = 0; |
214 | return 0; | ||
207 | out: | 215 | out: |
208 | return ret; | 216 | return ret; |
209 | } | 217 | } |
@@ -220,8 +228,11 @@ static int max8925_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm) | |||
220 | ret = max8925_bulk_write(info->rtc, MAX8925_ALARM0_SEC, TIME_NUM, buf); | 228 | ret = max8925_bulk_write(info->rtc, MAX8925_ALARM0_SEC, TIME_NUM, buf); |
221 | if (ret < 0) | 229 | if (ret < 0) |
222 | goto out; | 230 | goto out; |
223 | /* only enable alarm on year/month/day/hour/min/sec */ | 231 | if (alrm->enabled) |
224 | ret = max8925_reg_write(info->rtc, MAX8925_ALARM0_CNTL, 0x77); | 232 | /* only enable alarm on year/month/day/hour/min/sec */ |
233 | ret = max8925_reg_write(info->rtc, MAX8925_ALARM0_CNTL, 0x77); | ||
234 | else | ||
235 | ret = max8925_reg_write(info->rtc, MAX8925_ALARM0_CNTL, 0x0); | ||
225 | if (ret < 0) | 236 | if (ret < 0) |
226 | goto out; | 237 | goto out; |
227 | out: | 238 | out: |
diff --git a/drivers/rtc/rtc-mpc5121.c b/drivers/rtc/rtc-mpc5121.c index 9d3caccfc250..e954a759ba85 100644 --- a/drivers/rtc/rtc-mpc5121.c +++ b/drivers/rtc/rtc-mpc5121.c | |||
@@ -327,7 +327,7 @@ static int __devinit mpc5121_rtc_probe(struct platform_device *op) | |||
327 | dev_set_drvdata(&op->dev, rtc); | 327 | dev_set_drvdata(&op->dev, rtc); |
328 | 328 | ||
329 | rtc->irq = irq_of_parse_and_map(op->dev.of_node, 1); | 329 | rtc->irq = irq_of_parse_and_map(op->dev.of_node, 1); |
330 | err = request_irq(rtc->irq, mpc5121_rtc_handler, IRQF_DISABLED, | 330 | err = request_irq(rtc->irq, mpc5121_rtc_handler, 0, |
331 | "mpc5121-rtc", &op->dev); | 331 | "mpc5121-rtc", &op->dev); |
332 | if (err) { | 332 | if (err) { |
333 | dev_err(&op->dev, "%s: could not request irq: %i\n", | 333 | dev_err(&op->dev, "%s: could not request irq: %i\n", |
@@ -337,7 +337,7 @@ static int __devinit mpc5121_rtc_probe(struct platform_device *op) | |||
337 | 337 | ||
338 | rtc->irq_periodic = irq_of_parse_and_map(op->dev.of_node, 0); | 338 | rtc->irq_periodic = irq_of_parse_and_map(op->dev.of_node, 0); |
339 | err = request_irq(rtc->irq_periodic, mpc5121_rtc_handler_upd, | 339 | err = request_irq(rtc->irq_periodic, mpc5121_rtc_handler_upd, |
340 | IRQF_DISABLED, "mpc5121-rtc_upd", &op->dev); | 340 | 0, "mpc5121-rtc_upd", &op->dev); |
341 | if (err) { | 341 | if (err) { |
342 | dev_err(&op->dev, "%s: could not request irq: %i\n", | 342 | dev_err(&op->dev, "%s: could not request irq: %i\n", |
343 | __func__, rtc->irq_periodic); | 343 | __func__, rtc->irq_periodic); |
diff --git a/drivers/rtc/rtc-mrst.c b/drivers/rtc/rtc-mrst.c index 6cd6c7235344..f51719bf4a75 100644 --- a/drivers/rtc/rtc-mrst.c +++ b/drivers/rtc/rtc-mrst.c | |||
@@ -366,7 +366,7 @@ vrtc_mrst_do_probe(struct device *dev, struct resource *iomem, int rtc_irq) | |||
366 | 366 | ||
367 | if (rtc_irq) { | 367 | if (rtc_irq) { |
368 | retval = request_irq(rtc_irq, mrst_rtc_irq, | 368 | retval = request_irq(rtc_irq, mrst_rtc_irq, |
369 | IRQF_DISABLED, dev_name(&mrst_rtc.rtc->dev), | 369 | 0, dev_name(&mrst_rtc.rtc->dev), |
370 | mrst_rtc.rtc); | 370 | mrst_rtc.rtc); |
371 | if (retval < 0) { | 371 | if (retval < 0) { |
372 | dev_dbg(dev, "IRQ %d is already in use, err %d\n", | 372 | dev_dbg(dev, "IRQ %d is already in use, err %d\n", |
diff --git a/drivers/rtc/rtc-mv.c b/drivers/rtc/rtc-mv.c index 768e2edb9678..1300962486d1 100644 --- a/drivers/rtc/rtc-mv.c +++ b/drivers/rtc/rtc-mv.c | |||
@@ -273,7 +273,7 @@ static int __devinit mv_rtc_probe(struct platform_device *pdev) | |||
273 | if (pdata->irq >= 0) { | 273 | if (pdata->irq >= 0) { |
274 | writel(0, pdata->ioaddr + RTC_ALARM_INTERRUPT_MASK_REG_OFFS); | 274 | writel(0, pdata->ioaddr + RTC_ALARM_INTERRUPT_MASK_REG_OFFS); |
275 | if (devm_request_irq(&pdev->dev, pdata->irq, mv_rtc_interrupt, | 275 | if (devm_request_irq(&pdev->dev, pdata->irq, mv_rtc_interrupt, |
276 | IRQF_DISABLED | IRQF_SHARED, | 276 | IRQF_SHARED, |
277 | pdev->name, pdata) < 0) { | 277 | pdev->name, pdata) < 0) { |
278 | dev_warn(&pdev->dev, "interrupt not available.\n"); | 278 | dev_warn(&pdev->dev, "interrupt not available.\n"); |
279 | pdata->irq = -1; | 279 | pdata->irq = -1; |
diff --git a/drivers/rtc/rtc-nuc900.c b/drivers/rtc/rtc-nuc900.c index 781068d62f23..b79010987d1e 100644 --- a/drivers/rtc/rtc-nuc900.c +++ b/drivers/rtc/rtc-nuc900.c | |||
@@ -269,7 +269,7 @@ static int __devinit nuc900_rtc_probe(struct platform_device *pdev) | |||
269 | 269 | ||
270 | nuc900_rtc->irq_num = platform_get_irq(pdev, 0); | 270 | nuc900_rtc->irq_num = platform_get_irq(pdev, 0); |
271 | if (request_irq(nuc900_rtc->irq_num, nuc900_rtc_interrupt, | 271 | if (request_irq(nuc900_rtc->irq_num, nuc900_rtc_interrupt, |
272 | IRQF_DISABLED, "nuc900rtc", nuc900_rtc)) { | 272 | 0, "nuc900rtc", nuc900_rtc)) { |
273 | dev_err(&pdev->dev, "NUC900 RTC request irq failed\n"); | 273 | dev_err(&pdev->dev, "NUC900 RTC request irq failed\n"); |
274 | err = -EBUSY; | 274 | err = -EBUSY; |
275 | goto fail4; | 275 | goto fail4; |
diff --git a/drivers/rtc/rtc-omap.c b/drivers/rtc/rtc-omap.c index 7789002bdd5c..0b614e32653d 100644 --- a/drivers/rtc/rtc-omap.c +++ b/drivers/rtc/rtc-omap.c | |||
@@ -348,14 +348,14 @@ static int __init omap_rtc_probe(struct platform_device *pdev) | |||
348 | rtc_write(OMAP_RTC_STATUS_ALARM, OMAP_RTC_STATUS_REG); | 348 | rtc_write(OMAP_RTC_STATUS_ALARM, OMAP_RTC_STATUS_REG); |
349 | 349 | ||
350 | /* handle periodic and alarm irqs */ | 350 | /* handle periodic and alarm irqs */ |
351 | if (request_irq(omap_rtc_timer, rtc_irq, IRQF_DISABLED, | 351 | if (request_irq(omap_rtc_timer, rtc_irq, 0, |
352 | dev_name(&rtc->dev), rtc)) { | 352 | dev_name(&rtc->dev), rtc)) { |
353 | pr_debug("%s: RTC timer interrupt IRQ%d already claimed\n", | 353 | pr_debug("%s: RTC timer interrupt IRQ%d already claimed\n", |
354 | pdev->name, omap_rtc_timer); | 354 | pdev->name, omap_rtc_timer); |
355 | goto fail1; | 355 | goto fail1; |
356 | } | 356 | } |
357 | if ((omap_rtc_timer != omap_rtc_alarm) && | 357 | if ((omap_rtc_timer != omap_rtc_alarm) && |
358 | (request_irq(omap_rtc_alarm, rtc_irq, IRQF_DISABLED, | 358 | (request_irq(omap_rtc_alarm, rtc_irq, 0, |
359 | dev_name(&rtc->dev), rtc))) { | 359 | dev_name(&rtc->dev), rtc))) { |
360 | pr_debug("%s: RTC alarm interrupt IRQ%d already claimed\n", | 360 | pr_debug("%s: RTC alarm interrupt IRQ%d already claimed\n", |
361 | pdev->name, omap_rtc_alarm); | 361 | pdev->name, omap_rtc_alarm); |
diff --git a/drivers/rtc/rtc-pcf2123.c b/drivers/rtc/rtc-pcf2123.c index b46c4004d8fe..836118795c0b 100644 --- a/drivers/rtc/rtc-pcf2123.c +++ b/drivers/rtc/rtc-pcf2123.c | |||
@@ -346,20 +346,9 @@ static struct spi_driver pcf2123_driver = { | |||
346 | .remove = __devexit_p(pcf2123_remove), | 346 | .remove = __devexit_p(pcf2123_remove), |
347 | }; | 347 | }; |
348 | 348 | ||
349 | static int __init pcf2123_init(void) | 349 | module_spi_driver(pcf2123_driver); |
350 | { | ||
351 | return spi_register_driver(&pcf2123_driver); | ||
352 | } | ||
353 | |||
354 | static void __exit pcf2123_exit(void) | ||
355 | { | ||
356 | spi_unregister_driver(&pcf2123_driver); | ||
357 | } | ||
358 | 350 | ||
359 | MODULE_AUTHOR("Chris Verges <chrisv@cyberswitching.com>"); | 351 | MODULE_AUTHOR("Chris Verges <chrisv@cyberswitching.com>"); |
360 | MODULE_DESCRIPTION("NXP PCF2123 RTC driver"); | 352 | MODULE_DESCRIPTION("NXP PCF2123 RTC driver"); |
361 | MODULE_LICENSE("GPL"); | 353 | MODULE_LICENSE("GPL"); |
362 | MODULE_VERSION(DRV_VERSION); | 354 | MODULE_VERSION(DRV_VERSION); |
363 | |||
364 | module_init(pcf2123_init); | ||
365 | module_exit(pcf2123_exit); | ||
diff --git a/drivers/rtc/rtc-pcf8563.c b/drivers/rtc/rtc-pcf8563.c index 606fdfab34e2..bc0677de1996 100644 --- a/drivers/rtc/rtc-pcf8563.c +++ b/drivers/rtc/rtc-pcf8563.c | |||
@@ -252,20 +252,9 @@ static struct i2c_driver pcf8563_driver = { | |||
252 | .id_table = pcf8563_id, | 252 | .id_table = pcf8563_id, |
253 | }; | 253 | }; |
254 | 254 | ||
255 | static int __init pcf8563_init(void) | 255 | module_i2c_driver(pcf8563_driver); |
256 | { | ||
257 | return i2c_add_driver(&pcf8563_driver); | ||
258 | } | ||
259 | |||
260 | static void __exit pcf8563_exit(void) | ||
261 | { | ||
262 | i2c_del_driver(&pcf8563_driver); | ||
263 | } | ||
264 | 256 | ||
265 | MODULE_AUTHOR("Alessandro Zummo <a.zummo@towertech.it>"); | 257 | MODULE_AUTHOR("Alessandro Zummo <a.zummo@towertech.it>"); |
266 | MODULE_DESCRIPTION("Philips PCF8563/Epson RTC8564 RTC driver"); | 258 | MODULE_DESCRIPTION("Philips PCF8563/Epson RTC8564 RTC driver"); |
267 | MODULE_LICENSE("GPL"); | 259 | MODULE_LICENSE("GPL"); |
268 | MODULE_VERSION(DRV_VERSION); | 260 | MODULE_VERSION(DRV_VERSION); |
269 | |||
270 | module_init(pcf8563_init); | ||
271 | module_exit(pcf8563_exit); | ||
diff --git a/drivers/rtc/rtc-pcf8583.c b/drivers/rtc/rtc-pcf8583.c index 2d201afead3b..019ff3571168 100644 --- a/drivers/rtc/rtc-pcf8583.c +++ b/drivers/rtc/rtc-pcf8583.c | |||
@@ -320,18 +320,7 @@ static struct i2c_driver pcf8583_driver = { | |||
320 | .id_table = pcf8583_id, | 320 | .id_table = pcf8583_id, |
321 | }; | 321 | }; |
322 | 322 | ||
323 | static __init int pcf8583_init(void) | 323 | module_i2c_driver(pcf8583_driver); |
324 | { | ||
325 | return i2c_add_driver(&pcf8583_driver); | ||
326 | } | ||
327 | |||
328 | static __exit void pcf8583_exit(void) | ||
329 | { | ||
330 | i2c_del_driver(&pcf8583_driver); | ||
331 | } | ||
332 | |||
333 | module_init(pcf8583_init); | ||
334 | module_exit(pcf8583_exit); | ||
335 | 324 | ||
336 | MODULE_AUTHOR("Russell King"); | 325 | MODULE_AUTHOR("Russell King"); |
337 | MODULE_DESCRIPTION("PCF8583 I2C RTC driver"); | 326 | MODULE_DESCRIPTION("PCF8583 I2C RTC driver"); |
diff --git a/drivers/rtc/rtc-pl030.c b/drivers/rtc/rtc-pl030.c index 02111fee077e..22bacdbf9139 100644 --- a/drivers/rtc/rtc-pl030.c +++ b/drivers/rtc/rtc-pl030.c | |||
@@ -123,7 +123,7 @@ static int pl030_probe(struct amba_device *dev, const struct amba_id *id) | |||
123 | 123 | ||
124 | amba_set_drvdata(dev, rtc); | 124 | amba_set_drvdata(dev, rtc); |
125 | 125 | ||
126 | ret = request_irq(dev->irq[0], pl030_interrupt, IRQF_DISABLED, | 126 | ret = request_irq(dev->irq[0], pl030_interrupt, 0, |
127 | "rtc-pl030", rtc); | 127 | "rtc-pl030", rtc); |
128 | if (ret) | 128 | if (ret) |
129 | goto err_irq; | 129 | goto err_irq; |
@@ -185,18 +185,7 @@ static struct amba_driver pl030_driver = { | |||
185 | .id_table = pl030_ids, | 185 | .id_table = pl030_ids, |
186 | }; | 186 | }; |
187 | 187 | ||
188 | static int __init pl030_init(void) | 188 | module_amba_driver(pl030_driver); |
189 | { | ||
190 | return amba_driver_register(&pl030_driver); | ||
191 | } | ||
192 | |||
193 | static void __exit pl030_exit(void) | ||
194 | { | ||
195 | amba_driver_unregister(&pl030_driver); | ||
196 | } | ||
197 | |||
198 | module_init(pl030_init); | ||
199 | module_exit(pl030_exit); | ||
200 | 189 | ||
201 | MODULE_AUTHOR("Russell King <rmk@arm.linux.org.uk>"); | 190 | MODULE_AUTHOR("Russell King <rmk@arm.linux.org.uk>"); |
202 | MODULE_DESCRIPTION("ARM AMBA PL030 RTC Driver"); | 191 | MODULE_DESCRIPTION("ARM AMBA PL030 RTC Driver"); |
diff --git a/drivers/rtc/rtc-pl031.c b/drivers/rtc/rtc-pl031.c index a952c8de1dd7..692de7360e94 100644 --- a/drivers/rtc/rtc-pl031.c +++ b/drivers/rtc/rtc-pl031.c | |||
@@ -352,7 +352,7 @@ static int pl031_probe(struct amba_device *adev, const struct amba_id *id) | |||
352 | } | 352 | } |
353 | 353 | ||
354 | if (request_irq(adev->irq[0], pl031_interrupt, | 354 | if (request_irq(adev->irq[0], pl031_interrupt, |
355 | IRQF_DISABLED, "rtc-pl031", ldata)) { | 355 | 0, "rtc-pl031", ldata)) { |
356 | ret = -EIO; | 356 | ret = -EIO; |
357 | goto out_no_irq; | 357 | goto out_no_irq; |
358 | } | 358 | } |
@@ -431,18 +431,7 @@ static struct amba_driver pl031_driver = { | |||
431 | .remove = pl031_remove, | 431 | .remove = pl031_remove, |
432 | }; | 432 | }; |
433 | 433 | ||
434 | static int __init pl031_init(void) | 434 | module_amba_driver(pl031_driver); |
435 | { | ||
436 | return amba_driver_register(&pl031_driver); | ||
437 | } | ||
438 | |||
439 | static void __exit pl031_exit(void) | ||
440 | { | ||
441 | amba_driver_unregister(&pl031_driver); | ||
442 | } | ||
443 | |||
444 | module_init(pl031_init); | ||
445 | module_exit(pl031_exit); | ||
446 | 435 | ||
447 | MODULE_AUTHOR("Deepak Saxena <dsaxena@plexity.net"); | 436 | MODULE_AUTHOR("Deepak Saxena <dsaxena@plexity.net"); |
448 | MODULE_DESCRIPTION("ARM AMBA PL031 RTC Driver"); | 437 | MODULE_DESCRIPTION("ARM AMBA PL031 RTC Driver"); |
diff --git a/drivers/rtc/rtc-pm8xxx.c b/drivers/rtc/rtc-pm8xxx.c index 9f1d6bcbdf6c..d00bd24342a3 100644 --- a/drivers/rtc/rtc-pm8xxx.c +++ b/drivers/rtc/rtc-pm8xxx.c | |||
@@ -520,7 +520,7 @@ static int pm8xxx_rtc_suspend(struct device *dev) | |||
520 | } | 520 | } |
521 | #endif | 521 | #endif |
522 | 522 | ||
523 | SIMPLE_DEV_PM_OPS(pm8xxx_rtc_pm_ops, pm8xxx_rtc_suspend, pm8xxx_rtc_resume); | 523 | static SIMPLE_DEV_PM_OPS(pm8xxx_rtc_pm_ops, pm8xxx_rtc_suspend, pm8xxx_rtc_resume); |
524 | 524 | ||
525 | static struct platform_driver pm8xxx_rtc_driver = { | 525 | static struct platform_driver pm8xxx_rtc_driver = { |
526 | .probe = pm8xxx_rtc_probe, | 526 | .probe = pm8xxx_rtc_probe, |
diff --git a/drivers/rtc/rtc-pxa.c b/drivers/rtc/rtc-pxa.c index fc9f4991574b..0075c8fd93d8 100644 --- a/drivers/rtc/rtc-pxa.c +++ b/drivers/rtc/rtc-pxa.c | |||
@@ -174,14 +174,14 @@ static int pxa_rtc_open(struct device *dev) | |||
174 | struct pxa_rtc *pxa_rtc = dev_get_drvdata(dev); | 174 | struct pxa_rtc *pxa_rtc = dev_get_drvdata(dev); |
175 | int ret; | 175 | int ret; |
176 | 176 | ||
177 | ret = request_irq(pxa_rtc->irq_1Hz, pxa_rtc_irq, IRQF_DISABLED, | 177 | ret = request_irq(pxa_rtc->irq_1Hz, pxa_rtc_irq, 0, |
178 | "rtc 1Hz", dev); | 178 | "rtc 1Hz", dev); |
179 | if (ret < 0) { | 179 | if (ret < 0) { |
180 | dev_err(dev, "can't get irq %i, err %d\n", pxa_rtc->irq_1Hz, | 180 | dev_err(dev, "can't get irq %i, err %d\n", pxa_rtc->irq_1Hz, |
181 | ret); | 181 | ret); |
182 | goto err_irq_1Hz; | 182 | goto err_irq_1Hz; |
183 | } | 183 | } |
184 | ret = request_irq(pxa_rtc->irq_Alrm, pxa_rtc_irq, IRQF_DISABLED, | 184 | ret = request_irq(pxa_rtc->irq_Alrm, pxa_rtc_irq, 0, |
185 | "rtc Alrm", dev); | 185 | "rtc Alrm", dev); |
186 | if (ret < 0) { | 186 | if (ret < 0) { |
187 | dev_err(dev, "can't get irq %i, err %d\n", pxa_rtc->irq_Alrm, | 187 | dev_err(dev, "can't get irq %i, err %d\n", pxa_rtc->irq_Alrm, |
diff --git a/drivers/rtc/rtc-r9701.c b/drivers/rtc/rtc-r9701.c index 9beba49c3c5b..7f8e6c247935 100644 --- a/drivers/rtc/rtc-r9701.c +++ b/drivers/rtc/rtc-r9701.c | |||
@@ -125,6 +125,13 @@ static int __devinit r9701_probe(struct spi_device *spi) | |||
125 | unsigned char tmp; | 125 | unsigned char tmp; |
126 | int res; | 126 | int res; |
127 | 127 | ||
128 | tmp = R100CNT; | ||
129 | res = read_regs(&spi->dev, &tmp, 1); | ||
130 | if (res || tmp != 0x20) { | ||
131 | dev_err(&spi->dev, "cannot read RTC register\n"); | ||
132 | return -ENODEV; | ||
133 | } | ||
134 | |||
128 | rtc = rtc_device_register("r9701", | 135 | rtc = rtc_device_register("r9701", |
129 | &spi->dev, &r9701_rtc_ops, THIS_MODULE); | 136 | &spi->dev, &r9701_rtc_ops, THIS_MODULE); |
130 | if (IS_ERR(rtc)) | 137 | if (IS_ERR(rtc)) |
@@ -132,13 +139,6 @@ static int __devinit r9701_probe(struct spi_device *spi) | |||
132 | 139 | ||
133 | dev_set_drvdata(&spi->dev, rtc); | 140 | dev_set_drvdata(&spi->dev, rtc); |
134 | 141 | ||
135 | tmp = R100CNT; | ||
136 | res = read_regs(&spi->dev, &tmp, 1); | ||
137 | if (res || tmp != 0x20) { | ||
138 | rtc_device_unregister(rtc); | ||
139 | return res; | ||
140 | } | ||
141 | |||
142 | return 0; | 142 | return 0; |
143 | } | 143 | } |
144 | 144 | ||
@@ -159,17 +159,7 @@ static struct spi_driver r9701_driver = { | |||
159 | .remove = __devexit_p(r9701_remove), | 159 | .remove = __devexit_p(r9701_remove), |
160 | }; | 160 | }; |
161 | 161 | ||
162 | static __init int r9701_init(void) | 162 | module_spi_driver(r9701_driver); |
163 | { | ||
164 | return spi_register_driver(&r9701_driver); | ||
165 | } | ||
166 | module_init(r9701_init); | ||
167 | |||
168 | static __exit void r9701_exit(void) | ||
169 | { | ||
170 | spi_unregister_driver(&r9701_driver); | ||
171 | } | ||
172 | module_exit(r9701_exit); | ||
173 | 163 | ||
174 | MODULE_DESCRIPTION("r9701 spi RTC driver"); | 164 | MODULE_DESCRIPTION("r9701 spi RTC driver"); |
175 | MODULE_AUTHOR("Magnus Damm <damm@opensource.se>"); | 165 | MODULE_AUTHOR("Magnus Damm <damm@opensource.se>"); |
diff --git a/drivers/rtc/rtc-rs5c348.c b/drivers/rtc/rtc-rs5c348.c index ce2ca8523ddd..77074ccd2850 100644 --- a/drivers/rtc/rtc-rs5c348.c +++ b/drivers/rtc/rtc-rs5c348.c | |||
@@ -235,18 +235,7 @@ static struct spi_driver rs5c348_driver = { | |||
235 | .remove = __devexit_p(rs5c348_remove), | 235 | .remove = __devexit_p(rs5c348_remove), |
236 | }; | 236 | }; |
237 | 237 | ||
238 | static __init int rs5c348_init(void) | 238 | module_spi_driver(rs5c348_driver); |
239 | { | ||
240 | return spi_register_driver(&rs5c348_driver); | ||
241 | } | ||
242 | |||
243 | static __exit void rs5c348_exit(void) | ||
244 | { | ||
245 | spi_unregister_driver(&rs5c348_driver); | ||
246 | } | ||
247 | |||
248 | module_init(rs5c348_init); | ||
249 | module_exit(rs5c348_exit); | ||
250 | 239 | ||
251 | MODULE_AUTHOR("Atsushi Nemoto <anemo@mba.ocn.ne.jp>"); | 240 | MODULE_AUTHOR("Atsushi Nemoto <anemo@mba.ocn.ne.jp>"); |
252 | MODULE_DESCRIPTION("Ricoh RS5C348 RTC driver"); | 241 | MODULE_DESCRIPTION("Ricoh RS5C348 RTC driver"); |
diff --git a/drivers/rtc/rtc-rs5c372.c b/drivers/rtc/rtc-rs5c372.c index d29f5432c6e8..fb4842c3544e 100644 --- a/drivers/rtc/rtc-rs5c372.c +++ b/drivers/rtc/rtc-rs5c372.c | |||
@@ -689,18 +689,7 @@ static struct i2c_driver rs5c372_driver = { | |||
689 | .id_table = rs5c372_id, | 689 | .id_table = rs5c372_id, |
690 | }; | 690 | }; |
691 | 691 | ||
692 | static __init int rs5c372_init(void) | 692 | module_i2c_driver(rs5c372_driver); |
693 | { | ||
694 | return i2c_add_driver(&rs5c372_driver); | ||
695 | } | ||
696 | |||
697 | static __exit void rs5c372_exit(void) | ||
698 | { | ||
699 | i2c_del_driver(&rs5c372_driver); | ||
700 | } | ||
701 | |||
702 | module_init(rs5c372_init); | ||
703 | module_exit(rs5c372_exit); | ||
704 | 693 | ||
705 | MODULE_AUTHOR( | 694 | MODULE_AUTHOR( |
706 | "Pavel Mironchik <pmironchik@optifacio.net>, " | 695 | "Pavel Mironchik <pmironchik@optifacio.net>, " |
diff --git a/drivers/rtc/rtc-rv3029c2.c b/drivers/rtc/rtc-rv3029c2.c index ea09ff211dc6..0fbe57b2f6d2 100644 --- a/drivers/rtc/rtc-rv3029c2.c +++ b/drivers/rtc/rtc-rv3029c2.c | |||
@@ -436,18 +436,7 @@ static struct i2c_driver rv3029c2_driver = { | |||
436 | .id_table = rv3029c2_id, | 436 | .id_table = rv3029c2_id, |
437 | }; | 437 | }; |
438 | 438 | ||
439 | static int __init rv3029c2_init(void) | 439 | module_i2c_driver(rv3029c2_driver); |
440 | { | ||
441 | return i2c_add_driver(&rv3029c2_driver); | ||
442 | } | ||
443 | |||
444 | static void __exit rv3029c2_exit(void) | ||
445 | { | ||
446 | i2c_del_driver(&rv3029c2_driver); | ||
447 | } | ||
448 | |||
449 | module_init(rv3029c2_init); | ||
450 | module_exit(rv3029c2_exit); | ||
451 | 440 | ||
452 | MODULE_AUTHOR("Gregory Hermant <gregory.hermant@calao-systems.com>"); | 441 | MODULE_AUTHOR("Gregory Hermant <gregory.hermant@calao-systems.com>"); |
453 | MODULE_DESCRIPTION("Micro Crystal RV3029C2 RTC driver"); | 442 | MODULE_DESCRIPTION("Micro Crystal RV3029C2 RTC driver"); |
diff --git a/drivers/rtc/rtc-rx8025.c b/drivers/rtc/rtc-rx8025.c index fde172fb2abe..0de902dc1cd5 100644 --- a/drivers/rtc/rtc-rx8025.c +++ b/drivers/rtc/rtc-rx8025.c | |||
@@ -644,19 +644,8 @@ static struct i2c_driver rx8025_driver = { | |||
644 | .id_table = rx8025_id, | 644 | .id_table = rx8025_id, |
645 | }; | 645 | }; |
646 | 646 | ||
647 | static int __init rx8025_init(void) | 647 | module_i2c_driver(rx8025_driver); |
648 | { | ||
649 | return i2c_add_driver(&rx8025_driver); | ||
650 | } | ||
651 | |||
652 | static void __exit rx8025_exit(void) | ||
653 | { | ||
654 | i2c_del_driver(&rx8025_driver); | ||
655 | } | ||
656 | 648 | ||
657 | MODULE_AUTHOR("Wolfgang Grandegger <wg@grandegger.com>"); | 649 | MODULE_AUTHOR("Wolfgang Grandegger <wg@grandegger.com>"); |
658 | MODULE_DESCRIPTION("RX-8025 SA/NB RTC driver"); | 650 | MODULE_DESCRIPTION("RX-8025 SA/NB RTC driver"); |
659 | MODULE_LICENSE("GPL"); | 651 | MODULE_LICENSE("GPL"); |
660 | |||
661 | module_init(rx8025_init); | ||
662 | module_exit(rx8025_exit); | ||
diff --git a/drivers/rtc/rtc-rx8581.c b/drivers/rtc/rtc-rx8581.c index 600b890a3c15..d84825124a7a 100644 --- a/drivers/rtc/rtc-rx8581.c +++ b/drivers/rtc/rtc-rx8581.c | |||
@@ -276,20 +276,9 @@ static struct i2c_driver rx8581_driver = { | |||
276 | .id_table = rx8581_id, | 276 | .id_table = rx8581_id, |
277 | }; | 277 | }; |
278 | 278 | ||
279 | static int __init rx8581_init(void) | 279 | module_i2c_driver(rx8581_driver); |
280 | { | ||
281 | return i2c_add_driver(&rx8581_driver); | ||
282 | } | ||
283 | |||
284 | static void __exit rx8581_exit(void) | ||
285 | { | ||
286 | i2c_del_driver(&rx8581_driver); | ||
287 | } | ||
288 | 280 | ||
289 | MODULE_AUTHOR("Martyn Welch <martyn.welch@ge.com>"); | 281 | MODULE_AUTHOR("Martyn Welch <martyn.welch@ge.com>"); |
290 | MODULE_DESCRIPTION("Epson RX-8581 RTC driver"); | 282 | MODULE_DESCRIPTION("Epson RX-8581 RTC driver"); |
291 | MODULE_LICENSE("GPL"); | 283 | MODULE_LICENSE("GPL"); |
292 | MODULE_VERSION(DRV_VERSION); | 284 | MODULE_VERSION(DRV_VERSION); |
293 | |||
294 | module_init(rx8581_init); | ||
295 | module_exit(rx8581_exit); | ||
diff --git a/drivers/rtc/rtc-s35390a.c b/drivers/rtc/rtc-s35390a.c index f789e002c9b0..c9562ceedef3 100644 --- a/drivers/rtc/rtc-s35390a.c +++ b/drivers/rtc/rtc-s35390a.c | |||
@@ -304,19 +304,8 @@ static struct i2c_driver s35390a_driver = { | |||
304 | .id_table = s35390a_id, | 304 | .id_table = s35390a_id, |
305 | }; | 305 | }; |
306 | 306 | ||
307 | static int __init s35390a_rtc_init(void) | 307 | module_i2c_driver(s35390a_driver); |
308 | { | ||
309 | return i2c_add_driver(&s35390a_driver); | ||
310 | } | ||
311 | |||
312 | static void __exit s35390a_rtc_exit(void) | ||
313 | { | ||
314 | i2c_del_driver(&s35390a_driver); | ||
315 | } | ||
316 | 308 | ||
317 | MODULE_AUTHOR("Byron Bradley <byron.bbradley@gmail.com>"); | 309 | MODULE_AUTHOR("Byron Bradley <byron.bbradley@gmail.com>"); |
318 | MODULE_DESCRIPTION("S35390A RTC driver"); | 310 | MODULE_DESCRIPTION("S35390A RTC driver"); |
319 | MODULE_LICENSE("GPL"); | 311 | MODULE_LICENSE("GPL"); |
320 | |||
321 | module_init(s35390a_rtc_init); | ||
322 | module_exit(s35390a_rtc_exit); | ||
diff --git a/drivers/rtc/rtc-s3c.c b/drivers/rtc/rtc-s3c.c index aef40bd2957b..9ccea134a996 100644 --- a/drivers/rtc/rtc-s3c.c +++ b/drivers/rtc/rtc-s3c.c | |||
@@ -35,6 +35,8 @@ | |||
35 | 35 | ||
36 | enum s3c_cpu_type { | 36 | enum s3c_cpu_type { |
37 | TYPE_S3C2410, | 37 | TYPE_S3C2410, |
38 | TYPE_S3C2416, | ||
39 | TYPE_S3C2443, | ||
38 | TYPE_S3C64XX, | 40 | TYPE_S3C64XX, |
39 | }; | 41 | }; |
40 | 42 | ||
@@ -132,6 +134,7 @@ static int s3c_rtc_setfreq(struct device *dev, int freq) | |||
132 | struct platform_device *pdev = to_platform_device(dev); | 134 | struct platform_device *pdev = to_platform_device(dev); |
133 | struct rtc_device *rtc_dev = platform_get_drvdata(pdev); | 135 | struct rtc_device *rtc_dev = platform_get_drvdata(pdev); |
134 | unsigned int tmp = 0; | 136 | unsigned int tmp = 0; |
137 | int val; | ||
135 | 138 | ||
136 | if (!is_power_of_2(freq)) | 139 | if (!is_power_of_2(freq)) |
137 | return -EINVAL; | 140 | return -EINVAL; |
@@ -139,12 +142,22 @@ static int s3c_rtc_setfreq(struct device *dev, int freq) | |||
139 | clk_enable(rtc_clk); | 142 | clk_enable(rtc_clk); |
140 | spin_lock_irq(&s3c_rtc_pie_lock); | 143 | spin_lock_irq(&s3c_rtc_pie_lock); |
141 | 144 | ||
142 | if (s3c_rtc_cpu_type == TYPE_S3C2410) { | 145 | if (s3c_rtc_cpu_type != TYPE_S3C64XX) { |
143 | tmp = readb(s3c_rtc_base + S3C2410_TICNT); | 146 | tmp = readb(s3c_rtc_base + S3C2410_TICNT); |
144 | tmp &= S3C2410_TICNT_ENABLE; | 147 | tmp &= S3C2410_TICNT_ENABLE; |
145 | } | 148 | } |
146 | 149 | ||
147 | tmp |= (rtc_dev->max_user_freq / freq)-1; | 150 | val = (rtc_dev->max_user_freq / freq) - 1; |
151 | |||
152 | if (s3c_rtc_cpu_type == TYPE_S3C2416 || s3c_rtc_cpu_type == TYPE_S3C2443) { | ||
153 | tmp |= S3C2443_TICNT_PART(val); | ||
154 | writel(S3C2443_TICNT1_PART(val), s3c_rtc_base + S3C2443_TICNT1); | ||
155 | |||
156 | if (s3c_rtc_cpu_type == TYPE_S3C2416) | ||
157 | writel(S3C2416_TICNT2_PART(val), s3c_rtc_base + S3C2416_TICNT2); | ||
158 | } else { | ||
159 | tmp |= val; | ||
160 | } | ||
148 | 161 | ||
149 | writel(tmp, s3c_rtc_base + S3C2410_TICNT); | 162 | writel(tmp, s3c_rtc_base + S3C2410_TICNT); |
150 | spin_unlock_irq(&s3c_rtc_pie_lock); | 163 | spin_unlock_irq(&s3c_rtc_pie_lock); |
@@ -371,7 +384,7 @@ static void s3c_rtc_enable(struct platform_device *pdev, int en) | |||
371 | tmp &= ~S3C2410_RTCCON_RTCEN; | 384 | tmp &= ~S3C2410_RTCCON_RTCEN; |
372 | writew(tmp, base + S3C2410_RTCCON); | 385 | writew(tmp, base + S3C2410_RTCCON); |
373 | 386 | ||
374 | if (s3c_rtc_cpu_type == TYPE_S3C2410) { | 387 | if (s3c_rtc_cpu_type != TYPE_S3C64XX) { |
375 | tmp = readb(base + S3C2410_TICNT); | 388 | tmp = readb(base + S3C2410_TICNT); |
376 | tmp &= ~S3C2410_TICNT_ENABLE; | 389 | tmp &= ~S3C2410_TICNT_ENABLE; |
377 | writeb(tmp, base + S3C2410_TICNT); | 390 | writeb(tmp, base + S3C2410_TICNT); |
@@ -428,12 +441,27 @@ static int __devexit s3c_rtc_remove(struct platform_device *dev) | |||
428 | return 0; | 441 | return 0; |
429 | } | 442 | } |
430 | 443 | ||
444 | static const struct of_device_id s3c_rtc_dt_match[]; | ||
445 | |||
446 | static inline int s3c_rtc_get_driver_data(struct platform_device *pdev) | ||
447 | { | ||
448 | #ifdef CONFIG_OF | ||
449 | if (pdev->dev.of_node) { | ||
450 | const struct of_device_id *match; | ||
451 | match = of_match_node(s3c_rtc_dt_match, pdev->dev.of_node); | ||
452 | return match->data; | ||
453 | } | ||
454 | #endif | ||
455 | return platform_get_device_id(pdev)->driver_data; | ||
456 | } | ||
457 | |||
431 | static int __devinit s3c_rtc_probe(struct platform_device *pdev) | 458 | static int __devinit s3c_rtc_probe(struct platform_device *pdev) |
432 | { | 459 | { |
433 | struct rtc_device *rtc; | 460 | struct rtc_device *rtc; |
434 | struct rtc_time rtc_tm; | 461 | struct rtc_time rtc_tm; |
435 | struct resource *res; | 462 | struct resource *res; |
436 | int ret; | 463 | int ret; |
464 | int tmp; | ||
437 | 465 | ||
438 | pr_debug("%s: probe=%p\n", __func__, pdev); | 466 | pr_debug("%s: probe=%p\n", __func__, pdev); |
439 | 467 | ||
@@ -508,13 +536,7 @@ static int __devinit s3c_rtc_probe(struct platform_device *pdev) | |||
508 | goto err_nortc; | 536 | goto err_nortc; |
509 | } | 537 | } |
510 | 538 | ||
511 | #ifdef CONFIG_OF | 539 | s3c_rtc_cpu_type = s3c_rtc_get_driver_data(pdev); |
512 | if (pdev->dev.of_node) | ||
513 | s3c_rtc_cpu_type = of_device_is_compatible(pdev->dev.of_node, | ||
514 | "samsung,s3c6410-rtc") ? TYPE_S3C64XX : TYPE_S3C2410; | ||
515 | else | ||
516 | #endif | ||
517 | s3c_rtc_cpu_type = platform_get_device_id(pdev)->driver_data; | ||
518 | 540 | ||
519 | /* Check RTC Time */ | 541 | /* Check RTC Time */ |
520 | 542 | ||
@@ -533,24 +555,30 @@ static int __devinit s3c_rtc_probe(struct platform_device *pdev) | |||
533 | dev_warn(&pdev->dev, "warning: invalid RTC value so initializing it\n"); | 555 | dev_warn(&pdev->dev, "warning: invalid RTC value so initializing it\n"); |
534 | } | 556 | } |
535 | 557 | ||
536 | if (s3c_rtc_cpu_type == TYPE_S3C64XX) | 558 | if (s3c_rtc_cpu_type != TYPE_S3C2410) |
537 | rtc->max_user_freq = 32768; | 559 | rtc->max_user_freq = 32768; |
538 | else | 560 | else |
539 | rtc->max_user_freq = 128; | 561 | rtc->max_user_freq = 128; |
540 | 562 | ||
563 | if (s3c_rtc_cpu_type == TYPE_S3C2416 || s3c_rtc_cpu_type == TYPE_S3C2443) { | ||
564 | tmp = readw(s3c_rtc_base + S3C2410_RTCCON); | ||
565 | tmp |= S3C2443_RTCCON_TICSEL; | ||
566 | writew(tmp, s3c_rtc_base + S3C2410_RTCCON); | ||
567 | } | ||
568 | |||
541 | platform_set_drvdata(pdev, rtc); | 569 | platform_set_drvdata(pdev, rtc); |
542 | 570 | ||
543 | s3c_rtc_setfreq(&pdev->dev, 1); | 571 | s3c_rtc_setfreq(&pdev->dev, 1); |
544 | 572 | ||
545 | ret = request_irq(s3c_rtc_alarmno, s3c_rtc_alarmirq, | 573 | ret = request_irq(s3c_rtc_alarmno, s3c_rtc_alarmirq, |
546 | IRQF_DISABLED, "s3c2410-rtc alarm", rtc); | 574 | 0, "s3c2410-rtc alarm", rtc); |
547 | if (ret) { | 575 | if (ret) { |
548 | dev_err(&pdev->dev, "IRQ%d error %d\n", s3c_rtc_alarmno, ret); | 576 | dev_err(&pdev->dev, "IRQ%d error %d\n", s3c_rtc_alarmno, ret); |
549 | goto err_alarm_irq; | 577 | goto err_alarm_irq; |
550 | } | 578 | } |
551 | 579 | ||
552 | ret = request_irq(s3c_rtc_tickno, s3c_rtc_tickirq, | 580 | ret = request_irq(s3c_rtc_tickno, s3c_rtc_tickirq, |
553 | IRQF_DISABLED, "s3c2410-rtc tick", rtc); | 581 | 0, "s3c2410-rtc tick", rtc); |
554 | if (ret) { | 582 | if (ret) { |
555 | dev_err(&pdev->dev, "IRQ%d error %d\n", s3c_rtc_tickno, ret); | 583 | dev_err(&pdev->dev, "IRQ%d error %d\n", s3c_rtc_tickno, ret); |
556 | free_irq(s3c_rtc_alarmno, rtc); | 584 | free_irq(s3c_rtc_alarmno, rtc); |
@@ -638,8 +666,19 @@ static int s3c_rtc_resume(struct platform_device *pdev) | |||
638 | 666 | ||
639 | #ifdef CONFIG_OF | 667 | #ifdef CONFIG_OF |
640 | static const struct of_device_id s3c_rtc_dt_match[] = { | 668 | static const struct of_device_id s3c_rtc_dt_match[] = { |
641 | { .compatible = "samsung,s3c2410-rtc" }, | 669 | { |
642 | { .compatible = "samsung,s3c6410-rtc" }, | 670 | .compatible = "samsung,s3c2410-rtc" |
671 | .data = TYPE_S3C2410, | ||
672 | }, { | ||
673 | .compatible = "samsung,s3c2416-rtc" | ||
674 | .data = TYPE_S3C2416, | ||
675 | }, { | ||
676 | .compatible = "samsung,s3c2443-rtc" | ||
677 | .data = TYPE_S3C2443, | ||
678 | }, { | ||
679 | .compatible = "samsung,s3c6410-rtc" | ||
680 | .data = TYPE_S3C64XX, | ||
681 | }, | ||
643 | {}, | 682 | {}, |
644 | }; | 683 | }; |
645 | MODULE_DEVICE_TABLE(of, s3c_rtc_dt_match); | 684 | MODULE_DEVICE_TABLE(of, s3c_rtc_dt_match); |
@@ -652,6 +691,12 @@ static struct platform_device_id s3c_rtc_driver_ids[] = { | |||
652 | .name = "s3c2410-rtc", | 691 | .name = "s3c2410-rtc", |
653 | .driver_data = TYPE_S3C2410, | 692 | .driver_data = TYPE_S3C2410, |
654 | }, { | 693 | }, { |
694 | .name = "s3c2416-rtc", | ||
695 | .driver_data = TYPE_S3C2416, | ||
696 | }, { | ||
697 | .name = "s3c2443-rtc", | ||
698 | .driver_data = TYPE_S3C2443, | ||
699 | }, { | ||
655 | .name = "s3c64xx-rtc", | 700 | .name = "s3c64xx-rtc", |
656 | .driver_data = TYPE_S3C64XX, | 701 | .driver_data = TYPE_S3C64XX, |
657 | }, | 702 | }, |
diff --git a/drivers/rtc/rtc-sa1100.c b/drivers/rtc/rtc-sa1100.c index e8f1adde4d82..4940fa8c4e10 100644 --- a/drivers/rtc/rtc-sa1100.c +++ b/drivers/rtc/rtc-sa1100.c | |||
@@ -23,94 +23,44 @@ | |||
23 | 23 | ||
24 | #include <linux/platform_device.h> | 24 | #include <linux/platform_device.h> |
25 | #include <linux/module.h> | 25 | #include <linux/module.h> |
26 | #include <linux/clk.h> | ||
26 | #include <linux/rtc.h> | 27 | #include <linux/rtc.h> |
27 | #include <linux/init.h> | 28 | #include <linux/init.h> |
28 | #include <linux/fs.h> | 29 | #include <linux/fs.h> |
29 | #include <linux/interrupt.h> | 30 | #include <linux/interrupt.h> |
31 | #include <linux/slab.h> | ||
30 | #include <linux/string.h> | 32 | #include <linux/string.h> |
33 | #include <linux/of.h> | ||
31 | #include <linux/pm.h> | 34 | #include <linux/pm.h> |
32 | #include <linux/bitops.h> | 35 | #include <linux/bitops.h> |
33 | 36 | ||
34 | #include <mach/hardware.h> | 37 | #include <mach/hardware.h> |
35 | #include <mach/irqs.h> | 38 | #include <mach/irqs.h> |
36 | 39 | ||
37 | #ifdef CONFIG_ARCH_PXA | 40 | #if defined(CONFIG_ARCH_PXA) || defined(CONFIG_ARCH_MMP) |
38 | #include <mach/regs-rtc.h> | 41 | #include <mach/regs-rtc.h> |
39 | #endif | 42 | #endif |
40 | 43 | ||
41 | #define RTC_DEF_DIVIDER (32768 - 1) | 44 | #define RTC_DEF_DIVIDER (32768 - 1) |
42 | #define RTC_DEF_TRIM 0 | 45 | #define RTC_DEF_TRIM 0 |
43 | 46 | #define RTC_FREQ 1024 | |
44 | static const unsigned long RTC_FREQ = 1024; | 47 | |
45 | static struct rtc_time rtc_alarm; | 48 | struct sa1100_rtc { |
46 | static DEFINE_SPINLOCK(sa1100_rtc_lock); | 49 | spinlock_t lock; |
47 | 50 | int irq_1hz; | |
48 | static inline int rtc_periodic_alarm(struct rtc_time *tm) | 51 | int irq_alarm; |
49 | { | 52 | struct rtc_device *rtc; |
50 | return (tm->tm_year == -1) || | 53 | struct clk *clk; |
51 | ((unsigned)tm->tm_mon >= 12) || | 54 | }; |
52 | ((unsigned)(tm->tm_mday - 1) >= 31) || | ||
53 | ((unsigned)tm->tm_hour > 23) || | ||
54 | ((unsigned)tm->tm_min > 59) || | ||
55 | ((unsigned)tm->tm_sec > 59); | ||
56 | } | ||
57 | |||
58 | /* | ||
59 | * Calculate the next alarm time given the requested alarm time mask | ||
60 | * and the current time. | ||
61 | */ | ||
62 | static void rtc_next_alarm_time(struct rtc_time *next, struct rtc_time *now, | ||
63 | struct rtc_time *alrm) | ||
64 | { | ||
65 | unsigned long next_time; | ||
66 | unsigned long now_time; | ||
67 | |||
68 | next->tm_year = now->tm_year; | ||
69 | next->tm_mon = now->tm_mon; | ||
70 | next->tm_mday = now->tm_mday; | ||
71 | next->tm_hour = alrm->tm_hour; | ||
72 | next->tm_min = alrm->tm_min; | ||
73 | next->tm_sec = alrm->tm_sec; | ||
74 | |||
75 | rtc_tm_to_time(now, &now_time); | ||
76 | rtc_tm_to_time(next, &next_time); | ||
77 | |||
78 | if (next_time < now_time) { | ||
79 | /* Advance one day */ | ||
80 | next_time += 60 * 60 * 24; | ||
81 | rtc_time_to_tm(next_time, next); | ||
82 | } | ||
83 | } | ||
84 | |||
85 | static int rtc_update_alarm(struct rtc_time *alrm) | ||
86 | { | ||
87 | struct rtc_time alarm_tm, now_tm; | ||
88 | unsigned long now, time; | ||
89 | int ret; | ||
90 | |||
91 | do { | ||
92 | now = RCNR; | ||
93 | rtc_time_to_tm(now, &now_tm); | ||
94 | rtc_next_alarm_time(&alarm_tm, &now_tm, alrm); | ||
95 | ret = rtc_tm_to_time(&alarm_tm, &time); | ||
96 | if (ret != 0) | ||
97 | break; | ||
98 | |||
99 | RTSR = RTSR & (RTSR_HZE|RTSR_ALE|RTSR_AL); | ||
100 | RTAR = time; | ||
101 | } while (now != RCNR); | ||
102 | |||
103 | return ret; | ||
104 | } | ||
105 | 55 | ||
106 | static irqreturn_t sa1100_rtc_interrupt(int irq, void *dev_id) | 56 | static irqreturn_t sa1100_rtc_interrupt(int irq, void *dev_id) |
107 | { | 57 | { |
108 | struct platform_device *pdev = to_platform_device(dev_id); | 58 | struct sa1100_rtc *info = dev_get_drvdata(dev_id); |
109 | struct rtc_device *rtc = platform_get_drvdata(pdev); | 59 | struct rtc_device *rtc = info->rtc; |
110 | unsigned int rtsr; | 60 | unsigned int rtsr; |
111 | unsigned long events = 0; | 61 | unsigned long events = 0; |
112 | 62 | ||
113 | spin_lock(&sa1100_rtc_lock); | 63 | spin_lock(&info->lock); |
114 | 64 | ||
115 | rtsr = RTSR; | 65 | rtsr = RTSR; |
116 | /* clear interrupt sources */ | 66 | /* clear interrupt sources */ |
@@ -146,30 +96,28 @@ static irqreturn_t sa1100_rtc_interrupt(int irq, void *dev_id) | |||
146 | 96 | ||
147 | rtc_update_irq(rtc, 1, events); | 97 | rtc_update_irq(rtc, 1, events); |
148 | 98 | ||
149 | if (rtsr & RTSR_AL && rtc_periodic_alarm(&rtc_alarm)) | 99 | spin_unlock(&info->lock); |
150 | rtc_update_alarm(&rtc_alarm); | ||
151 | |||
152 | spin_unlock(&sa1100_rtc_lock); | ||
153 | 100 | ||
154 | return IRQ_HANDLED; | 101 | return IRQ_HANDLED; |
155 | } | 102 | } |
156 | 103 | ||
157 | static int sa1100_rtc_open(struct device *dev) | 104 | static int sa1100_rtc_open(struct device *dev) |
158 | { | 105 | { |
106 | struct sa1100_rtc *info = dev_get_drvdata(dev); | ||
107 | struct rtc_device *rtc = info->rtc; | ||
159 | int ret; | 108 | int ret; |
160 | struct platform_device *plat_dev = to_platform_device(dev); | ||
161 | struct rtc_device *rtc = platform_get_drvdata(plat_dev); | ||
162 | 109 | ||
163 | ret = request_irq(IRQ_RTC1Hz, sa1100_rtc_interrupt, IRQF_DISABLED, | 110 | ret = clk_prepare_enable(info->clk); |
164 | "rtc 1Hz", dev); | 111 | if (ret) |
112 | goto fail_clk; | ||
113 | ret = request_irq(info->irq_1hz, sa1100_rtc_interrupt, 0, "rtc 1Hz", dev); | ||
165 | if (ret) { | 114 | if (ret) { |
166 | dev_err(dev, "IRQ %d already in use.\n", IRQ_RTC1Hz); | 115 | dev_err(dev, "IRQ %d already in use.\n", info->irq_1hz); |
167 | goto fail_ui; | 116 | goto fail_ui; |
168 | } | 117 | } |
169 | ret = request_irq(IRQ_RTCAlrm, sa1100_rtc_interrupt, IRQF_DISABLED, | 118 | ret = request_irq(info->irq_alarm, sa1100_rtc_interrupt, 0, "rtc Alrm", dev); |
170 | "rtc Alrm", dev); | ||
171 | if (ret) { | 119 | if (ret) { |
172 | dev_err(dev, "IRQ %d already in use.\n", IRQ_RTCAlrm); | 120 | dev_err(dev, "IRQ %d already in use.\n", info->irq_alarm); |
173 | goto fail_ai; | 121 | goto fail_ai; |
174 | } | 122 | } |
175 | rtc->max_user_freq = RTC_FREQ; | 123 | rtc->max_user_freq = RTC_FREQ; |
@@ -178,29 +126,36 @@ static int sa1100_rtc_open(struct device *dev) | |||
178 | return 0; | 126 | return 0; |
179 | 127 | ||
180 | fail_ai: | 128 | fail_ai: |
181 | free_irq(IRQ_RTC1Hz, dev); | 129 | free_irq(info->irq_1hz, dev); |
182 | fail_ui: | 130 | fail_ui: |
131 | clk_disable_unprepare(info->clk); | ||
132 | fail_clk: | ||
183 | return ret; | 133 | return ret; |
184 | } | 134 | } |
185 | 135 | ||
186 | static void sa1100_rtc_release(struct device *dev) | 136 | static void sa1100_rtc_release(struct device *dev) |
187 | { | 137 | { |
188 | spin_lock_irq(&sa1100_rtc_lock); | 138 | struct sa1100_rtc *info = dev_get_drvdata(dev); |
139 | |||
140 | spin_lock_irq(&info->lock); | ||
189 | RTSR = 0; | 141 | RTSR = 0; |
190 | spin_unlock_irq(&sa1100_rtc_lock); | 142 | spin_unlock_irq(&info->lock); |
191 | 143 | ||
192 | free_irq(IRQ_RTCAlrm, dev); | 144 | free_irq(info->irq_alarm, dev); |
193 | free_irq(IRQ_RTC1Hz, dev); | 145 | free_irq(info->irq_1hz, dev); |
146 | clk_disable_unprepare(info->clk); | ||
194 | } | 147 | } |
195 | 148 | ||
196 | static int sa1100_rtc_alarm_irq_enable(struct device *dev, unsigned int enabled) | 149 | static int sa1100_rtc_alarm_irq_enable(struct device *dev, unsigned int enabled) |
197 | { | 150 | { |
198 | spin_lock_irq(&sa1100_rtc_lock); | 151 | struct sa1100_rtc *info = dev_get_drvdata(dev); |
152 | |||
153 | spin_lock_irq(&info->lock); | ||
199 | if (enabled) | 154 | if (enabled) |
200 | RTSR |= RTSR_ALE; | 155 | RTSR |= RTSR_ALE; |
201 | else | 156 | else |
202 | RTSR &= ~RTSR_ALE; | 157 | RTSR &= ~RTSR_ALE; |
203 | spin_unlock_irq(&sa1100_rtc_lock); | 158 | spin_unlock_irq(&info->lock); |
204 | return 0; | 159 | return 0; |
205 | } | 160 | } |
206 | 161 | ||
@@ -225,7 +180,6 @@ static int sa1100_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm) | |||
225 | { | 180 | { |
226 | u32 rtsr; | 181 | u32 rtsr; |
227 | 182 | ||
228 | memcpy(&alrm->time, &rtc_alarm, sizeof(struct rtc_time)); | ||
229 | rtsr = RTSR; | 183 | rtsr = RTSR; |
230 | alrm->enabled = (rtsr & RTSR_ALE) ? 1 : 0; | 184 | alrm->enabled = (rtsr & RTSR_ALE) ? 1 : 0; |
231 | alrm->pending = (rtsr & RTSR_AL) ? 1 : 0; | 185 | alrm->pending = (rtsr & RTSR_AL) ? 1 : 0; |
@@ -234,17 +188,22 @@ static int sa1100_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm) | |||
234 | 188 | ||
235 | static int sa1100_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm) | 189 | static int sa1100_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm) |
236 | { | 190 | { |
191 | struct sa1100_rtc *info = dev_get_drvdata(dev); | ||
192 | unsigned long time; | ||
237 | int ret; | 193 | int ret; |
238 | 194 | ||
239 | spin_lock_irq(&sa1100_rtc_lock); | 195 | spin_lock_irq(&info->lock); |
240 | ret = rtc_update_alarm(&alrm->time); | 196 | ret = rtc_tm_to_time(&alrm->time, &time); |
241 | if (ret == 0) { | 197 | if (ret != 0) |
242 | if (alrm->enabled) | 198 | goto out; |
243 | RTSR |= RTSR_ALE; | 199 | RTSR = RTSR & (RTSR_HZE|RTSR_ALE|RTSR_AL); |
244 | else | 200 | RTAR = time; |
245 | RTSR &= ~RTSR_ALE; | 201 | if (alrm->enabled) |
246 | } | 202 | RTSR |= RTSR_ALE; |
247 | spin_unlock_irq(&sa1100_rtc_lock); | 203 | else |
204 | RTSR &= ~RTSR_ALE; | ||
205 | out: | ||
206 | spin_unlock_irq(&info->lock); | ||
248 | 207 | ||
249 | return ret; | 208 | return ret; |
250 | } | 209 | } |
@@ -271,6 +230,27 @@ static const struct rtc_class_ops sa1100_rtc_ops = { | |||
271 | static int sa1100_rtc_probe(struct platform_device *pdev) | 230 | static int sa1100_rtc_probe(struct platform_device *pdev) |
272 | { | 231 | { |
273 | struct rtc_device *rtc; | 232 | struct rtc_device *rtc; |
233 | struct sa1100_rtc *info; | ||
234 | int irq_1hz, irq_alarm, ret = 0; | ||
235 | |||
236 | irq_1hz = platform_get_irq_byname(pdev, "rtc 1Hz"); | ||
237 | irq_alarm = platform_get_irq_byname(pdev, "rtc alarm"); | ||
238 | if (irq_1hz < 0 || irq_alarm < 0) | ||
239 | return -ENODEV; | ||
240 | |||
241 | info = kzalloc(sizeof(struct sa1100_rtc), GFP_KERNEL); | ||
242 | if (!info) | ||
243 | return -ENOMEM; | ||
244 | info->clk = clk_get(&pdev->dev, NULL); | ||
245 | if (IS_ERR(info->clk)) { | ||
246 | dev_err(&pdev->dev, "failed to find rtc clock source\n"); | ||
247 | ret = PTR_ERR(info->clk); | ||
248 | goto err_clk; | ||
249 | } | ||
250 | info->irq_1hz = irq_1hz; | ||
251 | info->irq_alarm = irq_alarm; | ||
252 | spin_lock_init(&info->lock); | ||
253 | platform_set_drvdata(pdev, info); | ||
274 | 254 | ||
275 | /* | 255 | /* |
276 | * According to the manual we should be able to let RTTR be zero | 256 | * According to the manual we should be able to let RTTR be zero |
@@ -292,10 +272,11 @@ static int sa1100_rtc_probe(struct platform_device *pdev) | |||
292 | rtc = rtc_device_register(pdev->name, &pdev->dev, &sa1100_rtc_ops, | 272 | rtc = rtc_device_register(pdev->name, &pdev->dev, &sa1100_rtc_ops, |
293 | THIS_MODULE); | 273 | THIS_MODULE); |
294 | 274 | ||
295 | if (IS_ERR(rtc)) | 275 | if (IS_ERR(rtc)) { |
296 | return PTR_ERR(rtc); | 276 | ret = PTR_ERR(rtc); |
297 | 277 | goto err_dev; | |
298 | platform_set_drvdata(pdev, rtc); | 278 | } |
279 | info->rtc = rtc; | ||
299 | 280 | ||
300 | /* Fix for a nasty initialization problem the in SA11xx RTSR register. | 281 | /* Fix for a nasty initialization problem the in SA11xx RTSR register. |
301 | * See also the comments in sa1100_rtc_interrupt(). | 282 | * See also the comments in sa1100_rtc_interrupt(). |
@@ -322,14 +303,24 @@ static int sa1100_rtc_probe(struct platform_device *pdev) | |||
322 | RTSR = RTSR_AL | RTSR_HZ; | 303 | RTSR = RTSR_AL | RTSR_HZ; |
323 | 304 | ||
324 | return 0; | 305 | return 0; |
306 | err_dev: | ||
307 | platform_set_drvdata(pdev, NULL); | ||
308 | clk_put(info->clk); | ||
309 | err_clk: | ||
310 | kfree(info); | ||
311 | return ret; | ||
325 | } | 312 | } |
326 | 313 | ||
327 | static int sa1100_rtc_remove(struct platform_device *pdev) | 314 | static int sa1100_rtc_remove(struct platform_device *pdev) |
328 | { | 315 | { |
329 | struct rtc_device *rtc = platform_get_drvdata(pdev); | 316 | struct sa1100_rtc *info = platform_get_drvdata(pdev); |
330 | 317 | ||
331 | if (rtc) | 318 | if (info) { |
332 | rtc_device_unregister(rtc); | 319 | rtc_device_unregister(info->rtc); |
320 | clk_put(info->clk); | ||
321 | platform_set_drvdata(pdev, NULL); | ||
322 | kfree(info); | ||
323 | } | ||
333 | 324 | ||
334 | return 0; | 325 | return 0; |
335 | } | 326 | } |
@@ -337,15 +328,17 @@ static int sa1100_rtc_remove(struct platform_device *pdev) | |||
337 | #ifdef CONFIG_PM | 328 | #ifdef CONFIG_PM |
338 | static int sa1100_rtc_suspend(struct device *dev) | 329 | static int sa1100_rtc_suspend(struct device *dev) |
339 | { | 330 | { |
331 | struct sa1100_rtc *info = dev_get_drvdata(dev); | ||
340 | if (device_may_wakeup(dev)) | 332 | if (device_may_wakeup(dev)) |
341 | enable_irq_wake(IRQ_RTCAlrm); | 333 | enable_irq_wake(info->irq_alarm); |
342 | return 0; | 334 | return 0; |
343 | } | 335 | } |
344 | 336 | ||
345 | static int sa1100_rtc_resume(struct device *dev) | 337 | static int sa1100_rtc_resume(struct device *dev) |
346 | { | 338 | { |
339 | struct sa1100_rtc *info = dev_get_drvdata(dev); | ||
347 | if (device_may_wakeup(dev)) | 340 | if (device_may_wakeup(dev)) |
348 | disable_irq_wake(IRQ_RTCAlrm); | 341 | disable_irq_wake(info->irq_alarm); |
349 | return 0; | 342 | return 0; |
350 | } | 343 | } |
351 | 344 | ||
@@ -355,6 +348,13 @@ static const struct dev_pm_ops sa1100_rtc_pm_ops = { | |||
355 | }; | 348 | }; |
356 | #endif | 349 | #endif |
357 | 350 | ||
351 | static struct of_device_id sa1100_rtc_dt_ids[] = { | ||
352 | { .compatible = "mrvl,sa1100-rtc", }, | ||
353 | { .compatible = "mrvl,mmp-rtc", }, | ||
354 | {} | ||
355 | }; | ||
356 | MODULE_DEVICE_TABLE(of, sa1100_rtc_dt_ids); | ||
357 | |||
358 | static struct platform_driver sa1100_rtc_driver = { | 358 | static struct platform_driver sa1100_rtc_driver = { |
359 | .probe = sa1100_rtc_probe, | 359 | .probe = sa1100_rtc_probe, |
360 | .remove = sa1100_rtc_remove, | 360 | .remove = sa1100_rtc_remove, |
@@ -363,6 +363,7 @@ static struct platform_driver sa1100_rtc_driver = { | |||
363 | #ifdef CONFIG_PM | 363 | #ifdef CONFIG_PM |
364 | .pm = &sa1100_rtc_pm_ops, | 364 | .pm = &sa1100_rtc_pm_ops, |
365 | #endif | 365 | #endif |
366 | .of_match_table = sa1100_rtc_dt_ids, | ||
366 | }, | 367 | }, |
367 | }; | 368 | }; |
368 | 369 | ||
diff --git a/drivers/rtc/rtc-sh.c b/drivers/rtc/rtc-sh.c index 6ac55fd48413..e55a7635ae5f 100644 --- a/drivers/rtc/rtc-sh.c +++ b/drivers/rtc/rtc-sh.c | |||
@@ -666,7 +666,7 @@ static int __init sh_rtc_probe(struct platform_device *pdev) | |||
666 | if (rtc->carry_irq <= 0) { | 666 | if (rtc->carry_irq <= 0) { |
667 | /* register shared periodic/carry/alarm irq */ | 667 | /* register shared periodic/carry/alarm irq */ |
668 | ret = request_irq(rtc->periodic_irq, sh_rtc_shared, | 668 | ret = request_irq(rtc->periodic_irq, sh_rtc_shared, |
669 | IRQF_DISABLED, "sh-rtc", rtc); | 669 | 0, "sh-rtc", rtc); |
670 | if (unlikely(ret)) { | 670 | if (unlikely(ret)) { |
671 | dev_err(&pdev->dev, | 671 | dev_err(&pdev->dev, |
672 | "request IRQ failed with %d, IRQ %d\n", ret, | 672 | "request IRQ failed with %d, IRQ %d\n", ret, |
@@ -676,7 +676,7 @@ static int __init sh_rtc_probe(struct platform_device *pdev) | |||
676 | } else { | 676 | } else { |
677 | /* register periodic/carry/alarm irqs */ | 677 | /* register periodic/carry/alarm irqs */ |
678 | ret = request_irq(rtc->periodic_irq, sh_rtc_periodic, | 678 | ret = request_irq(rtc->periodic_irq, sh_rtc_periodic, |
679 | IRQF_DISABLED, "sh-rtc period", rtc); | 679 | 0, "sh-rtc period", rtc); |
680 | if (unlikely(ret)) { | 680 | if (unlikely(ret)) { |
681 | dev_err(&pdev->dev, | 681 | dev_err(&pdev->dev, |
682 | "request period IRQ failed with %d, IRQ %d\n", | 682 | "request period IRQ failed with %d, IRQ %d\n", |
@@ -685,7 +685,7 @@ static int __init sh_rtc_probe(struct platform_device *pdev) | |||
685 | } | 685 | } |
686 | 686 | ||
687 | ret = request_irq(rtc->carry_irq, sh_rtc_interrupt, | 687 | ret = request_irq(rtc->carry_irq, sh_rtc_interrupt, |
688 | IRQF_DISABLED, "sh-rtc carry", rtc); | 688 | 0, "sh-rtc carry", rtc); |
689 | if (unlikely(ret)) { | 689 | if (unlikely(ret)) { |
690 | dev_err(&pdev->dev, | 690 | dev_err(&pdev->dev, |
691 | "request carry IRQ failed with %d, IRQ %d\n", | 691 | "request carry IRQ failed with %d, IRQ %d\n", |
@@ -695,7 +695,7 @@ static int __init sh_rtc_probe(struct platform_device *pdev) | |||
695 | } | 695 | } |
696 | 696 | ||
697 | ret = request_irq(rtc->alarm_irq, sh_rtc_alarm, | 697 | ret = request_irq(rtc->alarm_irq, sh_rtc_alarm, |
698 | IRQF_DISABLED, "sh-rtc alarm", rtc); | 698 | 0, "sh-rtc alarm", rtc); |
699 | if (unlikely(ret)) { | 699 | if (unlikely(ret)) { |
700 | dev_err(&pdev->dev, | 700 | dev_err(&pdev->dev, |
701 | "request alarm IRQ failed with %d, IRQ %d\n", | 701 | "request alarm IRQ failed with %d, IRQ %d\n", |
diff --git a/drivers/rtc/rtc-spear.c b/drivers/rtc/rtc-spear.c index 19a28a671a8e..e38da0dc4187 100644 --- a/drivers/rtc/rtc-spear.c +++ b/drivers/rtc/rtc-spear.c | |||
@@ -77,9 +77,11 @@ | |||
77 | #define STATUS_FAIL (LOST_WR_TIME | LOST_WR_DATE) | 77 | #define STATUS_FAIL (LOST_WR_TIME | LOST_WR_DATE) |
78 | 78 | ||
79 | struct spear_rtc_config { | 79 | struct spear_rtc_config { |
80 | struct rtc_device *rtc; | ||
80 | struct clk *clk; | 81 | struct clk *clk; |
81 | spinlock_t lock; | 82 | spinlock_t lock; |
82 | void __iomem *ioaddr; | 83 | void __iomem *ioaddr; |
84 | unsigned int irq_wake; | ||
83 | }; | 85 | }; |
84 | 86 | ||
85 | static inline void spear_rtc_clear_interrupt(struct spear_rtc_config *config) | 87 | static inline void spear_rtc_clear_interrupt(struct spear_rtc_config *config) |
@@ -149,8 +151,7 @@ static void rtc_wait_not_busy(struct spear_rtc_config *config) | |||
149 | 151 | ||
150 | static irqreturn_t spear_rtc_irq(int irq, void *dev_id) | 152 | static irqreturn_t spear_rtc_irq(int irq, void *dev_id) |
151 | { | 153 | { |
152 | struct rtc_device *rtc = (struct rtc_device *)dev_id; | 154 | struct spear_rtc_config *config = dev_id; |
153 | struct spear_rtc_config *config = dev_get_drvdata(&rtc->dev); | ||
154 | unsigned long flags, events = 0; | 155 | unsigned long flags, events = 0; |
155 | unsigned int irq_data; | 156 | unsigned int irq_data; |
156 | 157 | ||
@@ -161,7 +162,7 @@ static irqreturn_t spear_rtc_irq(int irq, void *dev_id) | |||
161 | if ((irq_data & RTC_INT_MASK)) { | 162 | if ((irq_data & RTC_INT_MASK)) { |
162 | spear_rtc_clear_interrupt(config); | 163 | spear_rtc_clear_interrupt(config); |
163 | events = RTC_IRQF | RTC_AF; | 164 | events = RTC_IRQF | RTC_AF; |
164 | rtc_update_irq(rtc, 1, events); | 165 | rtc_update_irq(config->rtc, 1, events); |
165 | return IRQ_HANDLED; | 166 | return IRQ_HANDLED; |
166 | } else | 167 | } else |
167 | return IRQ_NONE; | 168 | return IRQ_NONE; |
@@ -203,9 +204,7 @@ static void bcd2tm(struct rtc_time *tm) | |||
203 | */ | 204 | */ |
204 | static int spear_rtc_read_time(struct device *dev, struct rtc_time *tm) | 205 | static int spear_rtc_read_time(struct device *dev, struct rtc_time *tm) |
205 | { | 206 | { |
206 | struct platform_device *pdev = to_platform_device(dev); | 207 | struct spear_rtc_config *config = dev_get_drvdata(dev); |
207 | struct rtc_device *rtc = platform_get_drvdata(pdev); | ||
208 | struct spear_rtc_config *config = dev_get_drvdata(&rtc->dev); | ||
209 | unsigned int time, date; | 208 | unsigned int time, date; |
210 | 209 | ||
211 | /* we don't report wday/yday/isdst ... */ | 210 | /* we don't report wday/yday/isdst ... */ |
@@ -234,9 +233,7 @@ static int spear_rtc_read_time(struct device *dev, struct rtc_time *tm) | |||
234 | */ | 233 | */ |
235 | static int spear_rtc_set_time(struct device *dev, struct rtc_time *tm) | 234 | static int spear_rtc_set_time(struct device *dev, struct rtc_time *tm) |
236 | { | 235 | { |
237 | struct platform_device *pdev = to_platform_device(dev); | 236 | struct spear_rtc_config *config = dev_get_drvdata(dev); |
238 | struct rtc_device *rtc = platform_get_drvdata(pdev); | ||
239 | struct spear_rtc_config *config = dev_get_drvdata(&rtc->dev); | ||
240 | unsigned int time, date, err = 0; | 237 | unsigned int time, date, err = 0; |
241 | 238 | ||
242 | if (tm2bcd(tm) < 0) | 239 | if (tm2bcd(tm) < 0) |
@@ -266,9 +263,7 @@ static int spear_rtc_set_time(struct device *dev, struct rtc_time *tm) | |||
266 | */ | 263 | */ |
267 | static int spear_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alm) | 264 | static int spear_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alm) |
268 | { | 265 | { |
269 | struct platform_device *pdev = to_platform_device(dev); | 266 | struct spear_rtc_config *config = dev_get_drvdata(dev); |
270 | struct rtc_device *rtc = platform_get_drvdata(pdev); | ||
271 | struct spear_rtc_config *config = dev_get_drvdata(&rtc->dev); | ||
272 | unsigned int time, date; | 267 | unsigned int time, date; |
273 | 268 | ||
274 | rtc_wait_not_busy(config); | 269 | rtc_wait_not_busy(config); |
@@ -298,9 +293,7 @@ static int spear_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alm) | |||
298 | */ | 293 | */ |
299 | static int spear_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alm) | 294 | static int spear_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alm) |
300 | { | 295 | { |
301 | struct platform_device *pdev = to_platform_device(dev); | 296 | struct spear_rtc_config *config = dev_get_drvdata(dev); |
302 | struct rtc_device *rtc = platform_get_drvdata(pdev); | ||
303 | struct spear_rtc_config *config = dev_get_drvdata(&rtc->dev); | ||
304 | unsigned int time, date, err = 0; | 297 | unsigned int time, date, err = 0; |
305 | 298 | ||
306 | if (tm2bcd(&alm->time) < 0) | 299 | if (tm2bcd(&alm->time) < 0) |
@@ -326,17 +319,42 @@ static int spear_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alm) | |||
326 | 319 | ||
327 | return 0; | 320 | return 0; |
328 | } | 321 | } |
322 | |||
323 | static int spear_alarm_irq_enable(struct device *dev, unsigned int enabled) | ||
324 | { | ||
325 | struct spear_rtc_config *config = dev_get_drvdata(dev); | ||
326 | int ret = 0; | ||
327 | |||
328 | spear_rtc_clear_interrupt(config); | ||
329 | |||
330 | switch (enabled) { | ||
331 | case 0: | ||
332 | /* alarm off */ | ||
333 | spear_rtc_disable_interrupt(config); | ||
334 | break; | ||
335 | case 1: | ||
336 | /* alarm on */ | ||
337 | spear_rtc_enable_interrupt(config); | ||
338 | break; | ||
339 | default: | ||
340 | ret = -EINVAL; | ||
341 | break; | ||
342 | } | ||
343 | |||
344 | return ret; | ||
345 | } | ||
346 | |||
329 | static struct rtc_class_ops spear_rtc_ops = { | 347 | static struct rtc_class_ops spear_rtc_ops = { |
330 | .read_time = spear_rtc_read_time, | 348 | .read_time = spear_rtc_read_time, |
331 | .set_time = spear_rtc_set_time, | 349 | .set_time = spear_rtc_set_time, |
332 | .read_alarm = spear_rtc_read_alarm, | 350 | .read_alarm = spear_rtc_read_alarm, |
333 | .set_alarm = spear_rtc_set_alarm, | 351 | .set_alarm = spear_rtc_set_alarm, |
352 | .alarm_irq_enable = spear_alarm_irq_enable, | ||
334 | }; | 353 | }; |
335 | 354 | ||
336 | static int __devinit spear_rtc_probe(struct platform_device *pdev) | 355 | static int __devinit spear_rtc_probe(struct platform_device *pdev) |
337 | { | 356 | { |
338 | struct resource *res; | 357 | struct resource *res; |
339 | struct rtc_device *rtc; | ||
340 | struct spear_rtc_config *config; | 358 | struct spear_rtc_config *config; |
341 | unsigned int status = 0; | 359 | unsigned int status = 0; |
342 | int irq; | 360 | int irq; |
@@ -376,19 +394,17 @@ static int __devinit spear_rtc_probe(struct platform_device *pdev) | |||
376 | } | 394 | } |
377 | 395 | ||
378 | spin_lock_init(&config->lock); | 396 | spin_lock_init(&config->lock); |
397 | platform_set_drvdata(pdev, config); | ||
379 | 398 | ||
380 | rtc = rtc_device_register(pdev->name, &pdev->dev, &spear_rtc_ops, | 399 | config->rtc = rtc_device_register(pdev->name, &pdev->dev, |
381 | THIS_MODULE); | 400 | &spear_rtc_ops, THIS_MODULE); |
382 | if (IS_ERR(rtc)) { | 401 | if (IS_ERR(config->rtc)) { |
383 | dev_err(&pdev->dev, "can't register RTC device, err %ld\n", | 402 | dev_err(&pdev->dev, "can't register RTC device, err %ld\n", |
384 | PTR_ERR(rtc)); | 403 | PTR_ERR(config->rtc)); |
385 | status = PTR_ERR(rtc); | 404 | status = PTR_ERR(config->rtc); |
386 | goto err_iounmap; | 405 | goto err_iounmap; |
387 | } | 406 | } |
388 | 407 | ||
389 | platform_set_drvdata(pdev, rtc); | ||
390 | dev_set_drvdata(&rtc->dev, config); | ||
391 | |||
392 | /* alarm irqs */ | 408 | /* alarm irqs */ |
393 | irq = platform_get_irq(pdev, 0); | 409 | irq = platform_get_irq(pdev, 0); |
394 | if (irq < 0) { | 410 | if (irq < 0) { |
@@ -397,7 +413,7 @@ static int __devinit spear_rtc_probe(struct platform_device *pdev) | |||
397 | goto err_clear_platdata; | 413 | goto err_clear_platdata; |
398 | } | 414 | } |
399 | 415 | ||
400 | status = request_irq(irq, spear_rtc_irq, 0, pdev->name, rtc); | 416 | status = request_irq(irq, spear_rtc_irq, 0, pdev->name, config); |
401 | if (status) { | 417 | if (status) { |
402 | dev_err(&pdev->dev, "Alarm interrupt IRQ%d already \ | 418 | dev_err(&pdev->dev, "Alarm interrupt IRQ%d already \ |
403 | claimed\n", irq); | 419 | claimed\n", irq); |
@@ -411,8 +427,7 @@ static int __devinit spear_rtc_probe(struct platform_device *pdev) | |||
411 | 427 | ||
412 | err_clear_platdata: | 428 | err_clear_platdata: |
413 | platform_set_drvdata(pdev, NULL); | 429 | platform_set_drvdata(pdev, NULL); |
414 | dev_set_drvdata(&rtc->dev, NULL); | 430 | rtc_device_unregister(config->rtc); |
415 | rtc_device_unregister(rtc); | ||
416 | err_iounmap: | 431 | err_iounmap: |
417 | iounmap(config->ioaddr); | 432 | iounmap(config->ioaddr); |
418 | err_disable_clock: | 433 | err_disable_clock: |
@@ -429,8 +444,7 @@ err_release_region: | |||
429 | 444 | ||
430 | static int __devexit spear_rtc_remove(struct platform_device *pdev) | 445 | static int __devexit spear_rtc_remove(struct platform_device *pdev) |
431 | { | 446 | { |
432 | struct rtc_device *rtc = platform_get_drvdata(pdev); | 447 | struct spear_rtc_config *config = platform_get_drvdata(pdev); |
433 | struct spear_rtc_config *config = dev_get_drvdata(&rtc->dev); | ||
434 | int irq; | 448 | int irq; |
435 | struct resource *res; | 449 | struct resource *res; |
436 | 450 | ||
@@ -448,8 +462,7 @@ static int __devexit spear_rtc_remove(struct platform_device *pdev) | |||
448 | if (res) | 462 | if (res) |
449 | release_mem_region(res->start, resource_size(res)); | 463 | release_mem_region(res->start, resource_size(res)); |
450 | platform_set_drvdata(pdev, NULL); | 464 | platform_set_drvdata(pdev, NULL); |
451 | dev_set_drvdata(&rtc->dev, NULL); | 465 | rtc_device_unregister(config->rtc); |
452 | rtc_device_unregister(rtc); | ||
453 | 466 | ||
454 | return 0; | 467 | return 0; |
455 | } | 468 | } |
@@ -458,14 +471,14 @@ static int __devexit spear_rtc_remove(struct platform_device *pdev) | |||
458 | 471 | ||
459 | static int spear_rtc_suspend(struct platform_device *pdev, pm_message_t state) | 472 | static int spear_rtc_suspend(struct platform_device *pdev, pm_message_t state) |
460 | { | 473 | { |
461 | struct rtc_device *rtc = platform_get_drvdata(pdev); | 474 | struct spear_rtc_config *config = platform_get_drvdata(pdev); |
462 | struct spear_rtc_config *config = dev_get_drvdata(&rtc->dev); | ||
463 | int irq; | 475 | int irq; |
464 | 476 | ||
465 | irq = platform_get_irq(pdev, 0); | 477 | irq = platform_get_irq(pdev, 0); |
466 | if (device_may_wakeup(&pdev->dev)) | 478 | if (device_may_wakeup(&pdev->dev)) { |
467 | enable_irq_wake(irq); | 479 | if (!enable_irq_wake(irq)) |
468 | else { | 480 | config->irq_wake = 1; |
481 | } else { | ||
469 | spear_rtc_disable_interrupt(config); | 482 | spear_rtc_disable_interrupt(config); |
470 | clk_disable(config->clk); | 483 | clk_disable(config->clk); |
471 | } | 484 | } |
@@ -475,15 +488,17 @@ static int spear_rtc_suspend(struct platform_device *pdev, pm_message_t state) | |||
475 | 488 | ||
476 | static int spear_rtc_resume(struct platform_device *pdev) | 489 | static int spear_rtc_resume(struct platform_device *pdev) |
477 | { | 490 | { |
478 | struct rtc_device *rtc = platform_get_drvdata(pdev); | 491 | struct spear_rtc_config *config = platform_get_drvdata(pdev); |
479 | struct spear_rtc_config *config = dev_get_drvdata(&rtc->dev); | ||
480 | int irq; | 492 | int irq; |
481 | 493 | ||
482 | irq = platform_get_irq(pdev, 0); | 494 | irq = platform_get_irq(pdev, 0); |
483 | 495 | ||
484 | if (device_may_wakeup(&pdev->dev)) | 496 | if (device_may_wakeup(&pdev->dev)) { |
485 | disable_irq_wake(irq); | 497 | if (config->irq_wake) { |
486 | else { | 498 | disable_irq_wake(irq); |
499 | config->irq_wake = 0; | ||
500 | } | ||
501 | } else { | ||
487 | clk_enable(config->clk); | 502 | clk_enable(config->clk); |
488 | spear_rtc_enable_interrupt(config); | 503 | spear_rtc_enable_interrupt(config); |
489 | } | 504 | } |
@@ -498,8 +513,7 @@ static int spear_rtc_resume(struct platform_device *pdev) | |||
498 | 513 | ||
499 | static void spear_rtc_shutdown(struct platform_device *pdev) | 514 | static void spear_rtc_shutdown(struct platform_device *pdev) |
500 | { | 515 | { |
501 | struct rtc_device *rtc = platform_get_drvdata(pdev); | 516 | struct spear_rtc_config *config = platform_get_drvdata(pdev); |
502 | struct spear_rtc_config *config = dev_get_drvdata(&rtc->dev); | ||
503 | 517 | ||
504 | spear_rtc_disable_interrupt(config); | 518 | spear_rtc_disable_interrupt(config); |
505 | clk_disable(config->clk); | 519 | clk_disable(config->clk); |
diff --git a/drivers/rtc/rtc-stk17ta8.c b/drivers/rtc/rtc-stk17ta8.c index 7621116bd20d..279f5cfa691a 100644 --- a/drivers/rtc/rtc-stk17ta8.c +++ b/drivers/rtc/rtc-stk17ta8.c | |||
@@ -329,7 +329,7 @@ static int __devinit stk17ta8_rtc_probe(struct platform_device *pdev) | |||
329 | writeb(0, ioaddr + RTC_INTERRUPTS); | 329 | writeb(0, ioaddr + RTC_INTERRUPTS); |
330 | if (devm_request_irq(&pdev->dev, pdata->irq, | 330 | if (devm_request_irq(&pdev->dev, pdata->irq, |
331 | stk17ta8_rtc_interrupt, | 331 | stk17ta8_rtc_interrupt, |
332 | IRQF_DISABLED | IRQF_SHARED, | 332 | IRQF_SHARED, |
333 | pdev->name, pdev) < 0) { | 333 | pdev->name, pdev) < 0) { |
334 | dev_warn(&pdev->dev, "interrupt not available.\n"); | 334 | dev_warn(&pdev->dev, "interrupt not available.\n"); |
335 | pdata->irq = 0; | 335 | pdata->irq = 0; |
diff --git a/drivers/rtc/rtc-twl.c b/drivers/rtc/rtc-twl.c index d43b4f6eb4e4..4c2c6df2a9ef 100644 --- a/drivers/rtc/rtc-twl.c +++ b/drivers/rtc/rtc-twl.c | |||
@@ -176,6 +176,10 @@ static int set_rtc_irq_bit(unsigned char bit) | |||
176 | unsigned char val; | 176 | unsigned char val; |
177 | int ret; | 177 | int ret; |
178 | 178 | ||
179 | /* if the bit is set, return from here */ | ||
180 | if (rtc_irq_bits & bit) | ||
181 | return 0; | ||
182 | |||
179 | val = rtc_irq_bits | bit; | 183 | val = rtc_irq_bits | bit; |
180 | val &= ~BIT_RTC_INTERRUPTS_REG_EVERY_M; | 184 | val &= ~BIT_RTC_INTERRUPTS_REG_EVERY_M; |
181 | ret = twl_rtc_write_u8(val, REG_RTC_INTERRUPTS_REG); | 185 | ret = twl_rtc_write_u8(val, REG_RTC_INTERRUPTS_REG); |
@@ -193,6 +197,10 @@ static int mask_rtc_irq_bit(unsigned char bit) | |||
193 | unsigned char val; | 197 | unsigned char val; |
194 | int ret; | 198 | int ret; |
195 | 199 | ||
200 | /* if the bit is clear, return from here */ | ||
201 | if (!(rtc_irq_bits & bit)) | ||
202 | return 0; | ||
203 | |||
196 | val = rtc_irq_bits & ~bit; | 204 | val = rtc_irq_bits & ~bit; |
197 | ret = twl_rtc_write_u8(val, REG_RTC_INTERRUPTS_REG); | 205 | ret = twl_rtc_write_u8(val, REG_RTC_INTERRUPTS_REG); |
198 | if (ret == 0) | 206 | if (ret == 0) |
@@ -357,7 +365,7 @@ out: | |||
357 | 365 | ||
358 | static irqreturn_t twl_rtc_interrupt(int irq, void *rtc) | 366 | static irqreturn_t twl_rtc_interrupt(int irq, void *rtc) |
359 | { | 367 | { |
360 | unsigned long events = 0; | 368 | unsigned long events; |
361 | int ret = IRQ_NONE; | 369 | int ret = IRQ_NONE; |
362 | int res; | 370 | int res; |
363 | u8 rd_reg; | 371 | u8 rd_reg; |
@@ -372,11 +380,11 @@ static irqreturn_t twl_rtc_interrupt(int irq, void *rtc) | |||
372 | * by reading RTS_INTERRUPTS_REGISTER[IT_TIMER,IT_ALARM] | 380 | * by reading RTS_INTERRUPTS_REGISTER[IT_TIMER,IT_ALARM] |
373 | */ | 381 | */ |
374 | if (rd_reg & BIT_RTC_STATUS_REG_ALARM_M) | 382 | if (rd_reg & BIT_RTC_STATUS_REG_ALARM_M) |
375 | events |= RTC_IRQF | RTC_AF; | 383 | events = RTC_IRQF | RTC_AF; |
376 | else | 384 | else |
377 | events |= RTC_IRQF | RTC_UF; | 385 | events = RTC_IRQF | RTC_PF; |
378 | 386 | ||
379 | res = twl_rtc_write_u8(rd_reg | BIT_RTC_STATUS_REG_ALARM_M, | 387 | res = twl_rtc_write_u8(BIT_RTC_STATUS_REG_ALARM_M, |
380 | REG_RTC_STATUS_REG); | 388 | REG_RTC_STATUS_REG); |
381 | if (res) | 389 | if (res) |
382 | goto out; | 390 | goto out; |
@@ -449,19 +457,11 @@ static int __devinit twl_rtc_probe(struct platform_device *pdev) | |||
449 | REG_INT_MSK_STS_A); | 457 | REG_INT_MSK_STS_A); |
450 | } | 458 | } |
451 | 459 | ||
452 | /* Check RTC module status, Enable if it is off */ | 460 | dev_info(&pdev->dev, "Enabling TWL-RTC\n"); |
453 | ret = twl_rtc_read_u8(&rd_reg, REG_RTC_CTRL_REG); | 461 | ret = twl_rtc_write_u8(BIT_RTC_CTRL_REG_STOP_RTC_M, REG_RTC_CTRL_REG); |
454 | if (ret < 0) | 462 | if (ret < 0) |
455 | goto out1; | 463 | goto out1; |
456 | 464 | ||
457 | if (!(rd_reg & BIT_RTC_CTRL_REG_STOP_RTC_M)) { | ||
458 | dev_info(&pdev->dev, "Enabling TWL-RTC.\n"); | ||
459 | rd_reg = BIT_RTC_CTRL_REG_STOP_RTC_M; | ||
460 | ret = twl_rtc_write_u8(rd_reg, REG_RTC_CTRL_REG); | ||
461 | if (ret < 0) | ||
462 | goto out1; | ||
463 | } | ||
464 | |||
465 | /* init cached IRQ enable bits */ | 465 | /* init cached IRQ enable bits */ |
466 | ret = twl_rtc_read_u8(&rtc_irq_bits, REG_RTC_INTERRUPTS_REG); | 466 | ret = twl_rtc_read_u8(&rtc_irq_bits, REG_RTC_INTERRUPTS_REG); |
467 | if (ret < 0) | 467 | if (ret < 0) |
diff --git a/drivers/rtc/rtc-tx4939.c b/drivers/rtc/rtc-tx4939.c index aac0ffed4345..a12bfac49d36 100644 --- a/drivers/rtc/rtc-tx4939.c +++ b/drivers/rtc/rtc-tx4939.c | |||
@@ -266,7 +266,7 @@ static int __init tx4939_rtc_probe(struct platform_device *pdev) | |||
266 | spin_lock_init(&pdata->lock); | 266 | spin_lock_init(&pdata->lock); |
267 | tx4939_rtc_cmd(pdata->rtcreg, TX4939_RTCCTL_COMMAND_NOP); | 267 | tx4939_rtc_cmd(pdata->rtcreg, TX4939_RTCCTL_COMMAND_NOP); |
268 | if (devm_request_irq(&pdev->dev, irq, tx4939_rtc_interrupt, | 268 | if (devm_request_irq(&pdev->dev, irq, tx4939_rtc_interrupt, |
269 | IRQF_DISABLED, pdev->name, &pdev->dev) < 0) | 269 | 0, pdev->name, &pdev->dev) < 0) |
270 | return -EBUSY; | 270 | return -EBUSY; |
271 | rtc = rtc_device_register(pdev->name, &pdev->dev, | 271 | rtc = rtc_device_register(pdev->name, &pdev->dev, |
272 | &tx4939_rtc_ops, THIS_MODULE); | 272 | &tx4939_rtc_ops, THIS_MODULE); |
diff --git a/drivers/rtc/rtc-vr41xx.c b/drivers/rtc/rtc-vr41xx.c index fcbfdda2993b..5f60a7c6a155 100644 --- a/drivers/rtc/rtc-vr41xx.c +++ b/drivers/rtc/rtc-vr41xx.c | |||
@@ -333,7 +333,7 @@ static int __devinit rtc_probe(struct platform_device *pdev) | |||
333 | goto err_device_unregister; | 333 | goto err_device_unregister; |
334 | } | 334 | } |
335 | 335 | ||
336 | retval = request_irq(aie_irq, elapsedtime_interrupt, IRQF_DISABLED, | 336 | retval = request_irq(aie_irq, elapsedtime_interrupt, 0, |
337 | "elapsed_time", pdev); | 337 | "elapsed_time", pdev); |
338 | if (retval < 0) | 338 | if (retval < 0) |
339 | goto err_device_unregister; | 339 | goto err_device_unregister; |
@@ -342,7 +342,7 @@ static int __devinit rtc_probe(struct platform_device *pdev) | |||
342 | if (pie_irq <= 0) | 342 | if (pie_irq <= 0) |
343 | goto err_free_irq; | 343 | goto err_free_irq; |
344 | 344 | ||
345 | retval = request_irq(pie_irq, rtclong1_interrupt, IRQF_DISABLED, | 345 | retval = request_irq(pie_irq, rtclong1_interrupt, 0, |
346 | "rtclong1", pdev); | 346 | "rtclong1", pdev); |
347 | if (retval < 0) | 347 | if (retval < 0) |
348 | goto err_free_irq; | 348 | goto err_free_irq; |
diff --git a/drivers/rtc/rtc-x1205.c b/drivers/rtc/rtc-x1205.c index 8c051d3179db..403b3d41d101 100644 --- a/drivers/rtc/rtc-x1205.c +++ b/drivers/rtc/rtc-x1205.c | |||
@@ -623,15 +623,7 @@ static struct i2c_driver x1205_driver = { | |||
623 | .id_table = x1205_id, | 623 | .id_table = x1205_id, |
624 | }; | 624 | }; |
625 | 625 | ||
626 | static int __init x1205_init(void) | 626 | module_i2c_driver(x1205_driver); |
627 | { | ||
628 | return i2c_add_driver(&x1205_driver); | ||
629 | } | ||
630 | |||
631 | static void __exit x1205_exit(void) | ||
632 | { | ||
633 | i2c_del_driver(&x1205_driver); | ||
634 | } | ||
635 | 627 | ||
636 | MODULE_AUTHOR( | 628 | MODULE_AUTHOR( |
637 | "Karen Spearel <kas111 at gmail dot com>, " | 629 | "Karen Spearel <kas111 at gmail dot com>, " |
@@ -639,6 +631,3 @@ MODULE_AUTHOR( | |||
639 | MODULE_DESCRIPTION("Xicor/Intersil X1205 RTC driver"); | 631 | MODULE_DESCRIPTION("Xicor/Intersil X1205 RTC driver"); |
640 | MODULE_LICENSE("GPL"); | 632 | MODULE_LICENSE("GPL"); |
641 | MODULE_VERSION(DRV_VERSION); | 633 | MODULE_VERSION(DRV_VERSION); |
642 | |||
643 | module_init(x1205_init); | ||
644 | module_exit(x1205_exit); | ||