acp.h 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  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 CAP_CHANNEL0 0x00
  48. #define CAP_CHANNEL1 0x01
  49. #define ACP_TILE_ON_MASK 0x03
  50. #define ACP_TILE_OFF_MASK 0x02
  51. #define ACP_TILE_ON_RETAIN_REG_MASK 0x1f
  52. #define ACP_TILE_OFF_RETAIN_REG_MASK 0x20
  53. #define ACP_TILE_P1_MASK 0x3e
  54. #define ACP_TILE_P2_MASK 0x3d
  55. #define ACP_TILE_DSP0_MASK 0x3b
  56. #define ACP_TILE_DSP1_MASK 0x37
  57. #define ACP_TILE_DSP2_MASK 0x2f
  58. /* Playback DMA channels */
  59. #define SYSRAM_TO_ACP_CH_NUM 12
  60. #define ACP_TO_I2S_DMA_CH_NUM 13
  61. /* Capture DMA channels */
  62. #define I2S_TO_ACP_DMA_CH_NUM 14
  63. #define ACP_TO_SYSRAM_CH_NUM 15
  64. /* Playback DMA Channels for I2S BT instance */
  65. #define SYSRAM_TO_ACP_BT_INSTANCE_CH_NUM 8
  66. #define ACP_TO_I2S_DMA_BT_INSTANCE_CH_NUM 9
  67. /* Capture DMA Channels for I2S BT Instance */
  68. #define I2S_TO_ACP_DMA_BT_INSTANCE_CH_NUM 10
  69. #define ACP_TO_SYSRAM_BT_INSTANCE_CH_NUM 11
  70. #define NUM_DSCRS_PER_CHANNEL 2
  71. #define PLAYBACK_START_DMA_DESCR_CH12 0
  72. #define PLAYBACK_END_DMA_DESCR_CH12 1
  73. #define PLAYBACK_START_DMA_DESCR_CH13 2
  74. #define PLAYBACK_END_DMA_DESCR_CH13 3
  75. #define CAPTURE_START_DMA_DESCR_CH14 4
  76. #define CAPTURE_END_DMA_DESCR_CH14 5
  77. #define CAPTURE_START_DMA_DESCR_CH15 6
  78. #define CAPTURE_END_DMA_DESCR_CH15 7
  79. /* I2S BT Instance DMA Descriptors */
  80. #define PLAYBACK_START_DMA_DESCR_CH8 8
  81. #define PLAYBACK_END_DMA_DESCR_CH8 9
  82. #define PLAYBACK_START_DMA_DESCR_CH9 10
  83. #define PLAYBACK_END_DMA_DESCR_CH9 11
  84. #define CAPTURE_START_DMA_DESCR_CH10 12
  85. #define CAPTURE_END_DMA_DESCR_CH10 13
  86. #define CAPTURE_START_DMA_DESCR_CH11 14
  87. #define CAPTURE_END_DMA_DESCR_CH11 15
  88. #define mmACP_I2S_16BIT_RESOLUTION_EN 0x5209
  89. #define ACP_I2S_MIC_16BIT_RESOLUTION_EN 0x01
  90. #define ACP_I2S_SP_16BIT_RESOLUTION_EN 0x02
  91. #define ACP_I2S_BT_16BIT_RESOLUTION_EN 0x04
  92. #define ACP_BT_UART_PAD_SELECT_MASK 0x1
  93. enum acp_dma_priority_level {
  94. /* 0x0 Specifies the DMA channel is given normal priority */
  95. ACP_DMA_PRIORITY_LEVEL_NORMAL = 0x0,
  96. /* 0x1 Specifies the DMA channel is given high priority */
  97. ACP_DMA_PRIORITY_LEVEL_HIGH = 0x1,
  98. ACP_DMA_PRIORITY_LEVEL_FORCESIZE = 0xFF
  99. };
  100. struct audio_substream_data {
  101. struct page *pg;
  102. unsigned int order;
  103. u16 num_of_pages;
  104. u16 i2s_instance;
  105. u16 capture_channel;
  106. u16 direction;
  107. u16 ch1;
  108. u16 ch2;
  109. u16 destination;
  110. u16 dma_dscr_idx_1;
  111. u16 dma_dscr_idx_2;
  112. u32 pte_offset;
  113. u32 sram_bank;
  114. u32 byte_cnt_high_reg_offset;
  115. u32 byte_cnt_low_reg_offset;
  116. u32 dma_curr_dscr;
  117. uint64_t size;
  118. u64 bytescount;
  119. void __iomem *acp_mmio;
  120. };
  121. struct audio_drv_data {
  122. struct snd_pcm_substream *play_i2ssp_stream;
  123. struct snd_pcm_substream *capture_i2ssp_stream;
  124. struct snd_pcm_substream *play_i2sbt_stream;
  125. struct snd_pcm_substream *capture_i2sbt_stream;
  126. void __iomem *acp_mmio;
  127. u32 asic_type;
  128. };
  129. /*
  130. * this structure used for platform data transfer between machine driver
  131. * and dma driver
  132. */
  133. struct acp_platform_info {
  134. u16 i2s_instance;
  135. u16 capture_channel;
  136. };
  137. union acp_dma_count {
  138. struct {
  139. u32 low;
  140. u32 high;
  141. } bcount;
  142. u64 bytescount;
  143. };
  144. enum {
  145. ACP_TILE_P1 = 0,
  146. ACP_TILE_P2,
  147. ACP_TILE_DSP0,
  148. ACP_TILE_DSP1,
  149. ACP_TILE_DSP2,
  150. };
  151. enum {
  152. ACP_DMA_ATTR_SHAREDMEM_TO_DAGB_ONION = 0x0,
  153. ACP_DMA_ATTR_SHARED_MEM_TO_DAGB_GARLIC = 0x1,
  154. ACP_DMA_ATTR_DAGB_ONION_TO_SHAREDMEM = 0x8,
  155. ACP_DMA_ATTR_DAGB_GARLIC_TO_SHAREDMEM = 0x9,
  156. ACP_DMA_ATTR_FORCE_SIZE = 0xF
  157. };
  158. typedef struct acp_dma_dscr_transfer {
  159. /* Specifies the source memory location for the DMA data transfer. */
  160. u32 src;
  161. /*
  162. * Specifies the destination memory location to where the data will
  163. * be transferred.
  164. */
  165. u32 dest;
  166. /*
  167. * Specifies the number of bytes need to be transferred
  168. * from source to destination memory.Transfer direction & IOC enable
  169. */
  170. u32 xfer_val;
  171. /* Reserved for future use */
  172. u32 reserved;
  173. } acp_dma_dscr_transfer_t;
  174. #endif /*__ACP_HW_H */