acp.h 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef __ACP_HW_H
  3. #define __ACP_HW_H
  4. #include "include/acp_2_2_d.h"
  5. #include "include/acp_2_2_sh_mask.h"
  6. #define ACP_PAGE_SIZE_4K_ENABLE 0x02
  7. #define ACP_PLAYBACK_PTE_OFFSET 10
  8. #define ACP_CAPTURE_PTE_OFFSET 0
  9. /* Playback and Capture Offset for Stoney */
  10. #define ACP_ST_PLAYBACK_PTE_OFFSET 0x04
  11. #define ACP_ST_CAPTURE_PTE_OFFSET 0x00
  12. #define ACP_ST_BT_PLAYBACK_PTE_OFFSET 0x08
  13. #define ACP_ST_BT_CAPTURE_PTE_OFFSET 0x0c
  14. #define ACP_GARLIC_CNTL_DEFAULT 0x00000FB4
  15. #define ACP_ONION_CNTL_DEFAULT 0x00000FB4
  16. #define ACP_PHYSICAL_BASE 0x14000
  17. /*
  18. * In case of I2S SP controller instance, Stoney uses SRAM bank 1 for
  19. * playback and SRAM Bank 2 for capture where as in case of BT I2S
  20. * Instance, Stoney uses SRAM Bank 3 for playback & SRAM Bank 4 will
  21. * be used for capture. Carrizo uses I2S SP controller instance. SRAM Banks
  22. * 1, 2, 3, 4 will be used for playback & SRAM Banks 5, 6, 7, 8 will be used
  23. * for capture scenario.
  24. */
  25. #define ACP_SRAM_BANK_1_ADDRESS 0x4002000
  26. #define ACP_SRAM_BANK_2_ADDRESS 0x4004000
  27. #define ACP_SRAM_BANK_3_ADDRESS 0x4006000
  28. #define ACP_SRAM_BANK_4_ADDRESS 0x4008000
  29. #define ACP_SRAM_BANK_5_ADDRESS 0x400A000
  30. #define ACP_DMA_RESET_TIME 10000
  31. #define ACP_CLOCK_EN_TIME_OUT_VALUE 0x000000FF
  32. #define ACP_SOFT_RESET_DONE_TIME_OUT_VALUE 0x000000FF
  33. #define ACP_DMA_COMPLETE_TIME_OUT_VALUE 0x000000FF
  34. #define ACP_SRAM_BASE_ADDRESS 0x4000000
  35. #define ACP_DAGB_GRP_SRAM_BASE_ADDRESS 0x4001000
  36. #define ACP_DAGB_GRP_SRBM_SRAM_BASE_OFFSET 0x1000
  37. #define ACP_INTERNAL_APERTURE_WINDOW_0_ADDRESS 0x00000000
  38. #define ACP_INTERNAL_APERTURE_WINDOW_4_ADDRESS 0x01800000
  39. #define TO_ACP_I2S_1 0x2
  40. #define TO_ACP_I2S_2 0x4
  41. #define TO_BLUETOOTH 0x3
  42. #define FROM_ACP_I2S_1 0xa
  43. #define FROM_ACP_I2S_2 0xb
  44. #define FROM_BLUETOOTH 0xb
  45. #define I2S_SP_INSTANCE 0x01
  46. #define I2S_BT_INSTANCE 0x02
  47. #define I2S_MICSP_INSTANCE 0x03
  48. #define CAP_CHANNEL0 0x00
  49. #define CAP_CHANNEL1 0x01
  50. #define ACP_TILE_ON_MASK 0x03
  51. #define ACP_TILE_OFF_MASK 0x02
  52. #define ACP_TILE_ON_RETAIN_REG_MASK 0x1f
  53. #define ACP_TILE_OFF_RETAIN_REG_MASK 0x20
  54. #define ACP_TILE_P1_MASK 0x3e
  55. #define ACP_TILE_P2_MASK 0x3d
  56. #define ACP_TILE_DSP0_MASK 0x3b
  57. #define ACP_TILE_DSP1_MASK 0x37
  58. #define ACP_TILE_DSP2_MASK 0x2f
  59. /* Playback DMA channels */
  60. #define SYSRAM_TO_ACP_CH_NUM 12
  61. #define ACP_TO_I2S_DMA_CH_NUM 13
  62. /* Capture DMA channels */
  63. #define I2S_TO_ACP_DMA_CH_NUM 14
  64. #define ACP_TO_SYSRAM_CH_NUM 15
  65. /* Playback DMA Channels for I2S BT instance */
  66. #define SYSRAM_TO_ACP_BT_INSTANCE_CH_NUM 8
  67. #define ACP_TO_I2S_DMA_BT_INSTANCE_CH_NUM 9
  68. /* Capture DMA Channels for I2S BT Instance */
  69. #define I2S_TO_ACP_DMA_BT_INSTANCE_CH_NUM 10
  70. #define ACP_TO_SYSRAM_BT_INSTANCE_CH_NUM 11
  71. /* Playback DMA channels for I2S MICSP instance */
  72. #define SYSRAM_TO_ACP_MICSP_INSTANCE_CH_NUM 4
  73. #define ACP_TO_I2S_DMA_MICSP_INSTANCE_CH_NUM 5
  74. #define NUM_DSCRS_PER_CHANNEL 2
  75. #define PLAYBACK_START_DMA_DESCR_CH12 0
  76. #define PLAYBACK_END_DMA_DESCR_CH12 1
  77. #define PLAYBACK_START_DMA_DESCR_CH13 2
  78. #define PLAYBACK_END_DMA_DESCR_CH13 3
  79. #define CAPTURE_START_DMA_DESCR_CH14 4
  80. #define CAPTURE_END_DMA_DESCR_CH14 5
  81. #define CAPTURE_START_DMA_DESCR_CH15 6
  82. #define CAPTURE_END_DMA_DESCR_CH15 7
  83. /* I2S BT Instance DMA Descriptors */
  84. #define PLAYBACK_START_DMA_DESCR_CH8 8
  85. #define PLAYBACK_END_DMA_DESCR_CH8 9
  86. #define PLAYBACK_START_DMA_DESCR_CH9 10
  87. #define PLAYBACK_END_DMA_DESCR_CH9 11
  88. #define CAPTURE_START_DMA_DESCR_CH10 12
  89. #define CAPTURE_END_DMA_DESCR_CH10 13
  90. #define CAPTURE_START_DMA_DESCR_CH11 14
  91. #define CAPTURE_END_DMA_DESCR_CH11 15
  92. /* I2S MICSP Instance DMA Descriptors */
  93. #define PLAYBACK_START_DMA_DESCR_CH4 0
  94. #define PLAYBACK_END_DMA_DESCR_CH4 1
  95. #define PLAYBACK_START_DMA_DESCR_CH5 2
  96. #define PLAYBACK_END_DMA_DESCR_CH5 3
  97. #define mmACP_I2S_16BIT_RESOLUTION_EN 0x5209
  98. #define ACP_I2S_MIC_16BIT_RESOLUTION_EN 0x01
  99. #define ACP_I2S_MICSP_16BIT_RESOLUTION_EN 0x01
  100. #define ACP_I2S_SP_16BIT_RESOLUTION_EN 0x02
  101. #define ACP_I2S_BT_16BIT_RESOLUTION_EN 0x04
  102. #define ACP_BT_UART_PAD_SELECT_MASK 0x1
  103. enum acp_dma_priority_level {
  104. /* 0x0 Specifies the DMA channel is given normal priority */
  105. ACP_DMA_PRIORITY_LEVEL_NORMAL = 0x0,
  106. /* 0x1 Specifies the DMA channel is given high priority */
  107. ACP_DMA_PRIORITY_LEVEL_HIGH = 0x1,
  108. ACP_DMA_PRIORITY_LEVEL_FORCESIZE = 0xFF
  109. };
  110. struct audio_substream_data {
  111. dma_addr_t dma_addr;
  112. unsigned int order;
  113. u16 num_of_pages;
  114. u16 i2s_instance;
  115. u16 capture_channel;
  116. u16 direction;
  117. u16 ch1;
  118. u16 ch2;
  119. u16 destination;
  120. u16 dma_dscr_idx_1;
  121. u16 dma_dscr_idx_2;
  122. u32 pte_offset;
  123. u32 sram_bank;
  124. u32 byte_cnt_high_reg_offset;
  125. u32 byte_cnt_low_reg_offset;
  126. u32 dma_curr_dscr;
  127. uint64_t size;
  128. u64 bytescount;
  129. void __iomem *acp_mmio;
  130. };
  131. struct audio_drv_data {
  132. struct snd_pcm_substream *play_i2ssp_stream;
  133. struct snd_pcm_substream *capture_i2ssp_stream;
  134. struct snd_pcm_substream *play_i2sbt_stream;
  135. struct snd_pcm_substream *capture_i2sbt_stream;
  136. struct snd_pcm_substream *play_i2s_micsp_stream;
  137. void __iomem *acp_mmio;
  138. u32 asic_type;
  139. snd_pcm_sframes_t delay;
  140. };
  141. /*
  142. * this structure used for platform data transfer between machine driver
  143. * and dma driver
  144. */
  145. struct acp_platform_info {
  146. u16 play_i2s_instance;
  147. u16 cap_i2s_instance;
  148. u16 capture_channel;
  149. };
  150. union acp_dma_count {
  151. struct {
  152. u32 low;
  153. u32 high;
  154. } bcount;
  155. u64 bytescount;
  156. };
  157. enum {
  158. ACP_TILE_P1 = 0,
  159. ACP_TILE_P2,
  160. ACP_TILE_DSP0,
  161. ACP_TILE_DSP1,
  162. ACP_TILE_DSP2,
  163. };
  164. enum {
  165. ACP_DMA_ATTR_SHAREDMEM_TO_DAGB_ONION = 0x0,
  166. ACP_DMA_ATTR_SHARED_MEM_TO_DAGB_GARLIC = 0x1,
  167. ACP_DMA_ATTR_DAGB_ONION_TO_SHAREDMEM = 0x8,
  168. ACP_DMA_ATTR_DAGB_GARLIC_TO_SHAREDMEM = 0x9,
  169. ACP_DMA_ATTR_FORCE_SIZE = 0xF
  170. };
  171. typedef struct acp_dma_dscr_transfer {
  172. /* Specifies the source memory location for the DMA data transfer. */
  173. u32 src;
  174. /*
  175. * Specifies the destination memory location to where the data will
  176. * be transferred.
  177. */
  178. u32 dest;
  179. /*
  180. * Specifies the number of bytes need to be transferred
  181. * from source to destination memory.Transfer direction & IOC enable
  182. */
  183. u32 xfer_val;
  184. /* Reserved for future use */
  185. u32 reserved;
  186. } acp_dma_dscr_transfer_t;
  187. extern bool acp_bt_uart_enable;
  188. #endif /*__ACP_HW_H */