diff options
Diffstat (limited to 'drivers/rtc/rtc-pxa.c')
-rw-r--r-- | drivers/rtc/rtc-pxa.c | 70 |
1 files changed, 38 insertions, 32 deletions
diff --git a/drivers/rtc/rtc-pxa.c b/drivers/rtc/rtc-pxa.c index bb8cc05605ac..29e867a1aaa8 100644 --- a/drivers/rtc/rtc-pxa.c +++ b/drivers/rtc/rtc-pxa.c | |||
@@ -26,6 +26,7 @@ | |||
26 | #include <linux/seq_file.h> | 26 | #include <linux/seq_file.h> |
27 | #include <linux/interrupt.h> | 27 | #include <linux/interrupt.h> |
28 | #include <linux/io.h> | 28 | #include <linux/io.h> |
29 | #include <linux/slab.h> | ||
29 | 30 | ||
30 | #include <mach/hardware.h> | 31 | #include <mach/hardware.h> |
31 | 32 | ||
@@ -86,7 +87,6 @@ struct pxa_rtc { | |||
86 | int irq_Alrm; | 87 | int irq_Alrm; |
87 | struct rtc_device *rtc; | 88 | struct rtc_device *rtc; |
88 | spinlock_t lock; /* Protects this structure */ | 89 | spinlock_t lock; /* Protects this structure */ |
89 | struct rtc_time rtc_alarm; | ||
90 | }; | 90 | }; |
91 | 91 | ||
92 | static u32 ryxr_calc(struct rtc_time *tm) | 92 | static u32 ryxr_calc(struct rtc_time *tm) |
@@ -235,32 +235,34 @@ static int pxa_periodic_irq_set_state(struct device *dev, int enabled) | |||
235 | return 0; | 235 | return 0; |
236 | } | 236 | } |
237 | 237 | ||
238 | static int pxa_rtc_ioctl(struct device *dev, unsigned int cmd, | 238 | static int pxa_alarm_irq_enable(struct device *dev, unsigned int enabled) |
239 | unsigned long arg) | ||
240 | { | 239 | { |
241 | struct pxa_rtc *pxa_rtc = dev_get_drvdata(dev); | 240 | struct pxa_rtc *pxa_rtc = dev_get_drvdata(dev); |
242 | int ret = 0; | ||
243 | 241 | ||
244 | spin_lock_irq(&pxa_rtc->lock); | 242 | spin_lock_irq(&pxa_rtc->lock); |
245 | switch (cmd) { | 243 | |
246 | case RTC_AIE_OFF: | 244 | if (enabled) |
247 | rtsr_clear_bits(pxa_rtc, RTSR_RDALE1); | ||
248 | break; | ||
249 | case RTC_AIE_ON: | ||
250 | rtsr_set_bits(pxa_rtc, RTSR_RDALE1); | 245 | rtsr_set_bits(pxa_rtc, RTSR_RDALE1); |
251 | break; | 246 | else |
252 | case RTC_UIE_OFF: | 247 | rtsr_clear_bits(pxa_rtc, RTSR_RDALE1); |
253 | rtsr_clear_bits(pxa_rtc, RTSR_HZE); | 248 | |
254 | break; | 249 | spin_unlock_irq(&pxa_rtc->lock); |
255 | case RTC_UIE_ON: | 250 | return 0; |
251 | } | ||
252 | |||
253 | static int pxa_update_irq_enable(struct device *dev, unsigned int enabled) | ||
254 | { | ||
255 | struct pxa_rtc *pxa_rtc = dev_get_drvdata(dev); | ||
256 | |||
257 | spin_lock_irq(&pxa_rtc->lock); | ||
258 | |||
259 | if (enabled) | ||
256 | rtsr_set_bits(pxa_rtc, RTSR_HZE); | 260 | rtsr_set_bits(pxa_rtc, RTSR_HZE); |
257 | break; | 261 | else |
258 | default: | 262 | rtsr_clear_bits(pxa_rtc, RTSR_HZE); |
259 | ret = -ENOIOCTLCMD; | ||
260 | } | ||
261 | 263 | ||
262 | spin_unlock_irq(&pxa_rtc->lock); | 264 | spin_unlock_irq(&pxa_rtc->lock); |
263 | return ret; | 265 | return 0; |
264 | } | 266 | } |
265 | 267 | ||
266 | static int pxa_rtc_read_time(struct device *dev, struct rtc_time *tm) | 268 | static int pxa_rtc_read_time(struct device *dev, struct rtc_time *tm) |
@@ -339,11 +341,12 @@ static int pxa_rtc_proc(struct device *dev, struct seq_file *seq) | |||
339 | static const struct rtc_class_ops pxa_rtc_ops = { | 341 | static const struct rtc_class_ops pxa_rtc_ops = { |
340 | .open = pxa_rtc_open, | 342 | .open = pxa_rtc_open, |
341 | .release = pxa_rtc_release, | 343 | .release = pxa_rtc_release, |
342 | .ioctl = pxa_rtc_ioctl, | ||
343 | .read_time = pxa_rtc_read_time, | 344 | .read_time = pxa_rtc_read_time, |
344 | .set_time = pxa_rtc_set_time, | 345 | .set_time = pxa_rtc_set_time, |
345 | .read_alarm = pxa_rtc_read_alarm, | 346 | .read_alarm = pxa_rtc_read_alarm, |
346 | .set_alarm = pxa_rtc_set_alarm, | 347 | .set_alarm = pxa_rtc_set_alarm, |
348 | .alarm_irq_enable = pxa_alarm_irq_enable, | ||
349 | .update_irq_enable = pxa_update_irq_enable, | ||
347 | .proc = pxa_rtc_proc, | 350 | .proc = pxa_rtc_proc, |
348 | .irq_set_state = pxa_periodic_irq_set_state, | 351 | .irq_set_state = pxa_periodic_irq_set_state, |
349 | .irq_set_freq = pxa_periodic_irq_set_freq, | 352 | .irq_set_freq = pxa_periodic_irq_set_freq, |
@@ -438,34 +441,37 @@ static int __exit pxa_rtc_remove(struct platform_device *pdev) | |||
438 | } | 441 | } |
439 | 442 | ||
440 | #ifdef CONFIG_PM | 443 | #ifdef CONFIG_PM |
441 | static int pxa_rtc_suspend(struct platform_device *pdev, pm_message_t state) | 444 | static int pxa_rtc_suspend(struct device *dev) |
442 | { | 445 | { |
443 | struct pxa_rtc *pxa_rtc = platform_get_drvdata(pdev); | 446 | struct pxa_rtc *pxa_rtc = dev_get_drvdata(dev); |
444 | 447 | ||
445 | if (device_may_wakeup(&pdev->dev)) | 448 | if (device_may_wakeup(dev)) |
446 | enable_irq_wake(pxa_rtc->irq_Alrm); | 449 | enable_irq_wake(pxa_rtc->irq_Alrm); |
447 | return 0; | 450 | return 0; |
448 | } | 451 | } |
449 | 452 | ||
450 | static int pxa_rtc_resume(struct platform_device *pdev) | 453 | static int pxa_rtc_resume(struct device *dev) |
451 | { | 454 | { |
452 | struct pxa_rtc *pxa_rtc = platform_get_drvdata(pdev); | 455 | struct pxa_rtc *pxa_rtc = dev_get_drvdata(dev); |
453 | 456 | ||
454 | if (device_may_wakeup(&pdev->dev)) | 457 | if (device_may_wakeup(dev)) |
455 | disable_irq_wake(pxa_rtc->irq_Alrm); | 458 | disable_irq_wake(pxa_rtc->irq_Alrm); |
456 | return 0; | 459 | return 0; |
457 | } | 460 | } |
458 | #else | 461 | |
459 | #define pxa_rtc_suspend NULL | 462 | static const struct dev_pm_ops pxa_rtc_pm_ops = { |
460 | #define pxa_rtc_resume NULL | 463 | .suspend = pxa_rtc_suspend, |
464 | .resume = pxa_rtc_resume, | ||
465 | }; | ||
461 | #endif | 466 | #endif |
462 | 467 | ||
463 | static struct platform_driver pxa_rtc_driver = { | 468 | static struct platform_driver pxa_rtc_driver = { |
464 | .remove = __exit_p(pxa_rtc_remove), | 469 | .remove = __exit_p(pxa_rtc_remove), |
465 | .suspend = pxa_rtc_suspend, | ||
466 | .resume = pxa_rtc_resume, | ||
467 | .driver = { | 470 | .driver = { |
468 | .name = "pxa-rtc", | 471 | .name = "pxa-rtc", |
472 | #ifdef CONFIG_PM | ||
473 | .pm = &pxa_rtc_pm_ops, | ||
474 | #endif | ||
469 | }, | 475 | }, |
470 | }; | 476 | }; |
471 | 477 | ||