diff options
Diffstat (limited to 'drivers/rtc')
58 files changed, 916 insertions, 694 deletions
diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig index e19a4031f45e..4f9fb25f945b 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 |
@@ -774,7 +781,7 @@ config RTC_DRV_EP93XX | |||
774 | 781 | ||
775 | config RTC_DRV_SA1100 | 782 | config RTC_DRV_SA1100 |
776 | tristate "SA11x0/PXA2xx" | 783 | tristate "SA11x0/PXA2xx" |
777 | depends on ARCH_SA1100 || ARCH_PXA || ARCH_MMP | 784 | depends on ARCH_SA1100 || ARCH_PXA |
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..274a0aafe42b 100644 --- a/drivers/rtc/rtc-at91sam9.c +++ b/drivers/rtc/rtc-at91sam9.c | |||
@@ -307,8 +307,12 @@ static int __init at91_rtc_probe(struct platform_device *pdev) | |||
307 | device_init_wakeup(&pdev->dev, 1); | 307 | device_init_wakeup(&pdev->dev, 1); |
308 | 308 | ||
309 | platform_set_drvdata(pdev, rtc); | 309 | platform_set_drvdata(pdev, rtc); |
310 | rtc->rtt = (void __force __iomem *) (AT91_VA_BASE_SYS - AT91_BASE_SYS); | 310 | rtc->rtt = ioremap(r->start, resource_size(r)); |
311 | rtc->rtt += r->start; | 311 | if (!rtc->rtt) { |
312 | dev_err(&pdev->dev, "failed to map registers, aborting.\n"); | ||
313 | ret = -ENOMEM; | ||
314 | goto fail; | ||
315 | } | ||
312 | 316 | ||
313 | mr = rtt_readl(rtc, MR); | 317 | mr = rtt_readl(rtc, MR); |
314 | 318 | ||
@@ -326,12 +330,12 @@ static int __init at91_rtc_probe(struct platform_device *pdev) | |||
326 | &at91_rtc_ops, THIS_MODULE); | 330 | &at91_rtc_ops, THIS_MODULE); |
327 | if (IS_ERR(rtc->rtcdev)) { | 331 | if (IS_ERR(rtc->rtcdev)) { |
328 | ret = PTR_ERR(rtc->rtcdev); | 332 | ret = PTR_ERR(rtc->rtcdev); |
329 | goto fail; | 333 | goto fail_register; |
330 | } | 334 | } |
331 | 335 | ||
332 | /* register irq handler after we know what name we'll use */ | 336 | /* register irq handler after we know what name we'll use */ |
333 | ret = request_irq(AT91_ID_SYS, at91_rtc_interrupt, | 337 | ret = request_irq(AT91_ID_SYS, at91_rtc_interrupt, |
334 | IRQF_DISABLED | IRQF_SHARED, | 338 | IRQF_SHARED, |
335 | dev_name(&rtc->rtcdev->dev), rtc); | 339 | dev_name(&rtc->rtcdev->dev), rtc); |
336 | if (ret) { | 340 | if (ret) { |
337 | dev_dbg(&pdev->dev, "can't share IRQ %d?\n", AT91_ID_SYS); | 341 | dev_dbg(&pdev->dev, "can't share IRQ %d?\n", AT91_ID_SYS); |
@@ -351,6 +355,8 @@ static int __init at91_rtc_probe(struct platform_device *pdev) | |||
351 | 355 | ||
352 | return 0; | 356 | return 0; |
353 | 357 | ||
358 | fail_register: | ||
359 | iounmap(rtc->rtt); | ||
354 | fail: | 360 | fail: |
355 | platform_set_drvdata(pdev, NULL); | 361 | platform_set_drvdata(pdev, NULL); |
356 | kfree(rtc); | 362 | kfree(rtc); |
@@ -371,6 +377,7 @@ static int __exit at91_rtc_remove(struct platform_device *pdev) | |||
371 | 377 | ||
372 | rtc_device_unregister(rtc->rtcdev); | 378 | rtc_device_unregister(rtc->rtcdev); |
373 | 379 | ||
380 | iounmap(rtc->rtt); | ||
374 | platform_set_drvdata(pdev, NULL); | 381 | platform_set_drvdata(pdev, NULL); |
375 | kfree(rtc); | 382 | kfree(rtc); |
376 | return 0; | 383 | return 0; |
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 b2d3d20baebc..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; |
diff --git a/drivers/rtc/rtc-pl031.c b/drivers/rtc/rtc-pl031.c index 359e2c53c545..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 | } |
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..c543f6f1eec2 100644 --- a/drivers/rtc/rtc-s3c.c +++ b/drivers/rtc/rtc-s3c.c | |||
@@ -543,14 +543,14 @@ static int __devinit s3c_rtc_probe(struct platform_device *pdev) | |||
543 | s3c_rtc_setfreq(&pdev->dev, 1); | 543 | s3c_rtc_setfreq(&pdev->dev, 1); |
544 | 544 | ||
545 | ret = request_irq(s3c_rtc_alarmno, s3c_rtc_alarmirq, | 545 | ret = request_irq(s3c_rtc_alarmno, s3c_rtc_alarmirq, |
546 | IRQF_DISABLED, "s3c2410-rtc alarm", rtc); | 546 | 0, "s3c2410-rtc alarm", rtc); |
547 | if (ret) { | 547 | if (ret) { |
548 | dev_err(&pdev->dev, "IRQ%d error %d\n", s3c_rtc_alarmno, ret); | 548 | dev_err(&pdev->dev, "IRQ%d error %d\n", s3c_rtc_alarmno, ret); |
549 | goto err_alarm_irq; | 549 | goto err_alarm_irq; |
550 | } | 550 | } |
551 | 551 | ||
552 | ret = request_irq(s3c_rtc_tickno, s3c_rtc_tickirq, | 552 | ret = request_irq(s3c_rtc_tickno, s3c_rtc_tickirq, |
553 | IRQF_DISABLED, "s3c2410-rtc tick", rtc); | 553 | 0, "s3c2410-rtc tick", rtc); |
554 | if (ret) { | 554 | if (ret) { |
555 | dev_err(&pdev->dev, "IRQ%d error %d\n", s3c_rtc_tickno, ret); | 555 | dev_err(&pdev->dev, "IRQ%d error %d\n", s3c_rtc_tickno, ret); |
556 | free_irq(s3c_rtc_alarmno, rtc); | 556 | free_irq(s3c_rtc_alarmno, rtc); |
diff --git a/drivers/rtc/rtc-sa1100.c b/drivers/rtc/rtc-sa1100.c index 4595d3e645a7..fb758db9d0f4 100644 --- a/drivers/rtc/rtc-sa1100.c +++ b/drivers/rtc/rtc-sa1100.c | |||
@@ -27,42 +27,34 @@ | |||
27 | #include <linux/init.h> | 27 | #include <linux/init.h> |
28 | #include <linux/fs.h> | 28 | #include <linux/fs.h> |
29 | #include <linux/interrupt.h> | 29 | #include <linux/interrupt.h> |
30 | #include <linux/string.h> | ||
30 | #include <linux/pm.h> | 31 | #include <linux/pm.h> |
31 | #include <linux/slab.h> | 32 | #include <linux/bitops.h> |
32 | #include <linux/clk.h> | ||
33 | #include <linux/io.h> | ||
34 | 33 | ||
35 | #include <mach/hardware.h> | 34 | #include <mach/hardware.h> |
36 | #include <asm/irq.h> | 35 | #include <asm/irq.h> |
37 | 36 | ||
37 | #ifdef CONFIG_ARCH_PXA | ||
38 | #include <mach/regs-rtc.h> | ||
39 | #endif | ||
40 | |||
38 | #define RTC_DEF_DIVIDER (32768 - 1) | 41 | #define RTC_DEF_DIVIDER (32768 - 1) |
39 | #define RTC_DEF_TRIM 0 | 42 | #define RTC_DEF_TRIM 0 |
40 | #define RTC_FREQ 1024 | 43 | |
41 | 44 | static const unsigned long RTC_FREQ = 1024; | |
42 | #define RCNR 0x00 /* RTC Count Register */ | 45 | static struct rtc_time rtc_alarm; |
43 | #define RTAR 0x04 /* RTC Alarm Register */ | 46 | static DEFINE_SPINLOCK(sa1100_rtc_lock); |
44 | #define RTSR 0x08 /* RTC Status Register */ | 47 | |
45 | #define RTTR 0x0c /* RTC Timer Trim Register */ | 48 | static inline int rtc_periodic_alarm(struct rtc_time *tm) |
46 | 49 | { | |
47 | #define RTSR_HZE (1 << 3) /* HZ interrupt enable */ | 50 | return (tm->tm_year == -1) || |
48 | #define RTSR_ALE (1 << 2) /* RTC alarm interrupt enable */ | 51 | ((unsigned)tm->tm_mon >= 12) || |
49 | #define RTSR_HZ (1 << 1) /* HZ rising-edge detected */ | 52 | ((unsigned)(tm->tm_mday - 1) >= 31) || |
50 | #define RTSR_AL (1 << 0) /* RTC alarm detected */ | 53 | ((unsigned)tm->tm_hour > 23) || |
51 | 54 | ((unsigned)tm->tm_min > 59) || | |
52 | #define rtc_readl(sa1100_rtc, reg) \ | 55 | ((unsigned)tm->tm_sec > 59); |
53 | readl_relaxed((sa1100_rtc)->base + (reg)) | 56 | } |
54 | #define rtc_writel(sa1100_rtc, reg, value) \ | 57 | |
55 | writel_relaxed((value), (sa1100_rtc)->base + (reg)) | ||
56 | |||
57 | struct sa1100_rtc { | ||
58 | struct resource *ress; | ||
59 | void __iomem *base; | ||
60 | struct clk *clk; | ||
61 | int irq_1Hz; | ||
62 | int irq_Alrm; | ||
63 | struct rtc_device *rtc; | ||
64 | spinlock_t lock; /* Protects this structure */ | ||
65 | }; | ||
66 | /* | 58 | /* |
67 | * Calculate the next alarm time given the requested alarm time mask | 59 | * Calculate the next alarm time given the requested alarm time mask |
68 | * and the current time. | 60 | * and the current time. |
@@ -90,26 +82,46 @@ static void rtc_next_alarm_time(struct rtc_time *next, struct rtc_time *now, | |||
90 | } | 82 | } |
91 | } | 83 | } |
92 | 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 | |||
93 | static irqreturn_t sa1100_rtc_interrupt(int irq, void *dev_id) | 106 | static irqreturn_t sa1100_rtc_interrupt(int irq, void *dev_id) |
94 | { | 107 | { |
95 | struct platform_device *pdev = to_platform_device(dev_id); | 108 | struct platform_device *pdev = to_platform_device(dev_id); |
96 | struct sa1100_rtc *sa1100_rtc = platform_get_drvdata(pdev); | 109 | struct rtc_device *rtc = platform_get_drvdata(pdev); |
97 | unsigned int rtsr; | 110 | unsigned int rtsr; |
98 | unsigned long events = 0; | 111 | unsigned long events = 0; |
99 | 112 | ||
100 | spin_lock(&sa1100_rtc->lock); | 113 | spin_lock(&sa1100_rtc_lock); |
101 | 114 | ||
115 | rtsr = RTSR; | ||
102 | /* clear interrupt sources */ | 116 | /* clear interrupt sources */ |
103 | rtsr = rtc_readl(sa1100_rtc, RTSR); | 117 | RTSR = 0; |
104 | rtc_writel(sa1100_rtc, RTSR, 0); | ||
105 | |||
106 | /* Fix for a nasty initialization problem the in SA11xx RTSR register. | 118 | /* Fix for a nasty initialization problem the in SA11xx RTSR register. |
107 | * See also the comments in sa1100_rtc_probe(). */ | 119 | * See also the comments in sa1100_rtc_probe(). */ |
108 | if (rtsr & (RTSR_ALE | RTSR_HZE)) { | 120 | if (rtsr & (RTSR_ALE | RTSR_HZE)) { |
109 | /* This is the original code, before there was the if test | 121 | /* This is the original code, before there was the if test |
110 | * above. This code does not clear interrupts that were not | 122 | * above. This code does not clear interrupts that were not |
111 | * enabled. */ | 123 | * enabled. */ |
112 | rtc_writel(sa1100_rtc, RTSR, (RTSR_AL | RTSR_HZ) & (rtsr >> 2)); | 124 | RTSR = (RTSR_AL | RTSR_HZ) & (rtsr >> 2); |
113 | } else { | 125 | } else { |
114 | /* For some reason, it is possible to enter this routine | 126 | /* For some reason, it is possible to enter this routine |
115 | * without interruptions enabled, it has been tested with | 127 | * without interruptions enabled, it has been tested with |
@@ -118,13 +130,13 @@ static irqreturn_t sa1100_rtc_interrupt(int irq, void *dev_id) | |||
118 | * This situation leads to an infinite "loop" of interrupt | 130 | * This situation leads to an infinite "loop" of interrupt |
119 | * routine calling and as a result the processor seems to | 131 | * routine calling and as a result the processor seems to |
120 | * lock on its first call to open(). */ | 132 | * lock on its first call to open(). */ |
121 | rtc_writel(sa1100_rtc, RTSR, (RTSR_AL | RTSR_HZ)); | 133 | RTSR = RTSR_AL | RTSR_HZ; |
122 | } | 134 | } |
123 | 135 | ||
124 | /* clear alarm interrupt if it has occurred */ | 136 | /* clear alarm interrupt if it has occurred */ |
125 | if (rtsr & RTSR_AL) | 137 | if (rtsr & RTSR_AL) |
126 | rtsr &= ~RTSR_ALE; | 138 | rtsr &= ~RTSR_ALE; |
127 | rtc_writel(sa1100_rtc, RTSR, rtsr & (RTSR_ALE | RTSR_HZE)); | 139 | RTSR = rtsr & (RTSR_ALE | RTSR_HZE); |
128 | 140 | ||
129 | /* update irq data & counter */ | 141 | /* update irq data & counter */ |
130 | if (rtsr & RTSR_AL) | 142 | if (rtsr & RTSR_AL) |
@@ -132,100 +144,88 @@ static irqreturn_t sa1100_rtc_interrupt(int irq, void *dev_id) | |||
132 | if (rtsr & RTSR_HZ) | 144 | if (rtsr & RTSR_HZ) |
133 | events |= RTC_UF | RTC_IRQF; | 145 | events |= RTC_UF | RTC_IRQF; |
134 | 146 | ||
135 | rtc_update_irq(sa1100_rtc->rtc, 1, events); | 147 | rtc_update_irq(rtc, 1, events); |
136 | 148 | ||
137 | spin_unlock(&sa1100_rtc->lock); | 149 | if (rtsr & RTSR_AL && rtc_periodic_alarm(&rtc_alarm)) |
150 | rtc_update_alarm(&rtc_alarm); | ||
151 | |||
152 | spin_unlock(&sa1100_rtc_lock); | ||
138 | 153 | ||
139 | return IRQ_HANDLED; | 154 | return IRQ_HANDLED; |
140 | } | 155 | } |
141 | 156 | ||
142 | static int sa1100_rtc_open(struct device *dev) | 157 | static int sa1100_rtc_open(struct device *dev) |
143 | { | 158 | { |
144 | struct sa1100_rtc *sa1100_rtc = dev_get_drvdata(dev); | ||
145 | int ret; | 159 | int ret; |
160 | struct platform_device *plat_dev = to_platform_device(dev); | ||
161 | struct rtc_device *rtc = platform_get_drvdata(plat_dev); | ||
146 | 162 | ||
147 | ret = request_irq(sa1100_rtc->irq_1Hz, sa1100_rtc_interrupt, | 163 | ret = request_irq(IRQ_RTC1Hz, sa1100_rtc_interrupt, 0, "rtc 1Hz", dev); |
148 | IRQF_DISABLED, "rtc 1Hz", dev); | ||
149 | if (ret) { | 164 | if (ret) { |
150 | dev_err(dev, "IRQ %d already in use.\n", sa1100_rtc->irq_1Hz); | 165 | dev_err(dev, "IRQ %d already in use.\n", IRQ_RTC1Hz); |
151 | goto fail_ui; | 166 | goto fail_ui; |
152 | } | 167 | } |
153 | ret = request_irq(sa1100_rtc->irq_Alrm, sa1100_rtc_interrupt, | 168 | ret = request_irq(IRQ_RTCAlrm, sa1100_rtc_interrupt, 0, |
154 | IRQF_DISABLED, "rtc Alrm", dev); | 169 | "rtc Alrm", dev); |
155 | if (ret) { | 170 | if (ret) { |
156 | dev_err(dev, "IRQ %d already in use.\n", sa1100_rtc->irq_Alrm); | 171 | dev_err(dev, "IRQ %d already in use.\n", IRQ_RTCAlrm); |
157 | goto fail_ai; | 172 | goto fail_ai; |
158 | } | 173 | } |
159 | sa1100_rtc->rtc->max_user_freq = RTC_FREQ; | 174 | rtc->max_user_freq = RTC_FREQ; |
160 | rtc_irq_set_freq(sa1100_rtc->rtc, NULL, RTC_FREQ); | 175 | rtc_irq_set_freq(rtc, NULL, RTC_FREQ); |
161 | 176 | ||
162 | return 0; | 177 | return 0; |
163 | 178 | ||
164 | fail_ai: | 179 | fail_ai: |
165 | free_irq(sa1100_rtc->irq_1Hz, dev); | 180 | free_irq(IRQ_RTC1Hz, dev); |
166 | fail_ui: | 181 | fail_ui: |
167 | return ret; | 182 | return ret; |
168 | } | 183 | } |
169 | 184 | ||
170 | static void sa1100_rtc_release(struct device *dev) | 185 | static void sa1100_rtc_release(struct device *dev) |
171 | { | 186 | { |
172 | struct sa1100_rtc *sa1100_rtc = dev_get_drvdata(dev); | 187 | spin_lock_irq(&sa1100_rtc_lock); |
173 | 188 | RTSR = 0; | |
174 | spin_lock_irq(&sa1100_rtc->lock); | 189 | spin_unlock_irq(&sa1100_rtc_lock); |
175 | rtc_writel(sa1100_rtc, RTSR, 0); | ||
176 | spin_unlock_irq(&sa1100_rtc->lock); | ||
177 | 190 | ||
178 | free_irq(sa1100_rtc->irq_Alrm, dev); | 191 | free_irq(IRQ_RTCAlrm, dev); |
179 | free_irq(sa1100_rtc->irq_1Hz, dev); | 192 | free_irq(IRQ_RTC1Hz, dev); |
180 | } | 193 | } |
181 | 194 | ||
182 | static int sa1100_rtc_alarm_irq_enable(struct device *dev, unsigned int enabled) | 195 | static int sa1100_rtc_alarm_irq_enable(struct device *dev, unsigned int enabled) |
183 | { | 196 | { |
184 | struct sa1100_rtc *sa1100_rtc = dev_get_drvdata(dev); | 197 | spin_lock_irq(&sa1100_rtc_lock); |
185 | unsigned int rtsr; | ||
186 | |||
187 | spin_lock_irq(&sa1100_rtc->lock); | ||
188 | |||
189 | rtsr = rtc_readl(sa1100_rtc, RTSR); | ||
190 | if (enabled) | 198 | if (enabled) |
191 | rtsr |= RTSR_ALE; | 199 | RTSR |= RTSR_ALE; |
192 | else | 200 | else |
193 | rtsr &= ~RTSR_ALE; | 201 | RTSR &= ~RTSR_ALE; |
194 | rtc_writel(sa1100_rtc, RTSR, rtsr); | 202 | spin_unlock_irq(&sa1100_rtc_lock); |
195 | |||
196 | spin_unlock_irq(&sa1100_rtc->lock); | ||
197 | return 0; | 203 | return 0; |
198 | } | 204 | } |
199 | 205 | ||
200 | static int sa1100_rtc_read_time(struct device *dev, struct rtc_time *tm) | 206 | static int sa1100_rtc_read_time(struct device *dev, struct rtc_time *tm) |
201 | { | 207 | { |
202 | struct sa1100_rtc *sa1100_rtc = dev_get_drvdata(dev); | 208 | rtc_time_to_tm(RCNR, tm); |
203 | |||
204 | rtc_time_to_tm(rtc_readl(sa1100_rtc, RCNR), tm); | ||
205 | return 0; | 209 | return 0; |
206 | } | 210 | } |
207 | 211 | ||
208 | static int sa1100_rtc_set_time(struct device *dev, struct rtc_time *tm) | 212 | static int sa1100_rtc_set_time(struct device *dev, struct rtc_time *tm) |
209 | { | 213 | { |
210 | struct sa1100_rtc *sa1100_rtc = dev_get_drvdata(dev); | ||
211 | unsigned long time; | 214 | unsigned long time; |
212 | int ret; | 215 | int ret; |
213 | 216 | ||
214 | ret = rtc_tm_to_time(tm, &time); | 217 | ret = rtc_tm_to_time(tm, &time); |
215 | if (ret == 0) | 218 | if (ret == 0) |
216 | rtc_writel(sa1100_rtc, RCNR, time); | 219 | RCNR = time; |
217 | return ret; | 220 | return ret; |
218 | } | 221 | } |
219 | 222 | ||
220 | static int sa1100_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm) | 223 | static int sa1100_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm) |
221 | { | 224 | { |
222 | struct sa1100_rtc *sa1100_rtc = dev_get_drvdata(dev); | 225 | u32 rtsr; |
223 | unsigned long time; | ||
224 | unsigned int rtsr; | ||
225 | 226 | ||
226 | time = rtc_readl(sa1100_rtc, RCNR); | 227 | memcpy(&alrm->time, &rtc_alarm, sizeof(struct rtc_time)); |
227 | rtc_time_to_tm(time, &alrm->time); | 228 | rtsr = RTSR; |
228 | rtsr = rtc_readl(sa1100_rtc, RTSR); | ||
229 | alrm->enabled = (rtsr & RTSR_ALE) ? 1 : 0; | 229 | alrm->enabled = (rtsr & RTSR_ALE) ? 1 : 0; |
230 | alrm->pending = (rtsr & RTSR_AL) ? 1 : 0; | 230 | alrm->pending = (rtsr & RTSR_AL) ? 1 : 0; |
231 | return 0; | 231 | return 0; |
@@ -233,39 +233,26 @@ static int sa1100_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm) | |||
233 | 233 | ||
234 | static int sa1100_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm) | 234 | static int sa1100_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm) |
235 | { | 235 | { |
236 | struct sa1100_rtc *sa1100_rtc = dev_get_drvdata(dev); | 236 | int ret; |
237 | struct rtc_time now_tm, alarm_tm; | ||
238 | unsigned long time, alarm; | ||
239 | unsigned int rtsr; | ||
240 | |||
241 | spin_lock_irq(&sa1100_rtc->lock); | ||
242 | |||
243 | time = rtc_readl(sa1100_rtc, RCNR); | ||
244 | rtc_time_to_tm(time, &now_tm); | ||
245 | rtc_next_alarm_time(&alarm_tm, &now_tm, &alrm->time); | ||
246 | rtc_tm_to_time(&alarm_tm, &alarm); | ||
247 | rtc_writel(sa1100_rtc, RTAR, alarm); | ||
248 | |||
249 | rtsr = rtc_readl(sa1100_rtc, RTSR); | ||
250 | if (alrm->enabled) | ||
251 | rtsr |= RTSR_ALE; | ||
252 | else | ||
253 | rtsr &= ~RTSR_ALE; | ||
254 | rtc_writel(sa1100_rtc, RTSR, rtsr); | ||
255 | 237 | ||
256 | spin_unlock_irq(&sa1100_rtc->lock); | 238 | spin_lock_irq(&sa1100_rtc_lock); |
239 | ret = rtc_update_alarm(&alrm->time); | ||
240 | if (ret == 0) { | ||
241 | if (alrm->enabled) | ||
242 | RTSR |= RTSR_ALE; | ||
243 | else | ||
244 | RTSR &= ~RTSR_ALE; | ||
245 | } | ||
246 | spin_unlock_irq(&sa1100_rtc_lock); | ||
257 | 247 | ||
258 | return 0; | 248 | return ret; |
259 | } | 249 | } |
260 | 250 | ||
261 | static int sa1100_rtc_proc(struct device *dev, struct seq_file *seq) | 251 | static int sa1100_rtc_proc(struct device *dev, struct seq_file *seq) |
262 | { | 252 | { |
263 | struct sa1100_rtc *sa1100_rtc = dev_get_drvdata(dev); | 253 | seq_printf(seq, "trim/divider\t\t: 0x%08x\n", (u32) RTTR); |
254 | seq_printf(seq, "RTSR\t\t\t: 0x%08x\n", (u32)RTSR); | ||
264 | 255 | ||
265 | seq_printf(seq, "trim/divider\t\t: 0x%08x\n", | ||
266 | rtc_readl(sa1100_rtc, RTTR)); | ||
267 | seq_printf(seq, "RTSR\t\t\t: 0x%08x\n", | ||
268 | rtc_readl(sa1100_rtc, RTSR)); | ||
269 | return 0; | 256 | return 0; |
270 | } | 257 | } |
271 | 258 | ||
@@ -282,51 +269,7 @@ static const struct rtc_class_ops sa1100_rtc_ops = { | |||
282 | 269 | ||
283 | static int sa1100_rtc_probe(struct platform_device *pdev) | 270 | static int sa1100_rtc_probe(struct platform_device *pdev) |
284 | { | 271 | { |
285 | struct sa1100_rtc *sa1100_rtc; | 272 | struct rtc_device *rtc; |
286 | unsigned int rttr; | ||
287 | int ret; | ||
288 | |||
289 | sa1100_rtc = kzalloc(sizeof(struct sa1100_rtc), GFP_KERNEL); | ||
290 | if (!sa1100_rtc) | ||
291 | return -ENOMEM; | ||
292 | |||
293 | spin_lock_init(&sa1100_rtc->lock); | ||
294 | platform_set_drvdata(pdev, sa1100_rtc); | ||
295 | |||
296 | ret = -ENXIO; | ||
297 | sa1100_rtc->ress = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
298 | if (!sa1100_rtc->ress) { | ||
299 | dev_err(&pdev->dev, "No I/O memory resource defined\n"); | ||
300 | goto err_ress; | ||
301 | } | ||
302 | |||
303 | sa1100_rtc->irq_1Hz = platform_get_irq(pdev, 0); | ||
304 | if (sa1100_rtc->irq_1Hz < 0) { | ||
305 | dev_err(&pdev->dev, "No 1Hz IRQ resource defined\n"); | ||
306 | goto err_ress; | ||
307 | } | ||
308 | sa1100_rtc->irq_Alrm = platform_get_irq(pdev, 1); | ||
309 | if (sa1100_rtc->irq_Alrm < 0) { | ||
310 | dev_err(&pdev->dev, "No alarm IRQ resource defined\n"); | ||
311 | goto err_ress; | ||
312 | } | ||
313 | |||
314 | ret = -ENOMEM; | ||
315 | sa1100_rtc->base = ioremap(sa1100_rtc->ress->start, | ||
316 | resource_size(sa1100_rtc->ress)); | ||
317 | if (!sa1100_rtc->base) { | ||
318 | dev_err(&pdev->dev, "Unable to map pxa RTC I/O memory\n"); | ||
319 | goto err_map; | ||
320 | } | ||
321 | |||
322 | sa1100_rtc->clk = clk_get(&pdev->dev, NULL); | ||
323 | if (IS_ERR(sa1100_rtc->clk)) { | ||
324 | dev_err(&pdev->dev, "failed to find rtc clock source\n"); | ||
325 | ret = PTR_ERR(sa1100_rtc->clk); | ||
326 | goto err_clk; | ||
327 | } | ||
328 | clk_prepare(sa1100_rtc->clk); | ||
329 | clk_enable(sa1100_rtc->clk); | ||
330 | 273 | ||
331 | /* | 274 | /* |
332 | * According to the manual we should be able to let RTTR be zero | 275 | * According to the manual we should be able to let RTTR be zero |
@@ -335,24 +278,24 @@ static int sa1100_rtc_probe(struct platform_device *pdev) | |||
335 | * If the clock divider is uninitialized then reset it to the | 278 | * If the clock divider is uninitialized then reset it to the |
336 | * default value to get the 1Hz clock. | 279 | * default value to get the 1Hz clock. |
337 | */ | 280 | */ |
338 | if (rtc_readl(sa1100_rtc, RTTR) == 0) { | 281 | if (RTTR == 0) { |
339 | rttr = RTC_DEF_DIVIDER + (RTC_DEF_TRIM << 16); | 282 | RTTR = RTC_DEF_DIVIDER + (RTC_DEF_TRIM << 16); |
340 | rtc_writel(sa1100_rtc, RTTR, rttr); | 283 | dev_warn(&pdev->dev, "warning: " |
341 | dev_warn(&pdev->dev, "warning: initializing default clock" | 284 | "initializing default clock divider/trim value\n"); |
342 | " divider/trim value\n"); | ||
343 | /* The current RTC value probably doesn't make sense either */ | 285 | /* The current RTC value probably doesn't make sense either */ |
344 | rtc_writel(sa1100_rtc, RCNR, 0); | 286 | RCNR = 0; |
345 | } | 287 | } |
346 | 288 | ||
347 | device_init_wakeup(&pdev->dev, 1); | 289 | device_init_wakeup(&pdev->dev, 1); |
348 | 290 | ||
349 | sa1100_rtc->rtc = rtc_device_register(pdev->name, &pdev->dev, | 291 | rtc = rtc_device_register(pdev->name, &pdev->dev, &sa1100_rtc_ops, |
350 | &sa1100_rtc_ops, THIS_MODULE); | 292 | THIS_MODULE); |
351 | if (IS_ERR(sa1100_rtc->rtc)) { | 293 | |
352 | dev_err(&pdev->dev, "Failed to register RTC device -> %d\n", | 294 | if (IS_ERR(rtc)) |
353 | ret); | 295 | return PTR_ERR(rtc); |
354 | goto err_rtc_reg; | 296 | |
355 | } | 297 | platform_set_drvdata(pdev, rtc); |
298 | |||
356 | /* Fix for a nasty initialization problem the in SA11xx RTSR register. | 299 | /* Fix for a nasty initialization problem the in SA11xx RTSR register. |
357 | * See also the comments in sa1100_rtc_interrupt(). | 300 | * See also the comments in sa1100_rtc_interrupt(). |
358 | * | 301 | * |
@@ -375,46 +318,33 @@ static int sa1100_rtc_probe(struct platform_device *pdev) | |||
375 | * | 318 | * |
376 | * Notice that clearing bit 1 and 0 is accomplished by writting ONES to | 319 | * Notice that clearing bit 1 and 0 is accomplished by writting ONES to |
377 | * the corresponding bits in RTSR. */ | 320 | * the corresponding bits in RTSR. */ |
378 | rtc_writel(sa1100_rtc, RTSR, (RTSR_AL | RTSR_HZ)); | 321 | RTSR = RTSR_AL | RTSR_HZ; |
379 | 322 | ||
380 | return 0; | 323 | return 0; |
381 | |||
382 | err_rtc_reg: | ||
383 | err_clk: | ||
384 | iounmap(sa1100_rtc->base); | ||
385 | err_ress: | ||
386 | err_map: | ||
387 | kfree(sa1100_rtc); | ||
388 | return ret; | ||
389 | } | 324 | } |
390 | 325 | ||
391 | static int sa1100_rtc_remove(struct platform_device *pdev) | 326 | static int sa1100_rtc_remove(struct platform_device *pdev) |
392 | { | 327 | { |
393 | struct sa1100_rtc *sa1100_rtc = platform_get_drvdata(pdev); | 328 | struct rtc_device *rtc = platform_get_drvdata(pdev); |
329 | |||
330 | if (rtc) | ||
331 | rtc_device_unregister(rtc); | ||
394 | 332 | ||
395 | rtc_device_unregister(sa1100_rtc->rtc); | ||
396 | clk_disable(sa1100_rtc->clk); | ||
397 | clk_unprepare(sa1100_rtc->clk); | ||
398 | iounmap(sa1100_rtc->base); | ||
399 | return 0; | 333 | return 0; |
400 | } | 334 | } |
401 | 335 | ||
402 | #ifdef CONFIG_PM | 336 | #ifdef CONFIG_PM |
403 | static int sa1100_rtc_suspend(struct device *dev) | 337 | static int sa1100_rtc_suspend(struct device *dev) |
404 | { | 338 | { |
405 | struct sa1100_rtc *sa1100_rtc = dev_get_drvdata(dev); | ||
406 | |||
407 | if (device_may_wakeup(dev)) | 339 | if (device_may_wakeup(dev)) |
408 | enable_irq_wake(sa1100_rtc->irq_Alrm); | 340 | enable_irq_wake(IRQ_RTCAlrm); |
409 | return 0; | 341 | return 0; |
410 | } | 342 | } |
411 | 343 | ||
412 | static int sa1100_rtc_resume(struct device *dev) | 344 | static int sa1100_rtc_resume(struct device *dev) |
413 | { | 345 | { |
414 | struct sa1100_rtc *sa1100_rtc = dev_get_drvdata(dev); | ||
415 | |||
416 | if (device_may_wakeup(dev)) | 346 | if (device_may_wakeup(dev)) |
417 | disable_irq_wake(sa1100_rtc->irq_Alrm); | 347 | disable_irq_wake(IRQ_RTCAlrm); |
418 | return 0; | 348 | return 0; |
419 | } | 349 | } |
420 | 350 | ||
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); | ||