Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 #ifndef __ACP_HW_H
0003 #define __ACP_HW_H
0004 
0005 #include "include/acp_2_2_d.h"
0006 #include "include/acp_2_2_sh_mask.h"
0007 
0008 #define ACP_PAGE_SIZE_4K_ENABLE         0x02
0009 
0010 #define ACP_PLAYBACK_PTE_OFFSET         10
0011 #define ACP_CAPTURE_PTE_OFFSET          0
0012 
0013 /* Playback and Capture Offset for Stoney */
0014 #define ACP_ST_PLAYBACK_PTE_OFFSET  0x04
0015 #define ACP_ST_CAPTURE_PTE_OFFSET   0x00
0016 #define ACP_ST_BT_PLAYBACK_PTE_OFFSET   0x08
0017 #define ACP_ST_BT_CAPTURE_PTE_OFFSET    0x0c
0018 
0019 #define ACP_GARLIC_CNTL_DEFAULT         0x00000FB4
0020 #define ACP_ONION_CNTL_DEFAULT          0x00000FB4
0021 
0022 #define ACP_PHYSICAL_BASE           0x14000
0023 
0024 /*
0025  * In case of I2S SP controller instance, Stoney uses SRAM bank 1 for
0026  * playback and SRAM Bank 2 for capture where as in case of BT I2S
0027  * Instance, Stoney uses SRAM Bank 3 for playback & SRAM Bank 4 will
0028  * be used for capture. Carrizo uses I2S SP controller instance. SRAM Banks
0029  * 1, 2, 3, 4 will be used for playback & SRAM Banks 5, 6, 7, 8 will be used
0030  * for capture scenario.
0031  */
0032 #define ACP_SRAM_BANK_1_ADDRESS     0x4002000
0033 #define ACP_SRAM_BANK_2_ADDRESS     0x4004000
0034 #define ACP_SRAM_BANK_3_ADDRESS     0x4006000
0035 #define ACP_SRAM_BANK_4_ADDRESS     0x4008000
0036 #define ACP_SRAM_BANK_5_ADDRESS     0x400A000
0037 
0038 #define ACP_DMA_RESET_TIME          10000
0039 #define ACP_CLOCK_EN_TIME_OUT_VALUE     0x000000FF
0040 #define ACP_SOFT_RESET_DONE_TIME_OUT_VALUE  0x000000FF
0041 #define ACP_DMA_COMPLETE_TIME_OUT_VALUE     0x000000FF
0042 
0043 #define ACP_SRAM_BASE_ADDRESS           0x4000000
0044 #define ACP_DAGB_GRP_SRAM_BASE_ADDRESS      0x4001000
0045 #define ACP_DAGB_GRP_SRBM_SRAM_BASE_OFFSET  0x1000
0046 #define ACP_INTERNAL_APERTURE_WINDOW_0_ADDRESS  0x00000000
0047 #define ACP_INTERNAL_APERTURE_WINDOW_4_ADDRESS  0x01800000
0048 
0049 #define TO_ACP_I2S_1   0x2
0050 #define TO_ACP_I2S_2   0x4
0051 #define TO_BLUETOOTH   0x3
0052 #define FROM_ACP_I2S_1 0xa
0053 #define FROM_ACP_I2S_2 0xb
0054 #define FROM_BLUETOOTH 0xb
0055 
0056 #define I2S_SP_INSTANCE                 0x01
0057 #define I2S_BT_INSTANCE                 0x02
0058 #define I2S_MICSP_INSTANCE      0x03
0059 #define CAP_CHANNEL0            0x00
0060 #define CAP_CHANNEL1            0x01
0061 
0062 #define ACP_TILE_ON_MASK                0x03
0063 #define ACP_TILE_OFF_MASK               0x02
0064 #define ACP_TILE_ON_RETAIN_REG_MASK     0x1f
0065 #define ACP_TILE_OFF_RETAIN_REG_MASK    0x20
0066 
0067 #define ACP_TILE_P1_MASK                0x3e
0068 #define ACP_TILE_P2_MASK                0x3d
0069 #define ACP_TILE_DSP0_MASK              0x3b
0070 #define ACP_TILE_DSP1_MASK              0x37
0071 
0072 #define ACP_TILE_DSP2_MASK              0x2f
0073 /* Playback DMA channels */
0074 #define SYSRAM_TO_ACP_CH_NUM 12
0075 #define ACP_TO_I2S_DMA_CH_NUM 13
0076 
0077 /* Capture DMA channels */
0078 #define I2S_TO_ACP_DMA_CH_NUM 14
0079 #define ACP_TO_SYSRAM_CH_NUM 15
0080 
0081 /* Playback DMA Channels for I2S BT instance */
0082 #define SYSRAM_TO_ACP_BT_INSTANCE_CH_NUM  8
0083 #define ACP_TO_I2S_DMA_BT_INSTANCE_CH_NUM 9
0084 
0085 /* Capture DMA Channels for I2S BT Instance */
0086 #define I2S_TO_ACP_DMA_BT_INSTANCE_CH_NUM 10
0087 #define ACP_TO_SYSRAM_BT_INSTANCE_CH_NUM 11
0088 
0089 /* Playback DMA channels for I2S MICSP instance */
0090 #define SYSRAM_TO_ACP_MICSP_INSTANCE_CH_NUM  4
0091 #define ACP_TO_I2S_DMA_MICSP_INSTANCE_CH_NUM 5
0092 
0093 #define NUM_DSCRS_PER_CHANNEL 2
0094 
0095 #define PLAYBACK_START_DMA_DESCR_CH12 0
0096 #define PLAYBACK_END_DMA_DESCR_CH12 1
0097 #define PLAYBACK_START_DMA_DESCR_CH13 2
0098 #define PLAYBACK_END_DMA_DESCR_CH13 3
0099 
0100 #define CAPTURE_START_DMA_DESCR_CH14 4
0101 #define CAPTURE_END_DMA_DESCR_CH14 5
0102 #define CAPTURE_START_DMA_DESCR_CH15 6
0103 #define CAPTURE_END_DMA_DESCR_CH15 7
0104 
0105 /* I2S BT Instance DMA Descriptors */
0106 #define PLAYBACK_START_DMA_DESCR_CH8 8
0107 #define PLAYBACK_END_DMA_DESCR_CH8 9
0108 #define PLAYBACK_START_DMA_DESCR_CH9 10
0109 #define PLAYBACK_END_DMA_DESCR_CH9 11
0110 
0111 #define CAPTURE_START_DMA_DESCR_CH10 12
0112 #define CAPTURE_END_DMA_DESCR_CH10 13
0113 #define CAPTURE_START_DMA_DESCR_CH11 14
0114 #define CAPTURE_END_DMA_DESCR_CH11 15
0115 
0116 /* I2S MICSP Instance DMA Descriptors */
0117 #define PLAYBACK_START_DMA_DESCR_CH4 0
0118 #define PLAYBACK_END_DMA_DESCR_CH4 1
0119 #define PLAYBACK_START_DMA_DESCR_CH5 2
0120 #define PLAYBACK_END_DMA_DESCR_CH5 3
0121 
0122 #define mmACP_I2S_16BIT_RESOLUTION_EN       0x5209
0123 #define ACP_I2S_MIC_16BIT_RESOLUTION_EN 0x01
0124 #define ACP_I2S_MICSP_16BIT_RESOLUTION_EN 0x01
0125 #define ACP_I2S_SP_16BIT_RESOLUTION_EN  0x02
0126 #define ACP_I2S_BT_16BIT_RESOLUTION_EN  0x04
0127 #define ACP_BT_UART_PAD_SELECT_MASK 0x1
0128 
0129 enum acp_dma_priority_level {
0130     /* 0x0 Specifies the DMA channel is given normal priority */
0131     ACP_DMA_PRIORITY_LEVEL_NORMAL = 0x0,
0132     /* 0x1 Specifies the DMA channel is given high priority */
0133     ACP_DMA_PRIORITY_LEVEL_HIGH = 0x1,
0134     ACP_DMA_PRIORITY_LEVEL_FORCESIZE = 0xFF
0135 };
0136 
0137 struct audio_substream_data {
0138     dma_addr_t dma_addr;
0139     unsigned int order;
0140     u16 num_of_pages;
0141     u16 i2s_instance;
0142     u16 capture_channel;
0143     u16 direction;
0144     u16 ch1;
0145     u16 ch2;
0146     u16 destination;
0147     u16 dma_dscr_idx_1;
0148     u16 dma_dscr_idx_2;
0149     u32 pte_offset;
0150     u32 sram_bank;
0151     u32 byte_cnt_high_reg_offset;
0152     u32 byte_cnt_low_reg_offset;
0153     u32 dma_curr_dscr;
0154     uint64_t size;
0155     u64 bytescount;
0156     void __iomem *acp_mmio;
0157 };
0158 
0159 struct audio_drv_data {
0160     struct snd_pcm_substream *play_i2ssp_stream;
0161     struct snd_pcm_substream *capture_i2ssp_stream;
0162     struct snd_pcm_substream *play_i2sbt_stream;
0163     struct snd_pcm_substream *capture_i2sbt_stream;
0164     struct snd_pcm_substream *play_i2s_micsp_stream;
0165     void __iomem *acp_mmio;
0166     u32 asic_type;
0167     snd_pcm_sframes_t delay;
0168 };
0169 
0170 /*
0171  * this structure used for platform data transfer between machine driver
0172  * and dma driver
0173  */
0174 struct acp_platform_info {
0175     u16 play_i2s_instance;
0176     u16 cap_i2s_instance;
0177     u16 capture_channel;
0178 };
0179 
0180 union acp_dma_count {
0181     struct {
0182     u32 low;
0183     u32 high;
0184     } bcount;
0185     u64 bytescount;
0186 };
0187 
0188 enum {
0189     ACP_TILE_P1 = 0,
0190     ACP_TILE_P2,
0191     ACP_TILE_DSP0,
0192     ACP_TILE_DSP1,
0193     ACP_TILE_DSP2,
0194 };
0195 
0196 enum {
0197     ACP_DMA_ATTR_SHAREDMEM_TO_DAGB_ONION = 0x0,
0198     ACP_DMA_ATTR_SHARED_MEM_TO_DAGB_GARLIC = 0x1,
0199     ACP_DMA_ATTR_DAGB_ONION_TO_SHAREDMEM = 0x8,
0200     ACP_DMA_ATTR_DAGB_GARLIC_TO_SHAREDMEM = 0x9,
0201     ACP_DMA_ATTR_FORCE_SIZE = 0xF
0202 };
0203 
0204 typedef struct acp_dma_dscr_transfer {
0205     /* Specifies the source memory location for the DMA data transfer. */
0206     u32 src;
0207     /*
0208      * Specifies the destination memory location to where the data will
0209      * be transferred.
0210      */
0211     u32 dest;
0212     /*
0213      * Specifies the number of bytes need to be transferred
0214      * from source to destination memory.Transfer direction & IOC enable
0215      */
0216     u32 xfer_val;
0217     /* Reserved for future use */
0218     u32 reserved;
0219 } acp_dma_dscr_transfer_t;
0220 
0221 extern bool acp_bt_uart_enable;
0222 
0223 #endif /*__ACP_HW_H */