提交 1bdbdaac 编写于 作者: B Bernhard Walle 提交者: Ingo Molnar

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: NBernhard 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: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NIngo Molnar <mingo@elte.hu>
Signed-off-by: NThomas Gleixner <tglx@linutronix.de>
上级 8b2f7fff
...@@ -107,6 +107,7 @@ int is_hpet_enabled(void) ...@@ -107,6 +107,7 @@ int is_hpet_enabled(void)
{ {
return is_hpet_capable() && hpet_legacy_int_enabled; return is_hpet_capable() && hpet_legacy_int_enabled;
} }
EXPORT_SYMBOL_GPL(is_hpet_enabled);
/* /*
* When the hpet driver (/dev/hpet) is enabled, we need to reserve * When the hpet driver (/dev/hpet) is enabled, we need to reserve
...@@ -475,6 +476,7 @@ void hpet_disable(void) ...@@ -475,6 +476,7 @@ void hpet_disable(void)
*/ */
#include <linux/mc146818rtc.h> #include <linux/mc146818rtc.h>
#include <linux/rtc.h> #include <linux/rtc.h>
#include <asm/rtc.h>
#define DEFAULT_RTC_INT_FREQ 64 #define DEFAULT_RTC_INT_FREQ 64
#define DEFAULT_RTC_SHIFT 6 #define DEFAULT_RTC_SHIFT 6
...@@ -489,6 +491,38 @@ static unsigned long hpet_default_delta; ...@@ -489,6 +491,38 @@ static unsigned long hpet_default_delta;
static unsigned long hpet_pie_delta; static unsigned long hpet_pie_delta;
static unsigned long hpet_pie_limit; static unsigned long hpet_pie_limit;
static rtc_irq_handler irq_handler;
/*
* Registers a IRQ handler.
*/
int hpet_register_irq_handler(rtc_irq_handler handler)
{
if (!is_hpet_enabled())
return -ENODEV;
if (irq_handler)
return -EBUSY;
irq_handler = handler;
return 0;
}
EXPORT_SYMBOL_GPL(hpet_register_irq_handler);
/*
* Deregisters the IRQ handler registered with hpet_register_irq_handler()
* and does cleanup.
*/
void hpet_unregister_irq_handler(rtc_irq_handler handler)
{
if (!is_hpet_enabled())
return;
irq_handler = NULL;
hpet_rtc_flags = 0;
}
EXPORT_SYMBOL_GPL(hpet_unregister_irq_handler);
/* /*
* Timer 1 for RTC emulation. We use one shot mode, as periodic mode * Timer 1 for RTC emulation. We use one shot mode, as periodic mode
* is not supported by all HPET implementations for timer 1. * is not supported by all HPET implementations for timer 1.
...@@ -530,6 +564,7 @@ int hpet_rtc_timer_init(void) ...@@ -530,6 +564,7 @@ int hpet_rtc_timer_init(void)
return 1; return 1;
} }
EXPORT_SYMBOL_GPL(hpet_rtc_timer_init);
/* /*
* The functions below are called from rtc driver. * The functions below are called from rtc driver.
...@@ -544,6 +579,7 @@ int hpet_mask_rtc_irq_bit(unsigned long bit_mask) ...@@ -544,6 +579,7 @@ int hpet_mask_rtc_irq_bit(unsigned long bit_mask)
hpet_rtc_flags &= ~bit_mask; hpet_rtc_flags &= ~bit_mask;
return 1; return 1;
} }
EXPORT_SYMBOL_GPL(hpet_mask_rtc_irq_bit);
int hpet_set_rtc_irq_bit(unsigned long bit_mask) int hpet_set_rtc_irq_bit(unsigned long bit_mask)
{ {
...@@ -559,6 +595,7 @@ int hpet_set_rtc_irq_bit(unsigned long bit_mask) ...@@ -559,6 +595,7 @@ int hpet_set_rtc_irq_bit(unsigned long bit_mask)
return 1; return 1;
} }
EXPORT_SYMBOL_GPL(hpet_set_rtc_irq_bit);
int hpet_set_alarm_time(unsigned char hrs, unsigned char min, int hpet_set_alarm_time(unsigned char hrs, unsigned char min,
unsigned char sec) unsigned char sec)
...@@ -572,6 +609,7 @@ int hpet_set_alarm_time(unsigned char hrs, unsigned char min, ...@@ -572,6 +609,7 @@ int hpet_set_alarm_time(unsigned char hrs, unsigned char min,
return 1; return 1;
} }
EXPORT_SYMBOL_GPL(hpet_set_alarm_time);
int hpet_set_periodic_freq(unsigned long freq) int hpet_set_periodic_freq(unsigned long freq)
{ {
...@@ -590,11 +628,13 @@ int hpet_set_periodic_freq(unsigned long freq) ...@@ -590,11 +628,13 @@ int hpet_set_periodic_freq(unsigned long freq)
} }
return 1; return 1;
} }
EXPORT_SYMBOL_GPL(hpet_set_periodic_freq);
int hpet_rtc_dropped_irq(void) int hpet_rtc_dropped_irq(void)
{ {
return is_hpet_enabled(); return is_hpet_enabled();
} }
EXPORT_SYMBOL_GPL(hpet_rtc_dropped_irq);
static void hpet_rtc_timer_reinit(void) static void hpet_rtc_timer_reinit(void)
{ {
...@@ -638,9 +678,10 @@ irqreturn_t hpet_rtc_interrupt(int irq, void *dev_id) ...@@ -638,9 +678,10 @@ irqreturn_t hpet_rtc_interrupt(int irq, void *dev_id)
unsigned long rtc_int_flag = 0; unsigned long rtc_int_flag = 0;
hpet_rtc_timer_reinit(); hpet_rtc_timer_reinit();
memset(&curr_time, 0, sizeof(struct rtc_time));
if (hpet_rtc_flags & (RTC_UIE | RTC_AIE)) if (hpet_rtc_flags & (RTC_UIE | RTC_AIE))
rtc_get_rtc_time(&curr_time); get_rtc_time(&curr_time);
if (hpet_rtc_flags & RTC_UIE && if (hpet_rtc_flags & RTC_UIE &&
curr_time.tm_sec != hpet_prev_update_sec) { curr_time.tm_sec != hpet_prev_update_sec) {
...@@ -662,8 +703,12 @@ irqreturn_t hpet_rtc_interrupt(int irq, void *dev_id) ...@@ -662,8 +703,12 @@ irqreturn_t hpet_rtc_interrupt(int irq, void *dev_id)
if (rtc_int_flag) { if (rtc_int_flag) {
rtc_int_flag |= (RTC_IRQF | (RTC_NUM_INTS << 8)); rtc_int_flag |= (RTC_IRQF | (RTC_NUM_INTS << 8));
if (irq_handler)
irq_handler(rtc_int_flag, dev_id);
rtc_interrupt(rtc_int_flag, dev_id); rtc_interrupt(rtc_int_flag, dev_id);
} }
return IRQ_HANDLED; return IRQ_HANDLED;
} }
EXPORT_SYMBOL_GPL(hpet_rtc_interrupt);
#endif #endif
...@@ -69,6 +69,7 @@ extern void force_hpet_resume(void); ...@@ -69,6 +69,7 @@ extern void force_hpet_resume(void);
#include <linux/interrupt.h> #include <linux/interrupt.h>
typedef irqreturn_t (*rtc_irq_handler)(int interrupt, void *cookie);
extern int hpet_mask_rtc_irq_bit(unsigned long bit_mask); extern int hpet_mask_rtc_irq_bit(unsigned long bit_mask);
extern int hpet_set_rtc_irq_bit(unsigned long bit_mask); extern int hpet_set_rtc_irq_bit(unsigned long bit_mask);
extern int hpet_set_alarm_time(unsigned char hrs, unsigned char min, 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,6 +78,8 @@ extern int hpet_set_periodic_freq(unsigned long freq);
extern int hpet_rtc_dropped_irq(void); extern int hpet_rtc_dropped_irq(void);
extern int hpet_rtc_timer_init(void); extern int hpet_rtc_timer_init(void);
extern irqreturn_t hpet_rtc_interrupt(int irq, void *dev_id); extern irqreturn_t hpet_rtc_interrupt(int irq, void *dev_id);
extern int hpet_register_irq_handler(rtc_irq_handler handler);
extern void hpet_unregister_irq_handler(rtc_irq_handler handler);
#endif /* CONFIG_HPET_EMULATE_RTC */ #endif /* CONFIG_HPET_EMULATE_RTC */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册