diff options
Diffstat (limited to 'drivers/rtc')
-rw-r--r-- | drivers/rtc/interface.c | 1 | ||||
-rw-r--r-- | drivers/rtc/rtc-coh901331.c | 11 | ||||
-rw-r--r-- | drivers/rtc/rtc-dev.c | 1 | ||||
-rw-r--r-- | drivers/rtc/rtc-pcf50633.c | 7 | ||||
-rw-r--r-- | drivers/rtc/rtc-pxa.c | 27 | ||||
-rw-r--r-- | drivers/rtc/rtc-sa1100.c | 23 | ||||
-rw-r--r-- | drivers/rtc/rtc-v3020.c | 2 | ||||
-rw-r--r-- | drivers/rtc/rtc-vr41xx.c | 9 |
8 files changed, 50 insertions, 31 deletions
diff --git a/drivers/rtc/interface.c b/drivers/rtc/interface.c index 4cdb31a362ca..a0c816238aa9 100644 --- a/drivers/rtc/interface.c +++ b/drivers/rtc/interface.c | |||
@@ -12,6 +12,7 @@ | |||
12 | */ | 12 | */ |
13 | 13 | ||
14 | #include <linux/rtc.h> | 14 | #include <linux/rtc.h> |
15 | #include <linux/sched.h> | ||
15 | #include <linux/log2.h> | 16 | #include <linux/log2.h> |
16 | 17 | ||
17 | int rtc_read_time(struct rtc_device *rtc, struct rtc_time *tm) | 18 | int rtc_read_time(struct rtc_device *rtc, struct rtc_time *tm) |
diff --git a/drivers/rtc/rtc-coh901331.c b/drivers/rtc/rtc-coh901331.c index 7fe1fa26c52c..03ea530981d1 100644 --- a/drivers/rtc/rtc-coh901331.c +++ b/drivers/rtc/rtc-coh901331.c | |||
@@ -58,7 +58,16 @@ static irqreturn_t coh901331_interrupt(int irq, void *data) | |||
58 | clk_enable(rtap->clk); | 58 | clk_enable(rtap->clk); |
59 | /* Ack IRQ */ | 59 | /* Ack IRQ */ |
60 | writel(1, rtap->virtbase + COH901331_IRQ_EVENT); | 60 | writel(1, rtap->virtbase + COH901331_IRQ_EVENT); |
61 | /* | ||
62 | * Disable the interrupt. This is necessary because | ||
63 | * the RTC lives on a lower-clocked line and will | ||
64 | * not release the IRQ line until after a few (slower) | ||
65 | * clock cycles. The interrupt will be re-enabled when | ||
66 | * a new alarm is set anyway. | ||
67 | */ | ||
68 | writel(0, rtap->virtbase + COH901331_IRQ_MASK); | ||
61 | clk_disable(rtap->clk); | 69 | clk_disable(rtap->clk); |
70 | |||
62 | /* Set alarm flag */ | 71 | /* Set alarm flag */ |
63 | rtc_update_irq(rtap->rtc, 1, RTC_AF); | 72 | rtc_update_irq(rtap->rtc, 1, RTC_AF); |
64 | 73 | ||
@@ -128,6 +137,8 @@ static int coh901331_alarm_irq_enable(struct device *dev, unsigned int enabled) | |||
128 | else | 137 | else |
129 | writel(0, rtap->virtbase + COH901331_IRQ_MASK); | 138 | writel(0, rtap->virtbase + COH901331_IRQ_MASK); |
130 | clk_disable(rtap->clk); | 139 | clk_disable(rtap->clk); |
140 | |||
141 | return 0; | ||
131 | } | 142 | } |
132 | 143 | ||
133 | static struct rtc_class_ops coh901331_ops = { | 144 | static struct rtc_class_ops coh901331_ops = { |
diff --git a/drivers/rtc/rtc-dev.c b/drivers/rtc/rtc-dev.c index 8a11de9552cd..62227cd52410 100644 --- a/drivers/rtc/rtc-dev.c +++ b/drivers/rtc/rtc-dev.c | |||
@@ -13,6 +13,7 @@ | |||
13 | 13 | ||
14 | #include <linux/module.h> | 14 | #include <linux/module.h> |
15 | #include <linux/rtc.h> | 15 | #include <linux/rtc.h> |
16 | #include <linux/sched.h> | ||
16 | #include "rtc-core.h" | 17 | #include "rtc-core.h" |
17 | 18 | ||
18 | static dev_t rtc_devt; | 19 | static dev_t rtc_devt; |
diff --git a/drivers/rtc/rtc-pcf50633.c b/drivers/rtc/rtc-pcf50633.c index f4dd87e29075..33a10c47260e 100644 --- a/drivers/rtc/rtc-pcf50633.c +++ b/drivers/rtc/rtc-pcf50633.c | |||
@@ -70,7 +70,7 @@ static void pcf2rtc_time(struct rtc_time *rtc, struct pcf50633_time *pcf) | |||
70 | rtc->tm_hour = bcd2bin(pcf->time[PCF50633_TI_HOUR]); | 70 | rtc->tm_hour = bcd2bin(pcf->time[PCF50633_TI_HOUR]); |
71 | rtc->tm_wday = bcd2bin(pcf->time[PCF50633_TI_WKDAY]); | 71 | rtc->tm_wday = bcd2bin(pcf->time[PCF50633_TI_WKDAY]); |
72 | rtc->tm_mday = bcd2bin(pcf->time[PCF50633_TI_DAY]); | 72 | rtc->tm_mday = bcd2bin(pcf->time[PCF50633_TI_DAY]); |
73 | rtc->tm_mon = bcd2bin(pcf->time[PCF50633_TI_MONTH]); | 73 | rtc->tm_mon = bcd2bin(pcf->time[PCF50633_TI_MONTH]) - 1; |
74 | rtc->tm_year = bcd2bin(pcf->time[PCF50633_TI_YEAR]) + 100; | 74 | rtc->tm_year = bcd2bin(pcf->time[PCF50633_TI_YEAR]) + 100; |
75 | } | 75 | } |
76 | 76 | ||
@@ -81,7 +81,7 @@ static void rtc2pcf_time(struct pcf50633_time *pcf, struct rtc_time *rtc) | |||
81 | pcf->time[PCF50633_TI_HOUR] = bin2bcd(rtc->tm_hour); | 81 | pcf->time[PCF50633_TI_HOUR] = bin2bcd(rtc->tm_hour); |
82 | pcf->time[PCF50633_TI_WKDAY] = bin2bcd(rtc->tm_wday); | 82 | pcf->time[PCF50633_TI_WKDAY] = bin2bcd(rtc->tm_wday); |
83 | pcf->time[PCF50633_TI_DAY] = bin2bcd(rtc->tm_mday); | 83 | pcf->time[PCF50633_TI_DAY] = bin2bcd(rtc->tm_mday); |
84 | pcf->time[PCF50633_TI_MONTH] = bin2bcd(rtc->tm_mon); | 84 | pcf->time[PCF50633_TI_MONTH] = bin2bcd(rtc->tm_mon + 1); |
85 | pcf->time[PCF50633_TI_YEAR] = bin2bcd(rtc->tm_year % 100); | 85 | pcf->time[PCF50633_TI_YEAR] = bin2bcd(rtc->tm_year % 100); |
86 | } | 86 | } |
87 | 87 | ||
@@ -245,8 +245,9 @@ static int pcf50633_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm) | |||
245 | ret = pcf50633_write_block(rtc->pcf, PCF50633_REG_RTCSCA, | 245 | ret = pcf50633_write_block(rtc->pcf, PCF50633_REG_RTCSCA, |
246 | PCF50633_TI_EXTENT, &pcf_tm.time[0]); | 246 | PCF50633_TI_EXTENT, &pcf_tm.time[0]); |
247 | 247 | ||
248 | if (!alarm_masked) | 248 | if (!alarm_masked || alrm->enabled) |
249 | pcf50633_irq_unmask(rtc->pcf, PCF50633_IRQ_ALARM); | 249 | pcf50633_irq_unmask(rtc->pcf, PCF50633_IRQ_ALARM); |
250 | rtc->alarm_enabled = alrm->enabled; | ||
250 | 251 | ||
251 | return ret; | 252 | return ret; |
252 | } | 253 | } |
diff --git a/drivers/rtc/rtc-pxa.c b/drivers/rtc/rtc-pxa.c index bb8cc05605ac..747ca194fad4 100644 --- a/drivers/rtc/rtc-pxa.c +++ b/drivers/rtc/rtc-pxa.c | |||
@@ -438,34 +438,37 @@ static int __exit pxa_rtc_remove(struct platform_device *pdev) | |||
438 | } | 438 | } |
439 | 439 | ||
440 | #ifdef CONFIG_PM | 440 | #ifdef CONFIG_PM |
441 | static int pxa_rtc_suspend(struct platform_device *pdev, pm_message_t state) | 441 | static int pxa_rtc_suspend(struct device *dev) |
442 | { | 442 | { |
443 | struct pxa_rtc *pxa_rtc = platform_get_drvdata(pdev); | 443 | struct pxa_rtc *pxa_rtc = dev_get_drvdata(dev); |
444 | 444 | ||
445 | if (device_may_wakeup(&pdev->dev)) | 445 | if (device_may_wakeup(dev)) |
446 | enable_irq_wake(pxa_rtc->irq_Alrm); | 446 | enable_irq_wake(pxa_rtc->irq_Alrm); |
447 | return 0; | 447 | return 0; |
448 | } | 448 | } |
449 | 449 | ||
450 | static int pxa_rtc_resume(struct platform_device *pdev) | 450 | static int pxa_rtc_resume(struct device *dev) |
451 | { | 451 | { |
452 | struct pxa_rtc *pxa_rtc = platform_get_drvdata(pdev); | 452 | struct pxa_rtc *pxa_rtc = dev_get_drvdata(dev); |
453 | 453 | ||
454 | if (device_may_wakeup(&pdev->dev)) | 454 | if (device_may_wakeup(dev)) |
455 | disable_irq_wake(pxa_rtc->irq_Alrm); | 455 | disable_irq_wake(pxa_rtc->irq_Alrm); |
456 | return 0; | 456 | return 0; |
457 | } | 457 | } |
458 | #else | 458 | |
459 | #define pxa_rtc_suspend NULL | 459 | static struct dev_pm_ops pxa_rtc_pm_ops = { |
460 | #define pxa_rtc_resume NULL | 460 | .suspend = pxa_rtc_suspend, |
461 | .resume = pxa_rtc_resume, | ||
462 | }; | ||
461 | #endif | 463 | #endif |
462 | 464 | ||
463 | static struct platform_driver pxa_rtc_driver = { | 465 | static struct platform_driver pxa_rtc_driver = { |
464 | .remove = __exit_p(pxa_rtc_remove), | 466 | .remove = __exit_p(pxa_rtc_remove), |
465 | .suspend = pxa_rtc_suspend, | ||
466 | .resume = pxa_rtc_resume, | ||
467 | .driver = { | 467 | .driver = { |
468 | .name = "pxa-rtc", | 468 | .name = "pxa-rtc", |
469 | #ifdef CONFIG_PM | ||
470 | .pm = &pxa_rtc_pm_ops, | ||
471 | #endif | ||
469 | }, | 472 | }, |
470 | }; | 473 | }; |
471 | 474 | ||
diff --git a/drivers/rtc/rtc-sa1100.c b/drivers/rtc/rtc-sa1100.c index 021b2928f0b9..29f98a70586e 100644 --- a/drivers/rtc/rtc-sa1100.c +++ b/drivers/rtc/rtc-sa1100.c | |||
@@ -393,31 +393,34 @@ static int sa1100_rtc_remove(struct platform_device *pdev) | |||
393 | } | 393 | } |
394 | 394 | ||
395 | #ifdef CONFIG_PM | 395 | #ifdef CONFIG_PM |
396 | static int sa1100_rtc_suspend(struct platform_device *pdev, pm_message_t state) | 396 | static int sa1100_rtc_suspend(struct device *dev) |
397 | { | 397 | { |
398 | if (device_may_wakeup(&pdev->dev)) | 398 | if (device_may_wakeup(dev)) |
399 | enable_irq_wake(IRQ_RTCAlrm); | 399 | enable_irq_wake(IRQ_RTCAlrm); |
400 | return 0; | 400 | return 0; |
401 | } | 401 | } |
402 | 402 | ||
403 | static int sa1100_rtc_resume(struct platform_device *pdev) | 403 | static int sa1100_rtc_resume(struct device *dev) |
404 | { | 404 | { |
405 | if (device_may_wakeup(&pdev->dev)) | 405 | if (device_may_wakeup(dev)) |
406 | disable_irq_wake(IRQ_RTCAlrm); | 406 | disable_irq_wake(IRQ_RTCAlrm); |
407 | return 0; | 407 | return 0; |
408 | } | 408 | } |
409 | #else | 409 | |
410 | #define sa1100_rtc_suspend NULL | 410 | static struct dev_pm_ops sa1100_rtc_pm_ops = { |
411 | #define sa1100_rtc_resume NULL | 411 | .suspend = sa1100_rtc_suspend, |
412 | .resume = sa1100_rtc_resume, | ||
413 | }; | ||
412 | #endif | 414 | #endif |
413 | 415 | ||
414 | static struct platform_driver sa1100_rtc_driver = { | 416 | static struct platform_driver sa1100_rtc_driver = { |
415 | .probe = sa1100_rtc_probe, | 417 | .probe = sa1100_rtc_probe, |
416 | .remove = sa1100_rtc_remove, | 418 | .remove = sa1100_rtc_remove, |
417 | .suspend = sa1100_rtc_suspend, | ||
418 | .resume = sa1100_rtc_resume, | ||
419 | .driver = { | 419 | .driver = { |
420 | .name = "sa1100-rtc", | 420 | .name = "sa1100-rtc", |
421 | #ifdef CONFIG_PM | ||
422 | .pm = &sa1100_rtc_pm_ops, | ||
423 | #endif | ||
421 | }, | 424 | }, |
422 | }; | 425 | }; |
423 | 426 | ||
diff --git a/drivers/rtc/rtc-v3020.c b/drivers/rtc/rtc-v3020.c index ad164056feb6..423cd5a30b10 100644 --- a/drivers/rtc/rtc-v3020.c +++ b/drivers/rtc/rtc-v3020.c | |||
@@ -96,7 +96,7 @@ static void v3020_mmio_write_bit(struct v3020 *chip, unsigned char bit) | |||
96 | 96 | ||
97 | static unsigned char v3020_mmio_read_bit(struct v3020 *chip) | 97 | static unsigned char v3020_mmio_read_bit(struct v3020 *chip) |
98 | { | 98 | { |
99 | return readl(chip->ioaddress) & (1 << chip->leftshift); | 99 | return !!(readl(chip->ioaddress) & (1 << chip->leftshift)); |
100 | } | 100 | } |
101 | 101 | ||
102 | static struct v3020_chip_ops v3020_mmio_ops = { | 102 | static struct v3020_chip_ops v3020_mmio_ops = { |
diff --git a/drivers/rtc/rtc-vr41xx.c b/drivers/rtc/rtc-vr41xx.c index 2c839d0d21bd..fadddac1e5a4 100644 --- a/drivers/rtc/rtc-vr41xx.c +++ b/drivers/rtc/rtc-vr41xx.c | |||
@@ -209,19 +209,18 @@ static int vr41xx_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *wkalrm) | |||
209 | 209 | ||
210 | static int vr41xx_rtc_irq_set_freq(struct device *dev, int freq) | 210 | static int vr41xx_rtc_irq_set_freq(struct device *dev, int freq) |
211 | { | 211 | { |
212 | unsigned long count; | 212 | u64 count; |
213 | 213 | ||
214 | if (!is_power_of_2(freq)) | 214 | if (!is_power_of_2(freq)) |
215 | return -EINVAL; | 215 | return -EINVAL; |
216 | count = RTC_FREQUENCY; | 216 | count = RTC_FREQUENCY; |
217 | do_div(count, freq); | 217 | do_div(count, freq); |
218 | 218 | ||
219 | periodic_count = count; | ||
220 | |||
221 | spin_lock_irq(&rtc_lock); | 219 | spin_lock_irq(&rtc_lock); |
222 | 220 | ||
223 | rtc1_write(RTCL1LREG, count); | 221 | periodic_count = count; |
224 | rtc1_write(RTCL1HREG, count >> 16); | 222 | rtc1_write(RTCL1LREG, periodic_count); |
223 | rtc1_write(RTCL1HREG, periodic_count >> 16); | ||
225 | 224 | ||
226 | spin_unlock_irq(&rtc_lock); | 225 | spin_unlock_irq(&rtc_lock); |
227 | 226 | ||