Commit 06a24dec authored by Thomas Gleixner's avatar Thomas Gleixner Committed by Thomas Gleixner

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: default avatarThomas Gleixner <tglx@linutronix.de>
Signed-off-by: default avatarChris Wright <chrisw@sous-sol.org>
Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
Signed-off-by: default avatarArjan van de Ven <arjan@linux.intel.com>
parent d371698e
...@@ -8,10 +8,9 @@ ...@@ -8,10 +8,9 @@
#include <linux/delay.h> #include <linux/delay.h>
#include <asm/hpet.h> #include <asm/hpet.h>
#include <asm/i8253.h>
#include <asm/io.h> #include <asm/io.h>
extern struct clock_event_device *global_clock_event;
#define HPET_MASK CLOCKSOURCE_MASK(32) #define HPET_MASK CLOCKSOURCE_MASK(32)
#define HPET_SHIFT 22 #define HPET_SHIFT 22
...@@ -22,7 +21,7 @@ extern struct clock_event_device *global_clock_event; ...@@ -22,7 +21,7 @@ extern struct clock_event_device *global_clock_event;
* HPET address is set in acpi/boot.c, when an ACPI entry exists * HPET address is set in acpi/boot.c, when an ACPI entry exists
*/ */
unsigned long hpet_address; unsigned long hpet_address;
static void __iomem * hpet_virt_address; static void __iomem *hpet_virt_address;
static inline unsigned long hpet_readl(unsigned long a) static inline unsigned long hpet_readl(unsigned long a)
{ {
...@@ -34,6 +33,17 @@ static inline void hpet_writel(unsigned long d, unsigned long a) ...@@ -34,6 +33,17 @@ static inline void hpet_writel(unsigned long d, unsigned long a)
writel(d, hpet_virt_address + a); writel(d, hpet_virt_address + a);
} }
static inline void hpet_set_mapping(void)
{
hpet_virt_address = ioremap_nocache(hpet_address, HPET_MMAP_SIZE);
}
static inline void hpet_clear_mapping(void)
{
iounmap(hpet_virt_address);
hpet_virt_address = NULL;
}
/* /*
* HPET command line enable / disable * HPET command line enable / disable
*/ */
...@@ -83,7 +93,7 @@ static void hpet_reserve_platform_timers(unsigned long id) ...@@ -83,7 +93,7 @@ static void hpet_reserve_platform_timers(unsigned long id)
memset(&hd, 0, sizeof (hd)); memset(&hd, 0, sizeof (hd));
hd.hd_phys_address = hpet_address; hd.hd_phys_address = hpet_address;
hd.hd_address = hpet_virt_address; hd.hd_address = hpet;
hd.hd_nirqs = nrtimers; hd.hd_nirqs = nrtimers;
hd.hd_flags = HPET_DATA_PLATFORM; hd.hd_flags = HPET_DATA_PLATFORM;
hpet_reserve_timer(&hd, 0); hpet_reserve_timer(&hd, 0);
...@@ -238,7 +248,7 @@ int __init hpet_enable(void) ...@@ -238,7 +248,7 @@ int __init hpet_enable(void)
if (!is_hpet_capable()) if (!is_hpet_capable())
return 0; return 0;
hpet_virt_address = ioremap_nocache(hpet_address, HPET_MMAP_SIZE); hpet_set_mapping();
/* /*
* Read the period and check for a sane value: * Read the period and check for a sane value:
...@@ -334,13 +344,11 @@ int __init hpet_enable(void) ...@@ -334,13 +344,11 @@ int __init hpet_enable(void)
return 0; return 0;
out_nohpet: out_nohpet:
iounmap(hpet_virt_address); hpet_clear_mapping();
hpet_virt_address = NULL;
boot_hpet_disable = 1; boot_hpet_disable = 1;
return 0; return 0;
} }
#ifdef CONFIG_HPET_EMULATE_RTC #ifdef CONFIG_HPET_EMULATE_RTC
/* HPET in LegacyReplacement Mode eats up RTC interrupt line. When, HPET /* HPET in LegacyReplacement Mode eats up RTC interrupt line. When, HPET
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment