hpet.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. #ifndef _I386_HPET_H
  2. #define _I386_HPET_H
  3. #ifdef CONFIG_HPET_TIMER
  4. #include <linux/errno.h>
  5. #include <linux/module.h>
  6. #include <linux/sched.h>
  7. #include <linux/kernel.h>
  8. #include <linux/param.h>
  9. #include <linux/string.h>
  10. #include <linux/mm.h>
  11. #include <linux/interrupt.h>
  12. #include <linux/time.h>
  13. #include <linux/delay.h>
  14. #include <linux/init.h>
  15. #include <linux/smp.h>
  16. #include <asm/io.h>
  17. #include <asm/smp.h>
  18. #include <asm/irq.h>
  19. #include <asm/msr.h>
  20. #include <asm/delay.h>
  21. #include <asm/mpspec.h>
  22. #include <asm/uaccess.h>
  23. #include <asm/processor.h>
  24. #include <linux/timex.h>
  25. /*
  26. * Documentation on HPET can be found at:
  27. * http://www.intel.com/ial/home/sp/pcmmspec.htm
  28. * ftp://download.intel.com/ial/home/sp/mmts098.pdf
  29. */
  30. #define HPET_MMAP_SIZE 1024
  31. #define HPET_ID 0x000
  32. #define HPET_PERIOD 0x004
  33. #define HPET_CFG 0x010
  34. #define HPET_STATUS 0x020
  35. #define HPET_COUNTER 0x0f0
  36. #define HPET_T0_CFG 0x100
  37. #define HPET_T0_CMP 0x108
  38. #define HPET_T0_ROUTE 0x110
  39. #define HPET_T1_CFG 0x120
  40. #define HPET_T1_CMP 0x128
  41. #define HPET_T1_ROUTE 0x130
  42. #define HPET_T2_CFG 0x140
  43. #define HPET_T2_CMP 0x148
  44. #define HPET_T2_ROUTE 0x150
  45. #define HPET_ID_LEGSUP 0x00008000
  46. #define HPET_ID_NUMBER 0x00001f00
  47. #define HPET_ID_REV 0x000000ff
  48. #define HPET_ID_NUMBER_SHIFT 8
  49. #define HPET_CFG_ENABLE 0x001
  50. #define HPET_CFG_LEGACY 0x002
  51. #define HPET_LEGACY_8254 2
  52. #define HPET_LEGACY_RTC 8
  53. #define HPET_TN_ENABLE 0x004
  54. #define HPET_TN_PERIODIC 0x008
  55. #define HPET_TN_PERIODIC_CAP 0x010
  56. #define HPET_TN_SETVAL 0x040
  57. #define HPET_TN_32BIT 0x100
  58. /* Use our own asm for 64 bit multiply/divide */
  59. #define ASM_MUL64_REG(eax_out,edx_out,reg_in,eax_in) \
  60. __asm__ __volatile__("mull %2" \
  61. :"=a" (eax_out), "=d" (edx_out) \
  62. :"r" (reg_in), "0" (eax_in))
  63. #define ASM_DIV64_REG(eax_out,edx_out,reg_in,eax_in,edx_in) \
  64. __asm__ __volatile__("divl %2" \
  65. :"=a" (eax_out), "=d" (edx_out) \
  66. :"r" (reg_in), "0" (eax_in), "1" (edx_in))
  67. #define KERNEL_TICK_USEC (1000000UL/HZ) /* tick value in microsec */
  68. /* Max HPET Period is 10^8 femto sec as in HPET spec */
  69. #define HPET_MAX_PERIOD (100000000UL)
  70. /*
  71. * Min HPET period is 10^5 femto sec just for safety. If it is less than this,
  72. * then 32 bit HPET counter wrapsaround in less than 0.5 sec.
  73. */
  74. #define HPET_MIN_PERIOD (100000UL)
  75. #define HPET_TICK_RATE (HZ * 100000UL)
  76. extern unsigned long hpet_address; /* hpet memory map physical address */
  77. extern int is_hpet_enabled(void);
  78. #ifdef CONFIG_X86_64
  79. extern unsigned long hpet_tick; /* hpet clks count per tick */
  80. extern int hpet_use_timer;
  81. extern int hpet_rtc_timer_init(void);
  82. extern int hpet_enable(void);
  83. extern int is_hpet_capable(void);
  84. extern int hpet_readl(unsigned long a);
  85. #else
  86. extern int hpet_enable(void);
  87. #endif
  88. #ifdef CONFIG_HPET_EMULATE_RTC
  89. extern int hpet_mask_rtc_irq_bit(unsigned long bit_mask);
  90. extern int hpet_set_rtc_irq_bit(unsigned long bit_mask);
  91. extern int hpet_set_alarm_time(unsigned char hrs, unsigned char min, unsigned char sec);
  92. extern int hpet_set_periodic_freq(unsigned long freq);
  93. extern int hpet_rtc_dropped_irq(void);
  94. extern int hpet_rtc_timer_init(void);
  95. extern irqreturn_t hpet_rtc_interrupt(int irq, void *dev_id);
  96. #endif /* CONFIG_HPET_EMULATE_RTC */
  97. #else
  98. static inline int hpet_enable(void) { return 0; }
  99. #endif /* CONFIG_HPET_TIMER */
  100. #endif /* _I386_HPET_H */