Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | |
| 2 | #ifndef _I386_HPET_H |
| 3 | #define _I386_HPET_H |
| 4 | |
| 5 | #ifdef CONFIG_HPET_TIMER |
| 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 | #include <linux/config.h> |
| 31 | |
| 32 | #include <asm/fixmap.h> |
| 33 | |
| 34 | /* |
| 35 | * Documentation on HPET can be found at: |
| 36 | * http://www.intel.com/ial/home/sp/pcmmspec.htm |
| 37 | * ftp://download.intel.com/ial/home/sp/mmts098.pdf |
| 38 | */ |
| 39 | |
| 40 | #define HPET_MMAP_SIZE 1024 |
| 41 | |
| 42 | #define HPET_ID 0x000 |
| 43 | #define HPET_PERIOD 0x004 |
| 44 | #define HPET_CFG 0x010 |
| 45 | #define HPET_STATUS 0x020 |
| 46 | #define HPET_COUNTER 0x0f0 |
| 47 | #define HPET_T0_CFG 0x100 |
| 48 | #define HPET_T0_CMP 0x108 |
| 49 | #define HPET_T0_ROUTE 0x110 |
| 50 | #define HPET_T1_CFG 0x120 |
| 51 | #define HPET_T1_CMP 0x128 |
| 52 | #define HPET_T1_ROUTE 0x130 |
| 53 | #define HPET_T2_CFG 0x140 |
| 54 | #define HPET_T2_CMP 0x148 |
| 55 | #define HPET_T2_ROUTE 0x150 |
| 56 | |
| 57 | #define HPET_ID_LEGSUP 0x00008000 |
| 58 | #define HPET_ID_NUMBER 0x00001f00 |
| 59 | #define HPET_ID_REV 0x000000ff |
| 60 | #define HPET_ID_NUMBER_SHIFT 8 |
| 61 | |
| 62 | #define HPET_CFG_ENABLE 0x001 |
| 63 | #define HPET_CFG_LEGACY 0x002 |
| 64 | #define HPET_LEGACY_8254 2 |
| 65 | #define HPET_LEGACY_RTC 8 |
| 66 | |
| 67 | #define HPET_TN_ENABLE 0x004 |
| 68 | #define HPET_TN_PERIODIC 0x008 |
| 69 | #define HPET_TN_PERIODIC_CAP 0x010 |
| 70 | #define HPET_TN_SETVAL 0x040 |
| 71 | #define HPET_TN_32BIT 0x100 |
| 72 | |
| 73 | /* Use our own asm for 64 bit multiply/divide */ |
| 74 | #define ASM_MUL64_REG(eax_out,edx_out,reg_in,eax_in) \ |
| 75 | __asm__ __volatile__("mull %2" \ |
| 76 | :"=a" (eax_out), "=d" (edx_out) \ |
| 77 | :"r" (reg_in), "0" (eax_in)) |
| 78 | |
| 79 | #define ASM_DIV64_REG(eax_out,edx_out,reg_in,eax_in,edx_in) \ |
| 80 | __asm__ __volatile__("divl %2" \ |
| 81 | :"=a" (eax_out), "=d" (edx_out) \ |
| 82 | :"r" (reg_in), "0" (eax_in), "1" (edx_in)) |
| 83 | |
| 84 | #define KERNEL_TICK_USEC (1000000UL/HZ) /* tick value in microsec */ |
| 85 | /* Max HPET Period is 10^8 femto sec as in HPET spec */ |
| 86 | #define HPET_MAX_PERIOD (100000000UL) |
| 87 | /* |
| 88 | * Min HPET period is 10^5 femto sec just for safety. If it is less than this, |
| 89 | * then 32 bit HPET counter wrapsaround in less than 0.5 sec. |
| 90 | */ |
| 91 | #define HPET_MIN_PERIOD (100000UL) |
Jordan Hargrave | b20367a | 2006-04-07 19:50:18 +0200 | [diff] [blame] | 92 | #define HPET_TICK_RATE (HZ * 100000UL) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 93 | |
| 94 | extern unsigned long hpet_tick; /* hpet clks count per tick */ |
| 95 | extern unsigned long hpet_address; /* hpet memory map physical address */ |
john stultz | 35492df | 2005-05-01 08:58:50 -0700 | [diff] [blame] | 96 | extern int hpet_use_timer; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 97 | |
| 98 | extern int hpet_rtc_timer_init(void); |
| 99 | extern int hpet_enable(void); |
| 100 | extern int hpet_reenable(void); |
| 101 | extern int is_hpet_enabled(void); |
| 102 | extern int is_hpet_capable(void); |
| 103 | extern int hpet_readl(unsigned long a); |
| 104 | |
| 105 | #ifdef CONFIG_HPET_EMULATE_RTC |
| 106 | extern int hpet_mask_rtc_irq_bit(unsigned long bit_mask); |
| 107 | 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); |
| 109 | extern int hpet_set_periodic_freq(unsigned long freq); |
| 110 | extern int hpet_rtc_dropped_irq(void); |
| 111 | extern int hpet_rtc_timer_init(void); |
| 112 | extern irqreturn_t hpet_rtc_interrupt(int irq, void *dev_id, struct pt_regs *regs); |
| 113 | #endif /* CONFIG_HPET_EMULATE_RTC */ |
| 114 | #endif /* CONFIG_HPET_TIMER */ |
| 115 | #endif /* _I386_HPET_H */ |