1 /* SPDX-License-Identifier: GPL-2.0 */ 1 /* SPDX-License-Identifier: GPL-2.0 */ 2 /* 2 /* 3 * mtk-base-afe.h -- Mediatek base afe struc 3 * mtk-base-afe.h -- Mediatek base afe structure 4 * 4 * 5 * Copyright (c) 2016 MediaTek Inc. 5 * Copyright (c) 2016 MediaTek Inc. 6 * Author: Garlic Tseng <garlic.tseng@mediatek 6 * Author: Garlic Tseng <garlic.tseng@mediatek.com> 7 */ 7 */ 8 8 9 #ifndef _MTK_BASE_AFE_H_ 9 #ifndef _MTK_BASE_AFE_H_ 10 #define _MTK_BASE_AFE_H_ 10 #define _MTK_BASE_AFE_H_ 11 11 12 #include <linux/soc/mediatek/mtk_sip_svc.h> 12 #include <linux/soc/mediatek/mtk_sip_svc.h> 13 13 14 #define MTK_STREAM_NUM (SNDRV_PCM_STREAM_LAST 14 #define MTK_STREAM_NUM (SNDRV_PCM_STREAM_LAST + 1) 15 #define MTK_SIP_AUDIO_CONTROL MTK_SIP_SMC_CMD( 15 #define MTK_SIP_AUDIO_CONTROL MTK_SIP_SMC_CMD(0x517) 16 16 17 /* SMC CALL Operations */ 17 /* SMC CALL Operations */ 18 enum mtk_audio_smc_call_op { 18 enum mtk_audio_smc_call_op { 19 MTK_AUDIO_SMC_OP_INIT = 0, 19 MTK_AUDIO_SMC_OP_INIT = 0, 20 MTK_AUDIO_SMC_OP_DRAM_REQUEST, 20 MTK_AUDIO_SMC_OP_DRAM_REQUEST, 21 MTK_AUDIO_SMC_OP_DRAM_RELEASE, 21 MTK_AUDIO_SMC_OP_DRAM_RELEASE, 22 MTK_AUDIO_SMC_OP_SRAM_REQUEST, 22 MTK_AUDIO_SMC_OP_SRAM_REQUEST, 23 MTK_AUDIO_SMC_OP_SRAM_RELEASE, 23 MTK_AUDIO_SMC_OP_SRAM_RELEASE, 24 MTK_AUDIO_SMC_OP_ADSP_REQUEST, 24 MTK_AUDIO_SMC_OP_ADSP_REQUEST, 25 MTK_AUDIO_SMC_OP_ADSP_RELEASE, 25 MTK_AUDIO_SMC_OP_ADSP_RELEASE, 26 MTK_AUDIO_SMC_OP_DOMAIN_SIDEBANDS, 26 MTK_AUDIO_SMC_OP_DOMAIN_SIDEBANDS, 27 MTK_AUDIO_SMC_OP_BTCVSD_WRITE, 27 MTK_AUDIO_SMC_OP_BTCVSD_WRITE, 28 MTK_AUDIO_SMC_OP_BTCVSD_UPDATE_CTRL_CL 28 MTK_AUDIO_SMC_OP_BTCVSD_UPDATE_CTRL_CLEAR, 29 MTK_AUDIO_SMC_OP_BTCVSD_UPDATE_CTRL_UN 29 MTK_AUDIO_SMC_OP_BTCVSD_UPDATE_CTRL_UNDERFLOW, 30 MTK_AUDIO_SMC_OP_NUM 30 MTK_AUDIO_SMC_OP_NUM 31 }; 31 }; 32 32 33 struct mtk_base_memif_data { 33 struct mtk_base_memif_data { 34 int id; 34 int id; 35 const char *name; 35 const char *name; 36 int reg_ofs_base; 36 int reg_ofs_base; 37 int reg_ofs_cur; 37 int reg_ofs_cur; 38 int reg_ofs_end; 38 int reg_ofs_end; 39 int reg_ofs_base_msb; 39 int reg_ofs_base_msb; 40 int reg_ofs_cur_msb; 40 int reg_ofs_cur_msb; 41 int reg_ofs_end_msb; 41 int reg_ofs_end_msb; 42 int fs_reg; 42 int fs_reg; 43 int fs_shift; 43 int fs_shift; 44 int fs_maskbit; 44 int fs_maskbit; 45 int mono_reg; 45 int mono_reg; 46 int mono_shift; 46 int mono_shift; 47 int mono_invert; 47 int mono_invert; 48 int quad_ch_reg; 48 int quad_ch_reg; 49 int quad_ch_mask; 49 int quad_ch_mask; 50 int quad_ch_shift; 50 int quad_ch_shift; 51 int int_odd_flag_reg; 51 int int_odd_flag_reg; 52 int int_odd_flag_shift; 52 int int_odd_flag_shift; 53 int enable_reg; 53 int enable_reg; 54 int enable_shift; 54 int enable_shift; 55 int hd_reg; 55 int hd_reg; 56 int hd_shift; 56 int hd_shift; 57 int hd_align_reg; 57 int hd_align_reg; 58 int hd_align_mshift; 58 int hd_align_mshift; 59 int msb_reg; 59 int msb_reg; 60 int msb_shift; 60 int msb_shift; 61 int msb_end_reg; 61 int msb_end_reg; 62 int msb_end_shift; 62 int msb_end_shift; 63 int agent_disable_reg; 63 int agent_disable_reg; 64 int agent_disable_shift; 64 int agent_disable_shift; 65 int ch_num_reg; 65 int ch_num_reg; 66 int ch_num_shift; 66 int ch_num_shift; 67 int ch_num_maskbit; 67 int ch_num_maskbit; 68 /* playback memif only */ 68 /* playback memif only */ 69 int pbuf_reg; 69 int pbuf_reg; 70 int pbuf_mask; 70 int pbuf_mask; 71 int pbuf_shift; 71 int pbuf_shift; 72 int minlen_reg; 72 int minlen_reg; 73 int minlen_mask; 73 int minlen_mask; 74 int minlen_shift; 74 int minlen_shift; 75 }; 75 }; 76 76 77 struct mtk_base_irq_data { 77 struct mtk_base_irq_data { 78 int id; 78 int id; 79 int irq_cnt_reg; 79 int irq_cnt_reg; 80 int irq_cnt_shift; 80 int irq_cnt_shift; 81 int irq_cnt_maskbit; 81 int irq_cnt_maskbit; 82 int irq_fs_reg; 82 int irq_fs_reg; 83 int irq_fs_shift; 83 int irq_fs_shift; 84 int irq_fs_maskbit; 84 int irq_fs_maskbit; 85 int irq_en_reg; 85 int irq_en_reg; 86 int irq_en_shift; 86 int irq_en_shift; 87 int irq_clr_reg; 87 int irq_clr_reg; 88 int irq_clr_shift; 88 int irq_clr_shift; 89 int irq_status_shift; 89 int irq_status_shift; 90 }; 90 }; 91 91 92 struct device; 92 struct device; 93 struct list_head; 93 struct list_head; 94 struct mtk_base_afe_memif; 94 struct mtk_base_afe_memif; 95 struct mtk_base_afe_irq; 95 struct mtk_base_afe_irq; 96 struct mtk_base_afe_dai; 96 struct mtk_base_afe_dai; 97 struct regmap; 97 struct regmap; 98 struct snd_pcm_substream; 98 struct snd_pcm_substream; 99 struct snd_soc_dai; 99 struct snd_soc_dai; 100 100 101 struct mtk_base_afe { 101 struct mtk_base_afe { 102 void __iomem *base_addr; 102 void __iomem *base_addr; 103 struct device *dev; 103 struct device *dev; 104 struct regmap *regmap; 104 struct regmap *regmap; 105 struct mutex irq_alloc_lock; /* dynami 105 struct mutex irq_alloc_lock; /* dynamic alloc irq lock */ 106 106 107 unsigned int const *reg_back_up_list; 107 unsigned int const *reg_back_up_list; 108 unsigned int *reg_back_up; 108 unsigned int *reg_back_up; 109 unsigned int reg_back_up_list_num; 109 unsigned int reg_back_up_list_num; 110 110 111 int (*runtime_suspend)(struct device * 111 int (*runtime_suspend)(struct device *dev); 112 int (*runtime_resume)(struct device *d 112 int (*runtime_resume)(struct device *dev); 113 bool suspended; 113 bool suspended; 114 114 115 struct mtk_base_afe_memif *memif; 115 struct mtk_base_afe_memif *memif; 116 int memif_size; 116 int memif_size; 117 struct mtk_base_afe_irq *irqs; 117 struct mtk_base_afe_irq *irqs; 118 int irqs_size; 118 int irqs_size; 119 int memif_32bit_supported; 119 int memif_32bit_supported; 120 120 121 struct list_head sub_dais; 121 struct list_head sub_dais; 122 struct snd_soc_dai_driver *dai_drivers 122 struct snd_soc_dai_driver *dai_drivers; 123 unsigned int num_dai_drivers; 123 unsigned int num_dai_drivers; 124 124 125 const struct snd_pcm_hardware *mtk_afe 125 const struct snd_pcm_hardware *mtk_afe_hardware; 126 int (*memif_fs)(struct snd_pcm_substre 126 int (*memif_fs)(struct snd_pcm_substream *substream, 127 unsigned int rate); 127 unsigned int rate); 128 int (*irq_fs)(struct snd_pcm_substream 128 int (*irq_fs)(struct snd_pcm_substream *substream, 129 unsigned int rate); 129 unsigned int rate); 130 int (*get_dai_fs)(struct mtk_base_afe 130 int (*get_dai_fs)(struct mtk_base_afe *afe, 131 int dai_id, unsigned 131 int dai_id, unsigned int rate); 132 int (*get_memif_pbuf_size)(struct snd_ 132 int (*get_memif_pbuf_size)(struct snd_pcm_substream *substream); 133 133 134 int (*request_dram_resource)(struct de 134 int (*request_dram_resource)(struct device *dev); 135 int (*release_dram_resource)(struct de 135 int (*release_dram_resource)(struct device *dev); 136 136 137 void *platform_priv; 137 void *platform_priv; 138 }; 138 }; 139 139 140 struct mtk_base_afe_memif { 140 struct mtk_base_afe_memif { 141 unsigned int phys_buf_addr; 141 unsigned int phys_buf_addr; 142 int buffer_size; 142 int buffer_size; 143 struct snd_pcm_substream *substream; 143 struct snd_pcm_substream *substream; 144 const struct mtk_base_memif_data *data 144 const struct mtk_base_memif_data *data; 145 int irq_usage; 145 int irq_usage; 146 int const_irq; 146 int const_irq; 147 unsigned char *dma_area; 147 unsigned char *dma_area; 148 dma_addr_t dma_addr; 148 dma_addr_t dma_addr; 149 size_t dma_bytes; 149 size_t dma_bytes; 150 }; 150 }; 151 151 152 struct mtk_base_afe_irq { 152 struct mtk_base_afe_irq { 153 const struct mtk_base_irq_data *irq_da 153 const struct mtk_base_irq_data *irq_data; 154 int irq_occupyed; 154 int irq_occupyed; 155 }; 155 }; 156 156 157 struct mtk_base_afe_dai { 157 struct mtk_base_afe_dai { 158 struct snd_soc_dai_driver *dai_drivers 158 struct snd_soc_dai_driver *dai_drivers; 159 unsigned int num_dai_drivers; 159 unsigned int num_dai_drivers; 160 160 161 const struct snd_kcontrol_new *control 161 const struct snd_kcontrol_new *controls; 162 unsigned int num_controls; 162 unsigned int num_controls; 163 const struct snd_soc_dapm_widget *dapm 163 const struct snd_soc_dapm_widget *dapm_widgets; 164 unsigned int num_dapm_widgets; 164 unsigned int num_dapm_widgets; 165 const struct snd_soc_dapm_route *dapm_ 165 const struct snd_soc_dapm_route *dapm_routes; 166 unsigned int num_dapm_routes; 166 unsigned int num_dapm_routes; 167 167 168 struct list_head list; 168 struct list_head list; 169 }; 169 }; 170 170 171 #endif 171 #endif 172 172 173 173
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.