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/bitops.h> 98c2ecf20Sopenharmony_ci#include <linux/regmap.h> 108c2ecf20Sopenharmony_ci#include <sound/pcm_params.h> 118c2ecf20Sopenharmony_ci#include "mt8183-afe-clk.h" 128c2ecf20Sopenharmony_ci#include "mt8183-afe-common.h" 138c2ecf20Sopenharmony_ci#include "mt8183-interconnection.h" 148c2ecf20Sopenharmony_ci#include "mt8183-reg.h" 158c2ecf20Sopenharmony_ci 168c2ecf20Sopenharmony_cienum { 178c2ecf20Sopenharmony_ci I2S_FMT_EIAJ = 0, 188c2ecf20Sopenharmony_ci I2S_FMT_I2S = 1, 198c2ecf20Sopenharmony_ci}; 208c2ecf20Sopenharmony_ci 218c2ecf20Sopenharmony_cienum { 228c2ecf20Sopenharmony_ci I2S_WLEN_16_BIT = 0, 238c2ecf20Sopenharmony_ci I2S_WLEN_32_BIT = 1, 248c2ecf20Sopenharmony_ci}; 258c2ecf20Sopenharmony_ci 268c2ecf20Sopenharmony_cienum { 278c2ecf20Sopenharmony_ci I2S_HD_NORMAL = 0, 288c2ecf20Sopenharmony_ci I2S_HD_LOW_JITTER = 1, 298c2ecf20Sopenharmony_ci}; 308c2ecf20Sopenharmony_ci 318c2ecf20Sopenharmony_cienum { 328c2ecf20Sopenharmony_ci I2S1_SEL_O28_O29 = 0, 338c2ecf20Sopenharmony_ci I2S1_SEL_O03_O04 = 1, 348c2ecf20Sopenharmony_ci}; 358c2ecf20Sopenharmony_ci 368c2ecf20Sopenharmony_cienum { 378c2ecf20Sopenharmony_ci I2S_IN_PAD_CONNSYS = 0, 388c2ecf20Sopenharmony_ci I2S_IN_PAD_IO_MUX = 1, 398c2ecf20Sopenharmony_ci}; 408c2ecf20Sopenharmony_ci 418c2ecf20Sopenharmony_cistruct mtk_afe_i2s_priv { 428c2ecf20Sopenharmony_ci int id; 438c2ecf20Sopenharmony_ci int rate; /* for determine which apll to use */ 448c2ecf20Sopenharmony_ci int low_jitter_en; 458c2ecf20Sopenharmony_ci 468c2ecf20Sopenharmony_ci const char *share_property_name; 478c2ecf20Sopenharmony_ci int share_i2s_id; 488c2ecf20Sopenharmony_ci 498c2ecf20Sopenharmony_ci int mclk_id; 508c2ecf20Sopenharmony_ci int mclk_rate; 518c2ecf20Sopenharmony_ci int mclk_apll; 528c2ecf20Sopenharmony_ci 538c2ecf20Sopenharmony_ci int use_eiaj; 548c2ecf20Sopenharmony_ci}; 558c2ecf20Sopenharmony_ci 568c2ecf20Sopenharmony_cistatic unsigned int get_i2s_wlen(snd_pcm_format_t format) 578c2ecf20Sopenharmony_ci{ 588c2ecf20Sopenharmony_ci return snd_pcm_format_physical_width(format) <= 16 ? 598c2ecf20Sopenharmony_ci I2S_WLEN_16_BIT : I2S_WLEN_32_BIT; 608c2ecf20Sopenharmony_ci} 618c2ecf20Sopenharmony_ci 628c2ecf20Sopenharmony_ci#define MTK_AFE_I2S0_KCONTROL_NAME "I2S0_HD_Mux" 638c2ecf20Sopenharmony_ci#define MTK_AFE_I2S1_KCONTROL_NAME "I2S1_HD_Mux" 648c2ecf20Sopenharmony_ci#define MTK_AFE_I2S2_KCONTROL_NAME "I2S2_HD_Mux" 658c2ecf20Sopenharmony_ci#define MTK_AFE_I2S3_KCONTROL_NAME "I2S3_HD_Mux" 668c2ecf20Sopenharmony_ci#define MTK_AFE_I2S5_KCONTROL_NAME "I2S5_HD_Mux" 678c2ecf20Sopenharmony_ci 688c2ecf20Sopenharmony_ci#define I2S0_HD_EN_W_NAME "I2S0_HD_EN" 698c2ecf20Sopenharmony_ci#define I2S1_HD_EN_W_NAME "I2S1_HD_EN" 708c2ecf20Sopenharmony_ci#define I2S2_HD_EN_W_NAME "I2S2_HD_EN" 718c2ecf20Sopenharmony_ci#define I2S3_HD_EN_W_NAME "I2S3_HD_EN" 728c2ecf20Sopenharmony_ci#define I2S5_HD_EN_W_NAME "I2S5_HD_EN" 738c2ecf20Sopenharmony_ci 748c2ecf20Sopenharmony_ci#define I2S0_MCLK_EN_W_NAME "I2S0_MCLK_EN" 758c2ecf20Sopenharmony_ci#define I2S1_MCLK_EN_W_NAME "I2S1_MCLK_EN" 768c2ecf20Sopenharmony_ci#define I2S2_MCLK_EN_W_NAME "I2S2_MCLK_EN" 778c2ecf20Sopenharmony_ci#define I2S3_MCLK_EN_W_NAME "I2S3_MCLK_EN" 788c2ecf20Sopenharmony_ci#define I2S5_MCLK_EN_W_NAME "I2S5_MCLK_EN" 798c2ecf20Sopenharmony_ci 808c2ecf20Sopenharmony_cistatic int get_i2s_id_by_name(struct mtk_base_afe *afe, 818c2ecf20Sopenharmony_ci const char *name) 828c2ecf20Sopenharmony_ci{ 838c2ecf20Sopenharmony_ci if (strncmp(name, "I2S0", 4) == 0) 848c2ecf20Sopenharmony_ci return MT8183_DAI_I2S_0; 858c2ecf20Sopenharmony_ci else if (strncmp(name, "I2S1", 4) == 0) 868c2ecf20Sopenharmony_ci return MT8183_DAI_I2S_1; 878c2ecf20Sopenharmony_ci else if (strncmp(name, "I2S2", 4) == 0) 888c2ecf20Sopenharmony_ci return MT8183_DAI_I2S_2; 898c2ecf20Sopenharmony_ci else if (strncmp(name, "I2S3", 4) == 0) 908c2ecf20Sopenharmony_ci return MT8183_DAI_I2S_3; 918c2ecf20Sopenharmony_ci else if (strncmp(name, "I2S5", 4) == 0) 928c2ecf20Sopenharmony_ci return MT8183_DAI_I2S_5; 938c2ecf20Sopenharmony_ci else 948c2ecf20Sopenharmony_ci return -EINVAL; 958c2ecf20Sopenharmony_ci} 968c2ecf20Sopenharmony_ci 978c2ecf20Sopenharmony_cistatic struct mtk_afe_i2s_priv *get_i2s_priv_by_name(struct mtk_base_afe *afe, 988c2ecf20Sopenharmony_ci const char *name) 998c2ecf20Sopenharmony_ci{ 1008c2ecf20Sopenharmony_ci struct mt8183_afe_private *afe_priv = afe->platform_priv; 1018c2ecf20Sopenharmony_ci int dai_id = get_i2s_id_by_name(afe, name); 1028c2ecf20Sopenharmony_ci 1038c2ecf20Sopenharmony_ci if (dai_id < 0) 1048c2ecf20Sopenharmony_ci return NULL; 1058c2ecf20Sopenharmony_ci 1068c2ecf20Sopenharmony_ci return afe_priv->dai_priv[dai_id]; 1078c2ecf20Sopenharmony_ci} 1088c2ecf20Sopenharmony_ci 1098c2ecf20Sopenharmony_ci/* low jitter control */ 1108c2ecf20Sopenharmony_cistatic const char * const mt8183_i2s_hd_str[] = { 1118c2ecf20Sopenharmony_ci "Normal", "Low_Jitter" 1128c2ecf20Sopenharmony_ci}; 1138c2ecf20Sopenharmony_ci 1148c2ecf20Sopenharmony_cistatic const struct soc_enum mt8183_i2s_enum[] = { 1158c2ecf20Sopenharmony_ci SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(mt8183_i2s_hd_str), 1168c2ecf20Sopenharmony_ci mt8183_i2s_hd_str), 1178c2ecf20Sopenharmony_ci}; 1188c2ecf20Sopenharmony_ci 1198c2ecf20Sopenharmony_cistatic int mt8183_i2s_hd_get(struct snd_kcontrol *kcontrol, 1208c2ecf20Sopenharmony_ci struct snd_ctl_elem_value *ucontrol) 1218c2ecf20Sopenharmony_ci{ 1228c2ecf20Sopenharmony_ci struct snd_soc_component *cmpnt = snd_soc_kcontrol_component(kcontrol); 1238c2ecf20Sopenharmony_ci struct mtk_base_afe *afe = snd_soc_component_get_drvdata(cmpnt); 1248c2ecf20Sopenharmony_ci struct mtk_afe_i2s_priv *i2s_priv; 1258c2ecf20Sopenharmony_ci 1268c2ecf20Sopenharmony_ci i2s_priv = get_i2s_priv_by_name(afe, kcontrol->id.name); 1278c2ecf20Sopenharmony_ci 1288c2ecf20Sopenharmony_ci if (!i2s_priv) { 1298c2ecf20Sopenharmony_ci dev_warn(afe->dev, "%s(), i2s_priv == NULL", __func__); 1308c2ecf20Sopenharmony_ci return -EINVAL; 1318c2ecf20Sopenharmony_ci } 1328c2ecf20Sopenharmony_ci 1338c2ecf20Sopenharmony_ci ucontrol->value.integer.value[0] = i2s_priv->low_jitter_en; 1348c2ecf20Sopenharmony_ci 1358c2ecf20Sopenharmony_ci return 0; 1368c2ecf20Sopenharmony_ci} 1378c2ecf20Sopenharmony_ci 1388c2ecf20Sopenharmony_cistatic int mt8183_i2s_hd_set(struct snd_kcontrol *kcontrol, 1398c2ecf20Sopenharmony_ci struct snd_ctl_elem_value *ucontrol) 1408c2ecf20Sopenharmony_ci{ 1418c2ecf20Sopenharmony_ci struct snd_soc_component *cmpnt = snd_soc_kcontrol_component(kcontrol); 1428c2ecf20Sopenharmony_ci struct mtk_base_afe *afe = snd_soc_component_get_drvdata(cmpnt); 1438c2ecf20Sopenharmony_ci struct mtk_afe_i2s_priv *i2s_priv; 1448c2ecf20Sopenharmony_ci struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; 1458c2ecf20Sopenharmony_ci int hd_en; 1468c2ecf20Sopenharmony_ci 1478c2ecf20Sopenharmony_ci if (ucontrol->value.enumerated.item[0] >= e->items) 1488c2ecf20Sopenharmony_ci return -EINVAL; 1498c2ecf20Sopenharmony_ci 1508c2ecf20Sopenharmony_ci hd_en = ucontrol->value.integer.value[0]; 1518c2ecf20Sopenharmony_ci 1528c2ecf20Sopenharmony_ci dev_info(afe->dev, "%s(), kcontrol name %s, hd_en %d\n", 1538c2ecf20Sopenharmony_ci __func__, kcontrol->id.name, hd_en); 1548c2ecf20Sopenharmony_ci 1558c2ecf20Sopenharmony_ci i2s_priv = get_i2s_priv_by_name(afe, kcontrol->id.name); 1568c2ecf20Sopenharmony_ci 1578c2ecf20Sopenharmony_ci if (!i2s_priv) { 1588c2ecf20Sopenharmony_ci dev_warn(afe->dev, "%s(), i2s_priv == NULL", __func__); 1598c2ecf20Sopenharmony_ci return -EINVAL; 1608c2ecf20Sopenharmony_ci } 1618c2ecf20Sopenharmony_ci 1628c2ecf20Sopenharmony_ci i2s_priv->low_jitter_en = hd_en; 1638c2ecf20Sopenharmony_ci 1648c2ecf20Sopenharmony_ci return 0; 1658c2ecf20Sopenharmony_ci} 1668c2ecf20Sopenharmony_ci 1678c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new mtk_dai_i2s_controls[] = { 1688c2ecf20Sopenharmony_ci SOC_ENUM_EXT(MTK_AFE_I2S0_KCONTROL_NAME, mt8183_i2s_enum[0], 1698c2ecf20Sopenharmony_ci mt8183_i2s_hd_get, mt8183_i2s_hd_set), 1708c2ecf20Sopenharmony_ci SOC_ENUM_EXT(MTK_AFE_I2S1_KCONTROL_NAME, mt8183_i2s_enum[0], 1718c2ecf20Sopenharmony_ci mt8183_i2s_hd_get, mt8183_i2s_hd_set), 1728c2ecf20Sopenharmony_ci SOC_ENUM_EXT(MTK_AFE_I2S2_KCONTROL_NAME, mt8183_i2s_enum[0], 1738c2ecf20Sopenharmony_ci mt8183_i2s_hd_get, mt8183_i2s_hd_set), 1748c2ecf20Sopenharmony_ci SOC_ENUM_EXT(MTK_AFE_I2S3_KCONTROL_NAME, mt8183_i2s_enum[0], 1758c2ecf20Sopenharmony_ci mt8183_i2s_hd_get, mt8183_i2s_hd_set), 1768c2ecf20Sopenharmony_ci SOC_ENUM_EXT(MTK_AFE_I2S5_KCONTROL_NAME, mt8183_i2s_enum[0], 1778c2ecf20Sopenharmony_ci mt8183_i2s_hd_get, mt8183_i2s_hd_set), 1788c2ecf20Sopenharmony_ci}; 1798c2ecf20Sopenharmony_ci 1808c2ecf20Sopenharmony_ci/* dai component */ 1818c2ecf20Sopenharmony_ci/* interconnection */ 1828c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new mtk_i2s3_ch1_mix[] = { 1838c2ecf20Sopenharmony_ci SOC_DAPM_SINGLE_AUTODISABLE("DL1_CH1", AFE_CONN0, I_DL1_CH1, 1, 0), 1848c2ecf20Sopenharmony_ci SOC_DAPM_SINGLE_AUTODISABLE("DL2_CH1", AFE_CONN0, I_DL2_CH1, 1, 0), 1858c2ecf20Sopenharmony_ci SOC_DAPM_SINGLE_AUTODISABLE("DL3_CH1", AFE_CONN0, I_DL3_CH1, 1, 0), 1868c2ecf20Sopenharmony_ci SOC_DAPM_SINGLE_AUTODISABLE("ADDA_UL_CH1", AFE_CONN0, 1878c2ecf20Sopenharmony_ci I_ADDA_UL_CH1, 1, 0), 1888c2ecf20Sopenharmony_ci SOC_DAPM_SINGLE_AUTODISABLE("PCM_1_CAP_CH1", AFE_CONN0, 1898c2ecf20Sopenharmony_ci I_PCM_1_CAP_CH1, 1, 0), 1908c2ecf20Sopenharmony_ci SOC_DAPM_SINGLE_AUTODISABLE("PCM_2_CAP_CH1", AFE_CONN0, 1918c2ecf20Sopenharmony_ci I_PCM_2_CAP_CH1, 1, 0), 1928c2ecf20Sopenharmony_ci}; 1938c2ecf20Sopenharmony_ci 1948c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new mtk_i2s3_ch2_mix[] = { 1958c2ecf20Sopenharmony_ci SOC_DAPM_SINGLE_AUTODISABLE("DL1_CH2", AFE_CONN1, I_DL1_CH2, 1, 0), 1968c2ecf20Sopenharmony_ci SOC_DAPM_SINGLE_AUTODISABLE("DL2_CH2", AFE_CONN1, I_DL2_CH2, 1, 0), 1978c2ecf20Sopenharmony_ci SOC_DAPM_SINGLE_AUTODISABLE("DL3_CH2", AFE_CONN1, I_DL3_CH2, 1, 0), 1988c2ecf20Sopenharmony_ci SOC_DAPM_SINGLE_AUTODISABLE("ADDA_UL_CH2", AFE_CONN1, 1998c2ecf20Sopenharmony_ci I_ADDA_UL_CH2, 1, 0), 2008c2ecf20Sopenharmony_ci SOC_DAPM_SINGLE_AUTODISABLE("PCM_1_CAP_CH1", AFE_CONN1, 2018c2ecf20Sopenharmony_ci I_PCM_1_CAP_CH1, 1, 0), 2028c2ecf20Sopenharmony_ci SOC_DAPM_SINGLE_AUTODISABLE("PCM_2_CAP_CH1", AFE_CONN1, 2038c2ecf20Sopenharmony_ci I_PCM_2_CAP_CH1, 1, 0), 2048c2ecf20Sopenharmony_ci SOC_DAPM_SINGLE_AUTODISABLE("PCM_1_CAP_CH2", AFE_CONN1, 2058c2ecf20Sopenharmony_ci I_PCM_1_CAP_CH2, 1, 0), 2068c2ecf20Sopenharmony_ci SOC_DAPM_SINGLE_AUTODISABLE("PCM_2_CAP_CH2", AFE_CONN1, 2078c2ecf20Sopenharmony_ci I_PCM_2_CAP_CH2, 1, 0), 2088c2ecf20Sopenharmony_ci}; 2098c2ecf20Sopenharmony_ci 2108c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new mtk_i2s1_ch1_mix[] = { 2118c2ecf20Sopenharmony_ci SOC_DAPM_SINGLE_AUTODISABLE("DL1_CH1", AFE_CONN28, I_DL1_CH1, 1, 0), 2128c2ecf20Sopenharmony_ci SOC_DAPM_SINGLE_AUTODISABLE("DL2_CH1", AFE_CONN28, I_DL2_CH1, 1, 0), 2138c2ecf20Sopenharmony_ci SOC_DAPM_SINGLE_AUTODISABLE("DL3_CH1", AFE_CONN28, I_DL3_CH1, 1, 0), 2148c2ecf20Sopenharmony_ci SOC_DAPM_SINGLE_AUTODISABLE("ADDA_UL_CH1", AFE_CONN28, 2158c2ecf20Sopenharmony_ci I_ADDA_UL_CH1, 1, 0), 2168c2ecf20Sopenharmony_ci SOC_DAPM_SINGLE_AUTODISABLE("PCM_1_CAP_CH1", AFE_CONN28, 2178c2ecf20Sopenharmony_ci I_PCM_1_CAP_CH1, 1, 0), 2188c2ecf20Sopenharmony_ci SOC_DAPM_SINGLE_AUTODISABLE("PCM_2_CAP_CH1", AFE_CONN28, 2198c2ecf20Sopenharmony_ci I_PCM_2_CAP_CH1, 1, 0), 2208c2ecf20Sopenharmony_ci}; 2218c2ecf20Sopenharmony_ci 2228c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new mtk_i2s1_ch2_mix[] = { 2238c2ecf20Sopenharmony_ci SOC_DAPM_SINGLE_AUTODISABLE("DL1_CH2", AFE_CONN29, I_DL1_CH2, 1, 0), 2248c2ecf20Sopenharmony_ci SOC_DAPM_SINGLE_AUTODISABLE("DL2_CH2", AFE_CONN29, I_DL2_CH2, 1, 0), 2258c2ecf20Sopenharmony_ci SOC_DAPM_SINGLE_AUTODISABLE("DL3_CH2", AFE_CONN29, I_DL3_CH2, 1, 0), 2268c2ecf20Sopenharmony_ci SOC_DAPM_SINGLE_AUTODISABLE("ADDA_UL_CH2", AFE_CONN29, 2278c2ecf20Sopenharmony_ci I_ADDA_UL_CH2, 1, 0), 2288c2ecf20Sopenharmony_ci SOC_DAPM_SINGLE_AUTODISABLE("PCM_1_CAP_CH1", AFE_CONN29, 2298c2ecf20Sopenharmony_ci I_PCM_1_CAP_CH1, 1, 0), 2308c2ecf20Sopenharmony_ci SOC_DAPM_SINGLE_AUTODISABLE("PCM_2_CAP_CH1", AFE_CONN29, 2318c2ecf20Sopenharmony_ci I_PCM_2_CAP_CH1, 1, 0), 2328c2ecf20Sopenharmony_ci SOC_DAPM_SINGLE_AUTODISABLE("PCM_1_CAP_CH2", AFE_CONN29, 2338c2ecf20Sopenharmony_ci I_PCM_1_CAP_CH2, 1, 0), 2348c2ecf20Sopenharmony_ci SOC_DAPM_SINGLE_AUTODISABLE("PCM_2_CAP_CH2", AFE_CONN29, 2358c2ecf20Sopenharmony_ci I_PCM_2_CAP_CH2, 1, 0), 2368c2ecf20Sopenharmony_ci}; 2378c2ecf20Sopenharmony_ci 2388c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new mtk_i2s5_ch1_mix[] = { 2398c2ecf20Sopenharmony_ci SOC_DAPM_SINGLE_AUTODISABLE("DL1_CH1", AFE_CONN30, I_DL1_CH1, 1, 0), 2408c2ecf20Sopenharmony_ci SOC_DAPM_SINGLE_AUTODISABLE("DL2_CH1", AFE_CONN30, I_DL2_CH1, 1, 0), 2418c2ecf20Sopenharmony_ci SOC_DAPM_SINGLE_AUTODISABLE("DL3_CH1", AFE_CONN30, I_DL3_CH1, 1, 0), 2428c2ecf20Sopenharmony_ci SOC_DAPM_SINGLE_AUTODISABLE("ADDA_UL_CH1", AFE_CONN30, 2438c2ecf20Sopenharmony_ci I_ADDA_UL_CH1, 1, 0), 2448c2ecf20Sopenharmony_ci SOC_DAPM_SINGLE_AUTODISABLE("PCM_1_CAP_CH1", AFE_CONN30, 2458c2ecf20Sopenharmony_ci I_PCM_1_CAP_CH1, 1, 0), 2468c2ecf20Sopenharmony_ci SOC_DAPM_SINGLE_AUTODISABLE("PCM_2_CAP_CH1", AFE_CONN30, 2478c2ecf20Sopenharmony_ci I_PCM_2_CAP_CH1, 1, 0), 2488c2ecf20Sopenharmony_ci}; 2498c2ecf20Sopenharmony_ci 2508c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new mtk_i2s5_ch2_mix[] = { 2518c2ecf20Sopenharmony_ci SOC_DAPM_SINGLE_AUTODISABLE("DL1_CH2", AFE_CONN31, I_DL1_CH2, 1, 0), 2528c2ecf20Sopenharmony_ci SOC_DAPM_SINGLE_AUTODISABLE("DL2_CH2", AFE_CONN31, I_DL2_CH2, 1, 0), 2538c2ecf20Sopenharmony_ci SOC_DAPM_SINGLE_AUTODISABLE("DL3_CH2", AFE_CONN31, I_DL3_CH2, 1, 0), 2548c2ecf20Sopenharmony_ci SOC_DAPM_SINGLE_AUTODISABLE("ADDA_UL_CH2", AFE_CONN31, 2558c2ecf20Sopenharmony_ci I_ADDA_UL_CH2, 1, 0), 2568c2ecf20Sopenharmony_ci SOC_DAPM_SINGLE_AUTODISABLE("PCM_1_CAP_CH1", AFE_CONN31, 2578c2ecf20Sopenharmony_ci I_PCM_1_CAP_CH1, 1, 0), 2588c2ecf20Sopenharmony_ci SOC_DAPM_SINGLE_AUTODISABLE("PCM_2_CAP_CH1", AFE_CONN31, 2598c2ecf20Sopenharmony_ci I_PCM_2_CAP_CH1, 1, 0), 2608c2ecf20Sopenharmony_ci SOC_DAPM_SINGLE_AUTODISABLE("PCM_1_CAP_CH2", AFE_CONN31, 2618c2ecf20Sopenharmony_ci I_PCM_1_CAP_CH2, 1, 0), 2628c2ecf20Sopenharmony_ci SOC_DAPM_SINGLE_AUTODISABLE("PCM_2_CAP_CH2", AFE_CONN31, 2638c2ecf20Sopenharmony_ci I_PCM_2_CAP_CH2, 1, 0), 2648c2ecf20Sopenharmony_ci}; 2658c2ecf20Sopenharmony_ci 2668c2ecf20Sopenharmony_cienum { 2678c2ecf20Sopenharmony_ci SUPPLY_SEQ_APLL, 2688c2ecf20Sopenharmony_ci SUPPLY_SEQ_I2S_MCLK_EN, 2698c2ecf20Sopenharmony_ci SUPPLY_SEQ_I2S_HD_EN, 2708c2ecf20Sopenharmony_ci SUPPLY_SEQ_I2S_EN, 2718c2ecf20Sopenharmony_ci}; 2728c2ecf20Sopenharmony_ci 2738c2ecf20Sopenharmony_cistatic int mtk_apll_event(struct snd_soc_dapm_widget *w, 2748c2ecf20Sopenharmony_ci struct snd_kcontrol *kcontrol, 2758c2ecf20Sopenharmony_ci int event) 2768c2ecf20Sopenharmony_ci{ 2778c2ecf20Sopenharmony_ci struct snd_soc_component *cmpnt = snd_soc_dapm_to_component(w->dapm); 2788c2ecf20Sopenharmony_ci struct mtk_base_afe *afe = snd_soc_component_get_drvdata(cmpnt); 2798c2ecf20Sopenharmony_ci 2808c2ecf20Sopenharmony_ci dev_info(cmpnt->dev, "%s(), name %s, event 0x%x\n", 2818c2ecf20Sopenharmony_ci __func__, w->name, event); 2828c2ecf20Sopenharmony_ci 2838c2ecf20Sopenharmony_ci switch (event) { 2848c2ecf20Sopenharmony_ci case SND_SOC_DAPM_PRE_PMU: 2858c2ecf20Sopenharmony_ci if (strcmp(w->name, APLL1_W_NAME) == 0) 2868c2ecf20Sopenharmony_ci mt8183_apll1_enable(afe); 2878c2ecf20Sopenharmony_ci else 2888c2ecf20Sopenharmony_ci mt8183_apll2_enable(afe); 2898c2ecf20Sopenharmony_ci break; 2908c2ecf20Sopenharmony_ci case SND_SOC_DAPM_POST_PMD: 2918c2ecf20Sopenharmony_ci if (strcmp(w->name, APLL1_W_NAME) == 0) 2928c2ecf20Sopenharmony_ci mt8183_apll1_disable(afe); 2938c2ecf20Sopenharmony_ci else 2948c2ecf20Sopenharmony_ci mt8183_apll2_disable(afe); 2958c2ecf20Sopenharmony_ci break; 2968c2ecf20Sopenharmony_ci default: 2978c2ecf20Sopenharmony_ci break; 2988c2ecf20Sopenharmony_ci } 2998c2ecf20Sopenharmony_ci 3008c2ecf20Sopenharmony_ci return 0; 3018c2ecf20Sopenharmony_ci} 3028c2ecf20Sopenharmony_ci 3038c2ecf20Sopenharmony_cistatic int mtk_mclk_en_event(struct snd_soc_dapm_widget *w, 3048c2ecf20Sopenharmony_ci struct snd_kcontrol *kcontrol, 3058c2ecf20Sopenharmony_ci int event) 3068c2ecf20Sopenharmony_ci{ 3078c2ecf20Sopenharmony_ci struct snd_soc_component *cmpnt = snd_soc_dapm_to_component(w->dapm); 3088c2ecf20Sopenharmony_ci struct mtk_base_afe *afe = snd_soc_component_get_drvdata(cmpnt); 3098c2ecf20Sopenharmony_ci struct mtk_afe_i2s_priv *i2s_priv; 3108c2ecf20Sopenharmony_ci 3118c2ecf20Sopenharmony_ci dev_info(cmpnt->dev, "%s(), name %s, event 0x%x\n", 3128c2ecf20Sopenharmony_ci __func__, w->name, event); 3138c2ecf20Sopenharmony_ci 3148c2ecf20Sopenharmony_ci i2s_priv = get_i2s_priv_by_name(afe, w->name); 3158c2ecf20Sopenharmony_ci 3168c2ecf20Sopenharmony_ci if (!i2s_priv) { 3178c2ecf20Sopenharmony_ci dev_warn(afe->dev, "%s(), i2s_priv == NULL", __func__); 3188c2ecf20Sopenharmony_ci return -EINVAL; 3198c2ecf20Sopenharmony_ci } 3208c2ecf20Sopenharmony_ci 3218c2ecf20Sopenharmony_ci switch (event) { 3228c2ecf20Sopenharmony_ci case SND_SOC_DAPM_PRE_PMU: 3238c2ecf20Sopenharmony_ci mt8183_mck_enable(afe, i2s_priv->mclk_id, i2s_priv->mclk_rate); 3248c2ecf20Sopenharmony_ci break; 3258c2ecf20Sopenharmony_ci case SND_SOC_DAPM_POST_PMD: 3268c2ecf20Sopenharmony_ci i2s_priv->mclk_rate = 0; 3278c2ecf20Sopenharmony_ci mt8183_mck_disable(afe, i2s_priv->mclk_id); 3288c2ecf20Sopenharmony_ci break; 3298c2ecf20Sopenharmony_ci default: 3308c2ecf20Sopenharmony_ci break; 3318c2ecf20Sopenharmony_ci } 3328c2ecf20Sopenharmony_ci 3338c2ecf20Sopenharmony_ci return 0; 3348c2ecf20Sopenharmony_ci} 3358c2ecf20Sopenharmony_ci 3368c2ecf20Sopenharmony_cistatic const struct snd_soc_dapm_widget mtk_dai_i2s_widgets[] = { 3378c2ecf20Sopenharmony_ci SND_SOC_DAPM_MIXER("I2S1_CH1", SND_SOC_NOPM, 0, 0, 3388c2ecf20Sopenharmony_ci mtk_i2s1_ch1_mix, 3398c2ecf20Sopenharmony_ci ARRAY_SIZE(mtk_i2s1_ch1_mix)), 3408c2ecf20Sopenharmony_ci SND_SOC_DAPM_MIXER("I2S1_CH2", SND_SOC_NOPM, 0, 0, 3418c2ecf20Sopenharmony_ci mtk_i2s1_ch2_mix, 3428c2ecf20Sopenharmony_ci ARRAY_SIZE(mtk_i2s1_ch2_mix)), 3438c2ecf20Sopenharmony_ci 3448c2ecf20Sopenharmony_ci SND_SOC_DAPM_MIXER("I2S3_CH1", SND_SOC_NOPM, 0, 0, 3458c2ecf20Sopenharmony_ci mtk_i2s3_ch1_mix, 3468c2ecf20Sopenharmony_ci ARRAY_SIZE(mtk_i2s3_ch1_mix)), 3478c2ecf20Sopenharmony_ci SND_SOC_DAPM_MIXER("I2S3_CH2", SND_SOC_NOPM, 0, 0, 3488c2ecf20Sopenharmony_ci mtk_i2s3_ch2_mix, 3498c2ecf20Sopenharmony_ci ARRAY_SIZE(mtk_i2s3_ch2_mix)), 3508c2ecf20Sopenharmony_ci 3518c2ecf20Sopenharmony_ci SND_SOC_DAPM_MIXER("I2S5_CH1", SND_SOC_NOPM, 0, 0, 3528c2ecf20Sopenharmony_ci mtk_i2s5_ch1_mix, 3538c2ecf20Sopenharmony_ci ARRAY_SIZE(mtk_i2s5_ch1_mix)), 3548c2ecf20Sopenharmony_ci SND_SOC_DAPM_MIXER("I2S5_CH2", SND_SOC_NOPM, 0, 0, 3558c2ecf20Sopenharmony_ci mtk_i2s5_ch2_mix, 3568c2ecf20Sopenharmony_ci ARRAY_SIZE(mtk_i2s5_ch2_mix)), 3578c2ecf20Sopenharmony_ci 3588c2ecf20Sopenharmony_ci /* i2s en*/ 3598c2ecf20Sopenharmony_ci SND_SOC_DAPM_SUPPLY_S("I2S0_EN", SUPPLY_SEQ_I2S_EN, 3608c2ecf20Sopenharmony_ci AFE_I2S_CON, I2S_EN_SFT, 0, 3618c2ecf20Sopenharmony_ci NULL, 0), 3628c2ecf20Sopenharmony_ci SND_SOC_DAPM_SUPPLY_S("I2S1_EN", SUPPLY_SEQ_I2S_EN, 3638c2ecf20Sopenharmony_ci AFE_I2S_CON1, I2S_EN_SFT, 0, 3648c2ecf20Sopenharmony_ci NULL, 0), 3658c2ecf20Sopenharmony_ci SND_SOC_DAPM_SUPPLY_S("I2S2_EN", SUPPLY_SEQ_I2S_EN, 3668c2ecf20Sopenharmony_ci AFE_I2S_CON2, I2S_EN_SFT, 0, 3678c2ecf20Sopenharmony_ci NULL, 0), 3688c2ecf20Sopenharmony_ci SND_SOC_DAPM_SUPPLY_S("I2S3_EN", SUPPLY_SEQ_I2S_EN, 3698c2ecf20Sopenharmony_ci AFE_I2S_CON3, I2S_EN_SFT, 0, 3708c2ecf20Sopenharmony_ci NULL, 0), 3718c2ecf20Sopenharmony_ci SND_SOC_DAPM_SUPPLY_S("I2S5_EN", SUPPLY_SEQ_I2S_EN, 3728c2ecf20Sopenharmony_ci AFE_I2S_CON4, I2S5_EN_SFT, 0, 3738c2ecf20Sopenharmony_ci NULL, 0), 3748c2ecf20Sopenharmony_ci /* i2s hd en */ 3758c2ecf20Sopenharmony_ci SND_SOC_DAPM_SUPPLY_S(I2S0_HD_EN_W_NAME, SUPPLY_SEQ_I2S_HD_EN, 3768c2ecf20Sopenharmony_ci AFE_I2S_CON, I2S1_HD_EN_SFT, 0, 3778c2ecf20Sopenharmony_ci NULL, 0), 3788c2ecf20Sopenharmony_ci SND_SOC_DAPM_SUPPLY_S(I2S1_HD_EN_W_NAME, SUPPLY_SEQ_I2S_HD_EN, 3798c2ecf20Sopenharmony_ci AFE_I2S_CON1, I2S2_HD_EN_SFT, 0, 3808c2ecf20Sopenharmony_ci NULL, 0), 3818c2ecf20Sopenharmony_ci SND_SOC_DAPM_SUPPLY_S(I2S2_HD_EN_W_NAME, SUPPLY_SEQ_I2S_HD_EN, 3828c2ecf20Sopenharmony_ci AFE_I2S_CON2, I2S3_HD_EN_SFT, 0, 3838c2ecf20Sopenharmony_ci NULL, 0), 3848c2ecf20Sopenharmony_ci SND_SOC_DAPM_SUPPLY_S(I2S3_HD_EN_W_NAME, SUPPLY_SEQ_I2S_HD_EN, 3858c2ecf20Sopenharmony_ci AFE_I2S_CON3, I2S4_HD_EN_SFT, 0, 3868c2ecf20Sopenharmony_ci NULL, 0), 3878c2ecf20Sopenharmony_ci SND_SOC_DAPM_SUPPLY_S(I2S5_HD_EN_W_NAME, SUPPLY_SEQ_I2S_HD_EN, 3888c2ecf20Sopenharmony_ci AFE_I2S_CON4, I2S5_HD_EN_SFT, 0, 3898c2ecf20Sopenharmony_ci NULL, 0), 3908c2ecf20Sopenharmony_ci 3918c2ecf20Sopenharmony_ci /* i2s mclk en */ 3928c2ecf20Sopenharmony_ci SND_SOC_DAPM_SUPPLY_S(I2S0_MCLK_EN_W_NAME, SUPPLY_SEQ_I2S_MCLK_EN, 3938c2ecf20Sopenharmony_ci SND_SOC_NOPM, 0, 0, 3948c2ecf20Sopenharmony_ci mtk_mclk_en_event, 3958c2ecf20Sopenharmony_ci SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), 3968c2ecf20Sopenharmony_ci SND_SOC_DAPM_SUPPLY_S(I2S1_MCLK_EN_W_NAME, SUPPLY_SEQ_I2S_MCLK_EN, 3978c2ecf20Sopenharmony_ci SND_SOC_NOPM, 0, 0, 3988c2ecf20Sopenharmony_ci mtk_mclk_en_event, 3998c2ecf20Sopenharmony_ci SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), 4008c2ecf20Sopenharmony_ci SND_SOC_DAPM_SUPPLY_S(I2S2_MCLK_EN_W_NAME, SUPPLY_SEQ_I2S_MCLK_EN, 4018c2ecf20Sopenharmony_ci SND_SOC_NOPM, 0, 0, 4028c2ecf20Sopenharmony_ci mtk_mclk_en_event, 4038c2ecf20Sopenharmony_ci SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), 4048c2ecf20Sopenharmony_ci SND_SOC_DAPM_SUPPLY_S(I2S3_MCLK_EN_W_NAME, SUPPLY_SEQ_I2S_MCLK_EN, 4058c2ecf20Sopenharmony_ci SND_SOC_NOPM, 0, 0, 4068c2ecf20Sopenharmony_ci mtk_mclk_en_event, 4078c2ecf20Sopenharmony_ci SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), 4088c2ecf20Sopenharmony_ci SND_SOC_DAPM_SUPPLY_S(I2S5_MCLK_EN_W_NAME, SUPPLY_SEQ_I2S_MCLK_EN, 4098c2ecf20Sopenharmony_ci SND_SOC_NOPM, 0, 0, 4108c2ecf20Sopenharmony_ci mtk_mclk_en_event, 4118c2ecf20Sopenharmony_ci SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), 4128c2ecf20Sopenharmony_ci 4138c2ecf20Sopenharmony_ci /* apll */ 4148c2ecf20Sopenharmony_ci SND_SOC_DAPM_SUPPLY_S(APLL1_W_NAME, SUPPLY_SEQ_APLL, 4158c2ecf20Sopenharmony_ci SND_SOC_NOPM, 0, 0, 4168c2ecf20Sopenharmony_ci mtk_apll_event, 4178c2ecf20Sopenharmony_ci SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), 4188c2ecf20Sopenharmony_ci SND_SOC_DAPM_SUPPLY_S(APLL2_W_NAME, SUPPLY_SEQ_APLL, 4198c2ecf20Sopenharmony_ci SND_SOC_NOPM, 0, 0, 4208c2ecf20Sopenharmony_ci mtk_apll_event, 4218c2ecf20Sopenharmony_ci SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), 4228c2ecf20Sopenharmony_ci}; 4238c2ecf20Sopenharmony_ci 4248c2ecf20Sopenharmony_cistatic int mtk_afe_i2s_share_connect(struct snd_soc_dapm_widget *source, 4258c2ecf20Sopenharmony_ci struct snd_soc_dapm_widget *sink) 4268c2ecf20Sopenharmony_ci{ 4278c2ecf20Sopenharmony_ci struct snd_soc_dapm_widget *w = sink; 4288c2ecf20Sopenharmony_ci struct snd_soc_component *cmpnt = snd_soc_dapm_to_component(w->dapm); 4298c2ecf20Sopenharmony_ci struct mtk_base_afe *afe = snd_soc_component_get_drvdata(cmpnt); 4308c2ecf20Sopenharmony_ci struct mtk_afe_i2s_priv *i2s_priv; 4318c2ecf20Sopenharmony_ci 4328c2ecf20Sopenharmony_ci i2s_priv = get_i2s_priv_by_name(afe, sink->name); 4338c2ecf20Sopenharmony_ci 4348c2ecf20Sopenharmony_ci if (!i2s_priv) { 4358c2ecf20Sopenharmony_ci dev_warn(afe->dev, "%s(), i2s_priv == NULL", __func__); 4368c2ecf20Sopenharmony_ci return 0; 4378c2ecf20Sopenharmony_ci } 4388c2ecf20Sopenharmony_ci 4398c2ecf20Sopenharmony_ci if (i2s_priv->share_i2s_id < 0) 4408c2ecf20Sopenharmony_ci return 0; 4418c2ecf20Sopenharmony_ci 4428c2ecf20Sopenharmony_ci return i2s_priv->share_i2s_id == get_i2s_id_by_name(afe, source->name); 4438c2ecf20Sopenharmony_ci} 4448c2ecf20Sopenharmony_ci 4458c2ecf20Sopenharmony_cistatic int mtk_afe_i2s_hd_connect(struct snd_soc_dapm_widget *source, 4468c2ecf20Sopenharmony_ci struct snd_soc_dapm_widget *sink) 4478c2ecf20Sopenharmony_ci{ 4488c2ecf20Sopenharmony_ci struct snd_soc_dapm_widget *w = sink; 4498c2ecf20Sopenharmony_ci struct snd_soc_component *cmpnt = snd_soc_dapm_to_component(w->dapm); 4508c2ecf20Sopenharmony_ci struct mtk_base_afe *afe = snd_soc_component_get_drvdata(cmpnt); 4518c2ecf20Sopenharmony_ci struct mtk_afe_i2s_priv *i2s_priv; 4528c2ecf20Sopenharmony_ci 4538c2ecf20Sopenharmony_ci i2s_priv = get_i2s_priv_by_name(afe, sink->name); 4548c2ecf20Sopenharmony_ci 4558c2ecf20Sopenharmony_ci if (!i2s_priv) { 4568c2ecf20Sopenharmony_ci dev_warn(afe->dev, "%s(), i2s_priv == NULL", __func__); 4578c2ecf20Sopenharmony_ci return 0; 4588c2ecf20Sopenharmony_ci } 4598c2ecf20Sopenharmony_ci 4608c2ecf20Sopenharmony_ci if (get_i2s_id_by_name(afe, sink->name) == 4618c2ecf20Sopenharmony_ci get_i2s_id_by_name(afe, source->name)) 4628c2ecf20Sopenharmony_ci return i2s_priv->low_jitter_en; 4638c2ecf20Sopenharmony_ci 4648c2ecf20Sopenharmony_ci /* check if share i2s need hd en */ 4658c2ecf20Sopenharmony_ci if (i2s_priv->share_i2s_id < 0) 4668c2ecf20Sopenharmony_ci return 0; 4678c2ecf20Sopenharmony_ci 4688c2ecf20Sopenharmony_ci if (i2s_priv->share_i2s_id == get_i2s_id_by_name(afe, source->name)) 4698c2ecf20Sopenharmony_ci return i2s_priv->low_jitter_en; 4708c2ecf20Sopenharmony_ci 4718c2ecf20Sopenharmony_ci return 0; 4728c2ecf20Sopenharmony_ci} 4738c2ecf20Sopenharmony_ci 4748c2ecf20Sopenharmony_cistatic int mtk_afe_i2s_apll_connect(struct snd_soc_dapm_widget *source, 4758c2ecf20Sopenharmony_ci struct snd_soc_dapm_widget *sink) 4768c2ecf20Sopenharmony_ci{ 4778c2ecf20Sopenharmony_ci struct snd_soc_dapm_widget *w = sink; 4788c2ecf20Sopenharmony_ci struct snd_soc_component *cmpnt = snd_soc_dapm_to_component(w->dapm); 4798c2ecf20Sopenharmony_ci struct mtk_base_afe *afe = snd_soc_component_get_drvdata(cmpnt); 4808c2ecf20Sopenharmony_ci struct mtk_afe_i2s_priv *i2s_priv; 4818c2ecf20Sopenharmony_ci int cur_apll; 4828c2ecf20Sopenharmony_ci int i2s_need_apll; 4838c2ecf20Sopenharmony_ci 4848c2ecf20Sopenharmony_ci i2s_priv = get_i2s_priv_by_name(afe, w->name); 4858c2ecf20Sopenharmony_ci 4868c2ecf20Sopenharmony_ci if (!i2s_priv) { 4878c2ecf20Sopenharmony_ci dev_warn(afe->dev, "%s(), i2s_priv == NULL", __func__); 4888c2ecf20Sopenharmony_ci return 0; 4898c2ecf20Sopenharmony_ci } 4908c2ecf20Sopenharmony_ci 4918c2ecf20Sopenharmony_ci /* which apll */ 4928c2ecf20Sopenharmony_ci cur_apll = mt8183_get_apll_by_name(afe, source->name); 4938c2ecf20Sopenharmony_ci 4948c2ecf20Sopenharmony_ci /* choose APLL from i2s rate */ 4958c2ecf20Sopenharmony_ci i2s_need_apll = mt8183_get_apll_by_rate(afe, i2s_priv->rate); 4968c2ecf20Sopenharmony_ci 4978c2ecf20Sopenharmony_ci return (i2s_need_apll == cur_apll) ? 1 : 0; 4988c2ecf20Sopenharmony_ci} 4998c2ecf20Sopenharmony_ci 5008c2ecf20Sopenharmony_cistatic int mtk_afe_i2s_mclk_connect(struct snd_soc_dapm_widget *source, 5018c2ecf20Sopenharmony_ci struct snd_soc_dapm_widget *sink) 5028c2ecf20Sopenharmony_ci{ 5038c2ecf20Sopenharmony_ci struct snd_soc_dapm_widget *w = sink; 5048c2ecf20Sopenharmony_ci struct snd_soc_component *cmpnt = snd_soc_dapm_to_component(w->dapm); 5058c2ecf20Sopenharmony_ci struct mtk_base_afe *afe = snd_soc_component_get_drvdata(cmpnt); 5068c2ecf20Sopenharmony_ci struct mtk_afe_i2s_priv *i2s_priv; 5078c2ecf20Sopenharmony_ci 5088c2ecf20Sopenharmony_ci i2s_priv = get_i2s_priv_by_name(afe, sink->name); 5098c2ecf20Sopenharmony_ci 5108c2ecf20Sopenharmony_ci if (!i2s_priv) { 5118c2ecf20Sopenharmony_ci dev_warn(afe->dev, "%s(), i2s_priv == NULL", __func__); 5128c2ecf20Sopenharmony_ci return 0; 5138c2ecf20Sopenharmony_ci } 5148c2ecf20Sopenharmony_ci 5158c2ecf20Sopenharmony_ci if (get_i2s_id_by_name(afe, sink->name) == 5168c2ecf20Sopenharmony_ci get_i2s_id_by_name(afe, source->name)) 5178c2ecf20Sopenharmony_ci return (i2s_priv->mclk_rate > 0) ? 1 : 0; 5188c2ecf20Sopenharmony_ci 5198c2ecf20Sopenharmony_ci /* check if share i2s need mclk */ 5208c2ecf20Sopenharmony_ci if (i2s_priv->share_i2s_id < 0) 5218c2ecf20Sopenharmony_ci return 0; 5228c2ecf20Sopenharmony_ci 5238c2ecf20Sopenharmony_ci if (i2s_priv->share_i2s_id == get_i2s_id_by_name(afe, source->name)) 5248c2ecf20Sopenharmony_ci return (i2s_priv->mclk_rate > 0) ? 1 : 0; 5258c2ecf20Sopenharmony_ci 5268c2ecf20Sopenharmony_ci return 0; 5278c2ecf20Sopenharmony_ci} 5288c2ecf20Sopenharmony_ci 5298c2ecf20Sopenharmony_cistatic int mtk_afe_mclk_apll_connect(struct snd_soc_dapm_widget *source, 5308c2ecf20Sopenharmony_ci struct snd_soc_dapm_widget *sink) 5318c2ecf20Sopenharmony_ci{ 5328c2ecf20Sopenharmony_ci struct snd_soc_dapm_widget *w = sink; 5338c2ecf20Sopenharmony_ci struct snd_soc_component *cmpnt = snd_soc_dapm_to_component(w->dapm); 5348c2ecf20Sopenharmony_ci struct mtk_base_afe *afe = snd_soc_component_get_drvdata(cmpnt); 5358c2ecf20Sopenharmony_ci struct mtk_afe_i2s_priv *i2s_priv; 5368c2ecf20Sopenharmony_ci int cur_apll; 5378c2ecf20Sopenharmony_ci 5388c2ecf20Sopenharmony_ci i2s_priv = get_i2s_priv_by_name(afe, w->name); 5398c2ecf20Sopenharmony_ci 5408c2ecf20Sopenharmony_ci if (!i2s_priv) { 5418c2ecf20Sopenharmony_ci dev_warn(afe->dev, "%s(), i2s_priv == NULL", __func__); 5428c2ecf20Sopenharmony_ci return 0; 5438c2ecf20Sopenharmony_ci } 5448c2ecf20Sopenharmony_ci 5458c2ecf20Sopenharmony_ci /* which apll */ 5468c2ecf20Sopenharmony_ci cur_apll = mt8183_get_apll_by_name(afe, source->name); 5478c2ecf20Sopenharmony_ci 5488c2ecf20Sopenharmony_ci return (i2s_priv->mclk_apll == cur_apll) ? 1 : 0; 5498c2ecf20Sopenharmony_ci} 5508c2ecf20Sopenharmony_ci 5518c2ecf20Sopenharmony_cistatic const struct snd_soc_dapm_route mtk_dai_i2s_routes[] = { 5528c2ecf20Sopenharmony_ci /* i2s0 */ 5538c2ecf20Sopenharmony_ci {"I2S0", NULL, "I2S0_EN"}, 5548c2ecf20Sopenharmony_ci {"I2S0", NULL, "I2S1_EN", mtk_afe_i2s_share_connect}, 5558c2ecf20Sopenharmony_ci {"I2S0", NULL, "I2S2_EN", mtk_afe_i2s_share_connect}, 5568c2ecf20Sopenharmony_ci {"I2S0", NULL, "I2S3_EN", mtk_afe_i2s_share_connect}, 5578c2ecf20Sopenharmony_ci {"I2S0", NULL, "I2S5_EN", mtk_afe_i2s_share_connect}, 5588c2ecf20Sopenharmony_ci 5598c2ecf20Sopenharmony_ci {"I2S0", NULL, I2S0_HD_EN_W_NAME, mtk_afe_i2s_hd_connect}, 5608c2ecf20Sopenharmony_ci {"I2S0", NULL, I2S1_HD_EN_W_NAME, mtk_afe_i2s_hd_connect}, 5618c2ecf20Sopenharmony_ci {"I2S0", NULL, I2S2_HD_EN_W_NAME, mtk_afe_i2s_hd_connect}, 5628c2ecf20Sopenharmony_ci {"I2S0", NULL, I2S3_HD_EN_W_NAME, mtk_afe_i2s_hd_connect}, 5638c2ecf20Sopenharmony_ci {"I2S0", NULL, I2S5_HD_EN_W_NAME, mtk_afe_i2s_hd_connect}, 5648c2ecf20Sopenharmony_ci {I2S0_HD_EN_W_NAME, NULL, APLL1_W_NAME, mtk_afe_i2s_apll_connect}, 5658c2ecf20Sopenharmony_ci {I2S0_HD_EN_W_NAME, NULL, APLL2_W_NAME, mtk_afe_i2s_apll_connect}, 5668c2ecf20Sopenharmony_ci 5678c2ecf20Sopenharmony_ci {"I2S0", NULL, I2S0_MCLK_EN_W_NAME, mtk_afe_i2s_mclk_connect}, 5688c2ecf20Sopenharmony_ci {"I2S0", NULL, I2S1_MCLK_EN_W_NAME, mtk_afe_i2s_mclk_connect}, 5698c2ecf20Sopenharmony_ci {"I2S0", NULL, I2S2_MCLK_EN_W_NAME, mtk_afe_i2s_mclk_connect}, 5708c2ecf20Sopenharmony_ci {"I2S0", NULL, I2S3_MCLK_EN_W_NAME, mtk_afe_i2s_mclk_connect}, 5718c2ecf20Sopenharmony_ci {"I2S0", NULL, I2S5_MCLK_EN_W_NAME, mtk_afe_i2s_mclk_connect}, 5728c2ecf20Sopenharmony_ci {I2S0_MCLK_EN_W_NAME, NULL, APLL1_W_NAME, mtk_afe_mclk_apll_connect}, 5738c2ecf20Sopenharmony_ci {I2S0_MCLK_EN_W_NAME, NULL, APLL2_W_NAME, mtk_afe_mclk_apll_connect}, 5748c2ecf20Sopenharmony_ci 5758c2ecf20Sopenharmony_ci /* i2s1 */ 5768c2ecf20Sopenharmony_ci {"I2S1_CH1", "DL1_CH1", "DL1"}, 5778c2ecf20Sopenharmony_ci {"I2S1_CH2", "DL1_CH2", "DL1"}, 5788c2ecf20Sopenharmony_ci 5798c2ecf20Sopenharmony_ci {"I2S1_CH1", "DL2_CH1", "DL2"}, 5808c2ecf20Sopenharmony_ci {"I2S1_CH2", "DL2_CH2", "DL2"}, 5818c2ecf20Sopenharmony_ci 5828c2ecf20Sopenharmony_ci {"I2S1_CH1", "DL3_CH1", "DL3"}, 5838c2ecf20Sopenharmony_ci {"I2S1_CH2", "DL3_CH2", "DL3"}, 5848c2ecf20Sopenharmony_ci 5858c2ecf20Sopenharmony_ci {"I2S1", NULL, "I2S1_CH1"}, 5868c2ecf20Sopenharmony_ci {"I2S1", NULL, "I2S1_CH2"}, 5878c2ecf20Sopenharmony_ci 5888c2ecf20Sopenharmony_ci {"I2S1", NULL, "I2S0_EN", mtk_afe_i2s_share_connect}, 5898c2ecf20Sopenharmony_ci {"I2S1", NULL, "I2S1_EN"}, 5908c2ecf20Sopenharmony_ci {"I2S1", NULL, "I2S2_EN", mtk_afe_i2s_share_connect}, 5918c2ecf20Sopenharmony_ci {"I2S1", NULL, "I2S3_EN", mtk_afe_i2s_share_connect}, 5928c2ecf20Sopenharmony_ci {"I2S1", NULL, "I2S5_EN", mtk_afe_i2s_share_connect}, 5938c2ecf20Sopenharmony_ci 5948c2ecf20Sopenharmony_ci {"I2S1", NULL, I2S0_HD_EN_W_NAME, mtk_afe_i2s_hd_connect}, 5958c2ecf20Sopenharmony_ci {"I2S1", NULL, I2S1_HD_EN_W_NAME, mtk_afe_i2s_hd_connect}, 5968c2ecf20Sopenharmony_ci {"I2S1", NULL, I2S2_HD_EN_W_NAME, mtk_afe_i2s_hd_connect}, 5978c2ecf20Sopenharmony_ci {"I2S1", NULL, I2S3_HD_EN_W_NAME, mtk_afe_i2s_hd_connect}, 5988c2ecf20Sopenharmony_ci {"I2S1", NULL, I2S5_HD_EN_W_NAME, mtk_afe_i2s_hd_connect}, 5998c2ecf20Sopenharmony_ci {I2S1_HD_EN_W_NAME, NULL, APLL1_W_NAME, mtk_afe_i2s_apll_connect}, 6008c2ecf20Sopenharmony_ci {I2S1_HD_EN_W_NAME, NULL, APLL2_W_NAME, mtk_afe_i2s_apll_connect}, 6018c2ecf20Sopenharmony_ci 6028c2ecf20Sopenharmony_ci {"I2S1", NULL, I2S0_MCLK_EN_W_NAME, mtk_afe_i2s_mclk_connect}, 6038c2ecf20Sopenharmony_ci {"I2S1", NULL, I2S1_MCLK_EN_W_NAME, mtk_afe_i2s_mclk_connect}, 6048c2ecf20Sopenharmony_ci {"I2S1", NULL, I2S2_MCLK_EN_W_NAME, mtk_afe_i2s_mclk_connect}, 6058c2ecf20Sopenharmony_ci {"I2S1", NULL, I2S3_MCLK_EN_W_NAME, mtk_afe_i2s_mclk_connect}, 6068c2ecf20Sopenharmony_ci {"I2S1", NULL, I2S5_MCLK_EN_W_NAME, mtk_afe_i2s_mclk_connect}, 6078c2ecf20Sopenharmony_ci {I2S1_MCLK_EN_W_NAME, NULL, APLL1_W_NAME, mtk_afe_mclk_apll_connect}, 6088c2ecf20Sopenharmony_ci {I2S1_MCLK_EN_W_NAME, NULL, APLL2_W_NAME, mtk_afe_mclk_apll_connect}, 6098c2ecf20Sopenharmony_ci 6108c2ecf20Sopenharmony_ci /* i2s2 */ 6118c2ecf20Sopenharmony_ci {"I2S2", NULL, "I2S0_EN", mtk_afe_i2s_share_connect}, 6128c2ecf20Sopenharmony_ci {"I2S2", NULL, "I2S1_EN", mtk_afe_i2s_share_connect}, 6138c2ecf20Sopenharmony_ci {"I2S2", NULL, "I2S2_EN"}, 6148c2ecf20Sopenharmony_ci {"I2S2", NULL, "I2S3_EN", mtk_afe_i2s_share_connect}, 6158c2ecf20Sopenharmony_ci {"I2S2", NULL, "I2S5_EN", mtk_afe_i2s_share_connect}, 6168c2ecf20Sopenharmony_ci 6178c2ecf20Sopenharmony_ci {"I2S2", NULL, I2S0_HD_EN_W_NAME, mtk_afe_i2s_hd_connect}, 6188c2ecf20Sopenharmony_ci {"I2S2", NULL, I2S1_HD_EN_W_NAME, mtk_afe_i2s_hd_connect}, 6198c2ecf20Sopenharmony_ci {"I2S2", NULL, I2S2_HD_EN_W_NAME, mtk_afe_i2s_hd_connect}, 6208c2ecf20Sopenharmony_ci {"I2S2", NULL, I2S3_HD_EN_W_NAME, mtk_afe_i2s_hd_connect}, 6218c2ecf20Sopenharmony_ci {"I2S2", NULL, I2S5_HD_EN_W_NAME, mtk_afe_i2s_hd_connect}, 6228c2ecf20Sopenharmony_ci {I2S2_HD_EN_W_NAME, NULL, APLL1_W_NAME, mtk_afe_i2s_apll_connect}, 6238c2ecf20Sopenharmony_ci {I2S2_HD_EN_W_NAME, NULL, APLL2_W_NAME, mtk_afe_i2s_apll_connect}, 6248c2ecf20Sopenharmony_ci 6258c2ecf20Sopenharmony_ci {"I2S2", NULL, I2S0_MCLK_EN_W_NAME, mtk_afe_i2s_mclk_connect}, 6268c2ecf20Sopenharmony_ci {"I2S2", NULL, I2S1_MCLK_EN_W_NAME, mtk_afe_i2s_mclk_connect}, 6278c2ecf20Sopenharmony_ci {"I2S2", NULL, I2S2_MCLK_EN_W_NAME, mtk_afe_i2s_mclk_connect}, 6288c2ecf20Sopenharmony_ci {"I2S2", NULL, I2S3_MCLK_EN_W_NAME, mtk_afe_i2s_mclk_connect}, 6298c2ecf20Sopenharmony_ci {"I2S2", NULL, I2S5_MCLK_EN_W_NAME, mtk_afe_i2s_mclk_connect}, 6308c2ecf20Sopenharmony_ci {I2S2_MCLK_EN_W_NAME, NULL, APLL1_W_NAME, mtk_afe_mclk_apll_connect}, 6318c2ecf20Sopenharmony_ci {I2S2_MCLK_EN_W_NAME, NULL, APLL2_W_NAME, mtk_afe_mclk_apll_connect}, 6328c2ecf20Sopenharmony_ci 6338c2ecf20Sopenharmony_ci /* i2s3 */ 6348c2ecf20Sopenharmony_ci {"I2S3_CH1", "DL1_CH1", "DL1"}, 6358c2ecf20Sopenharmony_ci {"I2S3_CH2", "DL1_CH2", "DL1"}, 6368c2ecf20Sopenharmony_ci 6378c2ecf20Sopenharmony_ci {"I2S3_CH1", "DL2_CH1", "DL2"}, 6388c2ecf20Sopenharmony_ci {"I2S3_CH2", "DL2_CH2", "DL2"}, 6398c2ecf20Sopenharmony_ci 6408c2ecf20Sopenharmony_ci {"I2S3_CH1", "DL3_CH1", "DL3"}, 6418c2ecf20Sopenharmony_ci {"I2S3_CH2", "DL3_CH2", "DL3"}, 6428c2ecf20Sopenharmony_ci 6438c2ecf20Sopenharmony_ci {"I2S3", NULL, "I2S3_CH1"}, 6448c2ecf20Sopenharmony_ci {"I2S3", NULL, "I2S3_CH2"}, 6458c2ecf20Sopenharmony_ci 6468c2ecf20Sopenharmony_ci {"I2S3", NULL, "I2S0_EN", mtk_afe_i2s_share_connect}, 6478c2ecf20Sopenharmony_ci {"I2S3", NULL, "I2S1_EN", mtk_afe_i2s_share_connect}, 6488c2ecf20Sopenharmony_ci {"I2S3", NULL, "I2S2_EN", mtk_afe_i2s_share_connect}, 6498c2ecf20Sopenharmony_ci {"I2S3", NULL, "I2S3_EN"}, 6508c2ecf20Sopenharmony_ci {"I2S3", NULL, "I2S5_EN", mtk_afe_i2s_share_connect}, 6518c2ecf20Sopenharmony_ci 6528c2ecf20Sopenharmony_ci {"I2S3", NULL, I2S0_HD_EN_W_NAME, mtk_afe_i2s_hd_connect}, 6538c2ecf20Sopenharmony_ci {"I2S3", NULL, I2S1_HD_EN_W_NAME, mtk_afe_i2s_hd_connect}, 6548c2ecf20Sopenharmony_ci {"I2S3", NULL, I2S2_HD_EN_W_NAME, mtk_afe_i2s_hd_connect}, 6558c2ecf20Sopenharmony_ci {"I2S3", NULL, I2S3_HD_EN_W_NAME, mtk_afe_i2s_hd_connect}, 6568c2ecf20Sopenharmony_ci {"I2S3", NULL, I2S5_HD_EN_W_NAME, mtk_afe_i2s_hd_connect}, 6578c2ecf20Sopenharmony_ci {I2S3_HD_EN_W_NAME, NULL, APLL1_W_NAME, mtk_afe_i2s_apll_connect}, 6588c2ecf20Sopenharmony_ci {I2S3_HD_EN_W_NAME, NULL, APLL2_W_NAME, mtk_afe_i2s_apll_connect}, 6598c2ecf20Sopenharmony_ci 6608c2ecf20Sopenharmony_ci {"I2S3", NULL, I2S0_MCLK_EN_W_NAME, mtk_afe_i2s_mclk_connect}, 6618c2ecf20Sopenharmony_ci {"I2S3", NULL, I2S1_MCLK_EN_W_NAME, mtk_afe_i2s_mclk_connect}, 6628c2ecf20Sopenharmony_ci {"I2S3", NULL, I2S2_MCLK_EN_W_NAME, mtk_afe_i2s_mclk_connect}, 6638c2ecf20Sopenharmony_ci {"I2S3", NULL, I2S3_MCLK_EN_W_NAME, mtk_afe_i2s_mclk_connect}, 6648c2ecf20Sopenharmony_ci {"I2S3", NULL, I2S5_MCLK_EN_W_NAME, mtk_afe_i2s_mclk_connect}, 6658c2ecf20Sopenharmony_ci {I2S3_MCLK_EN_W_NAME, NULL, APLL1_W_NAME, mtk_afe_mclk_apll_connect}, 6668c2ecf20Sopenharmony_ci {I2S3_MCLK_EN_W_NAME, NULL, APLL2_W_NAME, mtk_afe_mclk_apll_connect}, 6678c2ecf20Sopenharmony_ci 6688c2ecf20Sopenharmony_ci /* i2s5 */ 6698c2ecf20Sopenharmony_ci {"I2S5_CH1", "DL1_CH1", "DL1"}, 6708c2ecf20Sopenharmony_ci {"I2S5_CH2", "DL1_CH2", "DL1"}, 6718c2ecf20Sopenharmony_ci 6728c2ecf20Sopenharmony_ci {"I2S5_CH1", "DL2_CH1", "DL2"}, 6738c2ecf20Sopenharmony_ci {"I2S5_CH2", "DL2_CH2", "DL2"}, 6748c2ecf20Sopenharmony_ci 6758c2ecf20Sopenharmony_ci {"I2S5_CH1", "DL3_CH1", "DL3"}, 6768c2ecf20Sopenharmony_ci {"I2S5_CH2", "DL3_CH2", "DL3"}, 6778c2ecf20Sopenharmony_ci 6788c2ecf20Sopenharmony_ci {"I2S5", NULL, "I2S5_CH1"}, 6798c2ecf20Sopenharmony_ci {"I2S5", NULL, "I2S5_CH2"}, 6808c2ecf20Sopenharmony_ci 6818c2ecf20Sopenharmony_ci {"I2S5", NULL, "I2S0_EN", mtk_afe_i2s_share_connect}, 6828c2ecf20Sopenharmony_ci {"I2S5", NULL, "I2S1_EN", mtk_afe_i2s_share_connect}, 6838c2ecf20Sopenharmony_ci {"I2S5", NULL, "I2S2_EN", mtk_afe_i2s_share_connect}, 6848c2ecf20Sopenharmony_ci {"I2S5", NULL, "I2S3_EN", mtk_afe_i2s_share_connect}, 6858c2ecf20Sopenharmony_ci {"I2S5", NULL, "I2S5_EN"}, 6868c2ecf20Sopenharmony_ci 6878c2ecf20Sopenharmony_ci {"I2S5", NULL, I2S0_HD_EN_W_NAME, mtk_afe_i2s_hd_connect}, 6888c2ecf20Sopenharmony_ci {"I2S5", NULL, I2S1_HD_EN_W_NAME, mtk_afe_i2s_hd_connect}, 6898c2ecf20Sopenharmony_ci {"I2S5", NULL, I2S2_HD_EN_W_NAME, mtk_afe_i2s_hd_connect}, 6908c2ecf20Sopenharmony_ci {"I2S5", NULL, I2S3_HD_EN_W_NAME, mtk_afe_i2s_hd_connect}, 6918c2ecf20Sopenharmony_ci {"I2S5", NULL, I2S5_HD_EN_W_NAME, mtk_afe_i2s_hd_connect}, 6928c2ecf20Sopenharmony_ci {I2S5_HD_EN_W_NAME, NULL, APLL1_W_NAME, mtk_afe_i2s_apll_connect}, 6938c2ecf20Sopenharmony_ci {I2S5_HD_EN_W_NAME, NULL, APLL2_W_NAME, mtk_afe_i2s_apll_connect}, 6948c2ecf20Sopenharmony_ci 6958c2ecf20Sopenharmony_ci {"I2S5", NULL, I2S0_MCLK_EN_W_NAME, mtk_afe_i2s_mclk_connect}, 6968c2ecf20Sopenharmony_ci {"I2S5", NULL, I2S1_MCLK_EN_W_NAME, mtk_afe_i2s_mclk_connect}, 6978c2ecf20Sopenharmony_ci {"I2S5", NULL, I2S2_MCLK_EN_W_NAME, mtk_afe_i2s_mclk_connect}, 6988c2ecf20Sopenharmony_ci {"I2S5", NULL, I2S3_MCLK_EN_W_NAME, mtk_afe_i2s_mclk_connect}, 6998c2ecf20Sopenharmony_ci {"I2S5", NULL, I2S5_MCLK_EN_W_NAME, mtk_afe_i2s_mclk_connect}, 7008c2ecf20Sopenharmony_ci {I2S5_MCLK_EN_W_NAME, NULL, APLL1_W_NAME, mtk_afe_mclk_apll_connect}, 7018c2ecf20Sopenharmony_ci {I2S5_MCLK_EN_W_NAME, NULL, APLL2_W_NAME, mtk_afe_mclk_apll_connect}, 7028c2ecf20Sopenharmony_ci}; 7038c2ecf20Sopenharmony_ci 7048c2ecf20Sopenharmony_ci/* dai ops */ 7058c2ecf20Sopenharmony_cistatic int mtk_dai_i2s_config(struct mtk_base_afe *afe, 7068c2ecf20Sopenharmony_ci struct snd_pcm_hw_params *params, 7078c2ecf20Sopenharmony_ci int i2s_id) 7088c2ecf20Sopenharmony_ci{ 7098c2ecf20Sopenharmony_ci struct mt8183_afe_private *afe_priv = afe->platform_priv; 7108c2ecf20Sopenharmony_ci struct mtk_afe_i2s_priv *i2s_priv = afe_priv->dai_priv[i2s_id]; 7118c2ecf20Sopenharmony_ci 7128c2ecf20Sopenharmony_ci unsigned int rate = params_rate(params); 7138c2ecf20Sopenharmony_ci unsigned int rate_reg = mt8183_rate_transform(afe->dev, 7148c2ecf20Sopenharmony_ci rate, i2s_id); 7158c2ecf20Sopenharmony_ci snd_pcm_format_t format = params_format(params); 7168c2ecf20Sopenharmony_ci unsigned int i2s_con = 0, fmt_con = I2S_FMT_I2S << I2S_FMT_SFT; 7178c2ecf20Sopenharmony_ci int ret = 0; 7188c2ecf20Sopenharmony_ci 7198c2ecf20Sopenharmony_ci dev_info(afe->dev, "%s(), id %d, rate %d, format %d\n", 7208c2ecf20Sopenharmony_ci __func__, 7218c2ecf20Sopenharmony_ci i2s_id, 7228c2ecf20Sopenharmony_ci rate, format); 7238c2ecf20Sopenharmony_ci 7248c2ecf20Sopenharmony_ci if (i2s_priv) { 7258c2ecf20Sopenharmony_ci i2s_priv->rate = rate; 7268c2ecf20Sopenharmony_ci 7278c2ecf20Sopenharmony_ci if (i2s_priv->use_eiaj) 7288c2ecf20Sopenharmony_ci fmt_con = I2S_FMT_EIAJ << I2S_FMT_SFT; 7298c2ecf20Sopenharmony_ci } else { 7308c2ecf20Sopenharmony_ci dev_warn(afe->dev, "%s(), i2s_priv == NULL", __func__); 7318c2ecf20Sopenharmony_ci } 7328c2ecf20Sopenharmony_ci 7338c2ecf20Sopenharmony_ci switch (i2s_id) { 7348c2ecf20Sopenharmony_ci case MT8183_DAI_I2S_0: 7358c2ecf20Sopenharmony_ci regmap_update_bits(afe->regmap, AFE_DAC_CON1, 7368c2ecf20Sopenharmony_ci I2S_MODE_MASK_SFT, rate_reg << I2S_MODE_SFT); 7378c2ecf20Sopenharmony_ci i2s_con = I2S_IN_PAD_IO_MUX << I2SIN_PAD_SEL_SFT; 7388c2ecf20Sopenharmony_ci i2s_con |= fmt_con; 7398c2ecf20Sopenharmony_ci i2s_con |= get_i2s_wlen(format) << I2S_WLEN_SFT; 7408c2ecf20Sopenharmony_ci regmap_update_bits(afe->regmap, AFE_I2S_CON, 7418c2ecf20Sopenharmony_ci 0xffffeffe, i2s_con); 7428c2ecf20Sopenharmony_ci break; 7438c2ecf20Sopenharmony_ci case MT8183_DAI_I2S_1: 7448c2ecf20Sopenharmony_ci i2s_con = I2S1_SEL_O28_O29 << I2S2_SEL_O03_O04_SFT; 7458c2ecf20Sopenharmony_ci i2s_con |= rate_reg << I2S2_OUT_MODE_SFT; 7468c2ecf20Sopenharmony_ci i2s_con |= fmt_con; 7478c2ecf20Sopenharmony_ci i2s_con |= get_i2s_wlen(format) << I2S2_WLEN_SFT; 7488c2ecf20Sopenharmony_ci regmap_update_bits(afe->regmap, AFE_I2S_CON1, 7498c2ecf20Sopenharmony_ci 0xffffeffe, i2s_con); 7508c2ecf20Sopenharmony_ci break; 7518c2ecf20Sopenharmony_ci case MT8183_DAI_I2S_2: 7528c2ecf20Sopenharmony_ci i2s_con = 8 << I2S3_UPDATE_WORD_SFT; 7538c2ecf20Sopenharmony_ci i2s_con |= rate_reg << I2S3_OUT_MODE_SFT; 7548c2ecf20Sopenharmony_ci i2s_con |= fmt_con; 7558c2ecf20Sopenharmony_ci i2s_con |= get_i2s_wlen(format) << I2S3_WLEN_SFT; 7568c2ecf20Sopenharmony_ci regmap_update_bits(afe->regmap, AFE_I2S_CON2, 7578c2ecf20Sopenharmony_ci 0xffffeffe, i2s_con); 7588c2ecf20Sopenharmony_ci break; 7598c2ecf20Sopenharmony_ci case MT8183_DAI_I2S_3: 7608c2ecf20Sopenharmony_ci i2s_con = rate_reg << I2S4_OUT_MODE_SFT; 7618c2ecf20Sopenharmony_ci i2s_con |= fmt_con; 7628c2ecf20Sopenharmony_ci i2s_con |= get_i2s_wlen(format) << I2S4_WLEN_SFT; 7638c2ecf20Sopenharmony_ci regmap_update_bits(afe->regmap, AFE_I2S_CON3, 7648c2ecf20Sopenharmony_ci 0xffffeffe, i2s_con); 7658c2ecf20Sopenharmony_ci break; 7668c2ecf20Sopenharmony_ci case MT8183_DAI_I2S_5: 7678c2ecf20Sopenharmony_ci i2s_con = rate_reg << I2S5_OUT_MODE_SFT; 7688c2ecf20Sopenharmony_ci i2s_con |= fmt_con; 7698c2ecf20Sopenharmony_ci i2s_con |= get_i2s_wlen(format) << I2S5_WLEN_SFT; 7708c2ecf20Sopenharmony_ci regmap_update_bits(afe->regmap, AFE_I2S_CON4, 7718c2ecf20Sopenharmony_ci 0xffffeffe, i2s_con); 7728c2ecf20Sopenharmony_ci break; 7738c2ecf20Sopenharmony_ci default: 7748c2ecf20Sopenharmony_ci dev_warn(afe->dev, "%s(), id %d not support\n", 7758c2ecf20Sopenharmony_ci __func__, i2s_id); 7768c2ecf20Sopenharmony_ci return -EINVAL; 7778c2ecf20Sopenharmony_ci } 7788c2ecf20Sopenharmony_ci 7798c2ecf20Sopenharmony_ci /* set share i2s */ 7808c2ecf20Sopenharmony_ci if (i2s_priv && i2s_priv->share_i2s_id >= 0) 7818c2ecf20Sopenharmony_ci ret = mtk_dai_i2s_config(afe, params, i2s_priv->share_i2s_id); 7828c2ecf20Sopenharmony_ci 7838c2ecf20Sopenharmony_ci return ret; 7848c2ecf20Sopenharmony_ci} 7858c2ecf20Sopenharmony_ci 7868c2ecf20Sopenharmony_cistatic int mtk_dai_i2s_hw_params(struct snd_pcm_substream *substream, 7878c2ecf20Sopenharmony_ci struct snd_pcm_hw_params *params, 7888c2ecf20Sopenharmony_ci struct snd_soc_dai *dai) 7898c2ecf20Sopenharmony_ci{ 7908c2ecf20Sopenharmony_ci struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai); 7918c2ecf20Sopenharmony_ci 7928c2ecf20Sopenharmony_ci return mtk_dai_i2s_config(afe, params, dai->id); 7938c2ecf20Sopenharmony_ci} 7948c2ecf20Sopenharmony_ci 7958c2ecf20Sopenharmony_cistatic int mtk_dai_i2s_set_sysclk(struct snd_soc_dai *dai, 7968c2ecf20Sopenharmony_ci int clk_id, unsigned int freq, int dir) 7978c2ecf20Sopenharmony_ci{ 7988c2ecf20Sopenharmony_ci struct mtk_base_afe *afe = dev_get_drvdata(dai->dev); 7998c2ecf20Sopenharmony_ci struct mt8183_afe_private *afe_priv = afe->platform_priv; 8008c2ecf20Sopenharmony_ci struct mtk_afe_i2s_priv *i2s_priv = afe_priv->dai_priv[dai->id]; 8018c2ecf20Sopenharmony_ci int apll; 8028c2ecf20Sopenharmony_ci int apll_rate; 8038c2ecf20Sopenharmony_ci 8048c2ecf20Sopenharmony_ci if (!i2s_priv) { 8058c2ecf20Sopenharmony_ci dev_warn(afe->dev, "%s(), i2s_priv == NULL", __func__); 8068c2ecf20Sopenharmony_ci return -EINVAL; 8078c2ecf20Sopenharmony_ci } 8088c2ecf20Sopenharmony_ci 8098c2ecf20Sopenharmony_ci if (dir != SND_SOC_CLOCK_OUT) { 8108c2ecf20Sopenharmony_ci dev_warn(afe->dev, "%s(), dir != SND_SOC_CLOCK_OUT", __func__); 8118c2ecf20Sopenharmony_ci return -EINVAL; 8128c2ecf20Sopenharmony_ci } 8138c2ecf20Sopenharmony_ci 8148c2ecf20Sopenharmony_ci dev_info(afe->dev, "%s(), freq %d\n", __func__, freq); 8158c2ecf20Sopenharmony_ci 8168c2ecf20Sopenharmony_ci apll = mt8183_get_apll_by_rate(afe, freq); 8178c2ecf20Sopenharmony_ci apll_rate = mt8183_get_apll_rate(afe, apll); 8188c2ecf20Sopenharmony_ci 8198c2ecf20Sopenharmony_ci if (freq > apll_rate) { 8208c2ecf20Sopenharmony_ci dev_warn(afe->dev, "%s(), freq > apll rate", __func__); 8218c2ecf20Sopenharmony_ci return -EINVAL; 8228c2ecf20Sopenharmony_ci } 8238c2ecf20Sopenharmony_ci 8248c2ecf20Sopenharmony_ci if (apll_rate % freq != 0) { 8258c2ecf20Sopenharmony_ci dev_warn(afe->dev, "%s(), APLL cannot generate freq Hz", 8268c2ecf20Sopenharmony_ci __func__); 8278c2ecf20Sopenharmony_ci return -EINVAL; 8288c2ecf20Sopenharmony_ci } 8298c2ecf20Sopenharmony_ci 8308c2ecf20Sopenharmony_ci i2s_priv->mclk_rate = freq; 8318c2ecf20Sopenharmony_ci i2s_priv->mclk_apll = apll; 8328c2ecf20Sopenharmony_ci 8338c2ecf20Sopenharmony_ci if (i2s_priv->share_i2s_id > 0) { 8348c2ecf20Sopenharmony_ci struct mtk_afe_i2s_priv *share_i2s_priv; 8358c2ecf20Sopenharmony_ci 8368c2ecf20Sopenharmony_ci share_i2s_priv = afe_priv->dai_priv[i2s_priv->share_i2s_id]; 8378c2ecf20Sopenharmony_ci if (!share_i2s_priv) { 8388c2ecf20Sopenharmony_ci dev_warn(afe->dev, "%s(), share_i2s_priv == NULL", 8398c2ecf20Sopenharmony_ci __func__); 8408c2ecf20Sopenharmony_ci return -EINVAL; 8418c2ecf20Sopenharmony_ci } 8428c2ecf20Sopenharmony_ci 8438c2ecf20Sopenharmony_ci share_i2s_priv->mclk_rate = i2s_priv->mclk_rate; 8448c2ecf20Sopenharmony_ci share_i2s_priv->mclk_apll = i2s_priv->mclk_apll; 8458c2ecf20Sopenharmony_ci } 8468c2ecf20Sopenharmony_ci 8478c2ecf20Sopenharmony_ci return 0; 8488c2ecf20Sopenharmony_ci} 8498c2ecf20Sopenharmony_ci 8508c2ecf20Sopenharmony_cistatic int mtk_dai_i2s_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) 8518c2ecf20Sopenharmony_ci{ 8528c2ecf20Sopenharmony_ci struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai); 8538c2ecf20Sopenharmony_ci struct mt8183_afe_private *afe_priv = afe->platform_priv; 8548c2ecf20Sopenharmony_ci struct mtk_afe_i2s_priv *i2s_priv; 8558c2ecf20Sopenharmony_ci 8568c2ecf20Sopenharmony_ci switch (dai->id) { 8578c2ecf20Sopenharmony_ci case MT8183_DAI_I2S_0: 8588c2ecf20Sopenharmony_ci case MT8183_DAI_I2S_1: 8598c2ecf20Sopenharmony_ci case MT8183_DAI_I2S_2: 8608c2ecf20Sopenharmony_ci case MT8183_DAI_I2S_3: 8618c2ecf20Sopenharmony_ci case MT8183_DAI_I2S_5: 8628c2ecf20Sopenharmony_ci break; 8638c2ecf20Sopenharmony_ci default: 8648c2ecf20Sopenharmony_ci dev_warn(afe->dev, "%s(), id %d not support\n", 8658c2ecf20Sopenharmony_ci __func__, dai->id); 8668c2ecf20Sopenharmony_ci return -EINVAL; 8678c2ecf20Sopenharmony_ci } 8688c2ecf20Sopenharmony_ci i2s_priv = afe_priv->dai_priv[dai->id]; 8698c2ecf20Sopenharmony_ci 8708c2ecf20Sopenharmony_ci switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { 8718c2ecf20Sopenharmony_ci case SND_SOC_DAIFMT_LEFT_J: 8728c2ecf20Sopenharmony_ci i2s_priv->use_eiaj = 1; 8738c2ecf20Sopenharmony_ci break; 8748c2ecf20Sopenharmony_ci case SND_SOC_DAIFMT_I2S: 8758c2ecf20Sopenharmony_ci i2s_priv->use_eiaj = 0; 8768c2ecf20Sopenharmony_ci break; 8778c2ecf20Sopenharmony_ci default: 8788c2ecf20Sopenharmony_ci dev_warn(afe->dev, "%s(), DAI format %d not support\n", 8798c2ecf20Sopenharmony_ci __func__, fmt & SND_SOC_DAIFMT_FORMAT_MASK); 8808c2ecf20Sopenharmony_ci return -EINVAL; 8818c2ecf20Sopenharmony_ci } 8828c2ecf20Sopenharmony_ci 8838c2ecf20Sopenharmony_ci return 0; 8848c2ecf20Sopenharmony_ci} 8858c2ecf20Sopenharmony_ci 8868c2ecf20Sopenharmony_cistatic const struct snd_soc_dai_ops mtk_dai_i2s_ops = { 8878c2ecf20Sopenharmony_ci .hw_params = mtk_dai_i2s_hw_params, 8888c2ecf20Sopenharmony_ci .set_sysclk = mtk_dai_i2s_set_sysclk, 8898c2ecf20Sopenharmony_ci .set_fmt = mtk_dai_i2s_set_fmt, 8908c2ecf20Sopenharmony_ci}; 8918c2ecf20Sopenharmony_ci 8928c2ecf20Sopenharmony_ci/* dai driver */ 8938c2ecf20Sopenharmony_ci#define MTK_I2S_RATES (SNDRV_PCM_RATE_8000_48000 |\ 8948c2ecf20Sopenharmony_ci SNDRV_PCM_RATE_88200 |\ 8958c2ecf20Sopenharmony_ci SNDRV_PCM_RATE_96000 |\ 8968c2ecf20Sopenharmony_ci SNDRV_PCM_RATE_176400 |\ 8978c2ecf20Sopenharmony_ci SNDRV_PCM_RATE_192000) 8988c2ecf20Sopenharmony_ci 8998c2ecf20Sopenharmony_ci#define MTK_I2S_FORMATS (SNDRV_PCM_FMTBIT_S16_LE |\ 9008c2ecf20Sopenharmony_ci SNDRV_PCM_FMTBIT_S24_LE |\ 9018c2ecf20Sopenharmony_ci SNDRV_PCM_FMTBIT_S32_LE) 9028c2ecf20Sopenharmony_ci 9038c2ecf20Sopenharmony_cistatic struct snd_soc_dai_driver mtk_dai_i2s_driver[] = { 9048c2ecf20Sopenharmony_ci { 9058c2ecf20Sopenharmony_ci .name = "I2S0", 9068c2ecf20Sopenharmony_ci .id = MT8183_DAI_I2S_0, 9078c2ecf20Sopenharmony_ci .capture = { 9088c2ecf20Sopenharmony_ci .stream_name = "I2S0", 9098c2ecf20Sopenharmony_ci .channels_min = 1, 9108c2ecf20Sopenharmony_ci .channels_max = 2, 9118c2ecf20Sopenharmony_ci .rates = MTK_I2S_RATES, 9128c2ecf20Sopenharmony_ci .formats = MTK_I2S_FORMATS, 9138c2ecf20Sopenharmony_ci }, 9148c2ecf20Sopenharmony_ci .ops = &mtk_dai_i2s_ops, 9158c2ecf20Sopenharmony_ci }, 9168c2ecf20Sopenharmony_ci { 9178c2ecf20Sopenharmony_ci .name = "I2S1", 9188c2ecf20Sopenharmony_ci .id = MT8183_DAI_I2S_1, 9198c2ecf20Sopenharmony_ci .playback = { 9208c2ecf20Sopenharmony_ci .stream_name = "I2S1", 9218c2ecf20Sopenharmony_ci .channels_min = 1, 9228c2ecf20Sopenharmony_ci .channels_max = 2, 9238c2ecf20Sopenharmony_ci .rates = MTK_I2S_RATES, 9248c2ecf20Sopenharmony_ci .formats = MTK_I2S_FORMATS, 9258c2ecf20Sopenharmony_ci }, 9268c2ecf20Sopenharmony_ci .ops = &mtk_dai_i2s_ops, 9278c2ecf20Sopenharmony_ci }, 9288c2ecf20Sopenharmony_ci { 9298c2ecf20Sopenharmony_ci .name = "I2S2", 9308c2ecf20Sopenharmony_ci .id = MT8183_DAI_I2S_2, 9318c2ecf20Sopenharmony_ci .capture = { 9328c2ecf20Sopenharmony_ci .stream_name = "I2S2", 9338c2ecf20Sopenharmony_ci .channels_min = 1, 9348c2ecf20Sopenharmony_ci .channels_max = 2, 9358c2ecf20Sopenharmony_ci .rates = MTK_I2S_RATES, 9368c2ecf20Sopenharmony_ci .formats = MTK_I2S_FORMATS, 9378c2ecf20Sopenharmony_ci }, 9388c2ecf20Sopenharmony_ci .ops = &mtk_dai_i2s_ops, 9398c2ecf20Sopenharmony_ci }, 9408c2ecf20Sopenharmony_ci { 9418c2ecf20Sopenharmony_ci .name = "I2S3", 9428c2ecf20Sopenharmony_ci .id = MT8183_DAI_I2S_3, 9438c2ecf20Sopenharmony_ci .playback = { 9448c2ecf20Sopenharmony_ci .stream_name = "I2S3", 9458c2ecf20Sopenharmony_ci .channels_min = 1, 9468c2ecf20Sopenharmony_ci .channels_max = 2, 9478c2ecf20Sopenharmony_ci .rates = MTK_I2S_RATES, 9488c2ecf20Sopenharmony_ci .formats = MTK_I2S_FORMATS, 9498c2ecf20Sopenharmony_ci }, 9508c2ecf20Sopenharmony_ci .ops = &mtk_dai_i2s_ops, 9518c2ecf20Sopenharmony_ci }, 9528c2ecf20Sopenharmony_ci { 9538c2ecf20Sopenharmony_ci .name = "I2S5", 9548c2ecf20Sopenharmony_ci .id = MT8183_DAI_I2S_5, 9558c2ecf20Sopenharmony_ci .playback = { 9568c2ecf20Sopenharmony_ci .stream_name = "I2S5", 9578c2ecf20Sopenharmony_ci .channels_min = 1, 9588c2ecf20Sopenharmony_ci .channels_max = 2, 9598c2ecf20Sopenharmony_ci .rates = MTK_I2S_RATES, 9608c2ecf20Sopenharmony_ci .formats = MTK_I2S_FORMATS, 9618c2ecf20Sopenharmony_ci }, 9628c2ecf20Sopenharmony_ci .ops = &mtk_dai_i2s_ops, 9638c2ecf20Sopenharmony_ci }, 9648c2ecf20Sopenharmony_ci}; 9658c2ecf20Sopenharmony_ci 9668c2ecf20Sopenharmony_ci/* this enum is merely for mtk_afe_i2s_priv declare */ 9678c2ecf20Sopenharmony_cienum { 9688c2ecf20Sopenharmony_ci DAI_I2S0 = 0, 9698c2ecf20Sopenharmony_ci DAI_I2S1, 9708c2ecf20Sopenharmony_ci DAI_I2S2, 9718c2ecf20Sopenharmony_ci DAI_I2S3, 9728c2ecf20Sopenharmony_ci DAI_I2S5, 9738c2ecf20Sopenharmony_ci DAI_I2S_NUM, 9748c2ecf20Sopenharmony_ci}; 9758c2ecf20Sopenharmony_ci 9768c2ecf20Sopenharmony_cistatic const struct mtk_afe_i2s_priv mt8183_i2s_priv[DAI_I2S_NUM] = { 9778c2ecf20Sopenharmony_ci [DAI_I2S0] = { 9788c2ecf20Sopenharmony_ci .id = MT8183_DAI_I2S_0, 9798c2ecf20Sopenharmony_ci .mclk_id = MT8183_I2S0_MCK, 9808c2ecf20Sopenharmony_ci .share_property_name = "i2s0-share", 9818c2ecf20Sopenharmony_ci .share_i2s_id = -1, 9828c2ecf20Sopenharmony_ci }, 9838c2ecf20Sopenharmony_ci [DAI_I2S1] = { 9848c2ecf20Sopenharmony_ci .id = MT8183_DAI_I2S_1, 9858c2ecf20Sopenharmony_ci .mclk_id = MT8183_I2S1_MCK, 9868c2ecf20Sopenharmony_ci .share_property_name = "i2s1-share", 9878c2ecf20Sopenharmony_ci .share_i2s_id = -1, 9888c2ecf20Sopenharmony_ci }, 9898c2ecf20Sopenharmony_ci [DAI_I2S2] = { 9908c2ecf20Sopenharmony_ci .id = MT8183_DAI_I2S_2, 9918c2ecf20Sopenharmony_ci .mclk_id = MT8183_I2S2_MCK, 9928c2ecf20Sopenharmony_ci .share_property_name = "i2s2-share", 9938c2ecf20Sopenharmony_ci .share_i2s_id = -1, 9948c2ecf20Sopenharmony_ci }, 9958c2ecf20Sopenharmony_ci [DAI_I2S3] = { 9968c2ecf20Sopenharmony_ci .id = MT8183_DAI_I2S_3, 9978c2ecf20Sopenharmony_ci .mclk_id = MT8183_I2S3_MCK, 9988c2ecf20Sopenharmony_ci .share_property_name = "i2s3-share", 9998c2ecf20Sopenharmony_ci .share_i2s_id = -1, 10008c2ecf20Sopenharmony_ci }, 10018c2ecf20Sopenharmony_ci [DAI_I2S5] = { 10028c2ecf20Sopenharmony_ci .id = MT8183_DAI_I2S_5, 10038c2ecf20Sopenharmony_ci .mclk_id = MT8183_I2S5_MCK, 10048c2ecf20Sopenharmony_ci .share_property_name = "i2s5-share", 10058c2ecf20Sopenharmony_ci .share_i2s_id = -1, 10068c2ecf20Sopenharmony_ci }, 10078c2ecf20Sopenharmony_ci}; 10088c2ecf20Sopenharmony_ci 10098c2ecf20Sopenharmony_cistatic int mt8183_dai_i2s_get_share(struct mtk_base_afe *afe) 10108c2ecf20Sopenharmony_ci{ 10118c2ecf20Sopenharmony_ci struct mt8183_afe_private *afe_priv = afe->platform_priv; 10128c2ecf20Sopenharmony_ci const struct device_node *of_node = afe->dev->of_node; 10138c2ecf20Sopenharmony_ci const char *of_str; 10148c2ecf20Sopenharmony_ci const char *property_name; 10158c2ecf20Sopenharmony_ci struct mtk_afe_i2s_priv *i2s_priv; 10168c2ecf20Sopenharmony_ci int i; 10178c2ecf20Sopenharmony_ci 10188c2ecf20Sopenharmony_ci for (i = 0; i < DAI_I2S_NUM; i++) { 10198c2ecf20Sopenharmony_ci i2s_priv = afe_priv->dai_priv[mt8183_i2s_priv[i].id]; 10208c2ecf20Sopenharmony_ci property_name = mt8183_i2s_priv[i].share_property_name; 10218c2ecf20Sopenharmony_ci if (of_property_read_string(of_node, property_name, &of_str)) 10228c2ecf20Sopenharmony_ci continue; 10238c2ecf20Sopenharmony_ci i2s_priv->share_i2s_id = get_i2s_id_by_name(afe, of_str); 10248c2ecf20Sopenharmony_ci } 10258c2ecf20Sopenharmony_ci 10268c2ecf20Sopenharmony_ci return 0; 10278c2ecf20Sopenharmony_ci} 10288c2ecf20Sopenharmony_ci 10298c2ecf20Sopenharmony_cistatic int mt8183_dai_i2s_set_priv(struct mtk_base_afe *afe) 10308c2ecf20Sopenharmony_ci{ 10318c2ecf20Sopenharmony_ci struct mt8183_afe_private *afe_priv = afe->platform_priv; 10328c2ecf20Sopenharmony_ci struct mtk_afe_i2s_priv *i2s_priv; 10338c2ecf20Sopenharmony_ci int i; 10348c2ecf20Sopenharmony_ci 10358c2ecf20Sopenharmony_ci for (i = 0; i < DAI_I2S_NUM; i++) { 10368c2ecf20Sopenharmony_ci i2s_priv = devm_kzalloc(afe->dev, 10378c2ecf20Sopenharmony_ci sizeof(struct mtk_afe_i2s_priv), 10388c2ecf20Sopenharmony_ci GFP_KERNEL); 10398c2ecf20Sopenharmony_ci if (!i2s_priv) 10408c2ecf20Sopenharmony_ci return -ENOMEM; 10418c2ecf20Sopenharmony_ci 10428c2ecf20Sopenharmony_ci memcpy(i2s_priv, &mt8183_i2s_priv[i], 10438c2ecf20Sopenharmony_ci sizeof(struct mtk_afe_i2s_priv)); 10448c2ecf20Sopenharmony_ci 10458c2ecf20Sopenharmony_ci afe_priv->dai_priv[mt8183_i2s_priv[i].id] = i2s_priv; 10468c2ecf20Sopenharmony_ci } 10478c2ecf20Sopenharmony_ci 10488c2ecf20Sopenharmony_ci return 0; 10498c2ecf20Sopenharmony_ci} 10508c2ecf20Sopenharmony_ci 10518c2ecf20Sopenharmony_ciint mt8183_dai_i2s_register(struct mtk_base_afe *afe) 10528c2ecf20Sopenharmony_ci{ 10538c2ecf20Sopenharmony_ci struct mtk_base_afe_dai *dai; 10548c2ecf20Sopenharmony_ci int ret; 10558c2ecf20Sopenharmony_ci 10568c2ecf20Sopenharmony_ci dai = devm_kzalloc(afe->dev, sizeof(*dai), GFP_KERNEL); 10578c2ecf20Sopenharmony_ci if (!dai) 10588c2ecf20Sopenharmony_ci return -ENOMEM; 10598c2ecf20Sopenharmony_ci 10608c2ecf20Sopenharmony_ci list_add(&dai->list, &afe->sub_dais); 10618c2ecf20Sopenharmony_ci 10628c2ecf20Sopenharmony_ci dai->dai_drivers = mtk_dai_i2s_driver; 10638c2ecf20Sopenharmony_ci dai->num_dai_drivers = ARRAY_SIZE(mtk_dai_i2s_driver); 10648c2ecf20Sopenharmony_ci 10658c2ecf20Sopenharmony_ci dai->controls = mtk_dai_i2s_controls; 10668c2ecf20Sopenharmony_ci dai->num_controls = ARRAY_SIZE(mtk_dai_i2s_controls); 10678c2ecf20Sopenharmony_ci dai->dapm_widgets = mtk_dai_i2s_widgets; 10688c2ecf20Sopenharmony_ci dai->num_dapm_widgets = ARRAY_SIZE(mtk_dai_i2s_widgets); 10698c2ecf20Sopenharmony_ci dai->dapm_routes = mtk_dai_i2s_routes; 10708c2ecf20Sopenharmony_ci dai->num_dapm_routes = ARRAY_SIZE(mtk_dai_i2s_routes); 10718c2ecf20Sopenharmony_ci 10728c2ecf20Sopenharmony_ci /* set all dai i2s private data */ 10738c2ecf20Sopenharmony_ci ret = mt8183_dai_i2s_set_priv(afe); 10748c2ecf20Sopenharmony_ci if (ret) 10758c2ecf20Sopenharmony_ci return ret; 10768c2ecf20Sopenharmony_ci 10778c2ecf20Sopenharmony_ci /* parse share i2s */ 10788c2ecf20Sopenharmony_ci ret = mt8183_dai_i2s_get_share(afe); 10798c2ecf20Sopenharmony_ci if (ret) 10808c2ecf20Sopenharmony_ci return ret; 10818c2ecf20Sopenharmony_ci 10828c2ecf20Sopenharmony_ci return 0; 10838c2ecf20Sopenharmony_ci} 1084