diff options
-rw-r--r-- | arch/i386/kernel/hpet.c | 1 | ||||
-rw-r--r-- | include/asm-i386/hpet.h | 126 | ||||
-rw-r--r-- | include/asm-x86_64/hpet.h | 61 |
3 files changed, 50 insertions, 138 deletions
diff --git a/arch/i386/kernel/hpet.c b/arch/i386/kernel/hpet.c index cfbf792a0bf4..662d7976a9ea 100644 --- a/arch/i386/kernel/hpet.c +++ b/arch/i386/kernel/hpet.c | |||
@@ -5,6 +5,7 @@ | |||
5 | #include <linux/init.h> | 5 | #include <linux/init.h> |
6 | #include <linux/sysdev.h> | 6 | #include <linux/sysdev.h> |
7 | #include <linux/pm.h> | 7 | #include <linux/pm.h> |
8 | #include <linux/delay.h> | ||
8 | 9 | ||
9 | #include <asm/hpet.h> | 10 | #include <asm/hpet.h> |
10 | #include <asm/io.h> | 11 | #include <asm/io.h> |
diff --git a/include/asm-i386/hpet.h b/include/asm-i386/hpet.h index dddeedf504b7..c82dc7ed96b3 100644 --- a/include/asm-i386/hpet.h +++ b/include/asm-i386/hpet.h | |||
@@ -4,112 +4,82 @@ | |||
4 | 4 | ||
5 | #ifdef CONFIG_HPET_TIMER | 5 | #ifdef CONFIG_HPET_TIMER |
6 | 6 | ||
7 | #include <linux/errno.h> | ||
8 | #include <linux/module.h> | ||
9 | #include <linux/sched.h> | ||
10 | #include <linux/kernel.h> | ||
11 | #include <linux/param.h> | ||
12 | #include <linux/string.h> | ||
13 | #include <linux/mm.h> | ||
14 | #include <linux/interrupt.h> | ||
15 | #include <linux/time.h> | ||
16 | #include <linux/delay.h> | ||
17 | #include <linux/init.h> | ||
18 | #include <linux/smp.h> | ||
19 | |||
20 | #include <asm/io.h> | ||
21 | #include <asm/smp.h> | ||
22 | #include <asm/irq.h> | ||
23 | #include <asm/msr.h> | ||
24 | #include <asm/delay.h> | ||
25 | #include <asm/mpspec.h> | ||
26 | #include <asm/uaccess.h> | ||
27 | #include <asm/processor.h> | ||
28 | |||
29 | #include <linux/timex.h> | ||
30 | |||
31 | /* | 7 | /* |
32 | * Documentation on HPET can be found at: | 8 | * Documentation on HPET can be found at: |
33 | * http://www.intel.com/ial/home/sp/pcmmspec.htm | 9 | * http://www.intel.com/ial/home/sp/pcmmspec.htm |
34 | * ftp://download.intel.com/ial/home/sp/mmts098.pdf | 10 | * ftp://download.intel.com/ial/home/sp/mmts098.pdf |
35 | */ | 11 | */ |
36 | 12 | ||
37 | #define HPET_MMAP_SIZE 1024 | 13 | #define HPET_MMAP_SIZE 1024 |
38 | 14 | ||
39 | #define HPET_ID 0x000 | 15 | #define HPET_ID 0x000 |
40 | #define HPET_PERIOD 0x004 | 16 | #define HPET_PERIOD 0x004 |
41 | #define HPET_CFG 0x010 | 17 | #define HPET_CFG 0x010 |
42 | #define HPET_STATUS 0x020 | 18 | #define HPET_STATUS 0x020 |
43 | #define HPET_COUNTER 0x0f0 | 19 | #define HPET_COUNTER 0x0f0 |
44 | #define HPET_T0_CFG 0x100 | 20 | #define HPET_T0_CFG 0x100 |
45 | #define HPET_T0_CMP 0x108 | 21 | #define HPET_T0_CMP 0x108 |
46 | #define HPET_T0_ROUTE 0x110 | 22 | #define HPET_T0_ROUTE 0x110 |
47 | #define HPET_T1_CFG 0x120 | 23 | #define HPET_T1_CFG 0x120 |
48 | #define HPET_T1_CMP 0x128 | 24 | #define HPET_T1_CMP 0x128 |
49 | #define HPET_T1_ROUTE 0x130 | 25 | #define HPET_T1_ROUTE 0x130 |
50 | #define HPET_T2_CFG 0x140 | 26 | #define HPET_T2_CFG 0x140 |
51 | #define HPET_T2_CMP 0x148 | 27 | #define HPET_T2_CMP 0x148 |
52 | #define HPET_T2_ROUTE 0x150 | 28 | #define HPET_T2_ROUTE 0x150 |
53 | 29 | ||
54 | #define HPET_ID_LEGSUP 0x00008000 | 30 | #define HPET_ID_REV 0x000000ff |
55 | #define HPET_ID_NUMBER 0x00001f00 | 31 | #define HPET_ID_NUMBER 0x00001f00 |
56 | #define HPET_ID_REV 0x000000ff | 32 | #define HPET_ID_64BIT 0x00002000 |
33 | #define HPET_ID_LEGSUP 0x00008000 | ||
34 | #define HPET_ID_VENDOR 0xffff0000 | ||
57 | #define HPET_ID_NUMBER_SHIFT 8 | 35 | #define HPET_ID_NUMBER_SHIFT 8 |
36 | #define HPET_ID_VENDOR_SHIFT 16 | ||
58 | 37 | ||
59 | #define HPET_CFG_ENABLE 0x001 | 38 | #define HPET_ID_VENDOR_8086 0x8086 |
60 | #define HPET_CFG_LEGACY 0x002 | 39 | |
40 | #define HPET_CFG_ENABLE 0x001 | ||
41 | #define HPET_CFG_LEGACY 0x002 | ||
61 | #define HPET_LEGACY_8254 2 | 42 | #define HPET_LEGACY_8254 2 |
62 | #define HPET_LEGACY_RTC 8 | 43 | #define HPET_LEGACY_RTC 8 |
63 | 44 | ||
64 | #define HPET_TN_ENABLE 0x004 | 45 | #define HPET_TN_LEVEL 0x0002 |
65 | #define HPET_TN_PERIODIC 0x008 | 46 | #define HPET_TN_ENABLE 0x0004 |
66 | #define HPET_TN_PERIODIC_CAP 0x010 | 47 | #define HPET_TN_PERIODIC 0x0008 |
67 | #define HPET_TN_SETVAL 0x040 | 48 | #define HPET_TN_PERIODIC_CAP 0x0010 |
68 | #define HPET_TN_32BIT 0x100 | 49 | #define HPET_TN_64BIT_CAP 0x0020 |
69 | 50 | #define HPET_TN_SETVAL 0x0040 | |
70 | /* Use our own asm for 64 bit multiply/divide */ | 51 | #define HPET_TN_32BIT 0x0100 |
71 | #define ASM_MUL64_REG(eax_out,edx_out,reg_in,eax_in) \ | 52 | #define HPET_TN_ROUTE 0x3e00 |
72 | __asm__ __volatile__("mull %2" \ | 53 | #define HPET_TN_FSB 0x4000 |
73 | :"=a" (eax_out), "=d" (edx_out) \ | 54 | #define HPET_TN_FSB_CAP 0x8000 |
74 | :"r" (reg_in), "0" (eax_in)) | 55 | #define HPET_TN_ROUTE_SHIFT 9 |
75 | 56 | ||
76 | #define ASM_DIV64_REG(eax_out,edx_out,reg_in,eax_in,edx_in) \ | ||
77 | __asm__ __volatile__("divl %2" \ | ||
78 | :"=a" (eax_out), "=d" (edx_out) \ | ||
79 | :"r" (reg_in), "0" (eax_in), "1" (edx_in)) | ||
80 | |||
81 | #define KERNEL_TICK_USEC (1000000UL/HZ) /* tick value in microsec */ | ||
82 | /* Max HPET Period is 10^8 femto sec as in HPET spec */ | 57 | /* Max HPET Period is 10^8 femto sec as in HPET spec */ |
83 | #define HPET_MAX_PERIOD (100000000UL) | 58 | #define HPET_MAX_PERIOD 100000000UL |
84 | /* | 59 | /* |
85 | * Min HPET period is 10^5 femto sec just for safety. If it is less than this, | 60 | * Min HPET period is 10^5 femto sec just for safety. If it is less than this, |
86 | * then 32 bit HPET counter wrapsaround in less than 0.5 sec. | 61 | * then 32 bit HPET counter wrapsaround in less than 0.5 sec. |
87 | */ | 62 | */ |
88 | #define HPET_MIN_PERIOD (100000UL) | 63 | #define HPET_MIN_PERIOD 100000UL |
89 | #define HPET_TICK_RATE (HZ * 100000UL) | ||
90 | 64 | ||
91 | extern unsigned long hpet_address; /* hpet memory map physical address */ | 65 | /* hpet memory map physical address */ |
66 | extern unsigned long hpet_address; | ||
92 | extern int is_hpet_enabled(void); | 67 | extern int is_hpet_enabled(void); |
93 | |||
94 | #ifdef CONFIG_X86_64 | ||
95 | extern unsigned long hpet_tick; /* hpet clks count per tick */ | ||
96 | extern int hpet_use_timer; | ||
97 | extern int hpet_rtc_timer_init(void); | ||
98 | extern int hpet_enable(void); | 68 | extern int hpet_enable(void); |
99 | extern int is_hpet_capable(void); | ||
100 | extern int hpet_readl(unsigned long a); | ||
101 | #else | ||
102 | extern int hpet_enable(void); | ||
103 | #endif | ||
104 | 69 | ||
105 | #ifdef CONFIG_HPET_EMULATE_RTC | 70 | #ifdef CONFIG_HPET_EMULATE_RTC |
71 | |||
72 | #include <linux/interrupt.h> | ||
73 | |||
106 | extern int hpet_mask_rtc_irq_bit(unsigned long bit_mask); | 74 | extern int hpet_mask_rtc_irq_bit(unsigned long bit_mask); |
107 | extern int hpet_set_rtc_irq_bit(unsigned long bit_mask); | 75 | extern int hpet_set_rtc_irq_bit(unsigned long bit_mask); |
108 | extern int hpet_set_alarm_time(unsigned char hrs, unsigned char min, unsigned char sec); | 76 | extern int hpet_set_alarm_time(unsigned char hrs, unsigned char min, |
77 | unsigned char sec); | ||
109 | extern int hpet_set_periodic_freq(unsigned long freq); | 78 | extern int hpet_set_periodic_freq(unsigned long freq); |
110 | extern int hpet_rtc_dropped_irq(void); | 79 | extern int hpet_rtc_dropped_irq(void); |
111 | extern int hpet_rtc_timer_init(void); | 80 | extern int hpet_rtc_timer_init(void); |
112 | extern irqreturn_t hpet_rtc_interrupt(int irq, void *dev_id); | 81 | extern irqreturn_t hpet_rtc_interrupt(int irq, void *dev_id); |
82 | |||
113 | #endif /* CONFIG_HPET_EMULATE_RTC */ | 83 | #endif /* CONFIG_HPET_EMULATE_RTC */ |
114 | 84 | ||
115 | #else | 85 | #else |
diff --git a/include/asm-x86_64/hpet.h b/include/asm-x86_64/hpet.h index 71ccdd11d7f0..79bb950f82c5 100644 --- a/include/asm-x86_64/hpet.h +++ b/include/asm-x86_64/hpet.h | |||
@@ -1,59 +1,10 @@ | |||
1 | #ifndef _ASM_X8664_HPET_H | 1 | #ifndef _ASM_X8664_HPET_H |
2 | #define _ASM_X8664_HPET_H 1 | 2 | #define _ASM_X8664_HPET_H 1 |
3 | 3 | ||
4 | /* | 4 | #include <asm-i386/hpet.h> |
5 | * Documentation on HPET can be found at: | ||
6 | * http://www.intel.com/ial/home/sp/pcmmspec.htm | ||
7 | * ftp://download.intel.com/ial/home/sp/mmts098.pdf | ||
8 | */ | ||
9 | |||
10 | #define HPET_MMAP_SIZE 1024 | ||
11 | |||
12 | #define HPET_ID 0x000 | ||
13 | #define HPET_PERIOD 0x004 | ||
14 | #define HPET_CFG 0x010 | ||
15 | #define HPET_STATUS 0x020 | ||
16 | #define HPET_COUNTER 0x0f0 | ||
17 | #define HPET_Tn_OFFSET 0x20 | ||
18 | #define HPET_Tn_CFG(n) (0x100 + (n) * HPET_Tn_OFFSET) | ||
19 | #define HPET_Tn_ROUTE(n) (0x104 + (n) * HPET_Tn_OFFSET) | ||
20 | #define HPET_Tn_CMP(n) (0x108 + (n) * HPET_Tn_OFFSET) | ||
21 | #define HPET_T0_CFG HPET_Tn_CFG(0) | ||
22 | #define HPET_T0_CMP HPET_Tn_CMP(0) | ||
23 | #define HPET_T1_CFG HPET_Tn_CFG(1) | ||
24 | #define HPET_T1_CMP HPET_Tn_CMP(1) | ||
25 | |||
26 | #define HPET_ID_VENDOR 0xffff0000 | ||
27 | #define HPET_ID_LEGSUP 0x00008000 | ||
28 | #define HPET_ID_64BIT 0x00002000 | ||
29 | #define HPET_ID_NUMBER 0x00001f00 | ||
30 | #define HPET_ID_REV 0x000000ff | ||
31 | #define HPET_ID_NUMBER_SHIFT 8 | ||
32 | |||
33 | #define HPET_ID_VENDOR_SHIFT 16 | ||
34 | #define HPET_ID_VENDOR_8086 0x8086 | ||
35 | |||
36 | #define HPET_CFG_ENABLE 0x001 | ||
37 | #define HPET_CFG_LEGACY 0x002 | ||
38 | #define HPET_LEGACY_8254 2 | ||
39 | #define HPET_LEGACY_RTC 8 | ||
40 | |||
41 | #define HPET_TN_LEVEL 0x0002 | ||
42 | #define HPET_TN_ENABLE 0x0004 | ||
43 | #define HPET_TN_PERIODIC 0x0008 | ||
44 | #define HPET_TN_PERIODIC_CAP 0x0010 | ||
45 | #define HPET_TN_64BIT_CAP 0x0020 | ||
46 | #define HPET_TN_SETVAL 0x0040 | ||
47 | #define HPET_TN_32BIT 0x0100 | ||
48 | #define HPET_TN_ROUTE 0x3e00 | ||
49 | #define HPET_TN_FSB 0x4000 | ||
50 | #define HPET_TN_FSB_CAP 0x8000 | ||
51 | |||
52 | #define HPET_TN_ROUTE_SHIFT 9 | ||
53 | 5 | ||
54 | #define HPET_TICK_RATE (HZ * 100000UL) | 6 | #define HPET_TICK_RATE (HZ * 100000UL) |
55 | 7 | ||
56 | extern int is_hpet_enabled(void); | ||
57 | extern int hpet_rtc_timer_init(void); | 8 | extern int hpet_rtc_timer_init(void); |
58 | extern int hpet_arch_init(void); | 9 | extern int hpet_arch_init(void); |
59 | extern int hpet_timer_stop_set_go(unsigned long tick); | 10 | extern int hpet_timer_stop_set_go(unsigned long tick); |
@@ -61,17 +12,7 @@ extern int hpet_reenable(void); | |||
61 | extern unsigned int hpet_calibrate_tsc(void); | 12 | extern unsigned int hpet_calibrate_tsc(void); |
62 | 13 | ||
63 | extern int hpet_use_timer; | 14 | extern int hpet_use_timer; |
64 | extern unsigned long hpet_address; | ||
65 | extern unsigned long hpet_period; | 15 | extern unsigned long hpet_period; |
66 | extern unsigned long hpet_tick; | 16 | extern unsigned long hpet_tick; |
67 | 17 | ||
68 | #ifdef CONFIG_HPET_EMULATE_RTC | ||
69 | extern int hpet_mask_rtc_irq_bit(unsigned long bit_mask); | ||
70 | extern int hpet_set_rtc_irq_bit(unsigned long bit_mask); | ||
71 | extern int hpet_set_alarm_time(unsigned char hrs, unsigned char min, unsigned char sec); | ||
72 | extern int hpet_set_periodic_freq(unsigned long freq); | ||
73 | extern int hpet_rtc_dropped_irq(void); | ||
74 | extern int hpet_rtc_timer_init(void); | ||
75 | #endif /* CONFIG_HPET_EMULATE_RTC */ | ||
76 | |||
77 | #endif | 18 | #endif |