1 /* SPDX-License-Identifier: GPL-2.0 */
3 * mtk-base-afe.h -- Mediatek base afe structure
5 * Copyright (c) 2016 MediaTek Inc.
6 * Author: Garlic Tseng <garlic.tseng@mediatek.com>
9 #ifndef _MTK_BASE_AFE_H_
10 #define _MTK_BASE_AFE_H_
12 #include <linux/soc/mediatek/mtk_sip_svc.h>
14 #define MTK_STREAM_NUM (SNDRV_PCM_STREAM_LAST + 1)
15 #define MTK_SIP_AUDIO_CONTROL MTK_SIP_SMC_CMD(0x517)
17 /* SMC CALL Operations */
18 enum mtk_audio_smc_call_op {
19 MTK_AUDIO_SMC_OP_INIT = 0,
20 MTK_AUDIO_SMC_OP_DRAM_REQUEST,
21 MTK_AUDIO_SMC_OP_DRAM_RELEASE,
22 MTK_AUDIO_SMC_OP_SRAM_REQUEST,
23 MTK_AUDIO_SMC_OP_SRAM_RELEASE,
24 MTK_AUDIO_SMC_OP_ADSP_REQUEST,
25 MTK_AUDIO_SMC_OP_ADSP_RELEASE,
26 MTK_AUDIO_SMC_OP_DOMAIN_SIDEBANDS,
27 MTK_AUDIO_SMC_OP_BTCVSD_WRITE,
28 MTK_AUDIO_SMC_OP_BTCVSD_UPDATE_CTRL_CLEAR,
29 MTK_AUDIO_SMC_OP_BTCVSD_UPDATE_CTRL_UNDERFLOW,
33 struct mtk_base_memif_data {
52 int int_odd_flag_shift;
63 int agent_disable_reg;
64 int agent_disable_shift;
68 /* playback memif only */
77 struct mtk_base_irq_data {
94 struct mtk_base_afe_memif;
95 struct mtk_base_afe_irq;
96 struct mtk_base_afe_dai;
98 struct snd_pcm_substream;
101 struct mtk_base_afe {
102 void __iomem *base_addr;
104 struct regmap *regmap;
105 struct mutex irq_alloc_lock; /* dynamic alloc irq lock */
107 unsigned int const *reg_back_up_list;
108 unsigned int *reg_back_up;
109 unsigned int reg_back_up_list_num;
111 int (*runtime_suspend)(struct device *dev);
112 int (*runtime_resume)(struct device *dev);
115 struct mtk_base_afe_memif *memif;
117 struct mtk_base_afe_irq *irqs;
119 int memif_32bit_supported;
121 struct list_head sub_dais;
122 struct snd_soc_dai_driver *dai_drivers;
123 unsigned int num_dai_drivers;
125 const struct snd_pcm_hardware *mtk_afe_hardware;
126 int (*memif_fs)(struct snd_pcm_substream *substream,
128 int (*irq_fs)(struct snd_pcm_substream *substream,
130 int (*get_dai_fs)(struct mtk_base_afe *afe,
131 int dai_id, unsigned int rate);
132 int (*get_memif_pbuf_size)(struct snd_pcm_substream *substream);
134 int (*request_dram_resource)(struct device *dev);
135 int (*release_dram_resource)(struct device *dev);
140 struct mtk_base_afe_memif {
141 unsigned int phys_buf_addr;
143 struct snd_pcm_substream *substream;
144 const struct mtk_base_memif_data *data;
147 unsigned char *dma_area;
152 struct mtk_base_afe_irq {
153 const struct mtk_base_irq_data *irq_data;
157 struct mtk_base_afe_dai {
158 struct snd_soc_dai_driver *dai_drivers;
159 unsigned int num_dai_drivers;
161 const struct snd_kcontrol_new *controls;
162 unsigned int num_controls;
163 const struct snd_soc_dapm_widget *dapm_widgets;
164 unsigned int num_dapm_widgets;
165 const struct snd_soc_dapm_route *dapm_routes;
166 unsigned int num_dapm_routes;
168 struct list_head list;