gpt.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451
  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 _GPT_H_
  13. #define _GPT_H_
  14. // Auto generated by dtools(see dtools.txt for its version).
  15. // Don't edit it manually!
  16. #define REG_AON_GPT1_BASE (0x5150b000)
  17. #define REG_AON_GPT2_BASE (0x5150b400)
  18. #define REG_AON_GPT3_BASE (0x5150b800)
  19. #define REG_AP_GPT1_BASE (0x04809200)
  20. #define REG_AP_GPT2_BASE (0x04809400)
  21. #define REG_AP_GPT3_BASE (0x04809600)
  22. #define REG_AP_GPT4_BASE (0x04809800)
  23. #define REG_AP_GPT5_BASE (0x04809a00)
  24. #define REG_AP_GPT6_BASE (0x04809c00)
  25. typedef volatile struct
  26. {
  27. uint32_t cr; // 0x00000000
  28. uint32_t smcr; // 0x00000004
  29. uint32_t egr; // 0x00000008
  30. uint32_t ccmr_oc1; // 0x0000000c
  31. uint32_t ccmr_ic1; // 0x00000010
  32. uint32_t ccer; // 0x00000014
  33. uint32_t cnt; // 0x00000018
  34. uint32_t psc; // 0x0000001c
  35. uint32_t arr; // 0x00000020
  36. uint32_t timer_ccr1_ic; // 0x00000024
  37. uint32_t timer_ccr2_ic; // 0x00000028
  38. uint32_t timer_ccr3_ic; // 0x0000002c
  39. uint32_t timer_ccr4_ic; // 0x00000030
  40. uint32_t timer_ccr1_oc; // 0x00000034
  41. uint32_t timer_ccr2_oc; // 0x00000038
  42. uint32_t timer_ccr3_oc; // 0x0000003c
  43. uint32_t timer_ccr4_oc; // 0x00000040
  44. uint32_t isr; // 0x00000044
  45. uint32_t irsr; // 0x00000048
  46. uint32_t mask; // 0x0000004c
  47. uint32_t clr; // 0x00000050
  48. } HWP_GPT_T;
  49. #define hwp_aonGpt1 ((HWP_GPT_T *)REG_ACCESS_ADDRESS(REG_AON_GPT1_BASE))
  50. #define hwp_aonGpt2 ((HWP_GPT_T *)REG_ACCESS_ADDRESS(REG_AON_GPT2_BASE))
  51. #define hwp_aonGpt3 ((HWP_GPT_T *)REG_ACCESS_ADDRESS(REG_AON_GPT3_BASE))
  52. #define hwp_apGpt1 ((HWP_GPT_T *)REG_ACCESS_ADDRESS(REG_AP_GPT1_BASE))
  53. #define hwp_apGpt2 ((HWP_GPT_T *)REG_ACCESS_ADDRESS(REG_AP_GPT2_BASE))
  54. #define hwp_apGpt3 ((HWP_GPT_T *)REG_ACCESS_ADDRESS(REG_AP_GPT3_BASE))
  55. #define hwp_apGpt4 ((HWP_GPT_T *)REG_ACCESS_ADDRESS(REG_AP_GPT4_BASE))
  56. #define hwp_apGpt5 ((HWP_GPT_T *)REG_ACCESS_ADDRESS(REG_AP_GPT5_BASE))
  57. #define hwp_apGpt6 ((HWP_GPT_T *)REG_ACCESS_ADDRESS(REG_AP_GPT6_BASE))
  58. // cr
  59. typedef union {
  60. uint32_t v;
  61. struct
  62. {
  63. uint32_t cen : 1; // [0]
  64. uint32_t ckd : 2; // [2:1]
  65. uint32_t udis : 1; // [3]
  66. uint32_t opm : 1; // [4]
  67. uint32_t dir : 1; // [5]
  68. uint32_t cms : 2; // [7:6]
  69. uint32_t arpe : 1; // [8]
  70. uint32_t tri : 3; // [11:9]
  71. uint32_t tri_cnt_en : 1; // [12]
  72. uint32_t __30_13 : 18; // [30:13]
  73. uint32_t refclk_sel : 1; // [31]
  74. } b;
  75. } REG_GPT_CR_T;
  76. // smcr
  77. typedef union {
  78. uint32_t v;
  79. struct
  80. {
  81. uint32_t sms : 3; // [2:0]
  82. uint32_t __31_3 : 29; // [31:3]
  83. } b;
  84. } REG_GPT_SMCR_T;
  85. // egr
  86. typedef union {
  87. uint32_t v;
  88. struct
  89. {
  90. uint32_t ug : 1; // [0], read only
  91. uint32_t __31_1 : 31; // [31:1]
  92. } b;
  93. } REG_GPT_EGR_T;
  94. // ccmr_oc1
  95. typedef union {
  96. uint32_t v;
  97. struct
  98. {
  99. uint32_t cc1s : 2; // [1:0]
  100. uint32_t oc1fe : 1; // [2]
  101. uint32_t oc1pe : 1; // [3]
  102. uint32_t oc1m : 3; // [6:4]
  103. uint32_t oc1ce : 1; // [7]
  104. uint32_t cc2s : 2; // [9:8]
  105. uint32_t oc2fe : 1; // [10]
  106. uint32_t oc2pe : 1; // [11]
  107. uint32_t oc2m : 3; // [14:12]
  108. uint32_t oc2ce : 1; // [15]
  109. uint32_t cc3s : 2; // [17:16]
  110. uint32_t oc3fe : 1; // [18]
  111. uint32_t oc3pe : 1; // [19]
  112. uint32_t oc3m : 3; // [22:20]
  113. uint32_t oc3ce : 1; // [23]
  114. uint32_t cc4s : 2; // [25:24]
  115. uint32_t oc4fe : 1; // [26]
  116. uint32_t oc4pe : 1; // [27]
  117. uint32_t oc4m : 3; // [30:28]
  118. uint32_t oc4ce : 1; // [31]
  119. } b;
  120. } REG_GPT_CCMR_OC1_T;
  121. // ccmr_ic1
  122. typedef union {
  123. uint32_t v;
  124. struct
  125. {
  126. uint32_t ic1psc : 2; // [1:0]
  127. uint32_t ic1f : 4; // [5:2]
  128. uint32_t __7_6 : 2; // [7:6]
  129. uint32_t ic2psc : 2; // [9:8]
  130. uint32_t ic2f : 4; // [13:10]
  131. uint32_t __15_14 : 2; // [15:14]
  132. uint32_t ic3psc : 2; // [17:16]
  133. uint32_t ic3f : 4; // [21:18]
  134. uint32_t __23_22 : 2; // [23:22]
  135. uint32_t ic4psc : 2; // [25:24]
  136. uint32_t ic4f : 4; // [29:26]
  137. uint32_t __31_30 : 2; // [31:30]
  138. } b;
  139. } REG_GPT_CCMR_IC1_T;
  140. // ccer
  141. typedef union {
  142. uint32_t v;
  143. struct
  144. {
  145. uint32_t cc1e : 1; // [0]
  146. uint32_t cc1p : 1; // [1]
  147. uint32_t cc2e : 1; // [2]
  148. uint32_t cc2p : 1; // [3]
  149. uint32_t cc3e : 1; // [4]
  150. uint32_t cc3p : 1; // [5]
  151. uint32_t cc4e : 1; // [6]
  152. uint32_t cc4p : 1; // [7]
  153. uint32_t __31_8 : 24; // [31:8]
  154. } b;
  155. } REG_GPT_CCER_T;
  156. // cnt
  157. typedef union {
  158. uint32_t v;
  159. struct
  160. {
  161. uint32_t cnt_value : 16; // [15:0], read only
  162. uint32_t __31_16 : 16; // [31:16]
  163. } b;
  164. } REG_GPT_CNT_T;
  165. // psc
  166. typedef union {
  167. uint32_t v;
  168. struct
  169. {
  170. uint32_t psc_value : 16; // [15:0]
  171. uint32_t __31_16 : 16; // [31:16]
  172. } b;
  173. } REG_GPT_PSC_T;
  174. // arr
  175. typedef union {
  176. uint32_t v;
  177. struct
  178. {
  179. uint32_t arr_value : 16; // [15:0]
  180. uint32_t __31_16 : 16; // [31:16]
  181. } b;
  182. } REG_GPT_ARR_T;
  183. // timer_ccr1_ic
  184. typedef union {
  185. uint32_t v;
  186. struct
  187. {
  188. uint32_t timer_ccr1_capture : 16; // [15:0], read only
  189. uint32_t __31_16 : 16; // [31:16]
  190. } b;
  191. } REG_GPT_TIMER_CCR1_IC_T;
  192. // timer_ccr2_ic
  193. typedef union {
  194. uint32_t v;
  195. struct
  196. {
  197. uint32_t timer_ccr2_capture : 16; // [15:0], read only
  198. uint32_t __31_16 : 16; // [31:16]
  199. } b;
  200. } REG_GPT_TIMER_CCR2_IC_T;
  201. // timer_ccr3_ic
  202. typedef union {
  203. uint32_t v;
  204. struct
  205. {
  206. uint32_t timer_ccr3_capture : 16; // [15:0], read only
  207. uint32_t __31_16 : 16; // [31:16]
  208. } b;
  209. } REG_GPT_TIMER_CCR3_IC_T;
  210. // timer_ccr4_ic
  211. typedef union {
  212. uint32_t v;
  213. struct
  214. {
  215. uint32_t timer_ccr4_capture : 16; // [15:0], read only
  216. uint32_t __31_16 : 16; // [31:16]
  217. } b;
  218. } REG_GPT_TIMER_CCR4_IC_T;
  219. // timer_ccr1_oc
  220. typedef union {
  221. uint32_t v;
  222. struct
  223. {
  224. uint32_t timer_ccr1_compare : 16; // [15:0]
  225. uint32_t __31_16 : 16; // [31:16]
  226. } b;
  227. } REG_GPT_TIMER_CCR1_OC_T;
  228. // timer_ccr2_oc
  229. typedef union {
  230. uint32_t v;
  231. struct
  232. {
  233. uint32_t timer_ccr2_compare : 16; // [15:0]
  234. uint32_t __31_16 : 16; // [31:16]
  235. } b;
  236. } REG_GPT_TIMER_CCR2_OC_T;
  237. // timer_ccr3_oc
  238. typedef union {
  239. uint32_t v;
  240. struct
  241. {
  242. uint32_t timer_ccr3_compare : 16; // [15:0]
  243. uint32_t __31_16 : 16; // [31:16]
  244. } b;
  245. } REG_GPT_TIMER_CCR3_OC_T;
  246. // timer_ccr4_oc
  247. typedef union {
  248. uint32_t v;
  249. struct
  250. {
  251. uint32_t timer_ccr4_compare : 16; // [15:0]
  252. uint32_t __31_16 : 16; // [31:16]
  253. } b;
  254. } REG_GPT_TIMER_CCR4_OC_T;
  255. // isr
  256. typedef union {
  257. uint32_t v;
  258. struct
  259. {
  260. uint32_t compare_int : 4; // [3:0], read only
  261. uint32_t __11_4 : 8; // [11:4]
  262. uint32_t capture_int : 4; // [15:12], read only
  263. uint32_t __29_16 : 14; // [29:16]
  264. uint32_t slave_trig : 1; // [30], read only
  265. uint32_t event_update : 1; // [31], read only
  266. } b;
  267. } REG_GPT_ISR_T;
  268. // irsr
  269. typedef union {
  270. uint32_t v;
  271. struct
  272. {
  273. uint32_t compare_int : 4; // [3:0], read only
  274. uint32_t __11_4 : 8; // [11:4]
  275. uint32_t capture_int : 4; // [15:12], read only
  276. uint32_t __29_16 : 14; // [29:16]
  277. uint32_t slave_trig : 1; // [30], read only
  278. uint32_t event_update : 1; // [31], read only
  279. } b;
  280. } REG_GPT_IRSR_T;
  281. // mask
  282. typedef union {
  283. uint32_t v;
  284. struct
  285. {
  286. uint32_t compare_int : 4; // [3:0]
  287. uint32_t __11_4 : 8; // [11:4]
  288. uint32_t capture_int : 4; // [15:12]
  289. uint32_t __29_16 : 14; // [29:16]
  290. uint32_t slave_trig : 1; // [30]
  291. uint32_t event_update : 1; // [31]
  292. } b;
  293. } REG_GPT_MASK_T;
  294. // clr
  295. typedef union {
  296. uint32_t v;
  297. struct
  298. {
  299. uint32_t compare_int : 4; // [3:0], read only
  300. uint32_t __11_4 : 8; // [11:4]
  301. uint32_t capture_int : 4; // [15:12], read only
  302. uint32_t __29_16 : 14; // [29:16]
  303. uint32_t slave_trig : 1; // [30], read only
  304. uint32_t event_update : 1; // [31], read only
  305. } b;
  306. } REG_GPT_CLR_T;
  307. // cr
  308. #define GPT_CEN (1 << 0)
  309. #define GPT_CKD(n) (((n)&0x3) << 1)
  310. #define GPT_UDIS (1 << 3)
  311. #define GPT_OPM (1 << 4)
  312. #define GPT_DIR (1 << 5)
  313. #define GPT_CMS(n) (((n)&0x3) << 6)
  314. #define GPT_ARPE (1 << 8)
  315. #define GPT_TRI(n) (((n)&0x7) << 9)
  316. #define GPT_TRI_CNT_EN (1 << 12)
  317. #define GPT_REFCLK_SEL (1 << 31)
  318. // smcr
  319. #define GPT_SMS(n) (((n)&0x7) << 0)
  320. // egr
  321. #define GPT_UG (1 << 0)
  322. // ccmr_oc1
  323. #define GPT_CC1S(n) (((n)&0x3) << 0)
  324. #define GPT_OC1FE (1 << 2)
  325. #define GPT_OC1PE (1 << 3)
  326. #define GPT_OC1M(n) (((n)&0x7) << 4)
  327. #define GPT_OC1CE (1 << 7)
  328. #define GPT_CC2S(n) (((n)&0x3) << 8)
  329. #define GPT_OC2FE (1 << 10)
  330. #define GPT_OC2PE (1 << 11)
  331. #define GPT_OC2M(n) (((n)&0x7) << 12)
  332. #define GPT_OC2CE (1 << 15)
  333. #define GPT_CC3S(n) (((n)&0x3) << 16)
  334. #define GPT_OC3FE (1 << 18)
  335. #define GPT_OC3PE (1 << 19)
  336. #define GPT_OC3M(n) (((n)&0x7) << 20)
  337. #define GPT_OC3CE (1 << 23)
  338. #define GPT_CC4S(n) (((n)&0x3) << 24)
  339. #define GPT_OC4FE (1 << 26)
  340. #define GPT_OC4PE (1 << 27)
  341. #define GPT_OC4M(n) (((n)&0x7) << 28)
  342. #define GPT_OC4CE (1 << 31)
  343. // ccmr_ic1
  344. #define GPT_IC1PSC(n) (((n)&0x3) << 0)
  345. #define GPT_IC1F(n) (((n)&0xf) << 2)
  346. #define GPT_IC2PSC(n) (((n)&0x3) << 8)
  347. #define GPT_IC2F(n) (((n)&0xf) << 10)
  348. #define GPT_IC3PSC(n) (((n)&0x3) << 16)
  349. #define GPT_IC3F(n) (((n)&0xf) << 18)
  350. #define GPT_IC4PSC(n) (((n)&0x3) << 24)
  351. #define GPT_IC4F(n) (((n)&0xf) << 26)
  352. // ccer
  353. #define GPT_CC1E (1 << 0)
  354. #define GPT_CC1P (1 << 1)
  355. #define GPT_CC2E (1 << 2)
  356. #define GPT_CC2P (1 << 3)
  357. #define GPT_CC3E (1 << 4)
  358. #define GPT_CC3P (1 << 5)
  359. #define GPT_CC4E (1 << 6)
  360. #define GPT_CC4P (1 << 7)
  361. // cnt
  362. #define GPT_CNT_VALUE(n) (((n)&0xffff) << 0)
  363. // psc
  364. #define GPT_PSC_VALUE(n) (((n)&0xffff) << 0)
  365. // arr
  366. #define GPT_ARR_VALUE(n) (((n)&0xffff) << 0)
  367. // timer_ccr1_ic
  368. #define GPT_TIMER_CCR1_CAPTURE(n) (((n)&0xffff) << 0)
  369. // timer_ccr2_ic
  370. #define GPT_TIMER_CCR2_CAPTURE(n) (((n)&0xffff) << 0)
  371. // timer_ccr3_ic
  372. #define GPT_TIMER_CCR3_CAPTURE(n) (((n)&0xffff) << 0)
  373. // timer_ccr4_ic
  374. #define GPT_TIMER_CCR4_CAPTURE(n) (((n)&0xffff) << 0)
  375. // timer_ccr1_oc
  376. #define GPT_TIMER_CCR1_COMPARE(n) (((n)&0xffff) << 0)
  377. // timer_ccr2_oc
  378. #define GPT_TIMER_CCR2_COMPARE(n) (((n)&0xffff) << 0)
  379. // timer_ccr3_oc
  380. #define GPT_TIMER_CCR3_COMPARE(n) (((n)&0xffff) << 0)
  381. // timer_ccr4_oc
  382. #define GPT_TIMER_CCR4_COMPARE(n) (((n)&0xffff) << 0)
  383. // isr
  384. #define GPT_COMPARE_INT(n) (((n)&0xf) << 0)
  385. #define GPT_CAPTURE_INT(n) (((n)&0xf) << 12)
  386. #define GPT_SLAVE_TRIG (1 << 30)
  387. #define GPT_EVENT_UPDATE (1 << 31)
  388. // irsr
  389. #define GPT_COMPARE_INT(n) (((n)&0xf) << 0)
  390. #define GPT_CAPTURE_INT(n) (((n)&0xf) << 12)
  391. #define GPT_SLAVE_TRIG (1 << 30)
  392. #define GPT_EVENT_UPDATE (1 << 31)
  393. // mask
  394. #define GPT_COMPARE_INT(n) (((n)&0xf) << 0)
  395. #define GPT_CAPTURE_INT(n) (((n)&0xf) << 12)
  396. #define GPT_SLAVE_TRIG (1 << 30)
  397. #define GPT_EVENT_UPDATE (1 << 31)
  398. // clr
  399. #define GPT_COMPARE_INT(n) (((n)&0xf) << 0)
  400. #define GPT_CAPTURE_INT(n) (((n)&0xf) << 12)
  401. #define GPT_SLAVE_TRIG (1 << 30)
  402. #define GPT_EVENT_UPDATE (1 << 31)
  403. #endif // _GPT_H_