rk32xx.h 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667
  1. /*++
  2. Copyright (c) 2015 Minoca Corp. All Rights Reserved
  3. Module Name:
  4. rk32xx.h
  5. Abstract:
  6. This header contains definitions for the Rockchip 32xx SoC.
  7. Author:
  8. Chris Stevens 30-Jul-2015
  9. --*/
  10. //
  11. // ------------------------------------------------------------------- Includes
  12. //
  13. //
  14. // --------------------------------------------------------------------- Macros
  15. //
  16. //
  17. // This macro computes a PLL clock frequency based on an input frequency of
  18. // 24MHz and the formula given in section 3.9.1. PLL Usage of the RK3288 TRM.
  19. //
  20. #define RK32_CRU_PLL_COMPUTE_CLOCK_FREQUENCY(_Nf, _Nr, _No) \
  21. ((24 * (_Nf)) / ((_Nr) * (_No))) * 1000000
  22. //
  23. // ---------------------------------------------------------------- Definitions
  24. //
  25. //
  26. // Define the number of timers in the SoC.
  27. //
  28. #define RK32_TIMER_COUNT 8
  29. //
  30. // Define the RK3288 register base map.
  31. //
  32. #define RK32_SD_BASE 0xFF0C0000
  33. #define RK32_EMMC_BASE 0xFF0F0000
  34. #define RK32_I2C_PMU_BASE 0xFF650000
  35. #define RK32_TIMER0_5_BASE 0xFF6B0000
  36. #define RK32_UART_DEBUG_BASE 0xFF690000
  37. #define RK32_SRAM_BASE 0xFF700000
  38. #define RK32_PMU_BASE 0xFF730000
  39. #define RK32_GPIO0_BASE 0xFF750000
  40. #define RK32_CRU_BASE 0xFF760000
  41. #define RK32_GRF_BASE 0xFF770000
  42. #define RK32_GPIO7_BASE 0xFF7E0000
  43. #define RK32_WATCHDOG_BASE 0xFF800000
  44. #define RK32_TIMER6_7_BASE 0xFF810000
  45. #define RK32_VOP_BIG_BASE 0xFF930000
  46. #define RK32_VOP_LITTLE_BASE 0xFF940000
  47. #define RK32_GIC_DISTRIBUTOR_BASE 0xFFC01000
  48. #define RK32_GIC_CPU_INTERFACE_BASE 0xFFC02000
  49. #define RK32_I2C_PMU_SIZE 0x1000
  50. #define RK32_GPIO0_SIZE 0x1000
  51. //
  52. // Define the RK3288 interrupt map.
  53. //
  54. #define RK32_INTERRUPT_USBOTG 55
  55. #define RK32_INTERRUPT_EHCI 56
  56. #define RK32_INTERRUPT_SDMMC 64
  57. #define RK32_INTERRUPT_EMMC 67
  58. #define RK32_INTERRUPT_OHCI 73
  59. #define RK32_INTERRUPT_TIMER0 98
  60. #define RK32_INTERRUPT_TIMER1 99
  61. #define RK32_INTERRUPT_TIMER2 100
  62. #define RK32_INTERRUPT_TIMER3 101
  63. #define RK32_INTERRUPT_TIMER4 102
  64. #define RK32_INTERRUPT_TIMER5 103
  65. #define RK32_INTERRUPT_TIMER6 104
  66. #define RK32_INTERRUPT_TIMER7 105
  67. //
  68. // Define the RK32 watchdog range.
  69. //
  70. #define RK32_WATCHDOG_MIN 0x0000FFFF
  71. #define RK32_WATCHDOG_MAX 0x7FFFFFFF
  72. //
  73. // Define timer parameters.
  74. //
  75. #define RK32_TIMER_FREQUENCY 24000000
  76. #define RK32_TIMER_REGISTER_STRIDE 0x00000020
  77. //
  78. // Define generic PLL register bits, organized by configuration register.
  79. //
  80. #define RK32_PLL_CONFIGURATION0_NR_MASK (0x3F << 8)
  81. #define RK32_PLL_CONFIGURATION0_NR_SHIFT 8
  82. #define RK32_PLL_CONFIGURATION0_OD_MASK (0xF << 0)
  83. #define RK32_PLL_CONFIGURATION0_OD_SHIFT 0
  84. #define RK32_PLL_CONFIGURATION1_NF_MASK (0x1FFF << 0)
  85. #define RK32_PLL_CONFIGURATION1_NF_SHIFT 0
  86. #define RK32_PLL_CONFIGURATION2_BWADJ_MASK (0xFFF << 0)
  87. #define RK32_PLL_CONFIGURATION2_BWADJ_SHIFT 0
  88. #define RK32_PLL_CONFIGURATION3_RESET (1 << 5)
  89. //
  90. // Define the CRU codec PLL control 0 register bits.
  91. //
  92. #define RK32_CRU_CODEC_PLL_CONTROL0_PROTECT_SHIFT 16
  93. #define RK32_CRU_CODEC_PLL_CONTROL0_CLKR_MASK (0x3F << 8)
  94. #define RK32_CRU_CODEC_PLL_CONTROL0_CLKR_SHIFT 8
  95. #define RK32_CRU_CODEC_PLL_CONTROL0_CLKOD_MASK (0xF << 0)
  96. #define RK32_CRU_CODEC_PLL_CONTROL0_CLKOD_SHIFT 0
  97. //
  98. // Define the CRU codec PLL control 1 register bits.
  99. //
  100. #define RK32_CRU_CODEC_PLL_CONTROL1_LOCK (1 << 31)
  101. #define RK32_CRU_CODEC_PLL_CONTROL1_CLKF_MASK (0x1FFF << 0)
  102. #define RK32_CRU_CODEC_PLL_CONTROL1_CLKF_SHIFT 0
  103. //
  104. // Define the CRU general PLL control 0 register bits.
  105. //
  106. #define RK32_CRU_GENERAL_PLL_CONTROL0_PROTECT_SHIFT 16
  107. #define RK32_CRU_GENERAL_PLL_CONTROL0_CLKR_MASK (0x3F << 8)
  108. #define RK32_CRU_GENERAL_PLL_CONTROL0_CLKR_SHIFT 8
  109. #define RK32_CRU_GENERAL_PLL_CONTROL0_CLKOD_MASK (0xF << 0)
  110. #define RK32_CRU_GENERAL_PLL_CONTROL0_CLKOD_SHIFT 0
  111. //
  112. // Define the CRU general PLL control 1 register bits.
  113. //
  114. #define RK32_CRU_GENERAL_PLL_CONTROL1_LOCK (1 << 31)
  115. #define RK32_CRU_GENERAL_PLL_CONTROL1_CLKF_MASK (0x1FFF << 0)
  116. #define RK32_CRU_GENERAL_PLL_CONTROL1_CLKF_SHIFT 0
  117. //
  118. // Define the PLL clock mode frequencies.
  119. //
  120. #define RK32_CRU_PLL_SLOW_MODE_FREQUENCY 24000000
  121. #define RK32_CRU_PLL_DEEP_SLOW_MODE_FREQUENCY 32768
  122. //
  123. // Define the three mode values for the CRU mode control register.
  124. //
  125. #define RK32_CRU_MODE_CONTROL_SLOW_MODE 0
  126. #define RK32_CRU_MODE_CONTROL_NORMAL_MODE 1
  127. #define RK32_CRU_MODE_CONTROL_DEEP_SLOW_MODE 2
  128. //
  129. // Define the CRU mode control register bits.
  130. //
  131. #define RK32_CRU_MODE_CONTROL_PROTECT_SHIFT 16
  132. #define RK32_CRU_MODE_CONTROL_NEW_PLL_MODE_MASK (0x3 << 14)
  133. #define RK32_CRU_MODE_CONTROL_NEW_PLL_MODE_SHIFT 14
  134. #define RK32_CRU_MODE_CONTROL_GENERAL_PLL_MODE_MASK (0x3 << 12)
  135. #define RK32_CRU_MODE_CONTROL_GENERAL_PLL_MODE_SHIFT 12
  136. #define RK32_CRU_MODE_CONTROL_CODEC_PLL_MODE_MASK (0x3 << 8)
  137. #define RK32_CRU_MODE_CONTROL_CODEC_PLL_MODE_SHIFT 8
  138. #define RK32_CRU_MODE_CONTROL_DDR_PLL_MODE_MASK (0x3 << 4)
  139. #define RK32_CRU_MODE_CONTROL_DDR_PLL_MODE_SHIFT 4
  140. #define RK32_CRU_MODE_CONTROL_ARM_PLL_MODE_SLOW (0x0 << 0)
  141. #define RK32_CRU_MODE_CONTROL_ARM_PLL_MODE_NORMAL (0x1 << 0)
  142. #define RK32_CRU_MODE_CONTROL_ARM_PLL_MODE_DEEP_SLOW (0x2 << 0)
  143. #define RK32_CRU_MODE_CONTROL_ARM_PLL_MODE_MASK (0x3 << 0)
  144. #define RK32_CRU_MODE_CONTROL_ARM_PLL_MODE_SHIFT 0
  145. //
  146. // Define the CRU clock select 1 register bits.
  147. //
  148. #define RK32_CRU_CLOCK_SELECT1_PROTECT_SHIFT 16
  149. #define RK32_CRU_CLOCK_SELECT1_GENERAL_PLL (1 << 15)
  150. #define RK32_CRU_CLOCK_SELECT1_PCLK_DIVIDER_MASK (0x7 << 12)
  151. #define RK32_CRU_CLOCK_SELECT1_PCLK_DIVIDER_SHIFT 12
  152. #define RK32_CRU_CLOCK_SELECT1_HCLK_DIVIDER_MASK (0x3 << 8)
  153. #define RK32_CRU_CLOCK_SELECT1_HCLK_DIVIDER_SHIFT 8
  154. #define RK32_CRU_CLOCK_SELECT1_ACLK_DIVIDER_MASK (0x1F << 3)
  155. #define RK32_CRU_CLOCK_SELECT1_ACLK_DIVIDER_SHIFT 3
  156. #define RK32_CRU_CLOCK_SELECT1_ACLK_DIVIDER1_MASK (0x7 << 0)
  157. #define RK32_CRU_CLOCK_SELECT1_ACLK_DIVIDER1_SHIFT 0
  158. //
  159. // Define the CRU clock select 11 register bits.
  160. //
  161. #define RK32_CRU_CLOCK_SELECT11_PROTECT_SHIFT 16
  162. #define RK32_CRU_CLOCK_SELECT11_HSIC_PHY_DIVIDER_MASK (0x3F << 8)
  163. #define RK32_CRU_CLOCK_SELECT11_HSIC_PHY_DIVIDER_SHIFT 8
  164. #define RK32_CRU_CLOCK_SELECT11_MMC0_CODEC_PLL 0
  165. #define RK32_CRU_CLOCK_SELECT11_MMC0_GENERAL_PLL 1
  166. #define RK32_CRU_CLOCK_SELECT11_MMC0_24MHZ 2
  167. #define RK32_CRU_CLOCK_SELECT11_MMC0_CLOCK_MASK (0x3 << 6)
  168. #define RK32_CRU_CLOCK_SELECT11_MMC0_CLOCK_SHIFT 6
  169. #define RK32_CRU_CLOCK_SELECT11_MMC0_DIVIDER_MASK (0x3F << 0)
  170. #define RK32_CRU_CLOCK_SELECT11_MMC0_DIVIDER_SHIFT 0
  171. //
  172. // Define CRU clock select 12 register bits.
  173. //
  174. #define RK32_CRU_CLOCK_SELECT12_EMMC_CODEC_PLL 0
  175. #define RK32_CRU_CLOCK_SELECT12_EMMC_GENERAL_PLL 1
  176. #define RK32_CRU_CLOCK_SELECT12_EMMC_24MHZ 2
  177. #define RK32_CRU_CLOCK_SELECT12_EMMC_CLOCK_SHIFT 14
  178. #define RK32_CRU_CLOCK_SELECT12_EMMC_DIVIDER_SHIFT 8
  179. #define RK32_CRU_CLOCK_SELECT12_EMMC_CLOCK_MASK (0x3 << 14)
  180. #define RK32_CRU_CLOCK_SELECT12_EMMC_DIVIDER_MASK (0x3F << 8)
  181. #define RK32_CRU_CLOCK_SELECT12_PROTECT_SHIFT 16
  182. //
  183. // Define the CRU clock select 33 register bits.
  184. //
  185. #define RK32_CRU_CLOCK_SELECT33_PROTECT_SHIFT 16
  186. #define RK32_CRU_CLOCK_SELECT33_ALIVE_PCLK_DIVIDER_MASK (0x1F << 8)
  187. #define RK32_CRU_CLOCK_SELECT33_ALIVE_PCLK_DIVIDER_SHIFT 8
  188. #define RK32_CRU_CLOCK_SELECT33_PMU_PCLK_DIVIDER_MASK (0x1F << 0)
  189. #define RK32_CRU_CLOCK_SELECT33_PMU_PCLK_DIVIDER_SHIFT 0
  190. //
  191. // Define generic CRU clock select value for SD/eMMC.
  192. //
  193. #define RK32_CRU_MAX_MMC_DIVISOR 0x3F
  194. #define RK32_CRU_CLOCK_SELECT_PROTECT_SHIFT 16
  195. #define RK32_CRU_CLOCK_SELECT_CODEC_PLL 0
  196. #define RK32_CRU_CLOCK_SELECT_GENERAL_PLL 1
  197. #define RK32_CRU_CLOCK_SELECT_24MHZ 2
  198. #define RK32_CRU_CLOCK_SELECT_CLOCK_MASK (0x3 << 6)
  199. #define RK32_CRU_CLOCK_SELECT_CLOCK_SHIFT 6
  200. #define RK32_CRU_CLOCK_SELECT_DIVIDER_MASK (0x3F << 0)
  201. #define RK32_CRU_CLOCK_SELECT_DIVIDER_SHIFT 0
  202. //
  203. // Define CRU global reset values.
  204. //
  205. #define RK32_GLOBAL_RESET1_VALUE 0x0000FDB9
  206. #define RK32_GLOBAL_RESET2_VALUE 0x0000ECA8
  207. //
  208. // Define CRU soft reset 0 register bits.
  209. //
  210. #define RK32_CRU_SOFT_RESET0_PROTECT_SHIFT 16
  211. #define RK32_CRU_SOFT_RESET0_CORE0 0x00000001
  212. #define RK32_CRU_SOFT_RESET0_CORE1 0x00000002
  213. #define RK32_CRU_SOFT_RESET0_CORE2 0x00000004
  214. #define RK32_CRU_SOFT_RESET0_CORE3 0x00000008
  215. //
  216. // Define CRU soft reset 8 register bits.
  217. //
  218. #define RK32_CRU_SOFT_RESET8_PROTECT_SHIFT 16
  219. #define RK32_CRU_SOFT_RESET8_MMC0 0x00000001
  220. //
  221. // Define PMU power down control register bits.
  222. //
  223. #define RK32_PMU_POWER_DOWN_CONTROL_A17_0 0x00000001
  224. #define RK32_PMU_POWER_DOWN_CONTROL_A17_1 0x00000002
  225. #define RK32_PMU_POWER_DOWN_CONTROL_A17_2 0x00000004
  226. #define RK32_PMU_POWER_DOWN_CONTROL_A17_3 0x00000008
  227. //
  228. // Define PMU power down status register bits.
  229. //
  230. #define RK32_PMU_POWER_DOWN_STATUS_A17_0 0x00000001
  231. #define RK32_PMU_POWER_DOWN_STATUS_A17_1 0x00000002
  232. #define RK32_PMU_POWER_DOWN_STATUS_A17_2 0x00000004
  233. #define RK32_PMU_POWER_DOWN_STATUS_A17_3 0x00000008
  234. //
  235. // Define the default values for the I2C PMU iomux.
  236. //
  237. #define RK32_PMU_IOMUX_I2C0_SDA_DEFAULT (1 << 14)
  238. #define RK32_PMU_IOMUX_I2C0_SCL_DEFAULT (1 << 0)
  239. //
  240. // Define GRF I/O Vsel register bits.
  241. //
  242. #define RK32_GRF_IO_VSEL_LCD_V18 0x00000001
  243. #define RK32_GRF_IO_VSEL_PROTECT_SHIFT 16
  244. //
  245. // Define GPIO SoC status 1 register bits.
  246. //
  247. #define RK32_GRF_SOC_STATUS1_ARM_PLL_LOCK (1 << 6)
  248. //
  249. // Define the GRF GPIO6C IOMUX value for SD/MMC.
  250. //
  251. #define RK32_GRF_GPIO6C_IOMUX_VALUE 0x2AAA1555
  252. //
  253. // Define the GRF GPIO7CH IOMUX initialization values.
  254. //
  255. #define RK32_GRF_GPIO7CH_IOMUX_VALUE 0x33001100
  256. //
  257. // Define LCD system control register bits.
  258. //
  259. #define RK32_LCD_SYSTEM_CONTROL_AUTO_GATING (1 << 23)
  260. #define RK32_LCD_SYSTEM_CONTROL_STANDBY (1 << 22)
  261. #define RK32_LCD_SYSTEM_CONTROL_DMA_STOP (1 << 21)
  262. #define RK32_LCD_SYSTEM_CONTROL_MMU_ENABLE (1 << 20)
  263. #define RK32_LCD_SYSTEM_CONTROL_MIPI_OUT (1 << 15)
  264. #define RK32_LCD_SYSTEM_CONTROL_EDP_OUT (1 << 14)
  265. #define RK32_LCD_SYSTEM_CONTROL_HDMI_OUT (1 << 13)
  266. #define RK32_LCD_SYSTEM_CONTROL_RGB_OUT (1 << 12)
  267. //
  268. // Define LCD DSP Control 0 register bits.
  269. //
  270. #define RK32_LCD_DSP_CONTROL0_BLACK (1 << 19)
  271. #define RK32_LCD_DSP_CONTROL0_BLANK (1 << 18)
  272. #define RK32_LCD_DSP_CONTROL0_OUT_ZERO (1 << 17)
  273. #define RK32_LCD_DSP_CONTROL0_DCLOCK_POLARITY (1 << 7)
  274. #define RK32_LCD_DSP_CONTROL0_DENABLE_POLARITY (1 << 6)
  275. #define RK32_LCD_DSP_CONTROL0_VSYNC_POLARITY (1 << 5)
  276. #define RK32_LCD_DSP_CONTROL0_HSYNC_POLARITY (1 << 4)
  277. //
  278. // Define LCD DSP control 1 register bits.
  279. //
  280. #define RK32_LCD_DSP_CONTROL1_LAYER3_SEL_SHIFT 14
  281. #define RK32_LCD_DSP_CONTROL1_LAYER2_SEL_SHIFT 12
  282. #define RK32_LCD_DSP_CONTROL1_LAYER1_SEL_SHIFT 10
  283. #define RK32_LCD_DSP_CONTROL1_LAYER0_SEL_SHIFT 8
  284. #define RK32_LCD_DSP_CONTROL1_DITHER_UP (1 << 6)
  285. #define RK32_LCD_DSP_CONTROL1_DITHER_DOWN_SELECT (1 << 4)
  286. #define RK32_LCD_DSP_CONTROL1_DITHER_DOWN_MODE (1 << 3)
  287. #define RK32_LCD_DSP_CONTROL1_DITHER_DOWN (1 << 2)
  288. #define RK32_LCD_DSP_CONTROL1_PRE_DITHER_DOWN (1 << 1)
  289. //
  290. // Define the LCD display information register bits.
  291. //
  292. #define RK32_LCD_DSP_INFORMATION_HEIGHT_MASK (0xFFF << 16)
  293. #define RK32_LCD_DSP_INFORMATION_HEIGHT_SHIFT 16
  294. #define RK32_LCD_DSP_INFORMATION_WIDTH_MASK (0xFFF << 0)
  295. #define RK32_LCD_DSP_INFORMATION_WIDTH_SHIFT 0
  296. //
  297. // Define the bits for the GPIO 7 data register.
  298. //
  299. #define RK32_GPIO7_BACKLIGHT_ENABLE 0x00000001
  300. #define RK32_GPIO7_LCD_BACKLIGHT 0x00000004
  301. //
  302. // Define the bits for the I2C control register.
  303. //
  304. #define RK32_I2C_CONTROL_STOP_ON_NAK (1 << 6)
  305. #define RK32_I2C_CONTROL_SEND_NAK (1 << 5)
  306. #define RK32_I2C_CONTROL_STOP (1 << 4)
  307. #define RK32_I2C_CONTROL_START (1 << 3)
  308. #define RK32_I2C_CONTROL_MODE_TRANSMIT (0x0 << 1)
  309. #define RK32_I2C_CONTROL_MODE_TRANSMIT_RECEIVE (0x1 << 1)
  310. #define RK32_I2C_CONTROL_MODE_RECEIVE (0x2 << 1)
  311. #define RK32_I2C_CONTROL_MODE_MASK (0x3 << 1)
  312. #define RK32_I2C_CONTROL_MODE_SHIFT 1
  313. #define RK32_I2C_CONTROL_ENABLE (1 << 0)
  314. #define RK32_I2C_BUFFER_SIZE 32
  315. //
  316. // Define the bits for the I2C clock divisor register.
  317. //
  318. #define RK32_I2C_CLOCK_DIVISOR_HIGH_MASK (0xFFFF << 16)
  319. #define RK32_I2C_CLOCK_DIVISOR_HIGH_SHIFT 16
  320. #define RK32_I2C_CLOCK_DIVISOR_LOW_MASK (0xFFFF << 0)
  321. #define RK32_I2C_CLOCK_DIVISOR_LOW_SHIFT 0
  322. //
  323. // Define the bits for the I2C master receive slave address register.
  324. //
  325. #define RK32_I2C_MASTER_RECEIVE_SLAVE_ADDRESS_HIGH_BYTE_VALID (1 << 26)
  326. #define RK32_I2C_MASTER_RECEIVE_SLAVE_ADDRESS_MIDDLE_BYTE_VALID (1 << 25)
  327. #define RK32_I2C_MASTER_RECEIVE_SLAVE_ADDRESS_LOW_BYTE_VALID (1 << 24)
  328. #define RK32_I2C_MASTER_RECEIVE_SLAVE_ADDRESS_MASK (0x7FFFFF << 1)
  329. #define RK32_I2C_MASTER_RECEIVE_SLAVE_ADDRESS_SHIFT 1
  330. #define RK32_I2C_MASTER_RECEIVE_SLAVE_ADDRESS_WRITE (0 << 0)
  331. #define RK32_I2C_MASTER_RECEIVE_SLAVE_ADDRESS_READ (1 << 0)
  332. //
  333. // Define the bits for the I2C master receive slave register.
  334. //
  335. #define RK32_I2C_MASTER_RECEIVE_SLAVE_REGISTER_HIGH_BYTE_VALID (1 << 26)
  336. #define RK32_I2C_MASTER_RECEIVE_SLAVE_REGISTER_MIDDLE_BYTE_VALID (1 << 25)
  337. #define RK32_I2C_MASTER_RECEIVE_SLAVE_REGISTER_LOW_BYTE_VALID (1 << 24)
  338. #define RK32_I2C_MASTER_RECEIVE_SLAVE_REGISTER_MASK (0xFFFFFF << 0)
  339. #define RK32_I2C_MASTER_RECEIVE_SLAVE_REGISTER_SHIFT 0
  340. //
  341. // Define the bits for the I2C master transmit count register.
  342. //
  343. #define RK32_I2C_MASTER_TRANSMIT_COUNT_MASK (0x3F << 0)
  344. #define RK32_I2C_MASTER_TRANSMIT_COUNT_SHIFT 0
  345. //
  346. // Define the bits for the I2C master receive count register.
  347. //
  348. #define RK32_I2C_MASTER_RECEIVE_COUNT_MASK (0x3F << 0)
  349. #define RK32_I2C_MASTER_RECEIVE_COUNT_SHIFT 0
  350. //
  351. // Define the bits for the I2C interrupt registers.
  352. //
  353. #define RK32_I2C_INTERRUPT_NAK (1 << 6)
  354. #define RK32_I2C_INTERRUPT_STOP (1 << 5)
  355. #define RK32_I2C_INTERRUPT_START (1 << 4)
  356. #define RK32_I2C_INTERRUPT_MASTER_RECEIVE_FINISHED (1 << 3)
  357. #define RK32_I2C_INTERRUPT_MASTER_TRANSMIT_FINISHED (1 << 2)
  358. #define RK32_I2C_INTERRUPT_BYTE_RECEIVE_FINISHED (1 << 1)
  359. #define RK32_I2C_INTERRUPT_BYTE_TRANSMIT_FINISHED (1 << 0)
  360. #define RK32_I2C_INTERRUPT_MASK \
  361. (RK32_I2C_INTERRUPT_NAK | \
  362. RK32_I2C_INTERRUPT_STOP | \
  363. RK32_I2C_INTERRUPT_START | \
  364. RK32_I2C_INTERRUPT_MASTER_RECEIVE_FINISHED | \
  365. RK32_I2C_INTERRUPT_MASTER_TRANSMIT_FINISHED | \
  366. RK32_I2C_INTERRUPT_BYTE_RECEIVE_FINISHED | \
  367. RK32_I2C_INTERRUPT_BYTE_TRANSMIT_FINISHED)
  368. //
  369. // Define the bits for the I2C finished count register.
  370. //
  371. #define RK32_I2C_FINISHED_COUNT_MASK (0x3F << 0)
  372. #define RK32_I2C_FINISHED_COUNT_SHIFT 0
  373. //
  374. // Define the UART parameters.
  375. //
  376. #define RK32_UART_BASE_BAUD 1497600
  377. #define RK32_UART_REGISTER_OFFSET 0
  378. #define RK32_UART_REGISTER_SHIFT 2
  379. //
  380. // Define the default frequency for the SD/MMC.
  381. //
  382. #define RK32_SDMMC_FREQUENCY_24MHZ 24000000
  383. //
  384. // Define attributes of the timers.
  385. //
  386. #define RK32_TIMER_BIT_WIDTH 64
  387. #define RK32_TIMER_BLOCK_SIZE 0x1000
  388. //
  389. // Define RK32 timer register bits.
  390. //
  391. //
  392. // Control bits
  393. //
  394. #define RK32_TIMER_CONTROL_ENABLE 0x00000001
  395. #define RK32_TIMER_CONTROL_ONE_SHOT 0x00000002
  396. #define RK32_TIMER_CONTROL_INTERRUPT_ENABLE 0x00000004
  397. #define RK32_WATCHDOG_CONTROL_ENABLE 0x00000001
  398. #define RK32_WATCHDOG_CONTROL_BARK_FIRST 0x00000002
  399. #define RK32_WATCHDOG_RESTART_VALUE 0x00000076
  400. //
  401. // ------------------------------------------------------ Data Type Definitions
  402. //
  403. typedef enum _RK32_CRU_REGISTER {
  404. Rk32CruArmPllConfiguration0 = 0x00,
  405. Rk32CruArmPllConfiguration1 = 0x04,
  406. Rk32CruArmPllConfiguration2 = 0x08,
  407. Rk32CruArmPllConfiguration3 = 0x0C,
  408. Rk32CruDdrPllConfiguration0 = 0x10,
  409. Rk32CruDdrPllConfiguration1 = 0x14,
  410. Rk32CruDdrPllConfiguration2 = 0x18,
  411. Rk32CruDdrPllConfiguration3 = 0x1C,
  412. Rk32CruCodecPllConfiguration0 = 0x20,
  413. Rk32CruCodecPllConfiguration1 = 0x24,
  414. Rk32CruCodecPllConfiguration2 = 0x28,
  415. Rk32CruCodecPllConfiguration3 = 0x2C,
  416. Rk32CruGeneralPllConfiguration0 = 0x30,
  417. Rk32CruGeneralPllConfiguration1 = 0x34,
  418. Rk32CruGeneralPllConfiguration2 = 0x38,
  419. Rk32CruGeneralPllConfiguration3 = 0x3C,
  420. Rk32CruNewPllConfiguration0 = 0x40,
  421. Rk32CruNewPllConfiguration1 = 0x44,
  422. Rk32CruNewPllConfiguration2 = 0x48,
  423. Rk32CruNewPllConfiguration3 = 0x4C,
  424. Rk32CruModeControl = 0x50,
  425. Rk32CruClockSelect0 = 0x60,
  426. Rk32CruClockSelect1 = 0x64,
  427. Rk32CruClockSelect11 = 0x8C,
  428. Rk32CruClockSelect12 = 0x90,
  429. Rk32CruClockSelect33 = 0xE4,
  430. Rk32CruGlobalReset1 = 0x1B0,
  431. Rk32CruGlobalReset2 = 0x1B4,
  432. Rk32CruSoftReset0 = 0x1B8,
  433. Rk32CruSoftReset1 = 0x1BC,
  434. Rk32CruSoftReset2 = 0x1C0,
  435. Rk32CruSoftReset3 = 0x1C4,
  436. Rk32CruSoftReset4 = 0x1C8,
  437. Rk32CruSoftReset5 = 0x1CC,
  438. Rk32CruSoftReset6 = 0x1D0,
  439. Rk32CruSoftReset7 = 0x1D4,
  440. Rk32CruSoftReset8 = 0x1D8,
  441. Rk32CruSoftReset9 = 0x1DC,
  442. Rk32CruSoftReset10 = 0x1E0,
  443. Rk32CruSoftReset11 = 0x1E4,
  444. } RK32_CRU_REGISTER, *PRK32_CRU_REGISTER;
  445. typedef enum _RK32_PLL_TYPE {
  446. Rk32PllNew,
  447. Rk32PllGeneral,
  448. Rk32PllCodec,
  449. Rk32PllDdr,
  450. Rk32PllArm
  451. } RK32_PLL_TYPE, *PRK32_PLL_TYPE;
  452. typedef enum _RK32_PMU_REGISTER {
  453. Rk32PmuPowerDownControl = 0x08,
  454. Rk32PmuPowerDownStatus = 0x0C,
  455. Rk32PmuIomuxI2c0Sda = 0x88,
  456. Rk32PmuIomuxI2c0Scl = 0x8C
  457. } RK32_PMU_REGISTER, *PRK32_PMU_REGISTER;
  458. typedef enum _RK32_GRF_REGISTER {
  459. Rk32GrfGpio6cIomux = 0x64,
  460. Rk32GrfGpio7chIomux = 0x78,
  461. Rk32GrfSocStatus0 = 0x280,
  462. Rk32GrfSocStatus1 = 0x284,
  463. Rk32GrfIoVsel = 0x380,
  464. } RK32_GRF_REGISTER, *PRK32_GRF_REGISTER;
  465. typedef enum _RK32_LCD_REGISTER {
  466. Rk32LcdConfigurationDone = 0x00,
  467. Rk32LcdSystemControl = 0x08,
  468. Rk32LcdSystemControl1 = 0x0C,
  469. Rk32LcdDspControl0 = 0x10,
  470. Rk32LcdDspControl1 = 0x14,
  471. Rk32LcdBackground = 0x18,
  472. Rk32LcdMcuControl = 0x1C,
  473. Rk32LcdInterruptControl0 = 0x20,
  474. Rk32LcdInterruptControl1 = 0x24,
  475. Rk32LcdWin0YrgbFrameBufferBase = 0x40,
  476. Rk32LcdWin0ActiveInformation = 0x48,
  477. Rk32LcdWin0DisplayInformation = 0x4C,
  478. } RK32_LCD_REGISTER, *PRK32_LCD_REGISTER;
  479. typedef enum _RK32_GPIO_REGISTER {
  480. Rk32GpioPortAData = 0x00,
  481. Rk32GpioPortADirection = 0x04,
  482. Rk32GpioInterruptEnable = 0x30,
  483. Rk32GpioInterruptMask = 0x34,
  484. Rk32GpioInterruptLevel = 0x38,
  485. Rk32GpioInterruptPolarity = 0x3C,
  486. Rk32GpioInterruptStatus = 0x40,
  487. Rk32GpioRawInterruptStatus = 0x44,
  488. Rk32GpioDebounce = 0x48,
  489. Rk32GpioClearInterrupt = 0x4C,
  490. Rk32GpioPortAExternal = 0x50,
  491. Rk32GpioLevelSensitiveSync = 0x60,
  492. } RK32_GPIO_REGISTER, *PRK32_GPIO_REGISTER;
  493. typedef enum _RK32_I2C_REGISTER {
  494. Rk32I2cControl = 0x00,
  495. Rk32I2cClockDivisor = 0x04,
  496. Rk32I2cMasterReceiveSlaveAddress = 0x08,
  497. Rk32I2cMasterReceiveSlaveRegister = 0x0C,
  498. Rk32I2cMasterTransmitCount = 0x10,
  499. Rk32I2cMasterReceiveCount = 0x14,
  500. Rk32I2cInterruptEnable = 0x18,
  501. Rk32I2cInterruptPending = 0x1C,
  502. Rk32I2cFinishedCount = 0x20,
  503. Rk32I2cTransmitData0 = 0x100,
  504. Rk32I2cTransmitData1 = 0x104,
  505. Rk32I2cTransmitData2 = 0x108,
  506. Rk32I2cTransmitData3 = 0x10C,
  507. Rk32I2cTransmitData4 = 0x110,
  508. Rk32I2cTransmitData5 = 0x114,
  509. Rk32I2cTransmitData6 = 0x118,
  510. Rk32I2cTransmitData7 = 0x11C,
  511. Rk32I2cReceiveData0 = 0x200,
  512. Rk32I2cReceiveData1 = 0x204,
  513. Rk32I2cReceiveData2 = 0x208,
  514. Rk32I2cReceiveData3 = 0x20C,
  515. Rk32I2cReceiveData4 = 0x210,
  516. Rk32I2cReceiveData5 = 0x214,
  517. Rk32I2cReceiveData6 = 0x218,
  518. Rk32I2cReceiveData7 = 0x21C
  519. } RK32_I2C_REGISTER, *PRK32_I2C_REGISTER;
  520. typedef enum _RK32_TIMER_REGISTER {
  521. Rk32TimerLoadCountLow = 0x00,
  522. Rk32TimerLoadCountHigh = 0x04,
  523. Rk32TimerCurrentValueLow = 0x08,
  524. Rk32TimerCurrentValueHigh = 0x0C,
  525. Rk32TimerControl = 0x10,
  526. Rk32TimerInterruptStatus = 0x18
  527. } RK32_TIMER_REGISTER, *PRK32_TIMER_REGISTER;
  528. typedef enum _RK32_WATCHDOG_REGISTER {
  529. Rk32WatchdogControl = 0x00,
  530. Rk32WatchdogTimeoutRange = 0x04,
  531. Rk32WatchdogCurrentCount = 0x08,
  532. Rk32WatchdogCounterRestart = 0x0C,
  533. Rk32WatchdogInterruptStatus = 0x10,
  534. Rk32WatchdogInterruptClear = 0x14
  535. } RK32_WATCHDOG_REGISTER, *PRK32_WATCHDOG_REGISTER;
  536. //
  537. // -------------------------------------------------------------------- Globals
  538. //
  539. //
  540. // -------------------------------------------------------- Function Prototypes
  541. //