xref: /linux/sound/soc/mediatek/mt8183/mt8183-afe-pcm.c (revision 3a39d672e7f48b8d6b91a09afa4b55352773b4b5)
1a94aec03SShunli Wang // SPDX-License-Identifier: GPL-2.0
2a94aec03SShunli Wang //
3a94aec03SShunli Wang // Mediatek ALSA SoC AFE platform driver for 8183
4a94aec03SShunli Wang //
5a94aec03SShunli Wang // Copyright (c) 2018 MediaTek Inc.
6a94aec03SShunli Wang // Author: KaiChieh Chuang <kaichieh.chuang@mediatek.com>
7a94aec03SShunli Wang 
8a94aec03SShunli Wang #include <linux/delay.h>
9a94aec03SShunli Wang #include <linux/module.h>
10a94aec03SShunli Wang #include <linux/mfd/syscon.h>
11a94aec03SShunli Wang #include <linux/of.h>
12a94aec03SShunli Wang #include <linux/of_address.h>
13a94aec03SShunli Wang #include <linux/pm_runtime.h>
149e985503SJiaxin Yu #include <linux/reset.h>
15a94aec03SShunli Wang 
16a94aec03SShunli Wang #include "mt8183-afe-common.h"
17a94aec03SShunli Wang #include "mt8183-afe-clk.h"
18a94aec03SShunli Wang #include "mt8183-interconnection.h"
19a94aec03SShunli Wang #include "mt8183-reg.h"
20a94aec03SShunli Wang #include "../common/mtk-afe-platform-driver.h"
21a94aec03SShunli Wang #include "../common/mtk-afe-fe-dai.h"
22a94aec03SShunli Wang 
23a94aec03SShunli Wang enum {
24a94aec03SShunli Wang 	MTK_AFE_RATE_8K = 0,
25a94aec03SShunli Wang 	MTK_AFE_RATE_11K = 1,
26a94aec03SShunli Wang 	MTK_AFE_RATE_12K = 2,
27a94aec03SShunli Wang 	MTK_AFE_RATE_384K = 3,
28a94aec03SShunli Wang 	MTK_AFE_RATE_16K = 4,
29a94aec03SShunli Wang 	MTK_AFE_RATE_22K = 5,
30a94aec03SShunli Wang 	MTK_AFE_RATE_24K = 6,
31a94aec03SShunli Wang 	MTK_AFE_RATE_130K = 7,
32a94aec03SShunli Wang 	MTK_AFE_RATE_32K = 8,
33a94aec03SShunli Wang 	MTK_AFE_RATE_44K = 9,
34a94aec03SShunli Wang 	MTK_AFE_RATE_48K = 10,
35a94aec03SShunli Wang 	MTK_AFE_RATE_88K = 11,
36a94aec03SShunli Wang 	MTK_AFE_RATE_96K = 12,
37a94aec03SShunli Wang 	MTK_AFE_RATE_176K = 13,
38a94aec03SShunli Wang 	MTK_AFE_RATE_192K = 14,
39a94aec03SShunli Wang 	MTK_AFE_RATE_260K = 15,
40a94aec03SShunli Wang };
41a94aec03SShunli Wang 
42a94aec03SShunli Wang enum {
43a94aec03SShunli Wang 	MTK_AFE_DAI_MEMIF_RATE_8K = 0,
44a94aec03SShunli Wang 	MTK_AFE_DAI_MEMIF_RATE_16K = 1,
45a94aec03SShunli Wang 	MTK_AFE_DAI_MEMIF_RATE_32K = 2,
46a94aec03SShunli Wang 	MTK_AFE_DAI_MEMIF_RATE_48K = 3,
47a94aec03SShunli Wang };
48a94aec03SShunli Wang 
49a94aec03SShunli Wang enum {
50a94aec03SShunli Wang 	MTK_AFE_PCM_RATE_8K = 0,
51a94aec03SShunli Wang 	MTK_AFE_PCM_RATE_16K = 1,
52a94aec03SShunli Wang 	MTK_AFE_PCM_RATE_32K = 2,
53a94aec03SShunli Wang 	MTK_AFE_PCM_RATE_48K = 3,
54a94aec03SShunli Wang };
55a94aec03SShunli Wang 
mt8183_general_rate_transform(struct device * dev,unsigned int rate)56a94aec03SShunli Wang unsigned int mt8183_general_rate_transform(struct device *dev,
57a94aec03SShunli Wang 					   unsigned int rate)
58a94aec03SShunli Wang {
59a94aec03SShunli Wang 	switch (rate) {
60a94aec03SShunli Wang 	case 8000:
61a94aec03SShunli Wang 		return MTK_AFE_RATE_8K;
62a94aec03SShunli Wang 	case 11025:
63a94aec03SShunli Wang 		return MTK_AFE_RATE_11K;
64a94aec03SShunli Wang 	case 12000:
65a94aec03SShunli Wang 		return MTK_AFE_RATE_12K;
66a94aec03SShunli Wang 	case 16000:
67a94aec03SShunli Wang 		return MTK_AFE_RATE_16K;
68a94aec03SShunli Wang 	case 22050:
69a94aec03SShunli Wang 		return MTK_AFE_RATE_22K;
70a94aec03SShunli Wang 	case 24000:
71a94aec03SShunli Wang 		return MTK_AFE_RATE_24K;
72a94aec03SShunli Wang 	case 32000:
73a94aec03SShunli Wang 		return MTK_AFE_RATE_32K;
74a94aec03SShunli Wang 	case 44100:
75a94aec03SShunli Wang 		return MTK_AFE_RATE_44K;
76a94aec03SShunli Wang 	case 48000:
77a94aec03SShunli Wang 		return MTK_AFE_RATE_48K;
78a94aec03SShunli Wang 	case 88200:
79a94aec03SShunli Wang 		return MTK_AFE_RATE_88K;
80a94aec03SShunli Wang 	case 96000:
81a94aec03SShunli Wang 		return MTK_AFE_RATE_96K;
82a94aec03SShunli Wang 	case 130000:
83a94aec03SShunli Wang 		return MTK_AFE_RATE_130K;
84a94aec03SShunli Wang 	case 176400:
85a94aec03SShunli Wang 		return MTK_AFE_RATE_176K;
86a94aec03SShunli Wang 	case 192000:
87a94aec03SShunli Wang 		return MTK_AFE_RATE_192K;
88a94aec03SShunli Wang 	case 260000:
89a94aec03SShunli Wang 		return MTK_AFE_RATE_260K;
90a94aec03SShunli Wang 	default:
91a94aec03SShunli Wang 		dev_warn(dev, "%s(), rate %u invalid, use %d!!!\n",
92a94aec03SShunli Wang 			 __func__, rate, MTK_AFE_RATE_48K);
93a94aec03SShunli Wang 		return MTK_AFE_RATE_48K;
94a94aec03SShunli Wang 	}
95a94aec03SShunli Wang }
96a94aec03SShunli Wang 
dai_memif_rate_transform(struct device * dev,unsigned int rate)97a94aec03SShunli Wang static unsigned int dai_memif_rate_transform(struct device *dev,
98a94aec03SShunli Wang 					     unsigned int rate)
99a94aec03SShunli Wang {
100a94aec03SShunli Wang 	switch (rate) {
101a94aec03SShunli Wang 	case 8000:
102a94aec03SShunli Wang 		return MTK_AFE_DAI_MEMIF_RATE_8K;
103a94aec03SShunli Wang 	case 16000:
104a94aec03SShunli Wang 		return MTK_AFE_DAI_MEMIF_RATE_16K;
105a94aec03SShunli Wang 	case 32000:
106a94aec03SShunli Wang 		return MTK_AFE_DAI_MEMIF_RATE_32K;
107a94aec03SShunli Wang 	case 48000:
108a94aec03SShunli Wang 		return MTK_AFE_DAI_MEMIF_RATE_48K;
109a94aec03SShunli Wang 	default:
110a94aec03SShunli Wang 		dev_warn(dev, "%s(), rate %u invalid, use %d!!!\n",
111a94aec03SShunli Wang 			 __func__, rate, MTK_AFE_DAI_MEMIF_RATE_16K);
112a94aec03SShunli Wang 		return MTK_AFE_DAI_MEMIF_RATE_16K;
113a94aec03SShunli Wang 	}
114a94aec03SShunli Wang }
115a94aec03SShunli Wang 
mt8183_rate_transform(struct device * dev,unsigned int rate,int aud_blk)116a94aec03SShunli Wang unsigned int mt8183_rate_transform(struct device *dev,
117a94aec03SShunli Wang 				   unsigned int rate, int aud_blk)
118a94aec03SShunli Wang {
119a94aec03SShunli Wang 	switch (aud_blk) {
120a94aec03SShunli Wang 	case MT8183_MEMIF_MOD_DAI:
121a94aec03SShunli Wang 		return dai_memif_rate_transform(dev, rate);
122a94aec03SShunli Wang 	default:
123a94aec03SShunli Wang 		return mt8183_general_rate_transform(dev, rate);
124a94aec03SShunli Wang 	}
125a94aec03SShunli Wang }
126a94aec03SShunli Wang 
127a94aec03SShunli Wang static const struct snd_pcm_hardware mt8183_afe_hardware = {
128a94aec03SShunli Wang 	.info = SNDRV_PCM_INFO_MMAP |
129a94aec03SShunli Wang 		SNDRV_PCM_INFO_INTERLEAVED |
130a94aec03SShunli Wang 		SNDRV_PCM_INFO_MMAP_VALID,
131a94aec03SShunli Wang 	.formats = SNDRV_PCM_FMTBIT_S16_LE |
132a94aec03SShunli Wang 		   SNDRV_PCM_FMTBIT_S24_LE |
133a94aec03SShunli Wang 		   SNDRV_PCM_FMTBIT_S32_LE,
134a94aec03SShunli Wang 	.period_bytes_min = 256,
135a94aec03SShunli Wang 	.period_bytes_max = 4 * 48 * 1024,
136a94aec03SShunli Wang 	.periods_min = 2,
137a94aec03SShunli Wang 	.periods_max = 256,
138a94aec03SShunli Wang 	.buffer_bytes_max = 8 * 48 * 1024,
139a94aec03SShunli Wang 	.fifo_size = 0,
140a94aec03SShunli Wang };
141a94aec03SShunli Wang 
mt8183_memif_fs(struct snd_pcm_substream * substream,unsigned int rate)142a94aec03SShunli Wang static int mt8183_memif_fs(struct snd_pcm_substream *substream,
143a94aec03SShunli Wang 			   unsigned int rate)
144a94aec03SShunli Wang {
145de9e7013SKuninori Morimoto 	struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
146a94aec03SShunli Wang 	struct snd_soc_component *component =
147a94aec03SShunli Wang 		snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME);
148a94aec03SShunli Wang 	struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component);
149de9e7013SKuninori Morimoto 	int id = snd_soc_rtd_to_cpu(rtd, 0)->id;
150a94aec03SShunli Wang 
151a94aec03SShunli Wang 	return mt8183_rate_transform(afe->dev, rate, id);
152a94aec03SShunli Wang }
153a94aec03SShunli Wang 
mt8183_irq_fs(struct snd_pcm_substream * substream,unsigned int rate)154a94aec03SShunli Wang static int mt8183_irq_fs(struct snd_pcm_substream *substream, unsigned int rate)
155a94aec03SShunli Wang {
156de9e7013SKuninori Morimoto 	struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
157a94aec03SShunli Wang 	struct snd_soc_component *component =
158a94aec03SShunli Wang 		snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME);
159a94aec03SShunli Wang 	struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component);
160a94aec03SShunli Wang 
161a94aec03SShunli Wang 	return mt8183_general_rate_transform(afe->dev, rate);
162a94aec03SShunli Wang }
163a94aec03SShunli Wang 
164a94aec03SShunli Wang #define MTK_PCM_RATES (SNDRV_PCM_RATE_8000_48000 |\
165a94aec03SShunli Wang 		       SNDRV_PCM_RATE_88200 |\
166a94aec03SShunli Wang 		       SNDRV_PCM_RATE_96000 |\
167a94aec03SShunli Wang 		       SNDRV_PCM_RATE_176400 |\
168a94aec03SShunli Wang 		       SNDRV_PCM_RATE_192000)
169a94aec03SShunli Wang 
170a94aec03SShunli Wang #define MTK_PCM_DAI_RATES (SNDRV_PCM_RATE_8000 |\
171a94aec03SShunli Wang 			   SNDRV_PCM_RATE_16000 |\
172a94aec03SShunli Wang 			   SNDRV_PCM_RATE_32000 |\
173a94aec03SShunli Wang 			   SNDRV_PCM_RATE_48000)
174a94aec03SShunli Wang 
175a94aec03SShunli Wang #define MTK_PCM_FORMATS (SNDRV_PCM_FMTBIT_S16_LE |\
176a94aec03SShunli Wang 			 SNDRV_PCM_FMTBIT_S24_LE |\
177a94aec03SShunli Wang 			 SNDRV_PCM_FMTBIT_S32_LE)
178a94aec03SShunli Wang 
179a94aec03SShunli Wang static struct snd_soc_dai_driver mt8183_memif_dai_driver[] = {
180a94aec03SShunli Wang 	/* FE DAIs: memory intefaces to CPU */
181a94aec03SShunli Wang 	{
182a94aec03SShunli Wang 		.name = "DL1",
183a94aec03SShunli Wang 		.id = MT8183_MEMIF_DL1,
184a94aec03SShunli Wang 		.playback = {
185a94aec03SShunli Wang 			.stream_name = "DL1",
186a94aec03SShunli Wang 			.channels_min = 1,
187a94aec03SShunli Wang 			.channels_max = 2,
188a94aec03SShunli Wang 			.rates = MTK_PCM_RATES,
189a94aec03SShunli Wang 			.formats = MTK_PCM_FORMATS,
190a94aec03SShunli Wang 		},
191a94aec03SShunli Wang 		.ops = &mtk_afe_fe_ops,
192a94aec03SShunli Wang 	},
193a94aec03SShunli Wang 	{
194a94aec03SShunli Wang 		.name = "DL2",
195a94aec03SShunli Wang 		.id = MT8183_MEMIF_DL2,
196a94aec03SShunli Wang 		.playback = {
197a94aec03SShunli Wang 			.stream_name = "DL2",
198a94aec03SShunli Wang 			.channels_min = 1,
199a94aec03SShunli Wang 			.channels_max = 2,
200a94aec03SShunli Wang 			.rates = MTK_PCM_RATES,
201a94aec03SShunli Wang 			.formats = MTK_PCM_FORMATS,
202a94aec03SShunli Wang 		},
203a94aec03SShunli Wang 		.ops = &mtk_afe_fe_ops,
204a94aec03SShunli Wang 	},
205a94aec03SShunli Wang 	{
206a94aec03SShunli Wang 		.name = "DL3",
207a94aec03SShunli Wang 		.id = MT8183_MEMIF_DL3,
208a94aec03SShunli Wang 		.playback = {
209a94aec03SShunli Wang 			.stream_name = "DL3",
210a94aec03SShunli Wang 			.channels_min = 1,
211a94aec03SShunli Wang 			.channels_max = 2,
212a94aec03SShunli Wang 			.rates = MTK_PCM_RATES,
213a94aec03SShunli Wang 			.formats = MTK_PCM_FORMATS,
214a94aec03SShunli Wang 		},
215a94aec03SShunli Wang 		.ops = &mtk_afe_fe_ops,
216a94aec03SShunli Wang 	},
217a94aec03SShunli Wang 	{
218a94aec03SShunli Wang 		.name = "UL1",
219a94aec03SShunli Wang 		.id = MT8183_MEMIF_VUL12,
220a94aec03SShunli Wang 		.capture = {
221a94aec03SShunli Wang 			.stream_name = "UL1",
222a94aec03SShunli Wang 			.channels_min = 1,
223a94aec03SShunli Wang 			.channels_max = 2,
224a94aec03SShunli Wang 			.rates = MTK_PCM_RATES,
225a94aec03SShunli Wang 			.formats = MTK_PCM_FORMATS,
226a94aec03SShunli Wang 		},
227a94aec03SShunli Wang 		.ops = &mtk_afe_fe_ops,
228a94aec03SShunli Wang 	},
229a94aec03SShunli Wang 	{
230a94aec03SShunli Wang 		.name = "UL2",
231a94aec03SShunli Wang 		.id = MT8183_MEMIF_AWB,
232a94aec03SShunli Wang 		.capture = {
233a94aec03SShunli Wang 			.stream_name = "UL2",
234a94aec03SShunli Wang 			.channels_min = 1,
235a94aec03SShunli Wang 			.channels_max = 2,
236a94aec03SShunli Wang 			.rates = MTK_PCM_RATES,
237a94aec03SShunli Wang 			.formats = MTK_PCM_FORMATS,
238a94aec03SShunli Wang 		},
239a94aec03SShunli Wang 		.ops = &mtk_afe_fe_ops,
240a94aec03SShunli Wang 	},
241a94aec03SShunli Wang 	{
242a94aec03SShunli Wang 		.name = "UL3",
243a94aec03SShunli Wang 		.id = MT8183_MEMIF_VUL2,
244a94aec03SShunli Wang 		.capture = {
245a94aec03SShunli Wang 			.stream_name = "UL3",
246a94aec03SShunli Wang 			.channels_min = 1,
247a94aec03SShunli Wang 			.channels_max = 2,
248a94aec03SShunli Wang 			.rates = MTK_PCM_RATES,
249a94aec03SShunli Wang 			.formats = MTK_PCM_FORMATS,
250a94aec03SShunli Wang 		},
251a94aec03SShunli Wang 		.ops = &mtk_afe_fe_ops,
252a94aec03SShunli Wang 	},
253a94aec03SShunli Wang 	{
254a94aec03SShunli Wang 		.name = "UL4",
255a94aec03SShunli Wang 		.id = MT8183_MEMIF_AWB2,
256a94aec03SShunli Wang 		.capture = {
257a94aec03SShunli Wang 			.stream_name = "UL4",
258a94aec03SShunli Wang 			.channels_min = 1,
259a94aec03SShunli Wang 			.channels_max = 2,
260a94aec03SShunli Wang 			.rates = MTK_PCM_RATES,
261a94aec03SShunli Wang 			.formats = MTK_PCM_FORMATS,
262a94aec03SShunli Wang 		},
263a94aec03SShunli Wang 		.ops = &mtk_afe_fe_ops,
264a94aec03SShunli Wang 	},
265a94aec03SShunli Wang 	{
266a94aec03SShunli Wang 		.name = "UL_MONO_1",
267a94aec03SShunli Wang 		.id = MT8183_MEMIF_MOD_DAI,
268a94aec03SShunli Wang 		.capture = {
269a94aec03SShunli Wang 			.stream_name = "UL_MONO_1",
270a94aec03SShunli Wang 			.channels_min = 1,
271a94aec03SShunli Wang 			.channels_max = 1,
272a94aec03SShunli Wang 			.rates = MTK_PCM_DAI_RATES,
273a94aec03SShunli Wang 			.formats = MTK_PCM_FORMATS,
274a94aec03SShunli Wang 		},
275a94aec03SShunli Wang 		.ops = &mtk_afe_fe_ops,
276a94aec03SShunli Wang 	},
277a94aec03SShunli Wang 	{
278a94aec03SShunli Wang 		.name = "HDMI",
279a94aec03SShunli Wang 		.id = MT8183_MEMIF_HDMI,
280a94aec03SShunli Wang 		.playback = {
281a94aec03SShunli Wang 			.stream_name = "HDMI",
282a94aec03SShunli Wang 			.channels_min = 2,
283a94aec03SShunli Wang 			.channels_max = 8,
284a94aec03SShunli Wang 			.rates = MTK_PCM_RATES,
285a94aec03SShunli Wang 			.formats = MTK_PCM_FORMATS,
286a94aec03SShunli Wang 		},
287a94aec03SShunli Wang 		.ops = &mtk_afe_fe_ops,
288a94aec03SShunli Wang 	},
289a94aec03SShunli Wang };
290a94aec03SShunli Wang 
291a94aec03SShunli Wang /* dma widget & routes*/
292a94aec03SShunli Wang static const struct snd_kcontrol_new memif_ul1_ch1_mix[] = {
293a94aec03SShunli Wang 	SOC_DAPM_SINGLE_AUTODISABLE("ADDA_UL_CH1", AFE_CONN21,
294a94aec03SShunli Wang 				    I_ADDA_UL_CH1, 1, 0),
295d232591cSShunli Wang 	SOC_DAPM_SINGLE_AUTODISABLE("I2S0_CH1", AFE_CONN21,
296d232591cSShunli Wang 				    I_I2S0_CH1, 1, 0),
297a94aec03SShunli Wang };
298a94aec03SShunli Wang 
299a94aec03SShunli Wang static const struct snd_kcontrol_new memif_ul1_ch2_mix[] = {
300a94aec03SShunli Wang 	SOC_DAPM_SINGLE_AUTODISABLE("ADDA_UL_CH2", AFE_CONN22,
301a94aec03SShunli Wang 				    I_ADDA_UL_CH2, 1, 0),
302d232591cSShunli Wang 	SOC_DAPM_SINGLE_AUTODISABLE("I2S0_CH2", AFE_CONN21,
303d232591cSShunli Wang 				    I_I2S0_CH2, 1, 0),
304a94aec03SShunli Wang };
305a94aec03SShunli Wang 
306a94aec03SShunli Wang static const struct snd_kcontrol_new memif_ul2_ch1_mix[] = {
307a94aec03SShunli Wang 	SOC_DAPM_SINGLE_AUTODISABLE("ADDA_UL_CH1", AFE_CONN5,
308a94aec03SShunli Wang 				    I_ADDA_UL_CH1, 1, 0),
309a94aec03SShunli Wang 	SOC_DAPM_SINGLE_AUTODISABLE("DL1_CH1", AFE_CONN5,
310a94aec03SShunli Wang 				    I_DL1_CH1, 1, 0),
311a94aec03SShunli Wang 	SOC_DAPM_SINGLE_AUTODISABLE("DL2_CH1", AFE_CONN5,
312a94aec03SShunli Wang 				    I_DL2_CH1, 1, 0),
313a94aec03SShunli Wang 	SOC_DAPM_SINGLE_AUTODISABLE("DL3_CH1", AFE_CONN5,
314a94aec03SShunli Wang 				    I_DL3_CH1, 1, 0),
315d232591cSShunli Wang 	SOC_DAPM_SINGLE_AUTODISABLE("I2S2_CH1", AFE_CONN5,
316d232591cSShunli Wang 				    I_I2S2_CH1, 1, 0),
317a94aec03SShunli Wang };
318a94aec03SShunli Wang 
319a94aec03SShunli Wang static const struct snd_kcontrol_new memif_ul2_ch2_mix[] = {
320a94aec03SShunli Wang 	SOC_DAPM_SINGLE_AUTODISABLE("ADDA_UL_CH2", AFE_CONN6,
321a94aec03SShunli Wang 				    I_ADDA_UL_CH2, 1, 0),
322a94aec03SShunli Wang 	SOC_DAPM_SINGLE_AUTODISABLE("DL1_CH2", AFE_CONN6,
323a94aec03SShunli Wang 				    I_DL1_CH2, 1, 0),
324a94aec03SShunli Wang 	SOC_DAPM_SINGLE_AUTODISABLE("DL2_CH2", AFE_CONN6,
325a94aec03SShunli Wang 				    I_DL2_CH2, 1, 0),
326a94aec03SShunli Wang 	SOC_DAPM_SINGLE_AUTODISABLE("DL3_CH2", AFE_CONN6,
327a94aec03SShunli Wang 				    I_DL3_CH2, 1, 0),
328d232591cSShunli Wang 	SOC_DAPM_SINGLE_AUTODISABLE("I2S2_CH2", AFE_CONN6,
329d232591cSShunli Wang 				    I_I2S2_CH2, 1, 0),
330a94aec03SShunli Wang };
331a94aec03SShunli Wang 
332a94aec03SShunli Wang static const struct snd_kcontrol_new memif_ul3_ch1_mix[] = {
333a94aec03SShunli Wang 	SOC_DAPM_SINGLE_AUTODISABLE("ADDA_UL_CH1", AFE_CONN32,
334a94aec03SShunli Wang 				    I_ADDA_UL_CH1, 1, 0),
335d232591cSShunli Wang 	SOC_DAPM_SINGLE_AUTODISABLE("I2S2_CH1", AFE_CONN32,
336d232591cSShunli Wang 				    I_I2S2_CH1, 1, 0),
337a94aec03SShunli Wang };
338a94aec03SShunli Wang 
339a94aec03SShunli Wang static const struct snd_kcontrol_new memif_ul3_ch2_mix[] = {
340a94aec03SShunli Wang 	SOC_DAPM_SINGLE_AUTODISABLE("ADDA_UL_CH2", AFE_CONN33,
341a94aec03SShunli Wang 				    I_ADDA_UL_CH2, 1, 0),
342d232591cSShunli Wang 	SOC_DAPM_SINGLE_AUTODISABLE("I2S2_CH2", AFE_CONN33,
343d232591cSShunli Wang 				    I_I2S2_CH2, 1, 0),
344a94aec03SShunli Wang };
345a94aec03SShunli Wang 
346a94aec03SShunli Wang static const struct snd_kcontrol_new memif_ul4_ch1_mix[] = {
347a94aec03SShunli Wang 	SOC_DAPM_SINGLE_AUTODISABLE("ADDA_UL_CH1", AFE_CONN38,
348a94aec03SShunli Wang 				    I_ADDA_UL_CH1, 1, 0),
349a94aec03SShunli Wang };
350a94aec03SShunli Wang 
351a94aec03SShunli Wang static const struct snd_kcontrol_new memif_ul4_ch2_mix[] = {
352a94aec03SShunli Wang 	SOC_DAPM_SINGLE_AUTODISABLE("ADDA_UL_CH2", AFE_CONN39,
353a94aec03SShunli Wang 				    I_ADDA_UL_CH2, 1, 0),
354a94aec03SShunli Wang };
355a94aec03SShunli Wang 
356a94aec03SShunli Wang static const struct snd_kcontrol_new memif_ul_mono_1_mix[] = {
357a94aec03SShunli Wang 	SOC_DAPM_SINGLE_AUTODISABLE("ADDA_UL_CH1", AFE_CONN12,
358a94aec03SShunli Wang 				    I_ADDA_UL_CH1, 1, 0),
359a94aec03SShunli Wang 	SOC_DAPM_SINGLE_AUTODISABLE("ADDA_UL_CH2", AFE_CONN12,
360a94aec03SShunli Wang 				    I_ADDA_UL_CH2, 1, 0),
361a94aec03SShunli Wang };
362a94aec03SShunli Wang 
363a94aec03SShunli Wang static const struct snd_soc_dapm_widget mt8183_memif_widgets[] = {
364a94aec03SShunli Wang 	/* memif */
365a94aec03SShunli Wang 	SND_SOC_DAPM_MIXER("UL1_CH1", SND_SOC_NOPM, 0, 0,
366a94aec03SShunli Wang 			   memif_ul1_ch1_mix, ARRAY_SIZE(memif_ul1_ch1_mix)),
367a94aec03SShunli Wang 	SND_SOC_DAPM_MIXER("UL1_CH2", SND_SOC_NOPM, 0, 0,
368a94aec03SShunli Wang 			   memif_ul1_ch2_mix, ARRAY_SIZE(memif_ul1_ch2_mix)),
369a94aec03SShunli Wang 
370a94aec03SShunli Wang 	SND_SOC_DAPM_MIXER("UL2_CH1", SND_SOC_NOPM, 0, 0,
371a94aec03SShunli Wang 			   memif_ul2_ch1_mix, ARRAY_SIZE(memif_ul2_ch1_mix)),
372a94aec03SShunli Wang 	SND_SOC_DAPM_MIXER("UL2_CH2", SND_SOC_NOPM, 0, 0,
373a94aec03SShunli Wang 			   memif_ul2_ch2_mix, ARRAY_SIZE(memif_ul2_ch2_mix)),
374a94aec03SShunli Wang 
375a94aec03SShunli Wang 	SND_SOC_DAPM_MIXER("UL3_CH1", SND_SOC_NOPM, 0, 0,
376a94aec03SShunli Wang 			   memif_ul3_ch1_mix, ARRAY_SIZE(memif_ul3_ch1_mix)),
377a94aec03SShunli Wang 	SND_SOC_DAPM_MIXER("UL3_CH2", SND_SOC_NOPM, 0, 0,
378a94aec03SShunli Wang 			   memif_ul3_ch2_mix, ARRAY_SIZE(memif_ul3_ch2_mix)),
379a94aec03SShunli Wang 
380a94aec03SShunli Wang 	SND_SOC_DAPM_MIXER("UL4_CH1", SND_SOC_NOPM, 0, 0,
381a94aec03SShunli Wang 			   memif_ul4_ch1_mix, ARRAY_SIZE(memif_ul4_ch1_mix)),
382a94aec03SShunli Wang 	SND_SOC_DAPM_MIXER("UL4_CH2", SND_SOC_NOPM, 0, 0,
383a94aec03SShunli Wang 			   memif_ul4_ch2_mix, ARRAY_SIZE(memif_ul4_ch2_mix)),
384a94aec03SShunli Wang 
385a94aec03SShunli Wang 	SND_SOC_DAPM_MIXER("UL_MONO_1_CH1", SND_SOC_NOPM, 0, 0,
386a94aec03SShunli Wang 			   memif_ul_mono_1_mix,
387a94aec03SShunli Wang 			   ARRAY_SIZE(memif_ul_mono_1_mix)),
388a94aec03SShunli Wang };
389a94aec03SShunli Wang 
390a94aec03SShunli Wang static const struct snd_soc_dapm_route mt8183_memif_routes[] = {
391a94aec03SShunli Wang 	/* capture */
392a94aec03SShunli Wang 	{"UL1", NULL, "UL1_CH1"},
393a94aec03SShunli Wang 	{"UL1", NULL, "UL1_CH2"},
394a94aec03SShunli Wang 	{"UL1_CH1", "ADDA_UL_CH1", "ADDA Capture"},
395a94aec03SShunli Wang 	{"UL1_CH2", "ADDA_UL_CH2", "ADDA Capture"},
396d232591cSShunli Wang 	{"UL1_CH1", "I2S0_CH1", "I2S0"},
397d232591cSShunli Wang 	{"UL1_CH2", "I2S0_CH2", "I2S0"},
398a94aec03SShunli Wang 
399a94aec03SShunli Wang 	{"UL2", NULL, "UL2_CH1"},
400a94aec03SShunli Wang 	{"UL2", NULL, "UL2_CH2"},
401a94aec03SShunli Wang 	{"UL2_CH1", "ADDA_UL_CH1", "ADDA Capture"},
402a94aec03SShunli Wang 	{"UL2_CH2", "ADDA_UL_CH2", "ADDA Capture"},
403d232591cSShunli Wang 	{"UL2_CH1", "I2S2_CH1", "I2S2"},
404d232591cSShunli Wang 	{"UL2_CH2", "I2S2_CH2", "I2S2"},
405a94aec03SShunli Wang 
406a94aec03SShunli Wang 	{"UL3", NULL, "UL3_CH1"},
407a94aec03SShunli Wang 	{"UL3", NULL, "UL3_CH2"},
408a94aec03SShunli Wang 	{"UL3_CH1", "ADDA_UL_CH1", "ADDA Capture"},
409a94aec03SShunli Wang 	{"UL3_CH2", "ADDA_UL_CH2", "ADDA Capture"},
410d232591cSShunli Wang 	{"UL3_CH1", "I2S2_CH1", "I2S2"},
411d232591cSShunli Wang 	{"UL3_CH2", "I2S2_CH2", "I2S2"},
412a94aec03SShunli Wang 
413a94aec03SShunli Wang 	{"UL4", NULL, "UL4_CH1"},
414a94aec03SShunli Wang 	{"UL4", NULL, "UL4_CH2"},
415a94aec03SShunli Wang 	{"UL4_CH1", "ADDA_UL_CH1", "ADDA Capture"},
416a94aec03SShunli Wang 	{"UL4_CH2", "ADDA_UL_CH2", "ADDA Capture"},
417a94aec03SShunli Wang 
418a94aec03SShunli Wang 	{"UL_MONO_1", NULL, "UL_MONO_1_CH1"},
419a94aec03SShunli Wang 	{"UL_MONO_1_CH1", "ADDA_UL_CH1", "ADDA Capture"},
420a94aec03SShunli Wang 	{"UL_MONO_1_CH1", "ADDA_UL_CH2", "ADDA Capture"},
421a94aec03SShunli Wang };
422a94aec03SShunli Wang 
423a94aec03SShunli Wang static const struct snd_soc_component_driver mt8183_afe_pcm_dai_component = {
424a94aec03SShunli Wang 	.name = "mt8183-afe-pcm-dai",
425a94aec03SShunli Wang };
426a94aec03SShunli Wang 
427a94aec03SShunli Wang static const struct mtk_base_memif_data memif_data[MT8183_MEMIF_NUM] = {
428a94aec03SShunli Wang 	[MT8183_MEMIF_DL1] = {
429a94aec03SShunli Wang 		.name = "DL1",
430a94aec03SShunli Wang 		.id = MT8183_MEMIF_DL1,
431a94aec03SShunli Wang 		.reg_ofs_base = AFE_DL1_BASE,
432a94aec03SShunli Wang 		.reg_ofs_cur = AFE_DL1_CUR,
433a94aec03SShunli Wang 		.fs_reg = AFE_DAC_CON1,
434a94aec03SShunli Wang 		.fs_shift = DL1_MODE_SFT,
435a94aec03SShunli Wang 		.fs_maskbit = DL1_MODE_MASK,
436a94aec03SShunli Wang 		.mono_reg = AFE_DAC_CON1,
437a94aec03SShunli Wang 		.mono_shift = DL1_DATA_SFT,
438a94aec03SShunli Wang 		.enable_reg = AFE_DAC_CON0,
439a94aec03SShunli Wang 		.enable_shift = DL1_ON_SFT,
440a94aec03SShunli Wang 		.hd_reg = AFE_MEMIF_HD_MODE,
441cf61f5b0SShunli Wang 		.hd_align_reg = AFE_MEMIF_HDALIGN,
442a94aec03SShunli Wang 		.hd_shift = DL1_HD_SFT,
443383d30e7SJiaxin Yu 		.hd_align_mshift = DL1_HD_ALIGN_SFT,
444a94aec03SShunli Wang 		.agent_disable_reg = -1,
445d232591cSShunli Wang 		.agent_disable_shift = -1,
446a94aec03SShunli Wang 		.msb_reg = -1,
447d232591cSShunli Wang 		.msb_shift = -1,
448a94aec03SShunli Wang 	},
449a94aec03SShunli Wang 	[MT8183_MEMIF_DL2] = {
450a94aec03SShunli Wang 		.name = "DL2",
451a94aec03SShunli Wang 		.id = MT8183_MEMIF_DL2,
452a94aec03SShunli Wang 		.reg_ofs_base = AFE_DL2_BASE,
453a94aec03SShunli Wang 		.reg_ofs_cur = AFE_DL2_CUR,
454a94aec03SShunli Wang 		.fs_reg = AFE_DAC_CON1,
455a94aec03SShunli Wang 		.fs_shift = DL2_MODE_SFT,
456a94aec03SShunli Wang 		.fs_maskbit = DL2_MODE_MASK,
457a94aec03SShunli Wang 		.mono_reg = AFE_DAC_CON1,
458a94aec03SShunli Wang 		.mono_shift = DL2_DATA_SFT,
459a94aec03SShunli Wang 		.enable_reg = AFE_DAC_CON0,
460a94aec03SShunli Wang 		.enable_shift = DL2_ON_SFT,
461a94aec03SShunli Wang 		.hd_reg = AFE_MEMIF_HD_MODE,
462cf61f5b0SShunli Wang 		.hd_align_reg = AFE_MEMIF_HDALIGN,
463a94aec03SShunli Wang 		.hd_shift = DL2_HD_SFT,
464383d30e7SJiaxin Yu 		.hd_align_mshift = DL2_HD_ALIGN_SFT,
465a94aec03SShunli Wang 		.agent_disable_reg = -1,
466d232591cSShunli Wang 		.agent_disable_shift = -1,
467a94aec03SShunli Wang 		.msb_reg = -1,
468d232591cSShunli Wang 		.msb_shift = -1,
469a94aec03SShunli Wang 	},
470a94aec03SShunli Wang 	[MT8183_MEMIF_DL3] = {
471a94aec03SShunli Wang 		.name = "DL3",
472a94aec03SShunli Wang 		.id = MT8183_MEMIF_DL3,
473a94aec03SShunli Wang 		.reg_ofs_base = AFE_DL3_BASE,
474a94aec03SShunli Wang 		.reg_ofs_cur = AFE_DL3_CUR,
475a94aec03SShunli Wang 		.fs_reg = AFE_DAC_CON2,
476a94aec03SShunli Wang 		.fs_shift = DL3_MODE_SFT,
477a94aec03SShunli Wang 		.fs_maskbit = DL3_MODE_MASK,
478a94aec03SShunli Wang 		.mono_reg = AFE_DAC_CON1,
479a94aec03SShunli Wang 		.mono_shift = DL3_DATA_SFT,
480a94aec03SShunli Wang 		.enable_reg = AFE_DAC_CON0,
481a94aec03SShunli Wang 		.enable_shift = DL3_ON_SFT,
482a94aec03SShunli Wang 		.hd_reg = AFE_MEMIF_HD_MODE,
483cf61f5b0SShunli Wang 		.hd_align_reg = AFE_MEMIF_HDALIGN,
484a94aec03SShunli Wang 		.hd_shift = DL3_HD_SFT,
485383d30e7SJiaxin Yu 		.hd_align_mshift = DL3_HD_ALIGN_SFT,
486a94aec03SShunli Wang 		.agent_disable_reg = -1,
487d232591cSShunli Wang 		.agent_disable_shift = -1,
488a94aec03SShunli Wang 		.msb_reg = -1,
489d232591cSShunli Wang 		.msb_shift = -1,
490a94aec03SShunli Wang 	},
491a94aec03SShunli Wang 	[MT8183_MEMIF_VUL2] = {
492a94aec03SShunli Wang 		.name = "VUL2",
493a94aec03SShunli Wang 		.id = MT8183_MEMIF_VUL2,
494a94aec03SShunli Wang 		.reg_ofs_base = AFE_VUL2_BASE,
495a94aec03SShunli Wang 		.reg_ofs_cur = AFE_VUL2_CUR,
496a94aec03SShunli Wang 		.fs_reg = AFE_DAC_CON2,
497a94aec03SShunli Wang 		.fs_shift = VUL2_MODE_SFT,
498a94aec03SShunli Wang 		.fs_maskbit = VUL2_MODE_MASK,
499a94aec03SShunli Wang 		.mono_reg = AFE_DAC_CON2,
500a94aec03SShunli Wang 		.mono_shift = VUL2_DATA_SFT,
501a94aec03SShunli Wang 		.enable_reg = AFE_DAC_CON0,
502a94aec03SShunli Wang 		.enable_shift = VUL2_ON_SFT,
503a94aec03SShunli Wang 		.hd_reg = AFE_MEMIF_HD_MODE,
504cf61f5b0SShunli Wang 		.hd_align_reg = AFE_MEMIF_HDALIGN,
505a94aec03SShunli Wang 		.hd_shift = VUL2_HD_SFT,
506383d30e7SJiaxin Yu 		.hd_align_mshift = VUL2_HD_ALIGN_SFT,
507a94aec03SShunli Wang 		.agent_disable_reg = -1,
508d232591cSShunli Wang 		.agent_disable_shift = -1,
509a94aec03SShunli Wang 		.msb_reg = -1,
510d232591cSShunli Wang 		.msb_shift = -1,
511a94aec03SShunli Wang 	},
512a94aec03SShunli Wang 	[MT8183_MEMIF_AWB] = {
513a94aec03SShunli Wang 		.name = "AWB",
514a94aec03SShunli Wang 		.id = MT8183_MEMIF_AWB,
515a94aec03SShunli Wang 		.reg_ofs_base = AFE_AWB_BASE,
516a94aec03SShunli Wang 		.reg_ofs_cur = AFE_AWB_CUR,
517a94aec03SShunli Wang 		.fs_reg = AFE_DAC_CON1,
518a94aec03SShunli Wang 		.fs_shift = AWB_MODE_SFT,
519a94aec03SShunli Wang 		.fs_maskbit = AWB_MODE_MASK,
520a94aec03SShunli Wang 		.mono_reg = AFE_DAC_CON1,
521a94aec03SShunli Wang 		.mono_shift = AWB_DATA_SFT,
522a94aec03SShunli Wang 		.enable_reg = AFE_DAC_CON0,
523a94aec03SShunli Wang 		.enable_shift = AWB_ON_SFT,
524a94aec03SShunli Wang 		.hd_reg = AFE_MEMIF_HD_MODE,
525cf61f5b0SShunli Wang 		.hd_align_reg = AFE_MEMIF_HDALIGN,
526a94aec03SShunli Wang 		.hd_shift = AWB_HD_SFT,
527383d30e7SJiaxin Yu 		.hd_align_mshift = AWB_HD_ALIGN_SFT,
528a94aec03SShunli Wang 		.agent_disable_reg = -1,
529d232591cSShunli Wang 		.agent_disable_shift = -1,
530a94aec03SShunli Wang 		.msb_reg = -1,
531d232591cSShunli Wang 		.msb_shift = -1,
532a94aec03SShunli Wang 	},
533a94aec03SShunli Wang 	[MT8183_MEMIF_AWB2] = {
534a94aec03SShunli Wang 		.name = "AWB2",
535a94aec03SShunli Wang 		.id = MT8183_MEMIF_AWB2,
536a94aec03SShunli Wang 		.reg_ofs_base = AFE_AWB2_BASE,
537a94aec03SShunli Wang 		.reg_ofs_cur = AFE_AWB2_CUR,
538a94aec03SShunli Wang 		.fs_reg = AFE_DAC_CON2,
539a94aec03SShunli Wang 		.fs_shift = AWB2_MODE_SFT,
540a94aec03SShunli Wang 		.fs_maskbit = AWB2_MODE_MASK,
541a94aec03SShunli Wang 		.mono_reg = AFE_DAC_CON2,
542a94aec03SShunli Wang 		.mono_shift = AWB2_DATA_SFT,
543a94aec03SShunli Wang 		.enable_reg = AFE_DAC_CON0,
544a94aec03SShunli Wang 		.enable_shift = AWB2_ON_SFT,
545a94aec03SShunli Wang 		.hd_reg = AFE_MEMIF_HD_MODE,
546cf61f5b0SShunli Wang 		.hd_align_reg = AFE_MEMIF_HDALIGN,
547a94aec03SShunli Wang 		.hd_shift = AWB2_HD_SFT,
548383d30e7SJiaxin Yu 		.hd_align_mshift = AWB2_ALIGN_SFT,
549a94aec03SShunli Wang 		.agent_disable_reg = -1,
550d232591cSShunli Wang 		.agent_disable_shift = -1,
551a94aec03SShunli Wang 		.msb_reg = -1,
552d232591cSShunli Wang 		.msb_shift = -1,
553a94aec03SShunli Wang 	},
554a94aec03SShunli Wang 	[MT8183_MEMIF_VUL12] = {
555a94aec03SShunli Wang 		.name = "VUL12",
556a94aec03SShunli Wang 		.id = MT8183_MEMIF_VUL12,
557a94aec03SShunli Wang 		.reg_ofs_base = AFE_VUL_D2_BASE,
558a94aec03SShunli Wang 		.reg_ofs_cur = AFE_VUL_D2_CUR,
559a94aec03SShunli Wang 		.fs_reg = AFE_DAC_CON0,
560a94aec03SShunli Wang 		.fs_shift = VUL12_MODE_SFT,
561a94aec03SShunli Wang 		.fs_maskbit = VUL12_MODE_MASK,
562a94aec03SShunli Wang 		.mono_reg = AFE_DAC_CON0,
563a94aec03SShunli Wang 		.mono_shift = VUL12_MONO_SFT,
564a94aec03SShunli Wang 		.enable_reg = AFE_DAC_CON0,
565a94aec03SShunli Wang 		.enable_shift = VUL12_ON_SFT,
566a94aec03SShunli Wang 		.hd_reg = AFE_MEMIF_HD_MODE,
567cf61f5b0SShunli Wang 		.hd_align_reg = AFE_MEMIF_HDALIGN,
568a94aec03SShunli Wang 		.hd_shift = VUL12_HD_SFT,
569383d30e7SJiaxin Yu 		.hd_align_mshift = VUL12_HD_ALIGN_SFT,
570a94aec03SShunli Wang 		.agent_disable_reg = -1,
571d232591cSShunli Wang 		.agent_disable_shift = -1,
572a94aec03SShunli Wang 		.msb_reg = -1,
573d232591cSShunli Wang 		.msb_shift = -1,
574a94aec03SShunli Wang 	},
575a94aec03SShunli Wang 	[MT8183_MEMIF_MOD_DAI] = {
576a94aec03SShunli Wang 		.name = "MOD_DAI",
577a94aec03SShunli Wang 		.id = MT8183_MEMIF_MOD_DAI,
578a94aec03SShunli Wang 		.reg_ofs_base = AFE_MOD_DAI_BASE,
579a94aec03SShunli Wang 		.reg_ofs_cur = AFE_MOD_DAI_CUR,
580a94aec03SShunli Wang 		.fs_reg = AFE_DAC_CON1,
581a94aec03SShunli Wang 		.fs_shift = MOD_DAI_MODE_SFT,
582a94aec03SShunli Wang 		.fs_maskbit = MOD_DAI_MODE_MASK,
583a94aec03SShunli Wang 		.mono_reg = -1,
584a94aec03SShunli Wang 		.mono_shift = 0,
585a94aec03SShunli Wang 		.enable_reg = AFE_DAC_CON0,
586a94aec03SShunli Wang 		.enable_shift = MOD_DAI_ON_SFT,
587a94aec03SShunli Wang 		.hd_reg = AFE_MEMIF_HD_MODE,
588cf61f5b0SShunli Wang 		.hd_align_reg = AFE_MEMIF_HDALIGN,
589a94aec03SShunli Wang 		.hd_shift = MOD_DAI_HD_SFT,
590383d30e7SJiaxin Yu 		.hd_align_mshift = MOD_DAI_HD_ALIGN_SFT,
591a94aec03SShunli Wang 		.agent_disable_reg = -1,
592d232591cSShunli Wang 		.agent_disable_shift = -1,
593a94aec03SShunli Wang 		.msb_reg = -1,
594d232591cSShunli Wang 		.msb_shift = -1,
595a94aec03SShunli Wang 	},
596a94aec03SShunli Wang 	[MT8183_MEMIF_HDMI] = {
597a94aec03SShunli Wang 		.name = "HDMI",
598a94aec03SShunli Wang 		.id = MT8183_MEMIF_HDMI,
599a94aec03SShunli Wang 		.reg_ofs_base = AFE_HDMI_OUT_BASE,
600a94aec03SShunli Wang 		.reg_ofs_cur = AFE_HDMI_OUT_CUR,
601a94aec03SShunli Wang 		.fs_reg = -1,
602a94aec03SShunli Wang 		.fs_shift = -1,
603a94aec03SShunli Wang 		.fs_maskbit = -1,
604a94aec03SShunli Wang 		.mono_reg = -1,
605a94aec03SShunli Wang 		.mono_shift = -1,
606a94aec03SShunli Wang 		.enable_reg = -1,	/* control in tdm for sync start */
607d232591cSShunli Wang 		.enable_shift = -1,
608a94aec03SShunli Wang 		.hd_reg = AFE_MEMIF_HD_MODE,
609cf61f5b0SShunli Wang 		.hd_align_reg = AFE_MEMIF_HDALIGN,
610a94aec03SShunli Wang 		.hd_shift = HDMI_HD_SFT,
611383d30e7SJiaxin Yu 		.hd_align_mshift = HDMI_HD_ALIGN_SFT,
612a94aec03SShunli Wang 		.agent_disable_reg = -1,
613d232591cSShunli Wang 		.agent_disable_shift = -1,
614a94aec03SShunli Wang 		.msb_reg = -1,
615d232591cSShunli Wang 		.msb_shift = -1,
616a94aec03SShunli Wang 	},
617a94aec03SShunli Wang };
618a94aec03SShunli Wang 
619a94aec03SShunli Wang static const struct mtk_base_irq_data irq_data[MT8183_IRQ_NUM] = {
620a94aec03SShunli Wang 	[MT8183_IRQ_0] = {
621a94aec03SShunli Wang 		.id = MT8183_IRQ_0,
622a94aec03SShunli Wang 		.irq_cnt_reg = AFE_IRQ_MCU_CNT0,
623a94aec03SShunli Wang 		.irq_cnt_shift = 0,
624a94aec03SShunli Wang 		.irq_cnt_maskbit = 0x3ffff,
625a94aec03SShunli Wang 		.irq_fs_reg = AFE_IRQ_MCU_CON1,
626a94aec03SShunli Wang 		.irq_fs_shift = IRQ0_MCU_MODE_SFT,
627a94aec03SShunli Wang 		.irq_fs_maskbit = IRQ0_MCU_MODE_MASK,
628a94aec03SShunli Wang 		.irq_en_reg = AFE_IRQ_MCU_CON0,
629a94aec03SShunli Wang 		.irq_en_shift = IRQ0_MCU_ON_SFT,
630a94aec03SShunli Wang 		.irq_clr_reg = AFE_IRQ_MCU_CLR,
631a94aec03SShunli Wang 		.irq_clr_shift = IRQ0_MCU_CLR_SFT,
632a94aec03SShunli Wang 	},
633a94aec03SShunli Wang 	[MT8183_IRQ_1] = {
634a94aec03SShunli Wang 		.id = MT8183_IRQ_1,
635a94aec03SShunli Wang 		.irq_cnt_reg = AFE_IRQ_MCU_CNT1,
636a94aec03SShunli Wang 		.irq_cnt_shift = 0,
637a94aec03SShunli Wang 		.irq_cnt_maskbit = 0x3ffff,
638a94aec03SShunli Wang 		.irq_fs_reg = AFE_IRQ_MCU_CON1,
639a94aec03SShunli Wang 		.irq_fs_shift = IRQ1_MCU_MODE_SFT,
640a94aec03SShunli Wang 		.irq_fs_maskbit = IRQ1_MCU_MODE_MASK,
641a94aec03SShunli Wang 		.irq_en_reg = AFE_IRQ_MCU_CON0,
642a94aec03SShunli Wang 		.irq_en_shift = IRQ1_MCU_ON_SFT,
643a94aec03SShunli Wang 		.irq_clr_reg = AFE_IRQ_MCU_CLR,
644a94aec03SShunli Wang 		.irq_clr_shift = IRQ1_MCU_CLR_SFT,
645a94aec03SShunli Wang 	},
646a94aec03SShunli Wang 	[MT8183_IRQ_2] = {
647a94aec03SShunli Wang 		.id = MT8183_IRQ_2,
648a94aec03SShunli Wang 		.irq_cnt_reg = AFE_IRQ_MCU_CNT2,
649a94aec03SShunli Wang 		.irq_cnt_shift = 0,
650a94aec03SShunli Wang 		.irq_cnt_maskbit = 0x3ffff,
651a94aec03SShunli Wang 		.irq_fs_reg = AFE_IRQ_MCU_CON1,
652a94aec03SShunli Wang 		.irq_fs_shift = IRQ2_MCU_MODE_SFT,
653a94aec03SShunli Wang 		.irq_fs_maskbit = IRQ2_MCU_MODE_MASK,
654a94aec03SShunli Wang 		.irq_en_reg = AFE_IRQ_MCU_CON0,
655a94aec03SShunli Wang 		.irq_en_shift = IRQ2_MCU_ON_SFT,
656a94aec03SShunli Wang 		.irq_clr_reg = AFE_IRQ_MCU_CLR,
657a94aec03SShunli Wang 		.irq_clr_shift = IRQ2_MCU_CLR_SFT,
658a94aec03SShunli Wang 	},
659a94aec03SShunli Wang 	[MT8183_IRQ_3] = {
660a94aec03SShunli Wang 		.id = MT8183_IRQ_3,
661a94aec03SShunli Wang 		.irq_cnt_reg = AFE_IRQ_MCU_CNT3,
662a94aec03SShunli Wang 		.irq_cnt_shift = 0,
663a94aec03SShunli Wang 		.irq_cnt_maskbit = 0x3ffff,
664a94aec03SShunli Wang 		.irq_fs_reg = AFE_IRQ_MCU_CON1,
665a94aec03SShunli Wang 		.irq_fs_shift = IRQ3_MCU_MODE_SFT,
666a94aec03SShunli Wang 		.irq_fs_maskbit = IRQ3_MCU_MODE_MASK,
667a94aec03SShunli Wang 		.irq_en_reg = AFE_IRQ_MCU_CON0,
668a94aec03SShunli Wang 		.irq_en_shift = IRQ3_MCU_ON_SFT,
669a94aec03SShunli Wang 		.irq_clr_reg = AFE_IRQ_MCU_CLR,
670a94aec03SShunli Wang 		.irq_clr_shift = IRQ3_MCU_CLR_SFT,
671a94aec03SShunli Wang 	},
672a94aec03SShunli Wang 	[MT8183_IRQ_4] = {
673a94aec03SShunli Wang 		.id = MT8183_IRQ_4,
674a94aec03SShunli Wang 		.irq_cnt_reg = AFE_IRQ_MCU_CNT4,
675a94aec03SShunli Wang 		.irq_cnt_shift = 0,
676a94aec03SShunli Wang 		.irq_cnt_maskbit = 0x3ffff,
677a94aec03SShunli Wang 		.irq_fs_reg = AFE_IRQ_MCU_CON1,
678a94aec03SShunli Wang 		.irq_fs_shift = IRQ4_MCU_MODE_SFT,
679a94aec03SShunli Wang 		.irq_fs_maskbit = IRQ4_MCU_MODE_MASK,
680a94aec03SShunli Wang 		.irq_en_reg = AFE_IRQ_MCU_CON0,
681a94aec03SShunli Wang 		.irq_en_shift = IRQ4_MCU_ON_SFT,
682a94aec03SShunli Wang 		.irq_clr_reg = AFE_IRQ_MCU_CLR,
683a94aec03SShunli Wang 		.irq_clr_shift = IRQ4_MCU_CLR_SFT,
684a94aec03SShunli Wang 	},
685a94aec03SShunli Wang 	[MT8183_IRQ_5] = {
686a94aec03SShunli Wang 		.id = MT8183_IRQ_5,
687a94aec03SShunli Wang 		.irq_cnt_reg = AFE_IRQ_MCU_CNT5,
688a94aec03SShunli Wang 		.irq_cnt_shift = 0,
689a94aec03SShunli Wang 		.irq_cnt_maskbit = 0x3ffff,
690a94aec03SShunli Wang 		.irq_fs_reg = AFE_IRQ_MCU_CON1,
691a94aec03SShunli Wang 		.irq_fs_shift = IRQ5_MCU_MODE_SFT,
692a94aec03SShunli Wang 		.irq_fs_maskbit = IRQ5_MCU_MODE_MASK,
693a94aec03SShunli Wang 		.irq_en_reg = AFE_IRQ_MCU_CON0,
694a94aec03SShunli Wang 		.irq_en_shift = IRQ5_MCU_ON_SFT,
695a94aec03SShunli Wang 		.irq_clr_reg = AFE_IRQ_MCU_CLR,
696a94aec03SShunli Wang 		.irq_clr_shift = IRQ5_MCU_CLR_SFT,
697a94aec03SShunli Wang 	},
698a94aec03SShunli Wang 	[MT8183_IRQ_6] = {
699a94aec03SShunli Wang 		.id = MT8183_IRQ_6,
700a94aec03SShunli Wang 		.irq_cnt_reg = AFE_IRQ_MCU_CNT6,
701a94aec03SShunli Wang 		.irq_cnt_shift = 0,
702a94aec03SShunli Wang 		.irq_cnt_maskbit = 0x3ffff,
703a94aec03SShunli Wang 		.irq_fs_reg = AFE_IRQ_MCU_CON1,
704a94aec03SShunli Wang 		.irq_fs_shift = IRQ6_MCU_MODE_SFT,
705a94aec03SShunli Wang 		.irq_fs_maskbit = IRQ6_MCU_MODE_MASK,
706a94aec03SShunli Wang 		.irq_en_reg = AFE_IRQ_MCU_CON0,
707a94aec03SShunli Wang 		.irq_en_shift = IRQ6_MCU_ON_SFT,
708a94aec03SShunli Wang 		.irq_clr_reg = AFE_IRQ_MCU_CLR,
709a94aec03SShunli Wang 		.irq_clr_shift = IRQ6_MCU_CLR_SFT,
710a94aec03SShunli Wang 	},
711a94aec03SShunli Wang 	[MT8183_IRQ_7] = {
712a94aec03SShunli Wang 		.id = MT8183_IRQ_7,
713a94aec03SShunli Wang 		.irq_cnt_reg = AFE_IRQ_MCU_CNT7,
714a94aec03SShunli Wang 		.irq_cnt_shift = 0,
715a94aec03SShunli Wang 		.irq_cnt_maskbit = 0x3ffff,
716a94aec03SShunli Wang 		.irq_fs_reg = AFE_IRQ_MCU_CON1,
717a94aec03SShunli Wang 		.irq_fs_shift = IRQ7_MCU_MODE_SFT,
718a94aec03SShunli Wang 		.irq_fs_maskbit = IRQ7_MCU_MODE_MASK,
719a94aec03SShunli Wang 		.irq_en_reg = AFE_IRQ_MCU_CON0,
720a94aec03SShunli Wang 		.irq_en_shift = IRQ7_MCU_ON_SFT,
721a94aec03SShunli Wang 		.irq_clr_reg = AFE_IRQ_MCU_CLR,
722a94aec03SShunli Wang 		.irq_clr_shift = IRQ7_MCU_CLR_SFT,
723a94aec03SShunli Wang 	},
724a94aec03SShunli Wang 	[MT8183_IRQ_8] = {
725a94aec03SShunli Wang 		.id = MT8183_IRQ_8,
726a94aec03SShunli Wang 		.irq_cnt_reg = AFE_IRQ_MCU_CNT8,
727a94aec03SShunli Wang 		.irq_cnt_shift = 0,
728a94aec03SShunli Wang 		.irq_cnt_maskbit = 0x3ffff,
729a94aec03SShunli Wang 		.irq_fs_reg = -1,
730d232591cSShunli Wang 		.irq_fs_shift = -1,
731a94aec03SShunli Wang 		.irq_fs_maskbit = -1,
732a94aec03SShunli Wang 		.irq_en_reg = AFE_IRQ_MCU_CON0,
733a94aec03SShunli Wang 		.irq_en_shift = IRQ8_MCU_ON_SFT,
734a94aec03SShunli Wang 		.irq_clr_reg = AFE_IRQ_MCU_CLR,
735a94aec03SShunli Wang 		.irq_clr_shift = IRQ8_MCU_CLR_SFT,
736a94aec03SShunli Wang 	},
737a94aec03SShunli Wang 	[MT8183_IRQ_11] = {
738a94aec03SShunli Wang 		.id = MT8183_IRQ_11,
739a94aec03SShunli Wang 		.irq_cnt_reg = AFE_IRQ_MCU_CNT11,
740a94aec03SShunli Wang 		.irq_cnt_shift = 0,
741a94aec03SShunli Wang 		.irq_cnt_maskbit = 0x3ffff,
742a94aec03SShunli Wang 		.irq_fs_reg = AFE_IRQ_MCU_CON2,
743a94aec03SShunli Wang 		.irq_fs_shift = IRQ11_MCU_MODE_SFT,
744a94aec03SShunli Wang 		.irq_fs_maskbit = IRQ11_MCU_MODE_MASK,
745a94aec03SShunli Wang 		.irq_en_reg = AFE_IRQ_MCU_CON0,
746a94aec03SShunli Wang 		.irq_en_shift = IRQ11_MCU_ON_SFT,
747a94aec03SShunli Wang 		.irq_clr_reg = AFE_IRQ_MCU_CLR,
748a94aec03SShunli Wang 		.irq_clr_shift = IRQ11_MCU_CLR_SFT,
749a94aec03SShunli Wang 	},
750a94aec03SShunli Wang 	[MT8183_IRQ_12] = {
751a94aec03SShunli Wang 		.id = MT8183_IRQ_12,
752a94aec03SShunli Wang 		.irq_cnt_reg = AFE_IRQ_MCU_CNT12,
753a94aec03SShunli Wang 		.irq_cnt_shift = 0,
754a94aec03SShunli Wang 		.irq_cnt_maskbit = 0x3ffff,
755a94aec03SShunli Wang 		.irq_fs_reg = AFE_IRQ_MCU_CON2,
756a94aec03SShunli Wang 		.irq_fs_shift = IRQ12_MCU_MODE_SFT,
757a94aec03SShunli Wang 		.irq_fs_maskbit = IRQ12_MCU_MODE_MASK,
758a94aec03SShunli Wang 		.irq_en_reg = AFE_IRQ_MCU_CON0,
759a94aec03SShunli Wang 		.irq_en_shift = IRQ12_MCU_ON_SFT,
760a94aec03SShunli Wang 		.irq_clr_reg = AFE_IRQ_MCU_CLR,
761a94aec03SShunli Wang 		.irq_clr_shift = IRQ12_MCU_CLR_SFT,
762a94aec03SShunli Wang 	},
763a94aec03SShunli Wang };
764a94aec03SShunli Wang 
mt8183_is_volatile_reg(struct device * dev,unsigned int reg)765a94aec03SShunli Wang static bool mt8183_is_volatile_reg(struct device *dev, unsigned int reg)
766a94aec03SShunli Wang {
767a94aec03SShunli Wang 	/* these auto-gen reg has read-only bit, so put it as volatile */
768a94aec03SShunli Wang 	/* volatile reg cannot be cached, so cannot be set when power off */
769a94aec03SShunli Wang 	switch (reg) {
770a94aec03SShunli Wang 	case AUDIO_TOP_CON0:	/* reg bit controlled by CCF */
771a94aec03SShunli Wang 	case AUDIO_TOP_CON1:	/* reg bit controlled by CCF */
772a94aec03SShunli Wang 	case AUDIO_TOP_CON3:
773a94aec03SShunli Wang 	case AFE_DL1_CUR:
774a94aec03SShunli Wang 	case AFE_DL1_END:
775a94aec03SShunli Wang 	case AFE_DL2_CUR:
776a94aec03SShunli Wang 	case AFE_DL2_END:
777a94aec03SShunli Wang 	case AFE_AWB_END:
778a94aec03SShunli Wang 	case AFE_AWB_CUR:
779a94aec03SShunli Wang 	case AFE_VUL_END:
780a94aec03SShunli Wang 	case AFE_VUL_CUR:
781a94aec03SShunli Wang 	case AFE_MEMIF_MON0:
782a94aec03SShunli Wang 	case AFE_MEMIF_MON1:
783a94aec03SShunli Wang 	case AFE_MEMIF_MON2:
784a94aec03SShunli Wang 	case AFE_MEMIF_MON3:
785a94aec03SShunli Wang 	case AFE_MEMIF_MON4:
786a94aec03SShunli Wang 	case AFE_MEMIF_MON5:
787a94aec03SShunli Wang 	case AFE_MEMIF_MON6:
788a94aec03SShunli Wang 	case AFE_MEMIF_MON7:
789a94aec03SShunli Wang 	case AFE_MEMIF_MON8:
790a94aec03SShunli Wang 	case AFE_MEMIF_MON9:
791a94aec03SShunli Wang 	case AFE_ADDA_SRC_DEBUG_MON0:
792a94aec03SShunli Wang 	case AFE_ADDA_SRC_DEBUG_MON1:
793a94aec03SShunli Wang 	case AFE_ADDA_UL_SRC_MON0:
794a94aec03SShunli Wang 	case AFE_ADDA_UL_SRC_MON1:
795a94aec03SShunli Wang 	case AFE_SIDETONE_MON:
796a94aec03SShunli Wang 	case AFE_SIDETONE_CON0:
797a94aec03SShunli Wang 	case AFE_SIDETONE_COEFF:
798a94aec03SShunli Wang 	case AFE_BUS_MON0:
799a94aec03SShunli Wang 	case AFE_MRGIF_MON0:
800a94aec03SShunli Wang 	case AFE_MRGIF_MON1:
801a94aec03SShunli Wang 	case AFE_MRGIF_MON2:
802a94aec03SShunli Wang 	case AFE_I2S_MON:
803a94aec03SShunli Wang 	case AFE_DAC_MON:
804a94aec03SShunli Wang 	case AFE_VUL2_END:
805a94aec03SShunli Wang 	case AFE_VUL2_CUR:
806a94aec03SShunli Wang 	case AFE_IRQ0_MCU_CNT_MON:
807a94aec03SShunli Wang 	case AFE_IRQ6_MCU_CNT_MON:
808a94aec03SShunli Wang 	case AFE_MOD_DAI_END:
809a94aec03SShunli Wang 	case AFE_MOD_DAI_CUR:
810a94aec03SShunli Wang 	case AFE_VUL_D2_END:
811a94aec03SShunli Wang 	case AFE_VUL_D2_CUR:
812a94aec03SShunli Wang 	case AFE_DL3_CUR:
813a94aec03SShunli Wang 	case AFE_DL3_END:
814a94aec03SShunli Wang 	case AFE_HDMI_OUT_CON0:
815a94aec03SShunli Wang 	case AFE_HDMI_OUT_CUR:
816a94aec03SShunli Wang 	case AFE_HDMI_OUT_END:
817a94aec03SShunli Wang 	case AFE_IRQ3_MCU_CNT_MON:
818a94aec03SShunli Wang 	case AFE_IRQ4_MCU_CNT_MON:
819a94aec03SShunli Wang 	case AFE_IRQ_MCU_STATUS:
820a94aec03SShunli Wang 	case AFE_IRQ_MCU_CLR:
821a94aec03SShunli Wang 	case AFE_IRQ_MCU_MON2:
822a94aec03SShunli Wang 	case AFE_IRQ1_MCU_CNT_MON:
823a94aec03SShunli Wang 	case AFE_IRQ2_MCU_CNT_MON:
824a94aec03SShunli Wang 	case AFE_IRQ1_MCU_EN_CNT_MON:
825a94aec03SShunli Wang 	case AFE_IRQ5_MCU_CNT_MON:
826a94aec03SShunli Wang 	case AFE_IRQ7_MCU_CNT_MON:
827a94aec03SShunli Wang 	case AFE_GAIN1_CUR:
828a94aec03SShunli Wang 	case AFE_GAIN2_CUR:
829a94aec03SShunli Wang 	case AFE_SRAM_DELSEL_CON0:
830a94aec03SShunli Wang 	case AFE_SRAM_DELSEL_CON2:
831a94aec03SShunli Wang 	case AFE_SRAM_DELSEL_CON3:
832a94aec03SShunli Wang 	case AFE_ASRC_2CH_CON12:
833a94aec03SShunli Wang 	case AFE_ASRC_2CH_CON13:
834a94aec03SShunli Wang 	case PCM_INTF_CON2:
835a94aec03SShunli Wang 	case FPGA_CFG0:
836a94aec03SShunli Wang 	case FPGA_CFG1:
837a94aec03SShunli Wang 	case FPGA_CFG2:
838a94aec03SShunli Wang 	case FPGA_CFG3:
839a94aec03SShunli Wang 	case AUDIO_TOP_DBG_MON0:
840a94aec03SShunli Wang 	case AUDIO_TOP_DBG_MON1:
841a94aec03SShunli Wang 	case AFE_IRQ8_MCU_CNT_MON:
842a94aec03SShunli Wang 	case AFE_IRQ11_MCU_CNT_MON:
843a94aec03SShunli Wang 	case AFE_IRQ12_MCU_CNT_MON:
844a94aec03SShunli Wang 	case AFE_CBIP_MON0:
845a94aec03SShunli Wang 	case AFE_CBIP_SLV_MUX_MON0:
846a94aec03SShunli Wang 	case AFE_CBIP_SLV_DECODER_MON0:
847a94aec03SShunli Wang 	case AFE_ADDA6_SRC_DEBUG_MON0:
848a94aec03SShunli Wang 	case AFE_ADD6A_UL_SRC_MON0:
849a94aec03SShunli Wang 	case AFE_ADDA6_UL_SRC_MON1:
850a94aec03SShunli Wang 	case AFE_DL1_CUR_MSB:
851a94aec03SShunli Wang 	case AFE_DL2_CUR_MSB:
852a94aec03SShunli Wang 	case AFE_AWB_CUR_MSB:
853a94aec03SShunli Wang 	case AFE_VUL_CUR_MSB:
854a94aec03SShunli Wang 	case AFE_VUL2_CUR_MSB:
855a94aec03SShunli Wang 	case AFE_MOD_DAI_CUR_MSB:
856a94aec03SShunli Wang 	case AFE_VUL_D2_CUR_MSB:
857a94aec03SShunli Wang 	case AFE_DL3_CUR_MSB:
858a94aec03SShunli Wang 	case AFE_HDMI_OUT_CUR_MSB:
859a94aec03SShunli Wang 	case AFE_AWB2_END:
860a94aec03SShunli Wang 	case AFE_AWB2_CUR:
861a94aec03SShunli Wang 	case AFE_AWB2_CUR_MSB:
862a94aec03SShunli Wang 	case AFE_ADDA_DL_SDM_FIFO_MON:
863a94aec03SShunli Wang 	case AFE_ADDA_DL_SRC_LCH_MON:
864a94aec03SShunli Wang 	case AFE_ADDA_DL_SRC_RCH_MON:
865a94aec03SShunli Wang 	case AFE_ADDA_DL_SDM_OUT_MON:
866a94aec03SShunli Wang 	case AFE_CONNSYS_I2S_MON:
867a94aec03SShunli Wang 	case AFE_ASRC_2CH_CON0:
868a94aec03SShunli Wang 	case AFE_ASRC_2CH_CON2:
869a94aec03SShunli Wang 	case AFE_ASRC_2CH_CON3:
870a94aec03SShunli Wang 	case AFE_ASRC_2CH_CON4:
871a94aec03SShunli Wang 	case AFE_ASRC_2CH_CON5:
872a94aec03SShunli Wang 	case AFE_ASRC_2CH_CON7:
873a94aec03SShunli Wang 	case AFE_ASRC_2CH_CON8:
874a94aec03SShunli Wang 	case AFE_MEMIF_MON12:
875a94aec03SShunli Wang 	case AFE_MEMIF_MON13:
876a94aec03SShunli Wang 	case AFE_MEMIF_MON14:
877a94aec03SShunli Wang 	case AFE_MEMIF_MON15:
878a94aec03SShunli Wang 	case AFE_MEMIF_MON16:
879a94aec03SShunli Wang 	case AFE_MEMIF_MON17:
880a94aec03SShunli Wang 	case AFE_MEMIF_MON18:
881a94aec03SShunli Wang 	case AFE_MEMIF_MON19:
882a94aec03SShunli Wang 	case AFE_MEMIF_MON20:
883a94aec03SShunli Wang 	case AFE_MEMIF_MON21:
884a94aec03SShunli Wang 	case AFE_MEMIF_MON22:
885a94aec03SShunli Wang 	case AFE_MEMIF_MON23:
886a94aec03SShunli Wang 	case AFE_MEMIF_MON24:
887a94aec03SShunli Wang 	case AFE_ADDA_MTKAIF_MON0:
888a94aec03SShunli Wang 	case AFE_ADDA_MTKAIF_MON1:
889a94aec03SShunli Wang 	case AFE_AUD_PAD_TOP:
890a94aec03SShunli Wang 	case AFE_GENERAL1_ASRC_2CH_CON0:
891a94aec03SShunli Wang 	case AFE_GENERAL1_ASRC_2CH_CON2:
892a94aec03SShunli Wang 	case AFE_GENERAL1_ASRC_2CH_CON3:
893a94aec03SShunli Wang 	case AFE_GENERAL1_ASRC_2CH_CON4:
894a94aec03SShunli Wang 	case AFE_GENERAL1_ASRC_2CH_CON5:
895a94aec03SShunli Wang 	case AFE_GENERAL1_ASRC_2CH_CON7:
896a94aec03SShunli Wang 	case AFE_GENERAL1_ASRC_2CH_CON8:
897a94aec03SShunli Wang 	case AFE_GENERAL1_ASRC_2CH_CON12:
898a94aec03SShunli Wang 	case AFE_GENERAL1_ASRC_2CH_CON13:
899a94aec03SShunli Wang 	case AFE_GENERAL2_ASRC_2CH_CON0:
900a94aec03SShunli Wang 	case AFE_GENERAL2_ASRC_2CH_CON2:
901a94aec03SShunli Wang 	case AFE_GENERAL2_ASRC_2CH_CON3:
902a94aec03SShunli Wang 	case AFE_GENERAL2_ASRC_2CH_CON4:
903a94aec03SShunli Wang 	case AFE_GENERAL2_ASRC_2CH_CON5:
904a94aec03SShunli Wang 	case AFE_GENERAL2_ASRC_2CH_CON7:
905a94aec03SShunli Wang 	case AFE_GENERAL2_ASRC_2CH_CON8:
906a94aec03SShunli Wang 	case AFE_GENERAL2_ASRC_2CH_CON12:
907a94aec03SShunli Wang 	case AFE_GENERAL2_ASRC_2CH_CON13:
908a94aec03SShunli Wang 		return true;
909a94aec03SShunli Wang 	default:
910a94aec03SShunli Wang 		return false;
911a94aec03SShunli Wang 	};
912a94aec03SShunli Wang }
913a94aec03SShunli Wang 
914a94aec03SShunli Wang static const struct regmap_config mt8183_afe_regmap_config = {
915a94aec03SShunli Wang 	.reg_bits = 32,
916a94aec03SShunli Wang 	.reg_stride = 4,
917a94aec03SShunli Wang 	.val_bits = 32,
918a94aec03SShunli Wang 
919a94aec03SShunli Wang 	.volatile_reg = mt8183_is_volatile_reg,
920a94aec03SShunli Wang 
921a94aec03SShunli Wang 	.max_register = AFE_MAX_REGISTER,
922a94aec03SShunli Wang 	.num_reg_defaults_raw = AFE_MAX_REGISTER,
923a94aec03SShunli Wang 
924a94aec03SShunli Wang 	.cache_type = REGCACHE_FLAT,
925a94aec03SShunli Wang };
926a94aec03SShunli Wang 
mt8183_afe_irq_handler(int irq_id,void * dev)927a94aec03SShunli Wang static irqreturn_t mt8183_afe_irq_handler(int irq_id, void *dev)
928a94aec03SShunli Wang {
929a94aec03SShunli Wang 	struct mtk_base_afe *afe = dev;
930a94aec03SShunli Wang 	struct mtk_base_afe_irq *irq;
931a94aec03SShunli Wang 	unsigned int status;
932a94aec03SShunli Wang 	unsigned int status_mcu;
933a94aec03SShunli Wang 	unsigned int mcu_en;
934a94aec03SShunli Wang 	int ret;
935a94aec03SShunli Wang 	int i;
936a94aec03SShunli Wang 	irqreturn_t irq_ret = IRQ_HANDLED;
937a94aec03SShunli Wang 
938a94aec03SShunli Wang 	/* get irq that is sent to MCU */
939a94aec03SShunli Wang 	regmap_read(afe->regmap, AFE_IRQ_MCU_EN, &mcu_en);
940a94aec03SShunli Wang 
941a94aec03SShunli Wang 	ret = regmap_read(afe->regmap, AFE_IRQ_MCU_STATUS, &status);
942a94aec03SShunli Wang 	/* only care IRQ which is sent to MCU */
943a94aec03SShunli Wang 	status_mcu = status & mcu_en & AFE_IRQ_STATUS_BITS;
944a94aec03SShunli Wang 
945a94aec03SShunli Wang 	if (ret || status_mcu == 0) {
946a94aec03SShunli Wang 		dev_err(afe->dev, "%s(), irq status err, ret %d, status 0x%x, mcu_en 0x%x\n",
947a94aec03SShunli Wang 			__func__, ret, status, mcu_en);
948a94aec03SShunli Wang 
949a94aec03SShunli Wang 		irq_ret = IRQ_NONE;
950a94aec03SShunli Wang 		goto err_irq;
951a94aec03SShunli Wang 	}
952a94aec03SShunli Wang 
953a94aec03SShunli Wang 	for (i = 0; i < MT8183_MEMIF_NUM; i++) {
954a94aec03SShunli Wang 		struct mtk_base_afe_memif *memif = &afe->memif[i];
955a94aec03SShunli Wang 
956a94aec03SShunli Wang 		if (!memif->substream)
957a94aec03SShunli Wang 			continue;
958a94aec03SShunli Wang 
959a94aec03SShunli Wang 		if (memif->irq_usage < 0)
960a94aec03SShunli Wang 			continue;
961a94aec03SShunli Wang 
962a94aec03SShunli Wang 		irq = &afe->irqs[memif->irq_usage];
963a94aec03SShunli Wang 
964a94aec03SShunli Wang 		if (status_mcu & (1 << irq->irq_data->irq_en_shift))
965a94aec03SShunli Wang 			snd_pcm_period_elapsed(memif->substream);
966a94aec03SShunli Wang 	}
967a94aec03SShunli Wang 
968a94aec03SShunli Wang err_irq:
969a94aec03SShunli Wang 	/* clear irq */
970a94aec03SShunli Wang 	regmap_write(afe->regmap,
971a94aec03SShunli Wang 		     AFE_IRQ_MCU_CLR,
972a94aec03SShunli Wang 		     status_mcu);
973a94aec03SShunli Wang 
974a94aec03SShunli Wang 	return irq_ret;
975a94aec03SShunli Wang }
976a94aec03SShunli Wang 
mt8183_afe_runtime_suspend(struct device * dev)977a94aec03SShunli Wang static int mt8183_afe_runtime_suspend(struct device *dev)
978a94aec03SShunli Wang {
979a94aec03SShunli Wang 	struct mtk_base_afe *afe = dev_get_drvdata(dev);
980a94aec03SShunli Wang 	struct mt8183_afe_private *afe_priv = afe->platform_priv;
981a94aec03SShunli Wang 	unsigned int value;
982a94aec03SShunli Wang 	int ret;
983a94aec03SShunli Wang 
984a94aec03SShunli Wang 	if (!afe->regmap || afe_priv->pm_runtime_bypass_reg_ctl)
985a94aec03SShunli Wang 		goto skip_regmap;
986a94aec03SShunli Wang 
987a94aec03SShunli Wang 	/* disable AFE */
988a94aec03SShunli Wang 	regmap_update_bits(afe->regmap, AFE_DAC_CON0, AFE_ON_MASK_SFT, 0x0);
989a94aec03SShunli Wang 
990a94aec03SShunli Wang 	ret = regmap_read_poll_timeout(afe->regmap,
991a94aec03SShunli Wang 				       AFE_DAC_MON,
992a94aec03SShunli Wang 				       value,
993a94aec03SShunli Wang 				       (value & AFE_ON_RETM_MASK_SFT) == 0,
994a94aec03SShunli Wang 				       20,
995a94aec03SShunli Wang 				       1 * 1000 * 1000);
996a94aec03SShunli Wang 	if (ret)
997a94aec03SShunli Wang 		dev_warn(afe->dev, "%s(), ret %d\n", __func__, ret);
998a94aec03SShunli Wang 
999a94aec03SShunli Wang 	/* make sure all irq status are cleared, twice intended */
1000a94aec03SShunli Wang 	regmap_update_bits(afe->regmap, AFE_IRQ_MCU_CLR, 0xffff, 0xffff);
1001a94aec03SShunli Wang 	regmap_update_bits(afe->regmap, AFE_IRQ_MCU_CLR, 0xffff, 0xffff);
1002a94aec03SShunli Wang 
1003a94aec03SShunli Wang 	/* cache only */
1004a94aec03SShunli Wang 	regcache_cache_only(afe->regmap, true);
1005a94aec03SShunli Wang 	regcache_mark_dirty(afe->regmap);
1006a94aec03SShunli Wang 
1007a94aec03SShunli Wang skip_regmap:
1008a94aec03SShunli Wang 	return mt8183_afe_disable_clock(afe);
1009a94aec03SShunli Wang }
1010a94aec03SShunli Wang 
mt8183_afe_runtime_resume(struct device * dev)1011a94aec03SShunli Wang static int mt8183_afe_runtime_resume(struct device *dev)
1012a94aec03SShunli Wang {
1013a94aec03SShunli Wang 	struct mtk_base_afe *afe = dev_get_drvdata(dev);
1014a94aec03SShunli Wang 	struct mt8183_afe_private *afe_priv = afe->platform_priv;
1015a94aec03SShunli Wang 	int ret;
1016a94aec03SShunli Wang 
1017a94aec03SShunli Wang 	ret = mt8183_afe_enable_clock(afe);
1018a94aec03SShunli Wang 	if (ret)
1019a94aec03SShunli Wang 		return ret;
1020a94aec03SShunli Wang 
1021a94aec03SShunli Wang 	if (!afe->regmap || afe_priv->pm_runtime_bypass_reg_ctl)
1022a94aec03SShunli Wang 		goto skip_regmap;
1023a94aec03SShunli Wang 
1024a94aec03SShunli Wang 	regcache_cache_only(afe->regmap, false);
1025a94aec03SShunli Wang 	regcache_sync(afe->regmap);
1026a94aec03SShunli Wang 
1027a94aec03SShunli Wang 	/* enable audio sys DCM for power saving */
1028a94aec03SShunli Wang 	regmap_update_bits(afe->regmap, AUDIO_TOP_CON0, 0x1 << 29, 0x1 << 29);
1029a94aec03SShunli Wang 
1030a94aec03SShunli Wang 	/* force cpu use 8_24 format when writing 32bit data */
1031a94aec03SShunli Wang 	regmap_update_bits(afe->regmap, AFE_MEMIF_MSB,
1032a94aec03SShunli Wang 			   CPU_HD_ALIGN_MASK_SFT, 0 << CPU_HD_ALIGN_SFT);
1033a94aec03SShunli Wang 
1034a94aec03SShunli Wang 	/* set all output port to 24bit */
1035a94aec03SShunli Wang 	regmap_write(afe->regmap, AFE_CONN_24BIT, 0xffffffff);
1036a94aec03SShunli Wang 	regmap_write(afe->regmap, AFE_CONN_24BIT_1, 0xffffffff);
1037a94aec03SShunli Wang 
1038a94aec03SShunli Wang 	/* enable AFE */
1039a94aec03SShunli Wang 	regmap_update_bits(afe->regmap, AFE_DAC_CON0, 0x1, 0x1);
1040a94aec03SShunli Wang 
1041a94aec03SShunli Wang skip_regmap:
1042a94aec03SShunli Wang 	return 0;
1043a94aec03SShunli Wang }
1044a94aec03SShunli Wang 
mt8183_dai_memif_register(struct mtk_base_afe * afe)1045a94aec03SShunli Wang static int mt8183_dai_memif_register(struct mtk_base_afe *afe)
1046a94aec03SShunli Wang {
1047a94aec03SShunli Wang 	struct mtk_base_afe_dai *dai;
1048a94aec03SShunli Wang 
1049a94aec03SShunli Wang 	dai = devm_kzalloc(afe->dev, sizeof(*dai), GFP_KERNEL);
1050a94aec03SShunli Wang 	if (!dai)
1051a94aec03SShunli Wang 		return -ENOMEM;
1052a94aec03SShunli Wang 
1053a94aec03SShunli Wang 	list_add(&dai->list, &afe->sub_dais);
1054a94aec03SShunli Wang 
1055a94aec03SShunli Wang 	dai->dai_drivers = mt8183_memif_dai_driver;
1056a94aec03SShunli Wang 	dai->num_dai_drivers = ARRAY_SIZE(mt8183_memif_dai_driver);
1057a94aec03SShunli Wang 
1058a94aec03SShunli Wang 	dai->dapm_widgets = mt8183_memif_widgets;
1059a94aec03SShunli Wang 	dai->num_dapm_widgets = ARRAY_SIZE(mt8183_memif_widgets);
1060a94aec03SShunli Wang 	dai->dapm_routes = mt8183_memif_routes;
1061a94aec03SShunli Wang 	dai->num_dapm_routes = ARRAY_SIZE(mt8183_memif_routes);
1062a94aec03SShunli Wang 	return 0;
1063a94aec03SShunli Wang }
1064a94aec03SShunli Wang 
1065a94aec03SShunli Wang typedef int (*dai_register_cb)(struct mtk_base_afe *);
1066a94aec03SShunli Wang static const dai_register_cb dai_register_cbs[] = {
1067a94aec03SShunli Wang 	mt8183_dai_adda_register,
1068a94aec03SShunli Wang 	mt8183_dai_i2s_register,
1069a94aec03SShunli Wang 	mt8183_dai_pcm_register,
1070a94aec03SShunli Wang 	mt8183_dai_tdm_register,
1071a94aec03SShunli Wang 	mt8183_dai_hostless_register,
1072a94aec03SShunli Wang 	mt8183_dai_memif_register,
1073a94aec03SShunli Wang };
1074a94aec03SShunli Wang 
mt8183_afe_pcm_dev_probe(struct platform_device * pdev)1075a94aec03SShunli Wang static int mt8183_afe_pcm_dev_probe(struct platform_device *pdev)
1076a94aec03SShunli Wang {
1077a94aec03SShunli Wang 	struct mtk_base_afe *afe;
1078a94aec03SShunli Wang 	struct mt8183_afe_private *afe_priv;
1079a94aec03SShunli Wang 	struct device *dev;
10809e985503SJiaxin Yu 	struct reset_control *rstc;
1081a94aec03SShunli Wang 	int i, irq_id, ret;
1082a94aec03SShunli Wang 
1083a94aec03SShunli Wang 	afe = devm_kzalloc(&pdev->dev, sizeof(*afe), GFP_KERNEL);
1084a94aec03SShunli Wang 	if (!afe)
1085a94aec03SShunli Wang 		return -ENOMEM;
1086a94aec03SShunli Wang 	platform_set_drvdata(pdev, afe);
1087a94aec03SShunli Wang 
1088a94aec03SShunli Wang 	afe->platform_priv = devm_kzalloc(&pdev->dev, sizeof(*afe_priv),
1089a94aec03SShunli Wang 					  GFP_KERNEL);
1090a94aec03SShunli Wang 	if (!afe->platform_priv)
1091a94aec03SShunli Wang 		return -ENOMEM;
1092a94aec03SShunli Wang 
1093a94aec03SShunli Wang 	afe_priv = afe->platform_priv;
1094a94aec03SShunli Wang 	afe->dev = &pdev->dev;
1095a94aec03SShunli Wang 	dev = afe->dev;
1096a94aec03SShunli Wang 
1097a94aec03SShunli Wang 	/* initial audio related clock */
1098a94aec03SShunli Wang 	ret = mt8183_init_clock(afe);
1099a94aec03SShunli Wang 	if (ret) {
1100a94aec03SShunli Wang 		dev_err(dev, "init clock error\n");
1101a94aec03SShunli Wang 		return ret;
1102a94aec03SShunli Wang 	}
1103a94aec03SShunli Wang 
1104a94aec03SShunli Wang 	pm_runtime_enable(dev);
1105a94aec03SShunli Wang 
1106a94aec03SShunli Wang 	/* regmap init */
1107a94aec03SShunli Wang 	afe->regmap = syscon_node_to_regmap(dev->parent->of_node);
1108a94aec03SShunli Wang 	if (IS_ERR(afe->regmap)) {
1109a94aec03SShunli Wang 		dev_err(dev, "could not get regmap from parent\n");
111019f479c3SZhang Qilong 		ret = PTR_ERR(afe->regmap);
111119f479c3SZhang Qilong 		goto err_pm_disable;
1112a94aec03SShunli Wang 	}
1113a94aec03SShunli Wang 	ret = regmap_attach_dev(dev, afe->regmap, &mt8183_afe_regmap_config);
1114a94aec03SShunli Wang 	if (ret) {
1115a94aec03SShunli Wang 		dev_warn(dev, "regmap_attach_dev fail, ret %d\n", ret);
111619f479c3SZhang Qilong 		goto err_pm_disable;
1117a94aec03SShunli Wang 	}
1118a94aec03SShunli Wang 
11199e985503SJiaxin Yu 	rstc = devm_reset_control_get(dev, "audiosys");
11209e985503SJiaxin Yu 	if (IS_ERR(rstc)) {
11219e985503SJiaxin Yu 		ret = PTR_ERR(rstc);
11229e985503SJiaxin Yu 		dev_err(dev, "could not get audiosys reset:%d\n", ret);
112319f479c3SZhang Qilong 		goto err_pm_disable;
11249e985503SJiaxin Yu 	}
11259e985503SJiaxin Yu 
11269e985503SJiaxin Yu 	ret = reset_control_reset(rstc);
11279e985503SJiaxin Yu 	if (ret) {
11289e985503SJiaxin Yu 		dev_err(dev, "failed to trigger audio reset:%d\n", ret);
112919f479c3SZhang Qilong 		goto err_pm_disable;
11309e985503SJiaxin Yu 	}
11319e985503SJiaxin Yu 
1132a94aec03SShunli Wang 	/* enable clock for regcache get default value from hw */
1133a94aec03SShunli Wang 	afe_priv->pm_runtime_bypass_reg_ctl = true;
1134a94aec03SShunli Wang 	pm_runtime_get_sync(&pdev->dev);
1135a94aec03SShunli Wang 
1136a94aec03SShunli Wang 	ret = regmap_reinit_cache(afe->regmap, &mt8183_afe_regmap_config);
1137a94aec03SShunli Wang 	if (ret) {
1138a94aec03SShunli Wang 		dev_err(dev, "regmap_reinit_cache fail, ret %d\n", ret);
113919f479c3SZhang Qilong 		goto err_pm_disable;
1140a94aec03SShunli Wang 	}
1141a94aec03SShunli Wang 
1142a94aec03SShunli Wang 	pm_runtime_put_sync(&pdev->dev);
1143a94aec03SShunli Wang 	afe_priv->pm_runtime_bypass_reg_ctl = false;
1144a94aec03SShunli Wang 
1145a94aec03SShunli Wang 	regcache_cache_only(afe->regmap, true);
1146a94aec03SShunli Wang 	regcache_mark_dirty(afe->regmap);
1147a94aec03SShunli Wang 
1148a94aec03SShunli Wang 	/* init memif */
1149a94aec03SShunli Wang 	afe->memif_size = MT8183_MEMIF_NUM;
1150a94aec03SShunli Wang 	afe->memif = devm_kcalloc(dev, afe->memif_size, sizeof(*afe->memif),
1151a94aec03SShunli Wang 				  GFP_KERNEL);
115219f479c3SZhang Qilong 	if (!afe->memif) {
115319f479c3SZhang Qilong 		ret = -ENOMEM;
115419f479c3SZhang Qilong 		goto err_pm_disable;
115519f479c3SZhang Qilong 	}
1156a94aec03SShunli Wang 
1157a94aec03SShunli Wang 	for (i = 0; i < afe->memif_size; i++) {
1158a94aec03SShunli Wang 		afe->memif[i].data = &memif_data[i];
1159a94aec03SShunli Wang 		afe->memif[i].irq_usage = -1;
1160a94aec03SShunli Wang 	}
1161a94aec03SShunli Wang 
1162a94aec03SShunli Wang 	afe->memif[MT8183_MEMIF_HDMI].irq_usage = MT8183_IRQ_8;
1163a94aec03SShunli Wang 	afe->memif[MT8183_MEMIF_HDMI].const_irq = 1;
1164a94aec03SShunli Wang 
1165a94aec03SShunli Wang 	mutex_init(&afe->irq_alloc_lock);
1166a94aec03SShunli Wang 
1167a94aec03SShunli Wang 	/* init memif */
1168a94aec03SShunli Wang 	/* irq initialize */
1169a94aec03SShunli Wang 	afe->irqs_size = MT8183_IRQ_NUM;
1170a94aec03SShunli Wang 	afe->irqs = devm_kcalloc(dev, afe->irqs_size, sizeof(*afe->irqs),
1171a94aec03SShunli Wang 				 GFP_KERNEL);
117219f479c3SZhang Qilong 	if (!afe->irqs) {
117319f479c3SZhang Qilong 		ret = -ENOMEM;
117419f479c3SZhang Qilong 		goto err_pm_disable;
117519f479c3SZhang Qilong 	}
1176a94aec03SShunli Wang 
1177a94aec03SShunli Wang 	for (i = 0; i < afe->irqs_size; i++)
1178a94aec03SShunli Wang 		afe->irqs[i].irq_data = &irq_data[i];
1179a94aec03SShunli Wang 
1180a94aec03SShunli Wang 	/* request irq */
1181a94aec03SShunli Wang 	irq_id = platform_get_irq(pdev, 0);
118219f479c3SZhang Qilong 	if (irq_id < 0) {
118319f479c3SZhang Qilong 		ret = irq_id;
118419f479c3SZhang Qilong 		goto err_pm_disable;
118519f479c3SZhang Qilong 	}
1186fe944625STzung-Bi Shih 
1187a94aec03SShunli Wang 	ret = devm_request_irq(dev, irq_id, mt8183_afe_irq_handler,
1188a94aec03SShunli Wang 			       IRQF_TRIGGER_NONE, "asys-isr", (void *)afe);
1189a94aec03SShunli Wang 	if (ret) {
1190a94aec03SShunli Wang 		dev_err(dev, "could not request_irq for asys-isr\n");
119119f479c3SZhang Qilong 		goto err_pm_disable;
1192a94aec03SShunli Wang 	}
1193a94aec03SShunli Wang 
1194a94aec03SShunli Wang 	/* init sub_dais */
1195a94aec03SShunli Wang 	INIT_LIST_HEAD(&afe->sub_dais);
1196a94aec03SShunli Wang 
1197a94aec03SShunli Wang 	for (i = 0; i < ARRAY_SIZE(dai_register_cbs); i++) {
1198a94aec03SShunli Wang 		ret = dai_register_cbs[i](afe);
1199a94aec03SShunli Wang 		if (ret) {
1200a94aec03SShunli Wang 			dev_warn(afe->dev, "dai register i %d fail, ret %d\n",
1201a94aec03SShunli Wang 				 i, ret);
120219f479c3SZhang Qilong 			goto err_pm_disable;
1203a94aec03SShunli Wang 		}
1204a94aec03SShunli Wang 	}
1205a94aec03SShunli Wang 
1206a94aec03SShunli Wang 	/* init dai_driver and component_driver */
1207a94aec03SShunli Wang 	ret = mtk_afe_combine_sub_dai(afe);
1208a94aec03SShunli Wang 	if (ret) {
1209a94aec03SShunli Wang 		dev_warn(afe->dev, "mtk_afe_combine_sub_dai fail, ret %d\n",
1210a94aec03SShunli Wang 			 ret);
121119f479c3SZhang Qilong 		goto err_pm_disable;
1212a94aec03SShunli Wang 	}
1213a94aec03SShunli Wang 
1214a94aec03SShunli Wang 	afe->mtk_afe_hardware = &mt8183_afe_hardware;
1215a94aec03SShunli Wang 	afe->memif_fs = mt8183_memif_fs;
1216a94aec03SShunli Wang 	afe->irq_fs = mt8183_irq_fs;
1217a94aec03SShunli Wang 
1218a94aec03SShunli Wang 	afe->runtime_resume = mt8183_afe_runtime_resume;
1219a94aec03SShunli Wang 	afe->runtime_suspend = mt8183_afe_runtime_suspend;
1220a94aec03SShunli Wang 
1221a94aec03SShunli Wang 	/* register component */
1222a94aec03SShunli Wang 	ret = devm_snd_soc_register_component(&pdev->dev,
12231d2a6b3bSAngeloGioacchino Del Regno 					      &mtk_afe_pcm_platform,
1224a94aec03SShunli Wang 					      NULL, 0);
1225a94aec03SShunli Wang 	if (ret) {
1226a94aec03SShunli Wang 		dev_warn(dev, "err_platform\n");
122719f479c3SZhang Qilong 		goto err_pm_disable;
1228a94aec03SShunli Wang 	}
1229a94aec03SShunli Wang 
1230a94aec03SShunli Wang 	ret = devm_snd_soc_register_component(afe->dev,
1231a94aec03SShunli Wang 					      &mt8183_afe_pcm_dai_component,
1232a94aec03SShunli Wang 					      afe->dai_drivers,
1233a94aec03SShunli Wang 					      afe->num_dai_drivers);
1234a94aec03SShunli Wang 	if (ret) {
1235a94aec03SShunli Wang 		dev_warn(dev, "err_dai_component\n");
123619f479c3SZhang Qilong 		goto err_pm_disable;
1237a94aec03SShunli Wang 	}
1238a94aec03SShunli Wang 
1239a94aec03SShunli Wang 	return ret;
124019f479c3SZhang Qilong 
124119f479c3SZhang Qilong err_pm_disable:
124219f479c3SZhang Qilong 	pm_runtime_disable(&pdev->dev);
124319f479c3SZhang Qilong 	return ret;
1244a94aec03SShunli Wang }
1245a94aec03SShunli Wang 
mt8183_afe_pcm_dev_remove(struct platform_device * pdev)1246718041d4SUwe Kleine-König static void mt8183_afe_pcm_dev_remove(struct platform_device *pdev)
1247a94aec03SShunli Wang {
1248a94aec03SShunli Wang 	pm_runtime_disable(&pdev->dev);
1249a94aec03SShunli Wang 	if (!pm_runtime_status_suspended(&pdev->dev))
1250a94aec03SShunli Wang 		mt8183_afe_runtime_suspend(&pdev->dev);
1251a94aec03SShunli Wang }
1252a94aec03SShunli Wang 
1253a94aec03SShunli Wang static const struct of_device_id mt8183_afe_pcm_dt_match[] = {
1254a94aec03SShunli Wang 	{ .compatible = "mediatek,mt8183-audio", },
1255a94aec03SShunli Wang 	{},
1256a94aec03SShunli Wang };
1257a94aec03SShunli Wang MODULE_DEVICE_TABLE(of, mt8183_afe_pcm_dt_match);
1258a94aec03SShunli Wang 
1259a94aec03SShunli Wang static const struct dev_pm_ops mt8183_afe_pm_ops = {
1260a94aec03SShunli Wang 	SET_RUNTIME_PM_OPS(mt8183_afe_runtime_suspend,
1261a94aec03SShunli Wang 			   mt8183_afe_runtime_resume, NULL)
1262a94aec03SShunli Wang };
1263a94aec03SShunli Wang 
1264a94aec03SShunli Wang static struct platform_driver mt8183_afe_pcm_driver = {
1265a94aec03SShunli Wang 	.driver = {
1266a94aec03SShunli Wang 		   .name = "mt8183-audio",
1267a94aec03SShunli Wang 		   .of_match_table = mt8183_afe_pcm_dt_match,
1268a94aec03SShunli Wang 		   .pm = &mt8183_afe_pm_ops,
1269a94aec03SShunli Wang 	},
1270a94aec03SShunli Wang 	.probe = mt8183_afe_pcm_dev_probe,
1271*130af75bSUwe Kleine-König 	.remove = mt8183_afe_pcm_dev_remove,
1272a94aec03SShunli Wang };
1273a94aec03SShunli Wang 
1274a94aec03SShunli Wang module_platform_driver(mt8183_afe_pcm_driver);
1275a94aec03SShunli Wang 
1276a94aec03SShunli Wang MODULE_DESCRIPTION("Mediatek ALSA SoC AFE platform driver for 8183");
1277a94aec03SShunli Wang MODULE_AUTHOR("KaiChieh Chuang <kaichieh.chuang@mediatek.com>");
1278a94aec03SShunli Wang MODULE_LICENSE("GPL v2");
1279