wm_regs.h 43 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971
  1. /**
  2. * @file wm_regs.h
  3. *
  4. * @brief register & operation file
  5. *
  6. * @author winnermicro
  7. *
  8. * Copyright (c) 2015 Winner Microelectronics Co., Ltd.
  9. */
  10. #ifndef WM_REGS_H
  11. #define WM_REGS_H
  12. typedef volatile unsigned char vu8;
  13. typedef volatile unsigned short vu16;
  14. typedef volatile unsigned long vu32;
  15. #define M8(adr) (*((vu8 *) (adr)))
  16. #define M16(adr) (*((vu16*) (adr)))
  17. #define M32(adr) (*((vu32*) (adr)))
  18. #define ATTRIBUTE_ISR __attribute__((isr))
  19. typedef enum IRQn
  20. {
  21. /****** xt804 specific Interrupt Numbers *********************************************************/
  22. SDIO_IRQn = 0, /*!< SDIO Receiver/Transmit/Command Receiver/SDIO Command Transmit Interrupt */
  23. MAC_IRQn = 1, /*!< MAC Interrupt */
  24. RF_CFG_IRQn = 2, /*!< RF_CFG Interrupt */
  25. SEC_IRQn = 3, /*!< SEC RX/TX_MNGT/TX_DATA Interrupt */
  26. DMA_Channel0_IRQn = 4, /*!< DMA Channel 0 global Interrupt */
  27. DMA_Channel1_IRQn = 5, /*!< DMA Channel 1 global Interrupt */
  28. DMA_Channel2_IRQn = 6, /*!< DMA Channel 2 global Interrupt */
  29. DMA_Channel3_IRQn = 7, /*!< DMA Channel 3 global Interrupt */
  30. DMA_Channel4_7_IRQn = 8, /*!< DMA Channel 4~7 global Interrupt */
  31. DMA_BRUST_IRQn = 9, /*!< DMA Burst global Interrupt */
  32. I2C_IRQn = 10, /*!< I2C Interrupts */
  33. ADC_IRQn = 11, /*!< ADC Convert Interrupts */
  34. SPI_LS_IRQn = 12, /*!< Low Speed SPI Interrupt */
  35. SPI_HS_IRQn = 13, /*!< High Speed SPI Interrupt */
  36. GPIOA_IRQn = 14, /*!< GPIO A Interrupt */
  37. GPIOB_IRQn = 15, /*!< GPIO B Interrupt */
  38. UART0_IRQn = 16, /*!< UART0 Interrupts */
  39. UART1_IRQn = 17, /*!< UART1 Interrupt */
  40. TOUCH_IRQn = 18, /*!< Touch Sensor Iterrupt */
  41. UART24_IRQn = 19, /*!< UART2/3/4/5 Interrupt */
  42. BLE_IRQn = 20, /*!< BLE Interrupt */
  43. BT_IRQn = 21, /*!< BT Interrupt */
  44. PWM_IRQn = 22, /*!< PWM Interrupt */
  45. I2S_IRQn = 23, /*!< I2S Interrupts */
  46. SIDO_HOST_IRQn = 24, /*!< SDIO Host Interrupts */
  47. SYS_TICK_IRQn = 25, /*!< SYS Tick Interrupts */
  48. RSA_IRQn = 26, /*!< RSA Interrupts */
  49. CRYPTION_IRQn = 27, /*!< GPSEC Interrupts */
  50. FLASH_IRQn = 28, /*!< Flash Interrupt */
  51. PMU_IRQn = 29, /*!< PMU Interrupt */
  52. TIMER_IRQn = 30, /*!< Timer0~5 Trigger */
  53. WDG_IRQn = 31, /*!< Watch Dog Interrupt */
  54. } IRQn_Type;
  55. //#include "core_cm3.h"
  56. #include "wm_type_def.h"
  57. #ifdef __cplusplus
  58. #define __I volatile /*!< Defines 'read only' permissions */
  59. #else
  60. #define __I volatile const /*!< Defines 'read only' permissions */
  61. #endif
  62. #define __O volatile /*!< Defines 'write only' permissions */
  63. #define __IO volatile /*!< Defines 'read / write' permissions */
  64. typedef enum {DISABLE = 0, ENABLE = !DISABLE} FunctionalState;
  65. typedef volatile unsigned int TLS_REG; /* Hardware register definition */
  66. #ifndef BIT
  67. #define BIT(x) (1UL << (x))
  68. #endif
  69. #define APB_CLK (40000000) /* 40MHz */
  70. #define DEVICE_BASE_ADDR 0x40000000
  71. /***************************************************************
  72. * SDIO Reg
  73. ***************************************************************/
  74. #define HR_SDIO_BASE_ADDR (DEVICE_BASE_ADDR + 0x2400)
  75. #define HR_SDIO_CIS0 (HR_SDIO_BASE_ADDR + 0x008)
  76. #define HR_SDIO_CIS1 (HR_SDIO_BASE_ADDR + 0x00C)
  77. #define HR_SDIO_CSA (HR_SDIO_BASE_ADDR + 0x010)
  78. #define HR_SDIO_READ (HR_SDIO_BASE_ADDR + 0x014)
  79. #define HR_SDIO_WRITE (HR_SDIO_BASE_ADDR + 0x018)
  80. #define HR_SDIO_INTEN (HR_SDIO_BASE_ADDR + 0x030)
  81. #define HR_SDIO_OCR (HR_SDIO_BASE_ADDR + 0x034)
  82. #define HR_SDIO_CIA (HR_SDIO_BASE_ADDR + 0x024)
  83. #define HR_SDIO_PROG (HR_SDIO_BASE_ADDR + 0x028)
  84. /***************************************************************
  85. * SDIO HOST Reg
  86. ***************************************************************/
  87. #define HR_SDIO_HOST_BASE_ADDR (DEVICE_BASE_ADDR + 0xA00)
  88. #define HR_SDIO_HOST_MMC_CTRL (HR_SDIO_HOST_BASE_ADDR + 0x0)
  89. /***************************************************************
  90. * HSPI Reg
  91. ***************************************************************/
  92. #define HR_HSPI_BASE_ADDR (DEVICE_BASE_ADDR + 0x2600)
  93. #define HR_HSPI_CLEAR_FIFO (HR_HSPI_BASE_ADDR)
  94. #define HR_HSPI_SPI_CFG (HR_HSPI_BASE_ADDR + 0x04)
  95. #define HR_HSPI_MODE_CFG (HR_HSPI_BASE_ADDR + 0x08)
  96. #define HR_HSPI_INT_MASK (HR_HSPI_BASE_ADDR + 0x0C)
  97. #define HR_HSPI_INT_STTS (HR_HSPI_BASE_ADDR + 0x10)
  98. #define HR_HSPI_RXDAT_LEN (HR_HSPI_BASE_ADDR + 0x18)
  99. /***************************************************************
  100. * Inner Flash Reg
  101. ***************************************************************/
  102. #define HR_FLASH_BASE_ADDR (DEVICE_BASE_ADDR + 0x2000)
  103. #define HR_FLASH_CMD_ADDR (HR_FLASH_BASE_ADDR + 0x000)
  104. #define HR_FLASH_CMD_START (HR_FLASH_BASE_ADDR + 0x004)
  105. #define HR_FLASH_CR (HR_FLASH_BASE_ADDR + 0x008)
  106. #define HR_FLASH_ADDR (HR_FLASH_BASE_ADDR + 0x010)
  107. /***************************************************************
  108. * SDIO WRAPPER Register
  109. ***************************************************************/
  110. #define HR_SDIO_WRAPPER_BASE_ADDR (DEVICE_BASE_ADDR + 0x2800)
  111. #define HR_SDIO_INT_SRC (HR_SDIO_WRAPPER_BASE_ADDR + 0x000)
  112. #define HR_SDIO_INT_MASK (HR_SDIO_WRAPPER_BASE_ADDR + 0x004)
  113. #define HR_SDIO_UPCMDVALID (HR_SDIO_WRAPPER_BASE_ADDR + 0x008)
  114. #define HR_SDIO_DOWNCMDVALID (HR_SDIO_WRAPPER_BASE_ADDR + 0x00C)
  115. #define HR_SDIO_TXBD_LINKEN (HR_SDIO_WRAPPER_BASE_ADDR + 0x010)
  116. #define HR_SDIO_TXBD_ADDR (HR_SDIO_WRAPPER_BASE_ADDR + 0x014)
  117. #define HR_SDIO_TXEN (HR_SDIO_WRAPPER_BASE_ADDR + 0x018)
  118. #define HR_SDIO_TX_STTS (HR_SDIO_WRAPPER_BASE_ADDR + 0x01C)
  119. #define HR_SDIO_RXBD_LINKEN (HR_SDIO_WRAPPER_BASE_ADDR + 0x020)
  120. #define HR_SDIO_RXBD_ADDR (HR_SDIO_WRAPPER_BASE_ADDR + 0x024)
  121. #define HR_SDIO_RXEN (HR_SDIO_WRAPPER_BASE_ADDR + 0x028)
  122. #define HR_SDIO_RX_STTS (HR_SDIO_WRAPPER_BASE_ADDR + 0x02C)
  123. #define HR_SDIO_CMD_ADDR (HR_SDIO_WRAPPER_BASE_ADDR + 0x030)
  124. #define HR_SDIO_CMD_SIZE (HR_SDIO_WRAPPER_BASE_ADDR + 0x034)
  125. /* SDIO interrupt bit definition */
  126. #define SDIO_WP_INT_SRC_CMD_DOWN (1UL<<3)
  127. #define SDIO_WP_INT_SRC_CMD_UP (1UL<<2)
  128. #define SDIO_WP_INT_SRC_DATA_DOWN (1UL<<1)
  129. #define SDIO_WP_INT_SRC_DATA_UP (1UL<<0)
  130. /***************************************************************
  131. * DMA Reg
  132. ***************************************************************/
  133. #define HR_DMA_BASE_ADDR (DEVICE_BASE_ADDR + 0x800)
  134. #define HR_DMA_INT_MASK (HR_DMA_BASE_ADDR + 0x0)
  135. #define HR_DMA_INT_SRC (HR_DMA_BASE_ADDR + 0x4)
  136. #define HR_DMA_CHNL_SEL (HR_DMA_BASE_ADDR + 0x08)
  137. #define HR_DMA_CHNL0_SRC_ADDR (HR_DMA_BASE_ADDR + 0x10)
  138. #define HR_DMA_CHNL0_DEST_ADDR (HR_DMA_BASE_ADDR + 0x14)
  139. #define HR_DMA_CHNL0_SRC_WRAP_ADDR (HR_DMA_BASE_ADDR + 0x18)
  140. #define HR_DMA_CHNL0_DEST_WRAP_ADDR (HR_DMA_BASE_ADDR + 0x1C)
  141. #define HR_DMA_CHNL0_WRAP_SIZE (HR_DMA_BASE_ADDR + 0x20)
  142. #define HR_DMA_CHNL0_CHNL_CTRL (HR_DMA_BASE_ADDR + 0x24)
  143. #define HR_DMA_CHNL0_DMA_MODE (HR_DMA_BASE_ADDR + 0x28)
  144. #define HR_DMA_CHNL0_DMA_CTRL (HR_DMA_BASE_ADDR + 0x2C)
  145. #define HR_DMA_CHNL0_DMA_STATUS (HR_DMA_BASE_ADDR + 0x30)
  146. #define HR_DMA_CHNL0_LINK_DEST_ADDR (HR_DMA_BASE_ADDR + 0x34)
  147. #define HR_DMA_CHNL0_CURRENT_DEST_ADDR (HR_DMA_BASE_ADDR + 0x38)
  148. #define DMA_STARTADDRESS HR_DMA_BASE_ADDR
  149. #define DMA_INTMASK_REG (*(volatile unsigned int*)(DMA_STARTADDRESS+0x000))
  150. #define DMA_INTSRC_REG (*(volatile unsigned int*)(DMA_STARTADDRESS+0x004))
  151. #define DMA_CHANNEL_SEL (*(volatile unsigned int*)(DMA_STARTADDRESS+0x008))
  152. #define DMA_CHNL_REG_BASE (DMA_STARTADDRESS+0x010)
  153. #define DMA_SRCADDR_REG(ch) (*(volatile unsigned int*)(DMA_CHNL_REG_BASE + 0x30 * (ch /*- 1*/) +0x00))
  154. #define DMA_DESTADDR_REG(ch) (*(volatile unsigned int*)(DMA_CHNL_REG_BASE + 0x30 * (ch /*- 1*/) +0x04))
  155. #define DMA_SRCWRAPADDR_REG(ch) (*(volatile unsigned int*)(DMA_CHNL_REG_BASE + 0x30 * (ch /*- 1*/) +0x08))
  156. #define DMA_DESTWRAPADDR_REG(ch) (*(volatile unsigned int*)(DMA_CHNL_REG_BASE + 0x30 * (ch /*- 1*/) +0x0C))
  157. #define DMA_WRAPSIZE_REG(ch) (*(volatile unsigned int*)(DMA_CHNL_REG_BASE + 0x30 * (ch /*- 1*/) +0x10))
  158. #define DMA_CHNLCTRL_REG(ch) (*(volatile unsigned int*)(DMA_CHNL_REG_BASE + 0x30 * (ch /*- 1*/) +0x14))
  159. #define DMA_MODE_REG(ch) (*(volatile unsigned int*)(DMA_CHNL_REG_BASE + 0x30 * (ch /*- 1*/) +0x18))
  160. #define DMA_CTRL_REG(ch) (*(volatile unsigned int*)(DMA_CHNL_REG_BASE + 0x30 * (ch /*- 1*/) +0x1C))
  161. #define DMA_STATUS_REG(ch) (*(volatile unsigned int*)(DMA_CHNL_REG_BASE + 0x30 * (ch /*- 1*/) +0x20))
  162. #define DMA_DESC_ADDR_REG(ch) (*(volatile unsigned int*)(DMA_CHNL_REG_BASE + 0x30 * (ch /*- 1*/) +0x24))
  163. #define DMA_CURRDESTADDR_REG(ch) (*(volatile unsigned int*)(DMA_CHNL_REG_BASE + 0x30 * (ch /*- 1*/) +0x28))
  164. #define DMA_CHNL_CTRL_CHNL_ON (1<<0)
  165. #define DMA_CHNL_CTRL_CHNL_OFF (1<<1)
  166. #define DMA_MODE_HARD_MODE (1<<0)
  167. #define DMA_MODE_CHAIN_MODE (1<<1)
  168. #define DMA_MODE_SEL_MASK (0xF<<2)
  169. #define DMA_MODE_SEL_UART_RX (0<<2)
  170. #define DMA_MODE_SEL_UART_TX (1<<2)
  171. #define DMA_MODE_SEL_PWM0 (2<<2)
  172. #define DMA_DODE_SEL_PWM1 (3<<2)
  173. #define DMA_MODE_SEL_LSSPI_RX (4<<2)
  174. #define DMA_MODE_SEL_LSSPI_TX (5<<2)
  175. #define DMA_MODE_SEL_SDADC_CH0 (6<<2)
  176. #define DMA_MODE_SEL_SDADC_CH1 (7<<2)
  177. #define DMA_MODE_SEL_SDADC_CH2 (8<<2)
  178. #define DMA_MODE_SEL_SDADC_CH3 (9<<2)
  179. #define DMA_MODE_SEL_I2S_RX (10<<2)
  180. #define DMA_MODE_SEL_I2S_TX (11<<2)
  181. #define DMA_MODE_SEL_SDIOHOST (12<<2)
  182. #define DMA_MODE_CHAIN_LINK_EN (1<<6)
  183. #define DMA_CTRL_AUTO_RELOAD (1<<0)
  184. #define DMA_CTRL_SRC_ADDR_INC (1<<1)
  185. #define DMA_CTRL_SRC_ADDR_CIR (3<<1)
  186. #define DMA_CTRL_DEST_ADDR_INC (1<<3)
  187. #define DMA_CTRL_DEST_ADDR_CIR (3<<3)
  188. #define DMA_CTRL_DATA_SIZE_BYTE (0<<5)
  189. #define DMA_CTRL_DATA_SIZE_SHORT (1<<5)
  190. #define DMA_CTRL_DATA_SIZE_WORD (2<<5)
  191. #define DMA_CTRL_BURST_SIZE1 (0<<7)
  192. #define DMA_CTRL_BURST_SIZE4 (1<<7)
  193. #define DMA_CTRL_TOTAL_MASK (0xFFF<<8)
  194. #define DMA_CTRL_TOTAL_SIZE(n) (n<<8)
  195. /***************************************************************
  196. * PMU Reg
  197. ***************************************************************/
  198. #define HR_PMU_BASE_ADDR (DEVICE_BASE_ADDR + 0xD00)
  199. #define HR_PMU_PS_CR (HR_PMU_BASE_ADDR + 0x00)
  200. #define HR_PMU_TIMER0 (HR_PMU_BASE_ADDR + 0x04)
  201. #define HR_PMU_TIMER1 (HR_PMU_BASE_ADDR + 0x08)
  202. #define HR_PMU_RTC_CTRL1 (HR_PMU_BASE_ADDR + 0x0C)
  203. #define HR_PMU_RTC_CTRL2 (HR_PMU_BASE_ADDR + 0x10)
  204. #define HR_PMU_INTERRUPT_SRC (HR_PMU_BASE_ADDR + 0x14)
  205. #define HR_PMU_INTERRUPT_MASK (HR_PMU_BASE_ADDR + 0x18)
  206. #define HR_PMU_WLAN_STTS (HR_PMU_BASE_ADDR + 0x1C)
  207. #define HR_PMU_BK_REG (HR_PMU_BASE_ADDR + 0x20)
  208. #define PMU_TIMER0_NTERRUPT_SRC (1UL << 0)
  209. #define PMU_TIMER1_NTERRUPT_SRC (1UL << 1)
  210. #define PMU_GPIO_NTERRUPT_SRC (1UL << 2)
  211. /***************************************************************
  212. * system clock and bus clock Reg
  213. ***************************************************************/
  214. #define HR_CLK_BASE_ADDR (DEVICE_BASE_ADDR + 0xE00)
  215. #define HR_CLK_GATE_EN HR_CLK_BASE_ADDR
  216. #define HR_CLK_SOFT_CLK_MASK (HR_CLK_BASE_ADDR + 0x04)
  217. #define HR_CLK_BBP_CLT_CTRL (HR_CLK_BASE_ADDR + 0x08)
  218. #define HR_CLK_RST_CTL (HR_CLK_BASE_ADDR + 0x0c)
  219. #define HR_CLK_DIV_CTL (HR_CLK_BASE_ADDR + 0x10)
  220. #define HR_CLK_SEL_CTL (HR_CLK_BASE_ADDR + 0x14)
  221. #define HR_OSC_32K_REG (HR_CLK_BASE_ADDR + 0x14)
  222. #define HR_CLK_I2S_CTL (HR_CLK_BASE_ADDR + 0x18)
  223. #define HR_CLK_RST_STA (HR_CLK_BASE_ADDR + 0x1C)
  224. /***************************************************************
  225. * �ڴ�ģ��Ĵ�������
  226. ***************************************************************/
  227. #define HR_MEM_BASE_ADDR (DEVICE_BASE_ADDR + 0xF00)
  228. #define HR_MEM_TXBUF_BASE_ADDR (HR_MEM_BASE_ADDR + 0x00)
  229. #define HR_MEM_RXBUF_BASE_ADDR (HR_MEM_BASE_ADDR + 0x04)
  230. #define HR_MEM_BUF_NUM_CFG (HR_MEM_BASE_ADDR + 0x08)
  231. #define HR_MEM_BUF_SIZE_CFG (HR_MEM_BASE_ADDR + 0x0C)
  232. #define HR_MEM_AGGR_CFG (HR_MEM_BASE_ADDR + 0x10)
  233. #define HR_MEM_BUF_EN (HR_MEM_BASE_ADDR + 0x14)
  234. /***************************************************************
  235. * PSRAM CTRL Register
  236. ****************************************************************/
  237. #define HR_PSRRAM_BASE_ADDR (DEVICE_BASE_ADDR + 0x2200)
  238. #define HR_PSRAM_CTRL_ADDR (HR_PSRRAM_BASE_ADDR+ 0x00)
  239. #define HR_PSRAM_OVERTIMER_ADDR (HR_PSRRAM_BASE_ADDR+ 0x04)
  240. /* APB BaseAddr*/
  241. #define HR_APB_BASE_ADDR 0x40010000
  242. /***************************************************************
  243. * I2C Reg
  244. ***************************************************************/
  245. #define HR_I2C_BASE_ADDR (HR_APB_BASE_ADDR)
  246. #define HR_I2C_PRER_LO (HR_I2C_BASE_ADDR + 0x0)
  247. #define HR_I2C_PRER_HI (HR_I2C_BASE_ADDR + 0x04)
  248. #define HR_I2C_CTRL (HR_I2C_BASE_ADDR + 0x08)
  249. #define HR_I2C_TX_RX (HR_I2C_BASE_ADDR + 0x0C)
  250. #define HR_I2C_CR_SR (HR_I2C_BASE_ADDR + 0x10)
  251. #define HR_I2C_TXR (HR_I2C_BASE_ADDR + 0x14)
  252. #define HR_I2C_CR (HR_I2C_BASE_ADDR + 0x18)
  253. #define I2C_CTRL_INT_DISABLE (0x1UL<<6)
  254. #define I2C_CTRL_ENABLE (0x1UL<<7)
  255. #define I2C_CR_STA (0x1UL<<7)
  256. #define I2C_CR_STO (0x1UL<<6)
  257. #define I2C_CR_RD (0x1UL<<5)
  258. #define I2C_CR_WR (0x1UL<<4)
  259. #define I2C_CR_NAK (0x1UL<<3)
  260. #define I2C_CR_IACK (0x1UL)
  261. #define I2C_SR_NAK (0x1UL<<7)
  262. #define I2C_SR_BUSY (0x1UL<<6)
  263. #define I2C_SR_TIP (0x1UL<<1)
  264. #define I2C_SR_IF (0x1UL)
  265. /***************************************************************
  266. * SD ADC Reg
  267. ***************************************************************/
  268. #define HR_SD_ADC_BASE_ADDR (HR_APB_BASE_ADDR + 0x200)
  269. #define HR_SD_ADC_RESULT_REG ((HR_SD_ADC_BASE_ADDR+0x000))
  270. #define HR_SD_ADC_ANA_CTRL ((HR_SD_ADC_BASE_ADDR+0x004))
  271. #define HR_SD_ADC_PGA_CTRL ((HR_SD_ADC_BASE_ADDR+0x008))
  272. #define HR_SD_ADC_TEMP_CTRL ((HR_SD_ADC_BASE_ADDR+0x00C))
  273. #define HR_SD_ADC_CTRL ((HR_SD_ADC_BASE_ADDR+0x010))
  274. #define HR_SD_ADC_INT_STATUS ((HR_SD_ADC_BASE_ADDR+0x014))
  275. #define HR_SD_ADC_CMP_VALUE ((HR_SD_ADC_BASE_ADDR+0x018))
  276. /***************************************************************
  277. *Low Speed SPI Reg
  278. ***************************************************************/
  279. #define HR_SPI_BASE_ADDR (HR_APB_BASE_ADDR + 0x400)
  280. #define HR_SPI_CHCFG_REG (HR_SPI_BASE_ADDR + 0x000)
  281. #define HR_SPI_SPICFG_REG (HR_SPI_BASE_ADDR + 0x004)
  282. #define HR_SPI_CLKCFG_REG (HR_SPI_BASE_ADDR + 0x008)
  283. #define HR_SPI_MODECFG_REG (HR_SPI_BASE_ADDR + 0x00C)
  284. #define HR_SPI_INT_MASK_REG (HR_SPI_BASE_ADDR + 0x010)
  285. #define HR_SPI_INT_STATUS_REG (HR_SPI_BASE_ADDR + 0x014)
  286. #define HR_SPI_STATUS_REG (HR_SPI_BASE_ADDR + 0x018)
  287. #define HR_SPI_TIMEOUT_REG (HR_SPI_BASE_ADDR + 0x01C)
  288. #define HR_SPI_TXDATA_REG (HR_SPI_BASE_ADDR + 0x020)
  289. #define HR_SPI_TRANSLEN_REG (HR_SPI_BASE_ADDR + 0x024)
  290. #define HR_SPI_SLV_XMIT_LEN_REG (HR_SPI_BASE_ADDR + 0x028)
  291. #define HR_SPI_RXDATA_REG (HR_SPI_BASE_ADDR + 0x030)
  292. #define SPIM_STARTADDRESS (HR_APB_BASE_ADDR + 0x400)
  293. #define SPIM_CHCFG_REG (*(volatile unsigned int*)(SPIM_STARTADDRESS+0x000))
  294. #define SPIM_SPICFG_REG (*(volatile unsigned int*)(SPIM_STARTADDRESS+0x004))
  295. #define SPIM_CLKCFG_REG (*(volatile unsigned int*)(SPIM_STARTADDRESS+0x008))
  296. #define SPIM_MODECFG_REG (*(volatile unsigned int*)(SPIM_STARTADDRESS+0x00C))
  297. #define SPIM_INTEN_REG (*(volatile unsigned int*)(SPIM_STARTADDRESS+0x010))
  298. #define SPIM_INTSRC_REG (*(volatile unsigned int*)(SPIM_STARTADDRESS+0x014))
  299. #define SPIM_SPISTATUS_REG (*(volatile unsigned int*)(SPIM_STARTADDRESS+0x018))
  300. #define SPIM_SPITIMEOUT_REG (*(volatile unsigned int*)(SPIM_STARTADDRESS+0x01C))
  301. #define SPIM_TXDATA_REG (*(volatile unsigned int*)(SPIM_STARTADDRESS+0x020))
  302. #define SPIM_TRANSLEN_REG (*(volatile unsigned int*)(SPIM_STARTADDRESS+0x024))
  303. #define SPIM_RXDATA_REG (*(volatile unsigned int*)(SPIM_STARTADDRESS+0x030))
  304. /*RSA Reg*/
  305. #define RSA_BASE_ADDRESS 0x40000000
  306. #define RSAXBUF (*((volatile unsigned long *) (RSA_BASE_ADDRESS + 0x0 )))
  307. #define RSAYBUF (*((volatile unsigned long *) (RSA_BASE_ADDRESS + 0x100 )))
  308. #define RSAMBUF (*((volatile unsigned long *) (RSA_BASE_ADDRESS + 0x200 )))
  309. #define RSADBUF (*((volatile unsigned long *) (RSA_BASE_ADDRESS + 0x300 )))
  310. #define RSACON (*((volatile unsigned long *) (RSA_BASE_ADDRESS + 0x400 )))
  311. #define RSAMC (*((volatile unsigned long *) (RSA_BASE_ADDRESS + 0x404 )))
  312. #define RSAN (*((volatile unsigned long *) (RSA_BASE_ADDRESS + 0x408 )))
  313. /* Bits Definitions of "CH_CFG" */
  314. #define SPI_RX_INVALID_BITS(n) ((n) << 23)
  315. #define SPI_CLEAR_FIFOS (1U << 22)
  316. #define SPI_CONTINUE_MODE (1U << 21)
  317. #define SPI_RX_CHANNEL_ON (1U << 20)
  318. #define SPI_RX_CHANNEL_OFF (0U << 20)
  319. #define SPI_TX_CHANNEL_ON (1U << 19)
  320. #define SPI_TX_CHANNEL_OFF (0U << 19)
  321. #define SPI_VALID_CLKS_NUM(n) ((n) << 3)
  322. #define SPI_CS_LOW (0U << 2)
  323. #define SPI_CS_HIGH (1U << 2)
  324. #define SPI_FORCE_SPI_CS_OUT (1U << 1)
  325. #define SPI_START (1U << 0)
  326. /* Bits Definitions of "SPI_CFG" */
  327. #define SPI_FRAME_FORMAT_MOTO (0U << 17)
  328. #define SPI_FRAME_FORMAT_TI (1U << 17)
  329. #define SPI_FRAME_FORMAT_MICROWAIRE (2U << 17)
  330. #define SPI_TX_PIN_ALWS_DRIVER (1U << 16)
  331. #define SPI_CS_HOLD(n) ((n) << 12)
  332. #define CS_HOLD_1_CLKS 0
  333. #define CS_HOLD_2_CLKS 1
  334. #define CS_HOLD_4_CLKS 2
  335. #define CS_HOLD_8_CLKS 3
  336. #define CS_HOLD_16_CLKS 4
  337. #define CS_HOLD_32_CLKS 5
  338. #define CS_HOLD_64_CLKS 6
  339. #define CS_HOLD_127_CLKS 7
  340. #define SPI_CS_SETUP(n) ((n) << 9)
  341. #define CS_SETUP_1_CLKS 0
  342. #define CS_SETUP_2_CLKS 1
  343. #define CS_SETUP_4_CLKS 2
  344. #define CS_SETUP_8_CLKS 3
  345. #define CS_SETUP_16_CLKS 4
  346. #define CS_SETUP_32_CLKS 5
  347. #define CS_SETUP_64_CLKS 6
  348. #define CS_SETUP_127_CLKS 7
  349. #define SPI_DATA_OUT_DELAY(n) ((n) << 7)
  350. #define DATA_OUT_DELAY_1_CLKS 0
  351. #define DATA_OUT_DELAY_2_CLKS 1
  352. #define DATA_OUT_DELAY_3_CLKS 2
  353. #define DATA_OUT_DELAY_0_CLKS 3
  354. #define SPI_FRAME_DELAY(n) ((n) << 4)
  355. #define FRAME_DELAY_1_CLKS 0
  356. #define FRAME_DELAY_2_CLKS 1
  357. #define FRAME_DELAY_4_CLKS 2
  358. #define FRAME_DELAY_8_CLKS 3
  359. #define FRAME_DELAY_16_CLKS 4
  360. #define FRAME_DELAY_32_CLKS 5
  361. #define FRAME_DELAY_64_CLKS 6
  362. #define FRAME_DELAY_127_CLKS 7
  363. #define SPI_LITTLE_ENDIAN (0 << 3)
  364. #define SPI_BIG_ENDIAN (1 << 3)
  365. #define SPI_SET_MASTER_SLAVE(mode) ((mode) << 2)
  366. #define SPI_MASTER 1
  367. #define SPI_SLAVE 0
  368. #define SPI_SET_CPHA(n) ((n) << 1)
  369. #define SPI_SET_CPOL(n) ((n) << 0)
  370. /* Bits Definitions of "CLK_CFG" */
  371. #define SPI_GET_SCLK_DIVIDER(clk) ((APB_CLK)/((clk) * 2) - 1)/*In HZ*/
  372. #define SPI_SCLK_DIVIDER(n) ((n) << 0)
  373. /* Bits Definitions of "MODE_CFG" */
  374. #define SPI_RX_TRIGGER_LEVEL(n) ((n) << 6)
  375. #define SPI_TX_TRIGGER_LEVEL(n) ((n) << 2)
  376. #define SPI_RX_DMA_ON (1 << 1)
  377. #define SPI_RX_DMA_OFF (0 << 1)
  378. #define SPI_TX_DMA_ON (1 << 0)
  379. #define SPI_TX_DMA_OFF (0 << 0)
  380. /* Bits Definitions of SPI interrupt register(SPI_INT_MASK and SPI_INT_SOURCE) */
  381. #define SPI_INT_MASK_ALL 0xffU
  382. #define SPI_INT_CLEAR_ALL 0xffU
  383. #define SPI_INT_TIMEOUT (1U << 7)
  384. #define SPI_INT_TRANSFER_DONE (1U << 6)
  385. #define SPI_INT_RX_OVERRUN (1U << 5)
  386. #define SPI_INT_RX_UNDERRUN (1U << 4)
  387. #define SPI_INT_TX_OVERRUN (1U << 3)
  388. #define SPI_INT_TX_UNDERRUN (1U << 2)
  389. #define SPI_INT_RX_FIFO_RDY (1U << 1)
  390. #define SPI_INT_TX_FIFO_RDY (1U << 0)
  391. /* Bits Definitions of "SPI_STATUS" */
  392. #define SPI_IS_BUSY(value) ((((value) & (1 << 12)) != 0) ? 1 : 0)
  393. #define SPI_GET_RX_FIFO_CNT(value) (((value) & 0xFC0) >> 6)
  394. #define SPI_GET_TX_FIFO_CNT(value) ((value) & 0x3F)
  395. /* Bits Definitions of "SPI_TIMEOUT" */
  396. #define SPI_TIMER_EN (1U << 31)
  397. #define SPI_TIME_OUT(n) (((((n) * (APB_CLK)) / 1000) & ~(0x01U << 31)) << 0)
  398. /***************************************************************
  399. * UART Reg
  400. ***************************************************************/
  401. #define HR_UART0_BASE_ADDR (HR_APB_BASE_ADDR + 0x600)
  402. #define HR_UART1_BASE_ADDR (HR_APB_BASE_ADDR + 0x800)
  403. #define HR_UART2_BASE_ADDR (HR_APB_BASE_ADDR + 0xA00)
  404. #define HR_UART3_BASE_ADDR (HR_APB_BASE_ADDR + 0xC00)
  405. #define HR_UART4_BASE_ADDR (HR_APB_BASE_ADDR + 0xE00)
  406. #define HR_UART0_LINE_CTRL (HR_UART0_BASE_ADDR + 0x0)
  407. #define HR_UART0_FLOW_CTRL (HR_UART0_BASE_ADDR + 0x04)
  408. #define HR_UART0_DMA_CTRL (HR_UART0_BASE_ADDR + 0x08)
  409. #define HR_UART0_FIFO_CTRL (HR_UART0_BASE_ADDR + 0x0C)
  410. #define HR_UART0_BAUD_RATE_CTRL (HR_UART0_BASE_ADDR + 0x10)
  411. #define HR_UART0_INT_MASK (HR_UART0_BASE_ADDR + 0x14)
  412. #define HR_UART0_INT_SRC (HR_UART0_BASE_ADDR + 0x18)
  413. #define HR_UART0_FIFO_STATUS (HR_UART0_BASE_ADDR + 0x1C)
  414. #define HR_UART0_TX_WIN (HR_UART0_BASE_ADDR + 0x20)
  415. #define HR_UART0_RX_WIN (HR_UART0_BASE_ADDR + 0x30)
  416. #define HR_UART1_LINE_CTRL (HR_UART1_BASE_ADDR + 0x0)
  417. #define HR_UART1_FLOW_CTRL (HR_UART1_BASE_ADDR + 0x04)
  418. #define HR_UART1_DMA_CTRL (HR_UART1_BASE_ADDR + 0x08)
  419. #define HR_UART1_FIFO_CTRL (HR_UART1_BASE_ADDR + 0x0C)
  420. #define HR_UART1_BAUD_RATE_CTRL (HR_UART1_BASE_ADDR + 0x10)
  421. #define HR_UART1_INT_MASK (HR_UART1_BASE_ADDR + 0x14)
  422. #define HR_UART1_INT_SRC (HR_UART1_BASE_ADDR + 0x18)
  423. #define HR_UART1_FIFO_STATUS (HR_UART1_BASE_ADDR + 0x1C)
  424. #define HR_UART1_TX_WIN (HR_UART1_BASE_ADDR + 0x20)
  425. #define HR_UART1_RX_WIN (HR_UART1_BASE_ADDR + 0x30)
  426. #define HR_UART2_LINE_CTRL (HR_UART2_BASE_ADDR + 0x0)
  427. #define HR_UART2_FLOW_CTRL (HR_UART2_BASE_ADDR + 0x04)
  428. #define HR_UART2_DMA_CTRL (HR_UART2_BASE_ADDR + 0x08)
  429. #define HR_UART2_FIFO_CTRL (HR_UART2_BASE_ADDR + 0x0C)
  430. #define HR_UART2_BAUD_RATE_CTRL (HR_UART2_BASE_ADDR + 0x10)
  431. #define HR_UART2_INT_MASK (HR_UART2_BASE_ADDR + 0x14)
  432. #define HR_UART2_INT_SRC (HR_UART2_BASE_ADDR + 0x18)
  433. #define HR_UART2_FIFO_STATUS (HR_UART2_BASE_ADDR + 0x1C)
  434. #define HR_UART2_TX_WIN (HR_UART2_BASE_ADDR + 0x20)
  435. #define HR_UART2_RX_WIN (HR_UART2_BASE_ADDR + 0x30)
  436. #define HR_UART2_GUARD_TIME (HR_UART2_BASE_ADDR + 0x40)
  437. #define HR_UART2_WAIT_TIME (HR_UART2_BASE_ADDR + 0x44)
  438. #define HR_UART2_GT (HR_UART2_BASE_ADDR + 0x40)
  439. #define HR_UART2_WT (HR_UART2_BASE_ADDR + 0x44)
  440. #define HR_UART3_LINE_CTRL (HR_UART3_BASE_ADDR + 0x0)
  441. #define HR_UART3_FLOW_CTRL (HR_UART3_BASE_ADDR + 0x04)
  442. #define HR_UART3_DMA_CTRL (HR_UART3_BASE_ADDR + 0x08)
  443. #define HR_UART3_FIFO_CTRL (HR_UART3_BASE_ADDR + 0x0C)
  444. #define HR_UART3_BAUD_RATE_CTRL (HR_UART3_BASE_ADDR + 0x10)
  445. #define HR_UART3_INT_MASK (HR_UART3_BASE_ADDR + 0x14)
  446. #define HR_UART3_INT_SRC (HR_UART3_BASE_ADDR + 0x18)
  447. #define HR_UART3_FIFO_STATUS (HR_UART3_BASE_ADDR + 0x1C)
  448. #define HR_UART3_TX_WIN (HR_UART3_BASE_ADDR + 0x20)
  449. #define HR_UART3_RX_WIN (HR_UART3_BASE_ADDR + 0x30)
  450. #define HR_UART4_LINE_CTRL (HR_UART4_BASE_ADDR + 0x0)
  451. #define HR_UART4_FLOW_CTRL (HR_UART4_BASE_ADDR + 0x04)
  452. #define HR_UART4_DMA_CTRL (HR_UART4_BASE_ADDR + 0x08)
  453. #define HR_UART4_FIFO_CTRL (HR_UART4_BASE_ADDR + 0x0C)
  454. #define HR_UART4_BAUD_RATE_CTRL (HR_UART4_BASE_ADDR + 0x10)
  455. #define HR_UART4_INT_MASK (HR_UART4_BASE_ADDR + 0x14)
  456. #define HR_UART4_INT_SRC (HR_UART4_BASE_ADDR + 0x18)
  457. #define HR_UART4_FIFO_STATUS (HR_UART4_BASE_ADDR + 0x1C)
  458. #define HR_UART4_TX_WIN (HR_UART4_BASE_ADDR + 0x20)
  459. #define HR_UART4_RX_WIN (HR_UART4_BASE_ADDR + 0x30)
  460. /*
  461. * Line Control Register bits definition
  462. * ULCON0 ULCON1 Register
  463. */
  464. /* bit 0-1 : Word length */
  465. #define ULCON_WL5 0x00
  466. #define ULCON_WL6 0x01
  467. #define ULCON_WL7 0x02
  468. #define ULCON_WL8 0x03
  469. #define ULCON_WL_MASK 0x03
  470. /* bit 2 : Number of stop bits */
  471. #define ULCON_STOP_2 0x04 /* 2 stop bit */
  472. /* bit 3-4 : Parity mode */
  473. #define ULCON_PMD_MASK 0x18
  474. #define ULCON_PMD_EN 0x08 /* no parity */
  475. #define ULCON_PMD_ODD 0x18 /* odd parity */
  476. #define ULCON_PMD_EVEN 0x08 /* even parity */
  477. /* bit 6 uart tx enable */
  478. #define ULCON_TX_EN 0x40
  479. #define ULCON_RX_EN 0x80
  480. /* bit 6 : Infra-red mode */
  481. #define ULCON_INFRA_RED 0x80
  482. /*
  483. * auto flow control register bits definition
  484. */
  485. #define UFC_ENABLE 0x01
  486. #define UFC_SW_RTS_SET 0x02
  487. #define UFC_RTS_TRIGGER_LVL_4_BYTE (0<<2)
  488. #define UFC_RTS_TRIGGER_LVL_8_BYTE (1<<2)
  489. #define UFC_RTS_TRIGGER_LVL_12_BYTE (2<<2)
  490. #define UFC_RTS_TRIGGER_LVL_16_BYTE (3<<2)
  491. #define UFC_RTS_TRIGGER_LVL_20_BYTE (4<<2)
  492. #define UFC_RTS_TRIGGER_LVL_24_BYTE (5<<2)
  493. #define UFC_RTS_TRIGGER_LVL_28_BYTE (6<<2)
  494. #define UFC_RTS_TRIGGER_LVL_31_BYTE (7<<2)
  495. #define UFC_TX_FIFO_RESET 0x01
  496. #define UFC_RX_FIFO_RESET 0x02
  497. #define UFC_TX_FIFO_LVL_ZERO (0<<2)
  498. #define UFC_TX_FIFO_LVL_4_BYTE (1<<2)
  499. #define UFC_TX_FIFO_LVL_8_BYTE (2<<2)
  500. #define UFC_TX_FIFO_LVL_16_BYTE (3<<2)
  501. #define UFC_RX_FIFO_LVL_ZERO (0<<4)
  502. #define UFC_RX_FIFO_LVL_4_BYTE (1<<4)
  503. #define UFC_RX_FIFO_LVL_8_BYTE (2<<4)
  504. #define UFC_RX_FIFO_LVL_16_BYTE (3<<4)
  505. /* dma control */
  506. #define UDMA_RX_FIFO_TIMEOUT (1<<2)
  507. #define UDMA_RX_FIFO_TIMEOUT_SHIFT (3)
  508. /*
  509. * uart interrupt source register bits definition
  510. */
  511. #define UIS_TX_FIFO_EMPTY (1UL<<0)
  512. #define UIS_TX_FIFO (1UL<<1)
  513. #define UIS_RX_FIFO (1UL<<2)
  514. #define UIS_RX_FIFO_TIMEOUT (1UL<<3)
  515. #define UIS_CTS_CHNG (1UL<<4)
  516. #define UIS_BREAK (1UL<<5)
  517. #define UIS_FRM_ERR (1UL<<6)
  518. #define UIS_PARITY_ERR (1UL<<7)
  519. #define UIS_OVERRUN (1UL<<8)
  520. /*
  521. * fifo status register bits definition
  522. */
  523. /* bit 0-5 : tx fifo count */
  524. #define UFS_TX_FIFO_CNT_MASK 0x3F
  525. /* bit 6-11 : rx fifo count */
  526. #define UFS_RX_FIFO_CNT_MASK 0x3C0
  527. #define UFS_CST_STS (1UL<<12)
  528. /***************************************************************
  529. * GPIO Reg
  530. ***************************************************************/
  531. #define HR_GPIO_BASE_ADDR (HR_APB_BASE_ADDR + 0x1200)
  532. #define HR_GPIO_DATA (HR_GPIO_BASE_ADDR + 0x0)
  533. #define HR_GPIO_DATA_EN (HR_GPIO_BASE_ADDR + 0x04)
  534. #define HR_GPIO_DIR (HR_GPIO_BASE_ADDR + 0x08)
  535. #define HR_GPIO_PULLUP_EN (HR_GPIO_BASE_ADDR + 0x0C)
  536. #define HR_GPIO_AF_SEL (HR_GPIO_BASE_ADDR + 0x10)
  537. #define HR_GPIO_AF_S1 (HR_GPIO_BASE_ADDR + 0x14)
  538. #define HR_GPIO_AF_S0 (HR_GPIO_BASE_ADDR + 0x18)
  539. #define HR_GPIO_PULLDOWN_EN (HR_GPIO_BASE_ADDR + 0x1C)
  540. #define HR_GPIO_IS (HR_GPIO_BASE_ADDR + 0x20)
  541. #define HR_GPIO_IBE (HR_GPIO_BASE_ADDR + 0x24)
  542. #define HR_GPIO_IEV (HR_GPIO_BASE_ADDR + 0x28)
  543. #define HR_GPIO_IE (HR_GPIO_BASE_ADDR + 0x2c)
  544. #define HR_GPIO_RIS (HR_GPIO_BASE_ADDR + 0x30)
  545. #define HR_GPIO_MIS (HR_GPIO_BASE_ADDR + 0x34)
  546. #define HR_GPIO_IC (HR_GPIO_BASE_ADDR + 0x38)
  547. #define HR_GPIOA_BASE_ADDR (HR_APB_BASE_ADDR + 0x1200)
  548. #define HR_GPIOA_DATA (HR_GPIOA_BASE_ADDR + 0x0)
  549. #define HR_GPIOA_DATA_EN (HR_GPIOA_BASE_ADDR + 0x04)
  550. #define HR_GPIOA_DATA_DIR (HR_GPIOA_BASE_ADDR + 0x08)
  551. #define HR_GPIOA_DATA_PULLEN (HR_GPIOA_BASE_ADDR + 0x0c)
  552. #define HR_GPIOA_AFSEL (HR_GPIOA_BASE_ADDR + 0x10)
  553. #define HR_GPIOA_AFS1 (HR_GPIOA_BASE_ADDR + 0x14)
  554. #define HR_GPIOA_AFS0 (HR_GPIOA_BASE_ADDR + 0x18)
  555. #define HR_GPIOA_IS (HR_GPIOA_BASE_ADDR + 0x20)
  556. #define HR_GPIOA_IBE (HR_GPIOA_BASE_ADDR + 0x24)
  557. #define HR_GPIOA_IEV (HR_GPIOA_BASE_ADDR + 0x28)
  558. #define HR_GPIOA_IE (HR_GPIOA_BASE_ADDR + 0x2C)
  559. #define HR_GPIOA_RIS (HR_GPIOA_BASE_ADDR + 0x30)
  560. #define HR_GPIOA_MIS (HR_GPIOA_BASE_ADDR + 0x34)
  561. #define HR_GPIOA_IC (HR_GPIOA_BASE_ADDR + 0x38)
  562. #define HR_GPIOB_BASE_ADDR (HR_APB_BASE_ADDR + 0x1400)
  563. #define HR_GPIOB_DATA (HR_GPIOB_BASE_ADDR + 0x0)
  564. #define HR_GPIOB_DATA_EN (HR_GPIOB_BASE_ADDR + 0x04)
  565. #define HR_GPIOB_DATA_DIR (HR_GPIOB_BASE_ADDR + 0x08)
  566. #define HR_GPIOB_DATA_PULLEN (HR_GPIOB_BASE_ADDR + 0x0c)
  567. #define HR_GPIOB_AFSEL (HR_GPIOB_BASE_ADDR + 0x10)
  568. #define HR_GPIOB_AFS1 (HR_GPIOB_BASE_ADDR + 0x14)
  569. #define HR_GPIOB_AFS0 (HR_GPIOB_BASE_ADDR + 0x18)
  570. #define HR_GPIOB_IS (HR_GPIOB_BASE_ADDR + 0x20)
  571. #define HR_GPIOB_IBE (HR_GPIOB_BASE_ADDR + 0x24)
  572. #define HR_GPIOB_IEV (HR_GPIOB_BASE_ADDR + 0x28)
  573. #define HR_GPIOB_IE (HR_GPIOB_BASE_ADDR + 0x2C)
  574. #define HR_GPIOB_RIS (HR_GPIOB_BASE_ADDR + 0x30)
  575. #define HR_GPIOB_MIS (HR_GPIOB_BASE_ADDR + 0x34)
  576. #define HR_GPIOB_IC (HR_GPIOB_BASE_ADDR + 0x38)
  577. #define IO_PA_BASE_ADDR (HR_APB_BASE_ADDR + 0x1200)
  578. #define IO_PA_DATA (*(volatile unsigned int*)(IO_PA_BASE_ADDR + 0x0))
  579. #define IO_PA_EN (*(volatile unsigned int*)(IO_PA_BASE_ADDR + 0x4))
  580. #define IO_PA_DIR (*(volatile unsigned int*)(IO_PA_BASE_ADDR + 0x8))
  581. #define IO_PA_REN (*(volatile unsigned int*)(IO_PA_BASE_ADDR + 0xC))
  582. #define IO_PA_AFSEL (*(volatile unsigned int*)(IO_PA_BASE_ADDR + 0x10))
  583. #define IO_PA_AFS1 (*(volatile unsigned int*)(IO_PA_BASE_ADDR + 0x14))
  584. #define IO_PA_AFS0 (*(volatile unsigned int*)(IO_PA_BASE_ADDR + 0x18))
  585. #define IO_PB_BASE_ADDR (HR_APB_BASE_ADDR + 0x1400)
  586. #define IO_PB_DATA (*(volatile unsigned int*)(IO_PB_BASE_ADDR + 0x0))
  587. #define IO_PB_EN (*(volatile unsigned int*)(IO_PB_BASE_ADDR + 0x4))
  588. #define IO_PB_DIR (*(volatile unsigned int*)(IO_PB_BASE_ADDR + 0x8))
  589. #define IO_PB_REN (*(volatile unsigned int*)(IO_PB_BASE_ADDR + 0xC))
  590. #define IO_PB_AFSEL (*(volatile unsigned int*)(IO_PB_BASE_ADDR + 0x10))
  591. #define IO_PB_AFS1 (*(volatile unsigned int*)(IO_PB_BASE_ADDR + 0x14))
  592. #define IO_PB_AFS0 (*(volatile unsigned int*)(IO_PB_BASE_ADDR + 0x18))
  593. /***************************************************************
  594. * TIMER Reg
  595. ***************************************************************/
  596. #define HR_TIMER_BASE_ADDR (HR_APB_BASE_ADDR + 0x1800)
  597. #define HR_TIMER_CFG (HR_TIMER_BASE_ADDR + 0x0)
  598. #define HR_TIMER0_5_CSR (HR_TIMER_BASE_ADDR + 0x04)
  599. #define HR_TIMER0_PRD (HR_TIMER_BASE_ADDR + 0x08)
  600. #define HR_TIMER1_PRD (HR_TIMER_BASE_ADDR + 0x0C)
  601. #define HR_TIMER2_PRD (HR_TIMER_BASE_ADDR + 0x10)
  602. #define HR_TIMER3_PRD (HR_TIMER_BASE_ADDR + 0x14)
  603. #define HR_TIMER4_PRD (HR_TIMER_BASE_ADDR + 0x18)
  604. #define HR_TIMER5_PRD (HR_TIMER_BASE_ADDR + 0x1C)
  605. #define HR_TIMER0_CNT (HR_TIMER_BASE_ADDR + 0x20)
  606. #define HR_TIMER1_CNT (HR_TIMER_BASE_ADDR + 0x24)
  607. #define HR_TIMER2_CNT (HR_TIMER_BASE_ADDR + 0x28)
  608. #define HR_TIMER3_CNT (HR_TIMER_BASE_ADDR + 0x2C)
  609. #define HR_TIMER4_CNT (HR_TIMER_BASE_ADDR + 0x30)
  610. #define HR_TIMER5_CNT (HR_TIMER_BASE_ADDR + 0x34)
  611. /* timer csr bits defintion */
  612. #define TLS_TIMER_MS_UNIT(n) (1UL<<(0+5*n))
  613. #define TLS_TIMER_ONE_TIME(n) (1UL<<(1+5*n))
  614. #define TLS_TIMER_EN(n) (1UL<<(2+5*n))
  615. #define TLS_TIMER_INT_EN(n) (1UL<<(3+5*n))
  616. #define TLS_TIMER_INT_CLR(n) (1UL<<(4+5*n))
  617. /***************************************************************
  618. * WATCH DOG Reg
  619. ***************************************************************/
  620. #define HR_WDG_BASE_ADDR (HR_APB_BASE_ADDR + 0x1600)
  621. #define HR_WDG_LOAD_VALUE (HR_WDG_BASE_ADDR + 0x00)
  622. #define HR_WDG_CUR_VALUE (HR_WDG_BASE_ADDR + 0x04)
  623. #define HR_WDG_CTRL (HR_WDG_BASE_ADDR + 0x08)
  624. #define HR_WDG_INT_CLR (HR_WDG_BASE_ADDR + 0x0C)
  625. #define HR_WDG_INT_SRC (HR_WDG_BASE_ADDR + 0x10)
  626. #define HR_WDG_INT_MIS (HR_WDG_BASE_ADDR + 0x14)
  627. #define HR_WDG_LOCK (HR_WDG_BASE_ADDR + 0x40)
  628. /** bit field of the lcd gate control in CLK gating register */
  629. #define HR_CLK_LCD_GATE_Pos (14)
  630. /***********************************************************//**
  631. * LCD Reg
  632. ***************************************************************/
  633. #define HR_LCD_REG_BASE (HR_APB_BASE_ADDR + 0x1C00) //(0x4001 1C00)
  634. #define HR_LCD_CR (HR_LCD_REG_BASE+0x000)
  635. #define HR_LCD_FRAME_CNT (HR_LCD_REG_BASE+0x004)
  636. #define HR_LCD_COM0_SEG (HR_LCD_REG_BASE+0x008)
  637. #define HR_LCD_COM1_SEG (HR_LCD_REG_BASE+0x00C)
  638. #define HR_LCD_COM2_SEG (HR_LCD_REG_BASE+0x010)
  639. #define HR_LCD_COM3_SEG (HR_LCD_REG_BASE+0x014)
  640. #define HR_LCD_COM4_SEG (HR_LCD_REG_BASE+0x018)
  641. #define HR_LCD_COM5_SEG (HR_LCD_REG_BASE+0x01C)
  642. #define HR_LCD_COM6_SEG (HR_LCD_REG_BASE+0x020)
  643. #define HR_LCD_COM7_SEG (HR_LCD_REG_BASE+0x024)
  644. #define HR_LCD_COM_EN (HR_LCD_REG_BASE+0x028)
  645. #define HR_LCD_SEG_EN (HR_LCD_REG_BASE+0x02C)
  646. #define LCD_CR_EN_Pos (8)
  647. #define LCD_CR_PD_Pos (9)
  648. #define LCD_VDD_ON (1UL<<9)
  649. #define LCD_VDD_OFF (0UL<<9)
  650. #define LCD_EN (1UL<<8)
  651. #define LCD_BIAS_MASK (3UL<<6)
  652. #define LCD_BIAS_MASK_Pos (6)
  653. #define LCD_BIAS_ONEFOURTH (0UL<<6)
  654. #define LCD_BIAS_ONEHALF (1UL<<6)
  655. #define LCD_BIAS_ONETHIRD (2UL<<6)
  656. #define LCD_BIAS_STATIC (3UL<<6)
  657. #define LCD_VLCD_MASK (7UL<<3)
  658. #define LCD_VLCD_MASK_Pos (3)
  659. #define LCD_VLCD_27 (0UL<<3)
  660. #define LCD_VLCD_29 (1UL<<3)
  661. #define LCD_VLCD_31 (2UL<<3)
  662. #define LCD_VLCD_33 (3UL<<3)
  663. #define LCD_DUTY_MASK (7UL<<0)
  664. #define LCD_DUTY_MASK_Pos (0)
  665. #define LCD_DUTY_STATIC (0UL<<0)
  666. #define LCD_DUTY_ONEHALF (1UL<<0)
  667. #define LCD_DUTY_ONETHIRD (2UL<<0)
  668. #define LCD_DUTY_ONEFOURTH (3UL<<0)
  669. #define LCD_DUTY_ONEFIFTH (4UL<<0)
  670. #define LCD_DUTY_ONESIXTH (5UL<<0)
  671. #define LCD_DUTY_ONESEVENTH (6UL<<0)
  672. #define LCD_DUTY_ONEEIGHTH (7UL<<0)
  673. /***********************************************************//**
  674. * I2S Reg
  675. ***************************************************************/
  676. #define HR_CLK_I2S_GATE_Pos (10)
  677. #define HR_I2S_REG_BASE (HR_APB_BASE_ADDR+0x2000)
  678. #define HR_I2S_CTRL (HR_I2S_REG_BASE+0x000)
  679. #define HR_I2S_INT_MASK (HR_I2S_REG_BASE+0x004)
  680. #define HR_I2S_INT_SRC (HR_I2S_REG_BASE+0x008)
  681. #define HR_I2S_STATUS (HR_I2S_REG_BASE+0x00C)
  682. #define HR_I2S_TX (HR_I2S_REG_BASE+0x010)
  683. #define HR_I2S_RX (HR_I2S_REG_BASE+0x014)
  684. /*****************************************************************/
  685. /* APB2SPI modem spi access register definition(BT) */
  686. /*****************************************************************/
  687. #define APB2SPI_REG_BASE (HR_APB_BASE_ADDR+ 0x2200)
  688. #define APB2SPI_REG_CFG (APB2SPI_REG_BASE+ 0x0000)
  689. #define APB2SPI_REG_PS_CR (APB2SPI_REG_BASE+ 0x0004)
  690. #define APB2SPI_REG_TX_DATA (APB2SPI_REG_BASE+ 0x0008)
  691. #define APB2SPI_REG_RX_DATA (APB2SPI_REG_BASE+ 0x000C)
  692. /******************************************************************************/
  693. /* */
  694. /* PWM */
  695. /* */
  696. /******************************************************************************/
  697. #define HR_PWM_REG_BASE (HR_APB_BASE_ADDR+0x1E00)
  698. #define HR_PWM_CLKDIV01 (HR_PWM_REG_BASE+0x0000)
  699. #define HR_PWM_CLKDIV23 (HR_PWM_REG_BASE+0x0004)
  700. #define HR_PWM_CTL (HR_PWM_REG_BASE+0x0008)
  701. #define HR_PWM_PERIOD (HR_PWM_REG_BASE+0x000C)
  702. #define HR_PWM_PNUM (HR_PWM_REG_BASE+0x0010)
  703. #define HR_PWM_CMPDAT (HR_PWM_REG_BASE+0x0014)
  704. #define HR_PWM_DTCTL (HR_PWM_REG_BASE+0x0018)
  705. #define HR_PWM_INTEN (HR_PWM_REG_BASE+0x001C)
  706. #define HR_PWM_INTSTS (HR_PWM_REG_BASE+0x0020)
  707. #define HR_PWM_CAPDAT (HR_PWM_REG_BASE+0x0024)
  708. #define HR_PWM_BRKCTL (HR_PWM_REG_BASE+0x0028)
  709. #define HR_PWM_CH4_REG1 (HR_PWM_REG_BASE+0x002C)
  710. #define HR_PWM_CH4_REG2 (HR_PWM_REG_BASE+0x0030)
  711. #define HR_PWM_CAP2DAT (HR_PWM_REG_BASE+0x0034)
  712. #define HR_PWM_CAP2CTL (HR_PWM_REG_BASE+0x0038)
  713. /******************************************************************************/
  714. /* */
  715. /* TOUCH SENSOR */
  716. /* */
  717. /******************************************************************************/
  718. #define HR_TC_REG_BASE (HR_APB_BASE_ADDR+0x2400)
  719. #define HR_TC_CONFIG (HR_TC_REG_BASE+0x0000)
  720. #define SCAN_PERID_SHIFT_BIT (26)
  721. #define CAPDET_CNT_SHIFT_BIT (20)
  722. #define TOUCH_SENSOR_SEL_SHIFT_BIT (4)
  723. #define TOUCH_SENSOR_EN_BIT (0)
  724. #define HR_TC1_TRESHOLD_REG (HR_TC_REG_BASE+0x0004)
  725. #define HR_TC1_COUNT_REG (HR_TC_REG_BASE+0x0004)
  726. #define HR_TC2_TRESHOLD_REG (HR_TC_REG_BASE+0x0008)
  727. #define HR_TC2_COUNT_REG (HR_TC_REG_BASE+0x0008)
  728. #define HR_TC3_TRESHOLD_REG (HR_TC_REG_BASE+0x000C)
  729. #define HR_TC3_COUNT_REG (HR_TC_REG_BASE+0x000C)
  730. #define HR_TC4_TRESHOLD_REG (HR_TC_REG_BASE+0x0010)
  731. #define HR_TC4_COUNT_REG (HR_TC_REG_BASE+0x0010)
  732. #define HR_TC5_TRESHOLD_REG (HR_TC_REG_BASE+0x0014)
  733. #define HR_TC5_COUNT_REG (HR_TC_REG_BASE+0x0014)
  734. #define HR_TC6_TRESHOLD_REG (HR_TC_REG_BASE+0x0018)
  735. #define HR_TC6_COUNT_REG (HR_TC_REG_BASE+0x0018)
  736. #define HR_TC7_TRESHOLD_REG (HR_TC_REG_BASE+0x001C)
  737. #define HR_TC7_COUNT_REG (HR_TC_REG_BASE+0x001C)
  738. #define HR_TC8_TRESHOLD_REG (HR_TC_REG_BASE+0x0020)
  739. #define HR_TC8_COUNT_REG (HR_TC_REG_BASE+0x0020)
  740. #define HR_TC9_TRESHOLD_REG (HR_TC_REG_BASE+0x0024)
  741. #define HR_TC9_COUNT_REG (HR_TC_REG_BASE+0x0024)
  742. #define HR_TC10_TRESHOLD_REG (HR_TC_REG_BASE+0x0028)
  743. #define HR_TC10_COUNT_REG (HR_TC_REG_BASE+0x0028)
  744. #define HR_TC11_TRESHOLD_REG (HR_TC_REG_BASE+0x002C)
  745. #define HR_TC11_COUNT_REG (HR_TC_REG_BASE+0x002C)
  746. #define HR_TC12_TRESHOLD_REG (HR_TC_REG_BASE+0x0030)
  747. #define HR_TC12_COUNT_REG (HR_TC_REG_BASE+0x0030)
  748. #define HR_TC13_TRESHOLD_REG (HR_TC_REG_BASE+0x0034)
  749. #define HR_TC13_COUNT_REG (HR_TC_REG_BASE+0x0034)
  750. #define HR_TC14_TRESHOLD_REG (HR_TC_REG_BASE+0x0038)
  751. #define HR_TC14_COUNT_REG (HR_TC_REG_BASE+0x0038)
  752. #define HR_TC15_TRESHOLD_REG (HR_TC_REG_BASE+0x003C)
  753. #define HR_TC15_COUNT_REG (HR_TC_REG_BASE+0x003C)
  754. #define HR_TC16_TRESHOLD_REG (HR_TC_REG_BASE+0x0040)
  755. #define HR_TC16_COUNT_REG (HR_TC_REG_BASE+0x0040)
  756. #define HR_TC_INT_EN (HR_TC_REG_BASE+0x0044) /*bit 31:16*/
  757. #define HR_TC_INT_STATUS (HR_TC_REG_BASE+0x0044) /*bit 15:0*/
  758. /**
  759. * @defgroup System_APIs System APIs
  760. * @brief System APIs
  761. */
  762. /**
  763. * @addtogroup System_APIs
  764. * @{
  765. */
  766. /**
  767. * @defgroup REG_APIs REG APIs
  768. * @brief Register operate APIs
  769. */
  770. /**
  771. * @addtogroup REG_APIs
  772. * @{
  773. */
  774. /**
  775. * @brief This function is used to write value to register or memory
  776. *
  777. * @param[in] reg address to be written
  778. * @param[in] val value to write
  779. *
  780. * @return None
  781. *
  782. * @note None
  783. */
  784. static __inline void tls_reg_write32(unsigned int reg, unsigned int val)
  785. {
  786. *(TLS_REG *)reg = val;
  787. }
  788. /**
  789. * @brief This function is used to read value from register or memory
  790. *
  791. * @param[in] reg address to read
  792. *
  793. * @retval val read from register or memory
  794. *
  795. * @note None
  796. */
  797. static __inline unsigned int tls_reg_read32(unsigned int reg)
  798. {
  799. unsigned int val = *(TLS_REG *)reg;
  800. return val;
  801. }
  802. /**
  803. * @brief This function is used to write specified bit through
  804. bit-band alias region
  805. *
  806. * @param[in] addr 32-bit aligned byte address where the bit exists.
  807. * @param[in] bit Bit position.
  808. * @param[in] val The value that the bit is set to, 0 or 1.
  809. *
  810. * @return None
  811. *
  812. * @note Only when bit-band mechnism is supported, you can use it
  813. */
  814. static __inline void tls_bitband_write(volatile unsigned int addr, unsigned int bit, unsigned int val)
  815. {
  816. unsigned int temp;
  817. temp = (M32(addr) & ~(1 << bit)) | (val << bit);
  818. *((volatile unsigned int * )addr) = temp;
  819. }
  820. /**
  821. * @brief This function is used to read a single bit from address
  822. by bit-band alias region
  823. *
  824. * @param[in] addr 32-bit aligned byte address where the bit exists
  825. * @param[in] bit Bit position
  826. *
  827. * @retval The value of the requested bit
  828. *
  829. * @note Only when bit-band mechnism is supported, you can use it
  830. */
  831. static __inline unsigned int tls_bitband_read(volatile unsigned int addr, unsigned int bit)
  832. {
  833. unsigned int temp;
  834. temp = (M32(addr) >> bit) & 0x1;
  835. return *((volatile unsigned int *)temp);
  836. }
  837. /**
  838. * @}
  839. */
  840. /**
  841. * @}
  842. */
  843. #endif /* WM_REGS_H */