18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0 28c2ecf20Sopenharmony_ci// 38c2ecf20Sopenharmony_ci// Mediatek ALSA SoC AFE platform driver for 6797 48c2ecf20Sopenharmony_ci// 58c2ecf20Sopenharmony_ci// Copyright (c) 2018 MediaTek Inc. 68c2ecf20Sopenharmony_ci// Author: KaiChieh Chuang <kaichieh.chuang@mediatek.com> 78c2ecf20Sopenharmony_ci 88c2ecf20Sopenharmony_ci#include <linux/delay.h> 98c2ecf20Sopenharmony_ci#include <linux/module.h> 108c2ecf20Sopenharmony_ci#include <linux/mfd/syscon.h> 118c2ecf20Sopenharmony_ci#include <linux/of.h> 128c2ecf20Sopenharmony_ci#include <linux/of_address.h> 138c2ecf20Sopenharmony_ci#include <linux/pm_runtime.h> 148c2ecf20Sopenharmony_ci 158c2ecf20Sopenharmony_ci#include "mt6797-afe-common.h" 168c2ecf20Sopenharmony_ci#include "mt6797-afe-clk.h" 178c2ecf20Sopenharmony_ci#include "mt6797-interconnection.h" 188c2ecf20Sopenharmony_ci#include "mt6797-reg.h" 198c2ecf20Sopenharmony_ci#include "../common/mtk-afe-platform-driver.h" 208c2ecf20Sopenharmony_ci#include "../common/mtk-afe-fe-dai.h" 218c2ecf20Sopenharmony_ci 228c2ecf20Sopenharmony_cienum { 238c2ecf20Sopenharmony_ci MTK_AFE_RATE_8K = 0, 248c2ecf20Sopenharmony_ci MTK_AFE_RATE_11K = 1, 258c2ecf20Sopenharmony_ci MTK_AFE_RATE_12K = 2, 268c2ecf20Sopenharmony_ci MTK_AFE_RATE_384K = 3, 278c2ecf20Sopenharmony_ci MTK_AFE_RATE_16K = 4, 288c2ecf20Sopenharmony_ci MTK_AFE_RATE_22K = 5, 298c2ecf20Sopenharmony_ci MTK_AFE_RATE_24K = 6, 308c2ecf20Sopenharmony_ci MTK_AFE_RATE_130K = 7, 318c2ecf20Sopenharmony_ci MTK_AFE_RATE_32K = 8, 328c2ecf20Sopenharmony_ci MTK_AFE_RATE_44K = 9, 338c2ecf20Sopenharmony_ci MTK_AFE_RATE_48K = 10, 348c2ecf20Sopenharmony_ci MTK_AFE_RATE_88K = 11, 358c2ecf20Sopenharmony_ci MTK_AFE_RATE_96K = 12, 368c2ecf20Sopenharmony_ci MTK_AFE_RATE_174K = 13, 378c2ecf20Sopenharmony_ci MTK_AFE_RATE_192K = 14, 388c2ecf20Sopenharmony_ci MTK_AFE_RATE_260K = 15, 398c2ecf20Sopenharmony_ci}; 408c2ecf20Sopenharmony_ci 418c2ecf20Sopenharmony_cienum { 428c2ecf20Sopenharmony_ci MTK_AFE_DAI_MEMIF_RATE_8K = 0, 438c2ecf20Sopenharmony_ci MTK_AFE_DAI_MEMIF_RATE_16K = 1, 448c2ecf20Sopenharmony_ci MTK_AFE_DAI_MEMIF_RATE_32K = 2, 458c2ecf20Sopenharmony_ci}; 468c2ecf20Sopenharmony_ci 478c2ecf20Sopenharmony_cienum { 488c2ecf20Sopenharmony_ci MTK_AFE_PCM_RATE_8K = 0, 498c2ecf20Sopenharmony_ci MTK_AFE_PCM_RATE_16K = 1, 508c2ecf20Sopenharmony_ci MTK_AFE_PCM_RATE_32K = 2, 518c2ecf20Sopenharmony_ci MTK_AFE_PCM_RATE_48K = 3, 528c2ecf20Sopenharmony_ci}; 538c2ecf20Sopenharmony_ci 548c2ecf20Sopenharmony_ciunsigned int mt6797_general_rate_transform(struct device *dev, 558c2ecf20Sopenharmony_ci unsigned int rate) 568c2ecf20Sopenharmony_ci{ 578c2ecf20Sopenharmony_ci switch (rate) { 588c2ecf20Sopenharmony_ci case 8000: 598c2ecf20Sopenharmony_ci return MTK_AFE_RATE_8K; 608c2ecf20Sopenharmony_ci case 11025: 618c2ecf20Sopenharmony_ci return MTK_AFE_RATE_11K; 628c2ecf20Sopenharmony_ci case 12000: 638c2ecf20Sopenharmony_ci return MTK_AFE_RATE_12K; 648c2ecf20Sopenharmony_ci case 16000: 658c2ecf20Sopenharmony_ci return MTK_AFE_RATE_16K; 668c2ecf20Sopenharmony_ci case 22050: 678c2ecf20Sopenharmony_ci return MTK_AFE_RATE_22K; 688c2ecf20Sopenharmony_ci case 24000: 698c2ecf20Sopenharmony_ci return MTK_AFE_RATE_24K; 708c2ecf20Sopenharmony_ci case 32000: 718c2ecf20Sopenharmony_ci return MTK_AFE_RATE_32K; 728c2ecf20Sopenharmony_ci case 44100: 738c2ecf20Sopenharmony_ci return MTK_AFE_RATE_44K; 748c2ecf20Sopenharmony_ci case 48000: 758c2ecf20Sopenharmony_ci return MTK_AFE_RATE_48K; 768c2ecf20Sopenharmony_ci case 88200: 778c2ecf20Sopenharmony_ci return MTK_AFE_RATE_88K; 788c2ecf20Sopenharmony_ci case 96000: 798c2ecf20Sopenharmony_ci return MTK_AFE_RATE_96K; 808c2ecf20Sopenharmony_ci case 130000: 818c2ecf20Sopenharmony_ci return MTK_AFE_RATE_130K; 828c2ecf20Sopenharmony_ci case 176400: 838c2ecf20Sopenharmony_ci return MTK_AFE_RATE_174K; 848c2ecf20Sopenharmony_ci case 192000: 858c2ecf20Sopenharmony_ci return MTK_AFE_RATE_192K; 868c2ecf20Sopenharmony_ci case 260000: 878c2ecf20Sopenharmony_ci return MTK_AFE_RATE_260K; 888c2ecf20Sopenharmony_ci default: 898c2ecf20Sopenharmony_ci dev_warn(dev, "%s(), rate %u invalid, use %d!!!\n", 908c2ecf20Sopenharmony_ci __func__, rate, MTK_AFE_RATE_48K); 918c2ecf20Sopenharmony_ci return MTK_AFE_RATE_48K; 928c2ecf20Sopenharmony_ci } 938c2ecf20Sopenharmony_ci} 948c2ecf20Sopenharmony_ci 958c2ecf20Sopenharmony_cistatic unsigned int dai_memif_rate_transform(struct device *dev, 968c2ecf20Sopenharmony_ci unsigned int rate) 978c2ecf20Sopenharmony_ci{ 988c2ecf20Sopenharmony_ci switch (rate) { 998c2ecf20Sopenharmony_ci case 8000: 1008c2ecf20Sopenharmony_ci return MTK_AFE_DAI_MEMIF_RATE_8K; 1018c2ecf20Sopenharmony_ci case 16000: 1028c2ecf20Sopenharmony_ci return MTK_AFE_DAI_MEMIF_RATE_16K; 1038c2ecf20Sopenharmony_ci case 32000: 1048c2ecf20Sopenharmony_ci return MTK_AFE_DAI_MEMIF_RATE_32K; 1058c2ecf20Sopenharmony_ci default: 1068c2ecf20Sopenharmony_ci dev_warn(dev, "%s(), rate %u invalid, use %d!!!\n", 1078c2ecf20Sopenharmony_ci __func__, rate, MTK_AFE_DAI_MEMIF_RATE_16K); 1088c2ecf20Sopenharmony_ci return MTK_AFE_DAI_MEMIF_RATE_16K; 1098c2ecf20Sopenharmony_ci } 1108c2ecf20Sopenharmony_ci} 1118c2ecf20Sopenharmony_ci 1128c2ecf20Sopenharmony_ciunsigned int mt6797_rate_transform(struct device *dev, 1138c2ecf20Sopenharmony_ci unsigned int rate, int aud_blk) 1148c2ecf20Sopenharmony_ci{ 1158c2ecf20Sopenharmony_ci switch (aud_blk) { 1168c2ecf20Sopenharmony_ci case MT6797_MEMIF_DAI: 1178c2ecf20Sopenharmony_ci case MT6797_MEMIF_MOD_DAI: 1188c2ecf20Sopenharmony_ci return dai_memif_rate_transform(dev, rate); 1198c2ecf20Sopenharmony_ci default: 1208c2ecf20Sopenharmony_ci return mt6797_general_rate_transform(dev, rate); 1218c2ecf20Sopenharmony_ci } 1228c2ecf20Sopenharmony_ci} 1238c2ecf20Sopenharmony_ci 1248c2ecf20Sopenharmony_cistatic const struct snd_pcm_hardware mt6797_afe_hardware = { 1258c2ecf20Sopenharmony_ci .info = SNDRV_PCM_INFO_MMAP | 1268c2ecf20Sopenharmony_ci SNDRV_PCM_INFO_INTERLEAVED | 1278c2ecf20Sopenharmony_ci SNDRV_PCM_INFO_MMAP_VALID, 1288c2ecf20Sopenharmony_ci .formats = SNDRV_PCM_FMTBIT_S16_LE | 1298c2ecf20Sopenharmony_ci SNDRV_PCM_FMTBIT_S24_LE | 1308c2ecf20Sopenharmony_ci SNDRV_PCM_FMTBIT_S32_LE, 1318c2ecf20Sopenharmony_ci .period_bytes_min = 256, 1328c2ecf20Sopenharmony_ci .period_bytes_max = 4 * 48 * 1024, 1338c2ecf20Sopenharmony_ci .periods_min = 2, 1348c2ecf20Sopenharmony_ci .periods_max = 256, 1358c2ecf20Sopenharmony_ci .buffer_bytes_max = 8 * 48 * 1024, 1368c2ecf20Sopenharmony_ci .fifo_size = 0, 1378c2ecf20Sopenharmony_ci}; 1388c2ecf20Sopenharmony_ci 1398c2ecf20Sopenharmony_cistatic int mt6797_memif_fs(struct snd_pcm_substream *substream, 1408c2ecf20Sopenharmony_ci unsigned int rate) 1418c2ecf20Sopenharmony_ci{ 1428c2ecf20Sopenharmony_ci struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); 1438c2ecf20Sopenharmony_ci struct snd_soc_component *component = 1448c2ecf20Sopenharmony_ci snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME); 1458c2ecf20Sopenharmony_ci struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component); 1468c2ecf20Sopenharmony_ci int id = asoc_rtd_to_cpu(rtd, 0)->id; 1478c2ecf20Sopenharmony_ci 1488c2ecf20Sopenharmony_ci return mt6797_rate_transform(afe->dev, rate, id); 1498c2ecf20Sopenharmony_ci} 1508c2ecf20Sopenharmony_ci 1518c2ecf20Sopenharmony_cistatic int mt6797_irq_fs(struct snd_pcm_substream *substream, unsigned int rate) 1528c2ecf20Sopenharmony_ci{ 1538c2ecf20Sopenharmony_ci struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); 1548c2ecf20Sopenharmony_ci struct snd_soc_component *component = 1558c2ecf20Sopenharmony_ci snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME); 1568c2ecf20Sopenharmony_ci struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component); 1578c2ecf20Sopenharmony_ci 1588c2ecf20Sopenharmony_ci return mt6797_general_rate_transform(afe->dev, rate); 1598c2ecf20Sopenharmony_ci} 1608c2ecf20Sopenharmony_ci 1618c2ecf20Sopenharmony_ci#define MTK_PCM_RATES (SNDRV_PCM_RATE_8000_48000 |\ 1628c2ecf20Sopenharmony_ci SNDRV_PCM_RATE_88200 |\ 1638c2ecf20Sopenharmony_ci SNDRV_PCM_RATE_96000 |\ 1648c2ecf20Sopenharmony_ci SNDRV_PCM_RATE_176400 |\ 1658c2ecf20Sopenharmony_ci SNDRV_PCM_RATE_192000) 1668c2ecf20Sopenharmony_ci 1678c2ecf20Sopenharmony_ci#define MTK_PCM_DAI_RATES (SNDRV_PCM_RATE_8000 |\ 1688c2ecf20Sopenharmony_ci SNDRV_PCM_RATE_16000 |\ 1698c2ecf20Sopenharmony_ci SNDRV_PCM_RATE_32000) 1708c2ecf20Sopenharmony_ci 1718c2ecf20Sopenharmony_ci#define MTK_PCM_FORMATS (SNDRV_PCM_FMTBIT_S16_LE |\ 1728c2ecf20Sopenharmony_ci SNDRV_PCM_FMTBIT_S24_LE |\ 1738c2ecf20Sopenharmony_ci SNDRV_PCM_FMTBIT_S32_LE) 1748c2ecf20Sopenharmony_ci 1758c2ecf20Sopenharmony_cistatic struct snd_soc_dai_driver mt6797_memif_dai_driver[] = { 1768c2ecf20Sopenharmony_ci /* FE DAIs: memory intefaces to CPU */ 1778c2ecf20Sopenharmony_ci { 1788c2ecf20Sopenharmony_ci .name = "DL1", 1798c2ecf20Sopenharmony_ci .id = MT6797_MEMIF_DL1, 1808c2ecf20Sopenharmony_ci .playback = { 1818c2ecf20Sopenharmony_ci .stream_name = "DL1", 1828c2ecf20Sopenharmony_ci .channels_min = 1, 1838c2ecf20Sopenharmony_ci .channels_max = 2, 1848c2ecf20Sopenharmony_ci .rates = MTK_PCM_RATES, 1858c2ecf20Sopenharmony_ci .formats = MTK_PCM_FORMATS, 1868c2ecf20Sopenharmony_ci }, 1878c2ecf20Sopenharmony_ci .ops = &mtk_afe_fe_ops, 1888c2ecf20Sopenharmony_ci }, 1898c2ecf20Sopenharmony_ci { 1908c2ecf20Sopenharmony_ci .name = "DL2", 1918c2ecf20Sopenharmony_ci .id = MT6797_MEMIF_DL2, 1928c2ecf20Sopenharmony_ci .playback = { 1938c2ecf20Sopenharmony_ci .stream_name = "DL2", 1948c2ecf20Sopenharmony_ci .channels_min = 1, 1958c2ecf20Sopenharmony_ci .channels_max = 2, 1968c2ecf20Sopenharmony_ci .rates = MTK_PCM_RATES, 1978c2ecf20Sopenharmony_ci .formats = MTK_PCM_FORMATS, 1988c2ecf20Sopenharmony_ci }, 1998c2ecf20Sopenharmony_ci .ops = &mtk_afe_fe_ops, 2008c2ecf20Sopenharmony_ci }, 2018c2ecf20Sopenharmony_ci { 2028c2ecf20Sopenharmony_ci .name = "DL3", 2038c2ecf20Sopenharmony_ci .id = MT6797_MEMIF_DL3, 2048c2ecf20Sopenharmony_ci .playback = { 2058c2ecf20Sopenharmony_ci .stream_name = "DL3", 2068c2ecf20Sopenharmony_ci .channels_min = 1, 2078c2ecf20Sopenharmony_ci .channels_max = 2, 2088c2ecf20Sopenharmony_ci .rates = MTK_PCM_RATES, 2098c2ecf20Sopenharmony_ci .formats = MTK_PCM_FORMATS, 2108c2ecf20Sopenharmony_ci }, 2118c2ecf20Sopenharmony_ci .ops = &mtk_afe_fe_ops, 2128c2ecf20Sopenharmony_ci }, 2138c2ecf20Sopenharmony_ci { 2148c2ecf20Sopenharmony_ci .name = "UL1", 2158c2ecf20Sopenharmony_ci .id = MT6797_MEMIF_VUL12, 2168c2ecf20Sopenharmony_ci .capture = { 2178c2ecf20Sopenharmony_ci .stream_name = "UL1", 2188c2ecf20Sopenharmony_ci .channels_min = 1, 2198c2ecf20Sopenharmony_ci .channels_max = 2, 2208c2ecf20Sopenharmony_ci .rates = MTK_PCM_RATES, 2218c2ecf20Sopenharmony_ci .formats = MTK_PCM_FORMATS, 2228c2ecf20Sopenharmony_ci }, 2238c2ecf20Sopenharmony_ci .ops = &mtk_afe_fe_ops, 2248c2ecf20Sopenharmony_ci }, 2258c2ecf20Sopenharmony_ci { 2268c2ecf20Sopenharmony_ci .name = "UL2", 2278c2ecf20Sopenharmony_ci .id = MT6797_MEMIF_AWB, 2288c2ecf20Sopenharmony_ci .capture = { 2298c2ecf20Sopenharmony_ci .stream_name = "UL2", 2308c2ecf20Sopenharmony_ci .channels_min = 1, 2318c2ecf20Sopenharmony_ci .channels_max = 2, 2328c2ecf20Sopenharmony_ci .rates = MTK_PCM_RATES, 2338c2ecf20Sopenharmony_ci .formats = MTK_PCM_FORMATS, 2348c2ecf20Sopenharmony_ci }, 2358c2ecf20Sopenharmony_ci .ops = &mtk_afe_fe_ops, 2368c2ecf20Sopenharmony_ci }, 2378c2ecf20Sopenharmony_ci { 2388c2ecf20Sopenharmony_ci .name = "UL3", 2398c2ecf20Sopenharmony_ci .id = MT6797_MEMIF_VUL, 2408c2ecf20Sopenharmony_ci .capture = { 2418c2ecf20Sopenharmony_ci .stream_name = "UL3", 2428c2ecf20Sopenharmony_ci .channels_min = 1, 2438c2ecf20Sopenharmony_ci .channels_max = 2, 2448c2ecf20Sopenharmony_ci .rates = MTK_PCM_RATES, 2458c2ecf20Sopenharmony_ci .formats = MTK_PCM_FORMATS, 2468c2ecf20Sopenharmony_ci }, 2478c2ecf20Sopenharmony_ci .ops = &mtk_afe_fe_ops, 2488c2ecf20Sopenharmony_ci }, 2498c2ecf20Sopenharmony_ci { 2508c2ecf20Sopenharmony_ci .name = "UL_MONO_1", 2518c2ecf20Sopenharmony_ci .id = MT6797_MEMIF_MOD_DAI, 2528c2ecf20Sopenharmony_ci .capture = { 2538c2ecf20Sopenharmony_ci .stream_name = "UL_MONO_1", 2548c2ecf20Sopenharmony_ci .channels_min = 1, 2558c2ecf20Sopenharmony_ci .channels_max = 1, 2568c2ecf20Sopenharmony_ci .rates = MTK_PCM_DAI_RATES, 2578c2ecf20Sopenharmony_ci .formats = MTK_PCM_FORMATS, 2588c2ecf20Sopenharmony_ci }, 2598c2ecf20Sopenharmony_ci .ops = &mtk_afe_fe_ops, 2608c2ecf20Sopenharmony_ci }, 2618c2ecf20Sopenharmony_ci { 2628c2ecf20Sopenharmony_ci .name = "UL_MONO_2", 2638c2ecf20Sopenharmony_ci .id = MT6797_MEMIF_DAI, 2648c2ecf20Sopenharmony_ci .capture = { 2658c2ecf20Sopenharmony_ci .stream_name = "UL_MONO_2", 2668c2ecf20Sopenharmony_ci .channels_min = 1, 2678c2ecf20Sopenharmony_ci .channels_max = 1, 2688c2ecf20Sopenharmony_ci .rates = MTK_PCM_DAI_RATES, 2698c2ecf20Sopenharmony_ci .formats = MTK_PCM_FORMATS, 2708c2ecf20Sopenharmony_ci }, 2718c2ecf20Sopenharmony_ci .ops = &mtk_afe_fe_ops, 2728c2ecf20Sopenharmony_ci }, 2738c2ecf20Sopenharmony_ci}; 2748c2ecf20Sopenharmony_ci 2758c2ecf20Sopenharmony_ci/* dma widget & routes*/ 2768c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new memif_ul1_ch1_mix[] = { 2778c2ecf20Sopenharmony_ci SOC_DAPM_SINGLE_AUTODISABLE("ADDA_UL_CH1", AFE_CONN21, 2788c2ecf20Sopenharmony_ci I_ADDA_UL_CH1, 1, 0), 2798c2ecf20Sopenharmony_ci}; 2808c2ecf20Sopenharmony_ci 2818c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new memif_ul1_ch2_mix[] = { 2828c2ecf20Sopenharmony_ci SOC_DAPM_SINGLE_AUTODISABLE("ADDA_UL_CH2", AFE_CONN22, 2838c2ecf20Sopenharmony_ci I_ADDA_UL_CH2, 1, 0), 2848c2ecf20Sopenharmony_ci}; 2858c2ecf20Sopenharmony_ci 2868c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new memif_ul2_ch1_mix[] = { 2878c2ecf20Sopenharmony_ci SOC_DAPM_SINGLE_AUTODISABLE("ADDA_UL_CH1", AFE_CONN5, 2888c2ecf20Sopenharmony_ci I_ADDA_UL_CH1, 1, 0), 2898c2ecf20Sopenharmony_ci SOC_DAPM_SINGLE_AUTODISABLE("DL1_CH1", AFE_CONN5, 2908c2ecf20Sopenharmony_ci I_DL1_CH1, 1, 0), 2918c2ecf20Sopenharmony_ci SOC_DAPM_SINGLE_AUTODISABLE("DL2_CH1", AFE_CONN5, 2928c2ecf20Sopenharmony_ci I_DL2_CH1, 1, 0), 2938c2ecf20Sopenharmony_ci SOC_DAPM_SINGLE_AUTODISABLE("DL3_CH1", AFE_CONN5, 2948c2ecf20Sopenharmony_ci I_DL3_CH1, 1, 0), 2958c2ecf20Sopenharmony_ci}; 2968c2ecf20Sopenharmony_ci 2978c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new memif_ul2_ch2_mix[] = { 2988c2ecf20Sopenharmony_ci SOC_DAPM_SINGLE_AUTODISABLE("ADDA_UL_CH2", AFE_CONN6, 2998c2ecf20Sopenharmony_ci I_ADDA_UL_CH2, 1, 0), 3008c2ecf20Sopenharmony_ci SOC_DAPM_SINGLE_AUTODISABLE("DL1_CH2", AFE_CONN6, 3018c2ecf20Sopenharmony_ci I_DL1_CH2, 1, 0), 3028c2ecf20Sopenharmony_ci SOC_DAPM_SINGLE_AUTODISABLE("DL2_CH2", AFE_CONN6, 3038c2ecf20Sopenharmony_ci I_DL2_CH2, 1, 0), 3048c2ecf20Sopenharmony_ci SOC_DAPM_SINGLE_AUTODISABLE("DL3_CH2", AFE_CONN6, 3058c2ecf20Sopenharmony_ci I_DL3_CH2, 1, 0), 3068c2ecf20Sopenharmony_ci}; 3078c2ecf20Sopenharmony_ci 3088c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new memif_ul3_ch1_mix[] = { 3098c2ecf20Sopenharmony_ci SOC_DAPM_SINGLE_AUTODISABLE("ADDA_UL_CH1", AFE_CONN9, 3108c2ecf20Sopenharmony_ci I_ADDA_UL_CH1, 1, 0), 3118c2ecf20Sopenharmony_ci}; 3128c2ecf20Sopenharmony_ci 3138c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new memif_ul3_ch2_mix[] = { 3148c2ecf20Sopenharmony_ci SOC_DAPM_SINGLE_AUTODISABLE("ADDA_UL_CH2", AFE_CONN10, 3158c2ecf20Sopenharmony_ci I_ADDA_UL_CH2, 1, 0), 3168c2ecf20Sopenharmony_ci}; 3178c2ecf20Sopenharmony_ci 3188c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new memif_ul_mono_1_mix[] = { 3198c2ecf20Sopenharmony_ci SOC_DAPM_SINGLE_AUTODISABLE("ADDA_UL_CH1", AFE_CONN12, 3208c2ecf20Sopenharmony_ci I_ADDA_UL_CH1, 1, 0), 3218c2ecf20Sopenharmony_ci SOC_DAPM_SINGLE_AUTODISABLE("ADDA_UL_CH2", AFE_CONN12, 3228c2ecf20Sopenharmony_ci I_ADDA_UL_CH2, 1, 0), 3238c2ecf20Sopenharmony_ci}; 3248c2ecf20Sopenharmony_ci 3258c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new memif_ul_mono_2_mix[] = { 3268c2ecf20Sopenharmony_ci SOC_DAPM_SINGLE_AUTODISABLE("ADDA_UL_CH1", AFE_CONN11, 3278c2ecf20Sopenharmony_ci I_ADDA_UL_CH1, 1, 0), 3288c2ecf20Sopenharmony_ci SOC_DAPM_SINGLE_AUTODISABLE("ADDA_UL_CH2", AFE_CONN11, 3298c2ecf20Sopenharmony_ci I_ADDA_UL_CH2, 1, 0), 3308c2ecf20Sopenharmony_ci}; 3318c2ecf20Sopenharmony_ci 3328c2ecf20Sopenharmony_cistatic const struct snd_soc_dapm_widget mt6797_memif_widgets[] = { 3338c2ecf20Sopenharmony_ci /* memif */ 3348c2ecf20Sopenharmony_ci SND_SOC_DAPM_MIXER("UL1_CH1", SND_SOC_NOPM, 0, 0, 3358c2ecf20Sopenharmony_ci memif_ul1_ch1_mix, ARRAY_SIZE(memif_ul1_ch1_mix)), 3368c2ecf20Sopenharmony_ci SND_SOC_DAPM_MIXER("UL1_CH2", SND_SOC_NOPM, 0, 0, 3378c2ecf20Sopenharmony_ci memif_ul1_ch2_mix, ARRAY_SIZE(memif_ul1_ch2_mix)), 3388c2ecf20Sopenharmony_ci 3398c2ecf20Sopenharmony_ci SND_SOC_DAPM_MIXER("UL2_CH1", SND_SOC_NOPM, 0, 0, 3408c2ecf20Sopenharmony_ci memif_ul2_ch1_mix, ARRAY_SIZE(memif_ul2_ch1_mix)), 3418c2ecf20Sopenharmony_ci SND_SOC_DAPM_MIXER("UL2_CH2", SND_SOC_NOPM, 0, 0, 3428c2ecf20Sopenharmony_ci memif_ul2_ch2_mix, ARRAY_SIZE(memif_ul2_ch2_mix)), 3438c2ecf20Sopenharmony_ci 3448c2ecf20Sopenharmony_ci SND_SOC_DAPM_MIXER("UL3_CH1", SND_SOC_NOPM, 0, 0, 3458c2ecf20Sopenharmony_ci memif_ul3_ch1_mix, ARRAY_SIZE(memif_ul3_ch1_mix)), 3468c2ecf20Sopenharmony_ci SND_SOC_DAPM_MIXER("UL3_CH2", SND_SOC_NOPM, 0, 0, 3478c2ecf20Sopenharmony_ci memif_ul3_ch2_mix, ARRAY_SIZE(memif_ul3_ch2_mix)), 3488c2ecf20Sopenharmony_ci 3498c2ecf20Sopenharmony_ci SND_SOC_DAPM_MIXER("UL_MONO_1_CH1", SND_SOC_NOPM, 0, 0, 3508c2ecf20Sopenharmony_ci memif_ul_mono_1_mix, 3518c2ecf20Sopenharmony_ci ARRAY_SIZE(memif_ul_mono_1_mix)), 3528c2ecf20Sopenharmony_ci 3538c2ecf20Sopenharmony_ci SND_SOC_DAPM_MIXER("UL_MONO_2_CH1", SND_SOC_NOPM, 0, 0, 3548c2ecf20Sopenharmony_ci memif_ul_mono_2_mix, 3558c2ecf20Sopenharmony_ci ARRAY_SIZE(memif_ul_mono_2_mix)), 3568c2ecf20Sopenharmony_ci}; 3578c2ecf20Sopenharmony_ci 3588c2ecf20Sopenharmony_cistatic const struct snd_soc_dapm_route mt6797_memif_routes[] = { 3598c2ecf20Sopenharmony_ci /* capture */ 3608c2ecf20Sopenharmony_ci {"UL1", NULL, "UL1_CH1"}, 3618c2ecf20Sopenharmony_ci {"UL1", NULL, "UL1_CH2"}, 3628c2ecf20Sopenharmony_ci {"UL1_CH1", "ADDA_UL_CH1", "ADDA Capture"}, 3638c2ecf20Sopenharmony_ci {"UL1_CH2", "ADDA_UL_CH2", "ADDA Capture"}, 3648c2ecf20Sopenharmony_ci 3658c2ecf20Sopenharmony_ci {"UL2", NULL, "UL2_CH1"}, 3668c2ecf20Sopenharmony_ci {"UL2", NULL, "UL2_CH2"}, 3678c2ecf20Sopenharmony_ci {"UL2_CH1", "ADDA_UL_CH1", "ADDA Capture"}, 3688c2ecf20Sopenharmony_ci {"UL2_CH2", "ADDA_UL_CH2", "ADDA Capture"}, 3698c2ecf20Sopenharmony_ci 3708c2ecf20Sopenharmony_ci {"UL3", NULL, "UL3_CH1"}, 3718c2ecf20Sopenharmony_ci {"UL3", NULL, "UL3_CH2"}, 3728c2ecf20Sopenharmony_ci {"UL3_CH1", "ADDA_UL_CH1", "ADDA Capture"}, 3738c2ecf20Sopenharmony_ci {"UL3_CH2", "ADDA_UL_CH2", "ADDA Capture"}, 3748c2ecf20Sopenharmony_ci 3758c2ecf20Sopenharmony_ci {"UL_MONO_1", NULL, "UL_MONO_1_CH1"}, 3768c2ecf20Sopenharmony_ci {"UL_MONO_1_CH1", "ADDA_UL_CH1", "ADDA Capture"}, 3778c2ecf20Sopenharmony_ci {"UL_MONO_1_CH1", "ADDA_UL_CH2", "ADDA Capture"}, 3788c2ecf20Sopenharmony_ci 3798c2ecf20Sopenharmony_ci {"UL_MONO_2", NULL, "UL_MONO_2_CH1"}, 3808c2ecf20Sopenharmony_ci {"UL_MONO_2_CH1", "ADDA_UL_CH1", "ADDA Capture"}, 3818c2ecf20Sopenharmony_ci {"UL_MONO_2_CH1", "ADDA_UL_CH2", "ADDA Capture"}, 3828c2ecf20Sopenharmony_ci}; 3838c2ecf20Sopenharmony_ci 3848c2ecf20Sopenharmony_cistatic const struct snd_soc_component_driver mt6797_afe_pcm_dai_component = { 3858c2ecf20Sopenharmony_ci .name = "mt6797-afe-pcm-dai", 3868c2ecf20Sopenharmony_ci}; 3878c2ecf20Sopenharmony_ci 3888c2ecf20Sopenharmony_cistatic const struct mtk_base_memif_data memif_data[MT6797_MEMIF_NUM] = { 3898c2ecf20Sopenharmony_ci [MT6797_MEMIF_DL1] = { 3908c2ecf20Sopenharmony_ci .name = "DL1", 3918c2ecf20Sopenharmony_ci .id = MT6797_MEMIF_DL1, 3928c2ecf20Sopenharmony_ci .reg_ofs_base = AFE_DL1_BASE, 3938c2ecf20Sopenharmony_ci .reg_ofs_cur = AFE_DL1_CUR, 3948c2ecf20Sopenharmony_ci .fs_reg = AFE_DAC_CON1, 3958c2ecf20Sopenharmony_ci .fs_shift = DL1_MODE_SFT, 3968c2ecf20Sopenharmony_ci .fs_maskbit = DL1_MODE_MASK, 3978c2ecf20Sopenharmony_ci .mono_reg = AFE_DAC_CON1, 3988c2ecf20Sopenharmony_ci .mono_shift = DL1_DATA_SFT, 3998c2ecf20Sopenharmony_ci .enable_reg = AFE_DAC_CON0, 4008c2ecf20Sopenharmony_ci .enable_shift = DL1_ON_SFT, 4018c2ecf20Sopenharmony_ci .hd_reg = AFE_MEMIF_HD_MODE, 4028c2ecf20Sopenharmony_ci .hd_shift = DL1_HD_SFT, 4038c2ecf20Sopenharmony_ci .agent_disable_reg = -1, 4048c2ecf20Sopenharmony_ci .msb_reg = -1, 4058c2ecf20Sopenharmony_ci }, 4068c2ecf20Sopenharmony_ci [MT6797_MEMIF_DL2] = { 4078c2ecf20Sopenharmony_ci .name = "DL2", 4088c2ecf20Sopenharmony_ci .id = MT6797_MEMIF_DL2, 4098c2ecf20Sopenharmony_ci .reg_ofs_base = AFE_DL2_BASE, 4108c2ecf20Sopenharmony_ci .reg_ofs_cur = AFE_DL2_CUR, 4118c2ecf20Sopenharmony_ci .fs_reg = AFE_DAC_CON1, 4128c2ecf20Sopenharmony_ci .fs_shift = DL2_MODE_SFT, 4138c2ecf20Sopenharmony_ci .fs_maskbit = DL2_MODE_MASK, 4148c2ecf20Sopenharmony_ci .mono_reg = AFE_DAC_CON1, 4158c2ecf20Sopenharmony_ci .mono_shift = DL2_DATA_SFT, 4168c2ecf20Sopenharmony_ci .enable_reg = AFE_DAC_CON0, 4178c2ecf20Sopenharmony_ci .enable_shift = DL2_ON_SFT, 4188c2ecf20Sopenharmony_ci .hd_reg = AFE_MEMIF_HD_MODE, 4198c2ecf20Sopenharmony_ci .hd_shift = DL2_HD_SFT, 4208c2ecf20Sopenharmony_ci .agent_disable_reg = -1, 4218c2ecf20Sopenharmony_ci .msb_reg = -1, 4228c2ecf20Sopenharmony_ci }, 4238c2ecf20Sopenharmony_ci [MT6797_MEMIF_DL3] = { 4248c2ecf20Sopenharmony_ci .name = "DL3", 4258c2ecf20Sopenharmony_ci .id = MT6797_MEMIF_DL3, 4268c2ecf20Sopenharmony_ci .reg_ofs_base = AFE_DL3_BASE, 4278c2ecf20Sopenharmony_ci .reg_ofs_cur = AFE_DL3_CUR, 4288c2ecf20Sopenharmony_ci .fs_reg = AFE_DAC_CON0, 4298c2ecf20Sopenharmony_ci .fs_shift = DL3_MODE_SFT, 4308c2ecf20Sopenharmony_ci .fs_maskbit = DL3_MODE_MASK, 4318c2ecf20Sopenharmony_ci .mono_reg = AFE_DAC_CON1, 4328c2ecf20Sopenharmony_ci .mono_shift = DL3_DATA_SFT, 4338c2ecf20Sopenharmony_ci .enable_reg = AFE_DAC_CON0, 4348c2ecf20Sopenharmony_ci .enable_shift = DL3_ON_SFT, 4358c2ecf20Sopenharmony_ci .hd_reg = AFE_MEMIF_HD_MODE, 4368c2ecf20Sopenharmony_ci .hd_shift = DL3_HD_SFT, 4378c2ecf20Sopenharmony_ci .agent_disable_reg = -1, 4388c2ecf20Sopenharmony_ci .msb_reg = -1, 4398c2ecf20Sopenharmony_ci }, 4408c2ecf20Sopenharmony_ci [MT6797_MEMIF_VUL] = { 4418c2ecf20Sopenharmony_ci .name = "VUL", 4428c2ecf20Sopenharmony_ci .id = MT6797_MEMIF_VUL, 4438c2ecf20Sopenharmony_ci .reg_ofs_base = AFE_VUL_BASE, 4448c2ecf20Sopenharmony_ci .reg_ofs_cur = AFE_VUL_CUR, 4458c2ecf20Sopenharmony_ci .fs_reg = AFE_DAC_CON1, 4468c2ecf20Sopenharmony_ci .fs_shift = VUL_MODE_SFT, 4478c2ecf20Sopenharmony_ci .fs_maskbit = VUL_MODE_MASK, 4488c2ecf20Sopenharmony_ci .mono_reg = AFE_DAC_CON1, 4498c2ecf20Sopenharmony_ci .mono_shift = VUL_DATA_SFT, 4508c2ecf20Sopenharmony_ci .enable_reg = AFE_DAC_CON0, 4518c2ecf20Sopenharmony_ci .enable_shift = VUL_ON_SFT, 4528c2ecf20Sopenharmony_ci .hd_reg = AFE_MEMIF_HD_MODE, 4538c2ecf20Sopenharmony_ci .hd_shift = VUL_HD_SFT, 4548c2ecf20Sopenharmony_ci .agent_disable_reg = -1, 4558c2ecf20Sopenharmony_ci .msb_reg = -1, 4568c2ecf20Sopenharmony_ci }, 4578c2ecf20Sopenharmony_ci [MT6797_MEMIF_AWB] = { 4588c2ecf20Sopenharmony_ci .name = "AWB", 4598c2ecf20Sopenharmony_ci .id = MT6797_MEMIF_AWB, 4608c2ecf20Sopenharmony_ci .reg_ofs_base = AFE_AWB_BASE, 4618c2ecf20Sopenharmony_ci .reg_ofs_cur = AFE_AWB_CUR, 4628c2ecf20Sopenharmony_ci .fs_reg = AFE_DAC_CON1, 4638c2ecf20Sopenharmony_ci .fs_shift = AWB_MODE_SFT, 4648c2ecf20Sopenharmony_ci .fs_maskbit = AWB_MODE_MASK, 4658c2ecf20Sopenharmony_ci .mono_reg = AFE_DAC_CON1, 4668c2ecf20Sopenharmony_ci .mono_shift = AWB_DATA_SFT, 4678c2ecf20Sopenharmony_ci .enable_reg = AFE_DAC_CON0, 4688c2ecf20Sopenharmony_ci .enable_shift = AWB_ON_SFT, 4698c2ecf20Sopenharmony_ci .hd_reg = AFE_MEMIF_HD_MODE, 4708c2ecf20Sopenharmony_ci .hd_shift = AWB_HD_SFT, 4718c2ecf20Sopenharmony_ci .agent_disable_reg = -1, 4728c2ecf20Sopenharmony_ci .msb_reg = -1, 4738c2ecf20Sopenharmony_ci }, 4748c2ecf20Sopenharmony_ci [MT6797_MEMIF_VUL12] = { 4758c2ecf20Sopenharmony_ci .name = "VUL12", 4768c2ecf20Sopenharmony_ci .id = MT6797_MEMIF_VUL12, 4778c2ecf20Sopenharmony_ci .reg_ofs_base = AFE_VUL_D2_BASE, 4788c2ecf20Sopenharmony_ci .reg_ofs_cur = AFE_VUL_D2_CUR, 4798c2ecf20Sopenharmony_ci .fs_reg = AFE_DAC_CON0, 4808c2ecf20Sopenharmony_ci .fs_shift = VUL_DATA2_MODE_SFT, 4818c2ecf20Sopenharmony_ci .fs_maskbit = VUL_DATA2_MODE_MASK, 4828c2ecf20Sopenharmony_ci .mono_reg = AFE_DAC_CON0, 4838c2ecf20Sopenharmony_ci .mono_shift = VUL_DATA2_DATA_SFT, 4848c2ecf20Sopenharmony_ci .enable_reg = AFE_DAC_CON0, 4858c2ecf20Sopenharmony_ci .enable_shift = VUL_DATA2_ON_SFT, 4868c2ecf20Sopenharmony_ci .hd_reg = AFE_MEMIF_HD_MODE, 4878c2ecf20Sopenharmony_ci .hd_shift = VUL_DATA2_HD_SFT, 4888c2ecf20Sopenharmony_ci .agent_disable_reg = -1, 4898c2ecf20Sopenharmony_ci .msb_reg = -1, 4908c2ecf20Sopenharmony_ci }, 4918c2ecf20Sopenharmony_ci [MT6797_MEMIF_DAI] = { 4928c2ecf20Sopenharmony_ci .name = "DAI", 4938c2ecf20Sopenharmony_ci .id = MT6797_MEMIF_DAI, 4948c2ecf20Sopenharmony_ci .reg_ofs_base = AFE_DAI_BASE, 4958c2ecf20Sopenharmony_ci .reg_ofs_cur = AFE_DAI_CUR, 4968c2ecf20Sopenharmony_ci .fs_reg = AFE_DAC_CON0, 4978c2ecf20Sopenharmony_ci .fs_shift = DAI_MODE_SFT, 4988c2ecf20Sopenharmony_ci .fs_maskbit = DAI_MODE_MASK, 4998c2ecf20Sopenharmony_ci .mono_reg = -1, 5008c2ecf20Sopenharmony_ci .mono_shift = 0, 5018c2ecf20Sopenharmony_ci .enable_reg = AFE_DAC_CON0, 5028c2ecf20Sopenharmony_ci .enable_shift = DAI_ON_SFT, 5038c2ecf20Sopenharmony_ci .hd_reg = AFE_MEMIF_HD_MODE, 5048c2ecf20Sopenharmony_ci .hd_shift = DAI_HD_SFT, 5058c2ecf20Sopenharmony_ci .agent_disable_reg = -1, 5068c2ecf20Sopenharmony_ci .msb_reg = -1, 5078c2ecf20Sopenharmony_ci }, 5088c2ecf20Sopenharmony_ci [MT6797_MEMIF_MOD_DAI] = { 5098c2ecf20Sopenharmony_ci .name = "MOD_DAI", 5108c2ecf20Sopenharmony_ci .id = MT6797_MEMIF_MOD_DAI, 5118c2ecf20Sopenharmony_ci .reg_ofs_base = AFE_MOD_DAI_BASE, 5128c2ecf20Sopenharmony_ci .reg_ofs_cur = AFE_MOD_DAI_CUR, 5138c2ecf20Sopenharmony_ci .fs_reg = AFE_DAC_CON1, 5148c2ecf20Sopenharmony_ci .fs_shift = MOD_DAI_MODE_SFT, 5158c2ecf20Sopenharmony_ci .fs_maskbit = MOD_DAI_MODE_MASK, 5168c2ecf20Sopenharmony_ci .mono_reg = -1, 5178c2ecf20Sopenharmony_ci .mono_shift = 0, 5188c2ecf20Sopenharmony_ci .enable_reg = AFE_DAC_CON0, 5198c2ecf20Sopenharmony_ci .enable_shift = MOD_DAI_ON_SFT, 5208c2ecf20Sopenharmony_ci .hd_reg = AFE_MEMIF_HD_MODE, 5218c2ecf20Sopenharmony_ci .hd_shift = MOD_DAI_HD_SFT, 5228c2ecf20Sopenharmony_ci .agent_disable_reg = -1, 5238c2ecf20Sopenharmony_ci .msb_reg = -1, 5248c2ecf20Sopenharmony_ci }, 5258c2ecf20Sopenharmony_ci}; 5268c2ecf20Sopenharmony_ci 5278c2ecf20Sopenharmony_cistatic const struct mtk_base_irq_data irq_data[MT6797_IRQ_NUM] = { 5288c2ecf20Sopenharmony_ci [MT6797_IRQ_1] = { 5298c2ecf20Sopenharmony_ci .id = MT6797_IRQ_1, 5308c2ecf20Sopenharmony_ci .irq_cnt_reg = AFE_IRQ_MCU_CNT1, 5318c2ecf20Sopenharmony_ci .irq_cnt_shift = AFE_IRQ_MCU_CNT1_SFT, 5328c2ecf20Sopenharmony_ci .irq_cnt_maskbit = AFE_IRQ_MCU_CNT1_MASK, 5338c2ecf20Sopenharmony_ci .irq_fs_reg = AFE_IRQ_MCU_CON, 5348c2ecf20Sopenharmony_ci .irq_fs_shift = IRQ1_MCU_MODE_SFT, 5358c2ecf20Sopenharmony_ci .irq_fs_maskbit = IRQ1_MCU_MODE_MASK, 5368c2ecf20Sopenharmony_ci .irq_en_reg = AFE_IRQ_MCU_CON, 5378c2ecf20Sopenharmony_ci .irq_en_shift = IRQ1_MCU_ON_SFT, 5388c2ecf20Sopenharmony_ci .irq_clr_reg = AFE_IRQ_MCU_CLR, 5398c2ecf20Sopenharmony_ci .irq_clr_shift = IRQ1_MCU_CLR_SFT, 5408c2ecf20Sopenharmony_ci }, 5418c2ecf20Sopenharmony_ci [MT6797_IRQ_2] = { 5428c2ecf20Sopenharmony_ci .id = MT6797_IRQ_2, 5438c2ecf20Sopenharmony_ci .irq_cnt_reg = AFE_IRQ_MCU_CNT2, 5448c2ecf20Sopenharmony_ci .irq_cnt_shift = AFE_IRQ_MCU_CNT2_SFT, 5458c2ecf20Sopenharmony_ci .irq_cnt_maskbit = AFE_IRQ_MCU_CNT2_MASK, 5468c2ecf20Sopenharmony_ci .irq_fs_reg = AFE_IRQ_MCU_CON, 5478c2ecf20Sopenharmony_ci .irq_fs_shift = IRQ2_MCU_MODE_SFT, 5488c2ecf20Sopenharmony_ci .irq_fs_maskbit = IRQ2_MCU_MODE_MASK, 5498c2ecf20Sopenharmony_ci .irq_en_reg = AFE_IRQ_MCU_CON, 5508c2ecf20Sopenharmony_ci .irq_en_shift = IRQ2_MCU_ON_SFT, 5518c2ecf20Sopenharmony_ci .irq_clr_reg = AFE_IRQ_MCU_CLR, 5528c2ecf20Sopenharmony_ci .irq_clr_shift = IRQ2_MCU_CLR_SFT, 5538c2ecf20Sopenharmony_ci }, 5548c2ecf20Sopenharmony_ci [MT6797_IRQ_3] = { 5558c2ecf20Sopenharmony_ci .id = MT6797_IRQ_3, 5568c2ecf20Sopenharmony_ci .irq_cnt_reg = AFE_IRQ_MCU_CNT3, 5578c2ecf20Sopenharmony_ci .irq_cnt_shift = AFE_IRQ_MCU_CNT3_SFT, 5588c2ecf20Sopenharmony_ci .irq_cnt_maskbit = AFE_IRQ_MCU_CNT3_MASK, 5598c2ecf20Sopenharmony_ci .irq_fs_reg = AFE_IRQ_MCU_CON, 5608c2ecf20Sopenharmony_ci .irq_fs_shift = IRQ3_MCU_MODE_SFT, 5618c2ecf20Sopenharmony_ci .irq_fs_maskbit = IRQ3_MCU_MODE_MASK, 5628c2ecf20Sopenharmony_ci .irq_en_reg = AFE_IRQ_MCU_CON, 5638c2ecf20Sopenharmony_ci .irq_en_shift = IRQ3_MCU_ON_SFT, 5648c2ecf20Sopenharmony_ci .irq_clr_reg = AFE_IRQ_MCU_CLR, 5658c2ecf20Sopenharmony_ci .irq_clr_shift = IRQ3_MCU_CLR_SFT, 5668c2ecf20Sopenharmony_ci }, 5678c2ecf20Sopenharmony_ci [MT6797_IRQ_4] = { 5688c2ecf20Sopenharmony_ci .id = MT6797_IRQ_4, 5698c2ecf20Sopenharmony_ci .irq_cnt_reg = AFE_IRQ_MCU_CNT4, 5708c2ecf20Sopenharmony_ci .irq_cnt_shift = AFE_IRQ_MCU_CNT4_SFT, 5718c2ecf20Sopenharmony_ci .irq_cnt_maskbit = AFE_IRQ_MCU_CNT4_MASK, 5728c2ecf20Sopenharmony_ci .irq_fs_reg = AFE_IRQ_MCU_CON, 5738c2ecf20Sopenharmony_ci .irq_fs_shift = IRQ4_MCU_MODE_SFT, 5748c2ecf20Sopenharmony_ci .irq_fs_maskbit = IRQ4_MCU_MODE_MASK, 5758c2ecf20Sopenharmony_ci .irq_en_reg = AFE_IRQ_MCU_CON, 5768c2ecf20Sopenharmony_ci .irq_en_shift = IRQ4_MCU_ON_SFT, 5778c2ecf20Sopenharmony_ci .irq_clr_reg = AFE_IRQ_MCU_CLR, 5788c2ecf20Sopenharmony_ci .irq_clr_shift = IRQ4_MCU_CLR_SFT, 5798c2ecf20Sopenharmony_ci }, 5808c2ecf20Sopenharmony_ci [MT6797_IRQ_7] = { 5818c2ecf20Sopenharmony_ci .id = MT6797_IRQ_7, 5828c2ecf20Sopenharmony_ci .irq_cnt_reg = AFE_IRQ_MCU_CNT7, 5838c2ecf20Sopenharmony_ci .irq_cnt_shift = AFE_IRQ_MCU_CNT7_SFT, 5848c2ecf20Sopenharmony_ci .irq_cnt_maskbit = AFE_IRQ_MCU_CNT7_MASK, 5858c2ecf20Sopenharmony_ci .irq_fs_reg = AFE_IRQ_MCU_CON, 5868c2ecf20Sopenharmony_ci .irq_fs_shift = IRQ7_MCU_MODE_SFT, 5878c2ecf20Sopenharmony_ci .irq_fs_maskbit = IRQ7_MCU_MODE_MASK, 5888c2ecf20Sopenharmony_ci .irq_en_reg = AFE_IRQ_MCU_CON, 5898c2ecf20Sopenharmony_ci .irq_en_shift = IRQ7_MCU_ON_SFT, 5908c2ecf20Sopenharmony_ci .irq_clr_reg = AFE_IRQ_MCU_CLR, 5918c2ecf20Sopenharmony_ci .irq_clr_shift = IRQ7_MCU_CLR_SFT, 5928c2ecf20Sopenharmony_ci }, 5938c2ecf20Sopenharmony_ci}; 5948c2ecf20Sopenharmony_ci 5958c2ecf20Sopenharmony_cistatic const struct regmap_config mt6797_afe_regmap_config = { 5968c2ecf20Sopenharmony_ci .reg_bits = 32, 5978c2ecf20Sopenharmony_ci .reg_stride = 4, 5988c2ecf20Sopenharmony_ci .val_bits = 32, 5998c2ecf20Sopenharmony_ci .max_register = AFE_MAX_REGISTER, 6008c2ecf20Sopenharmony_ci}; 6018c2ecf20Sopenharmony_ci 6028c2ecf20Sopenharmony_cistatic irqreturn_t mt6797_afe_irq_handler(int irq_id, void *dev) 6038c2ecf20Sopenharmony_ci{ 6048c2ecf20Sopenharmony_ci struct mtk_base_afe *afe = dev; 6058c2ecf20Sopenharmony_ci struct mtk_base_afe_irq *irq; 6068c2ecf20Sopenharmony_ci unsigned int status; 6078c2ecf20Sopenharmony_ci unsigned int mcu_en; 6088c2ecf20Sopenharmony_ci int ret; 6098c2ecf20Sopenharmony_ci int i; 6108c2ecf20Sopenharmony_ci irqreturn_t irq_ret = IRQ_HANDLED; 6118c2ecf20Sopenharmony_ci 6128c2ecf20Sopenharmony_ci /* get irq that is sent to MCU */ 6138c2ecf20Sopenharmony_ci regmap_read(afe->regmap, AFE_IRQ_MCU_EN, &mcu_en); 6148c2ecf20Sopenharmony_ci 6158c2ecf20Sopenharmony_ci ret = regmap_read(afe->regmap, AFE_IRQ_MCU_STATUS, &status); 6168c2ecf20Sopenharmony_ci if (ret || (status & mcu_en) == 0) { 6178c2ecf20Sopenharmony_ci dev_err(afe->dev, "%s(), irq status err, ret %d, status 0x%x, mcu_en 0x%x\n", 6188c2ecf20Sopenharmony_ci __func__, ret, status, mcu_en); 6198c2ecf20Sopenharmony_ci 6208c2ecf20Sopenharmony_ci /* only clear IRQ which is sent to MCU */ 6218c2ecf20Sopenharmony_ci status = mcu_en & AFE_IRQ_STATUS_BITS; 6228c2ecf20Sopenharmony_ci 6238c2ecf20Sopenharmony_ci irq_ret = IRQ_NONE; 6248c2ecf20Sopenharmony_ci goto err_irq; 6258c2ecf20Sopenharmony_ci } 6268c2ecf20Sopenharmony_ci 6278c2ecf20Sopenharmony_ci for (i = 0; i < MT6797_MEMIF_NUM; i++) { 6288c2ecf20Sopenharmony_ci struct mtk_base_afe_memif *memif = &afe->memif[i]; 6298c2ecf20Sopenharmony_ci 6308c2ecf20Sopenharmony_ci if (!memif->substream) 6318c2ecf20Sopenharmony_ci continue; 6328c2ecf20Sopenharmony_ci 6338c2ecf20Sopenharmony_ci irq = &afe->irqs[memif->irq_usage]; 6348c2ecf20Sopenharmony_ci 6358c2ecf20Sopenharmony_ci if (status & (1 << irq->irq_data->irq_en_shift)) 6368c2ecf20Sopenharmony_ci snd_pcm_period_elapsed(memif->substream); 6378c2ecf20Sopenharmony_ci } 6388c2ecf20Sopenharmony_ci 6398c2ecf20Sopenharmony_cierr_irq: 6408c2ecf20Sopenharmony_ci /* clear irq */ 6418c2ecf20Sopenharmony_ci regmap_write(afe->regmap, 6428c2ecf20Sopenharmony_ci AFE_IRQ_MCU_CLR, 6438c2ecf20Sopenharmony_ci status & AFE_IRQ_STATUS_BITS); 6448c2ecf20Sopenharmony_ci 6458c2ecf20Sopenharmony_ci return irq_ret; 6468c2ecf20Sopenharmony_ci} 6478c2ecf20Sopenharmony_ci 6488c2ecf20Sopenharmony_cistatic int mt6797_afe_runtime_suspend(struct device *dev) 6498c2ecf20Sopenharmony_ci{ 6508c2ecf20Sopenharmony_ci struct mtk_base_afe *afe = dev_get_drvdata(dev); 6518c2ecf20Sopenharmony_ci unsigned int afe_on_retm; 6528c2ecf20Sopenharmony_ci int retry = 0; 6538c2ecf20Sopenharmony_ci 6548c2ecf20Sopenharmony_ci /* disable AFE */ 6558c2ecf20Sopenharmony_ci regmap_update_bits(afe->regmap, AFE_DAC_CON0, AFE_ON_MASK_SFT, 0x0); 6568c2ecf20Sopenharmony_ci do { 6578c2ecf20Sopenharmony_ci regmap_read(afe->regmap, AFE_DAC_CON0, &afe_on_retm); 6588c2ecf20Sopenharmony_ci if ((afe_on_retm & AFE_ON_RETM_MASK_SFT) == 0) 6598c2ecf20Sopenharmony_ci break; 6608c2ecf20Sopenharmony_ci 6618c2ecf20Sopenharmony_ci udelay(10); 6628c2ecf20Sopenharmony_ci } while (++retry < 100000); 6638c2ecf20Sopenharmony_ci 6648c2ecf20Sopenharmony_ci if (retry) 6658c2ecf20Sopenharmony_ci dev_warn(afe->dev, "%s(), retry %d\n", __func__, retry); 6668c2ecf20Sopenharmony_ci 6678c2ecf20Sopenharmony_ci /* make sure all irq status are cleared */ 6688c2ecf20Sopenharmony_ci regmap_update_bits(afe->regmap, AFE_IRQ_MCU_CLR, 0xffff, 0xffff); 6698c2ecf20Sopenharmony_ci 6708c2ecf20Sopenharmony_ci return mt6797_afe_disable_clock(afe); 6718c2ecf20Sopenharmony_ci} 6728c2ecf20Sopenharmony_ci 6738c2ecf20Sopenharmony_cistatic int mt6797_afe_runtime_resume(struct device *dev) 6748c2ecf20Sopenharmony_ci{ 6758c2ecf20Sopenharmony_ci struct mtk_base_afe *afe = dev_get_drvdata(dev); 6768c2ecf20Sopenharmony_ci int ret; 6778c2ecf20Sopenharmony_ci 6788c2ecf20Sopenharmony_ci ret = mt6797_afe_enable_clock(afe); 6798c2ecf20Sopenharmony_ci if (ret) 6808c2ecf20Sopenharmony_ci return ret; 6818c2ecf20Sopenharmony_ci 6828c2ecf20Sopenharmony_ci /* irq signal to mcu only */ 6838c2ecf20Sopenharmony_ci regmap_write(afe->regmap, AFE_IRQ_MCU_EN, AFE_IRQ_MCU_EN_MASK_SFT); 6848c2ecf20Sopenharmony_ci 6858c2ecf20Sopenharmony_ci /* force all memif use normal mode */ 6868c2ecf20Sopenharmony_ci regmap_update_bits(afe->regmap, AFE_MEMIF_HDALIGN, 6878c2ecf20Sopenharmony_ci 0x7ff << 16, 0x7ff << 16); 6888c2ecf20Sopenharmony_ci /* force cpu use normal mode when access sram data */ 6898c2ecf20Sopenharmony_ci regmap_update_bits(afe->regmap, AFE_MEMIF_MSB, 6908c2ecf20Sopenharmony_ci CPU_COMPACT_MODE_MASK_SFT, 0); 6918c2ecf20Sopenharmony_ci /* force cpu use 8_24 format when writing 32bit data */ 6928c2ecf20Sopenharmony_ci regmap_update_bits(afe->regmap, AFE_MEMIF_MSB, 6938c2ecf20Sopenharmony_ci CPU_HD_ALIGN_MASK_SFT, 0); 6948c2ecf20Sopenharmony_ci 6958c2ecf20Sopenharmony_ci /* set all output port to 24bit */ 6968c2ecf20Sopenharmony_ci regmap_update_bits(afe->regmap, AFE_CONN_24BIT, 6978c2ecf20Sopenharmony_ci 0x3fffffff, 0x3fffffff); 6988c2ecf20Sopenharmony_ci 6998c2ecf20Sopenharmony_ci /* enable AFE */ 7008c2ecf20Sopenharmony_ci regmap_update_bits(afe->regmap, AFE_DAC_CON0, 7018c2ecf20Sopenharmony_ci AFE_ON_MASK_SFT, 7028c2ecf20Sopenharmony_ci 0x1 << AFE_ON_SFT); 7038c2ecf20Sopenharmony_ci 7048c2ecf20Sopenharmony_ci return 0; 7058c2ecf20Sopenharmony_ci} 7068c2ecf20Sopenharmony_ci 7078c2ecf20Sopenharmony_cistatic int mt6797_afe_component_probe(struct snd_soc_component *component) 7088c2ecf20Sopenharmony_ci{ 7098c2ecf20Sopenharmony_ci return mtk_afe_add_sub_dai_control(component); 7108c2ecf20Sopenharmony_ci} 7118c2ecf20Sopenharmony_ci 7128c2ecf20Sopenharmony_cistatic const struct snd_soc_component_driver mt6797_afe_component = { 7138c2ecf20Sopenharmony_ci .name = AFE_PCM_NAME, 7148c2ecf20Sopenharmony_ci .probe = mt6797_afe_component_probe, 7158c2ecf20Sopenharmony_ci .pointer = mtk_afe_pcm_pointer, 7168c2ecf20Sopenharmony_ci .pcm_construct = mtk_afe_pcm_new, 7178c2ecf20Sopenharmony_ci}; 7188c2ecf20Sopenharmony_ci 7198c2ecf20Sopenharmony_cistatic int mt6797_dai_memif_register(struct mtk_base_afe *afe) 7208c2ecf20Sopenharmony_ci{ 7218c2ecf20Sopenharmony_ci struct mtk_base_afe_dai *dai; 7228c2ecf20Sopenharmony_ci 7238c2ecf20Sopenharmony_ci dai = devm_kzalloc(afe->dev, sizeof(*dai), GFP_KERNEL); 7248c2ecf20Sopenharmony_ci if (!dai) 7258c2ecf20Sopenharmony_ci return -ENOMEM; 7268c2ecf20Sopenharmony_ci 7278c2ecf20Sopenharmony_ci list_add(&dai->list, &afe->sub_dais); 7288c2ecf20Sopenharmony_ci 7298c2ecf20Sopenharmony_ci dai->dai_drivers = mt6797_memif_dai_driver; 7308c2ecf20Sopenharmony_ci dai->num_dai_drivers = ARRAY_SIZE(mt6797_memif_dai_driver); 7318c2ecf20Sopenharmony_ci 7328c2ecf20Sopenharmony_ci dai->dapm_widgets = mt6797_memif_widgets; 7338c2ecf20Sopenharmony_ci dai->num_dapm_widgets = ARRAY_SIZE(mt6797_memif_widgets); 7348c2ecf20Sopenharmony_ci dai->dapm_routes = mt6797_memif_routes; 7358c2ecf20Sopenharmony_ci dai->num_dapm_routes = ARRAY_SIZE(mt6797_memif_routes); 7368c2ecf20Sopenharmony_ci return 0; 7378c2ecf20Sopenharmony_ci} 7388c2ecf20Sopenharmony_ci 7398c2ecf20Sopenharmony_citypedef int (*dai_register_cb)(struct mtk_base_afe *); 7408c2ecf20Sopenharmony_cistatic const dai_register_cb dai_register_cbs[] = { 7418c2ecf20Sopenharmony_ci mt6797_dai_adda_register, 7428c2ecf20Sopenharmony_ci mt6797_dai_pcm_register, 7438c2ecf20Sopenharmony_ci mt6797_dai_hostless_register, 7448c2ecf20Sopenharmony_ci mt6797_dai_memif_register, 7458c2ecf20Sopenharmony_ci}; 7468c2ecf20Sopenharmony_ci 7478c2ecf20Sopenharmony_cistatic int mt6797_afe_pcm_dev_probe(struct platform_device *pdev) 7488c2ecf20Sopenharmony_ci{ 7498c2ecf20Sopenharmony_ci struct mtk_base_afe *afe; 7508c2ecf20Sopenharmony_ci struct mt6797_afe_private *afe_priv; 7518c2ecf20Sopenharmony_ci struct device *dev; 7528c2ecf20Sopenharmony_ci int i, irq_id, ret; 7538c2ecf20Sopenharmony_ci 7548c2ecf20Sopenharmony_ci afe = devm_kzalloc(&pdev->dev, sizeof(*afe), GFP_KERNEL); 7558c2ecf20Sopenharmony_ci if (!afe) 7568c2ecf20Sopenharmony_ci return -ENOMEM; 7578c2ecf20Sopenharmony_ci 7588c2ecf20Sopenharmony_ci afe->platform_priv = devm_kzalloc(&pdev->dev, sizeof(*afe_priv), 7598c2ecf20Sopenharmony_ci GFP_KERNEL); 7608c2ecf20Sopenharmony_ci if (!afe->platform_priv) 7618c2ecf20Sopenharmony_ci return -ENOMEM; 7628c2ecf20Sopenharmony_ci 7638c2ecf20Sopenharmony_ci afe_priv = afe->platform_priv; 7648c2ecf20Sopenharmony_ci afe->dev = &pdev->dev; 7658c2ecf20Sopenharmony_ci dev = afe->dev; 7668c2ecf20Sopenharmony_ci 7678c2ecf20Sopenharmony_ci /* initial audio related clock */ 7688c2ecf20Sopenharmony_ci ret = mt6797_init_clock(afe); 7698c2ecf20Sopenharmony_ci if (ret) { 7708c2ecf20Sopenharmony_ci dev_err(dev, "init clock error\n"); 7718c2ecf20Sopenharmony_ci return ret; 7728c2ecf20Sopenharmony_ci } 7738c2ecf20Sopenharmony_ci 7748c2ecf20Sopenharmony_ci /* regmap init */ 7758c2ecf20Sopenharmony_ci afe->base_addr = devm_platform_ioremap_resource(pdev, 0); 7768c2ecf20Sopenharmony_ci if (IS_ERR(afe->base_addr)) 7778c2ecf20Sopenharmony_ci return PTR_ERR(afe->base_addr); 7788c2ecf20Sopenharmony_ci 7798c2ecf20Sopenharmony_ci afe->regmap = devm_regmap_init_mmio(&pdev->dev, afe->base_addr, 7808c2ecf20Sopenharmony_ci &mt6797_afe_regmap_config); 7818c2ecf20Sopenharmony_ci if (IS_ERR(afe->regmap)) 7828c2ecf20Sopenharmony_ci return PTR_ERR(afe->regmap); 7838c2ecf20Sopenharmony_ci 7848c2ecf20Sopenharmony_ci /* init memif */ 7858c2ecf20Sopenharmony_ci afe->memif_size = MT6797_MEMIF_NUM; 7868c2ecf20Sopenharmony_ci afe->memif = devm_kcalloc(dev, afe->memif_size, sizeof(*afe->memif), 7878c2ecf20Sopenharmony_ci GFP_KERNEL); 7888c2ecf20Sopenharmony_ci if (!afe->memif) 7898c2ecf20Sopenharmony_ci return -ENOMEM; 7908c2ecf20Sopenharmony_ci 7918c2ecf20Sopenharmony_ci for (i = 0; i < afe->memif_size; i++) { 7928c2ecf20Sopenharmony_ci afe->memif[i].data = &memif_data[i]; 7938c2ecf20Sopenharmony_ci afe->memif[i].irq_usage = -1; 7948c2ecf20Sopenharmony_ci } 7958c2ecf20Sopenharmony_ci 7968c2ecf20Sopenharmony_ci mutex_init(&afe->irq_alloc_lock); 7978c2ecf20Sopenharmony_ci 7988c2ecf20Sopenharmony_ci /* irq initialize */ 7998c2ecf20Sopenharmony_ci afe->irqs_size = MT6797_IRQ_NUM; 8008c2ecf20Sopenharmony_ci afe->irqs = devm_kcalloc(dev, afe->irqs_size, sizeof(*afe->irqs), 8018c2ecf20Sopenharmony_ci GFP_KERNEL); 8028c2ecf20Sopenharmony_ci if (!afe->irqs) 8038c2ecf20Sopenharmony_ci return -ENOMEM; 8048c2ecf20Sopenharmony_ci 8058c2ecf20Sopenharmony_ci for (i = 0; i < afe->irqs_size; i++) 8068c2ecf20Sopenharmony_ci afe->irqs[i].irq_data = &irq_data[i]; 8078c2ecf20Sopenharmony_ci 8088c2ecf20Sopenharmony_ci /* request irq */ 8098c2ecf20Sopenharmony_ci irq_id = platform_get_irq(pdev, 0); 8108c2ecf20Sopenharmony_ci if (irq_id < 0) 8118c2ecf20Sopenharmony_ci return irq_id; 8128c2ecf20Sopenharmony_ci 8138c2ecf20Sopenharmony_ci ret = devm_request_irq(dev, irq_id, mt6797_afe_irq_handler, 8148c2ecf20Sopenharmony_ci IRQF_TRIGGER_NONE, "asys-isr", (void *)afe); 8158c2ecf20Sopenharmony_ci if (ret) { 8168c2ecf20Sopenharmony_ci dev_err(dev, "could not request_irq for asys-isr\n"); 8178c2ecf20Sopenharmony_ci return ret; 8188c2ecf20Sopenharmony_ci } 8198c2ecf20Sopenharmony_ci 8208c2ecf20Sopenharmony_ci /* init sub_dais */ 8218c2ecf20Sopenharmony_ci INIT_LIST_HEAD(&afe->sub_dais); 8228c2ecf20Sopenharmony_ci 8238c2ecf20Sopenharmony_ci for (i = 0; i < ARRAY_SIZE(dai_register_cbs); i++) { 8248c2ecf20Sopenharmony_ci ret = dai_register_cbs[i](afe); 8258c2ecf20Sopenharmony_ci if (ret) { 8268c2ecf20Sopenharmony_ci dev_warn(afe->dev, "dai register i %d fail, ret %d\n", 8278c2ecf20Sopenharmony_ci i, ret); 8288c2ecf20Sopenharmony_ci return ret; 8298c2ecf20Sopenharmony_ci } 8308c2ecf20Sopenharmony_ci } 8318c2ecf20Sopenharmony_ci 8328c2ecf20Sopenharmony_ci /* init dai_driver and component_driver */ 8338c2ecf20Sopenharmony_ci ret = mtk_afe_combine_sub_dai(afe); 8348c2ecf20Sopenharmony_ci if (ret) { 8358c2ecf20Sopenharmony_ci dev_warn(afe->dev, "mtk_afe_combine_sub_dai fail, ret %d\n", 8368c2ecf20Sopenharmony_ci ret); 8378c2ecf20Sopenharmony_ci return ret; 8388c2ecf20Sopenharmony_ci } 8398c2ecf20Sopenharmony_ci 8408c2ecf20Sopenharmony_ci afe->mtk_afe_hardware = &mt6797_afe_hardware; 8418c2ecf20Sopenharmony_ci afe->memif_fs = mt6797_memif_fs; 8428c2ecf20Sopenharmony_ci afe->irq_fs = mt6797_irq_fs; 8438c2ecf20Sopenharmony_ci 8448c2ecf20Sopenharmony_ci afe->runtime_resume = mt6797_afe_runtime_resume; 8458c2ecf20Sopenharmony_ci afe->runtime_suspend = mt6797_afe_runtime_suspend; 8468c2ecf20Sopenharmony_ci 8478c2ecf20Sopenharmony_ci platform_set_drvdata(pdev, afe); 8488c2ecf20Sopenharmony_ci 8498c2ecf20Sopenharmony_ci pm_runtime_enable(dev); 8508c2ecf20Sopenharmony_ci if (!pm_runtime_enabled(dev)) 8518c2ecf20Sopenharmony_ci goto err_pm_disable; 8528c2ecf20Sopenharmony_ci pm_runtime_get_sync(&pdev->dev); 8538c2ecf20Sopenharmony_ci 8548c2ecf20Sopenharmony_ci /* register component */ 8558c2ecf20Sopenharmony_ci ret = devm_snd_soc_register_component(dev, &mt6797_afe_component, 8568c2ecf20Sopenharmony_ci NULL, 0); 8578c2ecf20Sopenharmony_ci if (ret) { 8588c2ecf20Sopenharmony_ci dev_warn(dev, "err_platform\n"); 8598c2ecf20Sopenharmony_ci goto err_pm_disable; 8608c2ecf20Sopenharmony_ci } 8618c2ecf20Sopenharmony_ci 8628c2ecf20Sopenharmony_ci ret = devm_snd_soc_register_component(afe->dev, 8638c2ecf20Sopenharmony_ci &mt6797_afe_pcm_dai_component, 8648c2ecf20Sopenharmony_ci afe->dai_drivers, 8658c2ecf20Sopenharmony_ci afe->num_dai_drivers); 8668c2ecf20Sopenharmony_ci if (ret) { 8678c2ecf20Sopenharmony_ci dev_warn(dev, "err_dai_component\n"); 8688c2ecf20Sopenharmony_ci goto err_pm_disable; 8698c2ecf20Sopenharmony_ci } 8708c2ecf20Sopenharmony_ci 8718c2ecf20Sopenharmony_ci return 0; 8728c2ecf20Sopenharmony_ci 8738c2ecf20Sopenharmony_cierr_pm_disable: 8748c2ecf20Sopenharmony_ci pm_runtime_disable(dev); 8758c2ecf20Sopenharmony_ci 8768c2ecf20Sopenharmony_ci return ret; 8778c2ecf20Sopenharmony_ci} 8788c2ecf20Sopenharmony_ci 8798c2ecf20Sopenharmony_cistatic int mt6797_afe_pcm_dev_remove(struct platform_device *pdev) 8808c2ecf20Sopenharmony_ci{ 8818c2ecf20Sopenharmony_ci pm_runtime_disable(&pdev->dev); 8828c2ecf20Sopenharmony_ci if (!pm_runtime_status_suspended(&pdev->dev)) 8838c2ecf20Sopenharmony_ci mt6797_afe_runtime_suspend(&pdev->dev); 8848c2ecf20Sopenharmony_ci pm_runtime_put_sync(&pdev->dev); 8858c2ecf20Sopenharmony_ci 8868c2ecf20Sopenharmony_ci return 0; 8878c2ecf20Sopenharmony_ci} 8888c2ecf20Sopenharmony_ci 8898c2ecf20Sopenharmony_cistatic const struct of_device_id mt6797_afe_pcm_dt_match[] = { 8908c2ecf20Sopenharmony_ci { .compatible = "mediatek,mt6797-audio", }, 8918c2ecf20Sopenharmony_ci {}, 8928c2ecf20Sopenharmony_ci}; 8938c2ecf20Sopenharmony_ciMODULE_DEVICE_TABLE(of, mt6797_afe_pcm_dt_match); 8948c2ecf20Sopenharmony_ci 8958c2ecf20Sopenharmony_cistatic const struct dev_pm_ops mt6797_afe_pm_ops = { 8968c2ecf20Sopenharmony_ci SET_RUNTIME_PM_OPS(mt6797_afe_runtime_suspend, 8978c2ecf20Sopenharmony_ci mt6797_afe_runtime_resume, NULL) 8988c2ecf20Sopenharmony_ci}; 8998c2ecf20Sopenharmony_ci 9008c2ecf20Sopenharmony_cistatic struct platform_driver mt6797_afe_pcm_driver = { 9018c2ecf20Sopenharmony_ci .driver = { 9028c2ecf20Sopenharmony_ci .name = "mt6797-audio", 9038c2ecf20Sopenharmony_ci .of_match_table = mt6797_afe_pcm_dt_match, 9048c2ecf20Sopenharmony_ci#ifdef CONFIG_PM 9058c2ecf20Sopenharmony_ci .pm = &mt6797_afe_pm_ops, 9068c2ecf20Sopenharmony_ci#endif 9078c2ecf20Sopenharmony_ci }, 9088c2ecf20Sopenharmony_ci .probe = mt6797_afe_pcm_dev_probe, 9098c2ecf20Sopenharmony_ci .remove = mt6797_afe_pcm_dev_remove, 9108c2ecf20Sopenharmony_ci}; 9118c2ecf20Sopenharmony_ci 9128c2ecf20Sopenharmony_cimodule_platform_driver(mt6797_afe_pcm_driver); 9138c2ecf20Sopenharmony_ci 9148c2ecf20Sopenharmony_ciMODULE_DESCRIPTION("Mediatek ALSA SoC AFE platform driver for 6797"); 9158c2ecf20Sopenharmony_ciMODULE_AUTHOR("KaiChieh Chuang <kaichieh.chuang@mediatek.com>"); 9168c2ecf20Sopenharmony_ciMODULE_LICENSE("GPL v2"); 917