aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kernel/hpet.c
diff options
context:
space:
mode:
authorBernhard Walle <bwalle@suse.de>2008-01-30 07:33:28 -0500
committerIngo Molnar <mingo@elte.hu>2008-01-30 07:33:28 -0500
commit1bdbdaacf774f2979ed4cb0c4a4316c9e578c897 (patch)
tree9fd0b72aec27c32288f016790b899a05c25a8f69 /arch/x86/kernel/hpet.c
parent8b2f7ffffe7f247ba237322fee78c528ba88f16b (diff)
x86, rtc: make CONFIG_HPET_EMULATE_RTC usable from modules
enabled, then interrupts don't work for the rtc-cmos driver which results in RTC_AIE*, RTC_PIE* and RTC_ALM being unusable. This affects hwclock from util-linux-ng at least on i386 since that uses RTC_PIE_ON. (For x86-64, a polling method is used for unknown reasons.) This patch series now 1. export the functions from arch/x86/kernel/hpet.c that the old char/rtc driver uses to work around that problem, 2. makes it possible to compile the old rtc driver as module, while still having CONFIG_HPET_EMULATE_RTC enabled and 3. makes use of the exported functions in (1) in the new rtc-cmos driver. This patch: This patch makes the RTC emulation functions in arch/x86/kernel/hpet.c usable for kernel modules. It - exports the functions (EXPORT_SYMBOL_GPL()), - adds an interface to register the interrupt callback function instead of using only a fixed callback function and - replaces the rtc_get_rtc_time() function which depends on CONFIG_RTC with a call to get_rtc_time() which is defined in include/asm-generic/rtc.h. The only dependency to CONFIG_RTC is the call to rtc_interrupt() which is removed by the next patch. After this, there's no (code) dependency of this functions to CONFIG_RTC=y any more. Signed-off-by: Bernhard Walle <bwalle@suse.de> Cc: Alessandro Zummo <a.zummo@towertech.it> Cc: David Brownell <david-b@pacbell.net> Cc: Andi Kleen <ak@suse.de> Cc: john stultz <johnstul@us.ibm.com> Cc: Robert Picco <Robert.Picco@hp.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Ingo Molnar <mingo@elte.hu> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'arch/x86/kernel/hpet.c')
-rw-r--r--arch/x86/kernel/hpet.c47
1 files changed, 46 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}
110EXPORT_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;
489static unsigned long hpet_pie_delta; 491static unsigned long hpet_pie_delta;
490static unsigned long hpet_pie_limit; 492static unsigned long hpet_pie_limit;
491 493
494static rtc_irq_handler irq_handler;
495
496/*
497 * Registers a IRQ handler.
498 */
499int 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}
510EXPORT_SYMBOL_GPL(hpet_register_irq_handler);
511
512/*
513 * Deregisters the IRQ handler registered with hpet_register_irq_handler()
514 * and does cleanup.
515 */
516void 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}
524EXPORT_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}
567EXPORT_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}
582EXPORT_SYMBOL_GPL(hpet_mask_rtc_irq_bit);
547 583
548int hpet_set_rtc_irq_bit(unsigned long bit_mask) 584int 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}
598EXPORT_SYMBOL_GPL(hpet_set_rtc_irq_bit);
562 599
563int hpet_set_alarm_time(unsigned char hrs, unsigned char min, 600int 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}
612EXPORT_SYMBOL_GPL(hpet_set_alarm_time);
575 613
576int hpet_set_periodic_freq(unsigned long freq) 614int 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}
631EXPORT_SYMBOL_GPL(hpet_set_periodic_freq);
593 632
594int hpet_rtc_dropped_irq(void) 633int hpet_rtc_dropped_irq(void)
595{ 634{
596 return is_hpet_enabled(); 635 return is_hpet_enabled();
597} 636}
637EXPORT_SYMBOL_GPL(hpet_rtc_dropped_irq);
598 638
599static void hpet_rtc_timer_reinit(void) 639static 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}
713EXPORT_SYMBOL_GPL(hpet_rtc_interrupt);
669#endif 714#endif