hpm_pllctlv2_regs.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306
  1. /*
  2. * Copyright (c) 2021-2023 HPMicro
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. *
  6. */
  7. #ifndef HPM_PLLCTLV2_H
  8. #define HPM_PLLCTLV2_H
  9. typedef struct {
  10. __RW uint32_t XTAL; /* 0x0: OSC configuration */
  11. __R uint8_t RESERVED0[124]; /* 0x4 - 0x7F: Reserved */
  12. struct {
  13. __RW uint32_t MFI; /* 0x80: PLL0 multiple register */
  14. __RW uint32_t MFN; /* 0x84: PLL0 fraction numerator register */
  15. __RW uint32_t MFD; /* 0x88: PLL0 fraction demoninator register */
  16. __RW uint32_t SS_STEP; /* 0x8C: PLL0 spread spectrum step register */
  17. __RW uint32_t SS_STOP; /* 0x90: PLL0 spread spectrum stop register */
  18. __RW uint32_t CONFIG; /* 0x94: PLL0 confguration register */
  19. __RW uint32_t LOCKTIME; /* 0x98: PLL0 lock time register */
  20. __RW uint32_t STEPTIME; /* 0x9C: PLL0 step time register */
  21. __RW uint32_t ADVANCED; /* 0xA0: PLL0 advance configuration register */
  22. __R uint8_t RESERVED0[28]; /* 0xA4 - 0xBF: Reserved */
  23. __RW uint32_t DIV[3]; /* 0xC0 - 0xC8: PLL0 divider output 0 configuration register */
  24. __R uint8_t RESERVED1[52]; /* 0xCC - 0xFF: Reserved */
  25. } PLL[3];
  26. } PLLCTLV2_Type;
  27. /* Bitfield definition for register: XTAL */
  28. /*
  29. * BUSY (RO)
  30. *
  31. * Busy flag
  32. * 0: Oscillator is working or shutdown
  33. * 1: Oscillator is changing status
  34. */
  35. #define PLLCTLV2_XTAL_BUSY_MASK (0x80000000UL)
  36. #define PLLCTLV2_XTAL_BUSY_SHIFT (31U)
  37. #define PLLCTLV2_XTAL_BUSY_GET(x) (((uint32_t)(x) & PLLCTLV2_XTAL_BUSY_MASK) >> PLLCTLV2_XTAL_BUSY_SHIFT)
  38. /*
  39. * RESPONSE (RO)
  40. *
  41. * Crystal oscillator status
  42. * 0: Oscillator is not stable
  43. * 1: Oscillator is stable for use
  44. */
  45. #define PLLCTLV2_XTAL_RESPONSE_MASK (0x20000000UL)
  46. #define PLLCTLV2_XTAL_RESPONSE_SHIFT (29U)
  47. #define PLLCTLV2_XTAL_RESPONSE_GET(x) (((uint32_t)(x) & PLLCTLV2_XTAL_RESPONSE_MASK) >> PLLCTLV2_XTAL_RESPONSE_SHIFT)
  48. /*
  49. * ENABLE (RO)
  50. *
  51. * Crystal oscillator enable status
  52. * 0: Oscillator is off
  53. * 1: Oscillator is on
  54. */
  55. #define PLLCTLV2_XTAL_ENABLE_MASK (0x10000000UL)
  56. #define PLLCTLV2_XTAL_ENABLE_SHIFT (28U)
  57. #define PLLCTLV2_XTAL_ENABLE_GET(x) (((uint32_t)(x) & PLLCTLV2_XTAL_ENABLE_MASK) >> PLLCTLV2_XTAL_ENABLE_SHIFT)
  58. /*
  59. * RAMP_TIME (RW)
  60. *
  61. * Rampup time of XTAL oscillator in cycles of RC24M clock
  62. * 0: 0 cycle
  63. * 1: 1 cycle
  64. * 2: 2 cycle
  65. * 1048575: 1048575 cycles
  66. */
  67. #define PLLCTLV2_XTAL_RAMP_TIME_MASK (0xFFFFFUL)
  68. #define PLLCTLV2_XTAL_RAMP_TIME_SHIFT (0U)
  69. #define PLLCTLV2_XTAL_RAMP_TIME_SET(x) (((uint32_t)(x) << PLLCTLV2_XTAL_RAMP_TIME_SHIFT) & PLLCTLV2_XTAL_RAMP_TIME_MASK)
  70. #define PLLCTLV2_XTAL_RAMP_TIME_GET(x) (((uint32_t)(x) & PLLCTLV2_XTAL_RAMP_TIME_MASK) >> PLLCTLV2_XTAL_RAMP_TIME_SHIFT)
  71. /* Bitfield definition for register of struct array PLL: MFI */
  72. /*
  73. * BUSY (RO)
  74. *
  75. * Busy flag
  76. * 0: PLL is stable or shutdown
  77. * 1: PLL is changing status
  78. */
  79. #define PLLCTLV2_PLL_MFI_BUSY_MASK (0x80000000UL)
  80. #define PLLCTLV2_PLL_MFI_BUSY_SHIFT (31U)
  81. #define PLLCTLV2_PLL_MFI_BUSY_GET(x) (((uint32_t)(x) & PLLCTLV2_PLL_MFI_BUSY_MASK) >> PLLCTLV2_PLL_MFI_BUSY_SHIFT)
  82. /*
  83. * RESPONSE (RO)
  84. *
  85. * PLL status
  86. * 0: PLL is not stable
  87. * 1: PLL is stable for use
  88. */
  89. #define PLLCTLV2_PLL_MFI_RESPONSE_MASK (0x20000000UL)
  90. #define PLLCTLV2_PLL_MFI_RESPONSE_SHIFT (29U)
  91. #define PLLCTLV2_PLL_MFI_RESPONSE_GET(x) (((uint32_t)(x) & PLLCTLV2_PLL_MFI_RESPONSE_MASK) >> PLLCTLV2_PLL_MFI_RESPONSE_SHIFT)
  92. /*
  93. * ENABLE (RO)
  94. *
  95. * PLL enable status
  96. * 0: PLL is off
  97. * 1: PLL is on
  98. */
  99. #define PLLCTLV2_PLL_MFI_ENABLE_MASK (0x10000000UL)
  100. #define PLLCTLV2_PLL_MFI_ENABLE_SHIFT (28U)
  101. #define PLLCTLV2_PLL_MFI_ENABLE_GET(x) (((uint32_t)(x) & PLLCTLV2_PLL_MFI_ENABLE_MASK) >> PLLCTLV2_PLL_MFI_ENABLE_SHIFT)
  102. /*
  103. * MFI (RW)
  104. *
  105. * loop back divider of PLL, support from 13 to 42, f=fref*(mfi + mfn/mfd)
  106. * 0-15: invalid
  107. * 16: divide by 16
  108. * 17: divide by17
  109. * . . .
  110. * 42: divide by 42
  111. * 43~:invalid
  112. */
  113. #define PLLCTLV2_PLL_MFI_MFI_MASK (0x7FU)
  114. #define PLLCTLV2_PLL_MFI_MFI_SHIFT (0U)
  115. #define PLLCTLV2_PLL_MFI_MFI_SET(x) (((uint32_t)(x) << PLLCTLV2_PLL_MFI_MFI_SHIFT) & PLLCTLV2_PLL_MFI_MFI_MASK)
  116. #define PLLCTLV2_PLL_MFI_MFI_GET(x) (((uint32_t)(x) & PLLCTLV2_PLL_MFI_MFI_MASK) >> PLLCTLV2_PLL_MFI_MFI_SHIFT)
  117. /* Bitfield definition for register of struct array PLL: MFN */
  118. /*
  119. * MFN (RW)
  120. *
  121. * Numeratorof fractional part,f=fref*(mfi + mfn/mfd). This field supports changing while running.
  122. */
  123. #define PLLCTLV2_PLL_MFN_MFN_MASK (0x3FFFFFFFUL)
  124. #define PLLCTLV2_PLL_MFN_MFN_SHIFT (0U)
  125. #define PLLCTLV2_PLL_MFN_MFN_SET(x) (((uint32_t)(x) << PLLCTLV2_PLL_MFN_MFN_SHIFT) & PLLCTLV2_PLL_MFN_MFN_MASK)
  126. #define PLLCTLV2_PLL_MFN_MFN_GET(x) (((uint32_t)(x) & PLLCTLV2_PLL_MFN_MFN_MASK) >> PLLCTLV2_PLL_MFN_MFN_SHIFT)
  127. /* Bitfield definition for register of struct array PLL: MFD */
  128. /*
  129. * MFD (RW)
  130. *
  131. * Demoninator of fraction part,f=fref*(mfi + mfn/mfd). This field should not be changed during PLL enabled. If changed, change will take efftect when PLL re-enabled.
  132. */
  133. #define PLLCTLV2_PLL_MFD_MFD_MASK (0x3FFFFFFFUL)
  134. #define PLLCTLV2_PLL_MFD_MFD_SHIFT (0U)
  135. #define PLLCTLV2_PLL_MFD_MFD_SET(x) (((uint32_t)(x) << PLLCTLV2_PLL_MFD_MFD_SHIFT) & PLLCTLV2_PLL_MFD_MFD_MASK)
  136. #define PLLCTLV2_PLL_MFD_MFD_GET(x) (((uint32_t)(x) & PLLCTLV2_PLL_MFD_MFD_MASK) >> PLLCTLV2_PLL_MFD_MFD_SHIFT)
  137. /* Bitfield definition for register of struct array PLL: SS_STEP */
  138. /*
  139. * STEP (RW)
  140. *
  141. * Step of spread spectrum modulator.
  142. * This register should not be changed during PLL and spread spectrum enabled. If changed, new value will take effect when PLL disabled or spread spectrum disabled.
  143. */
  144. #define PLLCTLV2_PLL_SS_STEP_STEP_MASK (0x3FFFFFFFUL)
  145. #define PLLCTLV2_PLL_SS_STEP_STEP_SHIFT (0U)
  146. #define PLLCTLV2_PLL_SS_STEP_STEP_SET(x) (((uint32_t)(x) << PLLCTLV2_PLL_SS_STEP_STEP_SHIFT) & PLLCTLV2_PLL_SS_STEP_STEP_MASK)
  147. #define PLLCTLV2_PLL_SS_STEP_STEP_GET(x) (((uint32_t)(x) & PLLCTLV2_PLL_SS_STEP_STEP_MASK) >> PLLCTLV2_PLL_SS_STEP_STEP_SHIFT)
  148. /* Bitfield definition for register of struct array PLL: SS_STOP */
  149. /*
  150. * STOP (RW)
  151. *
  152. * Stop point of spread spectrum modulator
  153. * This register should not be changed during PLL and spread spectrum enabled. If changed, new value will take effect when PLL disabled or spread spectrum disabled.
  154. */
  155. #define PLLCTLV2_PLL_SS_STOP_STOP_MASK (0x3FFFFFFFUL)
  156. #define PLLCTLV2_PLL_SS_STOP_STOP_SHIFT (0U)
  157. #define PLLCTLV2_PLL_SS_STOP_STOP_SET(x) (((uint32_t)(x) << PLLCTLV2_PLL_SS_STOP_STOP_SHIFT) & PLLCTLV2_PLL_SS_STOP_STOP_MASK)
  158. #define PLLCTLV2_PLL_SS_STOP_STOP_GET(x) (((uint32_t)(x) & PLLCTLV2_PLL_SS_STOP_STOP_MASK) >> PLLCTLV2_PLL_SS_STOP_STOP_SHIFT)
  159. /* Bitfield definition for register of struct array PLL: CONFIG */
  160. /*
  161. * SPREAD (RW)
  162. *
  163. * Enable spread spectrum function. This field supports changing during PLL running.
  164. */
  165. #define PLLCTLV2_PLL_CONFIG_SPREAD_MASK (0x100U)
  166. #define PLLCTLV2_PLL_CONFIG_SPREAD_SHIFT (8U)
  167. #define PLLCTLV2_PLL_CONFIG_SPREAD_SET(x) (((uint32_t)(x) << PLLCTLV2_PLL_CONFIG_SPREAD_SHIFT) & PLLCTLV2_PLL_CONFIG_SPREAD_MASK)
  168. #define PLLCTLV2_PLL_CONFIG_SPREAD_GET(x) (((uint32_t)(x) & PLLCTLV2_PLL_CONFIG_SPREAD_MASK) >> PLLCTLV2_PLL_CONFIG_SPREAD_SHIFT)
  169. /*
  170. * REFSEL (RW)
  171. *
  172. * Select reference clock, This filed support changing while running, but application must take frequency error and jitter into consideration. And if MFN changed before reference switch, application need make sure time is enough for MFN updating.
  173. * 0: XTAL24M
  174. * 1: IRC24M
  175. */
  176. #define PLLCTLV2_PLL_CONFIG_REFSEL_MASK (0x1U)
  177. #define PLLCTLV2_PLL_CONFIG_REFSEL_SHIFT (0U)
  178. #define PLLCTLV2_PLL_CONFIG_REFSEL_SET(x) (((uint32_t)(x) << PLLCTLV2_PLL_CONFIG_REFSEL_SHIFT) & PLLCTLV2_PLL_CONFIG_REFSEL_MASK)
  179. #define PLLCTLV2_PLL_CONFIG_REFSEL_GET(x) (((uint32_t)(x) & PLLCTLV2_PLL_CONFIG_REFSEL_MASK) >> PLLCTLV2_PLL_CONFIG_REFSEL_SHIFT)
  180. /* Bitfield definition for register of struct array PLL: LOCKTIME */
  181. /*
  182. * LOCKTIME (RW)
  183. *
  184. * Lock time of PLL in 24M clock cycles, typical value is 2500. If MFI changed during PLL startup, PLL lock time may be longer than this setting.
  185. */
  186. #define PLLCTLV2_PLL_LOCKTIME_LOCKTIME_MASK (0xFFFFU)
  187. #define PLLCTLV2_PLL_LOCKTIME_LOCKTIME_SHIFT (0U)
  188. #define PLLCTLV2_PLL_LOCKTIME_LOCKTIME_SET(x) (((uint32_t)(x) << PLLCTLV2_PLL_LOCKTIME_LOCKTIME_SHIFT) & PLLCTLV2_PLL_LOCKTIME_LOCKTIME_MASK)
  189. #define PLLCTLV2_PLL_LOCKTIME_LOCKTIME_GET(x) (((uint32_t)(x) & PLLCTLV2_PLL_LOCKTIME_LOCKTIME_MASK) >> PLLCTLV2_PLL_LOCKTIME_LOCKTIME_SHIFT)
  190. /* Bitfield definition for register of struct array PLL: STEPTIME */
  191. /*
  192. * STEPTIME (RW)
  193. *
  194. * Step time for MFI on-the-fly change in 24M clock cycles, typical value is 2500.
  195. */
  196. #define PLLCTLV2_PLL_STEPTIME_STEPTIME_MASK (0xFFFFU)
  197. #define PLLCTLV2_PLL_STEPTIME_STEPTIME_SHIFT (0U)
  198. #define PLLCTLV2_PLL_STEPTIME_STEPTIME_SET(x) (((uint32_t)(x) << PLLCTLV2_PLL_STEPTIME_STEPTIME_SHIFT) & PLLCTLV2_PLL_STEPTIME_STEPTIME_MASK)
  199. #define PLLCTLV2_PLL_STEPTIME_STEPTIME_GET(x) (((uint32_t)(x) & PLLCTLV2_PLL_STEPTIME_STEPTIME_MASK) >> PLLCTLV2_PLL_STEPTIME_STEPTIME_SHIFT)
  200. /* Bitfield definition for register of struct array PLL: ADVANCED */
  201. /*
  202. * SLOW (RW)
  203. *
  204. * Use slow lock flow, PLL lock expendite is disabled. This mode might be stabler. And software need config LOCKTIME field accordingly.
  205. * 0: fast lock enabled, lock time is 100us
  206. * 1: fast lock disabled, lock time is 400us
  207. */
  208. #define PLLCTLV2_PLL_ADVANCED_SLOW_MASK (0x10000000UL)
  209. #define PLLCTLV2_PLL_ADVANCED_SLOW_SHIFT (28U)
  210. #define PLLCTLV2_PLL_ADVANCED_SLOW_SET(x) (((uint32_t)(x) << PLLCTLV2_PLL_ADVANCED_SLOW_SHIFT) & PLLCTLV2_PLL_ADVANCED_SLOW_MASK)
  211. #define PLLCTLV2_PLL_ADVANCED_SLOW_GET(x) (((uint32_t)(x) & PLLCTLV2_PLL_ADVANCED_SLOW_MASK) >> PLLCTLV2_PLL_ADVANCED_SLOW_SHIFT)
  212. /*
  213. * DITHER (RW)
  214. *
  215. * Enable dither function
  216. */
  217. #define PLLCTLV2_PLL_ADVANCED_DITHER_MASK (0x1000000UL)
  218. #define PLLCTLV2_PLL_ADVANCED_DITHER_SHIFT (24U)
  219. #define PLLCTLV2_PLL_ADVANCED_DITHER_SET(x) (((uint32_t)(x) << PLLCTLV2_PLL_ADVANCED_DITHER_SHIFT) & PLLCTLV2_PLL_ADVANCED_DITHER_MASK)
  220. #define PLLCTLV2_PLL_ADVANCED_DITHER_GET(x) (((uint32_t)(x) & PLLCTLV2_PLL_ADVANCED_DITHER_MASK) >> PLLCTLV2_PLL_ADVANCED_DITHER_SHIFT)
  221. /* Bitfield definition for register of struct array PLL: DIV0 */
  222. /*
  223. * BUSY (RO)
  224. *
  225. * Busy flag
  226. * 0: divider is working
  227. * 1: divider is changing status
  228. */
  229. #define PLLCTLV2_PLL_DIV_BUSY_MASK (0x80000000UL)
  230. #define PLLCTLV2_PLL_DIV_BUSY_SHIFT (31U)
  231. #define PLLCTLV2_PLL_DIV_BUSY_GET(x) (((uint32_t)(x) & PLLCTLV2_PLL_DIV_BUSY_MASK) >> PLLCTLV2_PLL_DIV_BUSY_SHIFT)
  232. /*
  233. * RESPONSE (RO)
  234. *
  235. * Divider response status
  236. * 0: Divider is not stable
  237. * 1: Divider is stable for use
  238. */
  239. #define PLLCTLV2_PLL_DIV_RESPONSE_MASK (0x20000000UL)
  240. #define PLLCTLV2_PLL_DIV_RESPONSE_SHIFT (29U)
  241. #define PLLCTLV2_PLL_DIV_RESPONSE_GET(x) (((uint32_t)(x) & PLLCTLV2_PLL_DIV_RESPONSE_MASK) >> PLLCTLV2_PLL_DIV_RESPONSE_SHIFT)
  242. /*
  243. * ENABLE (RO)
  244. *
  245. * Divider enable status
  246. * 0: Divider is off
  247. * 1: Divider is on
  248. */
  249. #define PLLCTLV2_PLL_DIV_ENABLE_MASK (0x10000000UL)
  250. #define PLLCTLV2_PLL_DIV_ENABLE_SHIFT (28U)
  251. #define PLLCTLV2_PLL_DIV_ENABLE_GET(x) (((uint32_t)(x) & PLLCTLV2_PLL_DIV_ENABLE_MASK) >> PLLCTLV2_PLL_DIV_ENABLE_SHIFT)
  252. /*
  253. * DIV (RW)
  254. *
  255. * Divider factor, divider factor is DIV/5 + 1
  256. * 0: divide by 1
  257. * 1: divide by 1.2
  258. * 2: divide by 1.4
  259. * . . .
  260. * 63: divide by 13.6
  261. */
  262. #define PLLCTLV2_PLL_DIV_DIV_MASK (0x3FU)
  263. #define PLLCTLV2_PLL_DIV_DIV_SHIFT (0U)
  264. #define PLLCTLV2_PLL_DIV_DIV_SET(x) (((uint32_t)(x) << PLLCTLV2_PLL_DIV_DIV_SHIFT) & PLLCTLV2_PLL_DIV_DIV_MASK)
  265. #define PLLCTLV2_PLL_DIV_DIV_GET(x) (((uint32_t)(x) & PLLCTLV2_PLL_DIV_DIV_MASK) >> PLLCTLV2_PLL_DIV_DIV_SHIFT)
  266. /* DIV register group index macro definition */
  267. #define PLLCTLV2_PLL_DIV_DIV0 (0UL)
  268. #define PLLCTLV2_PLL_DIV_DIV1 (1UL)
  269. #define PLLCTLV2_PLL_DIV_DIV2 (2UL)
  270. /* PLL register group index macro definition */
  271. #define PLLCTLV2_PLL_PLL0 (0UL)
  272. #define PLLCTLV2_PLL_PLL1 (1UL)
  273. #define PLLCTLV2_PLL_PLL2 (2UL)
  274. #endif /* HPM_PLLCTLV2_H */