timer.h 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. /* Copyright (C) 2018 RDA Technologies Limited and/or its affiliates("RDA").
  2. * All rights reserved.
  3. *
  4. * This software is supplied "AS IS" without any warranties.
  5. * RDA assumes no responsibility or liability for the use of the software,
  6. * conveys no license or title under any patent, copyright, or mask work
  7. * right to the product. RDA reserves the right to make changes in the
  8. * software without notification. RDA also make no representation or
  9. * warranty that such application will be suitable for the specified use
  10. * without further testing or modification.
  11. */
  12. #ifndef _TIMER_H_
  13. #define _TIMER_H_
  14. // Auto generated by dtools(see dtools.txt for its version).
  15. // Don't edit it manually!
  16. #define NB_INTERVAL (1)
  17. #define INT_TIMER_NB_BITS (24)
  18. #define WD_TIMER_NB_BITS (24)
  19. #define HW_TIMER_NB_BITS (32)
  20. #define TIM_MAXVAL (0xffffff)
  21. #define REG_TIMER1_BASE (0x04805000)
  22. #define REG_TIMER3_BASE (0x14006000)
  23. typedef volatile struct
  24. {
  25. uint32_t ostimer_ctrl; // 0x00000000
  26. uint32_t ostimer_curval; // 0x00000004
  27. uint32_t wdtimer_ctrl; // 0x00000008
  28. uint32_t wdtimer_loadval; // 0x0000000c
  29. uint32_t hwtimer_ctrl; // 0x00000010
  30. uint32_t hwtimer_curval; // 0x00000014
  31. uint32_t timer_irq_mask_set; // 0x00000018
  32. uint32_t timer_irq_mask_clr; // 0x0000001c
  33. uint32_t timer_irq_clr; // 0x00000020
  34. uint32_t timer_irq_cause; // 0x00000024
  35. } HWP_TIMER_T;
  36. #define hwp_timer1 ((HWP_TIMER_T *)REG_ACCESS_ADDRESS(REG_TIMER1_BASE))
  37. #define hwp_timer3 ((HWP_TIMER_T *)REG_ACCESS_ADDRESS(REG_TIMER3_BASE))
  38. // ostimer_ctrl
  39. typedef union {
  40. uint32_t v;
  41. struct
  42. {
  43. uint32_t loadval : 24; // [23:0]
  44. uint32_t enable : 1; // [24]
  45. uint32_t enabled : 1; // [25], read only
  46. uint32_t cleared : 1; // [26], read only
  47. uint32_t __27_27 : 1; // [27]
  48. uint32_t repeat : 1; // [28]
  49. uint32_t wrap : 1; // [29]
  50. uint32_t load : 1; // [30]
  51. uint32_t __31_31 : 1; // [31]
  52. } b;
  53. } REG_TIMER_OSTIMER_CTRL_T;
  54. // wdtimer_ctrl
  55. typedef union {
  56. uint32_t v;
  57. struct
  58. {
  59. uint32_t start : 1; // [0], write set
  60. uint32_t __3_1 : 3; // [3:1]
  61. uint32_t stop : 1; // [4], write clear
  62. uint32_t __7_5 : 3; // [7:5]
  63. uint32_t wdenabled : 1; // [8], read only
  64. uint32_t __15_9 : 7; // [15:9]
  65. uint32_t reload : 1; // [16]
  66. uint32_t __31_17 : 15; // [31:17]
  67. } b;
  68. } REG_TIMER_WDTIMER_CTRL_T;
  69. // wdtimer_loadval
  70. typedef union {
  71. uint32_t v;
  72. struct
  73. {
  74. uint32_t wdloadval : 24; // [23:0]
  75. uint32_t __31_24 : 8; // [31:24]
  76. } b;
  77. } REG_TIMER_WDTIMER_LOADVAL_T;
  78. // hwtimer_ctrl
  79. typedef union {
  80. uint32_t v;
  81. struct
  82. {
  83. uint32_t interval : 2; // [1:0]
  84. uint32_t __7_2 : 6; // [7:2]
  85. uint32_t interval_en : 1; // [8]
  86. uint32_t __31_9 : 23; // [31:9]
  87. } b;
  88. } REG_TIMER_HWTIMER_CTRL_T;
  89. // timer_irq_mask_set
  90. typedef union {
  91. uint32_t v;
  92. struct
  93. {
  94. uint32_t ostimer_mask : 1; // [0], write set
  95. uint32_t hwtimer_wrap_mask : 1; // [1], write set
  96. uint32_t hwtimer_itv_mask : 1; // [2], write set
  97. uint32_t __31_3 : 29; // [31:3]
  98. } b;
  99. } REG_TIMER_TIMER_IRQ_MASK_SET_T;
  100. // timer_irq_mask_clr
  101. typedef union {
  102. uint32_t v;
  103. struct
  104. {
  105. uint32_t ostimer_mask : 1; // [0], write clear
  106. uint32_t hwtimer_wrap_mask : 1; // [1], write clear
  107. uint32_t hwtimer_itv_mask : 1; // [2], write clear
  108. uint32_t __31_3 : 29; // [31:3]
  109. } b;
  110. } REG_TIMER_TIMER_IRQ_MASK_CLR_T;
  111. // timer_irq_clr
  112. typedef union {
  113. uint32_t v;
  114. struct
  115. {
  116. uint32_t ostimer_clr : 1; // [0], write clear
  117. uint32_t hwtimer_wrap_clr : 1; // [1], write clear
  118. uint32_t hwtimer_itv_clr : 1; // [2], write clear
  119. uint32_t __31_3 : 29; // [31:3]
  120. } b;
  121. } REG_TIMER_TIMER_IRQ_CLR_T;
  122. // timer_irq_cause
  123. typedef union {
  124. uint32_t v;
  125. struct
  126. {
  127. uint32_t ostimer_cause : 1; // [0], read only
  128. uint32_t hwtimer_wrap_cause : 1; // [1], read only
  129. uint32_t hwtimer_itv_cause : 1; // [2], read only
  130. uint32_t __15_3 : 13; // [15:3]
  131. uint32_t ostimer_status : 1; // [16], read only
  132. uint32_t hwtimer_wrap_status : 1; // [17], read only
  133. uint32_t hwtimer_itv_status : 1; // [18], read only
  134. uint32_t __31_19 : 13; // [31:19]
  135. } b;
  136. } REG_TIMER_TIMER_IRQ_CAUSE_T;
  137. // ostimer_ctrl
  138. #define TIMER_LOADVAL(n) (((n)&0xffffff) << 0)
  139. #define TIMER_ENABLE (1 << 24)
  140. #define TIMER_ENABLED (1 << 25)
  141. #define TIMER_CLEARED (1 << 26)
  142. #define TIMER_REPEAT (1 << 28)
  143. #define TIMER_WRAP (1 << 29)
  144. #define TIMER_LOAD (1 << 30)
  145. // wdtimer_ctrl
  146. #define TIMER_START (1 << 0)
  147. #define TIMER_STOP (1 << 4)
  148. #define TIMER_WDENABLED (1 << 8)
  149. #define TIMER_RELOAD (1 << 16)
  150. // wdtimer_loadval
  151. #define TIMER_WDLOADVAL(n) (((n)&0xffffff) << 0)
  152. // hwtimer_ctrl
  153. #define TIMER_INTERVAL(n) (((n)&0x3) << 0)
  154. #define TIMER_INTERVAL_EN (1 << 8)
  155. // timer_irq_mask_set
  156. #define TIMER_OSTIMER_MASK (1 << 0)
  157. #define TIMER_HWTIMER_WRAP_MASK (1 << 1)
  158. #define TIMER_HWTIMER_ITV_MASK (1 << 2)
  159. // timer_irq_mask_clr
  160. #define TIMER_OSTIMER_MASK (1 << 0)
  161. #define TIMER_HWTIMER_WRAP_MASK (1 << 1)
  162. #define TIMER_HWTIMER_ITV_MASK (1 << 2)
  163. // timer_irq_clr
  164. #define TIMER_OSTIMER_CLR (1 << 0)
  165. #define TIMER_HWTIMER_WRAP_CLR (1 << 1)
  166. #define TIMER_HWTIMER_ITV_CLR (1 << 2)
  167. // timer_irq_cause
  168. #define TIMER_OTHER_TIMS_IRQ(n) (((n)&0x3) << 1)
  169. #define TIMER_OSTIMER_CAUSE (1 << 0)
  170. #define TIMER_HWTIMER_WRAP_CAUSE (1 << 1)
  171. #define TIMER_HWTIMER_ITV_CAUSE (1 << 2)
  172. #define TIMER_OSTIMER_STATUS (1 << 16)
  173. #define TIMER_HWTIMER_WRAP_STATUS (1 << 17)
  174. #define TIMER_HWTIMER_ITV_STATUS (1 << 18)
  175. #endif // _TIMER_H_