rk32xx.h 21 KB

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