aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86
diff options
context:
space:
mode:
authorThomas Gleixner <tglx@linutronix.de>2007-10-12 17:04:06 -0400
committerThomas Gleixner <tglx@inhelltoy.tec.linutronix.de>2007-10-12 17:04:06 -0400
commit06a24dec10bc4014fc0974670627efed68f5da27 (patch)
tree9cd0e96fca88a7875d15af6b506b723f0d3e9d00 /arch/x86
parentd371698efd45c3664fd1726780c360f02e1f9580 (diff)
i386: prepare sharing the hpet code with x86_64
The hpet implementations of i386 and x8664 has been mostly the same before the clock events conversion of i386. The clock events conversion of i386 hpet is already done. So it makes sense to share the code for the x86_64 clock events conversion. Abstract out the mapping functions. Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: Chris Wright <chrisw@sous-sol.org> Signed-off-by: Ingo Molnar <mingo@elte.hu> Signed-off-by: Arjan van de Ven <arjan@linux.intel.com>
Diffstat (limited to 'arch/x86')
-rw-r--r--arch/x86/kernel/hpet_32.c24
1 files changed, 16 insertions, 8 deletions
diff --git a/arch/x86/kernel/hpet_32.c b/arch/x86/kernel/hpet_32.c
index 533d4932bc7..748abf0286d 100644
--- a/arch/x86/kernel/hpet_32.c
+++ b/arch/x86/kernel/hpet_32.c
@@ -8,10 +8,9 @@
8#include <linux/delay.h> 8#include <linux/delay.h>
9 9
10#include <asm/hpet.h> 10#include <asm/hpet.h>
11#include <asm/i8253.h>
11#include <asm/io.h> 12#include <asm/io.h>
12 13
13extern struct clock_event_device *global_clock_event;
14
15#define HPET_MASK CLOCKSOURCE_MASK(32) 14#define HPET_MASK CLOCKSOURCE_MASK(32)
16#define HPET_SHIFT 22 15#define HPET_SHIFT 22
17 16
@@ -22,7 +21,7 @@ extern struct clock_event_device *global_clock_event;
22 * HPET address is set in acpi/boot.c, when an ACPI entry exists 21 * HPET address is set in acpi/boot.c, when an ACPI entry exists
23 */ 22 */
24unsigned long hpet_address; 23unsigned long hpet_address;
25static void __iomem * hpet_virt_address; 24static void __iomem *hpet_virt_address;
26 25
27static inline unsigned long hpet_readl(unsigned long a) 26static inline unsigned long hpet_readl(unsigned long a)
28{ 27{
@@ -34,6 +33,17 @@ static inline void hpet_writel(unsigned long d, unsigned long a)
34 writel(d, hpet_virt_address + a); 33 writel(d, hpet_virt_address + a);
35} 34}
36 35
36static inline void hpet_set_mapping(void)
37{
38 hpet_virt_address = ioremap_nocache(hpet_address, HPET_MMAP_SIZE);
39}
40
41static inline void hpet_clear_mapping(void)
42{
43 iounmap(hpet_virt_address);
44 hpet_virt_address = NULL;
45}
46
37/* 47/*
38 * HPET command line enable / disable 48 * HPET command line enable / disable
39 */ 49 */
@@ -83,7 +93,7 @@ static void hpet_reserve_platform_timers(unsigned long id)
83 93
84 memset(&hd, 0, sizeof (hd)); 94 memset(&hd, 0, sizeof (hd));
85 hd.hd_phys_address = hpet_address; 95 hd.hd_phys_address = hpet_address;
86 hd.hd_address = hpet_virt_address; 96 hd.hd_address = hpet;
87 hd.hd_nirqs = nrtimers; 97 hd.hd_nirqs = nrtimers;
88 hd.hd_flags = HPET_DATA_PLATFORM; 98 hd.hd_flags = HPET_DATA_PLATFORM;
89 hpet_reserve_timer(&hd, 0); 99 hpet_reserve_timer(&hd, 0);
@@ -238,7 +248,7 @@ int __init hpet_enable(void)
238 if (!is_hpet_capable()) 248 if (!is_hpet_capable())
239 return 0; 249 return 0;
240 250
241 hpet_virt_address = ioremap_nocache(hpet_address, HPET_MMAP_SIZE); 251 hpet_set_mapping();
242 252
243 /* 253 /*
244 * Read the period and check for a sane value: 254 * Read the period and check for a sane value:
@@ -334,13 +344,11 @@ int __init hpet_enable(void)
334 return 0; 344 return 0;
335 345
336out_nohpet: 346out_nohpet:
337 iounmap(hpet_virt_address); 347 hpet_clear_mapping();
338 hpet_virt_address = NULL;
339 boot_hpet_disable = 1; 348 boot_hpet_disable = 1;
340 return 0; 349 return 0;
341} 350}
342 351
343
344#ifdef CONFIG_HPET_EMULATE_RTC 352#ifdef CONFIG_HPET_EMULATE_RTC
345 353
346/* HPET in LegacyReplacement Mode eats up RTC interrupt line. When, HPET 354/* HPET in LegacyReplacement Mode eats up RTC interrupt line. When, HPET