1e1991d10SAlexandre Mergnat // SPDX-License-Identifier: GPL-2.0 2e1991d10SAlexandre Mergnat /* 3e1991d10SAlexandre Mergnat * MediaTek 8365 ALSA SoC AFE platform driver 4e1991d10SAlexandre Mergnat * 5e1991d10SAlexandre Mergnat * Copyright (c) 2024 MediaTek Inc. 6e1991d10SAlexandre Mergnat * Authors: Jia Zeng <jia.zeng@mediatek.com> 7e1991d10SAlexandre Mergnat * Alexandre Mergnat <amergnat@baylibre.com> 8e1991d10SAlexandre Mergnat */ 9e1991d10SAlexandre Mergnat 10e1991d10SAlexandre Mergnat #include <linux/delay.h> 11e1991d10SAlexandre Mergnat #include <linux/module.h> 12e1991d10SAlexandre Mergnat #include <linux/of.h> 13e1991d10SAlexandre Mergnat #include <linux/of_address.h> 14e1991d10SAlexandre Mergnat #include <linux/dma-mapping.h> 15e1991d10SAlexandre Mergnat #include <linux/pm_runtime.h> 16e1991d10SAlexandre Mergnat #include <sound/soc.h> 17e1991d10SAlexandre Mergnat #include <sound/pcm_params.h> 18e1991d10SAlexandre Mergnat #include "mt8365-afe-common.h" 19e1991d10SAlexandre Mergnat #include "mt8365-afe-clk.h" 20e1991d10SAlexandre Mergnat #include "mt8365-reg.h" 21e1991d10SAlexandre Mergnat #include "../common/mtk-base-afe.h" 22e1991d10SAlexandre Mergnat #include "../common/mtk-afe-platform-driver.h" 23e1991d10SAlexandre Mergnat #include "../common/mtk-afe-fe-dai.h" 24e1991d10SAlexandre Mergnat 25e1991d10SAlexandre Mergnat #define AFE_BASE_END_OFFSET 8 26e1991d10SAlexandre Mergnat 27e1991d10SAlexandre Mergnat static unsigned int mCM2Input; 28e1991d10SAlexandre Mergnat 29e1991d10SAlexandre Mergnat static const unsigned int mt8365_afe_backup_list[] = { 30e1991d10SAlexandre Mergnat AUDIO_TOP_CON0, 31e1991d10SAlexandre Mergnat AFE_CONN0, 32e1991d10SAlexandre Mergnat AFE_CONN1, 33e1991d10SAlexandre Mergnat AFE_CONN3, 34e1991d10SAlexandre Mergnat AFE_CONN4, 35e1991d10SAlexandre Mergnat AFE_CONN5, 36e1991d10SAlexandre Mergnat AFE_CONN6, 37e1991d10SAlexandre Mergnat AFE_CONN7, 38e1991d10SAlexandre Mergnat AFE_CONN8, 39e1991d10SAlexandre Mergnat AFE_CONN9, 40e1991d10SAlexandre Mergnat AFE_CONN10, 41e1991d10SAlexandre Mergnat AFE_CONN11, 42e1991d10SAlexandre Mergnat AFE_CONN12, 43e1991d10SAlexandre Mergnat AFE_CONN13, 44e1991d10SAlexandre Mergnat AFE_CONN14, 45e1991d10SAlexandre Mergnat AFE_CONN15, 46e1991d10SAlexandre Mergnat AFE_CONN16, 47e1991d10SAlexandre Mergnat AFE_CONN17, 48e1991d10SAlexandre Mergnat AFE_CONN18, 49e1991d10SAlexandre Mergnat AFE_CONN19, 50e1991d10SAlexandre Mergnat AFE_CONN20, 51e1991d10SAlexandre Mergnat AFE_CONN21, 52e1991d10SAlexandre Mergnat AFE_CONN26, 53e1991d10SAlexandre Mergnat AFE_CONN27, 54e1991d10SAlexandre Mergnat AFE_CONN28, 55e1991d10SAlexandre Mergnat AFE_CONN29, 56e1991d10SAlexandre Mergnat AFE_CONN30, 57e1991d10SAlexandre Mergnat AFE_CONN31, 58e1991d10SAlexandre Mergnat AFE_CONN32, 59e1991d10SAlexandre Mergnat AFE_CONN33, 60e1991d10SAlexandre Mergnat AFE_CONN34, 61e1991d10SAlexandre Mergnat AFE_CONN35, 62e1991d10SAlexandre Mergnat AFE_CONN36, 63e1991d10SAlexandre Mergnat AFE_CONN_24BIT, 64e1991d10SAlexandre Mergnat AFE_CONN_24BIT_1, 65e1991d10SAlexandre Mergnat AFE_DAC_CON0, 66e1991d10SAlexandre Mergnat AFE_DAC_CON1, 67e1991d10SAlexandre Mergnat AFE_DL1_BASE, 68e1991d10SAlexandre Mergnat AFE_DL1_END, 69e1991d10SAlexandre Mergnat AFE_DL2_BASE, 70e1991d10SAlexandre Mergnat AFE_DL2_END, 71e1991d10SAlexandre Mergnat AFE_VUL_BASE, 72e1991d10SAlexandre Mergnat AFE_VUL_END, 73e1991d10SAlexandre Mergnat AFE_AWB_BASE, 74e1991d10SAlexandre Mergnat AFE_AWB_END, 75e1991d10SAlexandre Mergnat AFE_VUL3_BASE, 76e1991d10SAlexandre Mergnat AFE_VUL3_END, 77e1991d10SAlexandre Mergnat AFE_HDMI_OUT_BASE, 78e1991d10SAlexandre Mergnat AFE_HDMI_OUT_END, 79e1991d10SAlexandre Mergnat AFE_HDMI_IN_2CH_BASE, 80e1991d10SAlexandre Mergnat AFE_HDMI_IN_2CH_END, 81e1991d10SAlexandre Mergnat AFE_ADDA_UL_DL_CON0, 82e1991d10SAlexandre Mergnat AFE_ADDA_DL_SRC2_CON0, 83e1991d10SAlexandre Mergnat AFE_ADDA_DL_SRC2_CON1, 84e1991d10SAlexandre Mergnat AFE_I2S_CON, 85e1991d10SAlexandre Mergnat AFE_I2S_CON1, 86e1991d10SAlexandre Mergnat AFE_I2S_CON2, 87e1991d10SAlexandre Mergnat AFE_I2S_CON3, 88e1991d10SAlexandre Mergnat AFE_ADDA_UL_SRC_CON0, 89e1991d10SAlexandre Mergnat AFE_AUD_PAD_TOP, 90e1991d10SAlexandre Mergnat AFE_HD_ENGEN_ENABLE, 91e1991d10SAlexandre Mergnat }; 92e1991d10SAlexandre Mergnat 93e1991d10SAlexandre Mergnat static const struct snd_pcm_hardware mt8365_afe_hardware = { 94e1991d10SAlexandre Mergnat .info = (SNDRV_PCM_INFO_MMAP | 95e1991d10SAlexandre Mergnat SNDRV_PCM_INFO_INTERLEAVED | 96e1991d10SAlexandre Mergnat SNDRV_PCM_INFO_MMAP_VALID), 97e1991d10SAlexandre Mergnat .buffer_bytes_max = 256 * 1024, 98e1991d10SAlexandre Mergnat .period_bytes_min = 512, 99e1991d10SAlexandre Mergnat .period_bytes_max = 128 * 1024, 100e1991d10SAlexandre Mergnat .periods_min = 2, 101e1991d10SAlexandre Mergnat .periods_max = 256, 102e1991d10SAlexandre Mergnat .fifo_size = 0, 103e1991d10SAlexandre Mergnat }; 104e1991d10SAlexandre Mergnat 105e1991d10SAlexandre Mergnat struct mt8365_afe_rate { 106e1991d10SAlexandre Mergnat unsigned int rate; 107e1991d10SAlexandre Mergnat unsigned int reg_val; 108e1991d10SAlexandre Mergnat }; 109e1991d10SAlexandre Mergnat 110e1991d10SAlexandre Mergnat static const struct mt8365_afe_rate mt8365_afe_fs_rates[] = { 111e1991d10SAlexandre Mergnat { .rate = 8000, .reg_val = MT8365_FS_8K }, 112e1991d10SAlexandre Mergnat { .rate = 11025, .reg_val = MT8365_FS_11D025K }, 113e1991d10SAlexandre Mergnat { .rate = 12000, .reg_val = MT8365_FS_12K }, 114e1991d10SAlexandre Mergnat { .rate = 16000, .reg_val = MT8365_FS_16K }, 115e1991d10SAlexandre Mergnat { .rate = 22050, .reg_val = MT8365_FS_22D05K }, 116e1991d10SAlexandre Mergnat { .rate = 24000, .reg_val = MT8365_FS_24K }, 117e1991d10SAlexandre Mergnat { .rate = 32000, .reg_val = MT8365_FS_32K }, 118e1991d10SAlexandre Mergnat { .rate = 44100, .reg_val = MT8365_FS_44D1K }, 119e1991d10SAlexandre Mergnat { .rate = 48000, .reg_val = MT8365_FS_48K }, 120e1991d10SAlexandre Mergnat { .rate = 88200, .reg_val = MT8365_FS_88D2K }, 121e1991d10SAlexandre Mergnat { .rate = 96000, .reg_val = MT8365_FS_96K }, 122e1991d10SAlexandre Mergnat { .rate = 176400, .reg_val = MT8365_FS_176D4K }, 123e1991d10SAlexandre Mergnat { .rate = 192000, .reg_val = MT8365_FS_192K }, 124e1991d10SAlexandre Mergnat }; 125e1991d10SAlexandre Mergnat 126e1991d10SAlexandre Mergnat int mt8365_afe_fs_timing(unsigned int rate) 127e1991d10SAlexandre Mergnat { 128e1991d10SAlexandre Mergnat int i; 129e1991d10SAlexandre Mergnat 130e1991d10SAlexandre Mergnat for (i = 0; i < ARRAY_SIZE(mt8365_afe_fs_rates); i++) 131e1991d10SAlexandre Mergnat if (mt8365_afe_fs_rates[i].rate == rate) 132e1991d10SAlexandre Mergnat return mt8365_afe_fs_rates[i].reg_val; 133e1991d10SAlexandre Mergnat 134e1991d10SAlexandre Mergnat return -EINVAL; 135e1991d10SAlexandre Mergnat } 136e1991d10SAlexandre Mergnat 137e1991d10SAlexandre Mergnat bool mt8365_afe_rate_supported(unsigned int rate, unsigned int id) 138e1991d10SAlexandre Mergnat { 139e1991d10SAlexandre Mergnat switch (id) { 140e1991d10SAlexandre Mergnat case MT8365_AFE_IO_TDM_IN: 141e1991d10SAlexandre Mergnat if (rate >= 8000 && rate <= 192000) 142e1991d10SAlexandre Mergnat return true; 143e1991d10SAlexandre Mergnat break; 144e1991d10SAlexandre Mergnat case MT8365_AFE_IO_DMIC: 145e1991d10SAlexandre Mergnat if (rate >= 8000 && rate <= 48000) 146e1991d10SAlexandre Mergnat return true; 147e1991d10SAlexandre Mergnat break; 148e1991d10SAlexandre Mergnat default: 149e1991d10SAlexandre Mergnat break; 150e1991d10SAlexandre Mergnat } 151e1991d10SAlexandre Mergnat 152e1991d10SAlexandre Mergnat return false; 153e1991d10SAlexandre Mergnat } 154e1991d10SAlexandre Mergnat 155e1991d10SAlexandre Mergnat bool mt8365_afe_channel_supported(unsigned int channel, unsigned int id) 156e1991d10SAlexandre Mergnat { 157e1991d10SAlexandre Mergnat switch (id) { 158e1991d10SAlexandre Mergnat case MT8365_AFE_IO_TDM_IN: 159e1991d10SAlexandre Mergnat if (channel >= 1 && channel <= 8) 160e1991d10SAlexandre Mergnat return true; 161e1991d10SAlexandre Mergnat break; 162e1991d10SAlexandre Mergnat case MT8365_AFE_IO_DMIC: 163e1991d10SAlexandre Mergnat if (channel >= 1 && channel <= 8) 164e1991d10SAlexandre Mergnat return true; 165e1991d10SAlexandre Mergnat break; 166e1991d10SAlexandre Mergnat default: 167e1991d10SAlexandre Mergnat break; 168e1991d10SAlexandre Mergnat } 169e1991d10SAlexandre Mergnat 170e1991d10SAlexandre Mergnat return false; 171e1991d10SAlexandre Mergnat } 172e1991d10SAlexandre Mergnat 173*63157d99SMark Brown static bool mt8365_afe_clk_group_44k(int sample_rate) 174e1991d10SAlexandre Mergnat { 175e1991d10SAlexandre Mergnat if (sample_rate == 11025 || 176e1991d10SAlexandre Mergnat sample_rate == 22050 || 177e1991d10SAlexandre Mergnat sample_rate == 44100 || 178e1991d10SAlexandre Mergnat sample_rate == 88200 || 179e1991d10SAlexandre Mergnat sample_rate == 176400) 180e1991d10SAlexandre Mergnat return true; 181e1991d10SAlexandre Mergnat else 182e1991d10SAlexandre Mergnat return false; 183e1991d10SAlexandre Mergnat } 184e1991d10SAlexandre Mergnat 185*63157d99SMark Brown static bool mt8365_afe_clk_group_48k(int sample_rate) 186e1991d10SAlexandre Mergnat { 187e1991d10SAlexandre Mergnat return (!mt8365_afe_clk_group_44k(sample_rate)); 188e1991d10SAlexandre Mergnat } 189e1991d10SAlexandre Mergnat 190e1991d10SAlexandre Mergnat int mt8365_dai_set_priv(struct mtk_base_afe *afe, int id, 191e1991d10SAlexandre Mergnat int priv_size, const void *priv_data) 192e1991d10SAlexandre Mergnat { 193e1991d10SAlexandre Mergnat struct mt8365_afe_private *afe_priv = afe->platform_priv; 194e1991d10SAlexandre Mergnat void *temp_data; 195e1991d10SAlexandre Mergnat 196e1991d10SAlexandre Mergnat temp_data = devm_kzalloc(afe->dev, priv_size, GFP_KERNEL); 197e1991d10SAlexandre Mergnat if (!temp_data) 198e1991d10SAlexandre Mergnat return -ENOMEM; 199e1991d10SAlexandre Mergnat 200e1991d10SAlexandre Mergnat if (priv_data) 201e1991d10SAlexandre Mergnat memcpy(temp_data, priv_data, priv_size); 202e1991d10SAlexandre Mergnat 203e1991d10SAlexandre Mergnat afe_priv->dai_priv[id] = temp_data; 204e1991d10SAlexandre Mergnat 205e1991d10SAlexandre Mergnat return 0; 206e1991d10SAlexandre Mergnat } 207e1991d10SAlexandre Mergnat 208e1991d10SAlexandre Mergnat static int mt8365_afe_irq_direction_enable(struct mtk_base_afe *afe, 209e1991d10SAlexandre Mergnat int irq_id, int direction) 210e1991d10SAlexandre Mergnat { 211e1991d10SAlexandre Mergnat struct mtk_base_afe_irq *irq; 212e1991d10SAlexandre Mergnat 213e1991d10SAlexandre Mergnat if (irq_id >= MT8365_AFE_IRQ_NUM) 214e1991d10SAlexandre Mergnat return -1; 215e1991d10SAlexandre Mergnat 216e1991d10SAlexandre Mergnat irq = &afe->irqs[irq_id]; 217e1991d10SAlexandre Mergnat 218e1991d10SAlexandre Mergnat if (direction == MT8365_AFE_IRQ_DIR_MCU) { 219e1991d10SAlexandre Mergnat regmap_update_bits(afe->regmap, AFE_IRQ_MCU_DSP_EN, 220e1991d10SAlexandre Mergnat (1 << irq->irq_data->irq_clr_shift), 221e1991d10SAlexandre Mergnat 0); 222e1991d10SAlexandre Mergnat regmap_update_bits(afe->regmap, AFE_IRQ_MCU_EN, 223e1991d10SAlexandre Mergnat (1 << irq->irq_data->irq_clr_shift), 224e1991d10SAlexandre Mergnat (1 << irq->irq_data->irq_clr_shift)); 225e1991d10SAlexandre Mergnat } else if (direction == MT8365_AFE_IRQ_DIR_DSP) { 226e1991d10SAlexandre Mergnat regmap_update_bits(afe->regmap, AFE_IRQ_MCU_DSP_EN, 227e1991d10SAlexandre Mergnat (1 << irq->irq_data->irq_clr_shift), 228e1991d10SAlexandre Mergnat (1 << irq->irq_data->irq_clr_shift)); 229e1991d10SAlexandre Mergnat regmap_update_bits(afe->regmap, AFE_IRQ_MCU_EN, 230e1991d10SAlexandre Mergnat (1 << irq->irq_data->irq_clr_shift), 231e1991d10SAlexandre Mergnat 0); 232e1991d10SAlexandre Mergnat } else { 233e1991d10SAlexandre Mergnat regmap_update_bits(afe->regmap, AFE_IRQ_MCU_DSP_EN, 234e1991d10SAlexandre Mergnat (1 << irq->irq_data->irq_clr_shift), 235e1991d10SAlexandre Mergnat (1 << irq->irq_data->irq_clr_shift)); 236e1991d10SAlexandre Mergnat regmap_update_bits(afe->regmap, AFE_IRQ_MCU_EN, 237e1991d10SAlexandre Mergnat (1 << irq->irq_data->irq_clr_shift), 238e1991d10SAlexandre Mergnat (1 << irq->irq_data->irq_clr_shift)); 239e1991d10SAlexandre Mergnat } 240e1991d10SAlexandre Mergnat return 0; 241e1991d10SAlexandre Mergnat } 242e1991d10SAlexandre Mergnat 243e1991d10SAlexandre Mergnat static int mt8365_memif_fs(struct snd_pcm_substream *substream, 244e1991d10SAlexandre Mergnat unsigned int rate) 245e1991d10SAlexandre Mergnat { 246e1991d10SAlexandre Mergnat return mt8365_afe_fs_timing(rate); 247e1991d10SAlexandre Mergnat } 248e1991d10SAlexandre Mergnat 249e1991d10SAlexandre Mergnat static int mt8365_irq_fs(struct snd_pcm_substream *substream, 250e1991d10SAlexandre Mergnat unsigned int rate) 251e1991d10SAlexandre Mergnat { 252e1991d10SAlexandre Mergnat return mt8365_memif_fs(substream, rate); 253e1991d10SAlexandre Mergnat } 254e1991d10SAlexandre Mergnat 255e1991d10SAlexandre Mergnat static const struct mt8365_cm_ctrl_reg cm_ctrl_reg[MT8365_CM_NUM] = { 256e1991d10SAlexandre Mergnat [MT8365_CM1] = { 257e1991d10SAlexandre Mergnat .con0 = AFE_CM1_CON0, 258e1991d10SAlexandre Mergnat .con1 = AFE_CM1_CON1, 259e1991d10SAlexandre Mergnat .con2 = AFE_CM1_CON2, 260e1991d10SAlexandre Mergnat .con3 = AFE_CM1_CON3, 261e1991d10SAlexandre Mergnat .con4 = AFE_CM1_CON4, 262e1991d10SAlexandre Mergnat }, 263e1991d10SAlexandre Mergnat [MT8365_CM2] = { 264e1991d10SAlexandre Mergnat .con0 = AFE_CM2_CON0, 265e1991d10SAlexandre Mergnat .con1 = AFE_CM2_CON1, 266e1991d10SAlexandre Mergnat .con2 = AFE_CM2_CON2, 267e1991d10SAlexandre Mergnat .con3 = AFE_CM2_CON3, 268e1991d10SAlexandre Mergnat .con4 = AFE_CM2_CON4, 269e1991d10SAlexandre Mergnat } 270e1991d10SAlexandre Mergnat }; 271e1991d10SAlexandre Mergnat 272e1991d10SAlexandre Mergnat static int mt8365_afe_cm2_mux_conn(struct mtk_base_afe *afe) 273e1991d10SAlexandre Mergnat { 274e1991d10SAlexandre Mergnat struct mt8365_afe_private *afe_priv = afe->platform_priv; 275e1991d10SAlexandre Mergnat unsigned int input = afe_priv->cm2_mux_input; 276e1991d10SAlexandre Mergnat 277e1991d10SAlexandre Mergnat /* TDM_IN interconnect to CM2 */ 278e1991d10SAlexandre Mergnat regmap_update_bits(afe->regmap, AFE_CM2_CONN0, 279e1991d10SAlexandre Mergnat CM2_AFE_CM2_CONN_CFG1_MASK, 280e1991d10SAlexandre Mergnat CM2_AFE_CM2_CONN_CFG1(TDM_IN_CH0)); 281e1991d10SAlexandre Mergnat regmap_update_bits(afe->regmap, AFE_CM2_CONN0, 282e1991d10SAlexandre Mergnat CM2_AFE_CM2_CONN_CFG2_MASK, 283e1991d10SAlexandre Mergnat CM2_AFE_CM2_CONN_CFG2(TDM_IN_CH1)); 284e1991d10SAlexandre Mergnat regmap_update_bits(afe->regmap, AFE_CM2_CONN0, 285e1991d10SAlexandre Mergnat CM2_AFE_CM2_CONN_CFG3_MASK, 286e1991d10SAlexandre Mergnat CM2_AFE_CM2_CONN_CFG3(TDM_IN_CH2)); 287e1991d10SAlexandre Mergnat regmap_update_bits(afe->regmap, AFE_CM2_CONN0, 288e1991d10SAlexandre Mergnat CM2_AFE_CM2_CONN_CFG4_MASK, 289e1991d10SAlexandre Mergnat CM2_AFE_CM2_CONN_CFG4(TDM_IN_CH3)); 290e1991d10SAlexandre Mergnat regmap_update_bits(afe->regmap, AFE_CM2_CONN0, 291e1991d10SAlexandre Mergnat CM2_AFE_CM2_CONN_CFG5_MASK, 292e1991d10SAlexandre Mergnat CM2_AFE_CM2_CONN_CFG5(TDM_IN_CH4)); 293e1991d10SAlexandre Mergnat regmap_update_bits(afe->regmap, AFE_CM2_CONN0, 294e1991d10SAlexandre Mergnat CM2_AFE_CM2_CONN_CFG6_MASK, 295e1991d10SAlexandre Mergnat CM2_AFE_CM2_CONN_CFG6(TDM_IN_CH5)); 296e1991d10SAlexandre Mergnat regmap_update_bits(afe->regmap, AFE_CM2_CONN1, 297e1991d10SAlexandre Mergnat CM2_AFE_CM2_CONN_CFG7_MASK, 298e1991d10SAlexandre Mergnat CM2_AFE_CM2_CONN_CFG7(TDM_IN_CH6)); 299e1991d10SAlexandre Mergnat regmap_update_bits(afe->regmap, AFE_CM2_CONN1, 300e1991d10SAlexandre Mergnat CM2_AFE_CM2_CONN_CFG8_MASK, 301e1991d10SAlexandre Mergnat CM2_AFE_CM2_CONN_CFG8(TDM_IN_CH7)); 302e1991d10SAlexandre Mergnat 303e1991d10SAlexandre Mergnat /* ref data interconnect to CM2 */ 304e1991d10SAlexandre Mergnat if (input == MT8365_FROM_GASRC1) { 305e1991d10SAlexandre Mergnat regmap_update_bits(afe->regmap, AFE_CM2_CONN1, 306e1991d10SAlexandre Mergnat CM2_AFE_CM2_CONN_CFG9_MASK, 307e1991d10SAlexandre Mergnat CM2_AFE_CM2_CONN_CFG9(GENERAL1_ASRC_OUT_LCH)); 308e1991d10SAlexandre Mergnat regmap_update_bits(afe->regmap, AFE_CM2_CONN1, 309e1991d10SAlexandre Mergnat CM2_AFE_CM2_CONN_CFG10_MASK, 310e1991d10SAlexandre Mergnat CM2_AFE_CM2_CONN_CFG10(GENERAL1_ASRC_OUT_RCH)); 311e1991d10SAlexandre Mergnat } else if (input == MT8365_FROM_GASRC2) { 312e1991d10SAlexandre Mergnat regmap_update_bits(afe->regmap, AFE_CM2_CONN1, 313e1991d10SAlexandre Mergnat CM2_AFE_CM2_CONN_CFG9_MASK, 314e1991d10SAlexandre Mergnat CM2_AFE_CM2_CONN_CFG9(GENERAL2_ASRC_OUT_LCH)); 315e1991d10SAlexandre Mergnat regmap_update_bits(afe->regmap, AFE_CM2_CONN1, 316e1991d10SAlexandre Mergnat CM2_AFE_CM2_CONN_CFG10_MASK, 317e1991d10SAlexandre Mergnat CM2_AFE_CM2_CONN_CFG10(GENERAL2_ASRC_OUT_RCH)); 318e1991d10SAlexandre Mergnat } else if (input == MT8365_FROM_TDM_ASRC) { 319e1991d10SAlexandre Mergnat regmap_update_bits(afe->regmap, AFE_CM2_CONN1, 320e1991d10SAlexandre Mergnat CM2_AFE_CM2_CONN_CFG9_MASK, 321e1991d10SAlexandre Mergnat CM2_AFE_CM2_CONN_CFG9(TDM_OUT_ASRC_CH0)); 322e1991d10SAlexandre Mergnat regmap_update_bits(afe->regmap, AFE_CM2_CONN1, 323e1991d10SAlexandre Mergnat CM2_AFE_CM2_CONN_CFG10_MASK, 324e1991d10SAlexandre Mergnat CM2_AFE_CM2_CONN_CFG10(TDM_OUT_ASRC_CH1)); 325e1991d10SAlexandre Mergnat regmap_update_bits(afe->regmap, AFE_CM2_CONN1, 326e1991d10SAlexandre Mergnat CM2_AFE_CM2_CONN_CFG11_MASK, 327e1991d10SAlexandre Mergnat CM2_AFE_CM2_CONN_CFG11(TDM_OUT_ASRC_CH2)); 328e1991d10SAlexandre Mergnat regmap_update_bits(afe->regmap, AFE_CM2_CONN1, 329e1991d10SAlexandre Mergnat CM2_AFE_CM2_CONN_CFG12_MASK, 330e1991d10SAlexandre Mergnat CM2_AFE_CM2_CONN_CFG12(TDM_OUT_ASRC_CH3)); 331e1991d10SAlexandre Mergnat regmap_update_bits(afe->regmap, AFE_CM2_CONN2, 332e1991d10SAlexandre Mergnat CM2_AFE_CM2_CONN_CFG13_MASK, 333e1991d10SAlexandre Mergnat CM2_AFE_CM2_CONN_CFG13(TDM_OUT_ASRC_CH4)); 334e1991d10SAlexandre Mergnat regmap_update_bits(afe->regmap, AFE_CM2_CONN2, 335e1991d10SAlexandre Mergnat CM2_AFE_CM2_CONN_CFG14_MASK, 336e1991d10SAlexandre Mergnat CM2_AFE_CM2_CONN_CFG14(TDM_OUT_ASRC_CH5)); 337e1991d10SAlexandre Mergnat regmap_update_bits(afe->regmap, AFE_CM2_CONN2, 338e1991d10SAlexandre Mergnat CM2_AFE_CM2_CONN_CFG15_MASK, 339e1991d10SAlexandre Mergnat CM2_AFE_CM2_CONN_CFG15(TDM_OUT_ASRC_CH6)); 340e1991d10SAlexandre Mergnat regmap_update_bits(afe->regmap, AFE_CM2_CONN2, 341e1991d10SAlexandre Mergnat CM2_AFE_CM2_CONN_CFG16_MASK, 342e1991d10SAlexandre Mergnat CM2_AFE_CM2_CONN_CFG16(TDM_OUT_ASRC_CH7)); 343e1991d10SAlexandre Mergnat } else { 344e1991d10SAlexandre Mergnat dev_err(afe->dev, "%s wrong CM2 input %d\n", __func__, input); 345e1991d10SAlexandre Mergnat return -1; 346e1991d10SAlexandre Mergnat } 347e1991d10SAlexandre Mergnat 348e1991d10SAlexandre Mergnat return 0; 349e1991d10SAlexandre Mergnat } 350e1991d10SAlexandre Mergnat 351e1991d10SAlexandre Mergnat static int mt8365_afe_get_cm_update_cnt(struct mtk_base_afe *afe, 352e1991d10SAlexandre Mergnat enum mt8365_cm_num cmNum, 353e1991d10SAlexandre Mergnat unsigned int rate, unsigned int channel) 354e1991d10SAlexandre Mergnat { 355e1991d10SAlexandre Mergnat unsigned int total_cnt, div_cnt, ch_pair, best_cnt; 356e1991d10SAlexandre Mergnat unsigned int ch_update_cnt[MT8365_CM_UPDATA_CNT_SET]; 357e1991d10SAlexandre Mergnat int i; 358e1991d10SAlexandre Mergnat 359e1991d10SAlexandre Mergnat /* calculate cm update cnt 360e1991d10SAlexandre Mergnat * total_cnt = clk / fs, clk is 26m or 24m or 22m 361e1991d10SAlexandre Mergnat * div_cnt = total_cnt / ch_pair, max ch 16ch ,2ch is a set 362e1991d10SAlexandre Mergnat * best_cnt < div_cnt ,we set best_cnt = div_cnt -10 363e1991d10SAlexandre Mergnat * ch01 = best_cnt, ch23 = 2* ch01_up_cnt 364e1991d10SAlexandre Mergnat * ch45 = 3* ch01_up_cnt ...ch1415 = 8* ch01_up_cnt 365e1991d10SAlexandre Mergnat */ 366e1991d10SAlexandre Mergnat 367e1991d10SAlexandre Mergnat if (cmNum == MT8365_CM1) { 368e1991d10SAlexandre Mergnat total_cnt = MT8365_CLK_26M / rate; 369e1991d10SAlexandre Mergnat } else if (cmNum == MT8365_CM2) { 370e1991d10SAlexandre Mergnat if (mt8365_afe_clk_group_48k(rate)) 371e1991d10SAlexandre Mergnat total_cnt = MT8365_CLK_24M / rate; 372e1991d10SAlexandre Mergnat else 373e1991d10SAlexandre Mergnat total_cnt = MT8365_CLK_22M / rate; 374e1991d10SAlexandre Mergnat } else { 375e1991d10SAlexandre Mergnat return -1; 376e1991d10SAlexandre Mergnat } 377e1991d10SAlexandre Mergnat 378e1991d10SAlexandre Mergnat if (channel % 2) 379e1991d10SAlexandre Mergnat ch_pair = (channel / 2) + 1; 380e1991d10SAlexandre Mergnat else 381e1991d10SAlexandre Mergnat ch_pair = channel / 2; 382e1991d10SAlexandre Mergnat 383e1991d10SAlexandre Mergnat div_cnt = total_cnt / ch_pair; 384e1991d10SAlexandre Mergnat best_cnt = div_cnt - 10; 385e1991d10SAlexandre Mergnat 386e1991d10SAlexandre Mergnat if (best_cnt <= 0) 387e1991d10SAlexandre Mergnat return -1; 388e1991d10SAlexandre Mergnat 389e1991d10SAlexandre Mergnat for (i = 0; i < ch_pair; i++) 390e1991d10SAlexandre Mergnat ch_update_cnt[i] = (i + 1) * best_cnt; 391e1991d10SAlexandre Mergnat 392e1991d10SAlexandre Mergnat switch (channel) { 393e1991d10SAlexandre Mergnat case 16: 394e1991d10SAlexandre Mergnat fallthrough; 395e1991d10SAlexandre Mergnat case 15: 396e1991d10SAlexandre Mergnat regmap_update_bits(afe->regmap, cm_ctrl_reg[cmNum].con4, 397e1991d10SAlexandre Mergnat CM_AFE_CM_UPDATE_CNT2_MASK, 398e1991d10SAlexandre Mergnat CM_AFE_CM_UPDATE_CNT2(ch_update_cnt[7])); 399e1991d10SAlexandre Mergnat fallthrough; 400e1991d10SAlexandre Mergnat case 14: 401e1991d10SAlexandre Mergnat fallthrough; 402e1991d10SAlexandre Mergnat case 13: 403e1991d10SAlexandre Mergnat regmap_update_bits(afe->regmap, cm_ctrl_reg[cmNum].con4, 404e1991d10SAlexandre Mergnat CM_AFE_CM_UPDATE_CNT1_MASK, 405e1991d10SAlexandre Mergnat CM_AFE_CM_UPDATE_CNT1(ch_update_cnt[6])); 406e1991d10SAlexandre Mergnat fallthrough; 407e1991d10SAlexandre Mergnat case 12: 408e1991d10SAlexandre Mergnat fallthrough; 409e1991d10SAlexandre Mergnat case 11: 410e1991d10SAlexandre Mergnat regmap_update_bits(afe->regmap, cm_ctrl_reg[cmNum].con3, 411e1991d10SAlexandre Mergnat CM_AFE_CM_UPDATE_CNT2_MASK, 412e1991d10SAlexandre Mergnat CM_AFE_CM_UPDATE_CNT2(ch_update_cnt[5])); 413e1991d10SAlexandre Mergnat fallthrough; 414e1991d10SAlexandre Mergnat case 10: 415e1991d10SAlexandre Mergnat fallthrough; 416e1991d10SAlexandre Mergnat case 9: 417e1991d10SAlexandre Mergnat regmap_update_bits(afe->regmap, cm_ctrl_reg[cmNum].con3, 418e1991d10SAlexandre Mergnat CM_AFE_CM_UPDATE_CNT1_MASK, 419e1991d10SAlexandre Mergnat CM_AFE_CM_UPDATE_CNT1(ch_update_cnt[4])); 420e1991d10SAlexandre Mergnat fallthrough; 421e1991d10SAlexandre Mergnat case 8: 422e1991d10SAlexandre Mergnat fallthrough; 423e1991d10SAlexandre Mergnat case 7: 424e1991d10SAlexandre Mergnat regmap_update_bits(afe->regmap, cm_ctrl_reg[cmNum].con2, 425e1991d10SAlexandre Mergnat CM_AFE_CM_UPDATE_CNT2_MASK, 426e1991d10SAlexandre Mergnat CM_AFE_CM_UPDATE_CNT2(ch_update_cnt[3])); 427e1991d10SAlexandre Mergnat fallthrough; 428e1991d10SAlexandre Mergnat case 6: 429e1991d10SAlexandre Mergnat fallthrough; 430e1991d10SAlexandre Mergnat case 5: 431e1991d10SAlexandre Mergnat regmap_update_bits(afe->regmap, cm_ctrl_reg[cmNum].con2, 432e1991d10SAlexandre Mergnat CM_AFE_CM_UPDATE_CNT1_MASK, 433e1991d10SAlexandre Mergnat CM_AFE_CM_UPDATE_CNT1(ch_update_cnt[2])); 434e1991d10SAlexandre Mergnat fallthrough; 435e1991d10SAlexandre Mergnat case 4: 436e1991d10SAlexandre Mergnat fallthrough; 437e1991d10SAlexandre Mergnat case 3: 438e1991d10SAlexandre Mergnat regmap_update_bits(afe->regmap, cm_ctrl_reg[cmNum].con1, 439e1991d10SAlexandre Mergnat CM_AFE_CM_UPDATE_CNT2_MASK, 440e1991d10SAlexandre Mergnat CM_AFE_CM_UPDATE_CNT2(ch_update_cnt[1])); 441e1991d10SAlexandre Mergnat fallthrough; 442e1991d10SAlexandre Mergnat case 2: 443e1991d10SAlexandre Mergnat fallthrough; 444e1991d10SAlexandre Mergnat case 1: 445e1991d10SAlexandre Mergnat regmap_update_bits(afe->regmap, cm_ctrl_reg[cmNum].con1, 446e1991d10SAlexandre Mergnat CM_AFE_CM_UPDATE_CNT1_MASK, 447e1991d10SAlexandre Mergnat CM_AFE_CM_UPDATE_CNT1(ch_update_cnt[0])); 448e1991d10SAlexandre Mergnat break; 449e1991d10SAlexandre Mergnat default: 450e1991d10SAlexandre Mergnat return -1; 451e1991d10SAlexandre Mergnat } 452e1991d10SAlexandre Mergnat 453e1991d10SAlexandre Mergnat return 0; 454e1991d10SAlexandre Mergnat } 455e1991d10SAlexandre Mergnat 456e1991d10SAlexandre Mergnat static int mt8365_afe_configure_cm(struct mtk_base_afe *afe, 457e1991d10SAlexandre Mergnat enum mt8365_cm_num cmNum, 458e1991d10SAlexandre Mergnat unsigned int channels, 459e1991d10SAlexandre Mergnat unsigned int rate) 460e1991d10SAlexandre Mergnat { 461e1991d10SAlexandre Mergnat unsigned int val, mask; 462e1991d10SAlexandre Mergnat unsigned int fs = mt8365_afe_fs_timing(rate); 463e1991d10SAlexandre Mergnat 464e1991d10SAlexandre Mergnat val = FIELD_PREP(CM_AFE_CM_CH_NUM_MASK, (channels - 1)) | 465e1991d10SAlexandre Mergnat FIELD_PREP(CM_AFE_CM_START_DATA_MASK, 0); 466e1991d10SAlexandre Mergnat 467e1991d10SAlexandre Mergnat mask = CM_AFE_CM_CH_NUM_MASK | 468e1991d10SAlexandre Mergnat CM_AFE_CM_START_DATA_MASK; 469e1991d10SAlexandre Mergnat 470e1991d10SAlexandre Mergnat if (cmNum == MT8365_CM1) { 471e1991d10SAlexandre Mergnat val |= FIELD_PREP(CM_AFE_CM1_IN_MODE_MASK, fs); 472e1991d10SAlexandre Mergnat 473e1991d10SAlexandre Mergnat mask |= CM_AFE_CM1_VUL_SEL | 474e1991d10SAlexandre Mergnat CM_AFE_CM1_IN_MODE_MASK; 475e1991d10SAlexandre Mergnat } else if (cmNum == MT8365_CM2) { 476e1991d10SAlexandre Mergnat if (mt8365_afe_clk_group_48k(rate)) 477e1991d10SAlexandre Mergnat val |= FIELD_PREP(CM_AFE_CM2_CLK_SEL, 0); 478e1991d10SAlexandre Mergnat else 479e1991d10SAlexandre Mergnat val |= FIELD_PREP(CM_AFE_CM2_CLK_SEL, 1); 480e1991d10SAlexandre Mergnat 481e1991d10SAlexandre Mergnat val |= FIELD_PREP(CM_AFE_CM2_TDM_SEL, 1); 482e1991d10SAlexandre Mergnat 483e1991d10SAlexandre Mergnat mask |= CM_AFE_CM2_TDM_SEL | 484e1991d10SAlexandre Mergnat CM_AFE_CM1_IN_MODE_MASK | 485e1991d10SAlexandre Mergnat CM_AFE_CM2_CLK_SEL; 486e1991d10SAlexandre Mergnat 487e1991d10SAlexandre Mergnat mt8365_afe_cm2_mux_conn(afe); 488e1991d10SAlexandre Mergnat } else { 489e1991d10SAlexandre Mergnat return -1; 490e1991d10SAlexandre Mergnat } 491e1991d10SAlexandre Mergnat 492e1991d10SAlexandre Mergnat regmap_update_bits(afe->regmap, cm_ctrl_reg[cmNum].con0, mask, val); 493e1991d10SAlexandre Mergnat 494e1991d10SAlexandre Mergnat mt8365_afe_get_cm_update_cnt(afe, cmNum, rate, channels); 495e1991d10SAlexandre Mergnat 496e1991d10SAlexandre Mergnat return 0; 497e1991d10SAlexandre Mergnat } 498e1991d10SAlexandre Mergnat 499*63157d99SMark Brown static int mt8365_afe_fe_startup(struct snd_pcm_substream *substream, 500e1991d10SAlexandre Mergnat struct snd_soc_dai *dai) 501e1991d10SAlexandre Mergnat { 502e1991d10SAlexandre Mergnat struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream); 503e1991d10SAlexandre Mergnat struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai); 504e1991d10SAlexandre Mergnat struct snd_pcm_runtime *runtime = substream->runtime; 505e1991d10SAlexandre Mergnat int memif_num = snd_soc_rtd_to_cpu(rtd, 0)->id; 506e1991d10SAlexandre Mergnat struct mtk_base_afe_memif *memif = &afe->memif[memif_num]; 507e1991d10SAlexandre Mergnat int ret; 508e1991d10SAlexandre Mergnat 509e1991d10SAlexandre Mergnat memif->substream = substream; 510e1991d10SAlexandre Mergnat 511e1991d10SAlexandre Mergnat snd_pcm_hw_constraint_step(substream->runtime, 0, 512e1991d10SAlexandre Mergnat SNDRV_PCM_HW_PARAM_BUFFER_BYTES, 16); 513e1991d10SAlexandre Mergnat 514e1991d10SAlexandre Mergnat snd_soc_set_runtime_hwparams(substream, afe->mtk_afe_hardware); 515e1991d10SAlexandre Mergnat 516e1991d10SAlexandre Mergnat ret = snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS); 517e1991d10SAlexandre Mergnat if (ret < 0) 518e1991d10SAlexandre Mergnat dev_err(afe->dev, "snd_pcm_hw_constraint_integer failed\n"); 519e1991d10SAlexandre Mergnat 520e1991d10SAlexandre Mergnat mt8365_afe_enable_main_clk(afe); 521e1991d10SAlexandre Mergnat return ret; 522e1991d10SAlexandre Mergnat } 523e1991d10SAlexandre Mergnat 524e1991d10SAlexandre Mergnat static void mt8365_afe_fe_shutdown(struct snd_pcm_substream *substream, 525e1991d10SAlexandre Mergnat struct snd_soc_dai *dai) 526e1991d10SAlexandre Mergnat { 527e1991d10SAlexandre Mergnat struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream); 528e1991d10SAlexandre Mergnat struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai); 529e1991d10SAlexandre Mergnat int memif_num = snd_soc_rtd_to_cpu(rtd, 0)->id; 530e1991d10SAlexandre Mergnat struct mtk_base_afe_memif *memif = &afe->memif[memif_num]; 531e1991d10SAlexandre Mergnat 532e1991d10SAlexandre Mergnat memif->substream = NULL; 533e1991d10SAlexandre Mergnat 534e1991d10SAlexandre Mergnat mt8365_afe_disable_main_clk(afe); 535e1991d10SAlexandre Mergnat } 536e1991d10SAlexandre Mergnat 537e1991d10SAlexandre Mergnat static int mt8365_afe_fe_hw_params(struct snd_pcm_substream *substream, 538e1991d10SAlexandre Mergnat struct snd_pcm_hw_params *params, 539e1991d10SAlexandre Mergnat struct snd_soc_dai *dai) 540e1991d10SAlexandre Mergnat { 541e1991d10SAlexandre Mergnat struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream); 542e1991d10SAlexandre Mergnat struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai); 543e1991d10SAlexandre Mergnat struct mt8365_afe_private *afe_priv = afe->platform_priv; 544e1991d10SAlexandre Mergnat struct mt8365_control_data *ctrl_data = &afe_priv->ctrl_data; 545e1991d10SAlexandre Mergnat int dai_id = snd_soc_rtd_to_cpu(rtd, 0)->id; 546e1991d10SAlexandre Mergnat struct mtk_base_afe_memif *memif = &afe->memif[dai_id]; 547e1991d10SAlexandre Mergnat struct mt8365_fe_dai_data *fe_data = &afe_priv->fe_data[dai_id]; 548e1991d10SAlexandre Mergnat size_t request_size = params_buffer_bytes(params); 549e1991d10SAlexandre Mergnat unsigned int channels = params_channels(params); 550e1991d10SAlexandre Mergnat unsigned int rate = params_rate(params); 551e1991d10SAlexandre Mergnat unsigned int base_end_offset = 8; 552e1991d10SAlexandre Mergnat int ret, fs; 553e1991d10SAlexandre Mergnat 554e1991d10SAlexandre Mergnat dev_info(afe->dev, "%s %s period = %d rate = %d channels = %d\n", 555e1991d10SAlexandre Mergnat __func__, memif->data->name, params_period_size(params), 556e1991d10SAlexandre Mergnat rate, channels); 557e1991d10SAlexandre Mergnat 558e1991d10SAlexandre Mergnat if (dai_id == MT8365_AFE_MEMIF_VUL2) { 559e1991d10SAlexandre Mergnat if (!ctrl_data->bypass_cm1) 560e1991d10SAlexandre Mergnat /* configure cm1 */ 561e1991d10SAlexandre Mergnat mt8365_afe_configure_cm(afe, MT8365_CM1, 562e1991d10SAlexandre Mergnat channels, rate); 563e1991d10SAlexandre Mergnat else 564e1991d10SAlexandre Mergnat regmap_update_bits(afe->regmap, AFE_CM1_CON0, 565e1991d10SAlexandre Mergnat CM_AFE_CM1_VUL_SEL, 566e1991d10SAlexandre Mergnat CM_AFE_CM1_VUL_SEL); 567e1991d10SAlexandre Mergnat } else if (dai_id == MT8365_AFE_MEMIF_TDM_IN) { 568e1991d10SAlexandre Mergnat if (!ctrl_data->bypass_cm2) 569e1991d10SAlexandre Mergnat /* configure cm2 */ 570e1991d10SAlexandre Mergnat mt8365_afe_configure_cm(afe, MT8365_CM2, 571e1991d10SAlexandre Mergnat channels, rate); 572e1991d10SAlexandre Mergnat else 573e1991d10SAlexandre Mergnat regmap_update_bits(afe->regmap, AFE_CM2_CON0, 574e1991d10SAlexandre Mergnat CM_AFE_CM2_TDM_SEL, 575e1991d10SAlexandre Mergnat ~CM_AFE_CM2_TDM_SEL); 576e1991d10SAlexandre Mergnat 577e1991d10SAlexandre Mergnat base_end_offset = 4; 578e1991d10SAlexandre Mergnat } 579e1991d10SAlexandre Mergnat 580e1991d10SAlexandre Mergnat if (request_size > fe_data->sram_size) { 581e1991d10SAlexandre Mergnat ret = snd_pcm_lib_malloc_pages(substream, request_size); 582e1991d10SAlexandre Mergnat if (ret < 0) { 583e1991d10SAlexandre Mergnat dev_err(afe->dev, 584e1991d10SAlexandre Mergnat "%s %s malloc pages %zu bytes failed %d\n", 585e1991d10SAlexandre Mergnat __func__, memif->data->name, request_size, ret); 586e1991d10SAlexandre Mergnat return ret; 587e1991d10SAlexandre Mergnat } 588e1991d10SAlexandre Mergnat 589e1991d10SAlexandre Mergnat fe_data->use_sram = false; 590e1991d10SAlexandre Mergnat 591e1991d10SAlexandre Mergnat mt8365_afe_emi_clk_on(afe); 592e1991d10SAlexandre Mergnat } else { 593e1991d10SAlexandre Mergnat struct snd_dma_buffer *dma_buf = &substream->dma_buffer; 594e1991d10SAlexandre Mergnat 595e1991d10SAlexandre Mergnat dma_buf->dev.type = SNDRV_DMA_TYPE_DEV; 596e1991d10SAlexandre Mergnat dma_buf->dev.dev = substream->pcm->card->dev; 597e1991d10SAlexandre Mergnat dma_buf->area = (unsigned char *)fe_data->sram_vir_addr; 598e1991d10SAlexandre Mergnat dma_buf->addr = fe_data->sram_phy_addr; 599e1991d10SAlexandre Mergnat dma_buf->bytes = request_size; 600e1991d10SAlexandre Mergnat snd_pcm_set_runtime_buffer(substream, dma_buf); 601e1991d10SAlexandre Mergnat 602e1991d10SAlexandre Mergnat fe_data->use_sram = true; 603e1991d10SAlexandre Mergnat } 604e1991d10SAlexandre Mergnat 605e1991d10SAlexandre Mergnat memif->phys_buf_addr = lower_32_bits(substream->runtime->dma_addr); 606e1991d10SAlexandre Mergnat memif->buffer_size = substream->runtime->dma_bytes; 607e1991d10SAlexandre Mergnat 608e1991d10SAlexandre Mergnat /* start */ 609e1991d10SAlexandre Mergnat regmap_write(afe->regmap, memif->data->reg_ofs_base, 610e1991d10SAlexandre Mergnat memif->phys_buf_addr); 611e1991d10SAlexandre Mergnat /* end */ 612e1991d10SAlexandre Mergnat regmap_write(afe->regmap, 613e1991d10SAlexandre Mergnat memif->data->reg_ofs_base + base_end_offset, 614e1991d10SAlexandre Mergnat memif->phys_buf_addr + memif->buffer_size - 1); 615e1991d10SAlexandre Mergnat 616e1991d10SAlexandre Mergnat /* set channel */ 617e1991d10SAlexandre Mergnat if (memif->data->mono_shift >= 0) { 618e1991d10SAlexandre Mergnat unsigned int mono = (params_channels(params) == 1) ? 1 : 0; 619e1991d10SAlexandre Mergnat 620e1991d10SAlexandre Mergnat if (memif->data->mono_reg < 0) 621e1991d10SAlexandre Mergnat dev_info(afe->dev, "%s mono_reg is NULL\n", __func__); 622e1991d10SAlexandre Mergnat else 623e1991d10SAlexandre Mergnat regmap_update_bits(afe->regmap, memif->data->mono_reg, 624e1991d10SAlexandre Mergnat 1 << memif->data->mono_shift, 625e1991d10SAlexandre Mergnat mono << memif->data->mono_shift); 626e1991d10SAlexandre Mergnat } 627e1991d10SAlexandre Mergnat 628e1991d10SAlexandre Mergnat /* set rate */ 629e1991d10SAlexandre Mergnat if (memif->data->fs_shift < 0) 630e1991d10SAlexandre Mergnat return 0; 631e1991d10SAlexandre Mergnat 632e1991d10SAlexandre Mergnat fs = afe->memif_fs(substream, params_rate(params)); 633e1991d10SAlexandre Mergnat 634e1991d10SAlexandre Mergnat if (fs < 0) 635e1991d10SAlexandre Mergnat return -EINVAL; 636e1991d10SAlexandre Mergnat 637e1991d10SAlexandre Mergnat if (memif->data->fs_reg < 0) 638e1991d10SAlexandre Mergnat dev_info(afe->dev, "%s fs_reg is NULL\n", __func__); 639e1991d10SAlexandre Mergnat else 640e1991d10SAlexandre Mergnat regmap_update_bits(afe->regmap, memif->data->fs_reg, 641e1991d10SAlexandre Mergnat memif->data->fs_maskbit << memif->data->fs_shift, 642e1991d10SAlexandre Mergnat fs << memif->data->fs_shift); 643e1991d10SAlexandre Mergnat 644e1991d10SAlexandre Mergnat return 0; 645e1991d10SAlexandre Mergnat } 646e1991d10SAlexandre Mergnat 647e1991d10SAlexandre Mergnat static int mt8365_afe_fe_hw_free(struct snd_pcm_substream *substream, 648e1991d10SAlexandre Mergnat struct snd_soc_dai *dai) 649e1991d10SAlexandre Mergnat { 650e1991d10SAlexandre Mergnat struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream); 651e1991d10SAlexandre Mergnat struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai); 652e1991d10SAlexandre Mergnat struct mt8365_afe_private *afe_priv = afe->platform_priv; 653e1991d10SAlexandre Mergnat int dai_id = snd_soc_rtd_to_cpu(rtd, 0)->id; 654e1991d10SAlexandre Mergnat struct mtk_base_afe_memif *memif = &afe->memif[dai_id]; 655e1991d10SAlexandre Mergnat struct mt8365_fe_dai_data *fe_data = &afe_priv->fe_data[dai_id]; 656e1991d10SAlexandre Mergnat int ret = 0; 657e1991d10SAlexandre Mergnat 658e1991d10SAlexandre Mergnat if (fe_data->use_sram) { 659e1991d10SAlexandre Mergnat snd_pcm_set_runtime_buffer(substream, NULL); 660e1991d10SAlexandre Mergnat } else { 661e1991d10SAlexandre Mergnat ret = snd_pcm_lib_free_pages(substream); 662e1991d10SAlexandre Mergnat 663e1991d10SAlexandre Mergnat mt8365_afe_emi_clk_off(afe); 664e1991d10SAlexandre Mergnat } 665e1991d10SAlexandre Mergnat 666e1991d10SAlexandre Mergnat return ret; 667e1991d10SAlexandre Mergnat } 668e1991d10SAlexandre Mergnat 669e1991d10SAlexandre Mergnat static int mt8365_afe_fe_prepare(struct snd_pcm_substream *substream, 670e1991d10SAlexandre Mergnat struct snd_soc_dai *dai) 671e1991d10SAlexandre Mergnat { 672e1991d10SAlexandre Mergnat struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream); 673e1991d10SAlexandre Mergnat struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai); 674e1991d10SAlexandre Mergnat int dai_id = snd_soc_rtd_to_cpu(rtd, 0)->id; 675e1991d10SAlexandre Mergnat struct mtk_base_afe_memif *memif = &afe->memif[dai_id]; 676e1991d10SAlexandre Mergnat 677e1991d10SAlexandre Mergnat /* set format */ 678e1991d10SAlexandre Mergnat if (memif->data->hd_reg >= 0) { 679e1991d10SAlexandre Mergnat switch (substream->runtime->format) { 680e1991d10SAlexandre Mergnat case SNDRV_PCM_FORMAT_S16_LE: 681e1991d10SAlexandre Mergnat regmap_update_bits(afe->regmap, memif->data->hd_reg, 682e1991d10SAlexandre Mergnat 3 << memif->data->hd_shift, 683e1991d10SAlexandre Mergnat 0 << memif->data->hd_shift); 684e1991d10SAlexandre Mergnat break; 685e1991d10SAlexandre Mergnat case SNDRV_PCM_FORMAT_S32_LE: 686e1991d10SAlexandre Mergnat regmap_update_bits(afe->regmap, memif->data->hd_reg, 687e1991d10SAlexandre Mergnat 3 << memif->data->hd_shift, 688e1991d10SAlexandre Mergnat 3 << memif->data->hd_shift); 689e1991d10SAlexandre Mergnat 690e1991d10SAlexandre Mergnat if (dai_id == MT8365_AFE_MEMIF_TDM_IN) { 691e1991d10SAlexandre Mergnat regmap_update_bits(afe->regmap, 692e1991d10SAlexandre Mergnat memif->data->hd_reg, 693e1991d10SAlexandre Mergnat 3 << memif->data->hd_shift, 694e1991d10SAlexandre Mergnat 1 << memif->data->hd_shift); 695e1991d10SAlexandre Mergnat regmap_update_bits(afe->regmap, 696e1991d10SAlexandre Mergnat memif->data->hd_reg, 697e1991d10SAlexandre Mergnat 1 << memif->data->hd_align_mshift, 698e1991d10SAlexandre Mergnat 1 << memif->data->hd_align_mshift); 699e1991d10SAlexandre Mergnat } 700e1991d10SAlexandre Mergnat break; 701e1991d10SAlexandre Mergnat case SNDRV_PCM_FORMAT_S24_LE: 702e1991d10SAlexandre Mergnat regmap_update_bits(afe->regmap, memif->data->hd_reg, 703e1991d10SAlexandre Mergnat 3 << memif->data->hd_shift, 704e1991d10SAlexandre Mergnat 1 << memif->data->hd_shift); 705e1991d10SAlexandre Mergnat break; 706e1991d10SAlexandre Mergnat default: 707e1991d10SAlexandre Mergnat return -EINVAL; 708e1991d10SAlexandre Mergnat } 709e1991d10SAlexandre Mergnat } 710e1991d10SAlexandre Mergnat 711e1991d10SAlexandre Mergnat mt8365_afe_irq_direction_enable(afe, memif->irq_usage, 712e1991d10SAlexandre Mergnat MT8365_AFE_IRQ_DIR_MCU); 713e1991d10SAlexandre Mergnat 714e1991d10SAlexandre Mergnat return 0; 715e1991d10SAlexandre Mergnat } 716e1991d10SAlexandre Mergnat 717*63157d99SMark Brown static int mt8365_afe_fe_trigger(struct snd_pcm_substream *substream, int cmd, 718e1991d10SAlexandre Mergnat struct snd_soc_dai *dai) 719e1991d10SAlexandre Mergnat { 720e1991d10SAlexandre Mergnat struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream); 721e1991d10SAlexandre Mergnat struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai); 722e1991d10SAlexandre Mergnat struct mt8365_afe_private *afe_priv = afe->platform_priv; 723e1991d10SAlexandre Mergnat int dai_id = snd_soc_rtd_to_cpu(rtd, 0)->id; 724e1991d10SAlexandre Mergnat struct mt8365_control_data *ctrl_data = &afe_priv->ctrl_data; 725e1991d10SAlexandre Mergnat 726e1991d10SAlexandre Mergnat switch (cmd) { 727e1991d10SAlexandre Mergnat case SNDRV_PCM_TRIGGER_START: 728e1991d10SAlexandre Mergnat case SNDRV_PCM_TRIGGER_RESUME: 729e1991d10SAlexandre Mergnat /* enable channel merge */ 730e1991d10SAlexandre Mergnat if (dai_id == MT8365_AFE_MEMIF_VUL2 && 731e1991d10SAlexandre Mergnat !ctrl_data->bypass_cm1) { 732e1991d10SAlexandre Mergnat regmap_update_bits(afe->regmap, AFE_CM1_CON0, 733e1991d10SAlexandre Mergnat CM_AFE_CM_ON, CM_AFE_CM_ON); 734e1991d10SAlexandre Mergnat } else if (dai_id == MT8365_AFE_MEMIF_TDM_IN && 735e1991d10SAlexandre Mergnat !ctrl_data->bypass_cm2) { 736e1991d10SAlexandre Mergnat regmap_update_bits(afe->regmap, AFE_CM2_CON0, 737e1991d10SAlexandre Mergnat CM_AFE_CM_ON, CM_AFE_CM_ON); 738e1991d10SAlexandre Mergnat } 739e1991d10SAlexandre Mergnat break; 740e1991d10SAlexandre Mergnat case SNDRV_PCM_TRIGGER_STOP: 741e1991d10SAlexandre Mergnat case SNDRV_PCM_TRIGGER_SUSPEND: 742e1991d10SAlexandre Mergnat /* disable channel merge */ 743e1991d10SAlexandre Mergnat if (dai_id == MT8365_AFE_MEMIF_VUL2 && 744e1991d10SAlexandre Mergnat !ctrl_data->bypass_cm1) { 745e1991d10SAlexandre Mergnat regmap_update_bits(afe->regmap, AFE_CM1_CON0, 746e1991d10SAlexandre Mergnat CM_AFE_CM_ON, ~CM_AFE_CM_ON); 747e1991d10SAlexandre Mergnat } else if (dai_id == MT8365_AFE_MEMIF_TDM_IN && 748e1991d10SAlexandre Mergnat !ctrl_data->bypass_cm2) { 749e1991d10SAlexandre Mergnat regmap_update_bits(afe->regmap, AFE_CM2_CON0, 750e1991d10SAlexandre Mergnat CM_AFE_CM_ON, ~CM_AFE_CM_ON); 751e1991d10SAlexandre Mergnat } 752e1991d10SAlexandre Mergnat break; 753e1991d10SAlexandre Mergnat default: 754e1991d10SAlexandre Mergnat break; 755e1991d10SAlexandre Mergnat } 756e1991d10SAlexandre Mergnat 757e1991d10SAlexandre Mergnat return mtk_afe_fe_trigger(substream, cmd, dai); 758e1991d10SAlexandre Mergnat } 759e1991d10SAlexandre Mergnat 760e1991d10SAlexandre Mergnat static int mt8365_afe_hw_gain1_startup(struct snd_pcm_substream *substream, 761e1991d10SAlexandre Mergnat struct snd_soc_dai *dai) 762e1991d10SAlexandre Mergnat { 763e1991d10SAlexandre Mergnat struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai); 764e1991d10SAlexandre Mergnat 765e1991d10SAlexandre Mergnat mt8365_afe_enable_main_clk(afe); 766e1991d10SAlexandre Mergnat return 0; 767e1991d10SAlexandre Mergnat } 768e1991d10SAlexandre Mergnat 769e1991d10SAlexandre Mergnat static void mt8365_afe_hw_gain1_shutdown(struct snd_pcm_substream *substream, 770e1991d10SAlexandre Mergnat struct snd_soc_dai *dai) 771e1991d10SAlexandre Mergnat { 772e1991d10SAlexandre Mergnat struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai); 773e1991d10SAlexandre Mergnat struct mt8365_afe_private *afe_priv = afe->platform_priv; 774e1991d10SAlexandre Mergnat struct mt8365_be_dai_data *be = 775e1991d10SAlexandre Mergnat &afe_priv->be_data[dai->id - MT8365_AFE_BACKEND_BASE]; 776e1991d10SAlexandre Mergnat 777e1991d10SAlexandre Mergnat if (be->prepared[substream->stream]) { 778e1991d10SAlexandre Mergnat regmap_update_bits(afe->regmap, AFE_GAIN1_CON0, 779e1991d10SAlexandre Mergnat AFE_GAIN1_CON0_EN_MASK, 0); 780e1991d10SAlexandre Mergnat be->prepared[substream->stream] = false; 781e1991d10SAlexandre Mergnat } 782e1991d10SAlexandre Mergnat mt8365_afe_disable_main_clk(afe); 783e1991d10SAlexandre Mergnat } 784e1991d10SAlexandre Mergnat 785e1991d10SAlexandre Mergnat static int mt8365_afe_hw_gain1_prepare(struct snd_pcm_substream *substream, 786e1991d10SAlexandre Mergnat struct snd_soc_dai *dai) 787e1991d10SAlexandre Mergnat { 788e1991d10SAlexandre Mergnat struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai); 789e1991d10SAlexandre Mergnat struct mt8365_afe_private *afe_priv = afe->platform_priv; 790e1991d10SAlexandre Mergnat struct mt8365_be_dai_data *be = 791e1991d10SAlexandre Mergnat &afe_priv->be_data[dai->id - MT8365_AFE_BACKEND_BASE]; 792e1991d10SAlexandre Mergnat 793e1991d10SAlexandre Mergnat int fs; 794e1991d10SAlexandre Mergnat unsigned int val1 = 0, val2 = 0; 795e1991d10SAlexandre Mergnat 796e1991d10SAlexandre Mergnat if (be->prepared[substream->stream]) { 797e1991d10SAlexandre Mergnat dev_info(afe->dev, "%s prepared already\n", __func__); 798e1991d10SAlexandre Mergnat return 0; 799e1991d10SAlexandre Mergnat } 800e1991d10SAlexandre Mergnat 801e1991d10SAlexandre Mergnat fs = mt8365_afe_fs_timing(substream->runtime->rate); 802e1991d10SAlexandre Mergnat regmap_update_bits(afe->regmap, AFE_GAIN1_CON0, 803e1991d10SAlexandre Mergnat AFE_GAIN1_CON0_MODE_MASK, (unsigned int)fs << 4); 804e1991d10SAlexandre Mergnat 805e1991d10SAlexandre Mergnat regmap_read(afe->regmap, AFE_GAIN1_CON1, &val1); 806e1991d10SAlexandre Mergnat regmap_read(afe->regmap, AFE_GAIN1_CUR, &val2); 807e1991d10SAlexandre Mergnat if ((val1 & AFE_GAIN1_CON1_MASK) != (val2 & AFE_GAIN1_CUR_MASK)) 808e1991d10SAlexandre Mergnat regmap_update_bits(afe->regmap, AFE_GAIN1_CUR, 809e1991d10SAlexandre Mergnat AFE_GAIN1_CUR_MASK, val1); 810e1991d10SAlexandre Mergnat 811e1991d10SAlexandre Mergnat regmap_update_bits(afe->regmap, AFE_GAIN1_CON0, 812e1991d10SAlexandre Mergnat AFE_GAIN1_CON0_EN_MASK, 1); 813e1991d10SAlexandre Mergnat be->prepared[substream->stream] = true; 814e1991d10SAlexandre Mergnat 815e1991d10SAlexandre Mergnat return 0; 816e1991d10SAlexandre Mergnat } 817e1991d10SAlexandre Mergnat 818e1991d10SAlexandre Mergnat static const struct snd_pcm_hardware mt8365_hostless_hardware = { 819e1991d10SAlexandre Mergnat .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | 820e1991d10SAlexandre Mergnat SNDRV_PCM_INFO_MMAP_VALID), 821e1991d10SAlexandre Mergnat .period_bytes_min = 256, 822e1991d10SAlexandre Mergnat .period_bytes_max = 4 * 48 * 1024, 823e1991d10SAlexandre Mergnat .periods_min = 2, 824e1991d10SAlexandre Mergnat .periods_max = 256, 825e1991d10SAlexandre Mergnat .buffer_bytes_max = 8 * 48 * 1024, 826e1991d10SAlexandre Mergnat .fifo_size = 0, 827e1991d10SAlexandre Mergnat }; 828e1991d10SAlexandre Mergnat 829e1991d10SAlexandre Mergnat /* dai ops */ 830e1991d10SAlexandre Mergnat static int mtk_dai_hostless_startup(struct snd_pcm_substream *substream, 831e1991d10SAlexandre Mergnat struct snd_soc_dai *dai) 832e1991d10SAlexandre Mergnat { 833e1991d10SAlexandre Mergnat struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai); 834e1991d10SAlexandre Mergnat struct snd_pcm_runtime *runtime = substream->runtime; 835e1991d10SAlexandre Mergnat int ret; 836e1991d10SAlexandre Mergnat 837e1991d10SAlexandre Mergnat snd_soc_set_runtime_hwparams(substream, &mt8365_hostless_hardware); 838e1991d10SAlexandre Mergnat 839e1991d10SAlexandre Mergnat ret = snd_pcm_hw_constraint_integer(runtime, 840e1991d10SAlexandre Mergnat SNDRV_PCM_HW_PARAM_PERIODS); 841e1991d10SAlexandre Mergnat if (ret < 0) 842e1991d10SAlexandre Mergnat dev_err(afe->dev, "snd_pcm_hw_constraint_integer failed\n"); 843e1991d10SAlexandre Mergnat return ret; 844e1991d10SAlexandre Mergnat } 845e1991d10SAlexandre Mergnat 846e1991d10SAlexandre Mergnat /* FE DAIs */ 847e1991d10SAlexandre Mergnat static const struct snd_soc_dai_ops mt8365_afe_fe_dai_ops = { 848e1991d10SAlexandre Mergnat .startup = mt8365_afe_fe_startup, 849e1991d10SAlexandre Mergnat .shutdown = mt8365_afe_fe_shutdown, 850e1991d10SAlexandre Mergnat .hw_params = mt8365_afe_fe_hw_params, 851e1991d10SAlexandre Mergnat .hw_free = mt8365_afe_fe_hw_free, 852e1991d10SAlexandre Mergnat .prepare = mt8365_afe_fe_prepare, 853e1991d10SAlexandre Mergnat .trigger = mt8365_afe_fe_trigger, 854e1991d10SAlexandre Mergnat }; 855e1991d10SAlexandre Mergnat 856e1991d10SAlexandre Mergnat static const struct snd_soc_dai_ops mt8365_dai_hostless_ops = { 857e1991d10SAlexandre Mergnat .startup = mtk_dai_hostless_startup, 858e1991d10SAlexandre Mergnat }; 859e1991d10SAlexandre Mergnat 860e1991d10SAlexandre Mergnat static const struct snd_soc_dai_ops mt8365_afe_hw_gain1_ops = { 861e1991d10SAlexandre Mergnat .startup = mt8365_afe_hw_gain1_startup, 862e1991d10SAlexandre Mergnat .shutdown = mt8365_afe_hw_gain1_shutdown, 863e1991d10SAlexandre Mergnat .prepare = mt8365_afe_hw_gain1_prepare, 864e1991d10SAlexandre Mergnat }; 865e1991d10SAlexandre Mergnat 866e1991d10SAlexandre Mergnat static struct snd_soc_dai_driver mt8365_memif_dai_driver[] = { 867e1991d10SAlexandre Mergnat /* FE DAIs: memory intefaces to CPU */ 868e1991d10SAlexandre Mergnat { 869e1991d10SAlexandre Mergnat .name = "DL1", 870e1991d10SAlexandre Mergnat .id = MT8365_AFE_MEMIF_DL1, 871e1991d10SAlexandre Mergnat .playback = { 872e1991d10SAlexandre Mergnat .stream_name = "DL1", 873e1991d10SAlexandre Mergnat .channels_min = 1, 874e1991d10SAlexandre Mergnat .channels_max = 2, 875e1991d10SAlexandre Mergnat .rates = SNDRV_PCM_RATE_8000_192000, 876e1991d10SAlexandre Mergnat .formats = SNDRV_PCM_FMTBIT_S16_LE | 877e1991d10SAlexandre Mergnat SNDRV_PCM_FMTBIT_S32_LE, 878e1991d10SAlexandre Mergnat }, 879e1991d10SAlexandre Mergnat .ops = &mt8365_afe_fe_dai_ops, 880e1991d10SAlexandre Mergnat }, { 881e1991d10SAlexandre Mergnat .name = "DL2", 882e1991d10SAlexandre Mergnat .id = MT8365_AFE_MEMIF_DL2, 883e1991d10SAlexandre Mergnat .playback = { 884e1991d10SAlexandre Mergnat .stream_name = "DL2", 885e1991d10SAlexandre Mergnat .channels_min = 1, 886e1991d10SAlexandre Mergnat .channels_max = 2, 887e1991d10SAlexandre Mergnat .rates = SNDRV_PCM_RATE_8000_192000, 888e1991d10SAlexandre Mergnat .formats = SNDRV_PCM_FMTBIT_S16_LE | 889e1991d10SAlexandre Mergnat SNDRV_PCM_FMTBIT_S32_LE, 890e1991d10SAlexandre Mergnat }, 891e1991d10SAlexandre Mergnat .ops = &mt8365_afe_fe_dai_ops, 892e1991d10SAlexandre Mergnat }, { 893e1991d10SAlexandre Mergnat .name = "TDM_OUT", 894e1991d10SAlexandre Mergnat .id = MT8365_AFE_MEMIF_TDM_OUT, 895e1991d10SAlexandre Mergnat .playback = { 896e1991d10SAlexandre Mergnat .stream_name = "TDM_OUT", 897e1991d10SAlexandre Mergnat .channels_min = 1, 898e1991d10SAlexandre Mergnat .channels_max = 8, 899e1991d10SAlexandre Mergnat .rates = SNDRV_PCM_RATE_8000_192000, 900e1991d10SAlexandre Mergnat .formats = SNDRV_PCM_FMTBIT_S16_LE | 901e1991d10SAlexandre Mergnat SNDRV_PCM_FMTBIT_S32_LE, 902e1991d10SAlexandre Mergnat }, 903e1991d10SAlexandre Mergnat .ops = &mt8365_afe_fe_dai_ops, 904e1991d10SAlexandre Mergnat }, { 905e1991d10SAlexandre Mergnat .name = "AWB", 906e1991d10SAlexandre Mergnat .id = MT8365_AFE_MEMIF_AWB, 907e1991d10SAlexandre Mergnat .capture = { 908e1991d10SAlexandre Mergnat .stream_name = "AWB", 909e1991d10SAlexandre Mergnat .channels_min = 1, 910e1991d10SAlexandre Mergnat .channels_max = 2, 911e1991d10SAlexandre Mergnat .rates = SNDRV_PCM_RATE_8000_192000, 912e1991d10SAlexandre Mergnat .formats = SNDRV_PCM_FMTBIT_S16_LE | 913e1991d10SAlexandre Mergnat SNDRV_PCM_FMTBIT_S32_LE, 914e1991d10SAlexandre Mergnat }, 915e1991d10SAlexandre Mergnat .ops = &mt8365_afe_fe_dai_ops, 916e1991d10SAlexandre Mergnat }, { 917e1991d10SAlexandre Mergnat .name = "VUL", 918e1991d10SAlexandre Mergnat .id = MT8365_AFE_MEMIF_VUL, 919e1991d10SAlexandre Mergnat .capture = { 920e1991d10SAlexandre Mergnat .stream_name = "VUL", 921e1991d10SAlexandre Mergnat .channels_min = 1, 922e1991d10SAlexandre Mergnat .channels_max = 2, 923e1991d10SAlexandre Mergnat .rates = SNDRV_PCM_RATE_8000_192000, 924e1991d10SAlexandre Mergnat .formats = SNDRV_PCM_FMTBIT_S16_LE | 925e1991d10SAlexandre Mergnat SNDRV_PCM_FMTBIT_S32_LE, 926e1991d10SAlexandre Mergnat }, 927e1991d10SAlexandre Mergnat .ops = &mt8365_afe_fe_dai_ops, 928e1991d10SAlexandre Mergnat }, { 929e1991d10SAlexandre Mergnat .name = "VUL2", 930e1991d10SAlexandre Mergnat .id = MT8365_AFE_MEMIF_VUL2, 931e1991d10SAlexandre Mergnat .capture = { 932e1991d10SAlexandre Mergnat .stream_name = "VUL2", 933e1991d10SAlexandre Mergnat .channels_min = 1, 934e1991d10SAlexandre Mergnat .channels_max = 16, 935e1991d10SAlexandre Mergnat .rates = SNDRV_PCM_RATE_8000_192000, 936e1991d10SAlexandre Mergnat .formats = SNDRV_PCM_FMTBIT_S16_LE | 937e1991d10SAlexandre Mergnat SNDRV_PCM_FMTBIT_S32_LE, 938e1991d10SAlexandre Mergnat }, 939e1991d10SAlexandre Mergnat .ops = &mt8365_afe_fe_dai_ops, 940e1991d10SAlexandre Mergnat }, { 941e1991d10SAlexandre Mergnat .name = "VUL3", 942e1991d10SAlexandre Mergnat .id = MT8365_AFE_MEMIF_VUL3, 943e1991d10SAlexandre Mergnat .capture = { 944e1991d10SAlexandre Mergnat .stream_name = "VUL3", 945e1991d10SAlexandre Mergnat .channels_min = 1, 946e1991d10SAlexandre Mergnat .channels_max = 2, 947e1991d10SAlexandre Mergnat .rates = SNDRV_PCM_RATE_8000_192000, 948e1991d10SAlexandre Mergnat .formats = SNDRV_PCM_FMTBIT_S16_LE | 949e1991d10SAlexandre Mergnat SNDRV_PCM_FMTBIT_S32_LE, 950e1991d10SAlexandre Mergnat }, 951e1991d10SAlexandre Mergnat .ops = &mt8365_afe_fe_dai_ops, 952e1991d10SAlexandre Mergnat }, { 953e1991d10SAlexandre Mergnat .name = "TDM_IN", 954e1991d10SAlexandre Mergnat .id = MT8365_AFE_MEMIF_TDM_IN, 955e1991d10SAlexandre Mergnat .capture = { 956e1991d10SAlexandre Mergnat .stream_name = "TDM_IN", 957e1991d10SAlexandre Mergnat .channels_min = 1, 958e1991d10SAlexandre Mergnat .channels_max = 16, 959e1991d10SAlexandre Mergnat .rates = SNDRV_PCM_RATE_8000_192000, 960e1991d10SAlexandre Mergnat .formats = SNDRV_PCM_FMTBIT_S16_LE | 961e1991d10SAlexandre Mergnat SNDRV_PCM_FMTBIT_S32_LE, 962e1991d10SAlexandre Mergnat }, 963e1991d10SAlexandre Mergnat .ops = &mt8365_afe_fe_dai_ops, 964e1991d10SAlexandre Mergnat }, { 965e1991d10SAlexandre Mergnat .name = "Hostless FM DAI", 966e1991d10SAlexandre Mergnat .id = MT8365_AFE_IO_VIRTUAL_FM, 967e1991d10SAlexandre Mergnat .playback = { 968e1991d10SAlexandre Mergnat .stream_name = "Hostless FM DL", 969e1991d10SAlexandre Mergnat .channels_min = 1, 970e1991d10SAlexandre Mergnat .channels_max = 2, 971e1991d10SAlexandre Mergnat .rates = SNDRV_PCM_RATE_8000_192000, 972e1991d10SAlexandre Mergnat .formats = SNDRV_PCM_FMTBIT_S16_LE | 973e1991d10SAlexandre Mergnat SNDRV_PCM_FMTBIT_S24_LE | 974e1991d10SAlexandre Mergnat SNDRV_PCM_FMTBIT_S32_LE, 975e1991d10SAlexandre Mergnat }, 976e1991d10SAlexandre Mergnat .capture = { 977e1991d10SAlexandre Mergnat .stream_name = "Hostless FM UL", 978e1991d10SAlexandre Mergnat .channels_min = 1, 979e1991d10SAlexandre Mergnat .channels_max = 2, 980e1991d10SAlexandre Mergnat .rates = SNDRV_PCM_RATE_8000_192000, 981e1991d10SAlexandre Mergnat .formats = SNDRV_PCM_FMTBIT_S16_LE | 982e1991d10SAlexandre Mergnat SNDRV_PCM_FMTBIT_S24_LE | 983e1991d10SAlexandre Mergnat SNDRV_PCM_FMTBIT_S32_LE, 984e1991d10SAlexandre Mergnat }, 985e1991d10SAlexandre Mergnat .ops = &mt8365_dai_hostless_ops, 986e1991d10SAlexandre Mergnat }, { 987e1991d10SAlexandre Mergnat .name = "HW_GAIN1", 988e1991d10SAlexandre Mergnat .id = MT8365_AFE_IO_HW_GAIN1, 989e1991d10SAlexandre Mergnat .playback = { 990e1991d10SAlexandre Mergnat .stream_name = "HW Gain 1 In", 991e1991d10SAlexandre Mergnat .channels_min = 1, 992e1991d10SAlexandre Mergnat .channels_max = 2, 993e1991d10SAlexandre Mergnat .rates = SNDRV_PCM_RATE_8000_192000, 994e1991d10SAlexandre Mergnat .formats = SNDRV_PCM_FMTBIT_S16_LE | 995e1991d10SAlexandre Mergnat SNDRV_PCM_FMTBIT_S24_LE | 996e1991d10SAlexandre Mergnat SNDRV_PCM_FMTBIT_S32_LE, 997e1991d10SAlexandre Mergnat }, 998e1991d10SAlexandre Mergnat .capture = { 999e1991d10SAlexandre Mergnat .stream_name = "HW Gain 1 Out", 1000e1991d10SAlexandre Mergnat .channels_min = 1, 1001e1991d10SAlexandre Mergnat .channels_max = 2, 1002e1991d10SAlexandre Mergnat .rates = SNDRV_PCM_RATE_8000_192000, 1003e1991d10SAlexandre Mergnat .formats = SNDRV_PCM_FMTBIT_S16_LE | 1004e1991d10SAlexandre Mergnat SNDRV_PCM_FMTBIT_S24_LE | 1005e1991d10SAlexandre Mergnat SNDRV_PCM_FMTBIT_S32_LE, 1006e1991d10SAlexandre Mergnat }, 1007e1991d10SAlexandre Mergnat .ops = &mt8365_afe_hw_gain1_ops, 1008e1991d10SAlexandre Mergnat .symmetric_rate = 1, 1009e1991d10SAlexandre Mergnat .symmetric_channels = 1, 1010e1991d10SAlexandre Mergnat .symmetric_sample_bits = 1, 1011e1991d10SAlexandre Mergnat }, 1012e1991d10SAlexandre Mergnat }; 1013e1991d10SAlexandre Mergnat 1014e1991d10SAlexandre Mergnat static const struct snd_kcontrol_new mt8365_afe_o00_mix[] = { 1015e1991d10SAlexandre Mergnat SOC_DAPM_SINGLE_AUTODISABLE("I05 Switch", AFE_CONN0, 5, 1, 0), 1016e1991d10SAlexandre Mergnat SOC_DAPM_SINGLE_AUTODISABLE("I07 Switch", AFE_CONN0, 7, 1, 0), 1017e1991d10SAlexandre Mergnat }; 1018e1991d10SAlexandre Mergnat 1019e1991d10SAlexandre Mergnat static const struct snd_kcontrol_new mt8365_afe_o01_mix[] = { 1020e1991d10SAlexandre Mergnat SOC_DAPM_SINGLE_AUTODISABLE("I06 Switch", AFE_CONN1, 6, 1, 0), 1021e1991d10SAlexandre Mergnat SOC_DAPM_SINGLE_AUTODISABLE("I08 Switch", AFE_CONN1, 8, 1, 0), 1022e1991d10SAlexandre Mergnat }; 1023e1991d10SAlexandre Mergnat 1024e1991d10SAlexandre Mergnat static const struct snd_kcontrol_new mt8365_afe_o03_mix[] = { 1025e1991d10SAlexandre Mergnat SOC_DAPM_SINGLE_AUTODISABLE("I05 Switch", AFE_CONN3, 5, 1, 0), 1026e1991d10SAlexandre Mergnat SOC_DAPM_SINGLE_AUTODISABLE("I07 Switch", AFE_CONN3, 7, 1, 0), 1027e1991d10SAlexandre Mergnat SOC_DAPM_SINGLE_AUTODISABLE("I00 Switch", AFE_CONN3, 0, 1, 0), 1028e1991d10SAlexandre Mergnat SOC_DAPM_SINGLE_AUTODISABLE("I10 Switch", AFE_CONN3, 10, 1, 0), 1029e1991d10SAlexandre Mergnat }; 1030e1991d10SAlexandre Mergnat 1031e1991d10SAlexandre Mergnat static const struct snd_kcontrol_new mt8365_afe_o04_mix[] = { 1032e1991d10SAlexandre Mergnat SOC_DAPM_SINGLE_AUTODISABLE("I06 Switch", AFE_CONN4, 6, 1, 0), 1033e1991d10SAlexandre Mergnat SOC_DAPM_SINGLE_AUTODISABLE("I08 Switch", AFE_CONN4, 8, 1, 0), 1034e1991d10SAlexandre Mergnat SOC_DAPM_SINGLE_AUTODISABLE("I01 Switch", AFE_CONN4, 1, 1, 0), 1035e1991d10SAlexandre Mergnat SOC_DAPM_SINGLE_AUTODISABLE("I11 Switch", AFE_CONN4, 11, 1, 0), 1036e1991d10SAlexandre Mergnat }; 1037e1991d10SAlexandre Mergnat 1038e1991d10SAlexandre Mergnat static const struct snd_kcontrol_new mt8365_afe_o05_mix[] = { 1039e1991d10SAlexandre Mergnat SOC_DAPM_SINGLE_AUTODISABLE("I00 Switch", AFE_CONN5, 0, 1, 0), 1040e1991d10SAlexandre Mergnat SOC_DAPM_SINGLE_AUTODISABLE("I03 Switch", AFE_CONN5, 3, 1, 0), 1041e1991d10SAlexandre Mergnat SOC_DAPM_SINGLE_AUTODISABLE("I05 Switch", AFE_CONN5, 5, 1, 0), 1042e1991d10SAlexandre Mergnat SOC_DAPM_SINGLE_AUTODISABLE("I07 Switch", AFE_CONN5, 7, 1, 0), 1043e1991d10SAlexandre Mergnat SOC_DAPM_SINGLE_AUTODISABLE("I09 Switch", AFE_CONN5, 9, 1, 0), 1044e1991d10SAlexandre Mergnat SOC_DAPM_SINGLE_AUTODISABLE("I14 Switch", AFE_CONN5, 14, 1, 0), 1045e1991d10SAlexandre Mergnat SOC_DAPM_SINGLE_AUTODISABLE("I16 Switch", AFE_CONN5, 16, 1, 0), 1046e1991d10SAlexandre Mergnat SOC_DAPM_SINGLE_AUTODISABLE("I18 Switch", AFE_CONN5, 18, 1, 0), 1047e1991d10SAlexandre Mergnat SOC_DAPM_SINGLE_AUTODISABLE("I20 Switch", AFE_CONN5, 20, 1, 0), 1048e1991d10SAlexandre Mergnat SOC_DAPM_SINGLE_AUTODISABLE("I23 Switch", AFE_CONN5, 23, 1, 0), 1049e1991d10SAlexandre Mergnat SOC_DAPM_SINGLE_AUTODISABLE("I10L Switch", AFE_CONN5, 10, 1, 0), 1050e1991d10SAlexandre Mergnat }; 1051e1991d10SAlexandre Mergnat 1052e1991d10SAlexandre Mergnat static const struct snd_kcontrol_new mt8365_afe_o06_mix[] = { 1053e1991d10SAlexandre Mergnat SOC_DAPM_SINGLE_AUTODISABLE("I01 Switch", AFE_CONN6, 1, 1, 0), 1054e1991d10SAlexandre Mergnat SOC_DAPM_SINGLE_AUTODISABLE("I04 Switch", AFE_CONN6, 4, 1, 0), 1055e1991d10SAlexandre Mergnat SOC_DAPM_SINGLE_AUTODISABLE("I06 Switch", AFE_CONN6, 6, 1, 0), 1056e1991d10SAlexandre Mergnat SOC_DAPM_SINGLE_AUTODISABLE("I08 Switch", AFE_CONN6, 8, 1, 0), 1057e1991d10SAlexandre Mergnat SOC_DAPM_SINGLE_AUTODISABLE("I22 Switch", AFE_CONN6, 22, 1, 0), 1058e1991d10SAlexandre Mergnat SOC_DAPM_SINGLE_AUTODISABLE("I15 Switch", AFE_CONN6, 15, 1, 0), 1059e1991d10SAlexandre Mergnat SOC_DAPM_SINGLE_AUTODISABLE("I17 Switch", AFE_CONN6, 17, 1, 0), 1060e1991d10SAlexandre Mergnat SOC_DAPM_SINGLE_AUTODISABLE("I19 Switch", AFE_CONN6, 19, 1, 0), 1061e1991d10SAlexandre Mergnat SOC_DAPM_SINGLE_AUTODISABLE("I21 Switch", AFE_CONN6, 21, 1, 0), 1062e1991d10SAlexandre Mergnat SOC_DAPM_SINGLE_AUTODISABLE("I24 Switch", AFE_CONN6, 24, 1, 0), 1063e1991d10SAlexandre Mergnat SOC_DAPM_SINGLE_AUTODISABLE("I11L Switch", AFE_CONN6, 11, 1, 0), 1064e1991d10SAlexandre Mergnat }; 1065e1991d10SAlexandre Mergnat 1066e1991d10SAlexandre Mergnat static const struct snd_kcontrol_new mt8365_afe_o07_mix[] = { 1067e1991d10SAlexandre Mergnat SOC_DAPM_SINGLE_AUTODISABLE("I05 Switch", AFE_CONN7, 5, 1, 0), 1068e1991d10SAlexandre Mergnat SOC_DAPM_SINGLE_AUTODISABLE("I07 Switch", AFE_CONN7, 7, 1, 0), 1069e1991d10SAlexandre Mergnat }; 1070e1991d10SAlexandre Mergnat 1071e1991d10SAlexandre Mergnat static const struct snd_kcontrol_new mt8365_afe_o08_mix[] = { 1072e1991d10SAlexandre Mergnat SOC_DAPM_SINGLE_AUTODISABLE("I06 Switch", AFE_CONN8, 6, 1, 0), 1073e1991d10SAlexandre Mergnat SOC_DAPM_SINGLE_AUTODISABLE("I08 Switch", AFE_CONN8, 8, 1, 0), 1074e1991d10SAlexandre Mergnat }; 1075e1991d10SAlexandre Mergnat 1076e1991d10SAlexandre Mergnat static const struct snd_kcontrol_new mt8365_afe_o09_mix[] = { 1077e1991d10SAlexandre Mergnat SOC_DAPM_SINGLE_AUTODISABLE("I00 Switch", AFE_CONN9, 0, 1, 0), 1078e1991d10SAlexandre Mergnat SOC_DAPM_SINGLE_AUTODISABLE("I03 Switch", AFE_CONN9, 3, 1, 0), 1079e1991d10SAlexandre Mergnat SOC_DAPM_SINGLE_AUTODISABLE("I09 Switch", AFE_CONN9, 9, 1, 0), 1080e1991d10SAlexandre Mergnat SOC_DAPM_SINGLE_AUTODISABLE("I14 Switch", AFE_CONN9, 14, 1, 0), 1081e1991d10SAlexandre Mergnat SOC_DAPM_SINGLE_AUTODISABLE("I16 Switch", AFE_CONN9, 16, 1, 0), 1082e1991d10SAlexandre Mergnat SOC_DAPM_SINGLE_AUTODISABLE("I18 Switch", AFE_CONN9, 18, 1, 0), 1083e1991d10SAlexandre Mergnat SOC_DAPM_SINGLE_AUTODISABLE("I20 Switch", AFE_CONN9, 20, 1, 0), 1084e1991d10SAlexandre Mergnat }; 1085e1991d10SAlexandre Mergnat 1086e1991d10SAlexandre Mergnat static const struct snd_kcontrol_new mt8365_afe_o10_mix[] = { 1087e1991d10SAlexandre Mergnat SOC_DAPM_SINGLE_AUTODISABLE("I01 Switch", AFE_CONN10, 1, 1, 0), 1088e1991d10SAlexandre Mergnat SOC_DAPM_SINGLE_AUTODISABLE("I04 Switch", AFE_CONN10, 4, 1, 0), 1089e1991d10SAlexandre Mergnat SOC_DAPM_SINGLE_AUTODISABLE("I22 Switch", AFE_CONN10, 22, 1, 0), 1090e1991d10SAlexandre Mergnat SOC_DAPM_SINGLE_AUTODISABLE("I15 Switch", AFE_CONN10, 15, 1, 0), 1091e1991d10SAlexandre Mergnat SOC_DAPM_SINGLE_AUTODISABLE("I17 Switch", AFE_CONN10, 17, 1, 0), 1092e1991d10SAlexandre Mergnat SOC_DAPM_SINGLE_AUTODISABLE("I19 Switch", AFE_CONN10, 19, 1, 0), 1093e1991d10SAlexandre Mergnat SOC_DAPM_SINGLE_AUTODISABLE("I21 Switch", AFE_CONN10, 21, 1, 0), 1094e1991d10SAlexandre Mergnat }; 1095e1991d10SAlexandre Mergnat 1096e1991d10SAlexandre Mergnat static const struct snd_kcontrol_new mt8365_afe_o11_mix[] = { 1097e1991d10SAlexandre Mergnat SOC_DAPM_SINGLE_AUTODISABLE("I00 Switch", AFE_CONN11, 0, 1, 0), 1098e1991d10SAlexandre Mergnat SOC_DAPM_SINGLE_AUTODISABLE("I03 Switch", AFE_CONN11, 3, 1, 0), 1099e1991d10SAlexandre Mergnat SOC_DAPM_SINGLE_AUTODISABLE("I09 Switch", AFE_CONN11, 9, 1, 0), 1100e1991d10SAlexandre Mergnat SOC_DAPM_SINGLE_AUTODISABLE("I14 Switch", AFE_CONN11, 14, 1, 0), 1101e1991d10SAlexandre Mergnat SOC_DAPM_SINGLE_AUTODISABLE("I16 Switch", AFE_CONN11, 16, 1, 0), 1102e1991d10SAlexandre Mergnat SOC_DAPM_SINGLE_AUTODISABLE("I18 Switch", AFE_CONN11, 18, 1, 0), 1103e1991d10SAlexandre Mergnat SOC_DAPM_SINGLE_AUTODISABLE("I20 Switch", AFE_CONN11, 20, 1, 0), 1104e1991d10SAlexandre Mergnat }; 1105e1991d10SAlexandre Mergnat 1106e1991d10SAlexandre Mergnat static const struct snd_kcontrol_new mt8365_afe_o12_mix[] = { 1107e1991d10SAlexandre Mergnat SOC_DAPM_SINGLE_AUTODISABLE("I01 Switch", AFE_CONN12, 1, 1, 0), 1108e1991d10SAlexandre Mergnat SOC_DAPM_SINGLE_AUTODISABLE("I04 Switch", AFE_CONN12, 4, 1, 0), 1109e1991d10SAlexandre Mergnat SOC_DAPM_SINGLE_AUTODISABLE("I22 Switch", AFE_CONN12, 22, 1, 0), 1110e1991d10SAlexandre Mergnat SOC_DAPM_SINGLE_AUTODISABLE("I15 Switch", AFE_CONN12, 15, 1, 0), 1111e1991d10SAlexandre Mergnat SOC_DAPM_SINGLE_AUTODISABLE("I17 Switch", AFE_CONN12, 17, 1, 0), 1112e1991d10SAlexandre Mergnat SOC_DAPM_SINGLE_AUTODISABLE("I19 Switch", AFE_CONN12, 19, 1, 0), 1113e1991d10SAlexandre Mergnat SOC_DAPM_SINGLE_AUTODISABLE("I21 Switch", AFE_CONN12, 21, 1, 0), 1114e1991d10SAlexandre Mergnat }; 1115e1991d10SAlexandre Mergnat 1116e1991d10SAlexandre Mergnat static const struct snd_kcontrol_new mt8365_afe_o13_mix[] = { 1117e1991d10SAlexandre Mergnat SOC_DAPM_SINGLE_AUTODISABLE("I00 Switch", AFE_CONN13, 0, 1, 0), 1118e1991d10SAlexandre Mergnat }; 1119e1991d10SAlexandre Mergnat 1120e1991d10SAlexandre Mergnat static const struct snd_kcontrol_new mt8365_afe_o14_mix[] = { 1121e1991d10SAlexandre Mergnat SOC_DAPM_SINGLE_AUTODISABLE("I01 Switch", AFE_CONN14, 1, 1, 0), 1122e1991d10SAlexandre Mergnat }; 1123e1991d10SAlexandre Mergnat 1124e1991d10SAlexandre Mergnat static const struct snd_kcontrol_new mt8365_afe_o15_mix[] = { 1125e1991d10SAlexandre Mergnat }; 1126e1991d10SAlexandre Mergnat 1127e1991d10SAlexandre Mergnat static const struct snd_kcontrol_new mt8365_afe_o16_mix[] = { 1128e1991d10SAlexandre Mergnat }; 1129e1991d10SAlexandre Mergnat 1130e1991d10SAlexandre Mergnat static const struct snd_kcontrol_new mt8365_afe_o17_mix[] = { 1131e1991d10SAlexandre Mergnat SOC_DAPM_SINGLE_AUTODISABLE("I03 Switch", AFE_CONN17, 3, 1, 0), 1132e1991d10SAlexandre Mergnat SOC_DAPM_SINGLE_AUTODISABLE("I14 Switch", AFE_CONN17, 14, 1, 0), 1133e1991d10SAlexandre Mergnat }; 1134e1991d10SAlexandre Mergnat 1135e1991d10SAlexandre Mergnat static const struct snd_kcontrol_new mt8365_afe_o18_mix[] = { 1136e1991d10SAlexandre Mergnat SOC_DAPM_SINGLE_AUTODISABLE("I04 Switch", AFE_CONN18, 4, 1, 0), 1137e1991d10SAlexandre Mergnat SOC_DAPM_SINGLE_AUTODISABLE("I15 Switch", AFE_CONN18, 15, 1, 0), 1138e1991d10SAlexandre Mergnat SOC_DAPM_SINGLE_AUTODISABLE("I23 Switch", AFE_CONN18, 23, 1, 0), 1139e1991d10SAlexandre Mergnat SOC_DAPM_SINGLE_AUTODISABLE("I25 Switch", AFE_CONN18, 25, 1, 0), 1140e1991d10SAlexandre Mergnat }; 1141e1991d10SAlexandre Mergnat 1142e1991d10SAlexandre Mergnat static const struct snd_kcontrol_new mt8365_afe_o19_mix[] = { 1143e1991d10SAlexandre Mergnat SOC_DAPM_SINGLE_AUTODISABLE("I04 Switch", AFE_CONN19, 4, 1, 0), 1144e1991d10SAlexandre Mergnat SOC_DAPM_SINGLE_AUTODISABLE("I16 Switch", AFE_CONN19, 16, 1, 0), 1145e1991d10SAlexandre Mergnat SOC_DAPM_SINGLE_AUTODISABLE("I23 Switch", AFE_CONN19, 23, 1, 0), 1146e1991d10SAlexandre Mergnat SOC_DAPM_SINGLE_AUTODISABLE("I24 Switch", AFE_CONN19, 24, 1, 0), 1147e1991d10SAlexandre Mergnat SOC_DAPM_SINGLE_AUTODISABLE("I25 Switch", AFE_CONN19, 25, 1, 0), 1148e1991d10SAlexandre Mergnat SOC_DAPM_SINGLE_AUTODISABLE("I26 Switch", AFE_CONN19, 26, 1, 0), 1149e1991d10SAlexandre Mergnat }; 1150e1991d10SAlexandre Mergnat 1151e1991d10SAlexandre Mergnat static const struct snd_kcontrol_new mt8365_afe_o20_mix[] = { 1152e1991d10SAlexandre Mergnat SOC_DAPM_SINGLE_AUTODISABLE("I17 Switch", AFE_CONN20, 17, 1, 0), 1153e1991d10SAlexandre Mergnat SOC_DAPM_SINGLE_AUTODISABLE("I24 Switch", AFE_CONN20, 24, 1, 0), 1154e1991d10SAlexandre Mergnat SOC_DAPM_SINGLE_AUTODISABLE("I26 Switch", AFE_CONN20, 26, 1, 0), 1155e1991d10SAlexandre Mergnat }; 1156e1991d10SAlexandre Mergnat 1157e1991d10SAlexandre Mergnat static const struct snd_kcontrol_new mt8365_afe_o21_mix[] = { 1158e1991d10SAlexandre Mergnat SOC_DAPM_SINGLE_AUTODISABLE("I18 Switch", AFE_CONN21, 18, 1, 0), 1159e1991d10SAlexandre Mergnat SOC_DAPM_SINGLE_AUTODISABLE("I23 Switch", AFE_CONN21, 23, 1, 0), 1160e1991d10SAlexandre Mergnat SOC_DAPM_SINGLE_AUTODISABLE("I25 Switch", AFE_CONN21, 25, 1, 0), 1161e1991d10SAlexandre Mergnat }; 1162e1991d10SAlexandre Mergnat 1163e1991d10SAlexandre Mergnat static const struct snd_kcontrol_new mt8365_afe_o22_mix[] = { 1164e1991d10SAlexandre Mergnat SOC_DAPM_SINGLE_AUTODISABLE("I19 Switch", AFE_CONN22, 19, 1, 0), 1165e1991d10SAlexandre Mergnat SOC_DAPM_SINGLE_AUTODISABLE("I24 Switch", AFE_CONN22, 24, 1, 0), 1166e1991d10SAlexandre Mergnat SOC_DAPM_SINGLE_AUTODISABLE("I26 Switch", AFE_CONN22, 26, 1, 0), 1167e1991d10SAlexandre Mergnat }; 1168e1991d10SAlexandre Mergnat 1169e1991d10SAlexandre Mergnat static const struct snd_kcontrol_new mt8365_afe_o23_mix[] = { 1170e1991d10SAlexandre Mergnat SOC_DAPM_SINGLE_AUTODISABLE("I20 Switch", AFE_CONN23, 20, 1, 0), 1171e1991d10SAlexandre Mergnat SOC_DAPM_SINGLE_AUTODISABLE("I23 Switch", AFE_CONN23, 23, 1, 0), 1172e1991d10SAlexandre Mergnat SOC_DAPM_SINGLE_AUTODISABLE("I25 Switch", AFE_CONN23, 25, 1, 0), 1173e1991d10SAlexandre Mergnat }; 1174e1991d10SAlexandre Mergnat 1175e1991d10SAlexandre Mergnat static const struct snd_kcontrol_new mt8365_afe_o24_mix[] = { 1176e1991d10SAlexandre Mergnat SOC_DAPM_SINGLE_AUTODISABLE("I21 Switch", AFE_CONN24, 21, 1, 0), 1177e1991d10SAlexandre Mergnat SOC_DAPM_SINGLE_AUTODISABLE("I24 Switch", AFE_CONN24, 24, 1, 0), 1178e1991d10SAlexandre Mergnat SOC_DAPM_SINGLE_AUTODISABLE("I26 Switch", AFE_CONN24, 26, 1, 0), 1179e1991d10SAlexandre Mergnat SOC_DAPM_SINGLE_AUTODISABLE("I23 Switch", AFE_CONN24, 23, 1, 0), 1180e1991d10SAlexandre Mergnat SOC_DAPM_SINGLE_AUTODISABLE("I25 Switch", AFE_CONN24, 25, 1, 0), 1181e1991d10SAlexandre Mergnat }; 1182e1991d10SAlexandre Mergnat 1183e1991d10SAlexandre Mergnat static const struct snd_kcontrol_new mt8365_afe_o25_mix[] = { 1184e1991d10SAlexandre Mergnat SOC_DAPM_SINGLE_AUTODISABLE("I27 Switch", AFE_CONN25, 27, 1, 0), 1185e1991d10SAlexandre Mergnat SOC_DAPM_SINGLE_AUTODISABLE("I23 Switch", AFE_CONN25, 23, 1, 0), 1186e1991d10SAlexandre Mergnat SOC_DAPM_SINGLE_AUTODISABLE("I25 Switch", AFE_CONN25, 25, 1, 0), 1187e1991d10SAlexandre Mergnat }; 1188e1991d10SAlexandre Mergnat 1189e1991d10SAlexandre Mergnat static const struct snd_kcontrol_new mt8365_afe_o26_mix[] = { 1190e1991d10SAlexandre Mergnat SOC_DAPM_SINGLE_AUTODISABLE("I28 Switch", AFE_CONN26, 28, 1, 0), 1191e1991d10SAlexandre Mergnat SOC_DAPM_SINGLE_AUTODISABLE("I24 Switch", AFE_CONN26, 24, 1, 0), 1192e1991d10SAlexandre Mergnat SOC_DAPM_SINGLE_AUTODISABLE("I26 Switch", AFE_CONN26, 26, 1, 0), 1193e1991d10SAlexandre Mergnat }; 1194e1991d10SAlexandre Mergnat 1195e1991d10SAlexandre Mergnat static const struct snd_kcontrol_new mt8365_afe_o27_mix[] = { 1196e1991d10SAlexandre Mergnat SOC_DAPM_SINGLE_AUTODISABLE("I05 Switch", AFE_CONN27, 5, 1, 0), 1197e1991d10SAlexandre Mergnat SOC_DAPM_SINGLE_AUTODISABLE("I07 Switch", AFE_CONN27, 7, 1, 0), 1198e1991d10SAlexandre Mergnat }; 1199e1991d10SAlexandre Mergnat 1200e1991d10SAlexandre Mergnat static const struct snd_kcontrol_new mt8365_afe_o28_mix[] = { 1201e1991d10SAlexandre Mergnat SOC_DAPM_SINGLE_AUTODISABLE("I06 Switch", AFE_CONN28, 6, 1, 0), 1202e1991d10SAlexandre Mergnat SOC_DAPM_SINGLE_AUTODISABLE("I08 Switch", AFE_CONN28, 8, 1, 0), 1203e1991d10SAlexandre Mergnat }; 1204e1991d10SAlexandre Mergnat 1205e1991d10SAlexandre Mergnat static const struct snd_kcontrol_new mt8365_afe_o29_mix[] = { 1206e1991d10SAlexandre Mergnat SOC_DAPM_SINGLE_AUTODISABLE("I05 Switch", AFE_CONN29, 5, 1, 0), 1207e1991d10SAlexandre Mergnat SOC_DAPM_SINGLE_AUTODISABLE("I07 Switch", AFE_CONN29, 7, 1, 0), 1208e1991d10SAlexandre Mergnat }; 1209e1991d10SAlexandre Mergnat 1210e1991d10SAlexandre Mergnat static const struct snd_kcontrol_new mt8365_afe_o30_mix[] = { 1211e1991d10SAlexandre Mergnat SOC_DAPM_SINGLE_AUTODISABLE("I06 Switch", AFE_CONN30, 6, 1, 0), 1212e1991d10SAlexandre Mergnat SOC_DAPM_SINGLE_AUTODISABLE("I08 Switch", AFE_CONN30, 8, 1, 0), 1213e1991d10SAlexandre Mergnat }; 1214e1991d10SAlexandre Mergnat 1215e1991d10SAlexandre Mergnat static const struct snd_kcontrol_new mt8365_afe_o31_mix[] = { 1216e1991d10SAlexandre Mergnat SOC_DAPM_SINGLE_AUTODISABLE("I29 Switch", AFE_CONN31, 29, 1, 0), 1217e1991d10SAlexandre Mergnat }; 1218e1991d10SAlexandre Mergnat 1219e1991d10SAlexandre Mergnat static const struct snd_kcontrol_new mt8365_afe_o32_mix[] = { 1220e1991d10SAlexandre Mergnat SOC_DAPM_SINGLE_AUTODISABLE("I30 Switch", AFE_CONN32, 30, 1, 0), 1221e1991d10SAlexandre Mergnat }; 1222e1991d10SAlexandre Mergnat 1223e1991d10SAlexandre Mergnat static const struct snd_kcontrol_new mt8365_afe_o33_mix[] = { 1224e1991d10SAlexandre Mergnat SOC_DAPM_SINGLE_AUTODISABLE("I31 Switch", AFE_CONN33, 31, 1, 0), 1225e1991d10SAlexandre Mergnat }; 1226e1991d10SAlexandre Mergnat 1227e1991d10SAlexandre Mergnat static const struct snd_kcontrol_new mt8365_afe_o34_mix[] = { 1228e1991d10SAlexandre Mergnat SOC_DAPM_SINGLE_AUTODISABLE("I32 Switch", AFE_CONN34_1, 0, 1, 0), 1229e1991d10SAlexandre Mergnat }; 1230e1991d10SAlexandre Mergnat 1231e1991d10SAlexandre Mergnat static const struct snd_kcontrol_new mt8365_afe_o35_mix[] = { 1232e1991d10SAlexandre Mergnat SOC_DAPM_SINGLE_AUTODISABLE("I33 Switch", AFE_CONN35_1, 1, 1, 0), 1233e1991d10SAlexandre Mergnat }; 1234e1991d10SAlexandre Mergnat 1235e1991d10SAlexandre Mergnat static const struct snd_kcontrol_new mt8365_afe_o36_mix[] = { 1236e1991d10SAlexandre Mergnat SOC_DAPM_SINGLE_AUTODISABLE("I34 Switch", AFE_CONN36_1, 2, 1, 0), 1237e1991d10SAlexandre Mergnat }; 1238e1991d10SAlexandre Mergnat 1239e1991d10SAlexandre Mergnat static const struct snd_kcontrol_new mtk_hw_gain1_in_ch1_mix[] = { 1240e1991d10SAlexandre Mergnat SOC_DAPM_SINGLE_AUTODISABLE("CONNSYS_I2S_CH1 Switch", AFE_CONN13, 1241e1991d10SAlexandre Mergnat 0, 1, 0), 1242e1991d10SAlexandre Mergnat }; 1243e1991d10SAlexandre Mergnat 1244e1991d10SAlexandre Mergnat static const struct snd_kcontrol_new mtk_hw_gain1_in_ch2_mix[] = { 1245e1991d10SAlexandre Mergnat SOC_DAPM_SINGLE_AUTODISABLE("CONNSYS_I2S_CH2 Switch", AFE_CONN14, 1246e1991d10SAlexandre Mergnat 1, 1, 0), 1247e1991d10SAlexandre Mergnat }; 1248e1991d10SAlexandre Mergnat 1249e1991d10SAlexandre Mergnat static int mt8365_afe_cm2_io_input_mux_get(struct snd_kcontrol *kcontrol, 1250e1991d10SAlexandre Mergnat struct snd_ctl_elem_value *ucontrol) 1251e1991d10SAlexandre Mergnat { 1252e1991d10SAlexandre Mergnat ucontrol->value.integer.value[0] = mCM2Input; 1253e1991d10SAlexandre Mergnat 1254e1991d10SAlexandre Mergnat return 0; 1255e1991d10SAlexandre Mergnat } 1256e1991d10SAlexandre Mergnat 1257e1991d10SAlexandre Mergnat static int mt8365_afe_cm2_io_input_mux_put(struct snd_kcontrol *kcontrol, 1258e1991d10SAlexandre Mergnat struct snd_ctl_elem_value *ucontrol) 1259e1991d10SAlexandre Mergnat { 1260e1991d10SAlexandre Mergnat struct snd_soc_dapm_context *dapm = 1261e1991d10SAlexandre Mergnat snd_soc_dapm_kcontrol_dapm(kcontrol); 1262e1991d10SAlexandre Mergnat struct snd_soc_component *comp = snd_soc_dapm_to_component(dapm); 1263e1991d10SAlexandre Mergnat struct mtk_base_afe *afe = snd_soc_component_get_drvdata(comp); 1264e1991d10SAlexandre Mergnat struct mt8365_afe_private *afe_priv = afe->platform_priv; 1265e1991d10SAlexandre Mergnat int ret; 1266e1991d10SAlexandre Mergnat 1267e1991d10SAlexandre Mergnat mCM2Input = ucontrol->value.enumerated.item[0]; 1268e1991d10SAlexandre Mergnat 1269e1991d10SAlexandre Mergnat afe_priv->cm2_mux_input = mCM2Input; 1270e1991d10SAlexandre Mergnat ret = snd_soc_dapm_put_enum_double(kcontrol, ucontrol); 1271e1991d10SAlexandre Mergnat 1272e1991d10SAlexandre Mergnat return ret; 1273e1991d10SAlexandre Mergnat } 1274e1991d10SAlexandre Mergnat 1275e1991d10SAlexandre Mergnat static const char * const fmhwgain_text[] = { 1276e1991d10SAlexandre Mergnat "OPEN", "FM_HW_GAIN_IO" 1277e1991d10SAlexandre Mergnat }; 1278e1991d10SAlexandre Mergnat 1279e1991d10SAlexandre Mergnat static const char * const ain_text[] = { 1280e1991d10SAlexandre Mergnat "INT ADC", "EXT ADC", 1281e1991d10SAlexandre Mergnat }; 1282e1991d10SAlexandre Mergnat 1283e1991d10SAlexandre Mergnat static const char * const vul2_in_input_text[] = { 1284e1991d10SAlexandre Mergnat "VUL2_IN_FROM_O17O18", "VUL2_IN_FROM_CM1", 1285e1991d10SAlexandre Mergnat }; 1286e1991d10SAlexandre Mergnat 1287e1991d10SAlexandre Mergnat static const char * const mt8365_afe_cm2_mux_text[] = { 1288e1991d10SAlexandre Mergnat "OPEN", "FROM_GASRC1_OUT", "FROM_GASRC2_OUT", "FROM_TDM_ASRC_OUT", 1289e1991d10SAlexandre Mergnat }; 1290e1991d10SAlexandre Mergnat 1291e1991d10SAlexandre Mergnat static SOC_ENUM_SINGLE_VIRT_DECL(fmhwgain_enum, fmhwgain_text); 1292e1991d10SAlexandre Mergnat static SOC_ENUM_SINGLE_DECL(ain_enum, AFE_ADDA_TOP_CON0, 0, ain_text); 1293e1991d10SAlexandre Mergnat static SOC_ENUM_SINGLE_VIRT_DECL(vul2_in_input_enum, vul2_in_input_text); 1294e1991d10SAlexandre Mergnat static SOC_ENUM_SINGLE_VIRT_DECL(mt8365_afe_cm2_mux_input_enum, 1295e1991d10SAlexandre Mergnat mt8365_afe_cm2_mux_text); 1296e1991d10SAlexandre Mergnat 1297e1991d10SAlexandre Mergnat static const struct snd_kcontrol_new fmhwgain_mux = 1298e1991d10SAlexandre Mergnat SOC_DAPM_ENUM("FM HW Gain Source", fmhwgain_enum); 1299e1991d10SAlexandre Mergnat 1300e1991d10SAlexandre Mergnat static const struct snd_kcontrol_new ain_mux = 1301e1991d10SAlexandre Mergnat SOC_DAPM_ENUM("AIN Source", ain_enum); 1302e1991d10SAlexandre Mergnat 1303e1991d10SAlexandre Mergnat static const struct snd_kcontrol_new vul2_in_input_mux = 1304e1991d10SAlexandre Mergnat SOC_DAPM_ENUM("VUL2 Input", vul2_in_input_enum); 1305e1991d10SAlexandre Mergnat 1306e1991d10SAlexandre Mergnat static const struct snd_kcontrol_new mt8365_afe_cm2_mux_input_mux = 1307e1991d10SAlexandre Mergnat SOC_DAPM_ENUM_EXT("CM2_MUX Source", mt8365_afe_cm2_mux_input_enum, 1308e1991d10SAlexandre Mergnat mt8365_afe_cm2_io_input_mux_get, 1309e1991d10SAlexandre Mergnat mt8365_afe_cm2_io_input_mux_put); 1310e1991d10SAlexandre Mergnat 1311e1991d10SAlexandre Mergnat static const struct snd_soc_dapm_widget mt8365_memif_widgets[] = { 1312e1991d10SAlexandre Mergnat /* inter-connections */ 1313e1991d10SAlexandre Mergnat SND_SOC_DAPM_MIXER("I00", SND_SOC_NOPM, 0, 0, NULL, 0), 1314e1991d10SAlexandre Mergnat SND_SOC_DAPM_MIXER("I01", SND_SOC_NOPM, 0, 0, NULL, 0), 1315e1991d10SAlexandre Mergnat SND_SOC_DAPM_MIXER("I03", SND_SOC_NOPM, 0, 0, NULL, 0), 1316e1991d10SAlexandre Mergnat SND_SOC_DAPM_MIXER("I04", SND_SOC_NOPM, 0, 0, NULL, 0), 1317e1991d10SAlexandre Mergnat SND_SOC_DAPM_MIXER("I05", SND_SOC_NOPM, 0, 0, NULL, 0), 1318e1991d10SAlexandre Mergnat SND_SOC_DAPM_MIXER("I06", SND_SOC_NOPM, 0, 0, NULL, 0), 1319e1991d10SAlexandre Mergnat SND_SOC_DAPM_MIXER("I07", SND_SOC_NOPM, 0, 0, NULL, 0), 1320e1991d10SAlexandre Mergnat SND_SOC_DAPM_MIXER("I08", SND_SOC_NOPM, 0, 0, NULL, 0), 1321e1991d10SAlexandre Mergnat SND_SOC_DAPM_MIXER("I05L", SND_SOC_NOPM, 0, 0, NULL, 0), 1322e1991d10SAlexandre Mergnat SND_SOC_DAPM_MIXER("I06L", SND_SOC_NOPM, 0, 0, NULL, 0), 1323e1991d10SAlexandre Mergnat SND_SOC_DAPM_MIXER("I07L", SND_SOC_NOPM, 0, 0, NULL, 0), 1324e1991d10SAlexandre Mergnat SND_SOC_DAPM_MIXER("I08L", SND_SOC_NOPM, 0, 0, NULL, 0), 1325e1991d10SAlexandre Mergnat SND_SOC_DAPM_MIXER("I09", SND_SOC_NOPM, 0, 0, NULL, 0), 1326e1991d10SAlexandre Mergnat SND_SOC_DAPM_MIXER("I10", SND_SOC_NOPM, 0, 0, NULL, 0), 1327e1991d10SAlexandre Mergnat SND_SOC_DAPM_MIXER("I11", SND_SOC_NOPM, 0, 0, NULL, 0), 1328e1991d10SAlexandre Mergnat SND_SOC_DAPM_MIXER("I10L", SND_SOC_NOPM, 0, 0, NULL, 0), 1329e1991d10SAlexandre Mergnat SND_SOC_DAPM_MIXER("I11L", SND_SOC_NOPM, 0, 0, NULL, 0), 1330e1991d10SAlexandre Mergnat SND_SOC_DAPM_MIXER("I12", SND_SOC_NOPM, 0, 0, NULL, 0), 1331e1991d10SAlexandre Mergnat SND_SOC_DAPM_MIXER("I13", SND_SOC_NOPM, 0, 0, NULL, 0), 1332e1991d10SAlexandre Mergnat SND_SOC_DAPM_MIXER("I14", SND_SOC_NOPM, 0, 0, NULL, 0), 1333e1991d10SAlexandre Mergnat SND_SOC_DAPM_MIXER("I15", SND_SOC_NOPM, 0, 0, NULL, 0), 1334e1991d10SAlexandre Mergnat SND_SOC_DAPM_MIXER("I16", SND_SOC_NOPM, 0, 0, NULL, 0), 1335e1991d10SAlexandre Mergnat SND_SOC_DAPM_MIXER("I17", SND_SOC_NOPM, 0, 0, NULL, 0), 1336e1991d10SAlexandre Mergnat SND_SOC_DAPM_MIXER("I18", SND_SOC_NOPM, 0, 0, NULL, 0), 1337e1991d10SAlexandre Mergnat SND_SOC_DAPM_MIXER("I19", SND_SOC_NOPM, 0, 0, NULL, 0), 1338e1991d10SAlexandre Mergnat SND_SOC_DAPM_MIXER("I20", SND_SOC_NOPM, 0, 0, NULL, 0), 1339e1991d10SAlexandre Mergnat SND_SOC_DAPM_MIXER("I21", SND_SOC_NOPM, 0, 0, NULL, 0), 1340e1991d10SAlexandre Mergnat SND_SOC_DAPM_MIXER("I22", SND_SOC_NOPM, 0, 0, NULL, 0), 1341e1991d10SAlexandre Mergnat SND_SOC_DAPM_MIXER("I23", SND_SOC_NOPM, 0, 0, NULL, 0), 1342e1991d10SAlexandre Mergnat SND_SOC_DAPM_MIXER("I24", SND_SOC_NOPM, 0, 0, NULL, 0), 1343e1991d10SAlexandre Mergnat SND_SOC_DAPM_MIXER("I25", SND_SOC_NOPM, 0, 0, NULL, 0), 1344e1991d10SAlexandre Mergnat SND_SOC_DAPM_MIXER("I26", SND_SOC_NOPM, 0, 0, NULL, 0), 1345e1991d10SAlexandre Mergnat SND_SOC_DAPM_MIXER("I27", SND_SOC_NOPM, 0, 0, NULL, 0), 1346e1991d10SAlexandre Mergnat SND_SOC_DAPM_MIXER("I28", SND_SOC_NOPM, 0, 0, NULL, 0), 1347e1991d10SAlexandre Mergnat SND_SOC_DAPM_MIXER("I29", SND_SOC_NOPM, 0, 0, NULL, 0), 1348e1991d10SAlexandre Mergnat SND_SOC_DAPM_MIXER("I30", SND_SOC_NOPM, 0, 0, NULL, 0), 1349e1991d10SAlexandre Mergnat SND_SOC_DAPM_MIXER("I31", SND_SOC_NOPM, 0, 0, NULL, 0), 1350e1991d10SAlexandre Mergnat SND_SOC_DAPM_MIXER("I32", SND_SOC_NOPM, 0, 0, NULL, 0), 1351e1991d10SAlexandre Mergnat SND_SOC_DAPM_MIXER("I33", SND_SOC_NOPM, 0, 0, NULL, 0), 1352e1991d10SAlexandre Mergnat SND_SOC_DAPM_MIXER("I34", SND_SOC_NOPM, 0, 0, NULL, 0), 1353e1991d10SAlexandre Mergnat SND_SOC_DAPM_MIXER("O00", SND_SOC_NOPM, 0, 0, 1354e1991d10SAlexandre Mergnat mt8365_afe_o00_mix, ARRAY_SIZE(mt8365_afe_o00_mix)), 1355e1991d10SAlexandre Mergnat SND_SOC_DAPM_MIXER("O01", SND_SOC_NOPM, 0, 0, 1356e1991d10SAlexandre Mergnat mt8365_afe_o01_mix, ARRAY_SIZE(mt8365_afe_o01_mix)), 1357e1991d10SAlexandre Mergnat SND_SOC_DAPM_MIXER("O03", SND_SOC_NOPM, 0, 0, 1358e1991d10SAlexandre Mergnat mt8365_afe_o03_mix, ARRAY_SIZE(mt8365_afe_o03_mix)), 1359e1991d10SAlexandre Mergnat SND_SOC_DAPM_MIXER("O04", SND_SOC_NOPM, 0, 0, 1360e1991d10SAlexandre Mergnat mt8365_afe_o04_mix, ARRAY_SIZE(mt8365_afe_o04_mix)), 1361e1991d10SAlexandre Mergnat SND_SOC_DAPM_MIXER("O05", SND_SOC_NOPM, 0, 0, 1362e1991d10SAlexandre Mergnat mt8365_afe_o05_mix, ARRAY_SIZE(mt8365_afe_o05_mix)), 1363e1991d10SAlexandre Mergnat SND_SOC_DAPM_MIXER("O06", SND_SOC_NOPM, 0, 0, 1364e1991d10SAlexandre Mergnat mt8365_afe_o06_mix, ARRAY_SIZE(mt8365_afe_o06_mix)), 1365e1991d10SAlexandre Mergnat SND_SOC_DAPM_MIXER("O07", SND_SOC_NOPM, 0, 0, 1366e1991d10SAlexandre Mergnat mt8365_afe_o07_mix, ARRAY_SIZE(mt8365_afe_o07_mix)), 1367e1991d10SAlexandre Mergnat SND_SOC_DAPM_MIXER("O08", SND_SOC_NOPM, 0, 0, 1368e1991d10SAlexandre Mergnat mt8365_afe_o08_mix, ARRAY_SIZE(mt8365_afe_o08_mix)), 1369e1991d10SAlexandre Mergnat SND_SOC_DAPM_MIXER("O09", SND_SOC_NOPM, 0, 0, 1370e1991d10SAlexandre Mergnat mt8365_afe_o09_mix, ARRAY_SIZE(mt8365_afe_o09_mix)), 1371e1991d10SAlexandre Mergnat SND_SOC_DAPM_MIXER("O10", SND_SOC_NOPM, 0, 0, 1372e1991d10SAlexandre Mergnat mt8365_afe_o10_mix, ARRAY_SIZE(mt8365_afe_o10_mix)), 1373e1991d10SAlexandre Mergnat SND_SOC_DAPM_MIXER("O11", SND_SOC_NOPM, 0, 0, 1374e1991d10SAlexandre Mergnat mt8365_afe_o11_mix, ARRAY_SIZE(mt8365_afe_o11_mix)), 1375e1991d10SAlexandre Mergnat SND_SOC_DAPM_MIXER("O12", SND_SOC_NOPM, 0, 0, 1376e1991d10SAlexandre Mergnat mt8365_afe_o12_mix, ARRAY_SIZE(mt8365_afe_o12_mix)), 1377e1991d10SAlexandre Mergnat SND_SOC_DAPM_MIXER("O13", SND_SOC_NOPM, 0, 0, 1378e1991d10SAlexandre Mergnat mt8365_afe_o13_mix, ARRAY_SIZE(mt8365_afe_o13_mix)), 1379e1991d10SAlexandre Mergnat SND_SOC_DAPM_MIXER("O14", SND_SOC_NOPM, 0, 0, 1380e1991d10SAlexandre Mergnat mt8365_afe_o14_mix, ARRAY_SIZE(mt8365_afe_o14_mix)), 1381e1991d10SAlexandre Mergnat SND_SOC_DAPM_MIXER("O15", SND_SOC_NOPM, 0, 0, 1382e1991d10SAlexandre Mergnat mt8365_afe_o15_mix, ARRAY_SIZE(mt8365_afe_o15_mix)), 1383e1991d10SAlexandre Mergnat SND_SOC_DAPM_MIXER("O16", SND_SOC_NOPM, 0, 0, 1384e1991d10SAlexandre Mergnat mt8365_afe_o16_mix, ARRAY_SIZE(mt8365_afe_o16_mix)), 1385e1991d10SAlexandre Mergnat SND_SOC_DAPM_MIXER("O17", SND_SOC_NOPM, 0, 0, 1386e1991d10SAlexandre Mergnat mt8365_afe_o17_mix, ARRAY_SIZE(mt8365_afe_o17_mix)), 1387e1991d10SAlexandre Mergnat SND_SOC_DAPM_MIXER("O18", SND_SOC_NOPM, 0, 0, 1388e1991d10SAlexandre Mergnat mt8365_afe_o18_mix, ARRAY_SIZE(mt8365_afe_o18_mix)), 1389e1991d10SAlexandre Mergnat SND_SOC_DAPM_MIXER("O19", SND_SOC_NOPM, 0, 0, 1390e1991d10SAlexandre Mergnat mt8365_afe_o19_mix, ARRAY_SIZE(mt8365_afe_o19_mix)), 1391e1991d10SAlexandre Mergnat SND_SOC_DAPM_MIXER("O20", SND_SOC_NOPM, 0, 0, 1392e1991d10SAlexandre Mergnat mt8365_afe_o20_mix, ARRAY_SIZE(mt8365_afe_o20_mix)), 1393e1991d10SAlexandre Mergnat SND_SOC_DAPM_MIXER("O21", SND_SOC_NOPM, 0, 0, 1394e1991d10SAlexandre Mergnat mt8365_afe_o21_mix, ARRAY_SIZE(mt8365_afe_o21_mix)), 1395e1991d10SAlexandre Mergnat SND_SOC_DAPM_MIXER("O22", SND_SOC_NOPM, 0, 0, 1396e1991d10SAlexandre Mergnat mt8365_afe_o22_mix, ARRAY_SIZE(mt8365_afe_o22_mix)), 1397e1991d10SAlexandre Mergnat SND_SOC_DAPM_MIXER("O23", SND_SOC_NOPM, 0, 0, 1398e1991d10SAlexandre Mergnat mt8365_afe_o23_mix, ARRAY_SIZE(mt8365_afe_o23_mix)), 1399e1991d10SAlexandre Mergnat SND_SOC_DAPM_MIXER("O24", SND_SOC_NOPM, 0, 0, 1400e1991d10SAlexandre Mergnat mt8365_afe_o24_mix, ARRAY_SIZE(mt8365_afe_o24_mix)), 1401e1991d10SAlexandre Mergnat SND_SOC_DAPM_MIXER("O25", SND_SOC_NOPM, 0, 0, 1402e1991d10SAlexandre Mergnat mt8365_afe_o25_mix, ARRAY_SIZE(mt8365_afe_o25_mix)), 1403e1991d10SAlexandre Mergnat SND_SOC_DAPM_MIXER("O26", SND_SOC_NOPM, 0, 0, 1404e1991d10SAlexandre Mergnat mt8365_afe_o26_mix, ARRAY_SIZE(mt8365_afe_o26_mix)), 1405e1991d10SAlexandre Mergnat SND_SOC_DAPM_MIXER("O27", SND_SOC_NOPM, 0, 0, 1406e1991d10SAlexandre Mergnat mt8365_afe_o27_mix, ARRAY_SIZE(mt8365_afe_o27_mix)), 1407e1991d10SAlexandre Mergnat SND_SOC_DAPM_MIXER("O28", SND_SOC_NOPM, 0, 0, 1408e1991d10SAlexandre Mergnat mt8365_afe_o28_mix, ARRAY_SIZE(mt8365_afe_o28_mix)), 1409e1991d10SAlexandre Mergnat SND_SOC_DAPM_MIXER("O29", SND_SOC_NOPM, 0, 0, 1410e1991d10SAlexandre Mergnat mt8365_afe_o29_mix, ARRAY_SIZE(mt8365_afe_o29_mix)), 1411e1991d10SAlexandre Mergnat SND_SOC_DAPM_MIXER("O30", SND_SOC_NOPM, 0, 0, 1412e1991d10SAlexandre Mergnat mt8365_afe_o30_mix, ARRAY_SIZE(mt8365_afe_o30_mix)), 1413e1991d10SAlexandre Mergnat SND_SOC_DAPM_MIXER("O31", SND_SOC_NOPM, 0, 0, 1414e1991d10SAlexandre Mergnat mt8365_afe_o31_mix, ARRAY_SIZE(mt8365_afe_o31_mix)), 1415e1991d10SAlexandre Mergnat SND_SOC_DAPM_MIXER("O32", SND_SOC_NOPM, 0, 0, 1416e1991d10SAlexandre Mergnat mt8365_afe_o32_mix, ARRAY_SIZE(mt8365_afe_o32_mix)), 1417e1991d10SAlexandre Mergnat SND_SOC_DAPM_MIXER("O33", SND_SOC_NOPM, 0, 0, 1418e1991d10SAlexandre Mergnat mt8365_afe_o33_mix, ARRAY_SIZE(mt8365_afe_o33_mix)), 1419e1991d10SAlexandre Mergnat SND_SOC_DAPM_MIXER("O34", SND_SOC_NOPM, 0, 0, 1420e1991d10SAlexandre Mergnat mt8365_afe_o34_mix, ARRAY_SIZE(mt8365_afe_o34_mix)), 1421e1991d10SAlexandre Mergnat SND_SOC_DAPM_MIXER("O35", SND_SOC_NOPM, 0, 0, 1422e1991d10SAlexandre Mergnat mt8365_afe_o35_mix, ARRAY_SIZE(mt8365_afe_o35_mix)), 1423e1991d10SAlexandre Mergnat SND_SOC_DAPM_MIXER("O36", SND_SOC_NOPM, 0, 0, 1424e1991d10SAlexandre Mergnat mt8365_afe_o36_mix, ARRAY_SIZE(mt8365_afe_o36_mix)), 1425e1991d10SAlexandre Mergnat SND_SOC_DAPM_MIXER("CM2_Mux IO", SND_SOC_NOPM, 0, 0, NULL, 0), 1426e1991d10SAlexandre Mergnat SND_SOC_DAPM_MIXER("CM1_IO", SND_SOC_NOPM, 0, 0, NULL, 0), 1427e1991d10SAlexandre Mergnat SND_SOC_DAPM_MIXER("O17O18", SND_SOC_NOPM, 0, 0, NULL, 0), 1428e1991d10SAlexandre Mergnat /* inter-connections */ 1429e1991d10SAlexandre Mergnat SND_SOC_DAPM_MIXER("HW_GAIN1_IN_CH1", SND_SOC_NOPM, 0, 0, 1430e1991d10SAlexandre Mergnat mtk_hw_gain1_in_ch1_mix, 1431e1991d10SAlexandre Mergnat ARRAY_SIZE(mtk_hw_gain1_in_ch1_mix)), 1432e1991d10SAlexandre Mergnat SND_SOC_DAPM_MIXER("HW_GAIN1_IN_CH2", SND_SOC_NOPM, 0, 0, 1433e1991d10SAlexandre Mergnat mtk_hw_gain1_in_ch2_mix, 1434e1991d10SAlexandre Mergnat ARRAY_SIZE(mtk_hw_gain1_in_ch2_mix)), 1435e1991d10SAlexandre Mergnat 1436e1991d10SAlexandre Mergnat SND_SOC_DAPM_INPUT("DL Source"), 1437e1991d10SAlexandre Mergnat 1438e1991d10SAlexandre Mergnat SND_SOC_DAPM_MUX("CM2_Mux_IO Input Mux", SND_SOC_NOPM, 0, 0, 1439e1991d10SAlexandre Mergnat &mt8365_afe_cm2_mux_input_mux), 1440e1991d10SAlexandre Mergnat 1441e1991d10SAlexandre Mergnat SND_SOC_DAPM_MUX("AIN Mux", SND_SOC_NOPM, 0, 0, &ain_mux), 1442e1991d10SAlexandre Mergnat SND_SOC_DAPM_MUX("VUL2 Input Mux", SND_SOC_NOPM, 0, 0, 1443e1991d10SAlexandre Mergnat &vul2_in_input_mux), 1444e1991d10SAlexandre Mergnat 1445e1991d10SAlexandre Mergnat SND_SOC_DAPM_MUX("FM HW Gain Mux", SND_SOC_NOPM, 0, 0, &fmhwgain_mux), 1446e1991d10SAlexandre Mergnat 1447e1991d10SAlexandre Mergnat SND_SOC_DAPM_INPUT("HW Gain 1 Out Endpoint"), 1448e1991d10SAlexandre Mergnat SND_SOC_DAPM_OUTPUT("HW Gain 1 In Endpoint"), 1449e1991d10SAlexandre Mergnat }; 1450e1991d10SAlexandre Mergnat 1451e1991d10SAlexandre Mergnat static const struct snd_soc_dapm_route mt8365_memif_routes[] = { 1452e1991d10SAlexandre Mergnat /* downlink */ 1453e1991d10SAlexandre Mergnat {"I00", NULL, "2ND I2S Capture"}, 1454e1991d10SAlexandre Mergnat {"I01", NULL, "2ND I2S Capture"}, 1455e1991d10SAlexandre Mergnat {"I05", NULL, "DL1"}, 1456e1991d10SAlexandre Mergnat {"I06", NULL, "DL1"}, 1457e1991d10SAlexandre Mergnat {"I07", NULL, "DL2"}, 1458e1991d10SAlexandre Mergnat {"I08", NULL, "DL2"}, 1459e1991d10SAlexandre Mergnat 1460e1991d10SAlexandre Mergnat {"O03", "I05 Switch", "I05"}, 1461e1991d10SAlexandre Mergnat {"O04", "I06 Switch", "I06"}, 1462e1991d10SAlexandre Mergnat {"O00", "I05 Switch", "I05"}, 1463e1991d10SAlexandre Mergnat {"O01", "I06 Switch", "I06"}, 1464e1991d10SAlexandre Mergnat {"O07", "I05 Switch", "I05"}, 1465e1991d10SAlexandre Mergnat {"O08", "I06 Switch", "I06"}, 1466e1991d10SAlexandre Mergnat {"O27", "I05 Switch", "I05"}, 1467e1991d10SAlexandre Mergnat {"O28", "I06 Switch", "I06"}, 1468e1991d10SAlexandre Mergnat {"O29", "I05 Switch", "I05"}, 1469e1991d10SAlexandre Mergnat {"O30", "I06 Switch", "I06"}, 1470e1991d10SAlexandre Mergnat 1471e1991d10SAlexandre Mergnat {"O03", "I07 Switch", "I07"}, 1472e1991d10SAlexandre Mergnat {"O04", "I08 Switch", "I08"}, 1473e1991d10SAlexandre Mergnat {"O00", "I07 Switch", "I07"}, 1474e1991d10SAlexandre Mergnat {"O01", "I08 Switch", "I08"}, 1475e1991d10SAlexandre Mergnat {"O07", "I07 Switch", "I07"}, 1476e1991d10SAlexandre Mergnat {"O08", "I08 Switch", "I08"}, 1477e1991d10SAlexandre Mergnat 1478e1991d10SAlexandre Mergnat /* uplink */ 1479e1991d10SAlexandre Mergnat {"AWB", NULL, "O05"}, 1480e1991d10SAlexandre Mergnat {"AWB", NULL, "O06"}, 1481e1991d10SAlexandre Mergnat {"VUL", NULL, "O09"}, 1482e1991d10SAlexandre Mergnat {"VUL", NULL, "O10"}, 1483e1991d10SAlexandre Mergnat {"VUL3", NULL, "O11"}, 1484e1991d10SAlexandre Mergnat {"VUL3", NULL, "O12"}, 1485e1991d10SAlexandre Mergnat 1486e1991d10SAlexandre Mergnat {"AIN Mux", "EXT ADC", "I2S Capture"}, 1487e1991d10SAlexandre Mergnat {"I03", NULL, "AIN Mux"}, 1488e1991d10SAlexandre Mergnat {"I04", NULL, "AIN Mux"}, 1489e1991d10SAlexandre Mergnat 1490e1991d10SAlexandre Mergnat {"HW_GAIN1_IN_CH1", "CONNSYS_I2S_CH1", "Hostless FM DL"}, 1491e1991d10SAlexandre Mergnat {"HW_GAIN1_IN_CH2", "CONNSYS_I2S_CH2", "Hostless FM DL"}, 1492e1991d10SAlexandre Mergnat 1493e1991d10SAlexandre Mergnat {"HW Gain 1 In Endpoint", NULL, "HW Gain 1 In"}, 1494e1991d10SAlexandre Mergnat {"HW Gain 1 Out", NULL, "HW Gain 1 Out Endpoint"}, 1495e1991d10SAlexandre Mergnat {"HW Gain 1 In", NULL, "HW_GAIN1_IN_CH1"}, 1496e1991d10SAlexandre Mergnat {"HW Gain 1 In", NULL, "HW_GAIN1_IN_CH2"}, 1497e1991d10SAlexandre Mergnat 1498e1991d10SAlexandre Mergnat {"FM HW Gain Mux", "FM_HW_GAIN_IO", "HW Gain 1 Out"}, 1499e1991d10SAlexandre Mergnat {"Hostless FM UL", NULL, "FM HW Gain Mux"}, 1500e1991d10SAlexandre Mergnat {"Hostless FM UL", NULL, "FM 2ND I2S Mux"}, 1501e1991d10SAlexandre Mergnat 1502e1991d10SAlexandre Mergnat {"O05", "I05 Switch", "I05L"}, 1503e1991d10SAlexandre Mergnat {"O06", "I06 Switch", "I06L"}, 1504e1991d10SAlexandre Mergnat {"O05", "I07 Switch", "I07L"}, 1505e1991d10SAlexandre Mergnat {"O06", "I08 Switch", "I08L"}, 1506e1991d10SAlexandre Mergnat 1507e1991d10SAlexandre Mergnat {"O05", "I03 Switch", "I03"}, 1508e1991d10SAlexandre Mergnat {"O06", "I04 Switch", "I04"}, 1509e1991d10SAlexandre Mergnat {"O05", "I00 Switch", "I00"}, 1510e1991d10SAlexandre Mergnat {"O06", "I01 Switch", "I01"}, 1511e1991d10SAlexandre Mergnat {"O05", "I09 Switch", "I09"}, 1512e1991d10SAlexandre Mergnat {"O06", "I22 Switch", "I22"}, 1513e1991d10SAlexandre Mergnat {"O05", "I14 Switch", "I14"}, 1514e1991d10SAlexandre Mergnat {"O06", "I15 Switch", "I15"}, 1515e1991d10SAlexandre Mergnat {"O05", "I16 Switch", "I16"}, 1516e1991d10SAlexandre Mergnat {"O06", "I17 Switch", "I17"}, 1517e1991d10SAlexandre Mergnat {"O05", "I18 Switch", "I18"}, 1518e1991d10SAlexandre Mergnat {"O06", "I19 Switch", "I19"}, 1519e1991d10SAlexandre Mergnat {"O05", "I20 Switch", "I20"}, 1520e1991d10SAlexandre Mergnat {"O06", "I21 Switch", "I21"}, 1521e1991d10SAlexandre Mergnat {"O05", "I23 Switch", "I23"}, 1522e1991d10SAlexandre Mergnat {"O06", "I24 Switch", "I24"}, 1523e1991d10SAlexandre Mergnat 1524e1991d10SAlexandre Mergnat {"O09", "I03 Switch", "I03"}, 1525e1991d10SAlexandre Mergnat {"O10", "I04 Switch", "I04"}, 1526e1991d10SAlexandre Mergnat {"O09", "I00 Switch", "I00"}, 1527e1991d10SAlexandre Mergnat {"O10", "I01 Switch", "I01"}, 1528e1991d10SAlexandre Mergnat {"O09", "I09 Switch", "I09"}, 1529e1991d10SAlexandre Mergnat {"O10", "I22 Switch", "I22"}, 1530e1991d10SAlexandre Mergnat {"O09", "I14 Switch", "I14"}, 1531e1991d10SAlexandre Mergnat {"O10", "I15 Switch", "I15"}, 1532e1991d10SAlexandre Mergnat {"O09", "I16 Switch", "I16"}, 1533e1991d10SAlexandre Mergnat {"O10", "I17 Switch", "I17"}, 1534e1991d10SAlexandre Mergnat {"O09", "I18 Switch", "I18"}, 1535e1991d10SAlexandre Mergnat {"O10", "I19 Switch", "I19"}, 1536e1991d10SAlexandre Mergnat {"O09", "I20 Switch", "I20"}, 1537e1991d10SAlexandre Mergnat {"O10", "I21 Switch", "I21"}, 1538e1991d10SAlexandre Mergnat 1539e1991d10SAlexandre Mergnat {"O11", "I03 Switch", "I03"}, 1540e1991d10SAlexandre Mergnat {"O12", "I04 Switch", "I04"}, 1541e1991d10SAlexandre Mergnat {"O11", "I00 Switch", "I00"}, 1542e1991d10SAlexandre Mergnat {"O12", "I01 Switch", "I01"}, 1543e1991d10SAlexandre Mergnat {"O11", "I09 Switch", "I09"}, 1544e1991d10SAlexandre Mergnat {"O12", "I22 Switch", "I22"}, 1545e1991d10SAlexandre Mergnat {"O11", "I14 Switch", "I14"}, 1546e1991d10SAlexandre Mergnat {"O12", "I15 Switch", "I15"}, 1547e1991d10SAlexandre Mergnat {"O11", "I16 Switch", "I16"}, 1548e1991d10SAlexandre Mergnat {"O12", "I17 Switch", "I17"}, 1549e1991d10SAlexandre Mergnat {"O11", "I18 Switch", "I18"}, 1550e1991d10SAlexandre Mergnat {"O12", "I19 Switch", "I19"}, 1551e1991d10SAlexandre Mergnat {"O11", "I20 Switch", "I20"}, 1552e1991d10SAlexandre Mergnat {"O12", "I21 Switch", "I21"}, 1553e1991d10SAlexandre Mergnat 1554e1991d10SAlexandre Mergnat /* CM2_Mux*/ 1555e1991d10SAlexandre Mergnat {"CM2_Mux IO", NULL, "CM2_Mux_IO Input Mux"}, 1556e1991d10SAlexandre Mergnat 1557e1991d10SAlexandre Mergnat /* VUL2 */ 1558e1991d10SAlexandre Mergnat {"VUL2", NULL, "VUL2 Input Mux"}, 1559e1991d10SAlexandre Mergnat {"VUL2 Input Mux", "VUL2_IN_FROM_O17O18", "O17O18"}, 1560e1991d10SAlexandre Mergnat {"VUL2 Input Mux", "VUL2_IN_FROM_CM1", "CM1_IO"}, 1561e1991d10SAlexandre Mergnat 1562e1991d10SAlexandre Mergnat {"O17O18", NULL, "O17"}, 1563e1991d10SAlexandre Mergnat {"O17O18", NULL, "O18"}, 1564e1991d10SAlexandre Mergnat {"CM1_IO", NULL, "O17"}, 1565e1991d10SAlexandre Mergnat {"CM1_IO", NULL, "O18"}, 1566e1991d10SAlexandre Mergnat {"CM1_IO", NULL, "O19"}, 1567e1991d10SAlexandre Mergnat {"CM1_IO", NULL, "O20"}, 1568e1991d10SAlexandre Mergnat {"CM1_IO", NULL, "O21"}, 1569e1991d10SAlexandre Mergnat {"CM1_IO", NULL, "O22"}, 1570e1991d10SAlexandre Mergnat {"CM1_IO", NULL, "O23"}, 1571e1991d10SAlexandre Mergnat {"CM1_IO", NULL, "O24"}, 1572e1991d10SAlexandre Mergnat {"CM1_IO", NULL, "O25"}, 1573e1991d10SAlexandre Mergnat {"CM1_IO", NULL, "O26"}, 1574e1991d10SAlexandre Mergnat {"CM1_IO", NULL, "O31"}, 1575e1991d10SAlexandre Mergnat {"CM1_IO", NULL, "O32"}, 1576e1991d10SAlexandre Mergnat {"CM1_IO", NULL, "O33"}, 1577e1991d10SAlexandre Mergnat {"CM1_IO", NULL, "O34"}, 1578e1991d10SAlexandre Mergnat {"CM1_IO", NULL, "O35"}, 1579e1991d10SAlexandre Mergnat {"CM1_IO", NULL, "O36"}, 1580e1991d10SAlexandre Mergnat 1581e1991d10SAlexandre Mergnat {"O17", "I14 Switch", "I14"}, 1582e1991d10SAlexandre Mergnat {"O18", "I15 Switch", "I15"}, 1583e1991d10SAlexandre Mergnat {"O19", "I16 Switch", "I16"}, 1584e1991d10SAlexandre Mergnat {"O20", "I17 Switch", "I17"}, 1585e1991d10SAlexandre Mergnat {"O21", "I18 Switch", "I18"}, 1586e1991d10SAlexandre Mergnat {"O22", "I19 Switch", "I19"}, 1587e1991d10SAlexandre Mergnat {"O23", "I20 Switch", "I20"}, 1588e1991d10SAlexandre Mergnat {"O24", "I21 Switch", "I21"}, 1589e1991d10SAlexandre Mergnat {"O25", "I23 Switch", "I23"}, 1590e1991d10SAlexandre Mergnat {"O26", "I24 Switch", "I24"}, 1591e1991d10SAlexandre Mergnat {"O25", "I25 Switch", "I25"}, 1592e1991d10SAlexandre Mergnat {"O26", "I26 Switch", "I26"}, 1593e1991d10SAlexandre Mergnat 1594e1991d10SAlexandre Mergnat {"O17", "I03 Switch", "I03"}, 1595e1991d10SAlexandre Mergnat {"O18", "I04 Switch", "I04"}, 1596e1991d10SAlexandre Mergnat {"O18", "I23 Switch", "I23"}, 1597e1991d10SAlexandre Mergnat {"O18", "I25 Switch", "I25"}, 1598e1991d10SAlexandre Mergnat {"O19", "I04 Switch", "I04"}, 1599e1991d10SAlexandre Mergnat {"O19", "I23 Switch", "I23"}, 1600e1991d10SAlexandre Mergnat {"O19", "I24 Switch", "I24"}, 1601e1991d10SAlexandre Mergnat {"O19", "I25 Switch", "I25"}, 1602e1991d10SAlexandre Mergnat {"O19", "I26 Switch", "I26"}, 1603e1991d10SAlexandre Mergnat {"O20", "I24 Switch", "I24"}, 1604e1991d10SAlexandre Mergnat {"O20", "I26 Switch", "I26"}, 1605e1991d10SAlexandre Mergnat {"O21", "I23 Switch", "I23"}, 1606e1991d10SAlexandre Mergnat {"O21", "I25 Switch", "I25"}, 1607e1991d10SAlexandre Mergnat {"O22", "I24 Switch", "I24"}, 1608e1991d10SAlexandre Mergnat {"O22", "I26 Switch", "I26"}, 1609e1991d10SAlexandre Mergnat 1610e1991d10SAlexandre Mergnat {"O23", "I23 Switch", "I23"}, 1611e1991d10SAlexandre Mergnat {"O23", "I25 Switch", "I25"}, 1612e1991d10SAlexandre Mergnat {"O24", "I24 Switch", "I24"}, 1613e1991d10SAlexandre Mergnat {"O24", "I26 Switch", "I26"}, 1614e1991d10SAlexandre Mergnat {"O24", "I23 Switch", "I23"}, 1615e1991d10SAlexandre Mergnat {"O24", "I25 Switch", "I25"}, 1616e1991d10SAlexandre Mergnat {"O13", "I00 Switch", "I00"}, 1617e1991d10SAlexandre Mergnat {"O14", "I01 Switch", "I01"}, 1618e1991d10SAlexandre Mergnat {"O03", "I10 Switch", "I10"}, 1619e1991d10SAlexandre Mergnat {"O04", "I11 Switch", "I11"}, 1620e1991d10SAlexandre Mergnat }; 1621e1991d10SAlexandre Mergnat 1622e1991d10SAlexandre Mergnat static const struct mtk_base_memif_data memif_data[MT8365_AFE_MEMIF_NUM] = { 1623e1991d10SAlexandre Mergnat { 1624e1991d10SAlexandre Mergnat .name = "DL1", 1625e1991d10SAlexandre Mergnat .id = MT8365_AFE_MEMIF_DL1, 1626e1991d10SAlexandre Mergnat .reg_ofs_base = AFE_DL1_BASE, 1627e1991d10SAlexandre Mergnat .reg_ofs_cur = AFE_DL1_CUR, 1628e1991d10SAlexandre Mergnat .fs_reg = AFE_DAC_CON1, 1629e1991d10SAlexandre Mergnat .fs_shift = 0, 1630e1991d10SAlexandre Mergnat .fs_maskbit = 0xf, 1631e1991d10SAlexandre Mergnat .mono_reg = AFE_DAC_CON1, 1632e1991d10SAlexandre Mergnat .mono_shift = 21, 1633e1991d10SAlexandre Mergnat .hd_reg = AFE_MEMIF_PBUF_SIZE, 1634e1991d10SAlexandre Mergnat .hd_shift = 16, 1635e1991d10SAlexandre Mergnat .enable_reg = AFE_DAC_CON0, 1636e1991d10SAlexandre Mergnat .enable_shift = 1, 1637e1991d10SAlexandre Mergnat .msb_reg = -1, 1638e1991d10SAlexandre Mergnat .msb_shift = -1, 1639e1991d10SAlexandre Mergnat .agent_disable_reg = -1, 1640e1991d10SAlexandre Mergnat .agent_disable_shift = -1, 1641e1991d10SAlexandre Mergnat }, { 1642e1991d10SAlexandre Mergnat .name = "DL2", 1643e1991d10SAlexandre Mergnat .id = MT8365_AFE_MEMIF_DL2, 1644e1991d10SAlexandre Mergnat .reg_ofs_base = AFE_DL2_BASE, 1645e1991d10SAlexandre Mergnat .reg_ofs_cur = AFE_DL2_CUR, 1646e1991d10SAlexandre Mergnat .fs_reg = AFE_DAC_CON1, 1647e1991d10SAlexandre Mergnat .fs_shift = 4, 1648e1991d10SAlexandre Mergnat .fs_maskbit = 0xf, 1649e1991d10SAlexandre Mergnat .mono_reg = AFE_DAC_CON1, 1650e1991d10SAlexandre Mergnat .mono_shift = 22, 1651e1991d10SAlexandre Mergnat .hd_reg = AFE_MEMIF_PBUF_SIZE, 1652e1991d10SAlexandre Mergnat .hd_shift = 18, 1653e1991d10SAlexandre Mergnat .enable_reg = AFE_DAC_CON0, 1654e1991d10SAlexandre Mergnat .enable_shift = 2, 1655e1991d10SAlexandre Mergnat .msb_reg = -1, 1656e1991d10SAlexandre Mergnat .msb_shift = -1, 1657e1991d10SAlexandre Mergnat .agent_disable_reg = -1, 1658e1991d10SAlexandre Mergnat .agent_disable_shift = -1, 1659e1991d10SAlexandre Mergnat }, { 1660e1991d10SAlexandre Mergnat .name = "TDM OUT", 1661e1991d10SAlexandre Mergnat .id = MT8365_AFE_MEMIF_TDM_OUT, 1662e1991d10SAlexandre Mergnat .reg_ofs_base = AFE_HDMI_OUT_BASE, 1663e1991d10SAlexandre Mergnat .reg_ofs_cur = AFE_HDMI_OUT_CUR, 1664e1991d10SAlexandre Mergnat .fs_reg = -1, 1665e1991d10SAlexandre Mergnat .fs_shift = -1, 1666e1991d10SAlexandre Mergnat .fs_maskbit = -1, 1667e1991d10SAlexandre Mergnat .mono_reg = -1, 1668e1991d10SAlexandre Mergnat .mono_shift = -1, 1669e1991d10SAlexandre Mergnat .hd_reg = AFE_MEMIF_PBUF_SIZE, 1670e1991d10SAlexandre Mergnat .hd_shift = 28, 1671e1991d10SAlexandre Mergnat .enable_reg = AFE_HDMI_OUT_CON0, 1672e1991d10SAlexandre Mergnat .enable_shift = 0, 1673e1991d10SAlexandre Mergnat .msb_reg = -1, 1674e1991d10SAlexandre Mergnat .msb_shift = -1, 1675e1991d10SAlexandre Mergnat .agent_disable_reg = -1, 1676e1991d10SAlexandre Mergnat .agent_disable_shift = -1, 1677e1991d10SAlexandre Mergnat }, { 1678e1991d10SAlexandre Mergnat .name = "AWB", 1679e1991d10SAlexandre Mergnat .id = MT8365_AFE_MEMIF_AWB, 1680e1991d10SAlexandre Mergnat .reg_ofs_base = AFE_AWB_BASE, 1681e1991d10SAlexandre Mergnat .reg_ofs_cur = AFE_AWB_CUR, 1682e1991d10SAlexandre Mergnat .fs_reg = AFE_DAC_CON1, 1683e1991d10SAlexandre Mergnat .fs_shift = 12, 1684e1991d10SAlexandre Mergnat .fs_maskbit = 0xf, 1685e1991d10SAlexandre Mergnat .mono_reg = AFE_DAC_CON1, 1686e1991d10SAlexandre Mergnat .mono_shift = 24, 1687e1991d10SAlexandre Mergnat .hd_reg = AFE_MEMIF_PBUF_SIZE, 1688e1991d10SAlexandre Mergnat .hd_shift = 20, 1689e1991d10SAlexandre Mergnat .enable_reg = AFE_DAC_CON0, 1690e1991d10SAlexandre Mergnat .enable_shift = 6, 1691e1991d10SAlexandre Mergnat .msb_reg = AFE_MEMIF_MSB, 1692e1991d10SAlexandre Mergnat .msb_shift = 17, 1693e1991d10SAlexandre Mergnat .agent_disable_reg = -1, 1694e1991d10SAlexandre Mergnat .agent_disable_shift = -1, 1695e1991d10SAlexandre Mergnat }, { 1696e1991d10SAlexandre Mergnat .name = "VUL", 1697e1991d10SAlexandre Mergnat .id = MT8365_AFE_MEMIF_VUL, 1698e1991d10SAlexandre Mergnat .reg_ofs_base = AFE_VUL_BASE, 1699e1991d10SAlexandre Mergnat .reg_ofs_cur = AFE_VUL_CUR, 1700e1991d10SAlexandre Mergnat .fs_reg = AFE_DAC_CON1, 1701e1991d10SAlexandre Mergnat .fs_shift = 16, 1702e1991d10SAlexandre Mergnat .fs_maskbit = 0xf, 1703e1991d10SAlexandre Mergnat .mono_reg = AFE_DAC_CON1, 1704e1991d10SAlexandre Mergnat .mono_shift = 27, 1705e1991d10SAlexandre Mergnat .hd_reg = AFE_MEMIF_PBUF_SIZE, 1706e1991d10SAlexandre Mergnat .hd_shift = 22, 1707e1991d10SAlexandre Mergnat .enable_reg = AFE_DAC_CON0, 1708e1991d10SAlexandre Mergnat .enable_shift = 3, 1709e1991d10SAlexandre Mergnat .msb_reg = AFE_MEMIF_MSB, 1710e1991d10SAlexandre Mergnat .msb_shift = 20, 1711e1991d10SAlexandre Mergnat .agent_disable_reg = -1, 1712e1991d10SAlexandre Mergnat .agent_disable_shift = -1, 1713e1991d10SAlexandre Mergnat }, { 1714e1991d10SAlexandre Mergnat .name = "VUL2", 1715e1991d10SAlexandre Mergnat .id = MT8365_AFE_MEMIF_VUL2, 1716e1991d10SAlexandre Mergnat .reg_ofs_base = AFE_VUL_D2_BASE, 1717e1991d10SAlexandre Mergnat .reg_ofs_cur = AFE_VUL_D2_CUR, 1718e1991d10SAlexandre Mergnat .fs_reg = AFE_DAC_CON0, 1719e1991d10SAlexandre Mergnat .fs_shift = 20, 1720e1991d10SAlexandre Mergnat .fs_maskbit = 0xf, 1721e1991d10SAlexandre Mergnat .mono_reg = -1, 1722e1991d10SAlexandre Mergnat .mono_shift = -1, 1723e1991d10SAlexandre Mergnat .hd_reg = AFE_MEMIF_PBUF_SIZE, 1724e1991d10SAlexandre Mergnat .hd_shift = 14, 1725e1991d10SAlexandre Mergnat .enable_reg = AFE_DAC_CON0, 1726e1991d10SAlexandre Mergnat .enable_shift = 9, 1727e1991d10SAlexandre Mergnat .msb_reg = AFE_MEMIF_MSB, 1728e1991d10SAlexandre Mergnat .msb_shift = 21, 1729e1991d10SAlexandre Mergnat .agent_disable_reg = -1, 1730e1991d10SAlexandre Mergnat .agent_disable_shift = -1, 1731e1991d10SAlexandre Mergnat }, { 1732e1991d10SAlexandre Mergnat .name = "VUL3", 1733e1991d10SAlexandre Mergnat .id = MT8365_AFE_MEMIF_VUL3, 1734e1991d10SAlexandre Mergnat .reg_ofs_base = AFE_VUL3_BASE, 1735e1991d10SAlexandre Mergnat .reg_ofs_cur = AFE_VUL3_CUR, 1736e1991d10SAlexandre Mergnat .fs_reg = AFE_DAC_CON1, 1737e1991d10SAlexandre Mergnat .fs_shift = 8, 1738e1991d10SAlexandre Mergnat .fs_maskbit = 0xf, 1739e1991d10SAlexandre Mergnat .mono_reg = AFE_DAC_CON0, 1740e1991d10SAlexandre Mergnat .mono_shift = 13, 1741e1991d10SAlexandre Mergnat .hd_reg = AFE_MEMIF_PBUF2_SIZE, 1742e1991d10SAlexandre Mergnat .hd_shift = 10, 1743e1991d10SAlexandre Mergnat .enable_reg = AFE_DAC_CON0, 1744e1991d10SAlexandre Mergnat .enable_shift = 12, 1745e1991d10SAlexandre Mergnat .msb_reg = AFE_MEMIF_MSB, 1746e1991d10SAlexandre Mergnat .msb_shift = 27, 1747e1991d10SAlexandre Mergnat .agent_disable_reg = -1, 1748e1991d10SAlexandre Mergnat .agent_disable_shift = -1, 1749e1991d10SAlexandre Mergnat }, { 1750e1991d10SAlexandre Mergnat .name = "TDM IN", 1751e1991d10SAlexandre Mergnat .id = MT8365_AFE_MEMIF_TDM_IN, 1752e1991d10SAlexandre Mergnat .reg_ofs_base = AFE_HDMI_IN_2CH_BASE, 1753e1991d10SAlexandre Mergnat .reg_ofs_cur = AFE_HDMI_IN_2CH_CUR, 1754e1991d10SAlexandre Mergnat .fs_reg = -1, 1755e1991d10SAlexandre Mergnat .fs_shift = -1, 1756e1991d10SAlexandre Mergnat .fs_maskbit = -1, 1757e1991d10SAlexandre Mergnat .mono_reg = AFE_HDMI_IN_2CH_CON0, 1758e1991d10SAlexandre Mergnat .mono_shift = 1, 1759e1991d10SAlexandre Mergnat .hd_reg = AFE_MEMIF_PBUF2_SIZE, 1760e1991d10SAlexandre Mergnat .hd_shift = 8, 1761e1991d10SAlexandre Mergnat .hd_align_mshift = 5, 1762e1991d10SAlexandre Mergnat .enable_reg = AFE_HDMI_IN_2CH_CON0, 1763e1991d10SAlexandre Mergnat .enable_shift = 0, 1764e1991d10SAlexandre Mergnat .msb_reg = AFE_MEMIF_MSB, 1765e1991d10SAlexandre Mergnat .msb_shift = 28, 1766e1991d10SAlexandre Mergnat .agent_disable_reg = -1, 1767e1991d10SAlexandre Mergnat .agent_disable_shift = -1, 1768e1991d10SAlexandre Mergnat }, 1769e1991d10SAlexandre Mergnat }; 1770e1991d10SAlexandre Mergnat 1771e1991d10SAlexandre Mergnat static const struct mtk_base_irq_data irq_data[MT8365_AFE_IRQ_NUM] = { 1772e1991d10SAlexandre Mergnat { 1773e1991d10SAlexandre Mergnat .id = MT8365_AFE_IRQ1, 1774e1991d10SAlexandre Mergnat .irq_cnt_reg = AFE_IRQ_MCU_CNT1, 1775e1991d10SAlexandre Mergnat .irq_cnt_shift = 0, 1776e1991d10SAlexandre Mergnat .irq_cnt_maskbit = 0x3ffff, 1777e1991d10SAlexandre Mergnat .irq_en_reg = AFE_IRQ_MCU_CON, 1778e1991d10SAlexandre Mergnat .irq_en_shift = 0, 1779e1991d10SAlexandre Mergnat .irq_fs_reg = AFE_IRQ_MCU_CON, 1780e1991d10SAlexandre Mergnat .irq_fs_shift = 4, 1781e1991d10SAlexandre Mergnat .irq_fs_maskbit = 0xf, 1782e1991d10SAlexandre Mergnat .irq_clr_reg = AFE_IRQ_MCU_CLR, 1783e1991d10SAlexandre Mergnat .irq_clr_shift = 0, 1784e1991d10SAlexandre Mergnat }, { 1785e1991d10SAlexandre Mergnat .id = MT8365_AFE_IRQ2, 1786e1991d10SAlexandre Mergnat .irq_cnt_reg = AFE_IRQ_MCU_CNT2, 1787e1991d10SAlexandre Mergnat .irq_cnt_shift = 0, 1788e1991d10SAlexandre Mergnat .irq_cnt_maskbit = 0x3ffff, 1789e1991d10SAlexandre Mergnat .irq_en_reg = AFE_IRQ_MCU_CON, 1790e1991d10SAlexandre Mergnat .irq_en_shift = 1, 1791e1991d10SAlexandre Mergnat .irq_fs_reg = AFE_IRQ_MCU_CON, 1792e1991d10SAlexandre Mergnat .irq_fs_shift = 8, 1793e1991d10SAlexandre Mergnat .irq_fs_maskbit = 0xf, 1794e1991d10SAlexandre Mergnat .irq_clr_reg = AFE_IRQ_MCU_CLR, 1795e1991d10SAlexandre Mergnat .irq_clr_shift = 1, 1796e1991d10SAlexandre Mergnat }, { 1797e1991d10SAlexandre Mergnat .id = MT8365_AFE_IRQ3, 1798e1991d10SAlexandre Mergnat .irq_cnt_reg = AFE_IRQ_MCU_CNT3, 1799e1991d10SAlexandre Mergnat .irq_cnt_shift = 0, 1800e1991d10SAlexandre Mergnat .irq_cnt_maskbit = 0x3ffff, 1801e1991d10SAlexandre Mergnat .irq_en_reg = AFE_IRQ_MCU_CON, 1802e1991d10SAlexandre Mergnat .irq_en_shift = 2, 1803e1991d10SAlexandre Mergnat .irq_fs_reg = AFE_IRQ_MCU_CON, 1804e1991d10SAlexandre Mergnat .irq_fs_shift = 16, 1805e1991d10SAlexandre Mergnat .irq_fs_maskbit = 0xf, 1806e1991d10SAlexandre Mergnat .irq_clr_reg = AFE_IRQ_MCU_CLR, 1807e1991d10SAlexandre Mergnat .irq_clr_shift = 2, 1808e1991d10SAlexandre Mergnat }, { 1809e1991d10SAlexandre Mergnat .id = MT8365_AFE_IRQ4, 1810e1991d10SAlexandre Mergnat .irq_cnt_reg = AFE_IRQ_MCU_CNT4, 1811e1991d10SAlexandre Mergnat .irq_cnt_shift = 0, 1812e1991d10SAlexandre Mergnat .irq_cnt_maskbit = 0x3ffff, 1813e1991d10SAlexandre Mergnat .irq_en_reg = AFE_IRQ_MCU_CON, 1814e1991d10SAlexandre Mergnat .irq_en_shift = 3, 1815e1991d10SAlexandre Mergnat .irq_fs_reg = AFE_IRQ_MCU_CON, 1816e1991d10SAlexandre Mergnat .irq_fs_shift = 20, 1817e1991d10SAlexandre Mergnat .irq_fs_maskbit = 0xf, 1818e1991d10SAlexandre Mergnat .irq_clr_reg = AFE_IRQ_MCU_CLR, 1819e1991d10SAlexandre Mergnat .irq_clr_shift = 3, 1820e1991d10SAlexandre Mergnat }, { 1821e1991d10SAlexandre Mergnat .id = MT8365_AFE_IRQ5, 1822e1991d10SAlexandre Mergnat .irq_cnt_reg = AFE_IRQ_MCU_CNT5, 1823e1991d10SAlexandre Mergnat .irq_cnt_shift = 0, 1824e1991d10SAlexandre Mergnat .irq_cnt_maskbit = 0x3ffff, 1825e1991d10SAlexandre Mergnat .irq_en_reg = AFE_IRQ_MCU_CON2, 1826e1991d10SAlexandre Mergnat .irq_en_shift = 3, 1827e1991d10SAlexandre Mergnat .irq_fs_reg = -1, 1828e1991d10SAlexandre Mergnat .irq_fs_shift = 0, 1829e1991d10SAlexandre Mergnat .irq_fs_maskbit = 0x0, 1830e1991d10SAlexandre Mergnat .irq_clr_reg = AFE_IRQ_MCU_CLR, 1831e1991d10SAlexandre Mergnat .irq_clr_shift = 4, 1832e1991d10SAlexandre Mergnat }, { 1833e1991d10SAlexandre Mergnat .id = MT8365_AFE_IRQ6, 1834e1991d10SAlexandre Mergnat .irq_cnt_reg = -1, 1835e1991d10SAlexandre Mergnat .irq_cnt_shift = 0, 1836e1991d10SAlexandre Mergnat .irq_cnt_maskbit = 0x0, 1837e1991d10SAlexandre Mergnat .irq_en_reg = AFE_IRQ_MCU_CON, 1838e1991d10SAlexandre Mergnat .irq_en_shift = 13, 1839e1991d10SAlexandre Mergnat .irq_fs_reg = -1, 1840e1991d10SAlexandre Mergnat .irq_fs_shift = 0, 1841e1991d10SAlexandre Mergnat .irq_fs_maskbit = 0x0, 1842e1991d10SAlexandre Mergnat .irq_clr_reg = AFE_IRQ_MCU_CLR, 1843e1991d10SAlexandre Mergnat .irq_clr_shift = 5, 1844e1991d10SAlexandre Mergnat }, { 1845e1991d10SAlexandre Mergnat .id = MT8365_AFE_IRQ7, 1846e1991d10SAlexandre Mergnat .irq_cnt_reg = AFE_IRQ_MCU_CNT7, 1847e1991d10SAlexandre Mergnat .irq_cnt_shift = 0, 1848e1991d10SAlexandre Mergnat .irq_cnt_maskbit = 0x3ffff, 1849e1991d10SAlexandre Mergnat .irq_en_reg = AFE_IRQ_MCU_CON, 1850e1991d10SAlexandre Mergnat .irq_en_shift = 14, 1851e1991d10SAlexandre Mergnat .irq_fs_reg = AFE_IRQ_MCU_CON, 1852e1991d10SAlexandre Mergnat .irq_fs_shift = 24, 1853e1991d10SAlexandre Mergnat .irq_fs_maskbit = 0xf, 1854e1991d10SAlexandre Mergnat .irq_clr_reg = AFE_IRQ_MCU_CLR, 1855e1991d10SAlexandre Mergnat .irq_clr_shift = 6, 1856e1991d10SAlexandre Mergnat }, { 1857e1991d10SAlexandre Mergnat .id = MT8365_AFE_IRQ8, 1858e1991d10SAlexandre Mergnat .irq_cnt_reg = AFE_IRQ_MCU_CNT8, 1859e1991d10SAlexandre Mergnat .irq_cnt_shift = 0, 1860e1991d10SAlexandre Mergnat .irq_cnt_maskbit = 0x3ffff, 1861e1991d10SAlexandre Mergnat .irq_en_reg = AFE_IRQ_MCU_CON, 1862e1991d10SAlexandre Mergnat .irq_en_shift = 15, 1863e1991d10SAlexandre Mergnat .irq_fs_reg = AFE_IRQ_MCU_CON, 1864e1991d10SAlexandre Mergnat .irq_fs_shift = 28, 1865e1991d10SAlexandre Mergnat .irq_fs_maskbit = 0xf, 1866e1991d10SAlexandre Mergnat .irq_clr_reg = AFE_IRQ_MCU_CLR, 1867e1991d10SAlexandre Mergnat .irq_clr_shift = 7, 1868e1991d10SAlexandre Mergnat }, { 1869e1991d10SAlexandre Mergnat .id = MT8365_AFE_IRQ9, 1870e1991d10SAlexandre Mergnat .irq_cnt_reg = -1, 1871e1991d10SAlexandre Mergnat .irq_cnt_shift = 0, 1872e1991d10SAlexandre Mergnat .irq_cnt_maskbit = 0x0, 1873e1991d10SAlexandre Mergnat .irq_en_reg = AFE_IRQ_MCU_CON2, 1874e1991d10SAlexandre Mergnat .irq_en_shift = 2, 1875e1991d10SAlexandre Mergnat .irq_fs_reg = -1, 1876e1991d10SAlexandre Mergnat .irq_fs_shift = 0, 1877e1991d10SAlexandre Mergnat .irq_fs_maskbit = 0x0, 1878e1991d10SAlexandre Mergnat .irq_clr_reg = AFE_IRQ_MCU_CLR, 1879e1991d10SAlexandre Mergnat .irq_clr_shift = 8, 1880e1991d10SAlexandre Mergnat }, { 1881e1991d10SAlexandre Mergnat .id = MT8365_AFE_IRQ10, 1882e1991d10SAlexandre Mergnat .irq_cnt_reg = AFE_IRQ_MCU_CNT10, 1883e1991d10SAlexandre Mergnat .irq_cnt_shift = 0, 1884e1991d10SAlexandre Mergnat .irq_cnt_maskbit = 0x3ffff, 1885e1991d10SAlexandre Mergnat .irq_en_reg = AFE_IRQ_MCU_CON2, 1886e1991d10SAlexandre Mergnat .irq_en_shift = 4, 1887e1991d10SAlexandre Mergnat .irq_fs_reg = -1, 1888e1991d10SAlexandre Mergnat .irq_fs_shift = 0, 1889e1991d10SAlexandre Mergnat .irq_fs_maskbit = 0x0, 1890e1991d10SAlexandre Mergnat .irq_clr_reg = AFE_IRQ_MCU_CLR, 1891e1991d10SAlexandre Mergnat .irq_clr_shift = 9, 1892e1991d10SAlexandre Mergnat }, 1893e1991d10SAlexandre Mergnat }; 1894e1991d10SAlexandre Mergnat 1895e1991d10SAlexandre Mergnat static int memif_specified_irqs[MT8365_AFE_MEMIF_NUM] = { 1896e1991d10SAlexandre Mergnat [MT8365_AFE_MEMIF_DL1] = MT8365_AFE_IRQ1, 1897e1991d10SAlexandre Mergnat [MT8365_AFE_MEMIF_DL2] = MT8365_AFE_IRQ2, 1898e1991d10SAlexandre Mergnat [MT8365_AFE_MEMIF_TDM_OUT] = MT8365_AFE_IRQ5, 1899e1991d10SAlexandre Mergnat [MT8365_AFE_MEMIF_AWB] = MT8365_AFE_IRQ3, 1900e1991d10SAlexandre Mergnat [MT8365_AFE_MEMIF_VUL] = MT8365_AFE_IRQ4, 1901e1991d10SAlexandre Mergnat [MT8365_AFE_MEMIF_VUL2] = MT8365_AFE_IRQ7, 1902e1991d10SAlexandre Mergnat [MT8365_AFE_MEMIF_VUL3] = MT8365_AFE_IRQ8, 1903e1991d10SAlexandre Mergnat [MT8365_AFE_MEMIF_TDM_IN] = MT8365_AFE_IRQ10, 1904e1991d10SAlexandre Mergnat }; 1905e1991d10SAlexandre Mergnat 1906e1991d10SAlexandre Mergnat static const struct regmap_config mt8365_afe_regmap_config = { 1907e1991d10SAlexandre Mergnat .reg_bits = 32, 1908e1991d10SAlexandre Mergnat .reg_stride = 4, 1909e1991d10SAlexandre Mergnat .val_bits = 32, 1910e1991d10SAlexandre Mergnat .max_register = MAX_REGISTER, 1911e1991d10SAlexandre Mergnat .cache_type = REGCACHE_NONE, 1912e1991d10SAlexandre Mergnat }; 1913e1991d10SAlexandre Mergnat 1914e1991d10SAlexandre Mergnat static irqreturn_t mt8365_afe_irq_handler(int irq, void *dev_id) 1915e1991d10SAlexandre Mergnat { 1916e1991d10SAlexandre Mergnat struct mtk_base_afe *afe = dev_id; 1917e1991d10SAlexandre Mergnat unsigned int reg_value; 1918e1991d10SAlexandre Mergnat unsigned int mcu_irq_mask; 1919e1991d10SAlexandre Mergnat int i, ret; 1920e1991d10SAlexandre Mergnat 1921e1991d10SAlexandre Mergnat ret = regmap_read(afe->regmap, AFE_IRQ_MCU_STATUS, ®_value); 1922e1991d10SAlexandre Mergnat if (ret) { 1923e1991d10SAlexandre Mergnat dev_err_ratelimited(afe->dev, "%s irq status err\n", __func__); 1924e1991d10SAlexandre Mergnat reg_value = AFE_IRQ_STATUS_BITS; 1925e1991d10SAlexandre Mergnat goto err_irq; 1926e1991d10SAlexandre Mergnat } 1927e1991d10SAlexandre Mergnat 1928e1991d10SAlexandre Mergnat ret = regmap_read(afe->regmap, AFE_IRQ_MCU_EN, &mcu_irq_mask); 1929e1991d10SAlexandre Mergnat if (ret) { 1930e1991d10SAlexandre Mergnat dev_err_ratelimited(afe->dev, "%s irq mcu_en err\n", __func__); 1931e1991d10SAlexandre Mergnat reg_value = AFE_IRQ_STATUS_BITS; 1932e1991d10SAlexandre Mergnat goto err_irq; 1933e1991d10SAlexandre Mergnat } 1934e1991d10SAlexandre Mergnat 1935e1991d10SAlexandre Mergnat /* only clr cpu irq */ 1936e1991d10SAlexandre Mergnat reg_value &= mcu_irq_mask; 1937e1991d10SAlexandre Mergnat 1938e1991d10SAlexandre Mergnat for (i = 0; i < MT8365_AFE_MEMIF_NUM; i++) { 1939e1991d10SAlexandre Mergnat struct mtk_base_afe_memif *memif = &afe->memif[i]; 1940e1991d10SAlexandre Mergnat struct mtk_base_afe_irq *mcu_irq; 1941e1991d10SAlexandre Mergnat 1942e1991d10SAlexandre Mergnat if (memif->irq_usage < 0) 1943e1991d10SAlexandre Mergnat continue; 1944e1991d10SAlexandre Mergnat 1945e1991d10SAlexandre Mergnat mcu_irq = &afe->irqs[memif->irq_usage]; 1946e1991d10SAlexandre Mergnat 1947e1991d10SAlexandre Mergnat if (!(reg_value & (1 << mcu_irq->irq_data->irq_clr_shift))) 1948e1991d10SAlexandre Mergnat continue; 1949e1991d10SAlexandre Mergnat 1950e1991d10SAlexandre Mergnat snd_pcm_period_elapsed(memif->substream); 1951e1991d10SAlexandre Mergnat } 1952e1991d10SAlexandre Mergnat 1953e1991d10SAlexandre Mergnat err_irq: 1954e1991d10SAlexandre Mergnat /* clear irq */ 1955e1991d10SAlexandre Mergnat regmap_write(afe->regmap, AFE_IRQ_MCU_CLR, 1956e1991d10SAlexandre Mergnat reg_value & AFE_IRQ_STATUS_BITS); 1957e1991d10SAlexandre Mergnat 1958e1991d10SAlexandre Mergnat return IRQ_HANDLED; 1959e1991d10SAlexandre Mergnat } 1960e1991d10SAlexandre Mergnat 1961e1991d10SAlexandre Mergnat static int __maybe_unused mt8365_afe_runtime_suspend(struct device *dev) 1962e1991d10SAlexandre Mergnat { 1963e1991d10SAlexandre Mergnat return 0; 1964e1991d10SAlexandre Mergnat } 1965e1991d10SAlexandre Mergnat 1966e1991d10SAlexandre Mergnat static int mt8365_afe_runtime_resume(struct device *dev) 1967e1991d10SAlexandre Mergnat { 1968e1991d10SAlexandre Mergnat return 0; 1969e1991d10SAlexandre Mergnat } 1970e1991d10SAlexandre Mergnat 1971e1991d10SAlexandre Mergnat static int __maybe_unused mt8365_afe_suspend(struct device *dev) 1972e1991d10SAlexandre Mergnat { 1973e1991d10SAlexandre Mergnat struct mtk_base_afe *afe = dev_get_drvdata(dev); 1974e1991d10SAlexandre Mergnat struct regmap *regmap = afe->regmap; 1975e1991d10SAlexandre Mergnat int i; 1976e1991d10SAlexandre Mergnat 1977e1991d10SAlexandre Mergnat mt8365_afe_enable_main_clk(afe); 1978e1991d10SAlexandre Mergnat 1979e1991d10SAlexandre Mergnat if (!afe->reg_back_up) 1980e1991d10SAlexandre Mergnat afe->reg_back_up = 1981e1991d10SAlexandre Mergnat devm_kcalloc(dev, afe->reg_back_up_list_num, 1982e1991d10SAlexandre Mergnat sizeof(unsigned int), GFP_KERNEL); 1983e1991d10SAlexandre Mergnat 1984e1991d10SAlexandre Mergnat for (i = 0; i < afe->reg_back_up_list_num; i++) 1985e1991d10SAlexandre Mergnat regmap_read(regmap, afe->reg_back_up_list[i], 1986e1991d10SAlexandre Mergnat &afe->reg_back_up[i]); 1987e1991d10SAlexandre Mergnat 1988e1991d10SAlexandre Mergnat mt8365_afe_disable_main_clk(afe); 1989e1991d10SAlexandre Mergnat 1990e1991d10SAlexandre Mergnat return 0; 1991e1991d10SAlexandre Mergnat } 1992e1991d10SAlexandre Mergnat 1993e1991d10SAlexandre Mergnat static int __maybe_unused mt8365_afe_resume(struct device *dev) 1994e1991d10SAlexandre Mergnat { 1995e1991d10SAlexandre Mergnat struct mtk_base_afe *afe = dev_get_drvdata(dev); 1996e1991d10SAlexandre Mergnat struct regmap *regmap = afe->regmap; 1997e1991d10SAlexandre Mergnat int i = 0; 1998e1991d10SAlexandre Mergnat 1999e1991d10SAlexandre Mergnat if (!afe->reg_back_up) 2000e1991d10SAlexandre Mergnat return 0; 2001e1991d10SAlexandre Mergnat 2002e1991d10SAlexandre Mergnat mt8365_afe_enable_main_clk(afe); 2003e1991d10SAlexandre Mergnat 2004e1991d10SAlexandre Mergnat for (i = 0; i < afe->reg_back_up_list_num; i++) 2005e1991d10SAlexandre Mergnat regmap_write(regmap, afe->reg_back_up_list[i], 2006e1991d10SAlexandre Mergnat afe->reg_back_up[i]); 2007e1991d10SAlexandre Mergnat 2008e1991d10SAlexandre Mergnat mt8365_afe_disable_main_clk(afe); 2009e1991d10SAlexandre Mergnat 2010e1991d10SAlexandre Mergnat return 0; 2011e1991d10SAlexandre Mergnat } 2012e1991d10SAlexandre Mergnat 2013e1991d10SAlexandre Mergnat static int __maybe_unused mt8365_afe_dev_runtime_suspend(struct device *dev) 2014e1991d10SAlexandre Mergnat { 2015e1991d10SAlexandre Mergnat struct mtk_base_afe *afe = dev_get_drvdata(dev); 2016e1991d10SAlexandre Mergnat 2017e1991d10SAlexandre Mergnat if (pm_runtime_status_suspended(dev) || afe->suspended) 2018e1991d10SAlexandre Mergnat return 0; 2019e1991d10SAlexandre Mergnat 2020e1991d10SAlexandre Mergnat mt8365_afe_suspend(dev); 2021e1991d10SAlexandre Mergnat afe->suspended = true; 2022e1991d10SAlexandre Mergnat return 0; 2023e1991d10SAlexandre Mergnat } 2024e1991d10SAlexandre Mergnat 2025e1991d10SAlexandre Mergnat static int __maybe_unused mt8365_afe_dev_runtime_resume(struct device *dev) 2026e1991d10SAlexandre Mergnat { 2027e1991d10SAlexandre Mergnat struct mtk_base_afe *afe = dev_get_drvdata(dev); 2028e1991d10SAlexandre Mergnat 2029e1991d10SAlexandre Mergnat if (pm_runtime_status_suspended(dev) || !afe->suspended) 2030e1991d10SAlexandre Mergnat return 0; 2031e1991d10SAlexandre Mergnat 2032e1991d10SAlexandre Mergnat mt8365_afe_resume(dev); 2033e1991d10SAlexandre Mergnat afe->suspended = false; 2034e1991d10SAlexandre Mergnat return 0; 2035e1991d10SAlexandre Mergnat } 2036e1991d10SAlexandre Mergnat 2037e1991d10SAlexandre Mergnat static int mt8365_afe_init_registers(struct mtk_base_afe *afe) 2038e1991d10SAlexandre Mergnat { 2039e1991d10SAlexandre Mergnat size_t i; 2040e1991d10SAlexandre Mergnat 2041e1991d10SAlexandre Mergnat static struct { 2042e1991d10SAlexandre Mergnat unsigned int reg; 2043e1991d10SAlexandre Mergnat unsigned int mask; 2044e1991d10SAlexandre Mergnat unsigned int val; 2045e1991d10SAlexandre Mergnat } init_regs[] = { 2046e1991d10SAlexandre Mergnat { AFE_CONN_24BIT, GENMASK(31, 0), GENMASK(31, 0) }, 2047e1991d10SAlexandre Mergnat { AFE_CONN_24BIT_1, GENMASK(21, 0), GENMASK(21, 0) }, 2048e1991d10SAlexandre Mergnat }; 2049e1991d10SAlexandre Mergnat 2050e1991d10SAlexandre Mergnat mt8365_afe_enable_main_clk(afe); 2051e1991d10SAlexandre Mergnat 2052e1991d10SAlexandre Mergnat for (i = 0; i < ARRAY_SIZE(init_regs); i++) 2053e1991d10SAlexandre Mergnat regmap_update_bits(afe->regmap, init_regs[i].reg, 2054e1991d10SAlexandre Mergnat init_regs[i].mask, init_regs[i].val); 2055e1991d10SAlexandre Mergnat 2056e1991d10SAlexandre Mergnat mt8365_afe_disable_main_clk(afe); 2057e1991d10SAlexandre Mergnat 2058e1991d10SAlexandre Mergnat return 0; 2059e1991d10SAlexandre Mergnat } 2060e1991d10SAlexandre Mergnat 2061e1991d10SAlexandre Mergnat static int mt8365_dai_memif_register(struct mtk_base_afe *afe) 2062e1991d10SAlexandre Mergnat { 2063e1991d10SAlexandre Mergnat struct mtk_base_afe_dai *dai; 2064e1991d10SAlexandre Mergnat 2065e1991d10SAlexandre Mergnat dai = devm_kzalloc(afe->dev, sizeof(*dai), GFP_KERNEL); 2066e1991d10SAlexandre Mergnat if (!dai) 2067e1991d10SAlexandre Mergnat return -ENOMEM; 2068e1991d10SAlexandre Mergnat 2069e1991d10SAlexandre Mergnat list_add(&dai->list, &afe->sub_dais); 2070e1991d10SAlexandre Mergnat 2071e1991d10SAlexandre Mergnat dai->dai_drivers = mt8365_memif_dai_driver; 2072e1991d10SAlexandre Mergnat dai->num_dai_drivers = ARRAY_SIZE(mt8365_memif_dai_driver); 2073e1991d10SAlexandre Mergnat 2074e1991d10SAlexandre Mergnat dai->dapm_widgets = mt8365_memif_widgets; 2075e1991d10SAlexandre Mergnat dai->num_dapm_widgets = ARRAY_SIZE(mt8365_memif_widgets); 2076e1991d10SAlexandre Mergnat dai->dapm_routes = mt8365_memif_routes; 2077e1991d10SAlexandre Mergnat dai->num_dapm_routes = ARRAY_SIZE(mt8365_memif_routes); 2078e1991d10SAlexandre Mergnat return 0; 2079e1991d10SAlexandre Mergnat } 2080e1991d10SAlexandre Mergnat 2081e1991d10SAlexandre Mergnat typedef int (*dai_register_cb)(struct mtk_base_afe *); 2082e1991d10SAlexandre Mergnat static const dai_register_cb dai_register_cbs[] = { 2083e1991d10SAlexandre Mergnat mt8365_dai_pcm_register, 2084e1991d10SAlexandre Mergnat mt8365_dai_i2s_register, 2085e1991d10SAlexandre Mergnat mt8365_dai_adda_register, 2086e1991d10SAlexandre Mergnat mt8365_dai_dmic_register, 2087e1991d10SAlexandre Mergnat mt8365_dai_memif_register, 2088e1991d10SAlexandre Mergnat }; 2089e1991d10SAlexandre Mergnat 2090e1991d10SAlexandre Mergnat static int mt8365_afe_pcm_dev_probe(struct platform_device *pdev) 2091e1991d10SAlexandre Mergnat { 2092e1991d10SAlexandre Mergnat struct mtk_base_afe *afe; 2093e1991d10SAlexandre Mergnat struct mt8365_afe_private *afe_priv; 2094e1991d10SAlexandre Mergnat struct device *dev; 2095e1991d10SAlexandre Mergnat int ret, i, sel_irq; 2096e1991d10SAlexandre Mergnat unsigned int irq_id; 2097e1991d10SAlexandre Mergnat struct resource *res; 2098e1991d10SAlexandre Mergnat 2099e1991d10SAlexandre Mergnat afe = devm_kzalloc(&pdev->dev, sizeof(*afe), GFP_KERNEL); 2100e1991d10SAlexandre Mergnat if (!afe) 2101e1991d10SAlexandre Mergnat return -ENOMEM; 2102e1991d10SAlexandre Mergnat platform_set_drvdata(pdev, afe); 2103e1991d10SAlexandre Mergnat 2104e1991d10SAlexandre Mergnat afe->platform_priv = devm_kzalloc(&pdev->dev, sizeof(*afe_priv), 2105e1991d10SAlexandre Mergnat GFP_KERNEL); 2106e1991d10SAlexandre Mergnat if (!afe->platform_priv) 2107e1991d10SAlexandre Mergnat return -ENOMEM; 2108e1991d10SAlexandre Mergnat 2109e1991d10SAlexandre Mergnat afe_priv = afe->platform_priv; 2110e1991d10SAlexandre Mergnat afe->dev = &pdev->dev; 2111e1991d10SAlexandre Mergnat dev = afe->dev; 2112e1991d10SAlexandre Mergnat 2113e1991d10SAlexandre Mergnat spin_lock_init(&afe_priv->afe_ctrl_lock); 2114e1991d10SAlexandre Mergnat mutex_init(&afe_priv->afe_clk_mutex); 2115e1991d10SAlexandre Mergnat 2116e1991d10SAlexandre Mergnat res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 2117e1991d10SAlexandre Mergnat afe->base_addr = devm_ioremap_resource(&pdev->dev, res); 2118e1991d10SAlexandre Mergnat if (IS_ERR(afe->base_addr)) 2119e1991d10SAlexandre Mergnat return PTR_ERR(afe->base_addr); 2120e1991d10SAlexandre Mergnat 2121e1991d10SAlexandre Mergnat res = platform_get_resource(pdev, IORESOURCE_MEM, 1); 2122e1991d10SAlexandre Mergnat if (res) { 2123e1991d10SAlexandre Mergnat afe_priv->afe_sram_vir_addr = 2124e1991d10SAlexandre Mergnat devm_ioremap_resource(&pdev->dev, res); 2125e1991d10SAlexandre Mergnat if (!IS_ERR(afe_priv->afe_sram_vir_addr)) { 2126e1991d10SAlexandre Mergnat afe_priv->afe_sram_phy_addr = res->start; 2127e1991d10SAlexandre Mergnat afe_priv->afe_sram_size = resource_size(res); 2128e1991d10SAlexandre Mergnat } 2129e1991d10SAlexandre Mergnat } 2130e1991d10SAlexandre Mergnat 2131e1991d10SAlexandre Mergnat /* initial audio related clock */ 2132e1991d10SAlexandre Mergnat ret = mt8365_afe_init_audio_clk(afe); 2133e1991d10SAlexandre Mergnat if (ret) 2134e1991d10SAlexandre Mergnat return dev_err_probe(afe->dev, ret, "mt8365_afe_init_audio_clk fail\n"); 2135e1991d10SAlexandre Mergnat 2136e1991d10SAlexandre Mergnat afe->regmap = devm_regmap_init_mmio_clk(&pdev->dev, "top_audio_sel", 2137e1991d10SAlexandre Mergnat afe->base_addr, 2138e1991d10SAlexandre Mergnat &mt8365_afe_regmap_config); 2139e1991d10SAlexandre Mergnat if (IS_ERR(afe->regmap)) 2140e1991d10SAlexandre Mergnat return PTR_ERR(afe->regmap); 2141e1991d10SAlexandre Mergnat 2142e1991d10SAlexandre Mergnat /* memif % irq initialize*/ 2143e1991d10SAlexandre Mergnat afe->memif_size = MT8365_AFE_MEMIF_NUM; 2144e1991d10SAlexandre Mergnat afe->memif = devm_kcalloc(afe->dev, afe->memif_size, 2145e1991d10SAlexandre Mergnat sizeof(*afe->memif), GFP_KERNEL); 2146e1991d10SAlexandre Mergnat if (!afe->memif) 2147e1991d10SAlexandre Mergnat return -ENOMEM; 2148e1991d10SAlexandre Mergnat 2149e1991d10SAlexandre Mergnat afe->irqs_size = MT8365_AFE_IRQ_NUM; 2150e1991d10SAlexandre Mergnat afe->irqs = devm_kcalloc(afe->dev, afe->irqs_size, 2151e1991d10SAlexandre Mergnat sizeof(*afe->irqs), GFP_KERNEL); 2152e1991d10SAlexandre Mergnat if (!afe->irqs) 2153e1991d10SAlexandre Mergnat return -ENOMEM; 2154e1991d10SAlexandre Mergnat 2155e1991d10SAlexandre Mergnat for (i = 0; i < afe->irqs_size; i++) 2156e1991d10SAlexandre Mergnat afe->irqs[i].irq_data = &irq_data[i]; 2157e1991d10SAlexandre Mergnat 2158e1991d10SAlexandre Mergnat irq_id = platform_get_irq(pdev, 0); 2159e1991d10SAlexandre Mergnat if (!irq_id) { 2160e1991d10SAlexandre Mergnat dev_err_probe(afe->dev, irq_id, "np %s no irq\n", afe->dev->of_node->name); 2161e1991d10SAlexandre Mergnat return -ENXIO; 2162e1991d10SAlexandre Mergnat } 2163e1991d10SAlexandre Mergnat ret = devm_request_irq(afe->dev, irq_id, mt8365_afe_irq_handler, 2164e1991d10SAlexandre Mergnat 0, "Afe_ISR_Handle", (void *)afe); 2165e1991d10SAlexandre Mergnat if (ret) 2166e1991d10SAlexandre Mergnat return dev_err_probe(afe->dev, ret, "could not request_irq\n"); 2167e1991d10SAlexandre Mergnat 2168e1991d10SAlexandre Mergnat /* init sub_dais */ 2169e1991d10SAlexandre Mergnat INIT_LIST_HEAD(&afe->sub_dais); 2170e1991d10SAlexandre Mergnat 2171e1991d10SAlexandre Mergnat for (i = 0; i < ARRAY_SIZE(dai_register_cbs); i++) { 2172e1991d10SAlexandre Mergnat ret = dai_register_cbs[i](afe); 2173e1991d10SAlexandre Mergnat if (ret) { 2174e1991d10SAlexandre Mergnat dev_warn(afe->dev, "dai register i %d fail, ret %d\n", 2175e1991d10SAlexandre Mergnat i, ret); 2176e1991d10SAlexandre Mergnat return ret; 2177e1991d10SAlexandre Mergnat } 2178e1991d10SAlexandre Mergnat } 2179e1991d10SAlexandre Mergnat 2180e1991d10SAlexandre Mergnat /* init dai_driver and component_driver */ 2181e1991d10SAlexandre Mergnat ret = mtk_afe_combine_sub_dai(afe); 2182e1991d10SAlexandre Mergnat if (ret) { 2183e1991d10SAlexandre Mergnat dev_warn(afe->dev, "mtk_afe_combine_sub_dai fail, ret %d\n", 2184e1991d10SAlexandre Mergnat ret); 2185e1991d10SAlexandre Mergnat return ret; 2186e1991d10SAlexandre Mergnat } 2187e1991d10SAlexandre Mergnat 2188e1991d10SAlexandre Mergnat for (i = 0; i < afe->memif_size; i++) { 2189e1991d10SAlexandre Mergnat afe->memif[i].data = &memif_data[i]; 2190e1991d10SAlexandre Mergnat sel_irq = memif_specified_irqs[i]; 2191e1991d10SAlexandre Mergnat if (sel_irq >= 0) { 2192e1991d10SAlexandre Mergnat afe->memif[i].irq_usage = sel_irq; 2193e1991d10SAlexandre Mergnat afe->memif[i].const_irq = 1; 2194e1991d10SAlexandre Mergnat afe->irqs[sel_irq].irq_occupyed = true; 2195e1991d10SAlexandre Mergnat } else { 2196e1991d10SAlexandre Mergnat afe->memif[i].irq_usage = -1; 2197e1991d10SAlexandre Mergnat } 2198e1991d10SAlexandre Mergnat } 2199e1991d10SAlexandre Mergnat 2200e1991d10SAlexandre Mergnat afe->mtk_afe_hardware = &mt8365_afe_hardware; 2201e1991d10SAlexandre Mergnat afe->memif_fs = mt8365_memif_fs; 2202e1991d10SAlexandre Mergnat afe->irq_fs = mt8365_irq_fs; 2203e1991d10SAlexandre Mergnat 2204e1991d10SAlexandre Mergnat ret = devm_pm_runtime_enable(&pdev->dev); 2205e1991d10SAlexandre Mergnat if (ret) 2206e1991d10SAlexandre Mergnat return ret; 2207e1991d10SAlexandre Mergnat 2208e1991d10SAlexandre Mergnat pm_runtime_get_sync(&pdev->dev); 2209e1991d10SAlexandre Mergnat afe->reg_back_up_list = mt8365_afe_backup_list; 2210e1991d10SAlexandre Mergnat afe->reg_back_up_list_num = ARRAY_SIZE(mt8365_afe_backup_list); 2211e1991d10SAlexandre Mergnat afe->runtime_resume = mt8365_afe_runtime_resume; 2212e1991d10SAlexandre Mergnat afe->runtime_suspend = mt8365_afe_runtime_suspend; 2213e1991d10SAlexandre Mergnat 2214e1991d10SAlexandre Mergnat /* open afe pdn for dapm read/write audio register */ 2215e1991d10SAlexandre Mergnat mt8365_afe_enable_top_cg(afe, MT8365_TOP_CG_AFE); 2216e1991d10SAlexandre Mergnat 2217e1991d10SAlexandre Mergnat /* Set 26m parent clk */ 2218e1991d10SAlexandre Mergnat mt8365_afe_set_clk_parent(afe, 2219e1991d10SAlexandre Mergnat afe_priv->clocks[MT8365_CLK_TOP_AUD_SEL], 2220e1991d10SAlexandre Mergnat afe_priv->clocks[MT8365_CLK_CLK26M]); 2221e1991d10SAlexandre Mergnat 2222e1991d10SAlexandre Mergnat ret = devm_snd_soc_register_component(&pdev->dev, 2223e1991d10SAlexandre Mergnat &mtk_afe_pcm_platform, 2224e1991d10SAlexandre Mergnat afe->dai_drivers, 2225e1991d10SAlexandre Mergnat afe->num_dai_drivers); 2226e1991d10SAlexandre Mergnat if (ret) { 2227e1991d10SAlexandre Mergnat dev_warn(dev, "err_platform\n"); 2228e1991d10SAlexandre Mergnat return ret; 2229e1991d10SAlexandre Mergnat } 2230e1991d10SAlexandre Mergnat 2231e1991d10SAlexandre Mergnat mt8365_afe_init_registers(afe); 2232e1991d10SAlexandre Mergnat 2233e1991d10SAlexandre Mergnat return 0; 2234e1991d10SAlexandre Mergnat } 2235e1991d10SAlexandre Mergnat 2236e1991d10SAlexandre Mergnat static void mt8365_afe_pcm_dev_remove(struct platform_device *pdev) 2237e1991d10SAlexandre Mergnat { 2238e1991d10SAlexandre Mergnat struct mtk_base_afe *afe = platform_get_drvdata(pdev); 2239e1991d10SAlexandre Mergnat 2240e1991d10SAlexandre Mergnat mt8365_afe_disable_top_cg(afe, MT8365_TOP_CG_AFE); 2241e1991d10SAlexandre Mergnat 2242e1991d10SAlexandre Mergnat pm_runtime_disable(&pdev->dev); 2243e1991d10SAlexandre Mergnat if (!pm_runtime_status_suspended(&pdev->dev)) 2244e1991d10SAlexandre Mergnat mt8365_afe_runtime_suspend(&pdev->dev); 2245e1991d10SAlexandre Mergnat } 2246e1991d10SAlexandre Mergnat 2247e1991d10SAlexandre Mergnat static const struct of_device_id mt8365_afe_pcm_dt_match[] = { 2248e1991d10SAlexandre Mergnat { .compatible = "mediatek,mt8365-afe-pcm", }, 2249e1991d10SAlexandre Mergnat { } 2250e1991d10SAlexandre Mergnat }; 2251e1991d10SAlexandre Mergnat MODULE_DEVICE_TABLE(of, mt8365_afe_pcm_dt_match); 2252e1991d10SAlexandre Mergnat 2253e1991d10SAlexandre Mergnat static const struct dev_pm_ops mt8365_afe_pm_ops = { 2254e1991d10SAlexandre Mergnat SET_RUNTIME_PM_OPS(mt8365_afe_dev_runtime_suspend, 2255e1991d10SAlexandre Mergnat mt8365_afe_dev_runtime_resume, NULL) 2256e1991d10SAlexandre Mergnat SET_SYSTEM_SLEEP_PM_OPS(mt8365_afe_suspend, 2257e1991d10SAlexandre Mergnat mt8365_afe_resume) 2258e1991d10SAlexandre Mergnat }; 2259e1991d10SAlexandre Mergnat 2260e1991d10SAlexandre Mergnat static struct platform_driver mt8365_afe_pcm_driver = { 2261e1991d10SAlexandre Mergnat .driver = { 2262e1991d10SAlexandre Mergnat .name = "mt8365-afe-pcm", 2263e1991d10SAlexandre Mergnat .of_match_table = mt8365_afe_pcm_dt_match, 2264e1991d10SAlexandre Mergnat .pm = &mt8365_afe_pm_ops, 2265e1991d10SAlexandre Mergnat }, 2266e1991d10SAlexandre Mergnat .probe = mt8365_afe_pcm_dev_probe, 2267e1991d10SAlexandre Mergnat .remove_new = mt8365_afe_pcm_dev_remove, 2268e1991d10SAlexandre Mergnat }; 2269e1991d10SAlexandre Mergnat 2270e1991d10SAlexandre Mergnat module_platform_driver(mt8365_afe_pcm_driver); 2271e1991d10SAlexandre Mergnat 2272e1991d10SAlexandre Mergnat MODULE_DESCRIPTION("MediaTek ALSA SoC AFE platform driver"); 2273e1991d10SAlexandre Mergnat MODULE_AUTHOR("Jia Zeng <jia.zeng@mediatek.com>"); 2274e1991d10SAlexandre Mergnat MODULE_AUTHOR("Alexandre Mergnat <amergnat@baylibre.com>"); 2275e1991d10SAlexandre Mergnat MODULE_LICENSE("GPL"); 2276