sdmmc.h 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324
  1. /* Copyright (C) 2018 RDA Technologies Limited and/or its affiliates("RDA").
  2. * All rights reserved.
  3. *
  4. * This software is supplied "AS IS" without any warranties.
  5. * RDA assumes no responsibility or liability for the use of the software,
  6. * conveys no license or title under any patent, copyright, or mask work
  7. * right to the product. RDA reserves the right to make changes in the
  8. * software without notification. RDA also make no representation or
  9. * warranty that such application will be suitable for the specified use
  10. * without further testing or modification.
  11. */
  12. #ifndef _SDMMC_H_
  13. #define _SDMMC_H_
  14. // Auto generated by dtools(see dtools.txt for its version).
  15. // Don't edit it manually!
  16. #define REG_SDMMC_BASE (0x04403000)
  17. typedef volatile struct
  18. {
  19. uint32_t apbi_ctrl_sdmmc; // 0x00000000
  20. uint32_t __4[1]; // 0x00000004
  21. uint32_t apbi_fifo_txrx; // 0x00000008
  22. uint32_t __12[509]; // 0x0000000c
  23. uint32_t sdmmc_config; // 0x00000800
  24. uint32_t sdmmc_status; // 0x00000804
  25. uint32_t sdmmc_cmd_index; // 0x00000808
  26. uint32_t sdmmc_cmd_arg; // 0x0000080c
  27. uint32_t sdmmc_resp_index; // 0x00000810
  28. uint32_t sdmmc_resp_arg3; // 0x00000814
  29. uint32_t sdmmc_resp_arg2; // 0x00000818
  30. uint32_t sdmmc_resp_arg1; // 0x0000081c
  31. uint32_t sdmmc_resp_arg0; // 0x00000820
  32. uint32_t sdmmc_data_width; // 0x00000824
  33. uint32_t sdmmc_block_size; // 0x00000828
  34. uint32_t sdmmc_block_cnt; // 0x0000082c
  35. uint32_t sdmmc_int_status; // 0x00000830
  36. uint32_t sdmmc_int_mask; // 0x00000834
  37. uint32_t sdmmc_int_clear; // 0x00000838
  38. uint32_t sdmmc_trans_speed; // 0x0000083c
  39. uint32_t sdmmc_mclk_adjust; // 0x00000840
  40. } HWP_SDMMC_T;
  41. #define hwp_sdmmc ((HWP_SDMMC_T *)REG_ACCESS_ADDRESS(REG_SDMMC_BASE))
  42. // apbi_ctrl_sdmmc
  43. typedef union {
  44. uint32_t v;
  45. struct
  46. {
  47. uint32_t l_endian : 3; // [2:0]
  48. uint32_t soft_rst_l : 1; // [3]
  49. uint32_t __31_4 : 28; // [31:4]
  50. } b;
  51. } REG_SDMMC_APBI_CTRL_SDMMC_T;
  52. // sdmmc_config
  53. typedef union {
  54. uint32_t v;
  55. struct
  56. {
  57. uint32_t sdmmc_sendcmd : 1; // [0]
  58. uint32_t sdmmc_suspend : 1; // [1]
  59. uint32_t __3_2 : 2; // [3:2]
  60. uint32_t rsp_en : 1; // [4]
  61. uint32_t rsp_sel : 2; // [6:5]
  62. uint32_t __7_7 : 1; // [7]
  63. uint32_t rd_wt_en : 1; // [8]
  64. uint32_t rd_wt_sel : 1; // [9]
  65. uint32_t s_m_sel : 1; // [10]
  66. uint32_t __15_11 : 5; // [15:11]
  67. uint32_t auto_flag_en : 1; // [16]
  68. uint32_t __31_17 : 15; // [31:17]
  69. } b;
  70. } REG_SDMMC_SDMMC_CONFIG_T;
  71. // sdmmc_status
  72. typedef union {
  73. uint32_t v;
  74. struct
  75. {
  76. uint32_t not_sdmmc_over : 1; // [0], read only
  77. uint32_t busy : 1; // [1], read only
  78. uint32_t dl_busy : 1; // [2], read only
  79. uint32_t suspend : 1; // [3], read only
  80. uint32_t __7_4 : 4; // [7:4]
  81. uint32_t rsp_error : 1; // [8], read only
  82. uint32_t no_rsp_error : 1; // [9], read only
  83. uint32_t __11_10 : 2; // [11:10]
  84. uint32_t crc_status : 3; // [14:12], read only
  85. uint32_t __15_15 : 1; // [15]
  86. uint32_t data_error : 8; // [23:16], read only
  87. uint32_t dat3_val : 1; // [24], read only
  88. uint32_t __31_25 : 7; // [31:25]
  89. } b;
  90. } REG_SDMMC_SDMMC_STATUS_T;
  91. // sdmmc_cmd_index
  92. typedef union {
  93. uint32_t v;
  94. struct
  95. {
  96. uint32_t command : 6; // [5:0]
  97. uint32_t __31_6 : 26; // [31:6]
  98. } b;
  99. } REG_SDMMC_SDMMC_CMD_INDEX_T;
  100. // sdmmc_resp_index
  101. typedef union {
  102. uint32_t v;
  103. struct
  104. {
  105. uint32_t response : 6; // [5:0], read only
  106. uint32_t __31_6 : 26; // [31:6]
  107. } b;
  108. } REG_SDMMC_SDMMC_RESP_INDEX_T;
  109. // sdmmc_data_width_reg
  110. typedef union {
  111. uint32_t v;
  112. struct
  113. {
  114. uint32_t sdmmc_data_width : 4; // [3:0]
  115. uint32_t __31_4 : 28; // [31:4]
  116. } b;
  117. } REG_SDMMC_SDMMC_DATA_WIDTH_REG_T;
  118. // sdmmc_block_size_reg
  119. typedef union {
  120. uint32_t v;
  121. struct
  122. {
  123. uint32_t sdmmc_block_size : 4; // [3:0]
  124. uint32_t __31_4 : 28; // [31:4]
  125. } b;
  126. } REG_SDMMC_SDMMC_BLOCK_SIZE_REG_T;
  127. // sdmmc_block_cnt_reg
  128. typedef union {
  129. uint32_t v;
  130. struct
  131. {
  132. uint32_t sdmmc_block_cnt : 16; // [15:0]
  133. uint32_t __31_16 : 16; // [31:16]
  134. } b;
  135. } REG_SDMMC_SDMMC_BLOCK_CNT_REG_T;
  136. // sdmmc_int_status
  137. typedef union {
  138. uint32_t v;
  139. struct
  140. {
  141. uint32_t no_rsp_int : 1; // [0], read only
  142. uint32_t rsp_err_int : 1; // [1], read only
  143. uint32_t rd_err_int : 1; // [2], read only
  144. uint32_t wr_err_int : 1; // [3], read only
  145. uint32_t dat_over_int : 1; // [4], read only
  146. uint32_t txdma_done_int : 1; // [5], read only
  147. uint32_t rxdma_done_int : 1; // [6], read only
  148. uint32_t __7_7 : 1; // [7]
  149. uint32_t no_rsp_sc : 1; // [8], read only
  150. uint32_t rsp_err_sc : 1; // [9], read only
  151. uint32_t rd_err_sc : 1; // [10], read only
  152. uint32_t wr_err_sc : 1; // [11], read only
  153. uint32_t dat_over_sc : 1; // [12], read only
  154. uint32_t txdma_done_sc : 1; // [13], read only
  155. uint32_t rxdma_done_sc : 1; // [14], read only
  156. uint32_t __31_15 : 17; // [31:15]
  157. } b;
  158. } REG_SDMMC_SDMMC_INT_STATUS_T;
  159. // sdmmc_int_mask
  160. typedef union {
  161. uint32_t v;
  162. struct
  163. {
  164. uint32_t no_rsp_mk : 1; // [0]
  165. uint32_t rsp_err_mk : 1; // [1]
  166. uint32_t rd_err_mk : 1; // [2]
  167. uint32_t wr_err_mk : 1; // [3]
  168. uint32_t dat_over_mk : 1; // [4]
  169. uint32_t txdma_done_mk : 1; // [5]
  170. uint32_t rxdma_done_mk : 1; // [6]
  171. uint32_t __31_7 : 25; // [31:7]
  172. } b;
  173. } REG_SDMMC_SDMMC_INT_MASK_T;
  174. // sdmmc_int_clear
  175. typedef union {
  176. uint32_t v;
  177. struct
  178. {
  179. uint32_t no_rsp_cl : 1; // [0]
  180. uint32_t rsp_err_cl : 1; // [1]
  181. uint32_t rd_err_cl : 1; // [2]
  182. uint32_t wr_err_cl : 1; // [3]
  183. uint32_t dat_over_cl : 1; // [4]
  184. uint32_t txdma_done_cl : 1; // [5]
  185. uint32_t rxdma_done_cl : 1; // [6]
  186. uint32_t __31_7 : 25; // [31:7]
  187. } b;
  188. } REG_SDMMC_SDMMC_INT_CLEAR_T;
  189. // sdmmc_trans_speed_reg
  190. typedef union {
  191. uint32_t v;
  192. struct
  193. {
  194. uint32_t sdmmc_trans_speed : 10; // [9:0]
  195. uint32_t __31_10 : 22; // [31:10]
  196. } b;
  197. } REG_SDMMC_SDMMC_TRANS_SPEED_REG_T;
  198. // sdmmc_mclk_adjust_reg
  199. typedef union {
  200. uint32_t v;
  201. struct
  202. {
  203. uint32_t sdmmc_mclk_adjust : 4; // [3:0]
  204. uint32_t clk_inv : 1; // [4]
  205. uint32_t __31_5 : 27; // [31:5]
  206. } b;
  207. } REG_SDMMC_SDMMC_MCLK_ADJUST_REG_T;
  208. // apbi_ctrl_sdmmc
  209. #define SDMMC_L_ENDIAN(n) (((n)&0x7) << 0)
  210. #define SDMMC_SOFT_RST_L (1 << 3)
  211. // apbi_fifo_txrx
  212. #define SDMMC_DATA_OUT(n) (((n)&0xffffffff) << 0)
  213. // sdmmc_config
  214. #define SDMMC_SDMMC_SENDCMD (1 << 0)
  215. #define SDMMC_SDMMC_SUSPEND (1 << 1)
  216. #define SDMMC_RSP_EN (1 << 4)
  217. #define SDMMC_RSP_SEL(n) (((n)&0x3) << 5)
  218. #define SDMMC_RSP_SEL_R2 (2 << 5)
  219. #define SDMMC_RSP_SEL_R3 (1 << 5)
  220. #define SDMMC_RSP_SEL_OTHER (0 << 5)
  221. #define SDMMC_RD_WT_EN (1 << 8)
  222. #define SDMMC_RD_WT_SEL_READ (0 << 9)
  223. #define SDMMC_RD_WT_SEL_WRITE (1 << 9)
  224. #define SDMMC_S_M_SEL_SIMPLE (0 << 10)
  225. #define SDMMC_S_M_SEL_MULTIPLE (1 << 10)
  226. #define SDMMC_BIT_16 (1 << 16)
  227. #define SDMMC_RSP_SEL_V_R2 (2)
  228. #define SDMMC_RSP_SEL_V_R3 (1)
  229. #define SDMMC_RSP_SEL_V_OTHER (0)
  230. #define SDMMC_RD_WT_SEL_V_READ (0)
  231. #define SDMMC_RD_WT_SEL_V_WRITE (1)
  232. #define SDMMC_S_M_SEL_V_SIMPLE (0)
  233. #define SDMMC_S_M_SEL_V_MULTIPLE (1)
  234. // sdmmc_status
  235. #define SDMMC_NOT_SDMMC_OVER (1 << 0)
  236. #define SDMMC_BUSY (1 << 1)
  237. #define SDMMC_DL_BUSY (1 << 2)
  238. #define SDMMC_SUSPEND (1 << 3)
  239. #define SDMMC_RSP_ERROR (1 << 8)
  240. #define SDMMC_NO_RSP_ERROR (1 << 9)
  241. #define SDMMC_CRC_STATUS(n) (((n)&0x7) << 12)
  242. #define SDMMC_DATA_ERROR(n) (((n)&0xff) << 16)
  243. #define SDMMC_DAT3_VAL (1 << 24)
  244. // sdmmc_cmd_index
  245. #define SDMMC_COMMAND(n) (((n)&0x3f) << 0)
  246. // sdmmc_resp_index
  247. #define SDMMC_RESPONSE(n) (((n)&0x3f) << 0)
  248. // sdmmc_data_width_reg
  249. #define SDMMC_SDMMC_DATA_WIDTH(n) (((n)&0xf) << 0)
  250. // sdmmc_block_size_reg
  251. #define SDMMC_SDMMC_BLOCK_SIZE(n) (((n)&0xf) << 0)
  252. // sdmmc_block_cnt_reg
  253. #define SDMMC_SDMMC_BLOCK_CNT(n) (((n)&0xffff) << 0)
  254. // sdmmc_int_status
  255. #define SDMMC_NO_RSP_INT (1 << 0)
  256. #define SDMMC_RSP_ERR_INT (1 << 1)
  257. #define SDMMC_RD_ERR_INT (1 << 2)
  258. #define SDMMC_WR_ERR_INT (1 << 3)
  259. #define SDMMC_DAT_OVER_INT (1 << 4)
  260. #define SDMMC_TXDMA_DONE_INT (1 << 5)
  261. #define SDMMC_RXDMA_DONE_INT (1 << 6)
  262. #define SDMMC_NO_RSP_SC (1 << 8)
  263. #define SDMMC_RSP_ERR_SC (1 << 9)
  264. #define SDMMC_RD_ERR_SC (1 << 10)
  265. #define SDMMC_WR_ERR_SC (1 << 11)
  266. #define SDMMC_DAT_OVER_SC (1 << 12)
  267. #define SDMMC_TXDMA_DONE_SC (1 << 13)
  268. #define SDMMC_RXDMA_DONE_SC (1 << 14)
  269. // sdmmc_int_mask
  270. #define SDMMC_NO_RSP_MK (1 << 0)
  271. #define SDMMC_RSP_ERR_MK (1 << 1)
  272. #define SDMMC_RD_ERR_MK (1 << 2)
  273. #define SDMMC_WR_ERR_MK (1 << 3)
  274. #define SDMMC_DAT_OVER_MK (1 << 4)
  275. #define SDMMC_TXDMA_DONE_MK (1 << 5)
  276. #define SDMMC_RXDMA_DONE_MK (1 << 6)
  277. // sdmmc_int_clear
  278. #define SDMMC_NO_RSP_CL (1 << 0)
  279. #define SDMMC_RSP_ERR_CL (1 << 1)
  280. #define SDMMC_RD_ERR_CL (1 << 2)
  281. #define SDMMC_WR_ERR_CL (1 << 3)
  282. #define SDMMC_DAT_OVER_CL (1 << 4)
  283. #define SDMMC_TXDMA_DONE_CL (1 << 5)
  284. #define SDMMC_RXDMA_DONE_CL (1 << 6)
  285. // sdmmc_trans_speed_reg
  286. #define SDMMC_SDMMC_TRANS_SPEED(n) (((n)&0x3ff) << 0)
  287. // sdmmc_mclk_adjust_reg
  288. #define SDMMC_SDMMC_MCLK_ADJUST(n) (((n)&0xf) << 0)
  289. #define SDMMC_CLK_INV (1 << 4)
  290. #endif // _SDMMC_H_