18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 28c2ecf20Sopenharmony_ci#ifndef __ACP_HW_H 38c2ecf20Sopenharmony_ci#define __ACP_HW_H 48c2ecf20Sopenharmony_ci 58c2ecf20Sopenharmony_ci#include "include/acp_2_2_d.h" 68c2ecf20Sopenharmony_ci#include "include/acp_2_2_sh_mask.h" 78c2ecf20Sopenharmony_ci 88c2ecf20Sopenharmony_ci#define ACP_PAGE_SIZE_4K_ENABLE 0x02 98c2ecf20Sopenharmony_ci 108c2ecf20Sopenharmony_ci#define ACP_PLAYBACK_PTE_OFFSET 10 118c2ecf20Sopenharmony_ci#define ACP_CAPTURE_PTE_OFFSET 0 128c2ecf20Sopenharmony_ci 138c2ecf20Sopenharmony_ci/* Playback and Capture Offset for Stoney */ 148c2ecf20Sopenharmony_ci#define ACP_ST_PLAYBACK_PTE_OFFSET 0x04 158c2ecf20Sopenharmony_ci#define ACP_ST_CAPTURE_PTE_OFFSET 0x00 168c2ecf20Sopenharmony_ci#define ACP_ST_BT_PLAYBACK_PTE_OFFSET 0x08 178c2ecf20Sopenharmony_ci#define ACP_ST_BT_CAPTURE_PTE_OFFSET 0x0c 188c2ecf20Sopenharmony_ci 198c2ecf20Sopenharmony_ci#define ACP_GARLIC_CNTL_DEFAULT 0x00000FB4 208c2ecf20Sopenharmony_ci#define ACP_ONION_CNTL_DEFAULT 0x00000FB4 218c2ecf20Sopenharmony_ci 228c2ecf20Sopenharmony_ci#define ACP_PHYSICAL_BASE 0x14000 238c2ecf20Sopenharmony_ci 248c2ecf20Sopenharmony_ci/* 258c2ecf20Sopenharmony_ci * In case of I2S SP controller instance, Stoney uses SRAM bank 1 for 268c2ecf20Sopenharmony_ci * playback and SRAM Bank 2 for capture where as in case of BT I2S 278c2ecf20Sopenharmony_ci * Instance, Stoney uses SRAM Bank 3 for playback & SRAM Bank 4 will 288c2ecf20Sopenharmony_ci * be used for capture. Carrizo uses I2S SP controller instance. SRAM Banks 298c2ecf20Sopenharmony_ci * 1, 2, 3, 4 will be used for playback & SRAM Banks 5, 6, 7, 8 will be used 308c2ecf20Sopenharmony_ci * for capture scenario. 318c2ecf20Sopenharmony_ci */ 328c2ecf20Sopenharmony_ci#define ACP_SRAM_BANK_1_ADDRESS 0x4002000 338c2ecf20Sopenharmony_ci#define ACP_SRAM_BANK_2_ADDRESS 0x4004000 348c2ecf20Sopenharmony_ci#define ACP_SRAM_BANK_3_ADDRESS 0x4006000 358c2ecf20Sopenharmony_ci#define ACP_SRAM_BANK_4_ADDRESS 0x4008000 368c2ecf20Sopenharmony_ci#define ACP_SRAM_BANK_5_ADDRESS 0x400A000 378c2ecf20Sopenharmony_ci 388c2ecf20Sopenharmony_ci#define ACP_DMA_RESET_TIME 10000 398c2ecf20Sopenharmony_ci#define ACP_CLOCK_EN_TIME_OUT_VALUE 0x000000FF 408c2ecf20Sopenharmony_ci#define ACP_SOFT_RESET_DONE_TIME_OUT_VALUE 0x000000FF 418c2ecf20Sopenharmony_ci#define ACP_DMA_COMPLETE_TIME_OUT_VALUE 0x000000FF 428c2ecf20Sopenharmony_ci 438c2ecf20Sopenharmony_ci#define ACP_SRAM_BASE_ADDRESS 0x4000000 448c2ecf20Sopenharmony_ci#define ACP_DAGB_GRP_SRAM_BASE_ADDRESS 0x4001000 458c2ecf20Sopenharmony_ci#define ACP_DAGB_GRP_SRBM_SRAM_BASE_OFFSET 0x1000 468c2ecf20Sopenharmony_ci#define ACP_INTERNAL_APERTURE_WINDOW_0_ADDRESS 0x00000000 478c2ecf20Sopenharmony_ci#define ACP_INTERNAL_APERTURE_WINDOW_4_ADDRESS 0x01800000 488c2ecf20Sopenharmony_ci 498c2ecf20Sopenharmony_ci#define TO_ACP_I2S_1 0x2 508c2ecf20Sopenharmony_ci#define TO_ACP_I2S_2 0x4 518c2ecf20Sopenharmony_ci#define TO_BLUETOOTH 0x3 528c2ecf20Sopenharmony_ci#define FROM_ACP_I2S_1 0xa 538c2ecf20Sopenharmony_ci#define FROM_ACP_I2S_2 0xb 548c2ecf20Sopenharmony_ci#define FROM_BLUETOOTH 0xb 558c2ecf20Sopenharmony_ci 568c2ecf20Sopenharmony_ci#define I2S_SP_INSTANCE 0x01 578c2ecf20Sopenharmony_ci#define I2S_BT_INSTANCE 0x02 588c2ecf20Sopenharmony_ci#define CAP_CHANNEL0 0x00 598c2ecf20Sopenharmony_ci#define CAP_CHANNEL1 0x01 608c2ecf20Sopenharmony_ci 618c2ecf20Sopenharmony_ci#define ACP_TILE_ON_MASK 0x03 628c2ecf20Sopenharmony_ci#define ACP_TILE_OFF_MASK 0x02 638c2ecf20Sopenharmony_ci#define ACP_TILE_ON_RETAIN_REG_MASK 0x1f 648c2ecf20Sopenharmony_ci#define ACP_TILE_OFF_RETAIN_REG_MASK 0x20 658c2ecf20Sopenharmony_ci 668c2ecf20Sopenharmony_ci#define ACP_TILE_P1_MASK 0x3e 678c2ecf20Sopenharmony_ci#define ACP_TILE_P2_MASK 0x3d 688c2ecf20Sopenharmony_ci#define ACP_TILE_DSP0_MASK 0x3b 698c2ecf20Sopenharmony_ci#define ACP_TILE_DSP1_MASK 0x37 708c2ecf20Sopenharmony_ci 718c2ecf20Sopenharmony_ci#define ACP_TILE_DSP2_MASK 0x2f 728c2ecf20Sopenharmony_ci/* Playback DMA channels */ 738c2ecf20Sopenharmony_ci#define SYSRAM_TO_ACP_CH_NUM 12 748c2ecf20Sopenharmony_ci#define ACP_TO_I2S_DMA_CH_NUM 13 758c2ecf20Sopenharmony_ci 768c2ecf20Sopenharmony_ci/* Capture DMA channels */ 778c2ecf20Sopenharmony_ci#define I2S_TO_ACP_DMA_CH_NUM 14 788c2ecf20Sopenharmony_ci#define ACP_TO_SYSRAM_CH_NUM 15 798c2ecf20Sopenharmony_ci 808c2ecf20Sopenharmony_ci/* Playback DMA Channels for I2S BT instance */ 818c2ecf20Sopenharmony_ci#define SYSRAM_TO_ACP_BT_INSTANCE_CH_NUM 8 828c2ecf20Sopenharmony_ci#define ACP_TO_I2S_DMA_BT_INSTANCE_CH_NUM 9 838c2ecf20Sopenharmony_ci 848c2ecf20Sopenharmony_ci/* Capture DMA Channels for I2S BT Instance */ 858c2ecf20Sopenharmony_ci#define I2S_TO_ACP_DMA_BT_INSTANCE_CH_NUM 10 868c2ecf20Sopenharmony_ci#define ACP_TO_SYSRAM_BT_INSTANCE_CH_NUM 11 878c2ecf20Sopenharmony_ci 888c2ecf20Sopenharmony_ci#define NUM_DSCRS_PER_CHANNEL 2 898c2ecf20Sopenharmony_ci 908c2ecf20Sopenharmony_ci#define PLAYBACK_START_DMA_DESCR_CH12 0 918c2ecf20Sopenharmony_ci#define PLAYBACK_END_DMA_DESCR_CH12 1 928c2ecf20Sopenharmony_ci#define PLAYBACK_START_DMA_DESCR_CH13 2 938c2ecf20Sopenharmony_ci#define PLAYBACK_END_DMA_DESCR_CH13 3 948c2ecf20Sopenharmony_ci 958c2ecf20Sopenharmony_ci#define CAPTURE_START_DMA_DESCR_CH14 4 968c2ecf20Sopenharmony_ci#define CAPTURE_END_DMA_DESCR_CH14 5 978c2ecf20Sopenharmony_ci#define CAPTURE_START_DMA_DESCR_CH15 6 988c2ecf20Sopenharmony_ci#define CAPTURE_END_DMA_DESCR_CH15 7 998c2ecf20Sopenharmony_ci 1008c2ecf20Sopenharmony_ci/* I2S BT Instance DMA Descriptors */ 1018c2ecf20Sopenharmony_ci#define PLAYBACK_START_DMA_DESCR_CH8 8 1028c2ecf20Sopenharmony_ci#define PLAYBACK_END_DMA_DESCR_CH8 9 1038c2ecf20Sopenharmony_ci#define PLAYBACK_START_DMA_DESCR_CH9 10 1048c2ecf20Sopenharmony_ci#define PLAYBACK_END_DMA_DESCR_CH9 11 1058c2ecf20Sopenharmony_ci 1068c2ecf20Sopenharmony_ci#define CAPTURE_START_DMA_DESCR_CH10 12 1078c2ecf20Sopenharmony_ci#define CAPTURE_END_DMA_DESCR_CH10 13 1088c2ecf20Sopenharmony_ci#define CAPTURE_START_DMA_DESCR_CH11 14 1098c2ecf20Sopenharmony_ci#define CAPTURE_END_DMA_DESCR_CH11 15 1108c2ecf20Sopenharmony_ci 1118c2ecf20Sopenharmony_ci#define mmACP_I2S_16BIT_RESOLUTION_EN 0x5209 1128c2ecf20Sopenharmony_ci#define ACP_I2S_MIC_16BIT_RESOLUTION_EN 0x01 1138c2ecf20Sopenharmony_ci#define ACP_I2S_SP_16BIT_RESOLUTION_EN 0x02 1148c2ecf20Sopenharmony_ci#define ACP_I2S_BT_16BIT_RESOLUTION_EN 0x04 1158c2ecf20Sopenharmony_ci#define ACP_BT_UART_PAD_SELECT_MASK 0x1 1168c2ecf20Sopenharmony_ci 1178c2ecf20Sopenharmony_cienum acp_dma_priority_level { 1188c2ecf20Sopenharmony_ci /* 0x0 Specifies the DMA channel is given normal priority */ 1198c2ecf20Sopenharmony_ci ACP_DMA_PRIORITY_LEVEL_NORMAL = 0x0, 1208c2ecf20Sopenharmony_ci /* 0x1 Specifies the DMA channel is given high priority */ 1218c2ecf20Sopenharmony_ci ACP_DMA_PRIORITY_LEVEL_HIGH = 0x1, 1228c2ecf20Sopenharmony_ci ACP_DMA_PRIORITY_LEVEL_FORCESIZE = 0xFF 1238c2ecf20Sopenharmony_ci}; 1248c2ecf20Sopenharmony_ci 1258c2ecf20Sopenharmony_cistruct audio_substream_data { 1268c2ecf20Sopenharmony_ci dma_addr_t dma_addr; 1278c2ecf20Sopenharmony_ci unsigned int order; 1288c2ecf20Sopenharmony_ci u16 num_of_pages; 1298c2ecf20Sopenharmony_ci u16 i2s_instance; 1308c2ecf20Sopenharmony_ci u16 capture_channel; 1318c2ecf20Sopenharmony_ci u16 direction; 1328c2ecf20Sopenharmony_ci u16 ch1; 1338c2ecf20Sopenharmony_ci u16 ch2; 1348c2ecf20Sopenharmony_ci u16 destination; 1358c2ecf20Sopenharmony_ci u16 dma_dscr_idx_1; 1368c2ecf20Sopenharmony_ci u16 dma_dscr_idx_2; 1378c2ecf20Sopenharmony_ci u32 pte_offset; 1388c2ecf20Sopenharmony_ci u32 sram_bank; 1398c2ecf20Sopenharmony_ci u32 byte_cnt_high_reg_offset; 1408c2ecf20Sopenharmony_ci u32 byte_cnt_low_reg_offset; 1418c2ecf20Sopenharmony_ci u32 dma_curr_dscr; 1428c2ecf20Sopenharmony_ci uint64_t size; 1438c2ecf20Sopenharmony_ci u64 bytescount; 1448c2ecf20Sopenharmony_ci void __iomem *acp_mmio; 1458c2ecf20Sopenharmony_ci}; 1468c2ecf20Sopenharmony_ci 1478c2ecf20Sopenharmony_cistruct audio_drv_data { 1488c2ecf20Sopenharmony_ci struct snd_pcm_substream *play_i2ssp_stream; 1498c2ecf20Sopenharmony_ci struct snd_pcm_substream *capture_i2ssp_stream; 1508c2ecf20Sopenharmony_ci struct snd_pcm_substream *play_i2sbt_stream; 1518c2ecf20Sopenharmony_ci struct snd_pcm_substream *capture_i2sbt_stream; 1528c2ecf20Sopenharmony_ci void __iomem *acp_mmio; 1538c2ecf20Sopenharmony_ci u32 asic_type; 1548c2ecf20Sopenharmony_ci}; 1558c2ecf20Sopenharmony_ci 1568c2ecf20Sopenharmony_ci/* 1578c2ecf20Sopenharmony_ci * this structure used for platform data transfer between machine driver 1588c2ecf20Sopenharmony_ci * and dma driver 1598c2ecf20Sopenharmony_ci */ 1608c2ecf20Sopenharmony_cistruct acp_platform_info { 1618c2ecf20Sopenharmony_ci u16 play_i2s_instance; 1628c2ecf20Sopenharmony_ci u16 cap_i2s_instance; 1638c2ecf20Sopenharmony_ci u16 capture_channel; 1648c2ecf20Sopenharmony_ci}; 1658c2ecf20Sopenharmony_ci 1668c2ecf20Sopenharmony_ciunion acp_dma_count { 1678c2ecf20Sopenharmony_ci struct { 1688c2ecf20Sopenharmony_ci u32 low; 1698c2ecf20Sopenharmony_ci u32 high; 1708c2ecf20Sopenharmony_ci } bcount; 1718c2ecf20Sopenharmony_ci u64 bytescount; 1728c2ecf20Sopenharmony_ci}; 1738c2ecf20Sopenharmony_ci 1748c2ecf20Sopenharmony_cienum { 1758c2ecf20Sopenharmony_ci ACP_TILE_P1 = 0, 1768c2ecf20Sopenharmony_ci ACP_TILE_P2, 1778c2ecf20Sopenharmony_ci ACP_TILE_DSP0, 1788c2ecf20Sopenharmony_ci ACP_TILE_DSP1, 1798c2ecf20Sopenharmony_ci ACP_TILE_DSP2, 1808c2ecf20Sopenharmony_ci}; 1818c2ecf20Sopenharmony_ci 1828c2ecf20Sopenharmony_cienum { 1838c2ecf20Sopenharmony_ci ACP_DMA_ATTR_SHAREDMEM_TO_DAGB_ONION = 0x0, 1848c2ecf20Sopenharmony_ci ACP_DMA_ATTR_SHARED_MEM_TO_DAGB_GARLIC = 0x1, 1858c2ecf20Sopenharmony_ci ACP_DMA_ATTR_DAGB_ONION_TO_SHAREDMEM = 0x8, 1868c2ecf20Sopenharmony_ci ACP_DMA_ATTR_DAGB_GARLIC_TO_SHAREDMEM = 0x9, 1878c2ecf20Sopenharmony_ci ACP_DMA_ATTR_FORCE_SIZE = 0xF 1888c2ecf20Sopenharmony_ci}; 1898c2ecf20Sopenharmony_ci 1908c2ecf20Sopenharmony_citypedef struct acp_dma_dscr_transfer { 1918c2ecf20Sopenharmony_ci /* Specifies the source memory location for the DMA data transfer. */ 1928c2ecf20Sopenharmony_ci u32 src; 1938c2ecf20Sopenharmony_ci /* 1948c2ecf20Sopenharmony_ci * Specifies the destination memory location to where the data will 1958c2ecf20Sopenharmony_ci * be transferred. 1968c2ecf20Sopenharmony_ci */ 1978c2ecf20Sopenharmony_ci u32 dest; 1988c2ecf20Sopenharmony_ci /* 1998c2ecf20Sopenharmony_ci * Specifies the number of bytes need to be transferred 2008c2ecf20Sopenharmony_ci * from source to destination memory.Transfer direction & IOC enable 2018c2ecf20Sopenharmony_ci */ 2028c2ecf20Sopenharmony_ci u32 xfer_val; 2038c2ecf20Sopenharmony_ci /* Reserved for future use */ 2048c2ecf20Sopenharmony_ci u32 reserved; 2058c2ecf20Sopenharmony_ci} acp_dma_dscr_transfer_t; 2068c2ecf20Sopenharmony_ci 2078c2ecf20Sopenharmony_ci#endif /*__ACP_HW_H */ 208