diff options
Diffstat (limited to 'drivers/rtc')
48 files changed, 822 insertions, 1180 deletions
diff --git a/drivers/rtc/class.c b/drivers/rtc/class.c index e6539cbabb3..09b4437b3e6 100644 --- a/drivers/rtc/class.c +++ b/drivers/rtc/class.c | |||
@@ -16,6 +16,7 @@ | |||
16 | #include <linux/kdev_t.h> | 16 | #include <linux/kdev_t.h> |
17 | #include <linux/idr.h> | 17 | #include <linux/idr.h> |
18 | #include <linux/slab.h> | 18 | #include <linux/slab.h> |
19 | #include <linux/workqueue.h> | ||
19 | 20 | ||
20 | #include "rtc-core.h" | 21 | #include "rtc-core.h" |
21 | 22 | ||
@@ -116,6 +117,7 @@ struct rtc_device *rtc_device_register(const char *name, struct device *dev, | |||
116 | struct module *owner) | 117 | struct module *owner) |
117 | { | 118 | { |
118 | struct rtc_device *rtc; | 119 | struct rtc_device *rtc; |
120 | struct rtc_wkalrm alrm; | ||
119 | int id, err; | 121 | int id, err; |
120 | 122 | ||
121 | if (idr_pre_get(&rtc_idr, GFP_KERNEL) == 0) { | 123 | if (idr_pre_get(&rtc_idr, GFP_KERNEL) == 0) { |
@@ -142,6 +144,7 @@ struct rtc_device *rtc_device_register(const char *name, struct device *dev, | |||
142 | rtc->id = id; | 144 | rtc->id = id; |
143 | rtc->ops = ops; | 145 | rtc->ops = ops; |
144 | rtc->owner = owner; | 146 | rtc->owner = owner; |
147 | rtc->irq_freq = 1; | ||
145 | rtc->max_user_freq = 64; | 148 | rtc->max_user_freq = 64; |
146 | rtc->dev.parent = dev; | 149 | rtc->dev.parent = dev; |
147 | rtc->dev.class = rtc_class; | 150 | rtc->dev.class = rtc_class; |
@@ -152,6 +155,24 @@ struct rtc_device *rtc_device_register(const char *name, struct device *dev, | |||
152 | spin_lock_init(&rtc->irq_task_lock); | 155 | spin_lock_init(&rtc->irq_task_lock); |
153 | init_waitqueue_head(&rtc->irq_queue); | 156 | init_waitqueue_head(&rtc->irq_queue); |
154 | 157 | ||
158 | /* Init timerqueue */ | ||
159 | timerqueue_init_head(&rtc->timerqueue); | ||
160 | INIT_WORK(&rtc->irqwork, rtc_timer_do_work); | ||
161 | /* Init aie timer */ | ||
162 | rtc_timer_init(&rtc->aie_timer, rtc_aie_update_irq, (void *)rtc); | ||
163 | /* Init uie timer */ | ||
164 | rtc_timer_init(&rtc->uie_rtctimer, rtc_uie_update_irq, (void *)rtc); | ||
165 | /* Init pie timer */ | ||
166 | hrtimer_init(&rtc->pie_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); | ||
167 | rtc->pie_timer.function = rtc_pie_update_irq; | ||
168 | rtc->pie_enabled = 0; | ||
169 | |||
170 | /* Check to see if there is an ALARM already set in hw */ | ||
171 | err = __rtc_read_alarm(rtc, &alrm); | ||
172 | |||
173 | if (!err && !rtc_valid_tm(&alrm.time)) | ||
174 | rtc_set_alarm(rtc, &alrm); | ||
175 | |||
155 | strlcpy(rtc->name, name, RTC_DEVICE_NAME_SIZE); | 176 | strlcpy(rtc->name, name, RTC_DEVICE_NAME_SIZE); |
156 | dev_set_name(&rtc->dev, "rtc%d", id); | 177 | dev_set_name(&rtc->dev, "rtc%d", id); |
157 | 178 | ||
diff --git a/drivers/rtc/interface.c b/drivers/rtc/interface.c index a0c816238aa..8ec6b069a7f 100644 --- a/drivers/rtc/interface.c +++ b/drivers/rtc/interface.c | |||
@@ -14,15 +14,14 @@ | |||
14 | #include <linux/rtc.h> | 14 | #include <linux/rtc.h> |
15 | #include <linux/sched.h> | 15 | #include <linux/sched.h> |
16 | #include <linux/log2.h> | 16 | #include <linux/log2.h> |
17 | #include <linux/workqueue.h> | ||
17 | 18 | ||
18 | int rtc_read_time(struct rtc_device *rtc, struct rtc_time *tm) | 19 | static int rtc_timer_enqueue(struct rtc_device *rtc, struct rtc_timer *timer); |
20 | static void rtc_timer_remove(struct rtc_device *rtc, struct rtc_timer *timer); | ||
21 | |||
22 | static int __rtc_read_time(struct rtc_device *rtc, struct rtc_time *tm) | ||
19 | { | 23 | { |
20 | int err; | 24 | int err; |
21 | |||
22 | err = mutex_lock_interruptible(&rtc->ops_lock); | ||
23 | if (err) | ||
24 | return err; | ||
25 | |||
26 | if (!rtc->ops) | 25 | if (!rtc->ops) |
27 | err = -ENODEV; | 26 | err = -ENODEV; |
28 | else if (!rtc->ops->read_time) | 27 | else if (!rtc->ops->read_time) |
@@ -31,7 +30,18 @@ int rtc_read_time(struct rtc_device *rtc, struct rtc_time *tm) | |||
31 | memset(tm, 0, sizeof(struct rtc_time)); | 30 | memset(tm, 0, sizeof(struct rtc_time)); |
32 | err = rtc->ops->read_time(rtc->dev.parent, tm); | 31 | err = rtc->ops->read_time(rtc->dev.parent, tm); |
33 | } | 32 | } |
33 | return err; | ||
34 | } | ||
35 | |||
36 | int rtc_read_time(struct rtc_device *rtc, struct rtc_time *tm) | ||
37 | { | ||
38 | int err; | ||
39 | |||
40 | err = mutex_lock_interruptible(&rtc->ops_lock); | ||
41 | if (err) | ||
42 | return err; | ||
34 | 43 | ||
44 | err = __rtc_read_time(rtc, tm); | ||
35 | mutex_unlock(&rtc->ops_lock); | 45 | mutex_unlock(&rtc->ops_lock); |
36 | return err; | 46 | return err; |
37 | } | 47 | } |
@@ -127,7 +137,7 @@ static int rtc_read_alarm_internal(struct rtc_device *rtc, struct rtc_wkalrm *al | |||
127 | return err; | 137 | return err; |
128 | } | 138 | } |
129 | 139 | ||
130 | int rtc_read_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm) | 140 | int __rtc_read_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm) |
131 | { | 141 | { |
132 | int err; | 142 | int err; |
133 | struct rtc_time before, now; | 143 | struct rtc_time before, now; |
@@ -190,8 +200,6 @@ int rtc_read_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm) | |||
190 | err = rtc_read_alarm_internal(rtc, alarm); | 200 | err = rtc_read_alarm_internal(rtc, alarm); |
191 | if (err) | 201 | if (err) |
192 | return err; | 202 | return err; |
193 | if (!alarm->enabled) | ||
194 | return 0; | ||
195 | 203 | ||
196 | /* full-function RTCs won't have such missing fields */ | 204 | /* full-function RTCs won't have such missing fields */ |
197 | if (rtc_valid_tm(&alarm->time) == 0) | 205 | if (rtc_valid_tm(&alarm->time) == 0) |
@@ -287,19 +295,51 @@ int rtc_read_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm) | |||
287 | done: | 295 | done: |
288 | return 0; | 296 | return 0; |
289 | } | 297 | } |
290 | EXPORT_SYMBOL_GPL(rtc_read_alarm); | ||
291 | 298 | ||
292 | int rtc_set_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm) | 299 | int rtc_read_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm) |
293 | { | 300 | { |
294 | int err; | 301 | int err; |
295 | 302 | ||
296 | err = rtc_valid_tm(&alarm->time); | 303 | err = mutex_lock_interruptible(&rtc->ops_lock); |
297 | if (err != 0) | 304 | if (err) |
298 | return err; | 305 | return err; |
306 | if (rtc->ops == NULL) | ||
307 | err = -ENODEV; | ||
308 | else if (!rtc->ops->read_alarm) | ||
309 | err = -EINVAL; | ||
310 | else { | ||
311 | memset(alarm, 0, sizeof(struct rtc_wkalrm)); | ||
312 | alarm->enabled = rtc->aie_timer.enabled; | ||
313 | alarm->time = rtc_ktime_to_tm(rtc->aie_timer.node.expires); | ||
314 | } | ||
315 | mutex_unlock(&rtc->ops_lock); | ||
299 | 316 | ||
300 | err = mutex_lock_interruptible(&rtc->ops_lock); | 317 | return err; |
318 | } | ||
319 | EXPORT_SYMBOL_GPL(rtc_read_alarm); | ||
320 | |||
321 | int __rtc_set_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm) | ||
322 | { | ||
323 | struct rtc_time tm; | ||
324 | long now, scheduled; | ||
325 | int err; | ||
326 | |||
327 | err = rtc_valid_tm(&alarm->time); | ||
301 | if (err) | 328 | if (err) |
302 | return err; | 329 | return err; |
330 | rtc_tm_to_time(&alarm->time, &scheduled); | ||
331 | |||
332 | /* Make sure we're not setting alarms in the past */ | ||
333 | err = __rtc_read_time(rtc, &tm); | ||
334 | rtc_tm_to_time(&tm, &now); | ||
335 | if (scheduled <= now) | ||
336 | return -ETIME; | ||
337 | /* | ||
338 | * XXX - We just checked to make sure the alarm time is not | ||
339 | * in the past, but there is still a race window where if | ||
340 | * the is alarm set for the next second and the second ticks | ||
341 | * over right here, before we set the alarm. | ||
342 | */ | ||
303 | 343 | ||
304 | if (!rtc->ops) | 344 | if (!rtc->ops) |
305 | err = -ENODEV; | 345 | err = -ENODEV; |
@@ -308,6 +348,28 @@ int rtc_set_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm) | |||
308 | else | 348 | else |
309 | err = rtc->ops->set_alarm(rtc->dev.parent, alarm); | 349 | err = rtc->ops->set_alarm(rtc->dev.parent, alarm); |
310 | 350 | ||
351 | return err; | ||
352 | } | ||
353 | |||
354 | int rtc_set_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm) | ||
355 | { | ||
356 | int err; | ||
357 | |||
358 | err = rtc_valid_tm(&alarm->time); | ||
359 | if (err != 0) | ||
360 | return err; | ||
361 | |||
362 | err = mutex_lock_interruptible(&rtc->ops_lock); | ||
363 | if (err) | ||
364 | return err; | ||
365 | if (rtc->aie_timer.enabled) { | ||
366 | rtc_timer_remove(rtc, &rtc->aie_timer); | ||
367 | } | ||
368 | rtc->aie_timer.node.expires = rtc_tm_to_ktime(alarm->time); | ||
369 | rtc->aie_timer.period = ktime_set(0, 0); | ||
370 | if (alarm->enabled) { | ||
371 | err = rtc_timer_enqueue(rtc, &rtc->aie_timer); | ||
372 | } | ||
311 | mutex_unlock(&rtc->ops_lock); | 373 | mutex_unlock(&rtc->ops_lock); |
312 | return err; | 374 | return err; |
313 | } | 375 | } |
@@ -319,7 +381,16 @@ int rtc_alarm_irq_enable(struct rtc_device *rtc, unsigned int enabled) | |||
319 | if (err) | 381 | if (err) |
320 | return err; | 382 | return err; |
321 | 383 | ||
322 | if (!rtc->ops) | 384 | if (rtc->aie_timer.enabled != enabled) { |
385 | if (enabled) | ||
386 | err = rtc_timer_enqueue(rtc, &rtc->aie_timer); | ||
387 | else | ||
388 | rtc_timer_remove(rtc, &rtc->aie_timer); | ||
389 | } | ||
390 | |||
391 | if (err) | ||
392 | /* nothing */; | ||
393 | else if (!rtc->ops) | ||
323 | err = -ENODEV; | 394 | err = -ENODEV; |
324 | else if (!rtc->ops->alarm_irq_enable) | 395 | else if (!rtc->ops->alarm_irq_enable) |
325 | err = -EINVAL; | 396 | err = -EINVAL; |
@@ -340,19 +411,28 @@ int rtc_update_irq_enable(struct rtc_device *rtc, unsigned int enabled) | |||
340 | #ifdef CONFIG_RTC_INTF_DEV_UIE_EMUL | 411 | #ifdef CONFIG_RTC_INTF_DEV_UIE_EMUL |
341 | if (enabled == 0 && rtc->uie_irq_active) { | 412 | if (enabled == 0 && rtc->uie_irq_active) { |
342 | mutex_unlock(&rtc->ops_lock); | 413 | mutex_unlock(&rtc->ops_lock); |
343 | return rtc_dev_update_irq_enable_emul(rtc, enabled); | 414 | return rtc_dev_update_irq_enable_emul(rtc, 0); |
344 | } | 415 | } |
345 | #endif | 416 | #endif |
417 | /* make sure we're changing state */ | ||
418 | if (rtc->uie_rtctimer.enabled == enabled) | ||
419 | goto out; | ||
420 | |||
421 | if (enabled) { | ||
422 | struct rtc_time tm; | ||
423 | ktime_t now, onesec; | ||
424 | |||
425 | __rtc_read_time(rtc, &tm); | ||
426 | onesec = ktime_set(1, 0); | ||
427 | now = rtc_tm_to_ktime(tm); | ||
428 | rtc->uie_rtctimer.node.expires = ktime_add(now, onesec); | ||
429 | rtc->uie_rtctimer.period = ktime_set(1, 0); | ||
430 | err = rtc_timer_enqueue(rtc, &rtc->uie_rtctimer); | ||
431 | } else | ||
432 | rtc_timer_remove(rtc, &rtc->uie_rtctimer); | ||
346 | 433 | ||
347 | if (!rtc->ops) | 434 | out: |
348 | err = -ENODEV; | ||
349 | else if (!rtc->ops->update_irq_enable) | ||
350 | err = -EINVAL; | ||
351 | else | ||
352 | err = rtc->ops->update_irq_enable(rtc->dev.parent, enabled); | ||
353 | |||
354 | mutex_unlock(&rtc->ops_lock); | 435 | mutex_unlock(&rtc->ops_lock); |
355 | |||
356 | #ifdef CONFIG_RTC_INTF_DEV_UIE_EMUL | 436 | #ifdef CONFIG_RTC_INTF_DEV_UIE_EMUL |
357 | /* | 437 | /* |
358 | * Enable emulation if the driver did not provide | 438 | * Enable emulation if the driver did not provide |
@@ -364,25 +444,30 @@ int rtc_update_irq_enable(struct rtc_device *rtc, unsigned int enabled) | |||
364 | err = rtc_dev_update_irq_enable_emul(rtc, enabled); | 444 | err = rtc_dev_update_irq_enable_emul(rtc, enabled); |
365 | #endif | 445 | #endif |
366 | return err; | 446 | return err; |
447 | |||
367 | } | 448 | } |
368 | EXPORT_SYMBOL_GPL(rtc_update_irq_enable); | 449 | EXPORT_SYMBOL_GPL(rtc_update_irq_enable); |
369 | 450 | ||
451 | |||
370 | /** | 452 | /** |
371 | * rtc_update_irq - report RTC periodic, alarm, and/or update irqs | 453 | * rtc_handle_legacy_irq - AIE, UIE and PIE event hook |
372 | * @rtc: the rtc device | 454 | * @rtc: pointer to the rtc device |
373 | * @num: how many irqs are being reported (usually one) | 455 | * |
374 | * @events: mask of RTC_IRQF with one or more of RTC_PF, RTC_AF, RTC_UF | 456 | * This function is called when an AIE, UIE or PIE mode interrupt |
375 | * Context: any | 457 | * has occured (or been emulated). |
458 | * | ||
459 | * Triggers the registered irq_task function callback. | ||
376 | */ | 460 | */ |
377 | void rtc_update_irq(struct rtc_device *rtc, | 461 | void rtc_handle_legacy_irq(struct rtc_device *rtc, int num, int mode) |
378 | unsigned long num, unsigned long events) | ||
379 | { | 462 | { |
380 | unsigned long flags; | 463 | unsigned long flags; |
381 | 464 | ||
465 | /* mark one irq of the appropriate mode */ | ||
382 | spin_lock_irqsave(&rtc->irq_lock, flags); | 466 | spin_lock_irqsave(&rtc->irq_lock, flags); |
383 | rtc->irq_data = (rtc->irq_data + (num << 8)) | events; | 467 | rtc->irq_data = (rtc->irq_data + (num << 8)) | (RTC_IRQF|mode); |
384 | spin_unlock_irqrestore(&rtc->irq_lock, flags); | 468 | spin_unlock_irqrestore(&rtc->irq_lock, flags); |
385 | 469 | ||
470 | /* call the task func */ | ||
386 | spin_lock_irqsave(&rtc->irq_task_lock, flags); | 471 | spin_lock_irqsave(&rtc->irq_task_lock, flags); |
387 | if (rtc->irq_task) | 472 | if (rtc->irq_task) |
388 | rtc->irq_task->func(rtc->irq_task->private_data); | 473 | rtc->irq_task->func(rtc->irq_task->private_data); |
@@ -391,6 +476,69 @@ void rtc_update_irq(struct rtc_device *rtc, | |||
391 | wake_up_interruptible(&rtc->irq_queue); | 476 | wake_up_interruptible(&rtc->irq_queue); |
392 | kill_fasync(&rtc->async_queue, SIGIO, POLL_IN); | 477 | kill_fasync(&rtc->async_queue, SIGIO, POLL_IN); |
393 | } | 478 | } |
479 | |||
480 | |||
481 | /** | ||
482 | * rtc_aie_update_irq - AIE mode rtctimer hook | ||
483 | * @private: pointer to the rtc_device | ||
484 | * | ||
485 | * This functions is called when the aie_timer expires. | ||
486 | */ | ||
487 | void rtc_aie_update_irq(void *private) | ||
488 | { | ||
489 | struct rtc_device *rtc = (struct rtc_device *)private; | ||
490 | rtc_handle_legacy_irq(rtc, 1, RTC_AF); | ||
491 | } | ||
492 | |||
493 | |||
494 | /** | ||
495 | * rtc_uie_update_irq - UIE mode rtctimer hook | ||
496 | * @private: pointer to the rtc_device | ||
497 | * | ||
498 | * This functions is called when the uie_timer expires. | ||
499 | */ | ||
500 | void rtc_uie_update_irq(void *private) | ||
501 | { | ||
502 | struct rtc_device *rtc = (struct rtc_device *)private; | ||
503 | rtc_handle_legacy_irq(rtc, 1, RTC_UF); | ||
504 | } | ||
505 | |||
506 | |||
507 | /** | ||
508 | * rtc_pie_update_irq - PIE mode hrtimer hook | ||
509 | * @timer: pointer to the pie mode hrtimer | ||
510 | * | ||
511 | * This function is used to emulate PIE mode interrupts | ||
512 | * using an hrtimer. This function is called when the periodic | ||
513 | * hrtimer expires. | ||
514 | */ | ||
515 | enum hrtimer_restart rtc_pie_update_irq(struct hrtimer *timer) | ||
516 | { | ||
517 | struct rtc_device *rtc; | ||
518 | ktime_t period; | ||
519 | int count; | ||
520 | rtc = container_of(timer, struct rtc_device, pie_timer); | ||
521 | |||
522 | period = ktime_set(0, NSEC_PER_SEC/rtc->irq_freq); | ||
523 | count = hrtimer_forward_now(timer, period); | ||
524 | |||
525 | rtc_handle_legacy_irq(rtc, count, RTC_PF); | ||
526 | |||
527 | return HRTIMER_RESTART; | ||
528 | } | ||
529 | |||
530 | /** | ||
531 | * rtc_update_irq - Triggered when a RTC interrupt occurs. | ||
532 | * @rtc: the rtc device | ||
533 | * @num: how many irqs are being reported (usually one) | ||
534 | * @events: mask of RTC_IRQF with one or more of RTC_PF, RTC_AF, RTC_UF | ||
535 | * Context: any | ||
536 | */ | ||
537 | void rtc_update_irq(struct rtc_device *rtc, | ||
538 | unsigned long num, unsigned long events) | ||
539 | { | ||
540 | schedule_work(&rtc->irqwork); | ||
541 | } | ||
394 | EXPORT_SYMBOL_GPL(rtc_update_irq); | 542 | EXPORT_SYMBOL_GPL(rtc_update_irq); |
395 | 543 | ||
396 | static int __rtc_match(struct device *dev, void *data) | 544 | static int __rtc_match(struct device *dev, void *data) |
@@ -477,18 +625,20 @@ int rtc_irq_set_state(struct rtc_device *rtc, struct rtc_task *task, int enabled | |||
477 | int err = 0; | 625 | int err = 0; |
478 | unsigned long flags; | 626 | unsigned long flags; |
479 | 627 | ||
480 | if (rtc->ops->irq_set_state == NULL) | ||
481 | return -ENXIO; | ||
482 | |||
483 | spin_lock_irqsave(&rtc->irq_task_lock, flags); | 628 | spin_lock_irqsave(&rtc->irq_task_lock, flags); |
484 | if (rtc->irq_task != NULL && task == NULL) | 629 | if (rtc->irq_task != NULL && task == NULL) |
485 | err = -EBUSY; | 630 | err = -EBUSY; |
486 | if (rtc->irq_task != task) | 631 | if (rtc->irq_task != task) |
487 | err = -EACCES; | 632 | err = -EACCES; |
488 | spin_unlock_irqrestore(&rtc->irq_task_lock, flags); | ||
489 | 633 | ||
490 | if (err == 0) | 634 | if (enabled) { |
491 | err = rtc->ops->irq_set_state(rtc->dev.parent, enabled); | 635 | ktime_t period = ktime_set(0, NSEC_PER_SEC/rtc->irq_freq); |
636 | hrtimer_start(&rtc->pie_timer, period, HRTIMER_MODE_REL); | ||
637 | } else { | ||
638 | hrtimer_cancel(&rtc->pie_timer); | ||
639 | } | ||
640 | rtc->pie_enabled = enabled; | ||
641 | spin_unlock_irqrestore(&rtc->irq_task_lock, flags); | ||
492 | 642 | ||
493 | return err; | 643 | return err; |
494 | } | 644 | } |
@@ -509,21 +659,206 @@ int rtc_irq_set_freq(struct rtc_device *rtc, struct rtc_task *task, int freq) | |||
509 | int err = 0; | 659 | int err = 0; |
510 | unsigned long flags; | 660 | unsigned long flags; |
511 | 661 | ||
512 | if (rtc->ops->irq_set_freq == NULL) | 662 | if (freq <= 0) |
513 | return -ENXIO; | 663 | return -EINVAL; |
514 | 664 | ||
515 | spin_lock_irqsave(&rtc->irq_task_lock, flags); | 665 | spin_lock_irqsave(&rtc->irq_task_lock, flags); |
516 | if (rtc->irq_task != NULL && task == NULL) | 666 | if (rtc->irq_task != NULL && task == NULL) |
517 | err = -EBUSY; | 667 | err = -EBUSY; |
518 | if (rtc->irq_task != task) | 668 | if (rtc->irq_task != task) |
519 | err = -EACCES; | 669 | err = -EACCES; |
520 | spin_unlock_irqrestore(&rtc->irq_task_lock, flags); | ||
521 | |||
522 | if (err == 0) { | 670 | if (err == 0) { |
523 | err = rtc->ops->irq_set_freq(rtc->dev.parent, freq); | 671 | rtc->irq_freq = freq; |
524 | if (err == 0) | 672 | if (rtc->pie_enabled) { |
525 | rtc->irq_freq = freq; | 673 | ktime_t period; |
674 | hrtimer_cancel(&rtc->pie_timer); | ||
675 | period = ktime_set(0, NSEC_PER_SEC/rtc->irq_freq); | ||
676 | hrtimer_start(&rtc->pie_timer, period, | ||
677 | HRTIMER_MODE_REL); | ||
678 | } | ||
526 | } | 679 | } |
680 | spin_unlock_irqrestore(&rtc->irq_task_lock, flags); | ||
527 | return err; | 681 | return err; |
528 | } | 682 | } |
529 | EXPORT_SYMBOL_GPL(rtc_irq_set_freq); | 683 | EXPORT_SYMBOL_GPL(rtc_irq_set_freq); |
684 | |||
685 | /** | ||
686 | * rtc_timer_enqueue - Adds a rtc_timer to the rtc_device timerqueue | ||
687 | * @rtc rtc device | ||
688 | * @timer timer being added. | ||
689 | * | ||
690 | * Enqueues a timer onto the rtc devices timerqueue and sets | ||
691 | * the next alarm event appropriately. | ||
692 | * | ||
693 | * Sets the enabled bit on the added timer. | ||
694 | * | ||
695 | * Must hold ops_lock for proper serialization of timerqueue | ||
696 | */ | ||
697 | static int rtc_timer_enqueue(struct rtc_device *rtc, struct rtc_timer *timer) | ||
698 | { | ||
699 | timer->enabled = 1; | ||
700 | timerqueue_add(&rtc->timerqueue, &timer->node); | ||
701 | if (&timer->node == timerqueue_getnext(&rtc->timerqueue)) { | ||
702 | struct rtc_wkalrm alarm; | ||
703 | int err; | ||
704 | alarm.time = rtc_ktime_to_tm(timer->node.expires); | ||
705 | alarm.enabled = 1; | ||
706 | err = __rtc_set_alarm(rtc, &alarm); | ||
707 | if (err == -ETIME) | ||
708 | schedule_work(&rtc->irqwork); | ||
709 | else if (err) { | ||
710 | timerqueue_del(&rtc->timerqueue, &timer->node); | ||
711 | timer->enabled = 0; | ||
712 | return err; | ||
713 | } | ||
714 | } | ||
715 | return 0; | ||
716 | } | ||
717 | |||
718 | /** | ||
719 | * rtc_timer_remove - Removes a rtc_timer from the rtc_device timerqueue | ||
720 | * @rtc rtc device | ||
721 | * @timer timer being removed. | ||
722 | * | ||
723 | * Removes a timer onto the rtc devices timerqueue and sets | ||
724 | * the next alarm event appropriately. | ||
725 | * | ||
726 | * Clears the enabled bit on the removed timer. | ||
727 | * | ||
728 | * Must hold ops_lock for proper serialization of timerqueue | ||
729 | */ | ||
730 | static void rtc_timer_remove(struct rtc_device *rtc, struct rtc_timer *timer) | ||
731 | { | ||
732 | struct timerqueue_node *next = timerqueue_getnext(&rtc->timerqueue); | ||
733 | timerqueue_del(&rtc->timerqueue, &timer->node); | ||
734 | timer->enabled = 0; | ||
735 | if (next == &timer->node) { | ||
736 | struct rtc_wkalrm alarm; | ||
737 | int err; | ||
738 | next = timerqueue_getnext(&rtc->timerqueue); | ||
739 | if (!next) | ||
740 | return; | ||
741 | alarm.time = rtc_ktime_to_tm(next->expires); | ||
742 | alarm.enabled = 1; | ||
743 | err = __rtc_set_alarm(rtc, &alarm); | ||
744 | if (err == -ETIME) | ||
745 | schedule_work(&rtc->irqwork); | ||
746 | } | ||
747 | } | ||
748 | |||
749 | /** | ||
750 | * rtc_timer_do_work - Expires rtc timers | ||
751 | * @rtc rtc device | ||
752 | * @timer timer being removed. | ||
753 | * | ||
754 | * Expires rtc timers. Reprograms next alarm event if needed. | ||
755 | * Called via worktask. | ||
756 | * | ||
757 | * Serializes access to timerqueue via ops_lock mutex | ||
758 | */ | ||
759 | void rtc_timer_do_work(struct work_struct *work) | ||
760 | { | ||
761 | struct rtc_timer *timer; | ||
762 | struct timerqueue_node *next; | ||
763 | ktime_t now; | ||
764 | struct rtc_time tm; | ||
765 | |||
766 | struct rtc_device *rtc = | ||
767 | container_of(work, struct rtc_device, irqwork); | ||
768 | |||
769 | mutex_lock(&rtc->ops_lock); | ||
770 | again: | ||
771 | __rtc_read_time(rtc, &tm); | ||
772 | now = rtc_tm_to_ktime(tm); | ||
773 | while ((next = timerqueue_getnext(&rtc->timerqueue))) { | ||
774 | if (next->expires.tv64 > now.tv64) | ||
775 | break; | ||
776 | |||
777 | /* expire timer */ | ||
778 | timer = container_of(next, struct rtc_timer, node); | ||
779 | timerqueue_del(&rtc->timerqueue, &timer->node); | ||
780 | timer->enabled = 0; | ||
781 | if (timer->task.func) | ||
782 | timer->task.func(timer->task.private_data); | ||
783 | |||
784 | /* Re-add/fwd periodic timers */ | ||
785 | if (ktime_to_ns(timer->period)) { | ||
786 | timer->node.expires = ktime_add(timer->node.expires, | ||
787 | timer->period); | ||
788 | timer->enabled = 1; | ||
789 | timerqueue_add(&rtc->timerqueue, &timer->node); | ||
790 | } | ||
791 | } | ||
792 | |||
793 | /* Set next alarm */ | ||
794 | if (next) { | ||
795 | struct rtc_wkalrm alarm; | ||
796 | int err; | ||
797 | alarm.time = rtc_ktime_to_tm(next->expires); | ||
798 | alarm.enabled = 1; | ||
799 | err = __rtc_set_alarm(rtc, &alarm); | ||
800 | if (err == -ETIME) | ||
801 | goto again; | ||
802 | } | ||
803 | |||
804 | mutex_unlock(&rtc->ops_lock); | ||
805 | } | ||
806 | |||
807 | |||
808 | /* rtc_timer_init - Initializes an rtc_timer | ||
809 | * @timer: timer to be intiialized | ||
810 | * @f: function pointer to be called when timer fires | ||
811 | * @data: private data passed to function pointer | ||
812 | * | ||
813 | * Kernel interface to initializing an rtc_timer. | ||
814 | */ | ||
815 | void rtc_timer_init(struct rtc_timer *timer, void (*f)(void* p), void* data) | ||
816 | { | ||
817 | timerqueue_init(&timer->node); | ||
818 | timer->enabled = 0; | ||
819 | timer->task.func = f; | ||
820 | timer->task.private_data = data; | ||
821 | } | ||
822 | |||
823 | /* rtc_timer_start - Sets an rtc_timer to fire in the future | ||
824 | * @ rtc: rtc device to be used | ||
825 | * @ timer: timer being set | ||
826 | * @ expires: time at which to expire the timer | ||
827 | * @ period: period that the timer will recur | ||
828 | * | ||
829 | * Kernel interface to set an rtc_timer | ||
830 | */ | ||
831 | int rtc_timer_start(struct rtc_device *rtc, struct rtc_timer* timer, | ||
832 | ktime_t expires, ktime_t period) | ||
833 | { | ||
834 | int ret = 0; | ||
835 | mutex_lock(&rtc->ops_lock); | ||
836 | if (timer->enabled) | ||
837 | rtc_timer_remove(rtc, timer); | ||
838 | |||
839 | timer->node.expires = expires; | ||
840 | timer->period = period; | ||
841 | |||
842 | ret = rtc_timer_enqueue(rtc, timer); | ||
843 | |||
844 | mutex_unlock(&rtc->ops_lock); | ||
845 | return ret; | ||
846 | } | ||
847 | |||
848 | /* rtc_timer_cancel - Stops an rtc_timer | ||
849 | * @ rtc: rtc device to be used | ||
850 | * @ timer: timer being set | ||
851 | * | ||
852 | * Kernel interface to cancel an rtc_timer | ||
853 | */ | ||
854 | int rtc_timer_cancel(struct rtc_device *rtc, struct rtc_timer* timer) | ||
855 | { | ||
856 | int ret = 0; | ||
857 | mutex_lock(&rtc->ops_lock); | ||
858 | if (timer->enabled) | ||
859 | rtc_timer_remove(rtc, timer); | ||
860 | mutex_unlock(&rtc->ops_lock); | ||
861 | return ret; | ||
862 | } | ||
863 | |||
864 | |||
diff --git a/drivers/rtc/rtc-at32ap700x.c b/drivers/rtc/rtc-at32ap700x.c index b2752b6e7a2..e725d51e773 100644 --- a/drivers/rtc/rtc-at32ap700x.c +++ b/drivers/rtc/rtc-at32ap700x.c | |||
@@ -134,36 +134,29 @@ static int at32_rtc_setalarm(struct device *dev, struct rtc_wkalrm *alrm) | |||
134 | return ret; | 134 | return ret; |
135 | } | 135 | } |
136 | 136 | ||
137 | static int at32_rtc_ioctl(struct device *dev, unsigned int cmd, | 137 | static int at32_rtc_alarm_irq_enable(struct device *dev, unsigned int enabled) |
138 | unsigned long arg) | ||
139 | { | 138 | { |
140 | struct rtc_at32ap700x *rtc = dev_get_drvdata(dev); | 139 | struct rtc_at32ap700x *rtc = dev_get_drvdata(dev); |
141 | int ret = 0; | 140 | int ret = 0; |
142 | 141 | ||
143 | spin_lock_irq(&rtc->lock); | 142 | spin_lock_irq(&rtc->lock); |
144 | 143 | ||
145 | switch (cmd) { | 144 | if(enabled) { |
146 | case RTC_AIE_ON: | ||
147 | if (rtc_readl(rtc, VAL) > rtc->alarm_time) { | 145 | if (rtc_readl(rtc, VAL) > rtc->alarm_time) { |
148 | ret = -EINVAL; | 146 | ret = -EINVAL; |
149 | break; | 147 | goto out; |
150 | } | 148 | } |
151 | rtc_writel(rtc, CTRL, rtc_readl(rtc, CTRL) | 149 | rtc_writel(rtc, CTRL, rtc_readl(rtc, CTRL) |
152 | | RTC_BIT(CTRL_TOPEN)); | 150 | | RTC_BIT(CTRL_TOPEN)); |
153 | rtc_writel(rtc, ICR, RTC_BIT(ICR_TOPI)); | 151 | rtc_writel(rtc, ICR, RTC_BIT(ICR_TOPI)); |
154 | rtc_writel(rtc, IER, RTC_BIT(IER_TOPI)); | 152 | rtc_writel(rtc, IER, RTC_BIT(IER_TOPI)); |
155 | break; | 153 | } else { |
156 | case RTC_AIE_OFF: | ||
157 | rtc_writel(rtc, CTRL, rtc_readl(rtc, CTRL) | 154 | rtc_writel(rtc, CTRL, rtc_readl(rtc, CTRL) |
158 | & ~RTC_BIT(CTRL_TOPEN)); | 155 | & ~RTC_BIT(CTRL_TOPEN)); |
159 | rtc_writel(rtc, IDR, RTC_BIT(IDR_TOPI)); | 156 | rtc_writel(rtc, IDR, RTC_BIT(IDR_TOPI)); |
160 | rtc_writel(rtc, ICR, RTC_BIT(ICR_TOPI)); | 157 | rtc_writel(rtc, ICR, RTC_BIT(ICR_TOPI)); |
161 | break; | ||
162 | default: | ||
163 | ret = -ENOIOCTLCMD; | ||
164 | break; | ||
165 | } | 158 | } |
166 | 159 | out: | |
167 | spin_unlock_irq(&rtc->lock); | 160 | spin_unlock_irq(&rtc->lock); |
168 | 161 | ||
169 | return ret; | 162 | return ret; |
@@ -195,11 +188,11 @@ static irqreturn_t at32_rtc_interrupt(int irq, void *dev_id) | |||
195 | } | 188 | } |
196 | 189 | ||
197 | static struct rtc_class_ops at32_rtc_ops = { | 190 | static struct rtc_class_ops at32_rtc_ops = { |
198 | .ioctl = at32_rtc_ioctl, | ||
199 | .read_time = at32_rtc_readtime, | 191 | .read_time = at32_rtc_readtime, |
200 | .set_time = at32_rtc_settime, | 192 | .set_time = at32_rtc_settime, |
201 | .read_alarm = at32_rtc_readalarm, | 193 | .read_alarm = at32_rtc_readalarm, |
202 | .set_alarm = at32_rtc_setalarm, | 194 | .set_alarm = at32_rtc_setalarm, |
195 | .alarm_irq_enable = at32_rtc_alarm_irq_enable, | ||
203 | }; | 196 | }; |
204 | 197 | ||
205 | static int __init at32_rtc_probe(struct platform_device *pdev) | 198 | static int __init at32_rtc_probe(struct platform_device *pdev) |
diff --git a/drivers/rtc/rtc-at91rm9200.c b/drivers/rtc/rtc-at91rm9200.c index bc8bbca9a2e..518a76ec71c 100644 --- a/drivers/rtc/rtc-at91rm9200.c +++ b/drivers/rtc/rtc-at91rm9200.c | |||
@@ -183,40 +183,18 @@ static int at91_rtc_setalarm(struct device *dev, struct rtc_wkalrm *alrm) | |||
183 | return 0; | 183 | return 0; |
184 | } | 184 | } |
185 | 185 | ||
186 | /* | 186 | static int at91_rtc_alarm_irq_enable(struct device *dev, unsigned int enabled) |
187 | * Handle commands from user-space | ||
188 | */ | ||
189 | static int at91_rtc_ioctl(struct device *dev, unsigned int cmd, | ||
190 | unsigned long arg) | ||
191 | { | 187 | { |
192 | int ret = 0; | 188 | pr_debug("%s(): cmd=%08x\n", __func__, enabled); |
193 | 189 | ||
194 | pr_debug("%s(): cmd=%08x, arg=%08lx.\n", __func__, cmd, arg); | 190 | if (enabled) { |
195 | |||
196 | /* important: scrub old status before enabling IRQs */ | ||
197 | switch (cmd) { | ||
198 | case RTC_AIE_OFF: /* alarm off */ | ||
199 | at91_sys_write(AT91_RTC_IDR, AT91_RTC_ALARM); | ||
200 | break; | ||
201 | case RTC_AIE_ON: /* alarm on */ | ||
202 | at91_sys_write(AT91_RTC_SCCR, AT91_RTC_ALARM); | 191 | at91_sys_write(AT91_RTC_SCCR, AT91_RTC_ALARM); |
203 | at91_sys_write(AT91_RTC_IER, AT91_RTC_ALARM); | 192 | at91_sys_write(AT91_RTC_IER, AT91_RTC_ALARM); |
204 | break; | 193 | } else |
205 | case RTC_UIE_OFF: /* update off */ | 194 | at91_sys_write(AT91_RTC_IDR, AT91_RTC_ALARM); |
206 | at91_sys_write(AT91_RTC_IDR, AT91_RTC_SECEV); | ||
207 | break; | ||
208 | case RTC_UIE_ON: /* update on */ | ||
209 | at91_sys_write(AT91_RTC_SCCR, AT91_RTC_SECEV); | ||
210 | at91_sys_write(AT91_RTC_IER, AT91_RTC_SECEV); | ||
211 | break; | ||
212 | default: | ||
213 | ret = -ENOIOCTLCMD; | ||
214 | break; | ||
215 | } | ||
216 | 195 | ||
217 | return ret; | 196 | return 0; |
218 | } | 197 | } |
219 | |||
220 | /* | 198 | /* |
221 | * Provide additional RTC information in /proc/driver/rtc | 199 | * Provide additional RTC information in /proc/driver/rtc |
222 | */ | 200 | */ |
@@ -264,12 +242,12 @@ static irqreturn_t at91_rtc_interrupt(int irq, void *dev_id) | |||
264 | } | 242 | } |
265 | 243 | ||
266 | static const struct rtc_class_ops at91_rtc_ops = { | 244 | static const struct rtc_class_ops at91_rtc_ops = { |
267 | .ioctl = at91_rtc_ioctl, | ||
268 | .read_time = at91_rtc_readtime, | 245 | .read_time = at91_rtc_readtime, |
269 | .set_time = at91_rtc_settime, | 246 | .set_time = at91_rtc_settime, |
270 | .read_alarm = at91_rtc_readalarm, | 247 | .read_alarm = at91_rtc_readalarm, |
271 | .set_alarm = at91_rtc_setalarm, | 248 | .set_alarm = at91_rtc_setalarm, |
272 | .proc = at91_rtc_proc, | 249 | .proc = at91_rtc_proc, |
250 | .alarm_irq_enable = at91_rtc_alarm_irq_enable, | ||
273 | }; | 251 | }; |
274 | 252 | ||
275 | /* | 253 | /* |
diff --git a/drivers/rtc/rtc-at91sam9.c b/drivers/rtc/rtc-at91sam9.c index f677e0710ca..a3ad957507d 100644 --- a/drivers/rtc/rtc-at91sam9.c +++ b/drivers/rtc/rtc-at91sam9.c | |||
@@ -216,37 +216,17 @@ static int at91_rtc_setalarm(struct device *dev, struct rtc_wkalrm *alrm) | |||
216 | return 0; | 216 | return 0; |
217 | } | 217 | } |
218 | 218 | ||
219 | /* | 219 | static int at91_rtc_alarm_irq_enable(struct device *dev, unsigned int enabled) |
220 | * Handle commands from user-space | ||
221 | */ | ||
222 | static int at91_rtc_ioctl(struct device *dev, unsigned int cmd, | ||
223 | unsigned long arg) | ||
224 | { | 220 | { |
225 | struct sam9_rtc *rtc = dev_get_drvdata(dev); | 221 | struct sam9_rtc *rtc = dev_get_drvdata(dev); |
226 | int ret = 0; | ||
227 | u32 mr = rtt_readl(rtc, MR); | 222 | u32 mr = rtt_readl(rtc, MR); |
228 | 223 | ||
229 | dev_dbg(dev, "ioctl: cmd=%08x, arg=%08lx, mr %08x\n", cmd, arg, mr); | 224 | dev_dbg(dev, "alarm_irq_enable: enabled=%08x, mr %08x\n", enabled, mr); |
230 | 225 | if (enabled) | |
231 | switch (cmd) { | ||
232 | case RTC_AIE_OFF: /* alarm off */ | ||
233 | rtt_writel(rtc, MR, mr & ~AT91_RTT_ALMIEN); | ||
234 | break; | ||
235 | case RTC_AIE_ON: /* alarm on */ | ||
236 | rtt_writel(rtc, MR, mr | AT91_RTT_ALMIEN); | 226 | rtt_writel(rtc, MR, mr | AT91_RTT_ALMIEN); |
237 | break; | 227 | else |
238 | case RTC_UIE_OFF: /* update off */ | 228 | rtt_writel(rtc, MR, mr & ~AT91_RTT_ALMIEN); |
239 | rtt_writel(rtc, MR, mr & ~AT91_RTT_RTTINCIEN); | 229 | return 0; |
240 | break; | ||
241 | case RTC_UIE_ON: /* update on */ | ||
242 | rtt_writel(rtc, MR, mr | AT91_RTT_RTTINCIEN); | ||
243 | break; | ||
244 | default: | ||
245 | ret = -ENOIOCTLCMD; | ||
246 | break; | ||
247 | } | ||
248 | |||
249 | return ret; | ||
250 | } | 230 | } |
251 | 231 | ||
252 | /* | 232 | /* |
@@ -296,12 +276,12 @@ static irqreturn_t at91_rtc_interrupt(int irq, void *_rtc) | |||
296 | } | 276 | } |
297 | 277 | ||
298 | static const struct rtc_class_ops at91_rtc_ops = { | 278 | static const struct rtc_class_ops at91_rtc_ops = { |
299 | .ioctl = at91_rtc_ioctl, | ||
300 | .read_time = at91_rtc_readtime, | 279 | .read_time = at91_rtc_readtime, |
301 | .set_time = at91_rtc_settime, | 280 | .set_time = at91_rtc_settime, |
302 | .read_alarm = at91_rtc_readalarm, | 281 | .read_alarm = at91_rtc_readalarm, |
303 | .set_alarm = at91_rtc_setalarm, | 282 | .set_alarm = at91_rtc_setalarm, |
304 | .proc = at91_rtc_proc, | 283 | .proc = at91_rtc_proc, |
284 | .alarm_irq_enable = at91_rtc_alarm_irq_enable, | ||
305 | }; | 285 | }; |
306 | 286 | ||
307 | /* | 287 | /* |
diff --git a/drivers/rtc/rtc-bfin.c b/drivers/rtc/rtc-bfin.c index b4b6087f223..ca9cff85ab8 100644 --- a/drivers/rtc/rtc-bfin.c +++ b/drivers/rtc/rtc-bfin.c | |||
@@ -240,40 +240,16 @@ static void bfin_rtc_int_set_alarm(struct bfin_rtc *rtc) | |||
240 | */ | 240 | */ |
241 | bfin_rtc_int_set(rtc->rtc_alarm.tm_yday == -1 ? RTC_ISTAT_ALARM : RTC_ISTAT_ALARM_DAY); | 241 | bfin_rtc_int_set(rtc->rtc_alarm.tm_yday == -1 ? RTC_ISTAT_ALARM : RTC_ISTAT_ALARM_DAY); |
242 | } | 242 | } |
243 | static int bfin_rtc_ioctl(struct device *dev, unsigned int cmd, unsigned long arg) | 243 | |
244 | static int bfin_rtc_alarm_irq_enable(struct device *dev, unsigned int enabled) | ||
244 | { | 245 | { |
245 | struct bfin_rtc *rtc = dev_get_drvdata(dev); | 246 | struct bfin_rtc *rtc = dev_get_drvdata(dev); |
246 | int ret = 0; | ||
247 | 247 | ||
248 | dev_dbg_stamp(dev); | 248 | dev_dbg_stamp(dev); |
249 | 249 | if (enabled) | |
250 | bfin_rtc_sync_pending(dev); | ||
251 | |||
252 | switch (cmd) { | ||
253 | case RTC_UIE_ON: | ||
254 | dev_dbg_stamp(dev); | ||
255 | bfin_rtc_int_set(RTC_ISTAT_SEC); | ||
256 | break; | ||
257 | case RTC_UIE_OFF: | ||
258 | dev_dbg_stamp(dev); | ||
259 | bfin_rtc_int_clear(~RTC_ISTAT_SEC); | ||
260 | break; | ||
261 | |||
262 | case RTC_AIE_ON: | ||
263 | dev_dbg_stamp(dev); | ||
264 | bfin_rtc_int_set_alarm(rtc); | 250 | bfin_rtc_int_set_alarm(rtc); |
265 | break; | 251 | else |
266 | case RTC_AIE_OFF: | ||
267 | dev_dbg_stamp(dev); | ||
268 | bfin_rtc_int_clear(~(RTC_ISTAT_ALARM | RTC_ISTAT_ALARM_DAY)); | 252 | bfin_rtc_int_clear(~(RTC_ISTAT_ALARM | RTC_ISTAT_ALARM_DAY)); |
269 | break; | ||
270 | |||
271 | default: | ||
272 | dev_dbg_stamp(dev); | ||
273 | ret = -ENOIOCTLCMD; | ||
274 | } | ||
275 | |||
276 | return ret; | ||
277 | } | 253 | } |
278 | 254 | ||
279 | static int bfin_rtc_read_time(struct device *dev, struct rtc_time *tm) | 255 | static int bfin_rtc_read_time(struct device *dev, struct rtc_time *tm) |
@@ -356,12 +332,12 @@ static int bfin_rtc_proc(struct device *dev, struct seq_file *seq) | |||
356 | } | 332 | } |
357 | 333 | ||
358 | static struct rtc_class_ops bfin_rtc_ops = { | 334 | static struct rtc_class_ops bfin_rtc_ops = { |
359 | .ioctl = bfin_rtc_ioctl, | ||
360 | .read_time = bfin_rtc_read_time, | 335 | .read_time = bfin_rtc_read_time, |
361 | .set_time = bfin_rtc_set_time, | 336 | .set_time = bfin_rtc_set_time, |
362 | .read_alarm = bfin_rtc_read_alarm, | 337 | .read_alarm = bfin_rtc_read_alarm, |
363 | .set_alarm = bfin_rtc_set_alarm, | 338 | .set_alarm = bfin_rtc_set_alarm, |
364 | .proc = bfin_rtc_proc, | 339 | .proc = bfin_rtc_proc, |
340 | .alarm_irq_enable = bfin_rtc_alarm_irq_enable, | ||
365 | }; | 341 | }; |
366 | 342 | ||
367 | static int __devinit bfin_rtc_probe(struct platform_device *pdev) | 343 | static int __devinit bfin_rtc_probe(struct platform_device *pdev) |
diff --git a/drivers/rtc/rtc-cmos.c b/drivers/rtc/rtc-cmos.c index 5856167a0c9..911e75cdc12 100644 --- a/drivers/rtc/rtc-cmos.c +++ b/drivers/rtc/rtc-cmos.c | |||
@@ -36,6 +36,9 @@ | |||
36 | #include <linux/platform_device.h> | 36 | #include <linux/platform_device.h> |
37 | #include <linux/mod_devicetable.h> | 37 | #include <linux/mod_devicetable.h> |
38 | #include <linux/log2.h> | 38 | #include <linux/log2.h> |
39 | #include <linux/pm.h> | ||
40 | #include <linux/of.h> | ||
41 | #include <linux/of_platform.h> | ||
39 | 42 | ||
40 | /* this is for "generic access to PC-style RTC" using CMOS_READ/CMOS_WRITE */ | 43 | /* this is for "generic access to PC-style RTC" using CMOS_READ/CMOS_WRITE */ |
41 | #include <asm-generic/rtc.h> | 44 | #include <asm-generic/rtc.h> |
@@ -374,50 +377,6 @@ static int cmos_set_alarm(struct device *dev, struct rtc_wkalrm *t) | |||
374 | return 0; | 377 | return 0; |
375 | } | 378 | } |
376 | 379 | ||
377 | static int cmos_irq_set_freq(struct device *dev, int freq) | ||
378 | { | ||
379 | struct cmos_rtc *cmos = dev_get_drvdata(dev); | ||
380 | int f; | ||
381 | unsigned long flags; | ||
382 | |||
383 | if (!is_valid_irq(cmos->irq)) | ||
384 | return -ENXIO; | ||
385 | |||
386 | if (!is_power_of_2(freq)) | ||
387 | return -EINVAL; | ||
388 | /* 0 = no irqs; 1 = 2^15 Hz ... 15 = 2^0 Hz */ | ||
389 | f = ffs(freq); | ||
390 | if (f-- > 16) | ||
391 | return -EINVAL; | ||
392 | f = 16 - f; | ||
393 | |||
394 | spin_lock_irqsave(&rtc_lock, flags); | ||
395 | hpet_set_periodic_freq(freq); | ||
396 | CMOS_WRITE(RTC_REF_CLCK_32KHZ | f, RTC_FREQ_SELECT); | ||
397 | spin_unlock_irqrestore(&rtc_lock, flags); | ||
398 | |||
399 | return 0; | ||
400 | } | ||
401 | |||
402 | static int cmos_irq_set_state(struct device *dev, int enabled) | ||
403 | { | ||
404 | struct cmos_rtc *cmos = dev_get_drvdata(dev); | ||
405 | unsigned long flags; | ||
406 | |||
407 | if (!is_valid_irq(cmos->irq)) | ||
408 | return -ENXIO; | ||
409 | |||
410 | spin_lock_irqsave(&rtc_lock, flags); | ||
411 | |||
412 | if (enabled) | ||
413 | cmos_irq_enable(cmos, RTC_PIE); | ||
414 | else | ||
415 | cmos_irq_disable(cmos, RTC_PIE); | ||
416 | |||
417 | spin_unlock_irqrestore(&rtc_lock, flags); | ||
418 | return 0; | ||
419 | } | ||
420 | |||
421 | static int cmos_alarm_irq_enable(struct device *dev, unsigned int enabled) | 380 | static int cmos_alarm_irq_enable(struct device *dev, unsigned int enabled) |
422 | { | 381 | { |
423 | struct cmos_rtc *cmos = dev_get_drvdata(dev); | 382 | struct cmos_rtc *cmos = dev_get_drvdata(dev); |
@@ -437,25 +396,6 @@ static int cmos_alarm_irq_enable(struct device *dev, unsigned int enabled) | |||
437 | return 0; | 396 | return 0; |
438 | } | 397 | } |
439 | 398 | ||
440 | static int cmos_update_irq_enable(struct device *dev, unsigned int enabled) | ||
441 | { | ||
442 | struct cmos_rtc *cmos = dev_get_drvdata(dev); | ||
443 | unsigned long flags; | ||
444 | |||
445 | if (!is_valid_irq(cmos->irq)) | ||
446 | return -EINVAL; | ||
447 | |||
448 | spin_lock_irqsave(&rtc_lock, flags); | ||
449 | |||
450 | if (enabled) | ||
451 | cmos_irq_enable(cmos, RTC_UIE); | ||
452 | else | ||
453 | cmos_irq_disable(cmos, RTC_UIE); | ||
454 | |||
455 | spin_unlock_irqrestore(&rtc_lock, flags); | ||
456 | return 0; | ||
457 | } | ||
458 | |||
459 | #if defined(CONFIG_RTC_INTF_PROC) || defined(CONFIG_RTC_INTF_PROC_MODULE) | 399 | #if defined(CONFIG_RTC_INTF_PROC) || defined(CONFIG_RTC_INTF_PROC_MODULE) |
460 | 400 | ||
461 | static int cmos_procfs(struct device *dev, struct seq_file *seq) | 401 | static int cmos_procfs(struct device *dev, struct seq_file *seq) |
@@ -500,10 +440,7 @@ static const struct rtc_class_ops cmos_rtc_ops = { | |||
500 | .read_alarm = cmos_read_alarm, | 440 | .read_alarm = cmos_read_alarm, |
501 | .set_alarm = cmos_set_alarm, | 441 | .set_alarm = cmos_set_alarm, |
502 | .proc = cmos_procfs, | 442 | .proc = cmos_procfs, |
503 | .irq_set_freq = cmos_irq_set_freq, | ||
504 | .irq_set_state = cmos_irq_set_state, | ||
505 | .alarm_irq_enable = cmos_alarm_irq_enable, | 443 | .alarm_irq_enable = cmos_alarm_irq_enable, |
506 | .update_irq_enable = cmos_update_irq_enable, | ||
507 | }; | 444 | }; |
508 | 445 | ||
509 | /*----------------------------------------------------------------*/ | 446 | /*----------------------------------------------------------------*/ |
@@ -687,7 +624,8 @@ cmos_do_probe(struct device *dev, struct resource *ports, int rtc_irq) | |||
687 | #if defined(CONFIG_ATARI) | 624 | #if defined(CONFIG_ATARI) |
688 | address_space = 64; | 625 | address_space = 64; |
689 | #elif defined(__i386__) || defined(__x86_64__) || defined(__arm__) \ | 626 | #elif defined(__i386__) || defined(__x86_64__) || defined(__arm__) \ |
690 | || defined(__sparc__) || defined(__mips__) | 627 | || defined(__sparc__) || defined(__mips__) \ |
628 | || defined(__powerpc__) | ||
691 | address_space = 128; | 629 | address_space = 128; |
692 | #else | 630 | #else |
693 | #warning Assuming 128 bytes of RTC+NVRAM address space, not 64 bytes. | 631 | #warning Assuming 128 bytes of RTC+NVRAM address space, not 64 bytes. |
@@ -850,7 +788,7 @@ static void __exit cmos_do_remove(struct device *dev) | |||
850 | 788 | ||
851 | #ifdef CONFIG_PM | 789 | #ifdef CONFIG_PM |
852 | 790 | ||
853 | static int cmos_suspend(struct device *dev, pm_message_t mesg) | 791 | static int cmos_suspend(struct device *dev) |
854 | { | 792 | { |
855 | struct cmos_rtc *cmos = dev_get_drvdata(dev); | 793 | struct cmos_rtc *cmos = dev_get_drvdata(dev); |
856 | unsigned char tmp; | 794 | unsigned char tmp; |
@@ -898,7 +836,7 @@ static int cmos_suspend(struct device *dev, pm_message_t mesg) | |||
898 | */ | 836 | */ |
899 | static inline int cmos_poweroff(struct device *dev) | 837 | static inline int cmos_poweroff(struct device *dev) |
900 | { | 838 | { |
901 | return cmos_suspend(dev, PMSG_HIBERNATE); | 839 | return cmos_suspend(dev); |
902 | } | 840 | } |
903 | 841 | ||
904 | static int cmos_resume(struct device *dev) | 842 | static int cmos_resume(struct device *dev) |
@@ -945,9 +883,9 @@ static int cmos_resume(struct device *dev) | |||
945 | return 0; | 883 | return 0; |
946 | } | 884 | } |
947 | 885 | ||
886 | static SIMPLE_DEV_PM_OPS(cmos_pm_ops, cmos_suspend, cmos_resume); | ||
887 | |||
948 | #else | 888 | #else |
949 | #define cmos_suspend NULL | ||
950 | #define cmos_resume NULL | ||
951 | 889 | ||
952 | static inline int cmos_poweroff(struct device *dev) | 890 | static inline int cmos_poweroff(struct device *dev) |
953 | { | 891 | { |
@@ -1077,7 +1015,7 @@ static void __exit cmos_pnp_remove(struct pnp_dev *pnp) | |||
1077 | 1015 | ||
1078 | static int cmos_pnp_suspend(struct pnp_dev *pnp, pm_message_t mesg) | 1016 | static int cmos_pnp_suspend(struct pnp_dev *pnp, pm_message_t mesg) |
1079 | { | 1017 | { |
1080 | return cmos_suspend(&pnp->dev, mesg); | 1018 | return cmos_suspend(&pnp->dev); |
1081 | } | 1019 | } |
1082 | 1020 | ||
1083 | static int cmos_pnp_resume(struct pnp_dev *pnp) | 1021 | static int cmos_pnp_resume(struct pnp_dev *pnp) |
@@ -1121,6 +1059,47 @@ static struct pnp_driver cmos_pnp_driver = { | |||
1121 | 1059 | ||
1122 | #endif /* CONFIG_PNP */ | 1060 | #endif /* CONFIG_PNP */ |
1123 | 1061 | ||
1062 | #ifdef CONFIG_OF | ||
1063 | static const struct of_device_id of_cmos_match[] = { | ||
1064 | { | ||
1065 | .compatible = "motorola,mc146818", | ||
1066 | }, | ||
1067 | { }, | ||
1068 | }; | ||
1069 | MODULE_DEVICE_TABLE(of, of_cmos_match); | ||
1070 | |||
1071 | static __init void cmos_of_init(struct platform_device *pdev) | ||
1072 | { | ||
1073 | struct device_node *node = pdev->dev.of_node; | ||
1074 | struct rtc_time time; | ||
1075 | int ret; | ||
1076 | const __be32 *val; | ||
1077 | |||
1078 | if (!node) | ||
1079 | return; | ||
1080 | |||
1081 | val = of_get_property(node, "ctrl-reg", NULL); | ||
1082 | if (val) | ||
1083 | CMOS_WRITE(be32_to_cpup(val), RTC_CONTROL); | ||
1084 | |||
1085 | val = of_get_property(node, "freq-reg", NULL); | ||
1086 | if (val) | ||
1087 | CMOS_WRITE(be32_to_cpup(val), RTC_FREQ_SELECT); | ||
1088 | |||
1089 | get_rtc_time(&time); | ||
1090 | ret = rtc_valid_tm(&time); | ||
1091 | if (ret) { | ||
1092 | struct rtc_time def_time = { | ||
1093 | .tm_year = 1, | ||
1094 | .tm_mday = 1, | ||
1095 | }; | ||
1096 | set_rtc_time(&def_time); | ||
1097 | } | ||
1098 | } | ||
1099 | #else | ||
1100 | static inline void cmos_of_init(struct platform_device *pdev) {} | ||
1101 | #define of_cmos_match NULL | ||
1102 | #endif | ||
1124 | /*----------------------------------------------------------------*/ | 1103 | /*----------------------------------------------------------------*/ |
1125 | 1104 | ||
1126 | /* Platform setup should have set up an RTC device, when PNP is | 1105 | /* Platform setup should have set up an RTC device, when PNP is |
@@ -1129,6 +1108,7 @@ static struct pnp_driver cmos_pnp_driver = { | |||
1129 | 1108 | ||
1130 | static int __init cmos_platform_probe(struct platform_device *pdev) | 1109 | static int __init cmos_platform_probe(struct platform_device *pdev) |
1131 | { | 1110 | { |
1111 | cmos_of_init(pdev); | ||
1132 | cmos_wake_setup(&pdev->dev); | 1112 | cmos_wake_setup(&pdev->dev); |
1133 | return cmos_do_probe(&pdev->dev, | 1113 | return cmos_do_probe(&pdev->dev, |
1134 | platform_get_resource(pdev, IORESOURCE_IO, 0), | 1114 | platform_get_resource(pdev, IORESOURCE_IO, 0), |
@@ -1157,8 +1137,10 @@ static struct platform_driver cmos_platform_driver = { | |||
1157 | .shutdown = cmos_platform_shutdown, | 1137 | .shutdown = cmos_platform_shutdown, |
1158 | .driver = { | 1138 | .driver = { |
1159 | .name = (char *) driver_name, | 1139 | .name = (char *) driver_name, |
1160 | .suspend = cmos_suspend, | 1140 | #ifdef CONFIG_PM |
1161 | .resume = cmos_resume, | 1141 | .pm = &cmos_pm_ops, |
1142 | #endif | ||
1143 | .of_match_table = of_cmos_match, | ||
1162 | } | 1144 | } |
1163 | }; | 1145 | }; |
1164 | 1146 | ||
diff --git a/drivers/rtc/rtc-davinci.c b/drivers/rtc/rtc-davinci.c index 34647fc1ee9..8d46838dff8 100644 --- a/drivers/rtc/rtc-davinci.c +++ b/drivers/rtc/rtc-davinci.c | |||
@@ -231,10 +231,6 @@ davinci_rtc_ioctl(struct device *dev, unsigned int cmd, unsigned long arg) | |||
231 | case RTC_WIE_OFF: | 231 | case RTC_WIE_OFF: |
232 | rtc_ctrl &= ~PRTCSS_RTC_CTRL_WEN; | 232 | rtc_ctrl &= ~PRTCSS_RTC_CTRL_WEN; |
233 | break; | 233 | break; |
234 | case RTC_UIE_OFF: | ||
235 | case RTC_UIE_ON: | ||
236 | ret = -ENOTTY; | ||
237 | break; | ||
238 | default: | 234 | default: |
239 | ret = -ENOIOCTLCMD; | 235 | ret = -ENOIOCTLCMD; |
240 | } | 236 | } |
@@ -473,55 +469,6 @@ static int davinci_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alm) | |||
473 | return 0; | 469 | return 0; |
474 | } | 470 | } |
475 | 471 | ||
476 | static int davinci_rtc_irq_set_state(struct device *dev, int enabled) | ||
477 | { | ||
478 | struct davinci_rtc *davinci_rtc = dev_get_drvdata(dev); | ||
479 | unsigned long flags; | ||
480 | u8 rtc_ctrl; | ||
481 | |||
482 | spin_lock_irqsave(&davinci_rtc_lock, flags); | ||
483 | |||
484 | rtc_ctrl = rtcss_read(davinci_rtc, PRTCSS_RTC_CTRL); | ||
485 | |||
486 | if (enabled) { | ||
487 | while (rtcss_read(davinci_rtc, PRTCSS_RTC_CTRL) | ||
488 | & PRTCSS_RTC_CTRL_WDTBUS) | ||
489 | cpu_relax(); | ||
490 | |||
491 | rtc_ctrl |= PRTCSS_RTC_CTRL_TE; | ||
492 | rtcss_write(davinci_rtc, rtc_ctrl, PRTCSS_RTC_CTRL); | ||
493 | |||
494 | rtcss_write(davinci_rtc, 0x0, PRTCSS_RTC_CLKC_CNT); | ||
495 | |||
496 | rtc_ctrl |= PRTCSS_RTC_CTRL_TIEN | | ||
497 | PRTCSS_RTC_CTRL_TMMD | | ||
498 | PRTCSS_RTC_CTRL_TMRFLG; | ||
499 | } else | ||
500 | rtc_ctrl &= ~PRTCSS_RTC_CTRL_TIEN; | ||
501 | |||
502 | rtcss_write(davinci_rtc, rtc_ctrl, PRTCSS_RTC_CTRL); | ||
503 | |||
504 | spin_unlock_irqrestore(&davinci_rtc_lock, flags); | ||
505 | |||
506 | return 0; | ||
507 | } | ||
508 | |||
509 | static int davinci_rtc_irq_set_freq(struct device *dev, int freq) | ||
510 | { | ||
511 | struct davinci_rtc *davinci_rtc = dev_get_drvdata(dev); | ||
512 | unsigned long flags; | ||
513 | u16 tmr_counter = (0x8000 >> (ffs(freq) - 1)); | ||
514 | |||
515 | spin_lock_irqsave(&davinci_rtc_lock, flags); | ||
516 | |||
517 | rtcss_write(davinci_rtc, tmr_counter & 0xFF, PRTCSS_RTC_TMR0); | ||
518 | rtcss_write(davinci_rtc, (tmr_counter & 0xFF00) >> 8, PRTCSS_RTC_TMR1); | ||
519 | |||
520 | spin_unlock_irqrestore(&davinci_rtc_lock, flags); | ||
521 | |||
522 | return 0; | ||
523 | } | ||
524 | |||
525 | static struct rtc_class_ops davinci_rtc_ops = { | 472 | static struct rtc_class_ops davinci_rtc_ops = { |
526 | .ioctl = davinci_rtc_ioctl, | 473 | .ioctl = davinci_rtc_ioctl, |
527 | .read_time = davinci_rtc_read_time, | 474 | .read_time = davinci_rtc_read_time, |
@@ -529,8 +476,6 @@ static struct rtc_class_ops davinci_rtc_ops = { | |||
529 | .alarm_irq_enable = davinci_rtc_alarm_irq_enable, | 476 | .alarm_irq_enable = davinci_rtc_alarm_irq_enable, |
530 | .read_alarm = davinci_rtc_read_alarm, | 477 | .read_alarm = davinci_rtc_read_alarm, |
531 | .set_alarm = davinci_rtc_set_alarm, | 478 | .set_alarm = davinci_rtc_set_alarm, |
532 | .irq_set_state = davinci_rtc_irq_set_state, | ||
533 | .irq_set_freq = davinci_rtc_irq_set_freq, | ||
534 | }; | 479 | }; |
535 | 480 | ||
536 | static int __init davinci_rtc_probe(struct platform_device *pdev) | 481 | static int __init davinci_rtc_probe(struct platform_device *pdev) |
diff --git a/drivers/rtc/rtc-dev.c b/drivers/rtc/rtc-dev.c index 62227cd5241..d0e06edb14c 100644 --- a/drivers/rtc/rtc-dev.c +++ b/drivers/rtc/rtc-dev.c | |||
@@ -76,7 +76,7 @@ static void rtc_uie_task(struct work_struct *work) | |||
76 | } | 76 | } |
77 | spin_unlock_irq(&rtc->irq_lock); | 77 | spin_unlock_irq(&rtc->irq_lock); |
78 | if (num) | 78 | if (num) |
79 | rtc_update_irq(rtc, num, RTC_UF | RTC_IRQF); | 79 | rtc_handle_legacy_irq(rtc, num, RTC_UF); |
80 | } | 80 | } |
81 | static void rtc_uie_timer(unsigned long data) | 81 | static void rtc_uie_timer(unsigned long data) |
82 | { | 82 | { |
@@ -253,19 +253,7 @@ static long rtc_dev_ioctl(struct file *file, | |||
253 | if (err) | 253 | if (err) |
254 | goto done; | 254 | goto done; |
255 | 255 | ||
256 | /* try the driver's ioctl interface */ | 256 | /* |
257 | if (ops->ioctl) { | ||
258 | err = ops->ioctl(rtc->dev.parent, cmd, arg); | ||
259 | if (err != -ENOIOCTLCMD) { | ||
260 | mutex_unlock(&rtc->ops_lock); | ||
261 | return err; | ||
262 | } | ||
263 | } | ||
264 | |||
265 | /* if the driver does not provide the ioctl interface | ||
266 | * or if that particular ioctl was not implemented | ||
267 | * (-ENOIOCTLCMD), we will try to emulate here. | ||
268 | * | ||
269 | * Drivers *SHOULD NOT* provide ioctl implementations | 257 | * Drivers *SHOULD NOT* provide ioctl implementations |
270 | * for these requests. Instead, provide methods to | 258 | * for these requests. Instead, provide methods to |
271 | * support the following code, so that the RTC's main | 259 | * support the following code, so that the RTC's main |
@@ -428,7 +416,12 @@ static long rtc_dev_ioctl(struct file *file, | |||
428 | return err; | 416 | return err; |
429 | 417 | ||
430 | default: | 418 | default: |
431 | err = -ENOTTY; | 419 | /* Finally try the driver's ioctl interface */ |
420 | if (ops->ioctl) { | ||
421 | err = ops->ioctl(rtc->dev.parent, cmd, arg); | ||
422 | if (err == -ENOIOCTLCMD) | ||
423 | err = -ENOTTY; | ||
424 | } | ||
432 | break; | 425 | break; |
433 | } | 426 | } |
434 | 427 | ||
diff --git a/drivers/rtc/rtc-ds1286.c b/drivers/rtc/rtc-ds1286.c index bf430f9091e..60ce6960082 100644 --- a/drivers/rtc/rtc-ds1286.c +++ b/drivers/rtc/rtc-ds1286.c | |||
@@ -40,6 +40,26 @@ static inline void ds1286_rtc_write(struct ds1286_priv *priv, u8 data, int reg) | |||
40 | __raw_writel(data, &priv->rtcregs[reg]); | 40 | __raw_writel(data, &priv->rtcregs[reg]); |
41 | } | 41 | } |
42 | 42 | ||
43 | |||
44 | static int ds1286_alarm_irq_enable(struct device *dev, unsigned int enabled) | ||
45 | { | ||
46 | struct ds1286_priv *priv = dev_get_drvdata(dev); | ||
47 | unsigned long flags; | ||
48 | unsigned char val; | ||
49 | |||
50 | /* Allow or mask alarm interrupts */ | ||
51 | spin_lock_irqsave(&priv->lock, flags); | ||
52 | val = ds1286_rtc_read(priv, RTC_CMD); | ||
53 | if (enabled) | ||
54 | val &= ~RTC_TDM; | ||
55 | else | ||
56 | val |= RTC_TDM; | ||
57 | ds1286_rtc_write(priv, val, RTC_CMD); | ||
58 | spin_unlock_irqrestore(&priv->lock, flags); | ||
59 | |||
60 | return 0; | ||
61 | } | ||
62 | |||
43 | #ifdef CONFIG_RTC_INTF_DEV | 63 | #ifdef CONFIG_RTC_INTF_DEV |
44 | 64 | ||
45 | static int ds1286_ioctl(struct device *dev, unsigned int cmd, unsigned long arg) | 65 | static int ds1286_ioctl(struct device *dev, unsigned int cmd, unsigned long arg) |
@@ -49,22 +69,6 @@ static int ds1286_ioctl(struct device *dev, unsigned int cmd, unsigned long arg) | |||
49 | unsigned char val; | 69 | unsigned char val; |
50 | 70 | ||
51 | switch (cmd) { | 71 | switch (cmd) { |
52 | case RTC_AIE_OFF: | ||
53 | /* Mask alarm int. enab. bit */ | ||
54 | spin_lock_irqsave(&priv->lock, flags); | ||
55 | val = ds1286_rtc_read(priv, RTC_CMD); | ||
56 | val |= RTC_TDM; | ||
57 | ds1286_rtc_write(priv, val, RTC_CMD); | ||
58 | spin_unlock_irqrestore(&priv->lock, flags); | ||
59 | break; | ||
60 | case RTC_AIE_ON: | ||
61 | /* Allow alarm interrupts. */ | ||
62 | spin_lock_irqsave(&priv->lock, flags); | ||
63 | val = ds1286_rtc_read(priv, RTC_CMD); | ||
64 | val &= ~RTC_TDM; | ||
65 | ds1286_rtc_write(priv, val, RTC_CMD); | ||
66 | spin_unlock_irqrestore(&priv->lock, flags); | ||
67 | break; | ||
68 | case RTC_WIE_OFF: | 72 | case RTC_WIE_OFF: |
69 | /* Mask watchdog int. enab. bit */ | 73 | /* Mask watchdog int. enab. bit */ |
70 | spin_lock_irqsave(&priv->lock, flags); | 74 | spin_lock_irqsave(&priv->lock, flags); |
@@ -316,12 +320,13 @@ static int ds1286_set_alarm(struct device *dev, struct rtc_wkalrm *alm) | |||
316 | } | 320 | } |
317 | 321 | ||
318 | static const struct rtc_class_ops ds1286_ops = { | 322 | static const struct rtc_class_ops ds1286_ops = { |
319 | .ioctl = ds1286_ioctl, | 323 | .ioctl = ds1286_ioctl, |
320 | .proc = ds1286_proc, | 324 | .proc = ds1286_proc, |
321 | .read_time = ds1286_read_time, | 325 | .read_time = ds1286_read_time, |
322 | .set_time = ds1286_set_time, | 326 | .set_time = ds1286_set_time, |
323 | .read_alarm = ds1286_read_alarm, | 327 | .read_alarm = ds1286_read_alarm, |
324 | .set_alarm = ds1286_set_alarm, | 328 | .set_alarm = ds1286_set_alarm, |
329 | .alarm_irq_enable = ds1286_alarm_irq_enable, | ||
325 | }; | 330 | }; |
326 | 331 | ||
327 | static int __devinit ds1286_probe(struct platform_device *pdev) | 332 | static int __devinit ds1286_probe(struct platform_device *pdev) |
diff --git a/drivers/rtc/rtc-ds1305.c b/drivers/rtc/rtc-ds1305.c index 48da85e97ca..57fbcc149ba 100644 --- a/drivers/rtc/rtc-ds1305.c +++ b/drivers/rtc/rtc-ds1305.c | |||
@@ -139,49 +139,32 @@ static u8 hour2bcd(bool hr12, int hour) | |||
139 | * Interface to RTC framework | 139 | * Interface to RTC framework |
140 | */ | 140 | */ |
141 | 141 | ||
142 | #ifdef CONFIG_RTC_INTF_DEV | 142 | static int ds1305_alarm_irq_enable(struct device *dev, unsigned int enabled) |
143 | |||
144 | /* | ||
145 | * Context: caller holds rtc->ops_lock (to protect ds1305->ctrl) | ||
146 | */ | ||
147 | static int ds1305_ioctl(struct device *dev, unsigned cmd, unsigned long arg) | ||
148 | { | 143 | { |
149 | struct ds1305 *ds1305 = dev_get_drvdata(dev); | 144 | struct ds1305 *ds1305 = dev_get_drvdata(dev); |
150 | u8 buf[2]; | 145 | u8 buf[2]; |
151 | int status = -ENOIOCTLCMD; | 146 | long err = -EINVAL; |
152 | 147 | ||
153 | buf[0] = DS1305_WRITE | DS1305_CONTROL; | 148 | buf[0] = DS1305_WRITE | DS1305_CONTROL; |
154 | buf[1] = ds1305->ctrl[0]; | 149 | buf[1] = ds1305->ctrl[0]; |
155 | 150 | ||
156 | switch (cmd) { | 151 | if (enabled) { |
157 | case RTC_AIE_OFF: | ||
158 | status = 0; | ||
159 | if (!(buf[1] & DS1305_AEI0)) | ||
160 | goto done; | ||
161 | buf[1] &= ~DS1305_AEI0; | ||
162 | break; | ||
163 | |||
164 | case RTC_AIE_ON: | ||
165 | status = 0; | ||
166 | if (ds1305->ctrl[0] & DS1305_AEI0) | 152 | if (ds1305->ctrl[0] & DS1305_AEI0) |
167 | goto done; | 153 | goto done; |
168 | buf[1] |= DS1305_AEI0; | 154 | buf[1] |= DS1305_AEI0; |
169 | break; | 155 | } else { |
170 | } | 156 | if (!(buf[1] & DS1305_AEI0)) |
171 | if (status == 0) { | 157 | goto done; |
172 | status = spi_write_then_read(ds1305->spi, buf, sizeof buf, | 158 | buf[1] &= ~DS1305_AEI0; |
173 | NULL, 0); | ||
174 | if (status >= 0) | ||
175 | ds1305->ctrl[0] = buf[1]; | ||
176 | } | 159 | } |
177 | 160 | err = spi_write_then_read(ds1305->spi, buf, sizeof buf, NULL, 0); | |
161 | if (err >= 0) | ||
162 | ds1305->ctrl[0] = buf[1]; | ||
178 | done: | 163 | done: |
179 | return status; | 164 | return err; |
165 | |||
180 | } | 166 | } |
181 | 167 | ||
182 | #else | ||
183 | #define ds1305_ioctl NULL | ||
184 | #endif | ||
185 | 168 | ||
186 | /* | 169 | /* |
187 | * Get/set of date and time is pretty normal. | 170 | * Get/set of date and time is pretty normal. |
@@ -460,12 +443,12 @@ done: | |||
460 | #endif | 443 | #endif |
461 | 444 | ||
462 | static const struct rtc_class_ops ds1305_ops = { | 445 | static const struct rtc_class_ops ds1305_ops = { |
463 | .ioctl = ds1305_ioctl, | ||
464 | .read_time = ds1305_get_time, | 446 | .read_time = ds1305_get_time, |
465 | .set_time = ds1305_set_time, | 447 | .set_time = ds1305_set_time, |
466 | .read_alarm = ds1305_get_alarm, | 448 | .read_alarm = ds1305_get_alarm, |
467 | .set_alarm = ds1305_set_alarm, | 449 | .set_alarm = ds1305_set_alarm, |
468 | .proc = ds1305_proc, | 450 | .proc = ds1305_proc, |
451 | .alarm_irq_enable = ds1305_alarm_irq_enable, | ||
469 | }; | 452 | }; |
470 | 453 | ||
471 | static void ds1305_work(struct work_struct *work) | 454 | static void ds1305_work(struct work_struct *work) |
@@ -813,7 +796,7 @@ static int __devexit ds1305_remove(struct spi_device *spi) | |||
813 | if (spi->irq) { | 796 | if (spi->irq) { |
814 | set_bit(FLAG_EXITING, &ds1305->flags); | 797 | set_bit(FLAG_EXITING, &ds1305->flags); |
815 | free_irq(spi->irq, ds1305); | 798 | free_irq(spi->irq, ds1305); |
816 | flush_scheduled_work(); | 799 | cancel_work_sync(&ds1305->work); |
817 | } | 800 | } |
818 | 801 | ||
819 | rtc_device_unregister(ds1305->rtc); | 802 | rtc_device_unregister(ds1305->rtc); |
diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c index d827ce570a8..4724ba3acf1 100644 --- a/drivers/rtc/rtc-ds1307.c +++ b/drivers/rtc/rtc-ds1307.c | |||
@@ -106,9 +106,9 @@ struct ds1307 { | |||
106 | struct i2c_client *client; | 106 | struct i2c_client *client; |
107 | struct rtc_device *rtc; | 107 | struct rtc_device *rtc; |
108 | struct work_struct work; | 108 | struct work_struct work; |
109 | s32 (*read_block_data)(struct i2c_client *client, u8 command, | 109 | s32 (*read_block_data)(const struct i2c_client *client, u8 command, |
110 | u8 length, u8 *values); | 110 | u8 length, u8 *values); |
111 | s32 (*write_block_data)(struct i2c_client *client, u8 command, | 111 | s32 (*write_block_data)(const struct i2c_client *client, u8 command, |
112 | u8 length, const u8 *values); | 112 | u8 length, const u8 *values); |
113 | }; | 113 | }; |
114 | 114 | ||
@@ -158,8 +158,8 @@ MODULE_DEVICE_TABLE(i2c, ds1307_id); | |||
158 | 158 | ||
159 | #define BLOCK_DATA_MAX_TRIES 10 | 159 | #define BLOCK_DATA_MAX_TRIES 10 |
160 | 160 | ||
161 | static s32 ds1307_read_block_data_once(struct i2c_client *client, u8 command, | 161 | static s32 ds1307_read_block_data_once(const struct i2c_client *client, |
162 | u8 length, u8 *values) | 162 | u8 command, u8 length, u8 *values) |
163 | { | 163 | { |
164 | s32 i, data; | 164 | s32 i, data; |
165 | 165 | ||
@@ -172,7 +172,7 @@ static s32 ds1307_read_block_data_once(struct i2c_client *client, u8 command, | |||
172 | return i; | 172 | return i; |
173 | } | 173 | } |
174 | 174 | ||
175 | static s32 ds1307_read_block_data(struct i2c_client *client, u8 command, | 175 | static s32 ds1307_read_block_data(const struct i2c_client *client, u8 command, |
176 | u8 length, u8 *values) | 176 | u8 length, u8 *values) |
177 | { | 177 | { |
178 | u8 oldvalues[I2C_SMBUS_BLOCK_MAX]; | 178 | u8 oldvalues[I2C_SMBUS_BLOCK_MAX]; |
@@ -198,7 +198,7 @@ static s32 ds1307_read_block_data(struct i2c_client *client, u8 command, | |||
198 | return length; | 198 | return length; |
199 | } | 199 | } |
200 | 200 | ||
201 | static s32 ds1307_write_block_data(struct i2c_client *client, u8 command, | 201 | static s32 ds1307_write_block_data(const struct i2c_client *client, u8 command, |
202 | u8 length, const u8 *values) | 202 | u8 length, const u8 *values) |
203 | { | 203 | { |
204 | u8 currvalues[I2C_SMBUS_BLOCK_MAX]; | 204 | u8 currvalues[I2C_SMBUS_BLOCK_MAX]; |
@@ -495,50 +495,27 @@ static int ds1337_set_alarm(struct device *dev, struct rtc_wkalrm *t) | |||
495 | return 0; | 495 | return 0; |
496 | } | 496 | } |
497 | 497 | ||
498 | static int ds1307_ioctl(struct device *dev, unsigned int cmd, unsigned long arg) | 498 | static int ds1307_alarm_irq_enable(struct device *dev, unsigned int enabled) |
499 | { | 499 | { |
500 | struct i2c_client *client = to_i2c_client(dev); | 500 | struct i2c_client *client = to_i2c_client(dev); |
501 | struct ds1307 *ds1307 = i2c_get_clientdata(client); | 501 | struct ds1307 *ds1307 = i2c_get_clientdata(client); |
502 | int ret; | 502 | int ret; |
503 | 503 | ||
504 | switch (cmd) { | 504 | if (!test_bit(HAS_ALARM, &ds1307->flags)) |
505 | case RTC_AIE_OFF: | 505 | return -ENOTTY; |
506 | if (!test_bit(HAS_ALARM, &ds1307->flags)) | ||
507 | return -ENOTTY; | ||
508 | |||
509 | ret = i2c_smbus_read_byte_data(client, DS1337_REG_CONTROL); | ||
510 | if (ret < 0) | ||
511 | return ret; | ||
512 | |||
513 | ret &= ~DS1337_BIT_A1IE; | ||
514 | |||
515 | ret = i2c_smbus_write_byte_data(client, | ||
516 | DS1337_REG_CONTROL, ret); | ||
517 | if (ret < 0) | ||
518 | return ret; | ||
519 | |||
520 | break; | ||
521 | |||
522 | case RTC_AIE_ON: | ||
523 | if (!test_bit(HAS_ALARM, &ds1307->flags)) | ||
524 | return -ENOTTY; | ||
525 | 506 | ||
526 | ret = i2c_smbus_read_byte_data(client, DS1337_REG_CONTROL); | 507 | ret = i2c_smbus_read_byte_data(client, DS1337_REG_CONTROL); |
527 | if (ret < 0) | 508 | if (ret < 0) |
528 | return ret; | 509 | return ret; |
529 | 510 | ||
511 | if (enabled) | ||
530 | ret |= DS1337_BIT_A1IE; | 512 | ret |= DS1337_BIT_A1IE; |
513 | else | ||
514 | ret &= ~DS1337_BIT_A1IE; | ||
531 | 515 | ||
532 | ret = i2c_smbus_write_byte_data(client, | 516 | ret = i2c_smbus_write_byte_data(client, DS1337_REG_CONTROL, ret); |
533 | DS1337_REG_CONTROL, ret); | 517 | if (ret < 0) |
534 | if (ret < 0) | 518 | return ret; |
535 | return ret; | ||
536 | |||
537 | break; | ||
538 | |||
539 | default: | ||
540 | return -ENOIOCTLCMD; | ||
541 | } | ||
542 | 519 | ||
543 | return 0; | 520 | return 0; |
544 | } | 521 | } |
@@ -548,7 +525,7 @@ static const struct rtc_class_ops ds13xx_rtc_ops = { | |||
548 | .set_time = ds1307_set_time, | 525 | .set_time = ds1307_set_time, |
549 | .read_alarm = ds1337_read_alarm, | 526 | .read_alarm = ds1337_read_alarm, |
550 | .set_alarm = ds1337_set_alarm, | 527 | .set_alarm = ds1337_set_alarm, |
551 | .ioctl = ds1307_ioctl, | 528 | .alarm_irq_enable = ds1307_alarm_irq_enable, |
552 | }; | 529 | }; |
553 | 530 | ||
554 | /*----------------------------------------------------------------------*/ | 531 | /*----------------------------------------------------------------------*/ |
diff --git a/drivers/rtc/rtc-ds1374.c b/drivers/rtc/rtc-ds1374.c index 1f0007fd443..d834a63ec4b 100644 --- a/drivers/rtc/rtc-ds1374.c +++ b/drivers/rtc/rtc-ds1374.c | |||
@@ -307,42 +307,25 @@ unlock: | |||
307 | mutex_unlock(&ds1374->mutex); | 307 | mutex_unlock(&ds1374->mutex); |
308 | } | 308 | } |
309 | 309 | ||
310 | static int ds1374_ioctl(struct device *dev, unsigned int cmd, unsigned long arg) | 310 | static int ds1374_alarm_irq_enable(struct device *dev, unsigned int enabled) |
311 | { | 311 | { |
312 | struct i2c_client *client = to_i2c_client(dev); | 312 | struct i2c_client *client = to_i2c_client(dev); |
313 | struct ds1374 *ds1374 = i2c_get_clientdata(client); | 313 | struct ds1374 *ds1374 = i2c_get_clientdata(client); |
314 | int ret = -ENOIOCTLCMD; | 314 | int ret; |
315 | 315 | ||
316 | mutex_lock(&ds1374->mutex); | 316 | mutex_lock(&ds1374->mutex); |
317 | 317 | ||
318 | switch (cmd) { | 318 | ret = i2c_smbus_read_byte_data(client, DS1374_REG_CR); |
319 | case RTC_AIE_OFF: | 319 | if (ret < 0) |
320 | ret = i2c_smbus_read_byte_data(client, DS1374_REG_CR); | 320 | goto out; |
321 | if (ret < 0) | ||
322 | goto out; | ||
323 | |||
324 | ret &= ~DS1374_REG_CR_WACE; | ||
325 | |||
326 | ret = i2c_smbus_write_byte_data(client, DS1374_REG_CR, ret); | ||
327 | if (ret < 0) | ||
328 | goto out; | ||
329 | |||
330 | break; | ||
331 | |||
332 | case RTC_AIE_ON: | ||
333 | ret = i2c_smbus_read_byte_data(client, DS1374_REG_CR); | ||
334 | if (ret < 0) | ||
335 | goto out; | ||
336 | 321 | ||
322 | if (enabled) { | ||
337 | ret |= DS1374_REG_CR_WACE | DS1374_REG_CR_AIE; | 323 | ret |= DS1374_REG_CR_WACE | DS1374_REG_CR_AIE; |
338 | ret &= ~DS1374_REG_CR_WDALM; | 324 | ret &= ~DS1374_REG_CR_WDALM; |
339 | 325 | } else { | |
340 | ret = i2c_smbus_write_byte_data(client, DS1374_REG_CR, ret); | 326 | ret &= ~DS1374_REG_CR_WACE; |
341 | if (ret < 0) | ||
342 | goto out; | ||
343 | |||
344 | break; | ||
345 | } | 327 | } |
328 | ret = i2c_smbus_write_byte_data(client, DS1374_REG_CR, ret); | ||
346 | 329 | ||
347 | out: | 330 | out: |
348 | mutex_unlock(&ds1374->mutex); | 331 | mutex_unlock(&ds1374->mutex); |
@@ -354,7 +337,7 @@ static const struct rtc_class_ops ds1374_rtc_ops = { | |||
354 | .set_time = ds1374_set_time, | 337 | .set_time = ds1374_set_time, |
355 | .read_alarm = ds1374_read_alarm, | 338 | .read_alarm = ds1374_read_alarm, |
356 | .set_alarm = ds1374_set_alarm, | 339 | .set_alarm = ds1374_set_alarm, |
357 | .ioctl = ds1374_ioctl, | 340 | .alarm_irq_enable = ds1374_alarm_irq_enable, |
358 | }; | 341 | }; |
359 | 342 | ||
360 | static int ds1374_probe(struct i2c_client *client, | 343 | static int ds1374_probe(struct i2c_client *client, |
@@ -417,7 +400,7 @@ static int __devexit ds1374_remove(struct i2c_client *client) | |||
417 | mutex_unlock(&ds1374->mutex); | 400 | mutex_unlock(&ds1374->mutex); |
418 | 401 | ||
419 | free_irq(client->irq, client); | 402 | free_irq(client->irq, client); |
420 | flush_scheduled_work(); | 403 | cancel_work_sync(&ds1374->work); |
421 | } | 404 | } |
422 | 405 | ||
423 | rtc_device_unregister(ds1374->rtc); | 406 | rtc_device_unregister(ds1374->rtc); |
diff --git a/drivers/rtc/rtc-ds1511.c b/drivers/rtc/rtc-ds1511.c index 37268e97de4..3fffd708711 100644 --- a/drivers/rtc/rtc-ds1511.c +++ b/drivers/rtc/rtc-ds1511.c | |||
@@ -397,29 +397,12 @@ static int ds1511_rtc_alarm_irq_enable(struct device *dev, unsigned int enabled) | |||
397 | return 0; | 397 | return 0; |
398 | } | 398 | } |
399 | 399 | ||
400 | static int ds1511_rtc_update_irq_enable(struct device *dev, | ||
401 | unsigned int enabled) | ||
402 | { | ||
403 | struct platform_device *pdev = to_platform_device(dev); | ||
404 | struct rtc_plat_data *pdata = platform_get_drvdata(pdev); | ||
405 | |||
406 | if (pdata->irq <= 0) | ||
407 | return -EINVAL; | ||
408 | if (enabled) | ||
409 | pdata->irqen |= RTC_UF; | ||
410 | else | ||
411 | pdata->irqen &= ~RTC_UF; | ||
412 | ds1511_rtc_update_alarm(pdata); | ||
413 | return 0; | ||
414 | } | ||
415 | |||
416 | static const struct rtc_class_ops ds1511_rtc_ops = { | 400 | static const struct rtc_class_ops ds1511_rtc_ops = { |
417 | .read_time = ds1511_rtc_read_time, | 401 | .read_time = ds1511_rtc_read_time, |
418 | .set_time = ds1511_rtc_set_time, | 402 | .set_time = ds1511_rtc_set_time, |
419 | .read_alarm = ds1511_rtc_read_alarm, | 403 | .read_alarm = ds1511_rtc_read_alarm, |
420 | .set_alarm = ds1511_rtc_set_alarm, | 404 | .set_alarm = ds1511_rtc_set_alarm, |
421 | .alarm_irq_enable = ds1511_rtc_alarm_irq_enable, | 405 | .alarm_irq_enable = ds1511_rtc_alarm_irq_enable, |
422 | .update_irq_enable = ds1511_rtc_update_irq_enable, | ||
423 | }; | 406 | }; |
424 | 407 | ||
425 | static ssize_t | 408 | static ssize_t |
diff --git a/drivers/rtc/rtc-ds1553.c b/drivers/rtc/rtc-ds1553.c index ff432e2ca27..fee41b97c9e 100644 --- a/drivers/rtc/rtc-ds1553.c +++ b/drivers/rtc/rtc-ds1553.c | |||
@@ -227,29 +227,12 @@ static int ds1553_rtc_alarm_irq_enable(struct device *dev, unsigned int enabled) | |||
227 | return 0; | 227 | return 0; |
228 | } | 228 | } |
229 | 229 | ||
230 | static int ds1553_rtc_update_irq_enable(struct device *dev, | ||
231 | unsigned int enabled) | ||
232 | { | ||
233 | struct platform_device *pdev = to_platform_device(dev); | ||
234 | struct rtc_plat_data *pdata = platform_get_drvdata(pdev); | ||
235 | |||
236 | if (pdata->irq <= 0) | ||
237 | return -EINVAL; | ||
238 | if (enabled) | ||
239 | pdata->irqen |= RTC_UF; | ||
240 | else | ||
241 | pdata->irqen &= ~RTC_UF; | ||
242 | ds1553_rtc_update_alarm(pdata); | ||
243 | return 0; | ||
244 | } | ||
245 | |||
246 | static const struct rtc_class_ops ds1553_rtc_ops = { | 230 | static const struct rtc_class_ops ds1553_rtc_ops = { |
247 | .read_time = ds1553_rtc_read_time, | 231 | .read_time = ds1553_rtc_read_time, |
248 | .set_time = ds1553_rtc_set_time, | 232 | .set_time = ds1553_rtc_set_time, |
249 | .read_alarm = ds1553_rtc_read_alarm, | 233 | .read_alarm = ds1553_rtc_read_alarm, |
250 | .set_alarm = ds1553_rtc_set_alarm, | 234 | .set_alarm = ds1553_rtc_set_alarm, |
251 | .alarm_irq_enable = ds1553_rtc_alarm_irq_enable, | 235 | .alarm_irq_enable = ds1553_rtc_alarm_irq_enable, |
252 | .update_irq_enable = ds1553_rtc_update_irq_enable, | ||
253 | }; | 236 | }; |
254 | 237 | ||
255 | static ssize_t ds1553_nvram_read(struct file *filp, struct kobject *kobj, | 238 | static ssize_t ds1553_nvram_read(struct file *filp, struct kobject *kobj, |
diff --git a/drivers/rtc/rtc-ds3232.c b/drivers/rtc/rtc-ds3232.c index 57063552d3b..27b7bf672ac 100644 --- a/drivers/rtc/rtc-ds3232.c +++ b/drivers/rtc/rtc-ds3232.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * RTC client/driver for the Maxim/Dallas DS3232 Real-Time Clock over I2C | 2 | * RTC client/driver for the Maxim/Dallas DS3232 Real-Time Clock over I2C |
3 | * | 3 | * |
4 | * Copyright (C) 2009-2010 Freescale Semiconductor. | 4 | * Copyright (C) 2009-2011 Freescale Semiconductor. |
5 | * Author: Jack Lan <jack.lan@freescale.com> | 5 | * Author: Jack Lan <jack.lan@freescale.com> |
6 | * | 6 | * |
7 | * This program is free software; you can redistribute it and/or modify it | 7 | * This program is free software; you can redistribute it and/or modify it |
@@ -141,9 +141,11 @@ static int ds3232_read_time(struct device *dev, struct rtc_time *time) | |||
141 | time->tm_hour = bcd2bin(hour); | 141 | time->tm_hour = bcd2bin(hour); |
142 | } | 142 | } |
143 | 143 | ||
144 | time->tm_wday = bcd2bin(week); | 144 | /* Day of the week in linux range is 0~6 while 1~7 in RTC chip */ |
145 | time->tm_wday = bcd2bin(week) - 1; | ||
145 | time->tm_mday = bcd2bin(day); | 146 | time->tm_mday = bcd2bin(day); |
146 | time->tm_mon = bcd2bin(month & 0x7F); | 147 | /* linux tm_mon range:0~11, while month range is 1~12 in RTC chip */ |
148 | time->tm_mon = bcd2bin(month & 0x7F) - 1; | ||
147 | if (century) | 149 | if (century) |
148 | add_century = 100; | 150 | add_century = 100; |
149 | 151 | ||
@@ -162,9 +164,11 @@ static int ds3232_set_time(struct device *dev, struct rtc_time *time) | |||
162 | buf[0] = bin2bcd(time->tm_sec); | 164 | buf[0] = bin2bcd(time->tm_sec); |
163 | buf[1] = bin2bcd(time->tm_min); | 165 | buf[1] = bin2bcd(time->tm_min); |
164 | buf[2] = bin2bcd(time->tm_hour); | 166 | buf[2] = bin2bcd(time->tm_hour); |
165 | buf[3] = bin2bcd(time->tm_wday); /* Day of the week */ | 167 | /* Day of the week in linux range is 0~6 while 1~7 in RTC chip */ |
168 | buf[3] = bin2bcd(time->tm_wday + 1); | ||
166 | buf[4] = bin2bcd(time->tm_mday); /* Date */ | 169 | buf[4] = bin2bcd(time->tm_mday); /* Date */ |
167 | buf[5] = bin2bcd(time->tm_mon); | 170 | /* linux tm_mon range:0~11, while month range is 1~12 in RTC chip */ |
171 | buf[5] = bin2bcd(time->tm_mon + 1); | ||
168 | if (time->tm_year >= 100) { | 172 | if (time->tm_year >= 100) { |
169 | buf[5] |= 0x80; | 173 | buf[5] |= 0x80; |
170 | buf[6] = bin2bcd(time->tm_year - 100); | 174 | buf[6] = bin2bcd(time->tm_year - 100); |
@@ -335,23 +339,6 @@ static int ds3232_alarm_irq_enable(struct device *dev, unsigned int enabled) | |||
335 | return 0; | 339 | return 0; |
336 | } | 340 | } |
337 | 341 | ||
338 | static int ds3232_update_irq_enable(struct device *dev, unsigned int enabled) | ||
339 | { | ||
340 | struct i2c_client *client = to_i2c_client(dev); | ||
341 | struct ds3232 *ds3232 = i2c_get_clientdata(client); | ||
342 | |||
343 | if (client->irq <= 0) | ||
344 | return -EINVAL; | ||
345 | |||
346 | if (enabled) | ||
347 | ds3232->rtc->irq_data |= RTC_UF; | ||
348 | else | ||
349 | ds3232->rtc->irq_data &= ~RTC_UF; | ||
350 | |||
351 | ds3232_update_alarm(client); | ||
352 | return 0; | ||
353 | } | ||
354 | |||
355 | static irqreturn_t ds3232_irq(int irq, void *dev_id) | 342 | static irqreturn_t ds3232_irq(int irq, void *dev_id) |
356 | { | 343 | { |
357 | struct i2c_client *client = dev_id; | 344 | struct i2c_client *client = dev_id; |
@@ -402,7 +389,6 @@ static const struct rtc_class_ops ds3232_rtc_ops = { | |||
402 | .read_alarm = ds3232_read_alarm, | 389 | .read_alarm = ds3232_read_alarm, |
403 | .set_alarm = ds3232_set_alarm, | 390 | .set_alarm = ds3232_set_alarm, |
404 | .alarm_irq_enable = ds3232_alarm_irq_enable, | 391 | .alarm_irq_enable = ds3232_alarm_irq_enable, |
405 | .update_irq_enable = ds3232_update_irq_enable, | ||
406 | }; | 392 | }; |
407 | 393 | ||
408 | static int __devinit ds3232_probe(struct i2c_client *client, | 394 | static int __devinit ds3232_probe(struct i2c_client *client, |
@@ -463,7 +449,7 @@ static int __devexit ds3232_remove(struct i2c_client *client) | |||
463 | mutex_unlock(&ds3232->mutex); | 449 | mutex_unlock(&ds3232->mutex); |
464 | 450 | ||
465 | free_irq(client->irq, client); | 451 | free_irq(client->irq, client); |
466 | flush_scheduled_work(); | 452 | cancel_work_sync(&ds3232->work); |
467 | } | 453 | } |
468 | 454 | ||
469 | rtc_device_unregister(ds3232->rtc); | 455 | rtc_device_unregister(ds3232->rtc); |
diff --git a/drivers/rtc/rtc-jz4740.c b/drivers/rtc/rtc-jz4740.c index 2e16f72c905..b6473631d18 100644 --- a/drivers/rtc/rtc-jz4740.c +++ b/drivers/rtc/rtc-jz4740.c | |||
@@ -168,12 +168,6 @@ static int jz4740_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm) | |||
168 | return ret; | 168 | return ret; |
169 | } | 169 | } |
170 | 170 | ||
171 | static int jz4740_rtc_update_irq_enable(struct device *dev, unsigned int enable) | ||
172 | { | ||
173 | struct jz4740_rtc *rtc = dev_get_drvdata(dev); | ||
174 | return jz4740_rtc_ctrl_set_bits(rtc, JZ_RTC_CTRL_1HZ_IRQ, enable); | ||
175 | } | ||
176 | |||
177 | static int jz4740_rtc_alarm_irq_enable(struct device *dev, unsigned int enable) | 171 | static int jz4740_rtc_alarm_irq_enable(struct device *dev, unsigned int enable) |
178 | { | 172 | { |
179 | struct jz4740_rtc *rtc = dev_get_drvdata(dev); | 173 | struct jz4740_rtc *rtc = dev_get_drvdata(dev); |
@@ -185,7 +179,6 @@ static struct rtc_class_ops jz4740_rtc_ops = { | |||
185 | .set_mmss = jz4740_rtc_set_mmss, | 179 | .set_mmss = jz4740_rtc_set_mmss, |
186 | .read_alarm = jz4740_rtc_read_alarm, | 180 | .read_alarm = jz4740_rtc_read_alarm, |
187 | .set_alarm = jz4740_rtc_set_alarm, | 181 | .set_alarm = jz4740_rtc_set_alarm, |
188 | .update_irq_enable = jz4740_rtc_update_irq_enable, | ||
189 | .alarm_irq_enable = jz4740_rtc_alarm_irq_enable, | 182 | .alarm_irq_enable = jz4740_rtc_alarm_irq_enable, |
190 | }; | 183 | }; |
191 | 184 | ||
diff --git a/drivers/rtc/rtc-lib.c b/drivers/rtc/rtc-lib.c index 773851f338b..075f1708dea 100644 --- a/drivers/rtc/rtc-lib.c +++ b/drivers/rtc/rtc-lib.c | |||
@@ -117,4 +117,32 @@ int rtc_tm_to_time(struct rtc_time *tm, unsigned long *time) | |||
117 | } | 117 | } |
118 | EXPORT_SYMBOL(rtc_tm_to_time); | 118 | EXPORT_SYMBOL(rtc_tm_to_time); |
119 | 119 | ||
120 | /* | ||
121 | * Convert rtc_time to ktime | ||
122 | */ | ||
123 | ktime_t rtc_tm_to_ktime(struct rtc_time tm) | ||
124 | { | ||
125 | time_t time; | ||
126 | rtc_tm_to_time(&tm, &time); | ||
127 | return ktime_set(time, 0); | ||
128 | } | ||
129 | EXPORT_SYMBOL_GPL(rtc_tm_to_ktime); | ||
130 | |||
131 | /* | ||
132 | * Convert ktime to rtc_time | ||
133 | */ | ||
134 | struct rtc_time rtc_ktime_to_tm(ktime_t kt) | ||
135 | { | ||
136 | struct timespec ts; | ||
137 | struct rtc_time ret; | ||
138 | |||
139 | ts = ktime_to_timespec(kt); | ||
140 | /* Round up any ns */ | ||
141 | if (ts.tv_nsec) | ||
142 | ts.tv_sec++; | ||
143 | rtc_time_to_tm(ts.tv_sec, &ret); | ||
144 | return ret; | ||
145 | } | ||
146 | EXPORT_SYMBOL_GPL(rtc_ktime_to_tm); | ||
147 | |||
120 | MODULE_LICENSE("GPL"); | 148 | MODULE_LICENSE("GPL"); |
diff --git a/drivers/rtc/rtc-m41t80.c b/drivers/rtc/rtc-m41t80.c index 5a8daa35806..69fe664a222 100644 --- a/drivers/rtc/rtc-m41t80.c +++ b/drivers/rtc/rtc-m41t80.c | |||
@@ -213,41 +213,27 @@ static int m41t80_rtc_set_time(struct device *dev, struct rtc_time *tm) | |||
213 | return m41t80_set_datetime(to_i2c_client(dev), tm); | 213 | return m41t80_set_datetime(to_i2c_client(dev), tm); |
214 | } | 214 | } |
215 | 215 | ||
216 | #if defined(CONFIG_RTC_INTF_DEV) || defined(CONFIG_RTC_INTF_DEV_MODULE) | 216 | static int m41t80_rtc_alarm_irq_enable(struct device *dev, unsigned int enabled) |
217 | static int | ||
218 | m41t80_rtc_ioctl(struct device *dev, unsigned int cmd, unsigned long arg) | ||
219 | { | 217 | { |
220 | struct i2c_client *client = to_i2c_client(dev); | 218 | struct i2c_client *client = to_i2c_client(dev); |
221 | int rc; | 219 | int rc; |
222 | 220 | ||
223 | switch (cmd) { | ||
224 | case RTC_AIE_OFF: | ||
225 | case RTC_AIE_ON: | ||
226 | break; | ||
227 | default: | ||
228 | return -ENOIOCTLCMD; | ||
229 | } | ||
230 | |||
231 | rc = i2c_smbus_read_byte_data(client, M41T80_REG_ALARM_MON); | 221 | rc = i2c_smbus_read_byte_data(client, M41T80_REG_ALARM_MON); |
232 | if (rc < 0) | 222 | if (rc < 0) |
233 | goto err; | 223 | goto err; |
234 | switch (cmd) { | 224 | |
235 | case RTC_AIE_OFF: | 225 | if (enabled) |
236 | rc &= ~M41T80_ALMON_AFE; | ||
237 | break; | ||
238 | case RTC_AIE_ON: | ||
239 | rc |= M41T80_ALMON_AFE; | 226 | rc |= M41T80_ALMON_AFE; |
240 | break; | 227 | else |
241 | } | 228 | rc &= ~M41T80_ALMON_AFE; |
229 | |||
242 | if (i2c_smbus_write_byte_data(client, M41T80_REG_ALARM_MON, rc) < 0) | 230 | if (i2c_smbus_write_byte_data(client, M41T80_REG_ALARM_MON, rc) < 0) |
243 | goto err; | 231 | goto err; |
232 | |||
244 | return 0; | 233 | return 0; |
245 | err: | 234 | err: |
246 | return -EIO; | 235 | return -EIO; |
247 | } | 236 | } |
248 | #else | ||
249 | #define m41t80_rtc_ioctl NULL | ||
250 | #endif | ||
251 | 237 | ||
252 | static int m41t80_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *t) | 238 | static int m41t80_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *t) |
253 | { | 239 | { |
@@ -374,7 +360,7 @@ static struct rtc_class_ops m41t80_rtc_ops = { | |||
374 | .read_alarm = m41t80_rtc_read_alarm, | 360 | .read_alarm = m41t80_rtc_read_alarm, |
375 | .set_alarm = m41t80_rtc_set_alarm, | 361 | .set_alarm = m41t80_rtc_set_alarm, |
376 | .proc = m41t80_rtc_proc, | 362 | .proc = m41t80_rtc_proc, |
377 | .ioctl = m41t80_rtc_ioctl, | 363 | .alarm_irq_enable = m41t80_rtc_alarm_irq_enable, |
378 | }; | 364 | }; |
379 | 365 | ||
380 | #if defined(CONFIG_RTC_INTF_SYSFS) || defined(CONFIG_RTC_INTF_SYSFS_MODULE) | 366 | #if defined(CONFIG_RTC_INTF_SYSFS) || defined(CONFIG_RTC_INTF_SYSFS_MODULE) |
diff --git a/drivers/rtc/rtc-m48t59.c b/drivers/rtc/rtc-m48t59.c index a99a0b554eb..3978f4caf72 100644 --- a/drivers/rtc/rtc-m48t59.c +++ b/drivers/rtc/rtc-m48t59.c | |||
@@ -263,30 +263,21 @@ static int m48t59_rtc_setalarm(struct device *dev, struct rtc_wkalrm *alrm) | |||
263 | /* | 263 | /* |
264 | * Handle commands from user-space | 264 | * Handle commands from user-space |
265 | */ | 265 | */ |
266 | static int m48t59_rtc_ioctl(struct device *dev, unsigned int cmd, | 266 | static int m48t59_rtc_alarm_irq_enable(struct device *dev, unsigned int enabled) |
267 | unsigned long arg) | ||
268 | { | 267 | { |
269 | struct platform_device *pdev = to_platform_device(dev); | 268 | struct platform_device *pdev = to_platform_device(dev); |
270 | struct m48t59_plat_data *pdata = pdev->dev.platform_data; | 269 | struct m48t59_plat_data *pdata = pdev->dev.platform_data; |
271 | struct m48t59_private *m48t59 = platform_get_drvdata(pdev); | 270 | struct m48t59_private *m48t59 = platform_get_drvdata(pdev); |
272 | unsigned long flags; | 271 | unsigned long flags; |
273 | int ret = 0; | ||
274 | 272 | ||
275 | spin_lock_irqsave(&m48t59->lock, flags); | 273 | spin_lock_irqsave(&m48t59->lock, flags); |
276 | switch (cmd) { | 274 | if (enabled) |
277 | case RTC_AIE_OFF: /* alarm interrupt off */ | ||
278 | M48T59_WRITE(0x00, M48T59_INTR); | ||
279 | break; | ||
280 | case RTC_AIE_ON: /* alarm interrupt on */ | ||
281 | M48T59_WRITE(M48T59_INTR_AFE, M48T59_INTR); | 275 | M48T59_WRITE(M48T59_INTR_AFE, M48T59_INTR); |
282 | break; | 276 | else |
283 | default: | 277 | M48T59_WRITE(0x00, M48T59_INTR); |
284 | ret = -ENOIOCTLCMD; | ||
285 | break; | ||
286 | } | ||
287 | spin_unlock_irqrestore(&m48t59->lock, flags); | 278 | spin_unlock_irqrestore(&m48t59->lock, flags); |
288 | 279 | ||
289 | return ret; | 280 | return 0; |
290 | } | 281 | } |
291 | 282 | ||
292 | static int m48t59_rtc_proc(struct device *dev, struct seq_file *seq) | 283 | static int m48t59_rtc_proc(struct device *dev, struct seq_file *seq) |
@@ -330,12 +321,12 @@ static irqreturn_t m48t59_rtc_interrupt(int irq, void *dev_id) | |||
330 | } | 321 | } |
331 | 322 | ||
332 | static const struct rtc_class_ops m48t59_rtc_ops = { | 323 | static const struct rtc_class_ops m48t59_rtc_ops = { |
333 | .ioctl = m48t59_rtc_ioctl, | ||
334 | .read_time = m48t59_rtc_read_time, | 324 | .read_time = m48t59_rtc_read_time, |
335 | .set_time = m48t59_rtc_set_time, | 325 | .set_time = m48t59_rtc_set_time, |
336 | .read_alarm = m48t59_rtc_readalarm, | 326 | .read_alarm = m48t59_rtc_readalarm, |
337 | .set_alarm = m48t59_rtc_setalarm, | 327 | .set_alarm = m48t59_rtc_setalarm, |
338 | .proc = m48t59_rtc_proc, | 328 | .proc = m48t59_rtc_proc, |
329 | .alarm_irq_enable = m48t59_rtc_alarm_irq_enable, | ||
339 | }; | 330 | }; |
340 | 331 | ||
341 | static const struct rtc_class_ops m48t02_rtc_ops = { | 332 | static const struct rtc_class_ops m48t02_rtc_ops = { |
diff --git a/drivers/rtc/rtc-max6902.c b/drivers/rtc/rtc-max6902.c index 657403ebd54..0ec3f588a25 100644 --- a/drivers/rtc/rtc-max6902.c +++ b/drivers/rtc/rtc-max6902.c | |||
@@ -139,12 +139,13 @@ static int __devinit max6902_probe(struct spi_device *spi) | |||
139 | if (IS_ERR(rtc)) | 139 | if (IS_ERR(rtc)) |
140 | return PTR_ERR(rtc); | 140 | return PTR_ERR(rtc); |
141 | 141 | ||
142 | dev_set_drvdata(&spi->dev, rtc); | ||
142 | return 0; | 143 | return 0; |
143 | } | 144 | } |
144 | 145 | ||
145 | static int __devexit max6902_remove(struct spi_device *spi) | 146 | static int __devexit max6902_remove(struct spi_device *spi) |
146 | { | 147 | { |
147 | struct rtc_device *rtc = platform_get_drvdata(spi); | 148 | struct rtc_device *rtc = dev_get_drvdata(&spi->dev); |
148 | 149 | ||
149 | rtc_device_unregister(rtc); | 150 | rtc_device_unregister(rtc); |
150 | return 0; | 151 | return 0; |
diff --git a/drivers/rtc/rtc-max8998.c b/drivers/rtc/rtc-max8998.c index f22dee35f33..3f7bc6b9fef 100644 --- a/drivers/rtc/rtc-max8998.c +++ b/drivers/rtc/rtc-max8998.c | |||
@@ -20,6 +20,7 @@ | |||
20 | #include <linux/platform_device.h> | 20 | #include <linux/platform_device.h> |
21 | #include <linux/mfd/max8998.h> | 21 | #include <linux/mfd/max8998.h> |
22 | #include <linux/mfd/max8998-private.h> | 22 | #include <linux/mfd/max8998-private.h> |
23 | #include <linux/delay.h> | ||
23 | 24 | ||
24 | #define MAX8998_RTC_SEC 0x00 | 25 | #define MAX8998_RTC_SEC 0x00 |
25 | #define MAX8998_RTC_MIN 0x01 | 26 | #define MAX8998_RTC_MIN 0x01 |
@@ -73,6 +74,7 @@ struct max8998_rtc_info { | |||
73 | struct i2c_client *rtc; | 74 | struct i2c_client *rtc; |
74 | struct rtc_device *rtc_dev; | 75 | struct rtc_device *rtc_dev; |
75 | int irq; | 76 | int irq; |
77 | bool lp3974_bug_workaround; | ||
76 | }; | 78 | }; |
77 | 79 | ||
78 | static void max8998_data_to_tm(u8 *data, struct rtc_time *tm) | 80 | static void max8998_data_to_tm(u8 *data, struct rtc_time *tm) |
@@ -124,10 +126,16 @@ static int max8998_rtc_set_time(struct device *dev, struct rtc_time *tm) | |||
124 | { | 126 | { |
125 | struct max8998_rtc_info *info = dev_get_drvdata(dev); | 127 | struct max8998_rtc_info *info = dev_get_drvdata(dev); |
126 | u8 data[8]; | 128 | u8 data[8]; |
129 | int ret; | ||
127 | 130 | ||
128 | max8998_tm_to_data(tm, data); | 131 | max8998_tm_to_data(tm, data); |
129 | 132 | ||
130 | return max8998_bulk_write(info->rtc, MAX8998_RTC_SEC, 8, data); | 133 | ret = max8998_bulk_write(info->rtc, MAX8998_RTC_SEC, 8, data); |
134 | |||
135 | if (info->lp3974_bug_workaround) | ||
136 | msleep(2000); | ||
137 | |||
138 | return ret; | ||
131 | } | 139 | } |
132 | 140 | ||
133 | static int max8998_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm) | 141 | static int max8998_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm) |
@@ -163,12 +171,29 @@ static int max8998_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm) | |||
163 | 171 | ||
164 | static int max8998_rtc_stop_alarm(struct max8998_rtc_info *info) | 172 | static int max8998_rtc_stop_alarm(struct max8998_rtc_info *info) |
165 | { | 173 | { |
166 | return max8998_write_reg(info->rtc, MAX8998_ALARM0_CONF, 0); | 174 | int ret = max8998_write_reg(info->rtc, MAX8998_ALARM0_CONF, 0); |
175 | |||
176 | if (info->lp3974_bug_workaround) | ||
177 | msleep(2000); | ||
178 | |||
179 | return ret; | ||
167 | } | 180 | } |
168 | 181 | ||
169 | static int max8998_rtc_start_alarm(struct max8998_rtc_info *info) | 182 | static int max8998_rtc_start_alarm(struct max8998_rtc_info *info) |
170 | { | 183 | { |
171 | return max8998_write_reg(info->rtc, MAX8998_ALARM0_CONF, 0x77); | 184 | int ret; |
185 | u8 alarm0_conf = 0x77; | ||
186 | |||
187 | /* LP3974 with delay bug chips has rtc alarm bugs with "MONTH" field */ | ||
188 | if (info->lp3974_bug_workaround) | ||
189 | alarm0_conf = 0x57; | ||
190 | |||
191 | ret = max8998_write_reg(info->rtc, MAX8998_ALARM0_CONF, alarm0_conf); | ||
192 | |||
193 | if (info->lp3974_bug_workaround) | ||
194 | msleep(2000); | ||
195 | |||
196 | return ret; | ||
172 | } | 197 | } |
173 | 198 | ||
174 | static int max8998_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm) | 199 | static int max8998_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm) |
@@ -187,10 +212,13 @@ static int max8998_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm) | |||
187 | if (ret < 0) | 212 | if (ret < 0) |
188 | return ret; | 213 | return ret; |
189 | 214 | ||
215 | if (info->lp3974_bug_workaround) | ||
216 | msleep(2000); | ||
217 | |||
190 | if (alrm->enabled) | 218 | if (alrm->enabled) |
191 | return max8998_rtc_start_alarm(info); | 219 | ret = max8998_rtc_start_alarm(info); |
192 | 220 | ||
193 | return 0; | 221 | return ret; |
194 | } | 222 | } |
195 | 223 | ||
196 | static int max8998_rtc_alarm_irq_enable(struct device *dev, | 224 | static int max8998_rtc_alarm_irq_enable(struct device *dev, |
@@ -224,6 +252,7 @@ static const struct rtc_class_ops max8998_rtc_ops = { | |||
224 | static int __devinit max8998_rtc_probe(struct platform_device *pdev) | 252 | static int __devinit max8998_rtc_probe(struct platform_device *pdev) |
225 | { | 253 | { |
226 | struct max8998_dev *max8998 = dev_get_drvdata(pdev->dev.parent); | 254 | struct max8998_dev *max8998 = dev_get_drvdata(pdev->dev.parent); |
255 | struct max8998_platform_data *pdata = dev_get_platdata(max8998->dev); | ||
227 | struct max8998_rtc_info *info; | 256 | struct max8998_rtc_info *info; |
228 | int ret; | 257 | int ret; |
229 | 258 | ||
@@ -249,10 +278,18 @@ static int __devinit max8998_rtc_probe(struct platform_device *pdev) | |||
249 | 278 | ||
250 | ret = request_threaded_irq(info->irq, NULL, max8998_rtc_alarm_irq, 0, | 279 | ret = request_threaded_irq(info->irq, NULL, max8998_rtc_alarm_irq, 0, |
251 | "rtc-alarm0", info); | 280 | "rtc-alarm0", info); |
281 | |||
252 | if (ret < 0) | 282 | if (ret < 0) |
253 | dev_err(&pdev->dev, "Failed to request alarm IRQ: %d: %d\n", | 283 | dev_err(&pdev->dev, "Failed to request alarm IRQ: %d: %d\n", |
254 | info->irq, ret); | 284 | info->irq, ret); |
255 | 285 | ||
286 | dev_info(&pdev->dev, "RTC CHIP NAME: %s\n", pdev->id_entry->name); | ||
287 | if (pdata->rtc_delay) { | ||
288 | info->lp3974_bug_workaround = true; | ||
289 | dev_warn(&pdev->dev, "LP3974 with RTC REGERR option." | ||
290 | " RTC updates will be extremely slow.\n"); | ||
291 | } | ||
292 | |||
256 | return 0; | 293 | return 0; |
257 | 294 | ||
258 | out_rtc: | 295 | out_rtc: |
@@ -273,6 +310,12 @@ static int __devexit max8998_rtc_remove(struct platform_device *pdev) | |||
273 | return 0; | 310 | return 0; |
274 | } | 311 | } |
275 | 312 | ||
313 | static const struct platform_device_id max8998_rtc_id[] = { | ||
314 | { "max8998-rtc", TYPE_MAX8998 }, | ||
315 | { "lp3974-rtc", TYPE_LP3974 }, | ||
316 | { } | ||
317 | }; | ||
318 | |||
276 | static struct platform_driver max8998_rtc_driver = { | 319 | static struct platform_driver max8998_rtc_driver = { |
277 | .driver = { | 320 | .driver = { |
278 | .name = "max8998-rtc", | 321 | .name = "max8998-rtc", |
@@ -280,6 +323,7 @@ static struct platform_driver max8998_rtc_driver = { | |||
280 | }, | 323 | }, |
281 | .probe = max8998_rtc_probe, | 324 | .probe = max8998_rtc_probe, |
282 | .remove = __devexit_p(max8998_rtc_remove), | 325 | .remove = __devexit_p(max8998_rtc_remove), |
326 | .id_table = max8998_rtc_id, | ||
283 | }; | 327 | }; |
284 | 328 | ||
285 | static int __init max8998_rtc_init(void) | 329 | static int __init max8998_rtc_init(void) |
diff --git a/drivers/rtc/rtc-mc13xxx.c b/drivers/rtc/rtc-mc13xxx.c index 5314b153bfb..c4200646955 100644 --- a/drivers/rtc/rtc-mc13xxx.c +++ b/drivers/rtc/rtc-mc13xxx.c | |||
@@ -282,12 +282,6 @@ static irqreturn_t mc13xxx_rtc_update_handler(int irq, void *dev) | |||
282 | return IRQ_HANDLED; | 282 | return IRQ_HANDLED; |
283 | } | 283 | } |
284 | 284 | ||
285 | static int mc13xxx_rtc_update_irq_enable(struct device *dev, | ||
286 | unsigned int enabled) | ||
287 | { | ||
288 | return mc13xxx_rtc_irq_enable(dev, enabled, MC13XXX_IRQ_1HZ); | ||
289 | } | ||
290 | |||
291 | static int mc13xxx_rtc_alarm_irq_enable(struct device *dev, | 285 | static int mc13xxx_rtc_alarm_irq_enable(struct device *dev, |
292 | unsigned int enabled) | 286 | unsigned int enabled) |
293 | { | 287 | { |
@@ -300,7 +294,6 @@ static const struct rtc_class_ops mc13xxx_rtc_ops = { | |||
300 | .read_alarm = mc13xxx_rtc_read_alarm, | 294 | .read_alarm = mc13xxx_rtc_read_alarm, |
301 | .set_alarm = mc13xxx_rtc_set_alarm, | 295 | .set_alarm = mc13xxx_rtc_set_alarm, |
302 | .alarm_irq_enable = mc13xxx_rtc_alarm_irq_enable, | 296 | .alarm_irq_enable = mc13xxx_rtc_alarm_irq_enable, |
303 | .update_irq_enable = mc13xxx_rtc_update_irq_enable, | ||
304 | }; | 297 | }; |
305 | 298 | ||
306 | static irqreturn_t mc13xxx_rtc_reset_handler(int irq, void *dev) | 299 | static irqreturn_t mc13xxx_rtc_reset_handler(int irq, void *dev) |
diff --git a/drivers/rtc/rtc-mpc5121.c b/drivers/rtc/rtc-mpc5121.c index dfcdf0901d2..b40c1ff1ebc 100644 --- a/drivers/rtc/rtc-mpc5121.c +++ b/drivers/rtc/rtc-mpc5121.c | |||
@@ -240,32 +240,12 @@ static int mpc5121_rtc_alarm_irq_enable(struct device *dev, | |||
240 | return 0; | 240 | return 0; |
241 | } | 241 | } |
242 | 242 | ||
243 | static int mpc5121_rtc_update_irq_enable(struct device *dev, | ||
244 | unsigned int enabled) | ||
245 | { | ||
246 | struct mpc5121_rtc_data *rtc = dev_get_drvdata(dev); | ||
247 | struct mpc5121_rtc_regs __iomem *regs = rtc->regs; | ||
248 | int val; | ||
249 | |||
250 | val = in_8(®s->int_enable); | ||
251 | |||
252 | if (enabled) | ||
253 | val = (val & ~0x8) | 0x1; | ||
254 | else | ||
255 | val &= ~0x1; | ||
256 | |||
257 | out_8(®s->int_enable, val); | ||
258 | |||
259 | return 0; | ||
260 | } | ||
261 | |||
262 | static const struct rtc_class_ops mpc5121_rtc_ops = { | 243 | static const struct rtc_class_ops mpc5121_rtc_ops = { |
263 | .read_time = mpc5121_rtc_read_time, | 244 | .read_time = mpc5121_rtc_read_time, |
264 | .set_time = mpc5121_rtc_set_time, | 245 | .set_time = mpc5121_rtc_set_time, |
265 | .read_alarm = mpc5121_rtc_read_alarm, | 246 | .read_alarm = mpc5121_rtc_read_alarm, |
266 | .set_alarm = mpc5121_rtc_set_alarm, | 247 | .set_alarm = mpc5121_rtc_set_alarm, |
267 | .alarm_irq_enable = mpc5121_rtc_alarm_irq_enable, | 248 | .alarm_irq_enable = mpc5121_rtc_alarm_irq_enable, |
268 | .update_irq_enable = mpc5121_rtc_update_irq_enable, | ||
269 | }; | 249 | }; |
270 | 250 | ||
271 | static int __devinit mpc5121_rtc_probe(struct platform_device *op, | 251 | static int __devinit mpc5121_rtc_probe(struct platform_device *op, |
diff --git a/drivers/rtc/rtc-mrst.c b/drivers/rtc/rtc-mrst.c index bcd0cf63eb1..b86bc328463 100644 --- a/drivers/rtc/rtc-mrst.c +++ b/drivers/rtc/rtc-mrst.c | |||
@@ -62,6 +62,17 @@ static inline int is_intr(u8 rtc_intr) | |||
62 | return rtc_intr & RTC_IRQMASK; | 62 | return rtc_intr & RTC_IRQMASK; |
63 | } | 63 | } |
64 | 64 | ||
65 | static inline unsigned char vrtc_is_updating(void) | ||
66 | { | ||
67 | unsigned char uip; | ||
68 | unsigned long flags; | ||
69 | |||
70 | spin_lock_irqsave(&rtc_lock, flags); | ||
71 | uip = (vrtc_cmos_read(RTC_FREQ_SELECT) & RTC_UIP); | ||
72 | spin_unlock_irqrestore(&rtc_lock, flags); | ||
73 | return uip; | ||
74 | } | ||
75 | |||
65 | /* | 76 | /* |
66 | * rtc_time's year contains the increment over 1900, but vRTC's YEAR | 77 | * rtc_time's year contains the increment over 1900, but vRTC's YEAR |
67 | * register can't be programmed to value larger than 0x64, so vRTC | 78 | * register can't be programmed to value larger than 0x64, so vRTC |
@@ -76,7 +87,7 @@ static int mrst_read_time(struct device *dev, struct rtc_time *time) | |||
76 | { | 87 | { |
77 | unsigned long flags; | 88 | unsigned long flags; |
78 | 89 | ||
79 | if (rtc_is_updating()) | 90 | if (vrtc_is_updating()) |
80 | mdelay(20); | 91 | mdelay(20); |
81 | 92 | ||
82 | spin_lock_irqsave(&rtc_lock, flags); | 93 | spin_lock_irqsave(&rtc_lock, flags); |
@@ -236,61 +247,21 @@ static int mrst_set_alarm(struct device *dev, struct rtc_wkalrm *t) | |||
236 | return 0; | 247 | return 0; |
237 | } | 248 | } |
238 | 249 | ||
239 | static int mrst_irq_set_state(struct device *dev, int enabled) | 250 | /* Currently, the vRTC doesn't support UIE ON/OFF */ |
251 | static int mrst_rtc_alarm_irq_enable(struct device *dev, unsigned int enabled) | ||
240 | { | 252 | { |
241 | struct mrst_rtc *mrst = dev_get_drvdata(dev); | 253 | struct mrst_rtc *mrst = dev_get_drvdata(dev); |
242 | unsigned long flags; | 254 | unsigned long flags; |
243 | 255 | ||
244 | if (!mrst->irq) | ||
245 | return -ENXIO; | ||
246 | |||
247 | spin_lock_irqsave(&rtc_lock, flags); | 256 | spin_lock_irqsave(&rtc_lock, flags); |
248 | |||
249 | if (enabled) | 257 | if (enabled) |
250 | mrst_irq_enable(mrst, RTC_PIE); | 258 | mrst_irq_enable(mrst, RTC_AIE); |
251 | else | 259 | else |
252 | mrst_irq_disable(mrst, RTC_PIE); | ||
253 | |||
254 | spin_unlock_irqrestore(&rtc_lock, flags); | ||
255 | return 0; | ||
256 | } | ||
257 | |||
258 | #if defined(CONFIG_RTC_INTF_DEV) || defined(CONFIG_RTC_INTF_DEV_MODULE) | ||
259 | |||
260 | /* Currently, the vRTC doesn't support UIE ON/OFF */ | ||
261 | static int | ||
262 | mrst_rtc_ioctl(struct device *dev, unsigned int cmd, unsigned long arg) | ||
263 | { | ||
264 | struct mrst_rtc *mrst = dev_get_drvdata(dev); | ||
265 | unsigned long flags; | ||
266 | |||
267 | switch (cmd) { | ||
268 | case RTC_AIE_OFF: | ||
269 | case RTC_AIE_ON: | ||
270 | if (!mrst->irq) | ||
271 | return -EINVAL; | ||
272 | break; | ||
273 | default: | ||
274 | /* PIE ON/OFF is handled by mrst_irq_set_state() */ | ||
275 | return -ENOIOCTLCMD; | ||
276 | } | ||
277 | |||
278 | spin_lock_irqsave(&rtc_lock, flags); | ||
279 | switch (cmd) { | ||
280 | case RTC_AIE_OFF: /* alarm off */ | ||
281 | mrst_irq_disable(mrst, RTC_AIE); | 260 | mrst_irq_disable(mrst, RTC_AIE); |
282 | break; | ||
283 | case RTC_AIE_ON: /* alarm on */ | ||
284 | mrst_irq_enable(mrst, RTC_AIE); | ||
285 | break; | ||
286 | } | ||
287 | spin_unlock_irqrestore(&rtc_lock, flags); | 261 | spin_unlock_irqrestore(&rtc_lock, flags); |
288 | return 0; | 262 | return 0; |
289 | } | 263 | } |
290 | 264 | ||
291 | #else | ||
292 | #define mrst_rtc_ioctl NULL | ||
293 | #endif | ||
294 | 265 | ||
295 | #if defined(CONFIG_RTC_INTF_PROC) || defined(CONFIG_RTC_INTF_PROC_MODULE) | 266 | #if defined(CONFIG_RTC_INTF_PROC) || defined(CONFIG_RTC_INTF_PROC_MODULE) |
296 | 267 | ||
@@ -317,13 +288,12 @@ static int mrst_procfs(struct device *dev, struct seq_file *seq) | |||
317 | #endif | 288 | #endif |
318 | 289 | ||
319 | static const struct rtc_class_ops mrst_rtc_ops = { | 290 | static const struct rtc_class_ops mrst_rtc_ops = { |
320 | .ioctl = mrst_rtc_ioctl, | ||
321 | .read_time = mrst_read_time, | 291 | .read_time = mrst_read_time, |
322 | .set_time = mrst_set_time, | 292 | .set_time = mrst_set_time, |
323 | .read_alarm = mrst_read_alarm, | 293 | .read_alarm = mrst_read_alarm, |
324 | .set_alarm = mrst_set_alarm, | 294 | .set_alarm = mrst_set_alarm, |
325 | .proc = mrst_procfs, | 295 | .proc = mrst_procfs, |
326 | .irq_set_state = mrst_irq_set_state, | 296 | .alarm_irq_enable = mrst_rtc_alarm_irq_enable, |
327 | }; | 297 | }; |
328 | 298 | ||
329 | static struct mrst_rtc mrst_rtc; | 299 | static struct mrst_rtc mrst_rtc; |
diff --git a/drivers/rtc/rtc-msm6242.c b/drivers/rtc/rtc-msm6242.c index b2fff0ca49f..67820626e18 100644 --- a/drivers/rtc/rtc-msm6242.c +++ b/drivers/rtc/rtc-msm6242.c | |||
@@ -82,7 +82,7 @@ static inline unsigned int msm6242_read(struct msm6242_priv *priv, | |||
82 | static inline void msm6242_write(struct msm6242_priv *priv, unsigned int val, | 82 | static inline void msm6242_write(struct msm6242_priv *priv, unsigned int val, |
83 | unsigned int reg) | 83 | unsigned int reg) |
84 | { | 84 | { |
85 | return __raw_writel(val, &priv->regs[reg]); | 85 | __raw_writel(val, &priv->regs[reg]); |
86 | } | 86 | } |
87 | 87 | ||
88 | static inline void msm6242_set(struct msm6242_priv *priv, unsigned int val, | 88 | static inline void msm6242_set(struct msm6242_priv *priv, unsigned int val, |
diff --git a/drivers/rtc/rtc-mv.c b/drivers/rtc/rtc-mv.c index bcca4729855..60627a76451 100644 --- a/drivers/rtc/rtc-mv.c +++ b/drivers/rtc/rtc-mv.c | |||
@@ -169,25 +169,19 @@ static int mv_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alm) | |||
169 | return 0; | 169 | return 0; |
170 | } | 170 | } |
171 | 171 | ||
172 | static int mv_rtc_ioctl(struct device *dev, unsigned int cmd, | 172 | static int mv_rtc_alarm_irq_enable(struct device *dev, unsigned int enabled) |
173 | unsigned long arg) | ||
174 | { | 173 | { |
175 | struct platform_device *pdev = to_platform_device(dev); | 174 | struct platform_device *pdev = to_platform_device(dev); |
176 | struct rtc_plat_data *pdata = platform_get_drvdata(pdev); | 175 | struct rtc_plat_data *pdata = platform_get_drvdata(pdev); |
177 | void __iomem *ioaddr = pdata->ioaddr; | 176 | void __iomem *ioaddr = pdata->ioaddr; |
178 | 177 | ||
179 | if (pdata->irq < 0) | 178 | if (pdata->irq < 0) |
180 | return -ENOIOCTLCMD; /* fall back into rtc-dev's emulation */ | 179 | return -EINVAL; /* fall back into rtc-dev's emulation */ |
181 | switch (cmd) { | 180 | |
182 | case RTC_AIE_OFF: | 181 | if (enabled) |
183 | writel(0, ioaddr + RTC_ALARM_INTERRUPT_MASK_REG_OFFS); | ||
184 | break; | ||
185 | case RTC_AIE_ON: | ||
186 | writel(1, ioaddr + RTC_ALARM_INTERRUPT_MASK_REG_OFFS); | 182 | writel(1, ioaddr + RTC_ALARM_INTERRUPT_MASK_REG_OFFS); |
187 | break; | 183 | else |
188 | default: | 184 | writel(0, ioaddr + RTC_ALARM_INTERRUPT_MASK_REG_OFFS); |
189 | return -ENOIOCTLCMD; | ||
190 | } | ||
191 | return 0; | 185 | return 0; |
192 | } | 186 | } |
193 | 187 | ||
@@ -216,7 +210,7 @@ static const struct rtc_class_ops mv_rtc_alarm_ops = { | |||
216 | .set_time = mv_rtc_set_time, | 210 | .set_time = mv_rtc_set_time, |
217 | .read_alarm = mv_rtc_read_alarm, | 211 | .read_alarm = mv_rtc_read_alarm, |
218 | .set_alarm = mv_rtc_set_alarm, | 212 | .set_alarm = mv_rtc_set_alarm, |
219 | .ioctl = mv_rtc_ioctl, | 213 | .alarm_irq_enable = mv_rtc_alarm_irq_enable, |
220 | }; | 214 | }; |
221 | 215 | ||
222 | static int __devinit mv_rtc_probe(struct platform_device *pdev) | 216 | static int __devinit mv_rtc_probe(struct platform_device *pdev) |
diff --git a/drivers/rtc/rtc-mxc.c b/drivers/rtc/rtc-mxc.c index 0b06c1e03fd..826ab64a8fa 100644 --- a/drivers/rtc/rtc-mxc.c +++ b/drivers/rtc/rtc-mxc.c | |||
@@ -274,12 +274,6 @@ static int mxc_rtc_alarm_irq_enable(struct device *dev, unsigned int enabled) | |||
274 | return 0; | 274 | return 0; |
275 | } | 275 | } |
276 | 276 | ||
277 | static int mxc_rtc_update_irq_enable(struct device *dev, unsigned int enabled) | ||
278 | { | ||
279 | mxc_rtc_irq_enable(dev, RTC_1HZ_BIT, enabled); | ||
280 | return 0; | ||
281 | } | ||
282 | |||
283 | /* | 277 | /* |
284 | * This function reads the current RTC time into tm in Gregorian date. | 278 | * This function reads the current RTC time into tm in Gregorian date. |
285 | */ | 279 | */ |
@@ -368,7 +362,6 @@ static struct rtc_class_ops mxc_rtc_ops = { | |||
368 | .read_alarm = mxc_rtc_read_alarm, | 362 | .read_alarm = mxc_rtc_read_alarm, |
369 | .set_alarm = mxc_rtc_set_alarm, | 363 | .set_alarm = mxc_rtc_set_alarm, |
370 | .alarm_irq_enable = mxc_rtc_alarm_irq_enable, | 364 | .alarm_irq_enable = mxc_rtc_alarm_irq_enable, |
371 | .update_irq_enable = mxc_rtc_update_irq_enable, | ||
372 | }; | 365 | }; |
373 | 366 | ||
374 | static int __init mxc_rtc_probe(struct platform_device *pdev) | 367 | static int __init mxc_rtc_probe(struct platform_device *pdev) |
diff --git a/drivers/rtc/rtc-nuc900.c b/drivers/rtc/rtc-nuc900.c index ddb0857e15a..781068d62f2 100644 --- a/drivers/rtc/rtc-nuc900.c +++ b/drivers/rtc/rtc-nuc900.c | |||
@@ -134,20 +134,6 @@ static void nuc900_rtc_bin2bcd(struct device *dev, struct rtc_time *settm, | |||
134 | gettm->bcd_hour = bin2bcd(settm->tm_hour) << 16; | 134 | gettm->bcd_hour = bin2bcd(settm->tm_hour) << 16; |
135 | } | 135 | } |
136 | 136 | ||
137 | static int nuc900_update_irq_enable(struct device *dev, unsigned int enabled) | ||
138 | { | ||
139 | struct nuc900_rtc *rtc = dev_get_drvdata(dev); | ||
140 | |||
141 | if (enabled) | ||
142 | __raw_writel(__raw_readl(rtc->rtc_reg + REG_RTC_RIER)| | ||
143 | (TICKINTENB), rtc->rtc_reg + REG_RTC_RIER); | ||
144 | else | ||
145 | __raw_writel(__raw_readl(rtc->rtc_reg + REG_RTC_RIER)& | ||
146 | (~TICKINTENB), rtc->rtc_reg + REG_RTC_RIER); | ||
147 | |||
148 | return 0; | ||
149 | } | ||
150 | |||
151 | static int nuc900_alarm_irq_enable(struct device *dev, unsigned int enabled) | 137 | static int nuc900_alarm_irq_enable(struct device *dev, unsigned int enabled) |
152 | { | 138 | { |
153 | struct nuc900_rtc *rtc = dev_get_drvdata(dev); | 139 | struct nuc900_rtc *rtc = dev_get_drvdata(dev); |
@@ -234,7 +220,6 @@ static struct rtc_class_ops nuc900_rtc_ops = { | |||
234 | .read_alarm = nuc900_rtc_read_alarm, | 220 | .read_alarm = nuc900_rtc_read_alarm, |
235 | .set_alarm = nuc900_rtc_set_alarm, | 221 | .set_alarm = nuc900_rtc_set_alarm, |
236 | .alarm_irq_enable = nuc900_alarm_irq_enable, | 222 | .alarm_irq_enable = nuc900_alarm_irq_enable, |
237 | .update_irq_enable = nuc900_update_irq_enable, | ||
238 | }; | 223 | }; |
239 | 224 | ||
240 | static int __devinit nuc900_rtc_probe(struct platform_device *pdev) | 225 | static int __devinit nuc900_rtc_probe(struct platform_device *pdev) |
diff --git a/drivers/rtc/rtc-omap.c b/drivers/rtc/rtc-omap.c index 73377b0d65d..de0dd7b1f14 100644 --- a/drivers/rtc/rtc-omap.c +++ b/drivers/rtc/rtc-omap.c | |||
@@ -135,42 +135,17 @@ static irqreturn_t rtc_irq(int irq, void *rtc) | |||
135 | return IRQ_HANDLED; | 135 | return IRQ_HANDLED; |
136 | } | 136 | } |
137 | 137 | ||
138 | #ifdef CONFIG_RTC_INTF_DEV | 138 | static int omap_rtc_alarm_irq_enable(struct device *dev, unsigned int enabled) |
139 | |||
140 | static int | ||
141 | omap_rtc_ioctl(struct device *dev, unsigned int cmd, unsigned long arg) | ||
142 | { | 139 | { |
143 | u8 reg; | 140 | u8 reg; |
144 | 141 | ||
145 | switch (cmd) { | ||
146 | case RTC_AIE_OFF: | ||
147 | case RTC_AIE_ON: | ||
148 | case RTC_UIE_OFF: | ||
149 | case RTC_UIE_ON: | ||
150 | break; | ||
151 | default: | ||
152 | return -ENOIOCTLCMD; | ||
153 | } | ||
154 | |||
155 | local_irq_disable(); | 142 | local_irq_disable(); |
156 | rtc_wait_not_busy(); | 143 | rtc_wait_not_busy(); |
157 | reg = rtc_read(OMAP_RTC_INTERRUPTS_REG); | 144 | reg = rtc_read(OMAP_RTC_INTERRUPTS_REG); |
158 | switch (cmd) { | 145 | if (enabled) |
159 | /* AIE = Alarm Interrupt Enable */ | ||
160 | case RTC_AIE_OFF: | ||
161 | reg &= ~OMAP_RTC_INTERRUPTS_IT_ALARM; | ||
162 | break; | ||
163 | case RTC_AIE_ON: | ||
164 | reg |= OMAP_RTC_INTERRUPTS_IT_ALARM; | 146 | reg |= OMAP_RTC_INTERRUPTS_IT_ALARM; |
165 | break; | 147 | else |
166 | /* UIE = Update Interrupt Enable (1/second) */ | 148 | reg &= ~OMAP_RTC_INTERRUPTS_IT_ALARM; |
167 | case RTC_UIE_OFF: | ||
168 | reg &= ~OMAP_RTC_INTERRUPTS_IT_TIMER; | ||
169 | break; | ||
170 | case RTC_UIE_ON: | ||
171 | reg |= OMAP_RTC_INTERRUPTS_IT_TIMER; | ||
172 | break; | ||
173 | } | ||
174 | rtc_wait_not_busy(); | 149 | rtc_wait_not_busy(); |
175 | rtc_write(reg, OMAP_RTC_INTERRUPTS_REG); | 150 | rtc_write(reg, OMAP_RTC_INTERRUPTS_REG); |
176 | local_irq_enable(); | 151 | local_irq_enable(); |
@@ -178,10 +153,6 @@ omap_rtc_ioctl(struct device *dev, unsigned int cmd, unsigned long arg) | |||
178 | return 0; | 153 | return 0; |
179 | } | 154 | } |
180 | 155 | ||
181 | #else | ||
182 | #define omap_rtc_ioctl NULL | ||
183 | #endif | ||
184 | |||
185 | /* this hardware doesn't support "don't care" alarm fields */ | 156 | /* this hardware doesn't support "don't care" alarm fields */ |
186 | static int tm2bcd(struct rtc_time *tm) | 157 | static int tm2bcd(struct rtc_time *tm) |
187 | { | 158 | { |
@@ -304,11 +275,11 @@ static int omap_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alm) | |||
304 | } | 275 | } |
305 | 276 | ||
306 | static struct rtc_class_ops omap_rtc_ops = { | 277 | static struct rtc_class_ops omap_rtc_ops = { |
307 | .ioctl = omap_rtc_ioctl, | ||
308 | .read_time = omap_rtc_read_time, | 278 | .read_time = omap_rtc_read_time, |
309 | .set_time = omap_rtc_set_time, | 279 | .set_time = omap_rtc_set_time, |
310 | .read_alarm = omap_rtc_read_alarm, | 280 | .read_alarm = omap_rtc_read_alarm, |
311 | .set_alarm = omap_rtc_set_alarm, | 281 | .set_alarm = omap_rtc_set_alarm, |
282 | .alarm_irq_enable = omap_rtc_alarm_irq_enable, | ||
312 | }; | 283 | }; |
313 | 284 | ||
314 | static int omap_rtc_alarm; | 285 | static int omap_rtc_alarm; |
@@ -429,13 +400,14 @@ fail1: | |||
429 | fail0: | 400 | fail0: |
430 | iounmap(rtc_base); | 401 | iounmap(rtc_base); |
431 | fail: | 402 | fail: |
432 | release_resource(mem); | 403 | release_mem_region(mem->start, resource_size(mem)); |
433 | return -EIO; | 404 | return -EIO; |
434 | } | 405 | } |
435 | 406 | ||
436 | static int __exit omap_rtc_remove(struct platform_device *pdev) | 407 | static int __exit omap_rtc_remove(struct platform_device *pdev) |
437 | { | 408 | { |
438 | struct rtc_device *rtc = platform_get_drvdata(pdev); | 409 | struct rtc_device *rtc = platform_get_drvdata(pdev); |
410 | struct resource *mem = dev_get_drvdata(&rtc->dev); | ||
439 | 411 | ||
440 | device_init_wakeup(&pdev->dev, 0); | 412 | device_init_wakeup(&pdev->dev, 0); |
441 | 413 | ||
@@ -447,8 +419,9 @@ static int __exit omap_rtc_remove(struct platform_device *pdev) | |||
447 | if (omap_rtc_timer != omap_rtc_alarm) | 419 | if (omap_rtc_timer != omap_rtc_alarm) |
448 | free_irq(omap_rtc_alarm, rtc); | 420 | free_irq(omap_rtc_alarm, rtc); |
449 | 421 | ||
450 | release_resource(dev_get_drvdata(&rtc->dev)); | ||
451 | rtc_device_unregister(rtc); | 422 | rtc_device_unregister(rtc); |
423 | iounmap(rtc_base); | ||
424 | release_mem_region(mem->start, resource_size(mem)); | ||
452 | return 0; | 425 | return 0; |
453 | } | 426 | } |
454 | 427 | ||
diff --git a/drivers/rtc/rtc-pcap.c b/drivers/rtc/rtc-pcap.c index 25c0b3fd44f..a633abc4289 100644 --- a/drivers/rtc/rtc-pcap.c +++ b/drivers/rtc/rtc-pcap.c | |||
@@ -131,18 +131,12 @@ static int pcap_rtc_alarm_irq_enable(struct device *dev, unsigned int en) | |||
131 | return pcap_rtc_irq_enable(dev, PCAP_IRQ_TODA, en); | 131 | return pcap_rtc_irq_enable(dev, PCAP_IRQ_TODA, en); |
132 | } | 132 | } |
133 | 133 | ||
134 | static int pcap_rtc_update_irq_enable(struct device *dev, unsigned int en) | ||
135 | { | ||
136 | return pcap_rtc_irq_enable(dev, PCAP_IRQ_1HZ, en); | ||
137 | } | ||
138 | |||
139 | static const struct rtc_class_ops pcap_rtc_ops = { | 134 | static const struct rtc_class_ops pcap_rtc_ops = { |
140 | .read_time = pcap_rtc_read_time, | 135 | .read_time = pcap_rtc_read_time, |
141 | .read_alarm = pcap_rtc_read_alarm, | 136 | .read_alarm = pcap_rtc_read_alarm, |
142 | .set_alarm = pcap_rtc_set_alarm, | 137 | .set_alarm = pcap_rtc_set_alarm, |
143 | .set_mmss = pcap_rtc_set_mmss, | 138 | .set_mmss = pcap_rtc_set_mmss, |
144 | .alarm_irq_enable = pcap_rtc_alarm_irq_enable, | 139 | .alarm_irq_enable = pcap_rtc_alarm_irq_enable, |
145 | .update_irq_enable = pcap_rtc_update_irq_enable, | ||
146 | }; | 140 | }; |
147 | 141 | ||
148 | static int __devinit pcap_rtc_probe(struct platform_device *pdev) | 142 | static int __devinit pcap_rtc_probe(struct platform_device *pdev) |
diff --git a/drivers/rtc/rtc-pcf50633.c b/drivers/rtc/rtc-pcf50633.c index 16edf94ab42..f90c574f9d0 100644 --- a/drivers/rtc/rtc-pcf50633.c +++ b/drivers/rtc/rtc-pcf50633.c | |||
@@ -106,25 +106,6 @@ pcf50633_rtc_alarm_irq_enable(struct device *dev, unsigned int enabled) | |||
106 | return 0; | 106 | return 0; |
107 | } | 107 | } |
108 | 108 | ||
109 | static int | ||
110 | pcf50633_rtc_update_irq_enable(struct device *dev, unsigned int enabled) | ||
111 | { | ||
112 | struct pcf50633_rtc *rtc = dev_get_drvdata(dev); | ||
113 | int err; | ||
114 | |||
115 | if (enabled) | ||
116 | err = pcf50633_irq_unmask(rtc->pcf, PCF50633_IRQ_SECOND); | ||
117 | else | ||
118 | err = pcf50633_irq_mask(rtc->pcf, PCF50633_IRQ_SECOND); | ||
119 | |||
120 | if (err < 0) | ||
121 | return err; | ||
122 | |||
123 | rtc->second_enabled = enabled; | ||
124 | |||
125 | return 0; | ||
126 | } | ||
127 | |||
128 | static int pcf50633_rtc_read_time(struct device *dev, struct rtc_time *tm) | 109 | static int pcf50633_rtc_read_time(struct device *dev, struct rtc_time *tm) |
129 | { | 110 | { |
130 | struct pcf50633_rtc *rtc; | 111 | struct pcf50633_rtc *rtc; |
@@ -262,8 +243,7 @@ static struct rtc_class_ops pcf50633_rtc_ops = { | |||
262 | .set_time = pcf50633_rtc_set_time, | 243 | .set_time = pcf50633_rtc_set_time, |
263 | .read_alarm = pcf50633_rtc_read_alarm, | 244 | .read_alarm = pcf50633_rtc_read_alarm, |
264 | .set_alarm = pcf50633_rtc_set_alarm, | 245 | .set_alarm = pcf50633_rtc_set_alarm, |
265 | .alarm_irq_enable = pcf50633_rtc_alarm_irq_enable, | 246 | .alarm_irq_enable = pcf50633_rtc_alarm_irq_enable, |
266 | .update_irq_enable = pcf50633_rtc_update_irq_enable, | ||
267 | }; | 247 | }; |
268 | 248 | ||
269 | static void pcf50633_rtc_irq(int irq, void *data) | 249 | static void pcf50633_rtc_irq(int irq, void *data) |
diff --git a/drivers/rtc/rtc-pl030.c b/drivers/rtc/rtc-pl030.c index bbdb2f02798..d554368c9f5 100644 --- a/drivers/rtc/rtc-pl030.c +++ b/drivers/rtc/rtc-pl030.c | |||
@@ -35,11 +35,6 @@ static irqreturn_t pl030_interrupt(int irq, void *dev_id) | |||
35 | return IRQ_HANDLED; | 35 | return IRQ_HANDLED; |
36 | } | 36 | } |
37 | 37 | ||
38 | static int pl030_ioctl(struct device *dev, unsigned int cmd, unsigned long arg) | ||
39 | { | ||
40 | return -ENOIOCTLCMD; | ||
41 | } | ||
42 | |||
43 | static int pl030_read_alarm(struct device *dev, struct rtc_wkalrm *alrm) | 38 | static int pl030_read_alarm(struct device *dev, struct rtc_wkalrm *alrm) |
44 | { | 39 | { |
45 | struct pl030_rtc *rtc = dev_get_drvdata(dev); | 40 | struct pl030_rtc *rtc = dev_get_drvdata(dev); |
@@ -96,7 +91,6 @@ static int pl030_set_time(struct device *dev, struct rtc_time *tm) | |||
96 | } | 91 | } |
97 | 92 | ||
98 | static const struct rtc_class_ops pl030_ops = { | 93 | static const struct rtc_class_ops pl030_ops = { |
99 | .ioctl = pl030_ioctl, | ||
100 | .read_time = pl030_read_time, | 94 | .read_time = pl030_read_time, |
101 | .set_time = pl030_set_time, | 95 | .set_time = pl030_set_time, |
102 | .read_alarm = pl030_read_alarm, | 96 | .read_alarm = pl030_read_alarm, |
diff --git a/drivers/rtc/rtc-pl031.c b/drivers/rtc/rtc-pl031.c index b7a6690e5b3..d829ea63c4f 100644 --- a/drivers/rtc/rtc-pl031.c +++ b/drivers/rtc/rtc-pl031.c | |||
@@ -293,57 +293,6 @@ static int pl031_set_alarm(struct device *dev, struct rtc_wkalrm *alarm) | |||
293 | return ret; | 293 | return ret; |
294 | } | 294 | } |
295 | 295 | ||
296 | /* Periodic interrupt is only available in ST variants. */ | ||
297 | static int pl031_irq_set_state(struct device *dev, int enabled) | ||
298 | { | ||
299 | struct pl031_local *ldata = dev_get_drvdata(dev); | ||
300 | |||
301 | if (enabled == 1) { | ||
302 | /* Clear any pending timer interrupt. */ | ||
303 | writel(RTC_BIT_PI, ldata->base + RTC_ICR); | ||
304 | |||
305 | writel(readl(ldata->base + RTC_IMSC) | RTC_BIT_PI, | ||
306 | ldata->base + RTC_IMSC); | ||
307 | |||
308 | /* Now start the timer */ | ||
309 | writel(readl(ldata->base + RTC_TCR) | RTC_TCR_EN, | ||
310 | ldata->base + RTC_TCR); | ||
311 | |||
312 | } else { | ||
313 | writel(readl(ldata->base + RTC_IMSC) & (~RTC_BIT_PI), | ||
314 | ldata->base + RTC_IMSC); | ||
315 | |||
316 | /* Also stop the timer */ | ||
317 | writel(readl(ldata->base + RTC_TCR) & (~RTC_TCR_EN), | ||
318 | ldata->base + RTC_TCR); | ||
319 | } | ||
320 | /* Wait at least 1 RTC32 clock cycle to ensure next access | ||
321 | * to RTC_TCR will succeed. | ||
322 | */ | ||
323 | udelay(40); | ||
324 | |||
325 | return 0; | ||
326 | } | ||
327 | |||
328 | static int pl031_irq_set_freq(struct device *dev, int freq) | ||
329 | { | ||
330 | struct pl031_local *ldata = dev_get_drvdata(dev); | ||
331 | |||
332 | /* Cant set timer if it is already enabled */ | ||
333 | if (readl(ldata->base + RTC_TCR) & RTC_TCR_EN) { | ||
334 | dev_err(dev, "can't change frequency while timer enabled\n"); | ||
335 | return -EINVAL; | ||
336 | } | ||
337 | |||
338 | /* If self start bit in RTC_TCR is set timer will start here, | ||
339 | * but we never set that bit. Instead we start the timer when | ||
340 | * set_state is called with enabled == 1. | ||
341 | */ | ||
342 | writel(RTC_TIMER_FREQ / freq, ldata->base + RTC_TLR); | ||
343 | |||
344 | return 0; | ||
345 | } | ||
346 | |||
347 | static int pl031_remove(struct amba_device *adev) | 296 | static int pl031_remove(struct amba_device *adev) |
348 | { | 297 | { |
349 | struct pl031_local *ldata = dev_get_drvdata(&adev->dev); | 298 | struct pl031_local *ldata = dev_get_drvdata(&adev->dev); |
@@ -440,8 +389,6 @@ static struct rtc_class_ops stv1_pl031_ops = { | |||
440 | .read_alarm = pl031_read_alarm, | 389 | .read_alarm = pl031_read_alarm, |
441 | .set_alarm = pl031_set_alarm, | 390 | .set_alarm = pl031_set_alarm, |
442 | .alarm_irq_enable = pl031_alarm_irq_enable, | 391 | .alarm_irq_enable = pl031_alarm_irq_enable, |
443 | .irq_set_state = pl031_irq_set_state, | ||
444 | .irq_set_freq = pl031_irq_set_freq, | ||
445 | }; | 392 | }; |
446 | 393 | ||
447 | /* And the second ST derivative */ | 394 | /* And the second ST derivative */ |
@@ -451,8 +398,6 @@ static struct rtc_class_ops stv2_pl031_ops = { | |||
451 | .read_alarm = pl031_stv2_read_alarm, | 398 | .read_alarm = pl031_stv2_read_alarm, |
452 | .set_alarm = pl031_stv2_set_alarm, | 399 | .set_alarm = pl031_stv2_set_alarm, |
453 | .alarm_irq_enable = pl031_alarm_irq_enable, | 400 | .alarm_irq_enable = pl031_alarm_irq_enable, |
454 | .irq_set_state = pl031_irq_set_state, | ||
455 | .irq_set_freq = pl031_irq_set_freq, | ||
456 | }; | 401 | }; |
457 | 402 | ||
458 | static struct amba_id pl031_ids[] = { | 403 | static struct amba_id pl031_ids[] = { |
diff --git a/drivers/rtc/rtc-proc.c b/drivers/rtc/rtc-proc.c index c086fc30a84..0a59fda5c09 100644 --- a/drivers/rtc/rtc-proc.c +++ b/drivers/rtc/rtc-proc.c | |||
@@ -69,6 +69,14 @@ static int rtc_proc_show(struct seq_file *seq, void *offset) | |||
69 | alrm.enabled ? "yes" : "no"); | 69 | alrm.enabled ? "yes" : "no"); |
70 | seq_printf(seq, "alrm_pending\t: %s\n", | 70 | seq_printf(seq, "alrm_pending\t: %s\n", |
71 | alrm.pending ? "yes" : "no"); | 71 | alrm.pending ? "yes" : "no"); |
72 | seq_printf(seq, "update IRQ enabled\t: %s\n", | ||
73 | (rtc->uie_rtctimer.enabled) ? "yes" : "no"); | ||
74 | seq_printf(seq, "periodic IRQ enabled\t: %s\n", | ||
75 | (rtc->pie_enabled) ? "yes" : "no"); | ||
76 | seq_printf(seq, "periodic IRQ frequency\t: %d\n", | ||
77 | rtc->irq_freq); | ||
78 | seq_printf(seq, "max user IRQ frequency\t: %d\n", | ||
79 | rtc->max_user_freq); | ||
72 | } | 80 | } |
73 | 81 | ||
74 | seq_printf(seq, "24hr\t\t: yes\n"); | 82 | seq_printf(seq, "24hr\t\t: yes\n"); |
@@ -81,12 +89,16 @@ static int rtc_proc_show(struct seq_file *seq, void *offset) | |||
81 | 89 | ||
82 | static int rtc_proc_open(struct inode *inode, struct file *file) | 90 | static int rtc_proc_open(struct inode *inode, struct file *file) |
83 | { | 91 | { |
92 | int ret; | ||
84 | struct rtc_device *rtc = PDE(inode)->data; | 93 | struct rtc_device *rtc = PDE(inode)->data; |
85 | 94 | ||
86 | if (!try_module_get(THIS_MODULE)) | 95 | if (!try_module_get(THIS_MODULE)) |
87 | return -ENODEV; | 96 | return -ENODEV; |
88 | 97 | ||
89 | return single_open(file, rtc_proc_show, rtc); | 98 | ret = single_open(file, rtc_proc_show, rtc); |
99 | if (ret) | ||
100 | module_put(THIS_MODULE); | ||
101 | return ret; | ||
90 | } | 102 | } |
91 | 103 | ||
92 | static int rtc_proc_release(struct inode *inode, struct file *file) | 104 | static int rtc_proc_release(struct inode *inode, struct file *file) |
diff --git a/drivers/rtc/rtc-pxa.c b/drivers/rtc/rtc-pxa.c index 29e867a1aaa..fc9f4991574 100644 --- a/drivers/rtc/rtc-pxa.c +++ b/drivers/rtc/rtc-pxa.c | |||
@@ -209,32 +209,6 @@ static void pxa_rtc_release(struct device *dev) | |||
209 | free_irq(pxa_rtc->irq_1Hz, dev); | 209 | free_irq(pxa_rtc->irq_1Hz, dev); |
210 | } | 210 | } |
211 | 211 | ||
212 | static int pxa_periodic_irq_set_freq(struct device *dev, int freq) | ||
213 | { | ||
214 | struct pxa_rtc *pxa_rtc = dev_get_drvdata(dev); | ||
215 | int period_ms; | ||
216 | |||
217 | if (freq < 1 || freq > MAXFREQ_PERIODIC) | ||
218 | return -EINVAL; | ||
219 | |||
220 | period_ms = 1000 / freq; | ||
221 | rtc_writel(pxa_rtc, PIAR, period_ms); | ||
222 | |||
223 | return 0; | ||
224 | } | ||
225 | |||
226 | static int pxa_periodic_irq_set_state(struct device *dev, int enabled) | ||
227 | { | ||
228 | struct pxa_rtc *pxa_rtc = dev_get_drvdata(dev); | ||
229 | |||
230 | if (enabled) | ||
231 | rtsr_set_bits(pxa_rtc, RTSR_PIALE | RTSR_PICE); | ||
232 | else | ||
233 | rtsr_clear_bits(pxa_rtc, RTSR_PIALE | RTSR_PICE); | ||
234 | |||
235 | return 0; | ||
236 | } | ||
237 | |||
238 | static int pxa_alarm_irq_enable(struct device *dev, unsigned int enabled) | 212 | static int pxa_alarm_irq_enable(struct device *dev, unsigned int enabled) |
239 | { | 213 | { |
240 | struct pxa_rtc *pxa_rtc = dev_get_drvdata(dev); | 214 | struct pxa_rtc *pxa_rtc = dev_get_drvdata(dev); |
@@ -250,21 +224,6 @@ static int pxa_alarm_irq_enable(struct device *dev, unsigned int enabled) | |||
250 | return 0; | 224 | return 0; |
251 | } | 225 | } |
252 | 226 | ||
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) | ||
260 | rtsr_set_bits(pxa_rtc, RTSR_HZE); | ||
261 | else | ||
262 | rtsr_clear_bits(pxa_rtc, RTSR_HZE); | ||
263 | |||
264 | spin_unlock_irq(&pxa_rtc->lock); | ||
265 | return 0; | ||
266 | } | ||
267 | |||
268 | static int pxa_rtc_read_time(struct device *dev, struct rtc_time *tm) | 227 | static int pxa_rtc_read_time(struct device *dev, struct rtc_time *tm) |
269 | { | 228 | { |
270 | struct pxa_rtc *pxa_rtc = dev_get_drvdata(dev); | 229 | struct pxa_rtc *pxa_rtc = dev_get_drvdata(dev); |
@@ -346,10 +305,7 @@ static const struct rtc_class_ops pxa_rtc_ops = { | |||
346 | .read_alarm = pxa_rtc_read_alarm, | 305 | .read_alarm = pxa_rtc_read_alarm, |
347 | .set_alarm = pxa_rtc_set_alarm, | 306 | .set_alarm = pxa_rtc_set_alarm, |
348 | .alarm_irq_enable = pxa_alarm_irq_enable, | 307 | .alarm_irq_enable = pxa_alarm_irq_enable, |
349 | .update_irq_enable = pxa_update_irq_enable, | ||
350 | .proc = pxa_rtc_proc, | 308 | .proc = pxa_rtc_proc, |
351 | .irq_set_state = pxa_periodic_irq_set_state, | ||
352 | .irq_set_freq = pxa_periodic_irq_set_freq, | ||
353 | }; | 309 | }; |
354 | 310 | ||
355 | static int __init pxa_rtc_probe(struct platform_device *pdev) | 311 | static int __init pxa_rtc_probe(struct platform_device *pdev) |
diff --git a/drivers/rtc/rtc-rp5c01.c b/drivers/rtc/rtc-rp5c01.c index 36eb6618446..694da39b6dd 100644 --- a/drivers/rtc/rtc-rp5c01.c +++ b/drivers/rtc/rtc-rp5c01.c | |||
@@ -76,7 +76,7 @@ static inline unsigned int rp5c01_read(struct rp5c01_priv *priv, | |||
76 | static inline void rp5c01_write(struct rp5c01_priv *priv, unsigned int val, | 76 | static inline void rp5c01_write(struct rp5c01_priv *priv, unsigned int val, |
77 | unsigned int reg) | 77 | unsigned int reg) |
78 | { | 78 | { |
79 | return __raw_writel(val, &priv->regs[reg]); | 79 | __raw_writel(val, &priv->regs[reg]); |
80 | } | 80 | } |
81 | 81 | ||
82 | static void rp5c01_lock(struct rp5c01_priv *priv) | 82 | static void rp5c01_lock(struct rp5c01_priv *priv) |
diff --git a/drivers/rtc/rtc-rs5c372.c b/drivers/rtc/rtc-rs5c372.c index dd14e202c2c..85c1b848dd7 100644 --- a/drivers/rtc/rtc-rs5c372.c +++ b/drivers/rtc/rtc-rs5c372.c | |||
@@ -281,10 +281,8 @@ static int rs5c372_rtc_set_time(struct device *dev, struct rtc_time *tm) | |||
281 | return rs5c372_set_datetime(to_i2c_client(dev), tm); | 281 | return rs5c372_set_datetime(to_i2c_client(dev), tm); |
282 | } | 282 | } |
283 | 283 | ||
284 | #if defined(CONFIG_RTC_INTF_DEV) || defined(CONFIG_RTC_INTF_DEV_MODULE) | ||
285 | 284 | ||
286 | static int | 285 | static int rs5c_rtc_alarm_irq_enable(struct device *dev, unsigned int enabled) |
287 | rs5c_rtc_ioctl(struct device *dev, unsigned int cmd, unsigned long arg) | ||
288 | { | 286 | { |
289 | struct i2c_client *client = to_i2c_client(dev); | 287 | struct i2c_client *client = to_i2c_client(dev); |
290 | struct rs5c372 *rs5c = i2c_get_clientdata(client); | 288 | struct rs5c372 *rs5c = i2c_get_clientdata(client); |
@@ -292,45 +290,19 @@ rs5c_rtc_ioctl(struct device *dev, unsigned int cmd, unsigned long arg) | |||
292 | int status, addr; | 290 | int status, addr; |
293 | 291 | ||
294 | buf = rs5c->regs[RS5C_REG_CTRL1]; | 292 | buf = rs5c->regs[RS5C_REG_CTRL1]; |
295 | switch (cmd) { | 293 | |
296 | case RTC_UIE_OFF: | 294 | if (!rs5c->has_irq) |
297 | case RTC_UIE_ON: | 295 | return -EINVAL; |
298 | /* some 327a modes use a different IRQ pin for 1Hz irqs */ | ||
299 | if (rs5c->type == rtc_rs5c372a | ||
300 | && (buf & RS5C372A_CTRL1_SL1)) | ||
301 | return -ENOIOCTLCMD; | ||
302 | case RTC_AIE_OFF: | ||
303 | case RTC_AIE_ON: | ||
304 | /* these irq management calls only make sense for chips | ||
305 | * which are wired up to an IRQ. | ||
306 | */ | ||
307 | if (!rs5c->has_irq) | ||
308 | return -ENOIOCTLCMD; | ||
309 | break; | ||
310 | default: | ||
311 | return -ENOIOCTLCMD; | ||
312 | } | ||
313 | 296 | ||
314 | status = rs5c_get_regs(rs5c); | 297 | status = rs5c_get_regs(rs5c); |
315 | if (status < 0) | 298 | if (status < 0) |
316 | return status; | 299 | return status; |
317 | 300 | ||
318 | addr = RS5C_ADDR(RS5C_REG_CTRL1); | 301 | addr = RS5C_ADDR(RS5C_REG_CTRL1); |
319 | switch (cmd) { | 302 | if (enabled) |
320 | case RTC_AIE_OFF: /* alarm off */ | ||
321 | buf &= ~RS5C_CTRL1_AALE; | ||
322 | break; | ||
323 | case RTC_AIE_ON: /* alarm on */ | ||
324 | buf |= RS5C_CTRL1_AALE; | 303 | buf |= RS5C_CTRL1_AALE; |
325 | break; | 304 | else |
326 | case RTC_UIE_OFF: /* update off */ | 305 | buf &= ~RS5C_CTRL1_AALE; |
327 | buf &= ~RS5C_CTRL1_CT_MASK; | ||
328 | break; | ||
329 | case RTC_UIE_ON: /* update on */ | ||
330 | buf &= ~RS5C_CTRL1_CT_MASK; | ||
331 | buf |= RS5C_CTRL1_CT4; | ||
332 | break; | ||
333 | } | ||
334 | 306 | ||
335 | if (i2c_smbus_write_byte_data(client, addr, buf) < 0) { | 307 | if (i2c_smbus_write_byte_data(client, addr, buf) < 0) { |
336 | printk(KERN_WARNING "%s: can't update alarm\n", | 308 | printk(KERN_WARNING "%s: can't update alarm\n", |
@@ -342,10 +314,6 @@ rs5c_rtc_ioctl(struct device *dev, unsigned int cmd, unsigned long arg) | |||
342 | return status; | 314 | return status; |
343 | } | 315 | } |
344 | 316 | ||
345 | #else | ||
346 | #define rs5c_rtc_ioctl NULL | ||
347 | #endif | ||
348 | |||
349 | 317 | ||
350 | /* NOTE: Since RTC_WKALM_{RD,SET} were originally defined for EFI, | 318 | /* NOTE: Since RTC_WKALM_{RD,SET} were originally defined for EFI, |
351 | * which only exposes a polled programming interface; and since | 319 | * which only exposes a polled programming interface; and since |
@@ -461,11 +429,11 @@ static int rs5c372_rtc_proc(struct device *dev, struct seq_file *seq) | |||
461 | 429 | ||
462 | static const struct rtc_class_ops rs5c372_rtc_ops = { | 430 | static const struct rtc_class_ops rs5c372_rtc_ops = { |
463 | .proc = rs5c372_rtc_proc, | 431 | .proc = rs5c372_rtc_proc, |
464 | .ioctl = rs5c_rtc_ioctl, | ||
465 | .read_time = rs5c372_rtc_read_time, | 432 | .read_time = rs5c372_rtc_read_time, |
466 | .set_time = rs5c372_rtc_set_time, | 433 | .set_time = rs5c372_rtc_set_time, |
467 | .read_alarm = rs5c_read_alarm, | 434 | .read_alarm = rs5c_read_alarm, |
468 | .set_alarm = rs5c_set_alarm, | 435 | .set_alarm = rs5c_set_alarm, |
436 | .alarm_irq_enable = rs5c_rtc_alarm_irq_enable, | ||
469 | }; | 437 | }; |
470 | 438 | ||
471 | #if defined(CONFIG_RTC_INTF_SYSFS) || defined(CONFIG_RTC_INTF_SYSFS_MODULE) | 439 | #if defined(CONFIG_RTC_INTF_SYSFS) || defined(CONFIG_RTC_INTF_SYSFS_MODULE) |
diff --git a/drivers/rtc/rtc-rx8025.c b/drivers/rtc/rtc-rx8025.c index 1146e3522d3..fde172fb2ab 100644 --- a/drivers/rtc/rtc-rx8025.c +++ b/drivers/rtc/rtc-rx8025.c | |||
@@ -424,37 +424,12 @@ static int rx8025_alarm_irq_enable(struct device *dev, unsigned int enabled) | |||
424 | return 0; | 424 | return 0; |
425 | } | 425 | } |
426 | 426 | ||
427 | static int rx8025_irq_set_state(struct device *dev, int enabled) | ||
428 | { | ||
429 | struct i2c_client *client = to_i2c_client(dev); | ||
430 | struct rx8025_data *rx8025 = i2c_get_clientdata(client); | ||
431 | int ctrl1; | ||
432 | int err; | ||
433 | |||
434 | if (client->irq <= 0) | ||
435 | return -ENXIO; | ||
436 | |||
437 | ctrl1 = rx8025->ctrl1 & ~RX8025_BIT_CTRL1_CT; | ||
438 | if (enabled) | ||
439 | ctrl1 |= RX8025_BIT_CTRL1_CT_1HZ; | ||
440 | if (ctrl1 != rx8025->ctrl1) { | ||
441 | rx8025->ctrl1 = ctrl1; | ||
442 | err = rx8025_write_reg(rx8025->client, RX8025_REG_CTRL1, | ||
443 | rx8025->ctrl1); | ||
444 | if (err) | ||
445 | return err; | ||
446 | } | ||
447 | |||
448 | return 0; | ||
449 | } | ||
450 | |||
451 | static struct rtc_class_ops rx8025_rtc_ops = { | 427 | static struct rtc_class_ops rx8025_rtc_ops = { |
452 | .read_time = rx8025_get_time, | 428 | .read_time = rx8025_get_time, |
453 | .set_time = rx8025_set_time, | 429 | .set_time = rx8025_set_time, |
454 | .read_alarm = rx8025_read_alarm, | 430 | .read_alarm = rx8025_read_alarm, |
455 | .set_alarm = rx8025_set_alarm, | 431 | .set_alarm = rx8025_set_alarm, |
456 | .alarm_irq_enable = rx8025_alarm_irq_enable, | 432 | .alarm_irq_enable = rx8025_alarm_irq_enable, |
457 | .irq_set_state = rx8025_irq_set_state, | ||
458 | }; | 433 | }; |
459 | 434 | ||
460 | /* | 435 | /* |
@@ -650,7 +625,7 @@ static int __devexit rx8025_remove(struct i2c_client *client) | |||
650 | mutex_unlock(lock); | 625 | mutex_unlock(lock); |
651 | 626 | ||
652 | free_irq(client->irq, client); | 627 | free_irq(client->irq, client); |
653 | flush_scheduled_work(); | 628 | cancel_work_sync(&rx8025->work); |
654 | } | 629 | } |
655 | 630 | ||
656 | rx8025_sysfs_unregister(&client->dev); | 631 | rx8025_sysfs_unregister(&client->dev); |
diff --git a/drivers/rtc/rtc-s3c.c b/drivers/rtc/rtc-s3c.c index cf953ecbfca..714964913e5 100644 --- a/drivers/rtc/rtc-s3c.c +++ b/drivers/rtc/rtc-s3c.c | |||
@@ -77,47 +77,18 @@ static irqreturn_t s3c_rtc_tickirq(int irq, void *id) | |||
77 | } | 77 | } |
78 | 78 | ||
79 | /* Update control registers */ | 79 | /* Update control registers */ |
80 | static void s3c_rtc_setaie(int to) | 80 | static int s3c_rtc_setaie(struct device *dev, unsigned int enabled) |
81 | { | 81 | { |
82 | unsigned int tmp; | 82 | unsigned int tmp; |
83 | 83 | ||
84 | pr_debug("%s: aie=%d\n", __func__, to); | 84 | pr_debug("%s: aie=%d\n", __func__, enabled); |
85 | 85 | ||
86 | tmp = readb(s3c_rtc_base + S3C2410_RTCALM) & ~S3C2410_RTCALM_ALMEN; | 86 | tmp = readb(s3c_rtc_base + S3C2410_RTCALM) & ~S3C2410_RTCALM_ALMEN; |
87 | 87 | ||
88 | if (to) | 88 | if (enabled) |
89 | tmp |= S3C2410_RTCALM_ALMEN; | 89 | tmp |= S3C2410_RTCALM_ALMEN; |
90 | 90 | ||
91 | writeb(tmp, s3c_rtc_base + S3C2410_RTCALM); | 91 | writeb(tmp, s3c_rtc_base + S3C2410_RTCALM); |
92 | } | ||
93 | |||
94 | static int s3c_rtc_setpie(struct device *dev, int enabled) | ||
95 | { | ||
96 | unsigned int tmp; | ||
97 | |||
98 | pr_debug("%s: pie=%d\n", __func__, enabled); | ||
99 | |||
100 | spin_lock_irq(&s3c_rtc_pie_lock); | ||
101 | |||
102 | if (s3c_rtc_cpu_type == TYPE_S3C64XX) { | ||
103 | tmp = readw(s3c_rtc_base + S3C2410_RTCCON); | ||
104 | tmp &= ~S3C64XX_RTCCON_TICEN; | ||
105 | |||
106 | if (enabled) | ||
107 | tmp |= S3C64XX_RTCCON_TICEN; | ||
108 | |||
109 | writew(tmp, s3c_rtc_base + S3C2410_RTCCON); | ||
110 | } else { | ||
111 | tmp = readb(s3c_rtc_base + S3C2410_TICNT); | ||
112 | tmp &= ~S3C2410_TICNT_ENABLE; | ||
113 | |||
114 | if (enabled) | ||
115 | tmp |= S3C2410_TICNT_ENABLE; | ||
116 | |||
117 | writeb(tmp, s3c_rtc_base + S3C2410_TICNT); | ||
118 | } | ||
119 | |||
120 | spin_unlock_irq(&s3c_rtc_pie_lock); | ||
121 | 92 | ||
122 | return 0; | 93 | return 0; |
123 | } | 94 | } |
@@ -308,7 +279,7 @@ static int s3c_rtc_setalarm(struct device *dev, struct rtc_wkalrm *alrm) | |||
308 | 279 | ||
309 | writeb(alrm_en, base + S3C2410_RTCALM); | 280 | writeb(alrm_en, base + S3C2410_RTCALM); |
310 | 281 | ||
311 | s3c_rtc_setaie(alrm->enabled); | 282 | s3c_rtc_setaie(dev, alrm->enabled); |
312 | 283 | ||
313 | return 0; | 284 | return 0; |
314 | } | 285 | } |
@@ -377,8 +348,6 @@ static const struct rtc_class_ops s3c_rtcops = { | |||
377 | .set_time = s3c_rtc_settime, | 348 | .set_time = s3c_rtc_settime, |
378 | .read_alarm = s3c_rtc_getalarm, | 349 | .read_alarm = s3c_rtc_getalarm, |
379 | .set_alarm = s3c_rtc_setalarm, | 350 | .set_alarm = s3c_rtc_setalarm, |
380 | .irq_set_freq = s3c_rtc_setfreq, | ||
381 | .irq_set_state = s3c_rtc_setpie, | ||
382 | .proc = s3c_rtc_proc, | 351 | .proc = s3c_rtc_proc, |
383 | .alarm_irq_enable = s3c_rtc_setaie, | 352 | .alarm_irq_enable = s3c_rtc_setaie, |
384 | }; | 353 | }; |
@@ -440,7 +409,7 @@ static int __devexit s3c_rtc_remove(struct platform_device *dev) | |||
440 | rtc_device_unregister(rtc); | 409 | rtc_device_unregister(rtc); |
441 | 410 | ||
442 | s3c_rtc_setpie(&dev->dev, 0); | 411 | s3c_rtc_setpie(&dev->dev, 0); |
443 | s3c_rtc_setaie(0); | 412 | s3c_rtc_setaie(&dev->dev, 0); |
444 | 413 | ||
445 | clk_disable(rtc_clk); | 414 | clk_disable(rtc_clk); |
446 | clk_put(rtc_clk); | 415 | clk_put(rtc_clk); |
diff --git a/drivers/rtc/rtc-sa1100.c b/drivers/rtc/rtc-sa1100.c index e4a44b64170..0b40bb88a88 100644 --- a/drivers/rtc/rtc-sa1100.c +++ b/drivers/rtc/rtc-sa1100.c | |||
@@ -39,11 +39,10 @@ | |||
39 | #include <mach/regs-ost.h> | 39 | #include <mach/regs-ost.h> |
40 | #endif | 40 | #endif |
41 | 41 | ||
42 | #define RTC_DEF_DIVIDER 32768 - 1 | 42 | #define RTC_DEF_DIVIDER (32768 - 1) |
43 | #define RTC_DEF_TRIM 0 | 43 | #define RTC_DEF_TRIM 0 |
44 | 44 | ||
45 | static unsigned long rtc_freq = 1024; | 45 | static const unsigned long RTC_FREQ = 1024; |
46 | static unsigned long timer_freq; | ||
47 | static struct rtc_time rtc_alarm; | 46 | static struct rtc_time rtc_alarm; |
48 | static DEFINE_SPINLOCK(sa1100_rtc_lock); | 47 | static DEFINE_SPINLOCK(sa1100_rtc_lock); |
49 | 48 | ||
@@ -61,7 +60,8 @@ static inline int rtc_periodic_alarm(struct rtc_time *tm) | |||
61 | * Calculate the next alarm time given the requested alarm time mask | 60 | * Calculate the next alarm time given the requested alarm time mask |
62 | * and the current time. | 61 | * and the current time. |
63 | */ | 62 | */ |
64 | static void rtc_next_alarm_time(struct rtc_time *next, struct rtc_time *now, struct rtc_time *alrm) | 63 | static void rtc_next_alarm_time(struct rtc_time *next, struct rtc_time *now, |
64 | struct rtc_time *alrm) | ||
65 | { | 65 | { |
66 | unsigned long next_time; | 66 | unsigned long next_time; |
67 | unsigned long now_time; | 67 | unsigned long now_time; |
@@ -116,7 +116,23 @@ static irqreturn_t sa1100_rtc_interrupt(int irq, void *dev_id) | |||
116 | rtsr = RTSR; | 116 | rtsr = RTSR; |
117 | /* clear interrupt sources */ | 117 | /* clear interrupt sources */ |
118 | RTSR = 0; | 118 | RTSR = 0; |
119 | RTSR = (RTSR_AL | RTSR_HZ) & (rtsr >> 2); | 119 | /* Fix for a nasty initialization problem the in SA11xx RTSR register. |
120 | * See also the comments in sa1100_rtc_probe(). */ | ||
121 | if (rtsr & (RTSR_ALE | RTSR_HZE)) { | ||
122 | /* This is the original code, before there was the if test | ||
123 | * above. This code does not clear interrupts that were not | ||
124 | * enabled. */ | ||
125 | RTSR = (RTSR_AL | RTSR_HZ) & (rtsr >> 2); | ||
126 | } else { | ||
127 | /* For some reason, it is possible to enter this routine | ||
128 | * without interruptions enabled, it has been tested with | ||
129 | * several units (Bug in SA11xx chip?). | ||
130 | * | ||
131 | * This situation leads to an infinite "loop" of interrupt | ||
132 | * routine calling and as a result the processor seems to | ||
133 | * lock on its first call to open(). */ | ||
134 | RTSR = RTSR_AL | RTSR_HZ; | ||
135 | } | ||
120 | 136 | ||
121 | /* clear alarm interrupt if it has occurred */ | 137 | /* clear alarm interrupt if it has occurred */ |
122 | if (rtsr & RTSR_AL) | 138 | if (rtsr & RTSR_AL) |
@@ -139,80 +155,29 @@ static irqreturn_t sa1100_rtc_interrupt(int irq, void *dev_id) | |||
139 | return IRQ_HANDLED; | 155 | return IRQ_HANDLED; |
140 | } | 156 | } |
141 | 157 | ||
142 | static int rtc_timer1_count; | ||
143 | |||
144 | static irqreturn_t timer1_interrupt(int irq, void *dev_id) | ||
145 | { | ||
146 | struct platform_device *pdev = to_platform_device(dev_id); | ||
147 | struct rtc_device *rtc = platform_get_drvdata(pdev); | ||
148 | |||
149 | /* | ||
150 | * If we match for the first time, rtc_timer1_count will be 1. | ||
151 | * Otherwise, we wrapped around (very unlikely but | ||
152 | * still possible) so compute the amount of missed periods. | ||
153 | * The match reg is updated only when the data is actually retrieved | ||
154 | * to avoid unnecessary interrupts. | ||
155 | */ | ||
156 | OSSR = OSSR_M1; /* clear match on timer1 */ | ||
157 | |||
158 | rtc_update_irq(rtc, rtc_timer1_count, RTC_PF | RTC_IRQF); | ||
159 | |||
160 | if (rtc_timer1_count == 1) | ||
161 | rtc_timer1_count = (rtc_freq * ((1 << 30) / (timer_freq >> 2))); | ||
162 | |||
163 | return IRQ_HANDLED; | ||
164 | } | ||
165 | |||
166 | static int sa1100_rtc_read_callback(struct device *dev, int data) | ||
167 | { | ||
168 | if (data & RTC_PF) { | ||
169 | /* interpolate missed periods and set match for the next */ | ||
170 | unsigned long period = timer_freq / rtc_freq; | ||
171 | unsigned long oscr = OSCR; | ||
172 | unsigned long osmr1 = OSMR1; | ||
173 | unsigned long missed = (oscr - osmr1)/period; | ||
174 | data += missed << 8; | ||
175 | OSSR = OSSR_M1; /* clear match on timer 1 */ | ||
176 | OSMR1 = osmr1 + (missed + 1)*period; | ||
177 | /* Ensure we didn't miss another match in the mean time. | ||
178 | * Here we compare (match - OSCR) 8 instead of 0 -- | ||
179 | * see comment in pxa_timer_interrupt() for explanation. | ||
180 | */ | ||
181 | while( (signed long)((osmr1 = OSMR1) - OSCR) <= 8 ) { | ||
182 | data += 0x100; | ||
183 | OSSR = OSSR_M1; /* clear match on timer 1 */ | ||
184 | OSMR1 = osmr1 + period; | ||
185 | } | ||
186 | } | ||
187 | return data; | ||
188 | } | ||
189 | |||
190 | static int sa1100_rtc_open(struct device *dev) | 158 | static int sa1100_rtc_open(struct device *dev) |
191 | { | 159 | { |
192 | int ret; | 160 | int ret; |
161 | struct platform_device *plat_dev = to_platform_device(dev); | ||
162 | struct rtc_device *rtc = platform_get_drvdata(plat_dev); | ||
193 | 163 | ||
194 | ret = request_irq(IRQ_RTC1Hz, sa1100_rtc_interrupt, IRQF_DISABLED, | 164 | ret = request_irq(IRQ_RTC1Hz, sa1100_rtc_interrupt, IRQF_DISABLED, |
195 | "rtc 1Hz", dev); | 165 | "rtc 1Hz", dev); |
196 | if (ret) { | 166 | if (ret) { |
197 | dev_err(dev, "IRQ %d already in use.\n", IRQ_RTC1Hz); | 167 | dev_err(dev, "IRQ %d already in use.\n", IRQ_RTC1Hz); |
198 | goto fail_ui; | 168 | goto fail_ui; |
199 | } | 169 | } |
200 | ret = request_irq(IRQ_RTCAlrm, sa1100_rtc_interrupt, IRQF_DISABLED, | 170 | ret = request_irq(IRQ_RTCAlrm, sa1100_rtc_interrupt, IRQF_DISABLED, |
201 | "rtc Alrm", dev); | 171 | "rtc Alrm", dev); |
202 | if (ret) { | 172 | if (ret) { |
203 | dev_err(dev, "IRQ %d already in use.\n", IRQ_RTCAlrm); | 173 | dev_err(dev, "IRQ %d already in use.\n", IRQ_RTCAlrm); |
204 | goto fail_ai; | 174 | goto fail_ai; |
205 | } | 175 | } |
206 | ret = request_irq(IRQ_OST1, timer1_interrupt, IRQF_DISABLED, | 176 | rtc->max_user_freq = RTC_FREQ; |
207 | "rtc timer", dev); | 177 | rtc_irq_set_freq(rtc, NULL, RTC_FREQ); |
208 | if (ret) { | 178 | |
209 | dev_err(dev, "IRQ %d already in use.\n", IRQ_OST1); | ||
210 | goto fail_pi; | ||
211 | } | ||
212 | return 0; | 179 | return 0; |
213 | 180 | ||
214 | fail_pi: | ||
215 | free_irq(IRQ_RTCAlrm, dev); | ||
216 | fail_ai: | 181 | fail_ai: |
217 | free_irq(IRQ_RTC1Hz, dev); | 182 | free_irq(IRQ_RTC1Hz, dev); |
218 | fail_ui: | 183 | fail_ui: |
@@ -227,57 +192,19 @@ static void sa1100_rtc_release(struct device *dev) | |||
227 | OSSR = OSSR_M1; | 192 | OSSR = OSSR_M1; |
228 | spin_unlock_irq(&sa1100_rtc_lock); | 193 | spin_unlock_irq(&sa1100_rtc_lock); |
229 | 194 | ||
230 | free_irq(IRQ_OST1, dev); | ||
231 | free_irq(IRQ_RTCAlrm, dev); | 195 | free_irq(IRQ_RTCAlrm, dev); |
232 | free_irq(IRQ_RTC1Hz, dev); | 196 | free_irq(IRQ_RTC1Hz, dev); |
233 | } | 197 | } |
234 | 198 | ||
235 | 199 | static int sa1100_rtc_alarm_irq_enable(struct device *dev, unsigned int enabled) | |
236 | static int sa1100_rtc_ioctl(struct device *dev, unsigned int cmd, | ||
237 | unsigned long arg) | ||
238 | { | 200 | { |
239 | switch(cmd) { | 201 | spin_lock_irq(&sa1100_rtc_lock); |
240 | case RTC_AIE_OFF: | 202 | if (enabled) |
241 | spin_lock_irq(&sa1100_rtc_lock); | ||
242 | RTSR &= ~RTSR_ALE; | ||
243 | spin_unlock_irq(&sa1100_rtc_lock); | ||
244 | return 0; | ||
245 | case RTC_AIE_ON: | ||
246 | spin_lock_irq(&sa1100_rtc_lock); | ||
247 | RTSR |= RTSR_ALE; | 203 | RTSR |= RTSR_ALE; |
248 | spin_unlock_irq(&sa1100_rtc_lock); | 204 | else |
249 | return 0; | 205 | RTSR &= ~RTSR_ALE; |
250 | case RTC_UIE_OFF: | 206 | spin_unlock_irq(&sa1100_rtc_lock); |
251 | spin_lock_irq(&sa1100_rtc_lock); | 207 | return 0; |
252 | RTSR &= ~RTSR_HZE; | ||
253 | spin_unlock_irq(&sa1100_rtc_lock); | ||
254 | return 0; | ||
255 | case RTC_UIE_ON: | ||
256 | spin_lock_irq(&sa1100_rtc_lock); | ||
257 | RTSR |= RTSR_HZE; | ||
258 | spin_unlock_irq(&sa1100_rtc_lock); | ||
259 | return 0; | ||
260 | case RTC_PIE_OFF: | ||
261 | spin_lock_irq(&sa1100_rtc_lock); | ||
262 | OIER &= ~OIER_E1; | ||
263 | spin_unlock_irq(&sa1100_rtc_lock); | ||
264 | return 0; | ||
265 | case RTC_PIE_ON: | ||
266 | spin_lock_irq(&sa1100_rtc_lock); | ||
267 | OSMR1 = timer_freq / rtc_freq + OSCR; | ||
268 | OIER |= OIER_E1; | ||
269 | rtc_timer1_count = 1; | ||
270 | spin_unlock_irq(&sa1100_rtc_lock); | ||
271 | return 0; | ||
272 | case RTC_IRQP_READ: | ||
273 | return put_user(rtc_freq, (unsigned long *)arg); | ||
274 | case RTC_IRQP_SET: | ||
275 | if (arg < 1 || arg > timer_freq) | ||
276 | return -EINVAL; | ||
277 | rtc_freq = arg; | ||
278 | return 0; | ||
279 | } | ||
280 | return -ENOIOCTLCMD; | ||
281 | } | 208 | } |
282 | 209 | ||
283 | static int sa1100_rtc_read_time(struct device *dev, struct rtc_time *tm) | 210 | static int sa1100_rtc_read_time(struct device *dev, struct rtc_time *tm) |
@@ -327,34 +254,27 @@ static int sa1100_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm) | |||
327 | 254 | ||
328 | static int sa1100_rtc_proc(struct device *dev, struct seq_file *seq) | 255 | static int sa1100_rtc_proc(struct device *dev, struct seq_file *seq) |
329 | { | 256 | { |
330 | seq_printf(seq, "trim/divider\t: 0x%08x\n", (u32) RTTR); | 257 | seq_printf(seq, "trim/divider\t\t: 0x%08x\n", (u32) RTTR); |
331 | seq_printf(seq, "update_IRQ\t: %s\n", | 258 | seq_printf(seq, "RTSR\t\t\t: 0x%08x\n", (u32)RTSR); |
332 | (RTSR & RTSR_HZE) ? "yes" : "no"); | ||
333 | seq_printf(seq, "periodic_IRQ\t: %s\n", | ||
334 | (OIER & OIER_E1) ? "yes" : "no"); | ||
335 | seq_printf(seq, "periodic_freq\t: %ld\n", rtc_freq); | ||
336 | 259 | ||
337 | return 0; | 260 | return 0; |
338 | } | 261 | } |
339 | 262 | ||
340 | static const struct rtc_class_ops sa1100_rtc_ops = { | 263 | static const struct rtc_class_ops sa1100_rtc_ops = { |
341 | .open = sa1100_rtc_open, | 264 | .open = sa1100_rtc_open, |
342 | .read_callback = sa1100_rtc_read_callback, | ||
343 | .release = sa1100_rtc_release, | 265 | .release = sa1100_rtc_release, |
344 | .ioctl = sa1100_rtc_ioctl, | ||
345 | .read_time = sa1100_rtc_read_time, | 266 | .read_time = sa1100_rtc_read_time, |
346 | .set_time = sa1100_rtc_set_time, | 267 | .set_time = sa1100_rtc_set_time, |
347 | .read_alarm = sa1100_rtc_read_alarm, | 268 | .read_alarm = sa1100_rtc_read_alarm, |
348 | .set_alarm = sa1100_rtc_set_alarm, | 269 | .set_alarm = sa1100_rtc_set_alarm, |
349 | .proc = sa1100_rtc_proc, | 270 | .proc = sa1100_rtc_proc, |
271 | .alarm_irq_enable = sa1100_rtc_alarm_irq_enable, | ||
350 | }; | 272 | }; |
351 | 273 | ||
352 | static int sa1100_rtc_probe(struct platform_device *pdev) | 274 | static int sa1100_rtc_probe(struct platform_device *pdev) |
353 | { | 275 | { |
354 | struct rtc_device *rtc; | 276 | struct rtc_device *rtc; |
355 | 277 | ||
356 | timer_freq = get_clock_tick_rate(); | ||
357 | |||
358 | /* | 278 | /* |
359 | * According to the manual we should be able to let RTTR be zero | 279 | * According to the manual we should be able to let RTTR be zero |
360 | * and then a default diviser for a 32.768KHz clock is used. | 280 | * and then a default diviser for a 32.768KHz clock is used. |
@@ -364,7 +284,8 @@ static int sa1100_rtc_probe(struct platform_device *pdev) | |||
364 | */ | 284 | */ |
365 | if (RTTR == 0) { | 285 | if (RTTR == 0) { |
366 | RTTR = RTC_DEF_DIVIDER + (RTC_DEF_TRIM << 16); | 286 | RTTR = RTC_DEF_DIVIDER + (RTC_DEF_TRIM << 16); |
367 | dev_warn(&pdev->dev, "warning: initializing default clock divider/trim value\n"); | 287 | dev_warn(&pdev->dev, "warning: " |
288 | "initializing default clock divider/trim value\n"); | ||
368 | /* The current RTC value probably doesn't make sense either */ | 289 | /* The current RTC value probably doesn't make sense either */ |
369 | RCNR = 0; | 290 | RCNR = 0; |
370 | } | 291 | } |
@@ -372,13 +293,37 @@ static int sa1100_rtc_probe(struct platform_device *pdev) | |||
372 | device_init_wakeup(&pdev->dev, 1); | 293 | device_init_wakeup(&pdev->dev, 1); |
373 | 294 | ||
374 | rtc = rtc_device_register(pdev->name, &pdev->dev, &sa1100_rtc_ops, | 295 | rtc = rtc_device_register(pdev->name, &pdev->dev, &sa1100_rtc_ops, |
375 | THIS_MODULE); | 296 | THIS_MODULE); |
376 | 297 | ||
377 | if (IS_ERR(rtc)) | 298 | if (IS_ERR(rtc)) |
378 | return PTR_ERR(rtc); | 299 | return PTR_ERR(rtc); |
379 | 300 | ||
380 | platform_set_drvdata(pdev, rtc); | 301 | platform_set_drvdata(pdev, rtc); |
381 | 302 | ||
303 | /* Fix for a nasty initialization problem the in SA11xx RTSR register. | ||
304 | * See also the comments in sa1100_rtc_interrupt(). | ||
305 | * | ||
306 | * Sometimes bit 1 of the RTSR (RTSR_HZ) will wake up 1, which means an | ||
307 | * interrupt pending, even though interrupts were never enabled. | ||
308 | * In this case, this bit it must be reset before enabling | ||
309 | * interruptions to avoid a nonexistent interrupt to occur. | ||
310 | * | ||
311 | * In principle, the same problem would apply to bit 0, although it has | ||
312 | * never been observed to happen. | ||
313 | * | ||
314 | * This issue is addressed both here and in sa1100_rtc_interrupt(). | ||
315 | * If the issue is not addressed here, in the times when the processor | ||
316 | * wakes up with the bit set there will be one spurious interrupt. | ||
317 | * | ||
318 | * The issue is also dealt with in sa1100_rtc_interrupt() to be on the | ||
319 | * safe side, once the condition that lead to this strange | ||
320 | * initialization is unknown and could in principle happen during | ||
321 | * normal processing. | ||
322 | * | ||
323 | * Notice that clearing bit 1 and 0 is accomplished by writting ONES to | ||
324 | * the corresponding bits in RTSR. */ | ||
325 | RTSR = RTSR_AL | RTSR_HZ; | ||
326 | |||
382 | return 0; | 327 | return 0; |
383 | } | 328 | } |
384 | 329 | ||
@@ -386,7 +331,7 @@ static int sa1100_rtc_remove(struct platform_device *pdev) | |||
386 | { | 331 | { |
387 | struct rtc_device *rtc = platform_get_drvdata(pdev); | 332 | struct rtc_device *rtc = platform_get_drvdata(pdev); |
388 | 333 | ||
389 | if (rtc) | 334 | if (rtc) |
390 | rtc_device_unregister(rtc); | 335 | rtc_device_unregister(rtc); |
391 | 336 | ||
392 | return 0; | 337 | return 0; |
diff --git a/drivers/rtc/rtc-sh.c b/drivers/rtc/rtc-sh.c index 06e41ed9323..e55dc1ac83a 100644 --- a/drivers/rtc/rtc-sh.c +++ b/drivers/rtc/rtc-sh.c | |||
@@ -344,29 +344,10 @@ static inline void sh_rtc_setcie(struct device *dev, unsigned int enable) | |||
344 | spin_unlock_irq(&rtc->lock); | 344 | spin_unlock_irq(&rtc->lock); |
345 | } | 345 | } |
346 | 346 | ||
347 | static int sh_rtc_ioctl(struct device *dev, unsigned int cmd, unsigned long arg) | 347 | static int sh_rtc_alarm_irq_enable(struct device *dev, unsigned int enabled) |
348 | { | 348 | { |
349 | struct sh_rtc *rtc = dev_get_drvdata(dev); | 349 | sh_rtc_setaie(dev, enabled); |
350 | unsigned int ret = 0; | 350 | return 0; |
351 | |||
352 | switch (cmd) { | ||
353 | case RTC_AIE_OFF: | ||
354 | case RTC_AIE_ON: | ||
355 | sh_rtc_setaie(dev, cmd == RTC_AIE_ON); | ||
356 | break; | ||
357 | case RTC_UIE_OFF: | ||
358 | rtc->periodic_freq &= ~PF_OXS; | ||
359 | sh_rtc_setcie(dev, 0); | ||
360 | break; | ||
361 | case RTC_UIE_ON: | ||
362 | rtc->periodic_freq |= PF_OXS; | ||
363 | sh_rtc_setcie(dev, 1); | ||
364 | break; | ||
365 | default: | ||
366 | ret = -ENOIOCTLCMD; | ||
367 | } | ||
368 | |||
369 | return ret; | ||
370 | } | 351 | } |
371 | 352 | ||
372 | static int sh_rtc_read_time(struct device *dev, struct rtc_time *tm) | 353 | static int sh_rtc_read_time(struct device *dev, struct rtc_time *tm) |
@@ -596,14 +577,12 @@ static int sh_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *wkalrm) | |||
596 | } | 577 | } |
597 | 578 | ||
598 | static struct rtc_class_ops sh_rtc_ops = { | 579 | static struct rtc_class_ops sh_rtc_ops = { |
599 | .ioctl = sh_rtc_ioctl, | ||
600 | .read_time = sh_rtc_read_time, | 580 | .read_time = sh_rtc_read_time, |
601 | .set_time = sh_rtc_set_time, | 581 | .set_time = sh_rtc_set_time, |
602 | .read_alarm = sh_rtc_read_alarm, | 582 | .read_alarm = sh_rtc_read_alarm, |
603 | .set_alarm = sh_rtc_set_alarm, | 583 | .set_alarm = sh_rtc_set_alarm, |
604 | .irq_set_state = sh_rtc_irq_set_state, | ||
605 | .irq_set_freq = sh_rtc_irq_set_freq, | ||
606 | .proc = sh_rtc_proc, | 584 | .proc = sh_rtc_proc, |
585 | .alarm_irq_enable = sh_rtc_alarm_irq_enable, | ||
607 | }; | 586 | }; |
608 | 587 | ||
609 | static int __init sh_rtc_probe(struct platform_device *pdev) | 588 | static int __init sh_rtc_probe(struct platform_device *pdev) |
diff --git a/drivers/rtc/rtc-stmp3xxx.c b/drivers/rtc/rtc-stmp3xxx.c index 7e7d0c806f2..572e9534b59 100644 --- a/drivers/rtc/rtc-stmp3xxx.c +++ b/drivers/rtc/rtc-stmp3xxx.c | |||
@@ -115,19 +115,6 @@ static int stmp3xxx_alarm_irq_enable(struct device *dev, unsigned int enabled) | |||
115 | return 0; | 115 | return 0; |
116 | } | 116 | } |
117 | 117 | ||
118 | static int stmp3xxx_update_irq_enable(struct device *dev, unsigned int enabled) | ||
119 | { | ||
120 | struct stmp3xxx_rtc_data *rtc_data = dev_get_drvdata(dev); | ||
121 | |||
122 | if (enabled) | ||
123 | stmp3xxx_setl(BM_RTC_CTRL_ONEMSEC_IRQ_EN, | ||
124 | rtc_data->io + HW_RTC_CTRL); | ||
125 | else | ||
126 | stmp3xxx_clearl(BM_RTC_CTRL_ONEMSEC_IRQ_EN, | ||
127 | rtc_data->io + HW_RTC_CTRL); | ||
128 | return 0; | ||
129 | } | ||
130 | |||
131 | static int stmp3xxx_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alm) | 118 | static int stmp3xxx_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alm) |
132 | { | 119 | { |
133 | struct stmp3xxx_rtc_data *rtc_data = dev_get_drvdata(dev); | 120 | struct stmp3xxx_rtc_data *rtc_data = dev_get_drvdata(dev); |
@@ -149,8 +136,6 @@ static int stmp3xxx_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alm) | |||
149 | static struct rtc_class_ops stmp3xxx_rtc_ops = { | 136 | static struct rtc_class_ops stmp3xxx_rtc_ops = { |
150 | .alarm_irq_enable = | 137 | .alarm_irq_enable = |
151 | stmp3xxx_alarm_irq_enable, | 138 | stmp3xxx_alarm_irq_enable, |
152 | .update_irq_enable = | ||
153 | stmp3xxx_update_irq_enable, | ||
154 | .read_time = stmp3xxx_rtc_gettime, | 139 | .read_time = stmp3xxx_rtc_gettime, |
155 | .set_mmss = stmp3xxx_rtc_set_mmss, | 140 | .set_mmss = stmp3xxx_rtc_set_mmss, |
156 | .read_alarm = stmp3xxx_rtc_read_alarm, | 141 | .read_alarm = stmp3xxx_rtc_read_alarm, |
diff --git a/drivers/rtc/rtc-test.c b/drivers/rtc/rtc-test.c index 51725f7755b..7e96254bd36 100644 --- a/drivers/rtc/rtc-test.c +++ b/drivers/rtc/rtc-test.c | |||
@@ -50,24 +50,9 @@ static int test_rtc_proc(struct device *dev, struct seq_file *seq) | |||
50 | return 0; | 50 | return 0; |
51 | } | 51 | } |
52 | 52 | ||
53 | static int test_rtc_ioctl(struct device *dev, unsigned int cmd, | 53 | static int test_rtc_alarm_irq_enable(struct device *dev, unsigned int enable) |
54 | unsigned long arg) | ||
55 | { | 54 | { |
56 | /* We do support interrupts, they're generated | 55 | return 0; |
57 | * using the sysfs interface. | ||
58 | */ | ||
59 | switch (cmd) { | ||
60 | case RTC_PIE_ON: | ||
61 | case RTC_PIE_OFF: | ||
62 | case RTC_UIE_ON: | ||
63 | case RTC_UIE_OFF: | ||
64 | case RTC_AIE_ON: | ||
65 | case RTC_AIE_OFF: | ||
66 | return 0; | ||
67 | |||
68 | default: | ||
69 | return -ENOIOCTLCMD; | ||
70 | } | ||
71 | } | 56 | } |
72 | 57 | ||
73 | static const struct rtc_class_ops test_rtc_ops = { | 58 | static const struct rtc_class_ops test_rtc_ops = { |
@@ -76,7 +61,7 @@ static const struct rtc_class_ops test_rtc_ops = { | |||
76 | .read_alarm = test_rtc_read_alarm, | 61 | .read_alarm = test_rtc_read_alarm, |
77 | .set_alarm = test_rtc_set_alarm, | 62 | .set_alarm = test_rtc_set_alarm, |
78 | .set_mmss = test_rtc_set_mmss, | 63 | .set_mmss = test_rtc_set_mmss, |
79 | .ioctl = test_rtc_ioctl, | 64 | .alarm_irq_enable = test_rtc_alarm_irq_enable, |
80 | }; | 65 | }; |
81 | 66 | ||
82 | static ssize_t test_irq_show(struct device *dev, | 67 | static ssize_t test_irq_show(struct device *dev, |
@@ -93,11 +78,16 @@ static ssize_t test_irq_store(struct device *dev, | |||
93 | struct rtc_device *rtc = platform_get_drvdata(plat_dev); | 78 | struct rtc_device *rtc = platform_get_drvdata(plat_dev); |
94 | 79 | ||
95 | retval = count; | 80 | retval = count; |
96 | if (strncmp(buf, "tick", 4) == 0) | 81 | if (strncmp(buf, "tick", 4) == 0 && rtc->pie_enabled) |
97 | rtc_update_irq(rtc, 1, RTC_PF | RTC_IRQF); | 82 | rtc_update_irq(rtc, 1, RTC_PF | RTC_IRQF); |
98 | else if (strncmp(buf, "alarm", 5) == 0) | 83 | else if (strncmp(buf, "alarm", 5) == 0) { |
99 | rtc_update_irq(rtc, 1, RTC_AF | RTC_IRQF); | 84 | struct rtc_wkalrm alrm; |
100 | else if (strncmp(buf, "update", 6) == 0) | 85 | int err = rtc_read_alarm(rtc, &alrm); |
86 | |||
87 | if (!err && alrm.enabled) | ||
88 | rtc_update_irq(rtc, 1, RTC_AF | RTC_IRQF); | ||
89 | |||
90 | } else if (strncmp(buf, "update", 6) == 0 && rtc->uie_rtctimer.enabled) | ||
101 | rtc_update_irq(rtc, 1, RTC_UF | RTC_IRQF); | 91 | rtc_update_irq(rtc, 1, RTC_UF | RTC_IRQF); |
102 | else | 92 | else |
103 | retval = -EINVAL; | 93 | retval = -EINVAL; |
diff --git a/drivers/rtc/rtc-twl.c b/drivers/rtc/rtc-twl.c index ed1b8682812..f9a2799c44d 100644 --- a/drivers/rtc/rtc-twl.c +++ b/drivers/rtc/rtc-twl.c | |||
@@ -213,18 +213,6 @@ static int twl_rtc_alarm_irq_enable(struct device *dev, unsigned enabled) | |||
213 | return ret; | 213 | return ret; |
214 | } | 214 | } |
215 | 215 | ||
216 | static int twl_rtc_update_irq_enable(struct device *dev, unsigned enabled) | ||
217 | { | ||
218 | int ret; | ||
219 | |||
220 | if (enabled) | ||
221 | ret = set_rtc_irq_bit(BIT_RTC_INTERRUPTS_REG_IT_TIMER_M); | ||
222 | else | ||
223 | ret = mask_rtc_irq_bit(BIT_RTC_INTERRUPTS_REG_IT_TIMER_M); | ||
224 | |||
225 | return ret; | ||
226 | } | ||
227 | |||
228 | /* | 216 | /* |
229 | * Gets current TWL RTC time and date parameters. | 217 | * Gets current TWL RTC time and date parameters. |
230 | * | 218 | * |
@@ -433,7 +421,6 @@ static struct rtc_class_ops twl_rtc_ops = { | |||
433 | .read_alarm = twl_rtc_read_alarm, | 421 | .read_alarm = twl_rtc_read_alarm, |
434 | .set_alarm = twl_rtc_set_alarm, | 422 | .set_alarm = twl_rtc_set_alarm, |
435 | .alarm_irq_enable = twl_rtc_alarm_irq_enable, | 423 | .alarm_irq_enable = twl_rtc_alarm_irq_enable, |
436 | .update_irq_enable = twl_rtc_update_irq_enable, | ||
437 | }; | 424 | }; |
438 | 425 | ||
439 | /*----------------------------------------------------------------------*/ | 426 | /*----------------------------------------------------------------------*/ |
diff --git a/drivers/rtc/rtc-vr41xx.c b/drivers/rtc/rtc-vr41xx.c index c3244244e8c..c5698cda366 100644 --- a/drivers/rtc/rtc-vr41xx.c +++ b/drivers/rtc/rtc-vr41xx.c | |||
@@ -207,59 +207,9 @@ static int vr41xx_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *wkalrm) | |||
207 | return 0; | 207 | return 0; |
208 | } | 208 | } |
209 | 209 | ||
210 | static int vr41xx_rtc_irq_set_freq(struct device *dev, int freq) | ||
211 | { | ||
212 | u64 count; | ||
213 | |||
214 | if (!is_power_of_2(freq)) | ||
215 | return -EINVAL; | ||
216 | count = RTC_FREQUENCY; | ||
217 | do_div(count, freq); | ||
218 | |||
219 | spin_lock_irq(&rtc_lock); | ||
220 | |||
221 | periodic_count = count; | ||
222 | rtc1_write(RTCL1LREG, periodic_count); | ||
223 | rtc1_write(RTCL1HREG, periodic_count >> 16); | ||
224 | |||
225 | spin_unlock_irq(&rtc_lock); | ||
226 | |||
227 | return 0; | ||
228 | } | ||
229 | |||
230 | static int vr41xx_rtc_irq_set_state(struct device *dev, int enabled) | ||
231 | { | ||
232 | if (enabled) | ||
233 | enable_irq(pie_irq); | ||
234 | else | ||
235 | disable_irq(pie_irq); | ||
236 | |||
237 | return 0; | ||
238 | } | ||
239 | |||
240 | static int vr41xx_rtc_ioctl(struct device *dev, unsigned int cmd, unsigned long arg) | 210 | static int vr41xx_rtc_ioctl(struct device *dev, unsigned int cmd, unsigned long arg) |
241 | { | 211 | { |
242 | switch (cmd) { | 212 | switch (cmd) { |
243 | case RTC_AIE_ON: | ||
244 | spin_lock_irq(&rtc_lock); | ||
245 | |||
246 | if (!alarm_enabled) { | ||
247 | enable_irq(aie_irq); | ||
248 | alarm_enabled = 1; | ||
249 | } | ||
250 | |||
251 | spin_unlock_irq(&rtc_lock); | ||
252 | break; | ||
253 | case RTC_AIE_OFF: | ||
254 | spin_lock_irq(&rtc_lock); | ||
255 | |||
256 | if (alarm_enabled) { | ||
257 | disable_irq(aie_irq); | ||
258 | alarm_enabled = 0; | ||
259 | } | ||
260 | |||
261 | spin_unlock_irq(&rtc_lock); | ||
262 | break; | ||
263 | case RTC_EPOCH_READ: | 213 | case RTC_EPOCH_READ: |
264 | return put_user(epoch, (unsigned long __user *)arg); | 214 | return put_user(epoch, (unsigned long __user *)arg); |
265 | case RTC_EPOCH_SET: | 215 | case RTC_EPOCH_SET: |
@@ -275,6 +225,24 @@ static int vr41xx_rtc_ioctl(struct device *dev, unsigned int cmd, unsigned long | |||
275 | return 0; | 225 | return 0; |
276 | } | 226 | } |
277 | 227 | ||
228 | static int vr41xx_rtc_alarm_irq_enable(struct device *dev, unsigned int enabled) | ||
229 | { | ||
230 | spin_lock_irq(&rtc_lock); | ||
231 | if (enabled) { | ||
232 | if (!alarm_enabled) { | ||
233 | enable_irq(aie_irq); | ||
234 | alarm_enabled = 1; | ||
235 | } | ||
236 | } else { | ||
237 | if (alarm_enabled) { | ||
238 | disable_irq(aie_irq); | ||
239 | alarm_enabled = 0; | ||
240 | } | ||
241 | } | ||
242 | spin_unlock_irq(&rtc_lock); | ||
243 | return 0; | ||
244 | } | ||
245 | |||
278 | static irqreturn_t elapsedtime_interrupt(int irq, void *dev_id) | 246 | static irqreturn_t elapsedtime_interrupt(int irq, void *dev_id) |
279 | { | 247 | { |
280 | struct platform_device *pdev = (struct platform_device *)dev_id; | 248 | struct platform_device *pdev = (struct platform_device *)dev_id; |
@@ -310,8 +278,6 @@ static const struct rtc_class_ops vr41xx_rtc_ops = { | |||
310 | .set_time = vr41xx_rtc_set_time, | 278 | .set_time = vr41xx_rtc_set_time, |
311 | .read_alarm = vr41xx_rtc_read_alarm, | 279 | .read_alarm = vr41xx_rtc_read_alarm, |
312 | .set_alarm = vr41xx_rtc_set_alarm, | 280 | .set_alarm = vr41xx_rtc_set_alarm, |
313 | .irq_set_freq = vr41xx_rtc_irq_set_freq, | ||
314 | .irq_set_state = vr41xx_rtc_irq_set_state, | ||
315 | }; | 281 | }; |
316 | 282 | ||
317 | static int __devinit rtc_probe(struct platform_device *pdev) | 283 | static int __devinit rtc_probe(struct platform_device *pdev) |
diff --git a/drivers/rtc/rtc-wm831x.c b/drivers/rtc/rtc-wm831x.c index 82931dc65c0..bdc909bd56d 100644 --- a/drivers/rtc/rtc-wm831x.c +++ b/drivers/rtc/rtc-wm831x.c | |||
@@ -315,21 +315,6 @@ static int wm831x_rtc_alarm_irq_enable(struct device *dev, | |||
315 | return wm831x_rtc_stop_alarm(wm831x_rtc); | 315 | return wm831x_rtc_stop_alarm(wm831x_rtc); |
316 | } | 316 | } |
317 | 317 | ||
318 | static int wm831x_rtc_update_irq_enable(struct device *dev, | ||
319 | unsigned int enabled) | ||
320 | { | ||
321 | struct wm831x_rtc *wm831x_rtc = dev_get_drvdata(dev); | ||
322 | int val; | ||
323 | |||
324 | if (enabled) | ||
325 | val = 1 << WM831X_RTC_PINT_FREQ_SHIFT; | ||
326 | else | ||
327 | val = 0; | ||
328 | |||
329 | return wm831x_set_bits(wm831x_rtc->wm831x, WM831X_RTC_CONTROL, | ||
330 | WM831X_RTC_PINT_FREQ_MASK, val); | ||
331 | } | ||
332 | |||
333 | static irqreturn_t wm831x_alm_irq(int irq, void *data) | 318 | static irqreturn_t wm831x_alm_irq(int irq, void *data) |
334 | { | 319 | { |
335 | struct wm831x_rtc *wm831x_rtc = data; | 320 | struct wm831x_rtc *wm831x_rtc = data; |
@@ -354,7 +339,6 @@ static const struct rtc_class_ops wm831x_rtc_ops = { | |||
354 | .read_alarm = wm831x_rtc_readalarm, | 339 | .read_alarm = wm831x_rtc_readalarm, |
355 | .set_alarm = wm831x_rtc_setalarm, | 340 | .set_alarm = wm831x_rtc_setalarm, |
356 | .alarm_irq_enable = wm831x_rtc_alarm_irq_enable, | 341 | .alarm_irq_enable = wm831x_rtc_alarm_irq_enable, |
357 | .update_irq_enable = wm831x_rtc_update_irq_enable, | ||
358 | }; | 342 | }; |
359 | 343 | ||
360 | #ifdef CONFIG_PM | 344 | #ifdef CONFIG_PM |
diff --git a/drivers/rtc/rtc-wm8350.c b/drivers/rtc/rtc-wm8350.c index 3d0dc76b38a..66421426e40 100644 --- a/drivers/rtc/rtc-wm8350.c +++ b/drivers/rtc/rtc-wm8350.c | |||
@@ -302,26 +302,6 @@ static int wm8350_rtc_setalarm(struct device *dev, struct rtc_wkalrm *alrm) | |||
302 | return ret; | 302 | return ret; |
303 | } | 303 | } |
304 | 304 | ||
305 | static int wm8350_rtc_update_irq_enable(struct device *dev, | ||
306 | unsigned int enabled) | ||
307 | { | ||
308 | struct wm8350 *wm8350 = dev_get_drvdata(dev); | ||
309 | |||
310 | /* Suppress duplicate changes since genirq nests enable and | ||
311 | * disable calls. */ | ||
312 | if (enabled == wm8350->rtc.update_enabled) | ||
313 | return 0; | ||
314 | |||
315 | if (enabled) | ||
316 | wm8350_unmask_irq(wm8350, WM8350_IRQ_RTC_SEC); | ||
317 | else | ||
318 | wm8350_mask_irq(wm8350, WM8350_IRQ_RTC_SEC); | ||
319 | |||
320 | wm8350->rtc.update_enabled = enabled; | ||
321 | |||
322 | return 0; | ||
323 | } | ||
324 | |||
325 | static irqreturn_t wm8350_rtc_alarm_handler(int irq, void *data) | 305 | static irqreturn_t wm8350_rtc_alarm_handler(int irq, void *data) |
326 | { | 306 | { |
327 | struct wm8350 *wm8350 = data; | 307 | struct wm8350 *wm8350 = data; |
@@ -357,7 +337,6 @@ static const struct rtc_class_ops wm8350_rtc_ops = { | |||
357 | .read_alarm = wm8350_rtc_readalarm, | 337 | .read_alarm = wm8350_rtc_readalarm, |
358 | .set_alarm = wm8350_rtc_setalarm, | 338 | .set_alarm = wm8350_rtc_setalarm, |
359 | .alarm_irq_enable = wm8350_rtc_alarm_irq_enable, | 339 | .alarm_irq_enable = wm8350_rtc_alarm_irq_enable, |
360 | .update_irq_enable = wm8350_rtc_update_irq_enable, | ||
361 | }; | 340 | }; |
362 | 341 | ||
363 | #ifdef CONFIG_PM | 342 | #ifdef CONFIG_PM |