diff options
-rw-r--r-- | arch/x86/kernel/hpet.c | 47 | ||||
-rw-r--r-- | include/asm-x86/hpet.h | 3 |
2 files changed, 49 insertions, 1 deletions
diff --git a/arch/x86/kernel/hpet.c b/arch/x86/kernel/hpet.c index 5c1702789be4..d65ced59a18f 100644 --- a/arch/x86/kernel/hpet.c +++ b/arch/x86/kernel/hpet.c | |||
@@ -107,6 +107,7 @@ int is_hpet_enabled(void) | |||
107 | { | 107 | { |
108 | return is_hpet_capable() && hpet_legacy_int_enabled; | 108 | return is_hpet_capable() && hpet_legacy_int_enabled; |
109 | } | 109 | } |
110 | EXPORT_SYMBOL_GPL(is_hpet_enabled); | ||
110 | 111 | ||
111 | /* | 112 | /* |
112 | * When the hpet driver (/dev/hpet) is enabled, we need to reserve | 113 | * When the hpet driver (/dev/hpet) is enabled, we need to reserve |
@@ -475,6 +476,7 @@ void hpet_disable(void) | |||
475 | */ | 476 | */ |
476 | #include <linux/mc146818rtc.h> | 477 | #include <linux/mc146818rtc.h> |
477 | #include <linux/rtc.h> | 478 | #include <linux/rtc.h> |
479 | #include <asm/rtc.h> | ||
478 | 480 | ||
479 | #define DEFAULT_RTC_INT_FREQ 64 | 481 | #define DEFAULT_RTC_INT_FREQ 64 |
480 | #define DEFAULT_RTC_SHIFT 6 | 482 | #define DEFAULT_RTC_SHIFT 6 |
@@ -489,6 +491,38 @@ static unsigned long hpet_default_delta; | |||
489 | static unsigned long hpet_pie_delta; | 491 | static unsigned long hpet_pie_delta; |
490 | static unsigned long hpet_pie_limit; | 492 | static unsigned long hpet_pie_limit; |
491 | 493 | ||
494 | static rtc_irq_handler irq_handler; | ||
495 | |||
496 | /* | ||
497 | * Registers a IRQ handler. | ||
498 | */ | ||
499 | int hpet_register_irq_handler(rtc_irq_handler handler) | ||
500 | { | ||
501 | if (!is_hpet_enabled()) | ||
502 | return -ENODEV; | ||
503 | if (irq_handler) | ||
504 | return -EBUSY; | ||
505 | |||
506 | irq_handler = handler; | ||
507 | |||
508 | return 0; | ||
509 | } | ||
510 | EXPORT_SYMBOL_GPL(hpet_register_irq_handler); | ||
511 | |||
512 | /* | ||
513 | * Deregisters the IRQ handler registered with hpet_register_irq_handler() | ||
514 | * and does cleanup. | ||
515 | */ | ||
516 | void hpet_unregister_irq_handler(rtc_irq_handler handler) | ||
517 | { | ||
518 | if (!is_hpet_enabled()) | ||
519 | return; | ||
520 | |||
521 | irq_handler = NULL; | ||
522 | hpet_rtc_flags = 0; | ||
523 | } | ||
524 | EXPORT_SYMBOL_GPL(hpet_unregister_irq_handler); | ||
525 | |||
492 | /* | 526 | /* |
493 | * Timer 1 for RTC emulation. We use one shot mode, as periodic mode | 527 | * Timer 1 for RTC emulation. We use one shot mode, as periodic mode |
494 | * is not supported by all HPET implementations for timer 1. | 528 | * is not supported by all HPET implementations for timer 1. |
@@ -530,6 +564,7 @@ int hpet_rtc_timer_init(void) | |||
530 | 564 | ||
531 | return 1; | 565 | return 1; |
532 | } | 566 | } |
567 | EXPORT_SYMBOL_GPL(hpet_rtc_timer_init); | ||
533 | 568 | ||
534 | /* | 569 | /* |
535 | * The functions below are called from rtc driver. | 570 | * The functions below are called from rtc driver. |
@@ -544,6 +579,7 @@ int hpet_mask_rtc_irq_bit(unsigned long bit_mask) | |||
544 | hpet_rtc_flags &= ~bit_mask; | 579 | hpet_rtc_flags &= ~bit_mask; |
545 | return 1; | 580 | return 1; |
546 | } | 581 | } |
582 | EXPORT_SYMBOL_GPL(hpet_mask_rtc_irq_bit); | ||
547 | 583 | ||
548 | int hpet_set_rtc_irq_bit(unsigned long bit_mask) | 584 | int hpet_set_rtc_irq_bit(unsigned long bit_mask) |
549 | { | 585 | { |
@@ -559,6 +595,7 @@ int hpet_set_rtc_irq_bit(unsigned long bit_mask) | |||
559 | 595 | ||
560 | return 1; | 596 | return 1; |
561 | } | 597 | } |
598 | EXPORT_SYMBOL_GPL(hpet_set_rtc_irq_bit); | ||
562 | 599 | ||
563 | int hpet_set_alarm_time(unsigned char hrs, unsigned char min, | 600 | int hpet_set_alarm_time(unsigned char hrs, unsigned char min, |
564 | unsigned char sec) | 601 | unsigned char sec) |
@@ -572,6 +609,7 @@ int hpet_set_alarm_time(unsigned char hrs, unsigned char min, | |||
572 | 609 | ||
573 | return 1; | 610 | return 1; |
574 | } | 611 | } |
612 | EXPORT_SYMBOL_GPL(hpet_set_alarm_time); | ||
575 | 613 | ||
576 | int hpet_set_periodic_freq(unsigned long freq) | 614 | int hpet_set_periodic_freq(unsigned long freq) |
577 | { | 615 | { |
@@ -590,11 +628,13 @@ int hpet_set_periodic_freq(unsigned long freq) | |||
590 | } | 628 | } |
591 | return 1; | 629 | return 1; |
592 | } | 630 | } |
631 | EXPORT_SYMBOL_GPL(hpet_set_periodic_freq); | ||
593 | 632 | ||
594 | int hpet_rtc_dropped_irq(void) | 633 | int hpet_rtc_dropped_irq(void) |
595 | { | 634 | { |
596 | return is_hpet_enabled(); | 635 | return is_hpet_enabled(); |
597 | } | 636 | } |
637 | EXPORT_SYMBOL_GPL(hpet_rtc_dropped_irq); | ||
598 | 638 | ||
599 | static void hpet_rtc_timer_reinit(void) | 639 | static void hpet_rtc_timer_reinit(void) |
600 | { | 640 | { |
@@ -638,9 +678,10 @@ irqreturn_t hpet_rtc_interrupt(int irq, void *dev_id) | |||
638 | unsigned long rtc_int_flag = 0; | 678 | unsigned long rtc_int_flag = 0; |
639 | 679 | ||
640 | hpet_rtc_timer_reinit(); | 680 | hpet_rtc_timer_reinit(); |
681 | memset(&curr_time, 0, sizeof(struct rtc_time)); | ||
641 | 682 | ||
642 | if (hpet_rtc_flags & (RTC_UIE | RTC_AIE)) | 683 | if (hpet_rtc_flags & (RTC_UIE | RTC_AIE)) |
643 | rtc_get_rtc_time(&curr_time); | 684 | get_rtc_time(&curr_time); |
644 | 685 | ||
645 | if (hpet_rtc_flags & RTC_UIE && | 686 | if (hpet_rtc_flags & RTC_UIE && |
646 | curr_time.tm_sec != hpet_prev_update_sec) { | 687 | curr_time.tm_sec != hpet_prev_update_sec) { |
@@ -662,8 +703,12 @@ irqreturn_t hpet_rtc_interrupt(int irq, void *dev_id) | |||
662 | 703 | ||
663 | if (rtc_int_flag) { | 704 | if (rtc_int_flag) { |
664 | rtc_int_flag |= (RTC_IRQF | (RTC_NUM_INTS << 8)); | 705 | rtc_int_flag |= (RTC_IRQF | (RTC_NUM_INTS << 8)); |
706 | if (irq_handler) | ||
707 | irq_handler(rtc_int_flag, dev_id); | ||
708 | |||
665 | rtc_interrupt(rtc_int_flag, dev_id); | 709 | rtc_interrupt(rtc_int_flag, dev_id); |
666 | } | 710 | } |
667 | return IRQ_HANDLED; | 711 | return IRQ_HANDLED; |
668 | } | 712 | } |
713 | EXPORT_SYMBOL_GPL(hpet_rtc_interrupt); | ||
669 | #endif | 714 | #endif |
diff --git a/include/asm-x86/hpet.h b/include/asm-x86/hpet.h index 624f600f7161..6a9b4ac59bf7 100644 --- a/include/asm-x86/hpet.h +++ b/include/asm-x86/hpet.h | |||
@@ -69,6 +69,7 @@ extern void force_hpet_resume(void); | |||
69 | 69 | ||
70 | #include <linux/interrupt.h> | 70 | #include <linux/interrupt.h> |
71 | 71 | ||
72 | typedef irqreturn_t (*rtc_irq_handler)(int interrupt, void *cookie); | ||
72 | extern int hpet_mask_rtc_irq_bit(unsigned long bit_mask); | 73 | extern int hpet_mask_rtc_irq_bit(unsigned long bit_mask); |
73 | extern int hpet_set_rtc_irq_bit(unsigned long bit_mask); | 74 | extern int hpet_set_rtc_irq_bit(unsigned long bit_mask); |
74 | extern int hpet_set_alarm_time(unsigned char hrs, unsigned char min, | 75 | extern int hpet_set_alarm_time(unsigned char hrs, unsigned char min, |
@@ -77,6 +78,8 @@ extern int hpet_set_periodic_freq(unsigned long freq); | |||
77 | extern int hpet_rtc_dropped_irq(void); | 78 | extern int hpet_rtc_dropped_irq(void); |
78 | extern int hpet_rtc_timer_init(void); | 79 | extern int hpet_rtc_timer_init(void); |
79 | extern irqreturn_t hpet_rtc_interrupt(int irq, void *dev_id); | 80 | extern irqreturn_t hpet_rtc_interrupt(int irq, void *dev_id); |
81 | extern int hpet_register_irq_handler(rtc_irq_handler handler); | ||
82 | extern void hpet_unregister_irq_handler(rtc_irq_handler handler); | ||
80 | 83 | ||
81 | #endif /* CONFIG_HPET_EMULATE_RTC */ | 84 | #endif /* CONFIG_HPET_EMULATE_RTC */ |
82 | 85 | ||