aml_audio_hw.h 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286
  1. #ifndef __AML_AUDIO_HW_H__
  2. #define __AML_AUDIO_HW_H__
  3. #if defined (CONFIG_ARCH_MESON) || defined (CONFIG_ARCH_MESON2) || defined (CONFIG_ARCH_MESON3)
  4. extern unsigned int acodec_regbank[];
  5. /* assumming PLL source is 24M */
  6. #define AUDIO_384FS_PLL_192K 0x507d /* 36.864M */
  7. #define AUDIO_384FS_PLL_192K_MUX 12
  8. #define AUDIO_384FS_CLK_192K 0x5eb
  9. #define AUDIO_384FS_PLL_176K 0x0e7c /* 33.8688M */
  10. #define AUDIO_384FS_PLL_176K_MUX 25
  11. #define AUDIO_384FS_CLK_176K 0x5eb
  12. #define AUDIO_384FS_PLL_96K 0x507d /* 36.864M */
  13. #define AUDIO_384FS_PLL_96K_MUX 12
  14. #define AUDIO_384FS_CLK_96K 0x5ef
  15. #define AUDIO_384FS_PLL_88K 0x0e7c /* 33.8688M */
  16. #define AUDIO_384FS_PLL_88K_MUX 25
  17. #define AUDIO_384FS_CLK_88K 0x5ef
  18. #define AUDIO_384FS_PLL_48K 0x487d /* 18.432M */
  19. #define AUDIO_384FS_PLL_48K_MUX 12
  20. #define AUDIO_384FS_CLK_48K_AC3 0x5ed
  21. #define AUDIO_384FS_CLK_48K 0x5ef
  22. #define AUDIO_384FS_PLL_44K 0x0aa3 /* 16.9344M */
  23. #define AUDIO_384FS_PLL_44K_MUX 23
  24. #define AUDIO_384FS_CLK_44K 0x5ef
  25. #define AUDIO_384FS_PLL_32K 0x1480 /* 12.288M */
  26. #define AUDIO_384FS_PLL_32K_MUX 24
  27. #define AUDIO_384FS_CLK_32K 0x5ef
  28. #define AUDIO_384FS_DAC_CFG 0x6
  29. #define AUDIO_256FS_PLL_192K 0x0a53 /* 24.576M */
  30. #define AUDIO_256FS_PLL_192K_MUX 17
  31. #define AUDIO_256FS_CLK_192K 0x5c7
  32. #define AUDIO_256FS_PLL_176K 0x0eba /* 22.5792M */
  33. #define AUDIO_256FS_PLL_176K_MUX 25
  34. #define AUDIO_256FS_CLK_176K 0x5c7
  35. #define AUDIO_256FS_PLL_96K 0x0a53 /* 24.576M */
  36. #define AUDIO_256FS_PLL_96K_MUX 17
  37. #define AUDIO_256FS_CLK_96K 0x5db
  38. #define AUDIO_256FS_PLL_88K 0x0eba /* 22.5792M */
  39. #define AUDIO_256FS_PLL_88K_MUX 25
  40. #define AUDIO_256FS_CLK_88K 0x5db
  41. #define AUDIO_256FS_PLL_48K 0x08d3 /* 12.288M */
  42. #define AUDIO_256FS_PLL_48K_MUX 27
  43. #define AUDIO_256FS_CLK_48K_AC3 0x5d9
  44. #define AUDIO_256FS_CLK_48K 0x5db
  45. #define AUDIO_256FS_PLL_44K 0x06b9 /* 11.2896M */
  46. #define AUDIO_256FS_PLL_44K_MUX 29
  47. #define AUDIO_256FS_CLK_44K 0x5db
  48. #define AUDIO_256FS_PLL_32K 0x4252 /* 8.192M */
  49. #define AUDIO_256FS_PLL_32K_MUX 14
  50. #define AUDIO_256FS_CLK_32K 0x5db
  51. #define AUDIO_256FS_DAC_CFG 0x7
  52. #endif
  53. typedef struct {
  54. unsigned short pll;
  55. unsigned short mux;
  56. unsigned short devisor;
  57. } _aiu_clk_setting_t;
  58. typedef struct {
  59. unsigned short chstat0_l;
  60. unsigned short chstat1_l;
  61. unsigned short chstat0_r;
  62. unsigned short chstat1_r;
  63. } _aiu_958_channel_status_t;
  64. typedef struct {
  65. /* audio clock */
  66. unsigned short clock;
  67. /* analog output */
  68. unsigned short i2s_mode;
  69. unsigned short i2s_dac_mode;
  70. unsigned short i2s_preemphsis;
  71. /* digital output */
  72. unsigned short i958_buf_start_addr;
  73. unsigned short i958_buf_blksize;
  74. unsigned short i958_int_flag;
  75. unsigned short i958_mode;
  76. unsigned short i958_sync_mode;
  77. unsigned short i958_preemphsis;
  78. unsigned short i958_copyright;
  79. unsigned short bpf;
  80. unsigned short brst;
  81. unsigned short length;
  82. unsigned short paddsize;
  83. _aiu_958_channel_status_t chan_status;
  84. } audio_output_config_t;
  85. typedef struct {
  86. unsigned short int_flag;
  87. unsigned short bpf;
  88. unsigned short brst;
  89. unsigned short length;
  90. unsigned short paddsize;
  91. _aiu_958_channel_status_t *chan_stat;
  92. } _aiu_958_raw_setting_t;
  93. #define AUDIO_CLK_256FS 0
  94. #define AUDIO_CLK_384FS 1
  95. #define AUDIO_CLK_FREQ_192 0
  96. #define AUDIO_CLK_FREQ_1764 1
  97. #define AUDIO_CLK_FREQ_96 2
  98. #define AUDIO_CLK_FREQ_882 3
  99. #define AUDIO_CLK_FREQ_48 4
  100. #define AUDIO_CLK_FREQ_441 5
  101. #define AUDIO_CLK_FREQ_32 6
  102. #define AUDIO_CLK_FREQ_8 7
  103. #define AUDIO_CLK_FREQ_11 8
  104. #define AUDIO_CLK_FREQ_12 9
  105. #define AUDIO_CLK_FREQ_16 10
  106. #define AUDIO_CLK_FREQ_22 11
  107. #define AUDIO_CLK_FREQ_24 12
  108. #define AIU_958_MODE_RAW 0
  109. #define AIU_958_MODE_PCM16 1
  110. #define AIU_958_MODE_PCM24 2
  111. #define AIU_958_MODE_PCM32 3
  112. #define AIU_I2S_MODE_PCM16 0
  113. #define AIU_I2S_MODE_PCM24 2
  114. #define AIU_I2S_MODE_PCM32 3
  115. #define AUDIO_ALGOUT_DAC_FORMAT_DSP 0
  116. #define AUDIO_ALGOUT_DAC_FORMAT_LEFT_JUSTIFY 1
  117. extern unsigned ENABLE_IEC958;
  118. extern unsigned IEC958_MODE;
  119. extern unsigned I2S_MODE;
  120. void audio_set_aiubuf(u32 addr, u32 size);
  121. void audio_set_958outbuf(u32 addr, u32 size);
  122. void audio_in_i2s_set_buf(u32 addr, u32 size);
  123. void audio_in_spdif_set_buf(u32 addr, u32 size);
  124. void audio_in_i2s_enable(int flag);
  125. void audio_in_spdif_enable(int flag);
  126. unsigned int audio_in_i2s_rd_ptr(void);
  127. unsigned int audio_in_i2s_wr_ptr(void);
  128. void audio_set_i2s_mode(u32 mode);
  129. void audio_set_clk(unsigned freq, unsigned fs_config);
  130. void audio_enable_ouput(int flag);
  131. unsigned int read_i2s_rd_ptr(void);
  132. void audio_i2s_unmute(void);
  133. void audio_i2s_mute(void);
  134. void audio_util_set_dac_format(unsigned format);
  135. void audio_set_958_mode(unsigned mode, _aiu_958_raw_setting_t * set);
  136. unsigned int read_i2s_mute_swap_reg(void);
  137. void audio_i2s_swap_left_right(unsigned int flag);
  138. int audio_dac_set(unsigned freq);
  139. int if_audio_out_enable(void);
  140. int if_audio_in_i2s_enable(void);
  141. void audio_out_enabled(int flag);
  142. void audio_util_set_dac_format(unsigned format);
  143. void set_acodec_source (unsigned int src);
  144. void adac_wr_reg (unsigned long addr, unsigned long data);
  145. unsigned long adac_rd_reg (unsigned long addr);
  146. void wr_regbank ( unsigned long rstdpz,
  147. unsigned long mclksel,
  148. unsigned long i2sfsadc,
  149. unsigned long i2sfsdac,
  150. unsigned long i2ssplit,
  151. unsigned long i2smode,
  152. unsigned long pdauxdrvrz,
  153. unsigned long pdauxdrvlz,
  154. unsigned long pdhsdrvrz,
  155. unsigned long pdhsdrvlz,
  156. unsigned long pdlsdrvz,
  157. unsigned long pddacrz,
  158. unsigned long pddaclz,
  159. unsigned long pdz,
  160. unsigned long pdmbiasz,
  161. unsigned long pdvcmbufz,
  162. unsigned long pdrpgaz,
  163. unsigned long pdlpgaz,
  164. unsigned long pdadcrz,
  165. unsigned long pdadclz,
  166. unsigned long hsmute,
  167. unsigned long recmute,
  168. unsigned long micmute,
  169. unsigned long lmmute,
  170. unsigned long lsmute,
  171. unsigned long lmmix,
  172. unsigned long recmix,
  173. unsigned long ctr,
  174. unsigned long enhp,
  175. unsigned long lmvol,
  176. unsigned long hsvol,
  177. unsigned long pbmix,
  178. unsigned long lsmix,
  179. unsigned long micvol,
  180. unsigned long recvol,
  181. unsigned long recsel);
  182. void adac_power_up_mode_2(void);
  183. void adac_startup_seq(void);
  184. #define APB_BASE 0x4000
  185. #define ADAC_RESET 0x00
  186. #define ADAC_LATCH 0x01
  187. #define ADAC_CLOCK 0x02
  188. // 0x03-0x0b reserved
  189. #define ADAC_I2S_CONFIG_REG1 0x0c
  190. #define ADAC_I2S_CONFIG_REG2 0x0d
  191. // 0x0e - 0x0f reserved
  192. #define ADAC_POWER_CTRL_REG1 0x10
  193. #define ADAC_POWER_CTRL_REG2 0x11
  194. #define ADAC_POWER_CTRL_REG3 0x12
  195. // 0x13-0x17 reserved
  196. #define ADAC_MUTE_CTRL_REG1 0x18
  197. #define ADAC_MUTE_CTRL_REG2 0x19
  198. #define ADAC_DAC_ADC_MIXER 0x1a
  199. // 0x1b-0x1f reserved
  200. #define ADAC_PLAYBACK_VOL_CTRL_LSB 0x20
  201. #define ADAC_PLAYBACK_VOL_CTRL_MSB 0x21
  202. #define ADAC_STEREO_HS_VOL_CTRL_LSB 0x22
  203. #define ADAC_STEREO_HS_VOL_CTRL_MSB 0x23
  204. #define ADAC_PLAYBACK_MIX_CTRL_LSB 0x24
  205. #define ADAC_PLAYBACK_MIX_CTRL_MSB 0x25
  206. #define ADAC_LS_MIX_CTRL_LSB 0x26
  207. #define ADAC_LS_MIX_CTRL_MSB 0x27
  208. #define ADAC_STEREO_PGA_VOL_LSB 0x40
  209. #define ADAC_STEREO_PGA_VOL_MSB 0x41
  210. #define ADAC_RECVOL_CTRL_LSB 0x42
  211. #define ADAC_RECVOL_CTRL_MSB 0x43
  212. #define ADAC_REC_CH_SEL_LSB 0x48
  213. #define ADAC_REC_CH_SEL_MSB 0x49
  214. #define ADAC_VCM_REG1 0x80
  215. #define ADAC_VCM_REG2 0x81
  216. #define ADAC_TEST_REG1 0xe0
  217. #define ADAC_TEST_REG2 0xe1
  218. #define ADAC_TEST_REG3 0xe2
  219. #define ADAC_TEST_REG4 0xe3
  220. #define ADAC_MAXREG 0xe4
  221. #define NO_CLOCK_TO_CODEC 0
  222. #define PCMOUT_TO_DAC 1
  223. #define AIU_I2SOUT_TO_DAC 2
  224. #define APB_ADAC_RESET (APB_BASE+ADAC_RESET*4)
  225. #define APB_ADAC_LATCH (APB_BASE+ADAC_LATCH*4)
  226. #define APB_ADAC_CLOCK (APB_BASE+ADAC_CLOCK*4)
  227. #define APB_ADAC_I2S_CONFIG_REG1 (APB_BASE+ADAC_I2S_CONFIG_REG1*4)
  228. #define APB_ADAC_I2S_CONFIG_REG2 (APB_BASE+ADAC_I2S_CONFIG_REG2*4)
  229. #define APB_ADAC_POWER_CTRL_REG1 (APB_BASE+ADAC_POWER_CTRL_REG1*4)
  230. #define APB_ADAC_POWER_CTRL_REG2 (APB_BASE+ADAC_POWER_CTRL_REG2*4)
  231. #define APB_ADAC_POWER_CTRL_REG3 (APB_BASE+ADAC_POWER_CTRL_REG3*4)
  232. #define APB_ADAC_MUTE_CTRL_REG1 (APB_BASE+ADAC_MUTE_CTRL_REG1*4)
  233. #define APB_ADAC_DAC_ADC_MIXER (APB_BASE+ADAC_DAC_ADC_MIXER*4)
  234. #define APB_ADAC_PLAYBACK_VOL_CTRL_LSB (APB_BASE+ADAC_PLAYBACK_VOL_CTRL_LSB*4)
  235. #define APB_ADAC_PLAYBACK_VOL_CTRL_MSB (APB_BASE+ADAC_PLAYBACK_VOL_CTRL_MSB*4)
  236. #define APB_ADAC_STEREO_HS_VOL_CTRL_LSB (APB_BASE+ADAC_STEREO_HS_VOL_CTRL_LSB*4)
  237. #define APB_ADAC_STEREO_HS_VOL_CTRL_MSB (APB_BASE+ADAC_STEREO_HS_VOL_CTRL_MSB*4)
  238. #endif