hpet.h
上传用户:szlgq88
上传日期:2009-04-28
资源大小:48287k
文件大小:3k
源码类别:

嵌入式Linux

开发平台:

Unix_Linux

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