18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0
28c2ecf20Sopenharmony_ci//
38c2ecf20Sopenharmony_ci// MediaTek ALSA SoC Audio DAI I2S Control
48c2ecf20Sopenharmony_ci//
58c2ecf20Sopenharmony_ci// Copyright (c) 2018 MediaTek Inc.
68c2ecf20Sopenharmony_ci// Author: KaiChieh Chuang <kaichieh.chuang@mediatek.com>
78c2ecf20Sopenharmony_ci
88c2ecf20Sopenharmony_ci#include <linux/regmap.h>
98c2ecf20Sopenharmony_ci#include <sound/pcm_params.h>
108c2ecf20Sopenharmony_ci#include "mt8183-afe-common.h"
118c2ecf20Sopenharmony_ci#include "mt8183-interconnection.h"
128c2ecf20Sopenharmony_ci#include "mt8183-reg.h"
138c2ecf20Sopenharmony_ci
148c2ecf20Sopenharmony_cienum AUD_TX_LCH_RPT {
158c2ecf20Sopenharmony_ci	AUD_TX_LCH_RPT_NO_REPEAT = 0,
168c2ecf20Sopenharmony_ci	AUD_TX_LCH_RPT_REPEAT = 1
178c2ecf20Sopenharmony_ci};
188c2ecf20Sopenharmony_ci
198c2ecf20Sopenharmony_cienum AUD_VBT_16K_MODE {
208c2ecf20Sopenharmony_ci	AUD_VBT_16K_MODE_DISABLE = 0,
218c2ecf20Sopenharmony_ci	AUD_VBT_16K_MODE_ENABLE = 1
228c2ecf20Sopenharmony_ci};
238c2ecf20Sopenharmony_ci
248c2ecf20Sopenharmony_cienum AUD_EXT_MODEM {
258c2ecf20Sopenharmony_ci	AUD_EXT_MODEM_SELECT_INTERNAL = 0,
268c2ecf20Sopenharmony_ci	AUD_EXT_MODEM_SELECT_EXTERNAL = 1
278c2ecf20Sopenharmony_ci};
288c2ecf20Sopenharmony_ci
298c2ecf20Sopenharmony_cienum AUD_PCM_SYNC_TYPE {
308c2ecf20Sopenharmony_ci	/* bck sync length = 1 */
318c2ecf20Sopenharmony_ci	AUD_PCM_ONE_BCK_CYCLE_SYNC = 0,
328c2ecf20Sopenharmony_ci	/* bck sync length = PCM_INTF_CON1[9:13] */
338c2ecf20Sopenharmony_ci	AUD_PCM_EXTENDED_BCK_CYCLE_SYNC = 1
348c2ecf20Sopenharmony_ci};
358c2ecf20Sopenharmony_ci
368c2ecf20Sopenharmony_cienum AUD_BT_MODE {
378c2ecf20Sopenharmony_ci	AUD_BT_MODE_DUAL_MIC_ON_TX = 0,
388c2ecf20Sopenharmony_ci	AUD_BT_MODE_SINGLE_MIC_ON_TX = 1
398c2ecf20Sopenharmony_ci};
408c2ecf20Sopenharmony_ci
418c2ecf20Sopenharmony_cienum AUD_PCM_AFIFO_SRC {
428c2ecf20Sopenharmony_ci	/* slave mode & external modem uses different crystal */
438c2ecf20Sopenharmony_ci	AUD_PCM_AFIFO_ASRC = 0,
448c2ecf20Sopenharmony_ci	/* slave mode & external modem uses the same crystal */
458c2ecf20Sopenharmony_ci	AUD_PCM_AFIFO_AFIFO = 1
468c2ecf20Sopenharmony_ci};
478c2ecf20Sopenharmony_ci
488c2ecf20Sopenharmony_cienum AUD_PCM_CLOCK_SOURCE {
498c2ecf20Sopenharmony_ci	AUD_PCM_CLOCK_MASTER_MODE = 0,
508c2ecf20Sopenharmony_ci	AUD_PCM_CLOCK_SLAVE_MODE = 1
518c2ecf20Sopenharmony_ci};
528c2ecf20Sopenharmony_ci
538c2ecf20Sopenharmony_cienum AUD_PCM_WLEN {
548c2ecf20Sopenharmony_ci	AUD_PCM_WLEN_PCM_32_BCK_CYCLES = 0,
558c2ecf20Sopenharmony_ci	AUD_PCM_WLEN_PCM_64_BCK_CYCLES = 1
568c2ecf20Sopenharmony_ci};
578c2ecf20Sopenharmony_ci
588c2ecf20Sopenharmony_cienum AUD_PCM_MODE {
598c2ecf20Sopenharmony_ci	AUD_PCM_MODE_PCM_MODE_8K = 0,
608c2ecf20Sopenharmony_ci	AUD_PCM_MODE_PCM_MODE_16K = 1,
618c2ecf20Sopenharmony_ci	AUD_PCM_MODE_PCM_MODE_32K = 2,
628c2ecf20Sopenharmony_ci	AUD_PCM_MODE_PCM_MODE_48K = 3,
638c2ecf20Sopenharmony_ci};
648c2ecf20Sopenharmony_ci
658c2ecf20Sopenharmony_cienum AUD_PCM_FMT {
668c2ecf20Sopenharmony_ci	AUD_PCM_FMT_I2S = 0,
678c2ecf20Sopenharmony_ci	AUD_PCM_FMT_EIAJ = 1,
688c2ecf20Sopenharmony_ci	AUD_PCM_FMT_PCM_MODE_A = 2,
698c2ecf20Sopenharmony_ci	AUD_PCM_FMT_PCM_MODE_B = 3
708c2ecf20Sopenharmony_ci};
718c2ecf20Sopenharmony_ci
728c2ecf20Sopenharmony_cienum AUD_BCLK_OUT_INV {
738c2ecf20Sopenharmony_ci	AUD_BCLK_OUT_INV_NO_INVERSE = 0,
748c2ecf20Sopenharmony_ci	AUD_BCLK_OUT_INV_INVERSE = 1
758c2ecf20Sopenharmony_ci};
768c2ecf20Sopenharmony_ci
778c2ecf20Sopenharmony_cienum AUD_PCM_EN {
788c2ecf20Sopenharmony_ci	AUD_PCM_EN_DISABLE = 0,
798c2ecf20Sopenharmony_ci	AUD_PCM_EN_ENABLE = 1
808c2ecf20Sopenharmony_ci};
818c2ecf20Sopenharmony_ci
828c2ecf20Sopenharmony_ci/* dai component */
838c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new mtk_pcm_1_playback_ch1_mix[] = {
848c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE_AUTODISABLE("ADDA_UL_CH1", AFE_CONN7,
858c2ecf20Sopenharmony_ci				    I_ADDA_UL_CH1, 1, 0),
868c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE_AUTODISABLE("DL2_CH1", AFE_CONN7,
878c2ecf20Sopenharmony_ci				    I_DL2_CH1, 1, 0),
888c2ecf20Sopenharmony_ci};
898c2ecf20Sopenharmony_ci
908c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new mtk_pcm_1_playback_ch2_mix[] = {
918c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE_AUTODISABLE("ADDA_UL_CH2", AFE_CONN8,
928c2ecf20Sopenharmony_ci				    I_ADDA_UL_CH2, 1, 0),
938c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE_AUTODISABLE("DL2_CH2", AFE_CONN8,
948c2ecf20Sopenharmony_ci				    I_DL2_CH2, 1, 0),
958c2ecf20Sopenharmony_ci};
968c2ecf20Sopenharmony_ci
978c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new mtk_pcm_1_playback_ch4_mix[] = {
988c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE_AUTODISABLE("DL1_CH1", AFE_CONN27,
998c2ecf20Sopenharmony_ci				    I_DL1_CH1, 1, 0),
1008c2ecf20Sopenharmony_ci};
1018c2ecf20Sopenharmony_ci
1028c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new mtk_pcm_2_playback_ch1_mix[] = {
1038c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE_AUTODISABLE("ADDA_UL_CH1", AFE_CONN17,
1048c2ecf20Sopenharmony_ci				    I_ADDA_UL_CH1, 1, 0),
1058c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE_AUTODISABLE("DL2_CH1", AFE_CONN17,
1068c2ecf20Sopenharmony_ci				    I_DL2_CH1, 1, 0),
1078c2ecf20Sopenharmony_ci};
1088c2ecf20Sopenharmony_ci
1098c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new mtk_pcm_2_playback_ch2_mix[] = {
1108c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE_AUTODISABLE("ADDA_UL_CH2", AFE_CONN18,
1118c2ecf20Sopenharmony_ci				    I_ADDA_UL_CH2, 1, 0),
1128c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE_AUTODISABLE("DL2_CH2", AFE_CONN18,
1138c2ecf20Sopenharmony_ci				    I_DL2_CH2, 1, 0),
1148c2ecf20Sopenharmony_ci};
1158c2ecf20Sopenharmony_ci
1168c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new mtk_pcm_2_playback_ch4_mix[] = {
1178c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE_AUTODISABLE("DL1_CH1", AFE_CONN24,
1188c2ecf20Sopenharmony_ci				    I_DL1_CH1, 1, 0),
1198c2ecf20Sopenharmony_ci};
1208c2ecf20Sopenharmony_ci
1218c2ecf20Sopenharmony_cistatic const struct snd_soc_dapm_widget mtk_dai_pcm_widgets[] = {
1228c2ecf20Sopenharmony_ci	/* inter-connections */
1238c2ecf20Sopenharmony_ci	SND_SOC_DAPM_MIXER("PCM_1_PB_CH1", SND_SOC_NOPM, 0, 0,
1248c2ecf20Sopenharmony_ci			   mtk_pcm_1_playback_ch1_mix,
1258c2ecf20Sopenharmony_ci			   ARRAY_SIZE(mtk_pcm_1_playback_ch1_mix)),
1268c2ecf20Sopenharmony_ci	SND_SOC_DAPM_MIXER("PCM_1_PB_CH2", SND_SOC_NOPM, 0, 0,
1278c2ecf20Sopenharmony_ci			   mtk_pcm_1_playback_ch2_mix,
1288c2ecf20Sopenharmony_ci			   ARRAY_SIZE(mtk_pcm_1_playback_ch2_mix)),
1298c2ecf20Sopenharmony_ci	SND_SOC_DAPM_MIXER("PCM_1_PB_CH4", SND_SOC_NOPM, 0, 0,
1308c2ecf20Sopenharmony_ci			   mtk_pcm_1_playback_ch4_mix,
1318c2ecf20Sopenharmony_ci			   ARRAY_SIZE(mtk_pcm_1_playback_ch4_mix)),
1328c2ecf20Sopenharmony_ci	SND_SOC_DAPM_MIXER("PCM_2_PB_CH1", SND_SOC_NOPM, 0, 0,
1338c2ecf20Sopenharmony_ci			   mtk_pcm_2_playback_ch1_mix,
1348c2ecf20Sopenharmony_ci			   ARRAY_SIZE(mtk_pcm_2_playback_ch1_mix)),
1358c2ecf20Sopenharmony_ci	SND_SOC_DAPM_MIXER("PCM_2_PB_CH2", SND_SOC_NOPM, 0, 0,
1368c2ecf20Sopenharmony_ci			   mtk_pcm_2_playback_ch2_mix,
1378c2ecf20Sopenharmony_ci			   ARRAY_SIZE(mtk_pcm_2_playback_ch2_mix)),
1388c2ecf20Sopenharmony_ci	SND_SOC_DAPM_MIXER("PCM_2_PB_CH4", SND_SOC_NOPM, 0, 0,
1398c2ecf20Sopenharmony_ci			   mtk_pcm_2_playback_ch4_mix,
1408c2ecf20Sopenharmony_ci			   ARRAY_SIZE(mtk_pcm_2_playback_ch4_mix)),
1418c2ecf20Sopenharmony_ci
1428c2ecf20Sopenharmony_ci	SND_SOC_DAPM_SUPPLY("PCM_1_EN", PCM_INTF_CON1, PCM_EN_SFT, 0,
1438c2ecf20Sopenharmony_ci			    NULL, 0),
1448c2ecf20Sopenharmony_ci
1458c2ecf20Sopenharmony_ci	SND_SOC_DAPM_SUPPLY("PCM_2_EN", PCM2_INTF_CON, PCM2_EN_SFT, 0,
1468c2ecf20Sopenharmony_ci			    NULL, 0),
1478c2ecf20Sopenharmony_ci
1488c2ecf20Sopenharmony_ci	SND_SOC_DAPM_INPUT("MD1_TO_AFE"),
1498c2ecf20Sopenharmony_ci	SND_SOC_DAPM_INPUT("MD2_TO_AFE"),
1508c2ecf20Sopenharmony_ci	SND_SOC_DAPM_OUTPUT("AFE_TO_MD1"),
1518c2ecf20Sopenharmony_ci	SND_SOC_DAPM_OUTPUT("AFE_TO_MD2"),
1528c2ecf20Sopenharmony_ci};
1538c2ecf20Sopenharmony_ci
1548c2ecf20Sopenharmony_cistatic const struct snd_soc_dapm_route mtk_dai_pcm_routes[] = {
1558c2ecf20Sopenharmony_ci	{"PCM 1 Playback", NULL, "PCM_1_PB_CH1"},
1568c2ecf20Sopenharmony_ci	{"PCM 1 Playback", NULL, "PCM_1_PB_CH2"},
1578c2ecf20Sopenharmony_ci	{"PCM 1 Playback", NULL, "PCM_1_PB_CH4"},
1588c2ecf20Sopenharmony_ci	{"PCM 2 Playback", NULL, "PCM_2_PB_CH1"},
1598c2ecf20Sopenharmony_ci	{"PCM 2 Playback", NULL, "PCM_2_PB_CH2"},
1608c2ecf20Sopenharmony_ci	{"PCM 2 Playback", NULL, "PCM_2_PB_CH4"},
1618c2ecf20Sopenharmony_ci
1628c2ecf20Sopenharmony_ci	{"PCM 1 Playback", NULL, "PCM_1_EN"},
1638c2ecf20Sopenharmony_ci	{"PCM 2 Playback", NULL, "PCM_2_EN"},
1648c2ecf20Sopenharmony_ci	{"PCM 1 Capture", NULL, "PCM_1_EN"},
1658c2ecf20Sopenharmony_ci	{"PCM 2 Capture", NULL, "PCM_2_EN"},
1668c2ecf20Sopenharmony_ci
1678c2ecf20Sopenharmony_ci	{"AFE_TO_MD1", NULL, "PCM 2 Playback"},
1688c2ecf20Sopenharmony_ci	{"AFE_TO_MD2", NULL, "PCM 1 Playback"},
1698c2ecf20Sopenharmony_ci	{"PCM 2 Capture", NULL, "MD1_TO_AFE"},
1708c2ecf20Sopenharmony_ci	{"PCM 1 Capture", NULL, "MD2_TO_AFE"},
1718c2ecf20Sopenharmony_ci
1728c2ecf20Sopenharmony_ci	{"PCM_1_PB_CH1", "DL2_CH1", "DL2"},
1738c2ecf20Sopenharmony_ci	{"PCM_1_PB_CH2", "DL2_CH2", "DL2"},
1748c2ecf20Sopenharmony_ci	{"PCM_1_PB_CH4", "DL1_CH1", "DL1"},
1758c2ecf20Sopenharmony_ci	{"PCM_2_PB_CH1", "DL2_CH1", "DL2"},
1768c2ecf20Sopenharmony_ci	{"PCM_2_PB_CH2", "DL2_CH2", "DL2"},
1778c2ecf20Sopenharmony_ci	{"PCM_2_PB_CH4", "DL1_CH1", "DL1"},
1788c2ecf20Sopenharmony_ci};
1798c2ecf20Sopenharmony_ci
1808c2ecf20Sopenharmony_ci/* dai ops */
1818c2ecf20Sopenharmony_cistatic int mtk_dai_pcm_hw_params(struct snd_pcm_substream *substream,
1828c2ecf20Sopenharmony_ci				 struct snd_pcm_hw_params *params,
1838c2ecf20Sopenharmony_ci				 struct snd_soc_dai *dai)
1848c2ecf20Sopenharmony_ci{
1858c2ecf20Sopenharmony_ci	struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai);
1868c2ecf20Sopenharmony_ci	unsigned int rate = params_rate(params);
1878c2ecf20Sopenharmony_ci	unsigned int rate_reg = mt8183_rate_transform(afe->dev, rate, dai->id);
1888c2ecf20Sopenharmony_ci	unsigned int pcm_con = 0;
1898c2ecf20Sopenharmony_ci
1908c2ecf20Sopenharmony_ci	dev_dbg(afe->dev, "%s(), id %d, stream %d, rate %d, rate_reg %d, widget active p %d, c %d\n",
1918c2ecf20Sopenharmony_ci		__func__,
1928c2ecf20Sopenharmony_ci		dai->id,
1938c2ecf20Sopenharmony_ci		substream->stream,
1948c2ecf20Sopenharmony_ci		rate,
1958c2ecf20Sopenharmony_ci		rate_reg,
1968c2ecf20Sopenharmony_ci		dai->playback_widget->active,
1978c2ecf20Sopenharmony_ci		dai->capture_widget->active);
1988c2ecf20Sopenharmony_ci
1998c2ecf20Sopenharmony_ci	if (dai->playback_widget->active || dai->capture_widget->active)
2008c2ecf20Sopenharmony_ci		return 0;
2018c2ecf20Sopenharmony_ci
2028c2ecf20Sopenharmony_ci	switch (dai->id) {
2038c2ecf20Sopenharmony_ci	case MT8183_DAI_PCM_1:
2048c2ecf20Sopenharmony_ci		pcm_con |= AUD_BCLK_OUT_INV_NO_INVERSE << PCM_BCLK_OUT_INV_SFT;
2058c2ecf20Sopenharmony_ci		pcm_con |= AUD_TX_LCH_RPT_NO_REPEAT << PCM_TX_LCH_RPT_SFT;
2068c2ecf20Sopenharmony_ci		pcm_con |= AUD_VBT_16K_MODE_DISABLE << PCM_VBT_16K_MODE_SFT;
2078c2ecf20Sopenharmony_ci		pcm_con |= AUD_EXT_MODEM_SELECT_INTERNAL << PCM_EXT_MODEM_SFT;
2088c2ecf20Sopenharmony_ci		pcm_con |= 0 << PCM_SYNC_LENGTH_SFT;
2098c2ecf20Sopenharmony_ci		pcm_con |= AUD_PCM_ONE_BCK_CYCLE_SYNC << PCM_SYNC_TYPE_SFT;
2108c2ecf20Sopenharmony_ci		pcm_con |= AUD_BT_MODE_DUAL_MIC_ON_TX << PCM_BT_MODE_SFT;
2118c2ecf20Sopenharmony_ci		pcm_con |= AUD_PCM_AFIFO_AFIFO << PCM_BYP_ASRC_SFT;
2128c2ecf20Sopenharmony_ci		pcm_con |= AUD_PCM_CLOCK_SLAVE_MODE << PCM_SLAVE_SFT;
2138c2ecf20Sopenharmony_ci		pcm_con |= rate_reg << PCM_MODE_SFT;
2148c2ecf20Sopenharmony_ci		pcm_con |= AUD_PCM_FMT_PCM_MODE_B << PCM_FMT_SFT;
2158c2ecf20Sopenharmony_ci
2168c2ecf20Sopenharmony_ci		regmap_update_bits(afe->regmap, PCM_INTF_CON1,
2178c2ecf20Sopenharmony_ci				   0xfffffffe, pcm_con);
2188c2ecf20Sopenharmony_ci		break;
2198c2ecf20Sopenharmony_ci	case MT8183_DAI_PCM_2:
2208c2ecf20Sopenharmony_ci		pcm_con |= AUD_TX_LCH_RPT_NO_REPEAT << PCM2_TX_LCH_RPT_SFT;
2218c2ecf20Sopenharmony_ci		pcm_con |= AUD_VBT_16K_MODE_DISABLE << PCM2_VBT_16K_MODE_SFT;
2228c2ecf20Sopenharmony_ci		pcm_con |= AUD_BT_MODE_DUAL_MIC_ON_TX << PCM2_BT_MODE_SFT;
2238c2ecf20Sopenharmony_ci		pcm_con |= AUD_PCM_AFIFO_AFIFO << PCM2_AFIFO_SFT;
2248c2ecf20Sopenharmony_ci		pcm_con |= AUD_PCM_WLEN_PCM_32_BCK_CYCLES << PCM2_WLEN_SFT;
2258c2ecf20Sopenharmony_ci		pcm_con |= rate_reg << PCM2_MODE_SFT;
2268c2ecf20Sopenharmony_ci		pcm_con |= AUD_PCM_FMT_PCM_MODE_B << PCM2_FMT_SFT;
2278c2ecf20Sopenharmony_ci
2288c2ecf20Sopenharmony_ci		regmap_update_bits(afe->regmap, PCM2_INTF_CON,
2298c2ecf20Sopenharmony_ci				   0xfffffffe, pcm_con);
2308c2ecf20Sopenharmony_ci		break;
2318c2ecf20Sopenharmony_ci	default:
2328c2ecf20Sopenharmony_ci		dev_warn(afe->dev, "%s(), id %d not support\n",
2338c2ecf20Sopenharmony_ci			 __func__, dai->id);
2348c2ecf20Sopenharmony_ci		return -EINVAL;
2358c2ecf20Sopenharmony_ci	}
2368c2ecf20Sopenharmony_ci
2378c2ecf20Sopenharmony_ci	return 0;
2388c2ecf20Sopenharmony_ci}
2398c2ecf20Sopenharmony_ci
2408c2ecf20Sopenharmony_cistatic const struct snd_soc_dai_ops mtk_dai_pcm_ops = {
2418c2ecf20Sopenharmony_ci	.hw_params = mtk_dai_pcm_hw_params,
2428c2ecf20Sopenharmony_ci};
2438c2ecf20Sopenharmony_ci
2448c2ecf20Sopenharmony_ci/* dai driver */
2458c2ecf20Sopenharmony_ci#define MTK_PCM_RATES (SNDRV_PCM_RATE_8000 |\
2468c2ecf20Sopenharmony_ci		       SNDRV_PCM_RATE_16000 |\
2478c2ecf20Sopenharmony_ci		       SNDRV_PCM_RATE_32000 |\
2488c2ecf20Sopenharmony_ci		       SNDRV_PCM_RATE_48000)
2498c2ecf20Sopenharmony_ci
2508c2ecf20Sopenharmony_ci#define MTK_PCM_FORMATS (SNDRV_PCM_FMTBIT_S16_LE |\
2518c2ecf20Sopenharmony_ci			 SNDRV_PCM_FMTBIT_S24_LE |\
2528c2ecf20Sopenharmony_ci			 SNDRV_PCM_FMTBIT_S32_LE)
2538c2ecf20Sopenharmony_ci
2548c2ecf20Sopenharmony_cistatic struct snd_soc_dai_driver mtk_dai_pcm_driver[] = {
2558c2ecf20Sopenharmony_ci	{
2568c2ecf20Sopenharmony_ci		.name = "PCM 1",
2578c2ecf20Sopenharmony_ci		.id = MT8183_DAI_PCM_1,
2588c2ecf20Sopenharmony_ci		.playback = {
2598c2ecf20Sopenharmony_ci			.stream_name = "PCM 1 Playback",
2608c2ecf20Sopenharmony_ci			.channels_min = 1,
2618c2ecf20Sopenharmony_ci			.channels_max = 2,
2628c2ecf20Sopenharmony_ci			.rates = MTK_PCM_RATES,
2638c2ecf20Sopenharmony_ci			.formats = MTK_PCM_FORMATS,
2648c2ecf20Sopenharmony_ci		},
2658c2ecf20Sopenharmony_ci		.capture = {
2668c2ecf20Sopenharmony_ci			.stream_name = "PCM 1 Capture",
2678c2ecf20Sopenharmony_ci			.channels_min = 1,
2688c2ecf20Sopenharmony_ci			.channels_max = 2,
2698c2ecf20Sopenharmony_ci			.rates = MTK_PCM_RATES,
2708c2ecf20Sopenharmony_ci			.formats = MTK_PCM_FORMATS,
2718c2ecf20Sopenharmony_ci		},
2728c2ecf20Sopenharmony_ci		.ops = &mtk_dai_pcm_ops,
2738c2ecf20Sopenharmony_ci		.symmetric_rates = 1,
2748c2ecf20Sopenharmony_ci		.symmetric_samplebits = 1,
2758c2ecf20Sopenharmony_ci	},
2768c2ecf20Sopenharmony_ci	{
2778c2ecf20Sopenharmony_ci		.name = "PCM 2",
2788c2ecf20Sopenharmony_ci		.id = MT8183_DAI_PCM_2,
2798c2ecf20Sopenharmony_ci		.playback = {
2808c2ecf20Sopenharmony_ci			.stream_name = "PCM 2 Playback",
2818c2ecf20Sopenharmony_ci			.channels_min = 1,
2828c2ecf20Sopenharmony_ci			.channels_max = 2,
2838c2ecf20Sopenharmony_ci			.rates = MTK_PCM_RATES,
2848c2ecf20Sopenharmony_ci			.formats = MTK_PCM_FORMATS,
2858c2ecf20Sopenharmony_ci		},
2868c2ecf20Sopenharmony_ci		.capture = {
2878c2ecf20Sopenharmony_ci			.stream_name = "PCM 2 Capture",
2888c2ecf20Sopenharmony_ci			.channels_min = 1,
2898c2ecf20Sopenharmony_ci			.channels_max = 2,
2908c2ecf20Sopenharmony_ci			.rates = MTK_PCM_RATES,
2918c2ecf20Sopenharmony_ci			.formats = MTK_PCM_FORMATS,
2928c2ecf20Sopenharmony_ci		},
2938c2ecf20Sopenharmony_ci		.ops = &mtk_dai_pcm_ops,
2948c2ecf20Sopenharmony_ci		.symmetric_rates = 1,
2958c2ecf20Sopenharmony_ci		.symmetric_samplebits = 1,
2968c2ecf20Sopenharmony_ci	},
2978c2ecf20Sopenharmony_ci};
2988c2ecf20Sopenharmony_ci
2998c2ecf20Sopenharmony_ciint mt8183_dai_pcm_register(struct mtk_base_afe *afe)
3008c2ecf20Sopenharmony_ci{
3018c2ecf20Sopenharmony_ci	struct mtk_base_afe_dai *dai;
3028c2ecf20Sopenharmony_ci
3038c2ecf20Sopenharmony_ci	dai = devm_kzalloc(afe->dev, sizeof(*dai), GFP_KERNEL);
3048c2ecf20Sopenharmony_ci	if (!dai)
3058c2ecf20Sopenharmony_ci		return -ENOMEM;
3068c2ecf20Sopenharmony_ci
3078c2ecf20Sopenharmony_ci	list_add(&dai->list, &afe->sub_dais);
3088c2ecf20Sopenharmony_ci
3098c2ecf20Sopenharmony_ci	dai->dai_drivers = mtk_dai_pcm_driver;
3108c2ecf20Sopenharmony_ci	dai->num_dai_drivers = ARRAY_SIZE(mtk_dai_pcm_driver);
3118c2ecf20Sopenharmony_ci
3128c2ecf20Sopenharmony_ci	dai->dapm_widgets = mtk_dai_pcm_widgets;
3138c2ecf20Sopenharmony_ci	dai->num_dapm_widgets = ARRAY_SIZE(mtk_dai_pcm_widgets);
3148c2ecf20Sopenharmony_ci	dai->dapm_routes = mtk_dai_pcm_routes;
3158c2ecf20Sopenharmony_ci	dai->num_dapm_routes = ARRAY_SIZE(mtk_dai_pcm_routes);
3168c2ecf20Sopenharmony_ci
3178c2ecf20Sopenharmony_ci	return 0;
3188c2ecf20Sopenharmony_ci}
319