hpet.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. #ifndef __HPET__
  2. #define __HPET__ 1
  3. #include <linux/compiler.h>
  4. #ifdef __KERNEL__
  5. /*
  6. * Offsets into HPET Registers
  7. */
  8. struct hpet {
  9. u64 hpet_cap; /* capabilities */
  10. u64 res0; /* reserved */
  11. u64 hpet_config; /* configuration */
  12. u64 res1; /* reserved */
  13. u64 hpet_isr; /* interrupt status reg */
  14. u64 res2[25]; /* reserved */
  15. union { /* main counter */
  16. u64 _hpet_mc64;
  17. u32 _hpet_mc32;
  18. unsigned long _hpet_mc;
  19. } _u0;
  20. u64 res3; /* reserved */
  21. struct hpet_timer {
  22. u64 hpet_config; /* configuration/cap */
  23. union { /* timer compare register */
  24. u64 _hpet_hc64;
  25. u32 _hpet_hc32;
  26. unsigned long _hpet_compare;
  27. } _u1;
  28. u64 hpet_fsb[2]; /* FSB route */
  29. } hpet_timers[1];
  30. };
  31. #define hpet_mc _u0._hpet_mc
  32. #define hpet_compare _u1._hpet_compare
  33. #define HPET_MAX_TIMERS (32)
  34. /*
  35. * HPET general capabilities register
  36. */
  37. #define HPET_COUNTER_CLK_PERIOD_MASK (0xffffffff00000000ULL)
  38. #define HPET_COUNTER_CLK_PERIOD_SHIFT (32UL)
  39. #define HPET_VENDOR_ID_MASK (0x00000000ffff0000ULL)
  40. #define HPET_VENDOR_ID_SHIFT (16ULL)
  41. #define HPET_LEG_RT_CAP_MASK (0x8000)
  42. #define HPET_COUNTER_SIZE_MASK (0x2000)
  43. #define HPET_NUM_TIM_CAP_MASK (0x1f00)
  44. #define HPET_NUM_TIM_CAP_SHIFT (8ULL)
  45. /*
  46. * HPET general configuration register
  47. */
  48. #define HPET_LEG_RT_CNF_MASK (2UL)
  49. #define HPET_ENABLE_CNF_MASK (1UL)
  50. /*
  51. * Timer configuration register
  52. */
  53. #define Tn_INT_ROUTE_CAP_MASK (0xffffffff00000000ULL)
  54. #define Tn_INI_ROUTE_CAP_SHIFT (32UL)
  55. #define Tn_FSB_INT_DELCAP_MASK (0x8000UL)
  56. #define Tn_FSB_INT_DELCAP_SHIFT (15)
  57. #define Tn_FSB_EN_CNF_MASK (0x4000UL)
  58. #define Tn_FSB_EN_CNF_SHIFT (14)
  59. #define Tn_INT_ROUTE_CNF_MASK (0x3e00UL)
  60. #define Tn_INT_ROUTE_CNF_SHIFT (9)
  61. #define Tn_32MODE_CNF_MASK (0x0100UL)
  62. #define Tn_VAL_SET_CNF_MASK (0x0040UL)
  63. #define Tn_SIZE_CAP_MASK (0x0020UL)
  64. #define Tn_PER_INT_CAP_MASK (0x0010UL)
  65. #define Tn_TYPE_CNF_MASK (0x0008UL)
  66. #define Tn_INT_ENB_CNF_MASK (0x0004UL)
  67. #define Tn_INT_TYPE_CNF_MASK (0x0002UL)
  68. /*
  69. * Timer FSB Interrupt Route Register
  70. */
  71. #define Tn_FSB_INT_ADDR_MASK (0xffffffff00000000ULL)
  72. #define Tn_FSB_INT_ADDR_SHIFT (32UL)
  73. #define Tn_FSB_INT_VAL_MASK (0x00000000ffffffffULL)
  74. /*
  75. * exported interfaces
  76. */
  77. struct hpet_task {
  78. void (*ht_func) (void *);
  79. void *ht_data;
  80. void *ht_opaque;
  81. };
  82. struct hpet_data {
  83. unsigned long hd_phys_address;
  84. void __iomem *hd_address;
  85. unsigned short hd_nirqs;
  86. unsigned short hd_flags;
  87. unsigned int hd_state; /* timer allocated */
  88. unsigned int hd_irq[HPET_MAX_TIMERS];
  89. };
  90. #define HPET_DATA_PLATFORM 0x0001 /* platform call to hpet_alloc */
  91. static inline void hpet_reserve_timer(struct hpet_data *hd, int timer)
  92. {
  93. hd->hd_state |= (1 << timer);
  94. return;
  95. }
  96. int hpet_alloc(struct hpet_data *);
  97. int hpet_register(struct hpet_task *, int);
  98. int hpet_unregister(struct hpet_task *);
  99. int hpet_control(struct hpet_task *, unsigned int, unsigned long);
  100. #endif /* __KERNEL__ */
  101. struct hpet_info {
  102. unsigned long hi_ireqfreq; /* Hz */
  103. unsigned long hi_flags; /* information */
  104. unsigned short hi_hpet;
  105. unsigned short hi_timer;
  106. };
  107. #define HPET_INFO_PERIODIC 0x0001 /* timer is periodic */
  108. #define HPET_IE_ON _IO('h', 0x01) /* interrupt on */
  109. #define HPET_IE_OFF _IO('h', 0x02) /* interrupt off */
  110. #define HPET_INFO _IOR('h', 0x03, struct hpet_info)
  111. #define HPET_EPI _IO('h', 0x04) /* enable periodic */
  112. #define HPET_DPI _IO('h', 0x05) /* disable periodic */
  113. #define HPET_IRQFREQ _IOW('h', 0x6, unsigned long) /* IRQFREQ usec */
  114. #endif /* !__HPET__ */