mt_afe_reg.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322
  1. /* Copyright (c) 2011-2013, The Linux Foundation. All rights reserved.
  2. *
  3. * This program is free software; you can redistribute it and/or modify
  4. * it under the terms of the GNU General Public License version 2 and
  5. * only version 2 as published by the Free Software Foundation.
  6. *
  7. * This program is distributed in the hope that it will be useful,
  8. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. * GNU General Public License for more details.
  11. */
  12. #ifndef __MT_AFE_REG_H__
  13. #define __MT_AFE_REG_H__
  14. #include "mt_afe_def.h"
  15. #include <linux/types.h>
  16. /*****************************************************************************
  17. * C O M P I L E R F L A G S
  18. *****************************************************************************/
  19. /*****************************************************************************
  20. * E X T E R N A L R E F E R E N C E S
  21. *****************************************************************************/
  22. /*****************************************************************************
  23. * D A T A T Y P E S
  24. *****************************************************************************/
  25. /*****************************************************************************
  26. * C O N S T A N T S
  27. *****************************************************************************/
  28. #define AUDIO_HW_PHYSICAL_BASE (0x11220000)
  29. #define AUDIO_HW_VIRTUAL_BASE (0xF2220000)
  30. #ifdef AUDIO_MEM_IOREMAP
  31. #define AFE_BASE (0)
  32. #else
  33. #define AFE_BASE (AUDIO_HW_VIRTUAL_BASE)
  34. #endif
  35. /* Internal sram: 0x11221000~0x1122A000 (36K) */
  36. #define AFE_INTERNAL_SRAM_PHY_BASE (0x11221000)
  37. #define AFE_INTERNAL_SRAM_VIR_BASE (AUDIO_HW_VIRTUAL_BASE - 0x70000 + 0x8000)
  38. #define AFE_INTERNAL_SRAM_SIZE (0x9000)
  39. /* need enable this SPM register before access all AFE registers, set 0x1000629c = 0xd */
  40. #define SPM_BASE (0x10006000)
  41. #define SCP_AUDIO_PWR_CON (0x29C)
  42. #define CKSYS_TOP (0x10000000)
  43. #define AUDIO_DCM_CFG (0x0004)
  44. #define AUDIO_CLK_CFG_4 (0x0080)
  45. #define AUDIO_CLK_CFG_6 (0x00A0)
  46. #define AUDIO_CLK_CFG_7 (0x00B0)
  47. #define AUDIO_CLK_AUDDIV_0 (0x0120)
  48. #define AUDIO_CLK_AUDDIV_1 (0x0124)
  49. #define AUDIO_CLK_AUDDIV_2 (0x0128)
  50. #define AUDIO_CLK_AUDDIV_3 (0x012C)
  51. #define AUDIO_CLK_AUDDIV_4 (0x0134)
  52. /*****************************************************************************
  53. * M A C R O
  54. *****************************************************************************/
  55. /*****************************************************************************
  56. * R E G I S T E R D E F I N I T I O N
  57. *****************************************************************************/
  58. /* #define APMIXEDSYS_BASE (0xF0209000) */
  59. #define APMIXEDSYS_BASE (0x10209000)
  60. #define AP_PLL_CON5 (0x0014)
  61. #define AUDIO_APLL1_CON0 (0x02A0)
  62. #define AUDIO_APLL1_CON1 (0x02A4)
  63. #define AUDIO_APLL1_CON2 (0x02A8)
  64. #define AUDIO_APLL1_PWR_CON0 (0x02B0)
  65. #define AUDIO_APLL2_CON0 (0x02B4)
  66. #define AUDIO_APLL2_CON1 (0x02B8)
  67. #define AUDIO_APLL2_CON2 (0x02C0)
  68. #define AUDIO_APLL2_PWR_CON0 (0x02C4)
  69. /* Fix build warning */
  70. #undef AUDIO_TOP_CON0
  71. /* End */
  72. #define AUDIO_TOP_CON0 (AFE_BASE + 0x0000)
  73. #define AUDIO_TOP_CON1 (AFE_BASE + 0x0004)
  74. #define AUDIO_TOP_CON2 (AFE_BASE + 0x0008)
  75. #define AUDIO_TOP_CON3 (AFE_BASE + 0x000C)
  76. #define AFE_DAC_CON0 (AFE_BASE + 0x0010)
  77. #define AFE_DAC_CON1 (AFE_BASE + 0x0014)
  78. #define AFE_I2S_CON (AFE_BASE + 0x0018)
  79. #define AFE_DAIBT_CON0 (AFE_BASE + 0x001c)
  80. #define AFE_CONN0 (AFE_BASE + 0x0020)
  81. #define AFE_CONN1 (AFE_BASE + 0x0024)
  82. #define AFE_CONN2 (AFE_BASE + 0x0028)
  83. #define AFE_CONN3 (AFE_BASE + 0x002C)
  84. #define AFE_CONN4 (AFE_BASE + 0x0030)
  85. #define AFE_CONN5 (AFE_BASE + 0x005C)
  86. #define AFE_CONN6 (AFE_BASE + 0x00BC)
  87. #define AFE_CONN7 (AFE_BASE + 0x0460)
  88. #define AFE_CONN8 (AFE_BASE + 0x0464)
  89. #define AFE_CONN9 (AFE_BASE + 0x0468)
  90. #define AFE_I2S_CON1 (AFE_BASE + 0x0034)
  91. #define AFE_I2S_CON2 (AFE_BASE + 0x0038)
  92. #define AFE_MRGIF_CON (AFE_BASE + 0x003C)
  93. /* Memory interface */
  94. #define AFE_DL1_BASE (AFE_BASE + 0x0040)
  95. #define AFE_DL1_CUR (AFE_BASE + 0x0044)
  96. #define AFE_DL1_END (AFE_BASE + 0x0048)
  97. #define AFE_DL1_D2_BASE (AFE_BASE + 0x0340)
  98. #define AFE_DL1_D2_CUR (AFE_BASE + 0x0344)
  99. #define AFE_DL1_D2_END (AFE_BASE + 0x0348)
  100. #define AFE_VUL_D2_BASE (AFE_BASE + 0x0350)
  101. #define AFE_VUL_D2_END (AFE_BASE + 0x0358)
  102. #define AFE_VUL_D2_CUR (AFE_BASE + 0x035C)
  103. #define AFE_I2S_CON3 (AFE_BASE + 0x004C)
  104. #define AFE_DL2_BASE (AFE_BASE + 0x0050)
  105. #define AFE_DL2_CUR (AFE_BASE + 0x0054)
  106. #define AFE_DL2_END (AFE_BASE + 0x0058)
  107. #define AFE_CONN_24BIT (AFE_BASE + 0x006C)
  108. #define AFE_AWB_BASE (AFE_BASE + 0x0070)
  109. #define AFE_AWB_END (AFE_BASE + 0x0078)
  110. #define AFE_AWB_CUR (AFE_BASE + 0x007C)
  111. #define AFE_VUL_BASE (AFE_BASE + 0x0080)
  112. #define AFE_VUL_END (AFE_BASE + 0x0088)
  113. #define AFE_VUL_CUR (AFE_BASE + 0x008C)
  114. #define AFE_DAI_BASE (AFE_BASE + 0x0090)
  115. #define AFE_DAI_END (AFE_BASE + 0x0098)
  116. #define AFE_DAI_CUR (AFE_BASE + 0x009C)
  117. /* Memory interface monitor */
  118. #define AFE_MEMIF_MSB (AFE_BASE + 0x00CC)
  119. #define AFE_MEMIF_MON0 (AFE_BASE + 0x00D0)
  120. #define AFE_MEMIF_MON1 (AFE_BASE + 0x00D4)
  121. #define AFE_MEMIF_MON2 (AFE_BASE + 0x00D8)
  122. #define AFE_MEMIF_MON4 (AFE_BASE + 0x00E0)
  123. #define AFE_ADDA_DL_SRC2_CON0 (AFE_BASE + 0x0108)
  124. #define AFE_ADDA_DL_SRC2_CON1 (AFE_BASE + 0x010C)
  125. #define AFE_ADDA_UL_SRC_CON0 (AFE_BASE + 0x0114)
  126. #define AFE_ADDA_UL_SRC_CON1 (AFE_BASE + 0x0118)
  127. #define AFE_ADDA_TOP_CON0 (AFE_BASE + 0x0120)
  128. #define AFE_ADDA_UL_DL_CON0 (AFE_BASE + 0x0124)
  129. #define AFE_ADDA_SRC_DEBUG (AFE_BASE + 0x012C)
  130. #define AFE_ADDA_SRC_DEBUG_MON0 (AFE_BASE + 0x0130)
  131. #define AFE_ADDA_SRC_DEBUG_MON1 (AFE_BASE + 0x0134)
  132. #define AFE_ADDA_NEWIF_CFG0 (AFE_BASE + 0x0138)
  133. #define AFE_ADDA_NEWIF_CFG1 (AFE_BASE + 0x013C)
  134. #define AFE_SIDETONE_DEBUG (AFE_BASE + 0x01D0)
  135. #define AFE_SIDETONE_MON (AFE_BASE + 0x01D4)
  136. #define AFE_SIDETONE_CON0 (AFE_BASE + 0x01E0)
  137. #define AFE_SIDETONE_COEFF (AFE_BASE + 0x01E4)
  138. #define AFE_SIDETONE_CON1 (AFE_BASE + 0x01E8)
  139. #define AFE_SIDETONE_GAIN (AFE_BASE + 0x01EC)
  140. #define AFE_SGEN_CON0 (AFE_BASE + 0x01F0)
  141. #define AFE_SGEN_CON1 (AFE_BASE + 0x01F4)
  142. #define AFE_TOP_CON0 (AFE_BASE + 0x0200)
  143. #define AFE_ADDA_PREDIS_CON0 (AFE_BASE + 0x0260)
  144. #define AFE_ADDA_PREDIS_CON1 (AFE_BASE + 0x0264)
  145. #define AFE_MRGIF_MON0 (AFE_BASE + 0x0270)
  146. #define AFE_MRGIF_MON1 (AFE_BASE + 0x0274)
  147. #define AFE_MRGIF_MON2 (AFE_BASE + 0x0278)
  148. #define AFE_MOD_DAI_BASE (AFE_BASE + 0x0330)
  149. #define AFE_MOD_DAI_END (AFE_BASE + 0x0338)
  150. #define AFE_MOD_DAI_CUR (AFE_BASE + 0x033C)
  151. #define AFE_MOD_PCM_BASE (AFE_BASE + 0x0330)
  152. #define AFE_MOD_PCM_END (AFE_BASE + 0x0338)
  153. #define AFE_MOD_PCM_CUR (AFE_BASE + 0x033C)
  154. #define AFE_SPDIF2_OUT_CON0 (AFE_BASE + 0x0360)
  155. #define AFE_SPDIF2_BASE (AFE_BASE + 0x0364)
  156. #define AFE_SPDIF2_CUR (AFE_BASE + 0x0368)
  157. #define AFE_SPDIF2_END (AFE_BASE + 0x036C)
  158. #define AFE_HDMI_OUT_CON0 (AFE_BASE + 0x0370)
  159. #define AFE_HDMI_OUT_BASE (AFE_BASE + 0x0374)
  160. #define AFE_HDMI_OUT_CUR (AFE_BASE + 0x0378)
  161. #define AFE_HDMI_OUT_END (AFE_BASE + 0x037C)
  162. #define AFE_SPDIF_OUT_CON0 (AFE_BASE + 0x0380)
  163. #define AFE_SPDIF_BASE (AFE_BASE + 0x0384)
  164. #define AFE_SPDIF_CUR (AFE_BASE + 0x0388)
  165. #define AFE_SPDIF_END (AFE_BASE + 0x038C)
  166. #define AFE_HDMI_CONN0 (AFE_BASE + 0x0390)
  167. #define AFE_HDMI_CONN1 (AFE_BASE + 0x0398)
  168. #define AFE_IRQ_MCU_CON (AFE_BASE + 0x03A0)
  169. #define AFE_IRQ_MCU_STATUS (AFE_BASE + 0x03A4)
  170. #define AFE_IRQ_MCU_CLR (AFE_BASE + 0x03A8)
  171. #define AFE_IRQ_MCU_CNT1 (AFE_BASE + 0x03AC)
  172. #define AFE_IRQ_MCU_CNT2 (AFE_BASE + 0x03B0)
  173. #define AFE_IRQ_MCU_EN (AFE_BASE + 0x03B4)
  174. #define AFE_IRQ_MCU_MON2 (AFE_BASE + 0x03B8)
  175. #define AFE_IRQ_MCU_CNT5 (AFE_BASE + 0x03BC)
  176. #define AFE_IRQ1_MCU_CNT_MON (AFE_BASE + 0x03C0)
  177. #define AFE_IRQ2_MCU_CNT_MON (AFE_BASE + 0x03C4)
  178. #define AFE_IRQ1_MCU_EN_CNT_MON (AFE_BASE + 0x03C8)
  179. #define AFE_IRQ5_MCU_CNT_MON (AFE_BASE + 0x03CC)
  180. #define AFE_MEMIF_MAXLEN (AFE_BASE + 0x03D4)
  181. #define AFE_MEMIF_PBUF_SIZE (AFE_BASE + 0x03D8)
  182. #define AFE_IRQ_MCU_CNT7 (AFE_BASE + 0x03DC)
  183. #define AFE_MEMIF_PBUF2_SIZE (AFE_BASE + 0x03EC)
  184. #define AFE_APLL1_TUNER_CFG (AFE_BASE + 0x03f0)
  185. #define AFE_APLL2_TUNER_CFG (AFE_BASE + 0x03f4)
  186. /* AFE GAIN CONTROL REGISTER */
  187. #define AFE_GAIN1_CON0 (AFE_BASE + 0x0410)
  188. #define AFE_GAIN1_CON1 (AFE_BASE + 0x0414)
  189. #define AFE_GAIN1_CON2 (AFE_BASE + 0x0418)
  190. #define AFE_GAIN1_CON3 (AFE_BASE + 0x041C)
  191. #define AFE_GAIN1_CONN (AFE_BASE + 0x0420)
  192. #define AFE_GAIN1_CUR (AFE_BASE + 0x0424)
  193. #define AFE_GAIN2_CON0 (AFE_BASE + 0x0428)
  194. #define AFE_GAIN2_CON1 (AFE_BASE + 0x042C)
  195. #define AFE_GAIN2_CON2 (AFE_BASE + 0x0430)
  196. #define AFE_GAIN2_CON3 (AFE_BASE + 0x0434)
  197. #define AFE_GAIN2_CONN (AFE_BASE + 0x0438)
  198. #define AFE_GAIN2_CUR (AFE_BASE + 0x043C)
  199. #define AFE_GAIN2_CONN2 (AFE_BASE + 0x0440)
  200. #define AFE_GAIN2_CONN3 (AFE_BASE + 0x0444)
  201. #define AFE_GAIN1_CONN2 (AFE_BASE + 0x0448)
  202. #define AFE_GAIN1_CONN3 (AFE_BASE + 0x044C)
  203. #define AFE_IEC_CFG (AFE_BASE + 0x0480)
  204. #define AFE_IEC_NSNUM (AFE_BASE + 0x0484)
  205. #define AFE_IEC_BURST_INFO (AFE_BASE + 0x0488)
  206. #define AFE_IEC_BURST_LEN (AFE_BASE + 0x048C)
  207. #define AFE_IEC_NSADR (AFE_BASE + 0x0490)
  208. #define AFE_IEC_CHL_STAT0 (AFE_BASE + 0x04A0)
  209. #define AFE_IEC_CHL_STAT1 (AFE_BASE + 0x04A4)
  210. #define AFE_IEC_CHR_STAT0 (AFE_BASE + 0x04A8)
  211. #define AFE_IEC_CHR_STAT1 (AFE_BASE + 0x04AC)
  212. #define AFE_IEC2_CFG (AFE_BASE + 0x04B0)
  213. #define AFE_IEC2_NSNUM (AFE_BASE + 0x04B4)
  214. #define AFE_IEC2_BURST_INFO (AFE_BASE + 0x04B8)
  215. #define AFE_IEC2_BURST_LEN (AFE_BASE + 0x04BC)
  216. #define AFE_IEC2_NSADR (AFE_BASE + 0x04C0)
  217. #define AFE_IEC2_CHL_STAT0 (AFE_BASE + 0x04D0)
  218. #define AFE_IEC2_CHL_STAT1 (AFE_BASE + 0x04D4)
  219. #define AFE_IEC2_CHR_STAT0 (AFE_BASE + 0x04D8)
  220. #define AFE_IEC2_CHR_STAT1 (AFE_BASE + 0x04DC)
  221. /* here is only fpga needed */
  222. #define FPGA_CFG2 (AFE_BASE + 0x04B8)
  223. #define FPGA_CFG3 (AFE_BASE + 0x04BC)
  224. #define FPGA_CFG0 (AFE_BASE + 0x04C0)
  225. #define FPGA_CFG1 (AFE_BASE + 0x04C4)
  226. #define FPGA_VERSION (AFE_BASE + 0x04C8)
  227. #define FPGA_STC (AFE_BASE + 0x04CC)
  228. #define AFE_ASRC_CON0 (AFE_BASE + 0x0500)
  229. #define AFE_ASRC_CON1 (AFE_BASE + 0x0504)
  230. #define AFE_ASRC_CON2 (AFE_BASE + 0x0508)
  231. #define AFE_ASRC_CON3 (AFE_BASE + 0x050C)
  232. #define AFE_ASRC_CON4 (AFE_BASE + 0x0510)
  233. #define AFE_ASRC_CON5 (AFE_BASE + 0x0514)
  234. #define AFE_ASRC_CON6 (AFE_BASE + 0x0518)
  235. #define AFE_ASRC_CON7 (AFE_BASE + 0x051C)
  236. #define AFE_ASRC_CON8 (AFE_BASE + 0x0520)
  237. #define AFE_ASRC_CON9 (AFE_BASE + 0x0524)
  238. #define AFE_ASRC_CON10 (AFE_BASE + 0x0528)
  239. #define AFE_ASRC_CON11 (AFE_BASE + 0x052C)
  240. #define PCM_INTF_CON1 (AFE_BASE + 0x0530)
  241. #define PCM_INTF_CON2 (AFE_BASE + 0x0538)
  242. #define PCM2_INTF_CON (AFE_BASE + 0x053C)
  243. #define AFE_TDM_CON1 (AFE_BASE + 0x548)
  244. #define AFE_TDM_CON2 (AFE_BASE + 0x54C)
  245. #define AFE_ASRC_CON13 (AFE_BASE+0x00550)
  246. #define AFE_ASRC_CON14 (AFE_BASE+0x00554)
  247. #define AFE_ASRC_CON15 (AFE_BASE+0x00558)
  248. #define AFE_ASRC_CON16 (AFE_BASE+0x0055C)
  249. #define AFE_ASRC_CON17 (AFE_BASE+0x00560)
  250. #define AFE_ASRC_CON18 (AFE_BASE+0x00564)
  251. #define AFE_ASRC_CON19 (AFE_BASE+0x00568)
  252. #define AFE_ASRC_CON20 (AFE_BASE+0x0056C)
  253. #define AFE_ASRC_CON21 (AFE_BASE+0x00570)
  254. #define AFE_ADDA2_TOP_CON0 (AFE_BASE + 0x0600)
  255. /**********************************
  256. * Detailed Definitions
  257. **********************************/
  258. #define IRQ_STATUS_BIT 0xFF
  259. int mt_afe_reg_remap(void *dev);
  260. void mt_afe_reg_unmap(void);
  261. void mt_afe_set_reg(uint32_t offset, uint32_t value, uint32_t mask);
  262. uint32_t mt_afe_get_reg(uint32_t offset);
  263. uint32_t mt_afe_topck_get_reg(uint32_t offset);
  264. void mt_afe_topck_set_reg(uint32_t offset, uint32_t value, uint32_t mask);
  265. uint32_t mt_afe_pll_get_reg(uint32_t offset);
  266. void mt_afe_pll_set_reg(uint32_t offset, uint32_t value, uint32_t mask);
  267. uint32_t mt_afe_spm_get_reg(uint32_t offset);
  268. void mt_afe_spm_set_reg(uint32_t offset, uint32_t value, uint32_t mask);
  269. void *mt_afe_get_sram_base_ptr(void);
  270. phys_addr_t mt_afe_get_sram_phy_addr(void);
  271. void mt_afe_log_print(void);
  272. #endif