18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0 28c2ecf20Sopenharmony_ci// 38c2ecf20Sopenharmony_ci// Mediatek ALSA SoC AFE platform driver for 8183 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#include <linux/reset.h> 158c2ecf20Sopenharmony_ci 168c2ecf20Sopenharmony_ci#include "mt8183-afe-common.h" 178c2ecf20Sopenharmony_ci#include "mt8183-afe-clk.h" 188c2ecf20Sopenharmony_ci#include "mt8183-interconnection.h" 198c2ecf20Sopenharmony_ci#include "mt8183-reg.h" 208c2ecf20Sopenharmony_ci#include "../common/mtk-afe-platform-driver.h" 218c2ecf20Sopenharmony_ci#include "../common/mtk-afe-fe-dai.h" 228c2ecf20Sopenharmony_ci 238c2ecf20Sopenharmony_cienum { 248c2ecf20Sopenharmony_ci MTK_AFE_RATE_8K = 0, 258c2ecf20Sopenharmony_ci MTK_AFE_RATE_11K = 1, 268c2ecf20Sopenharmony_ci MTK_AFE_RATE_12K = 2, 278c2ecf20Sopenharmony_ci MTK_AFE_RATE_384K = 3, 288c2ecf20Sopenharmony_ci MTK_AFE_RATE_16K = 4, 298c2ecf20Sopenharmony_ci MTK_AFE_RATE_22K = 5, 308c2ecf20Sopenharmony_ci MTK_AFE_RATE_24K = 6, 318c2ecf20Sopenharmony_ci MTK_AFE_RATE_130K = 7, 328c2ecf20Sopenharmony_ci MTK_AFE_RATE_32K = 8, 338c2ecf20Sopenharmony_ci MTK_AFE_RATE_44K = 9, 348c2ecf20Sopenharmony_ci MTK_AFE_RATE_48K = 10, 358c2ecf20Sopenharmony_ci MTK_AFE_RATE_88K = 11, 368c2ecf20Sopenharmony_ci MTK_AFE_RATE_96K = 12, 378c2ecf20Sopenharmony_ci MTK_AFE_RATE_176K = 13, 388c2ecf20Sopenharmony_ci MTK_AFE_RATE_192K = 14, 398c2ecf20Sopenharmony_ci MTK_AFE_RATE_260K = 15, 408c2ecf20Sopenharmony_ci}; 418c2ecf20Sopenharmony_ci 428c2ecf20Sopenharmony_cienum { 438c2ecf20Sopenharmony_ci MTK_AFE_DAI_MEMIF_RATE_8K = 0, 448c2ecf20Sopenharmony_ci MTK_AFE_DAI_MEMIF_RATE_16K = 1, 458c2ecf20Sopenharmony_ci MTK_AFE_DAI_MEMIF_RATE_32K = 2, 468c2ecf20Sopenharmony_ci MTK_AFE_DAI_MEMIF_RATE_48K = 3, 478c2ecf20Sopenharmony_ci}; 488c2ecf20Sopenharmony_ci 498c2ecf20Sopenharmony_cienum { 508c2ecf20Sopenharmony_ci MTK_AFE_PCM_RATE_8K = 0, 518c2ecf20Sopenharmony_ci MTK_AFE_PCM_RATE_16K = 1, 528c2ecf20Sopenharmony_ci MTK_AFE_PCM_RATE_32K = 2, 538c2ecf20Sopenharmony_ci MTK_AFE_PCM_RATE_48K = 3, 548c2ecf20Sopenharmony_ci}; 558c2ecf20Sopenharmony_ci 568c2ecf20Sopenharmony_ciunsigned int mt8183_general_rate_transform(struct device *dev, 578c2ecf20Sopenharmony_ci unsigned int rate) 588c2ecf20Sopenharmony_ci{ 598c2ecf20Sopenharmony_ci switch (rate) { 608c2ecf20Sopenharmony_ci case 8000: 618c2ecf20Sopenharmony_ci return MTK_AFE_RATE_8K; 628c2ecf20Sopenharmony_ci case 11025: 638c2ecf20Sopenharmony_ci return MTK_AFE_RATE_11K; 648c2ecf20Sopenharmony_ci case 12000: 658c2ecf20Sopenharmony_ci return MTK_AFE_RATE_12K; 668c2ecf20Sopenharmony_ci case 16000: 678c2ecf20Sopenharmony_ci return MTK_AFE_RATE_16K; 688c2ecf20Sopenharmony_ci case 22050: 698c2ecf20Sopenharmony_ci return MTK_AFE_RATE_22K; 708c2ecf20Sopenharmony_ci case 24000: 718c2ecf20Sopenharmony_ci return MTK_AFE_RATE_24K; 728c2ecf20Sopenharmony_ci case 32000: 738c2ecf20Sopenharmony_ci return MTK_AFE_RATE_32K; 748c2ecf20Sopenharmony_ci case 44100: 758c2ecf20Sopenharmony_ci return MTK_AFE_RATE_44K; 768c2ecf20Sopenharmony_ci case 48000: 778c2ecf20Sopenharmony_ci return MTK_AFE_RATE_48K; 788c2ecf20Sopenharmony_ci case 88200: 798c2ecf20Sopenharmony_ci return MTK_AFE_RATE_88K; 808c2ecf20Sopenharmony_ci case 96000: 818c2ecf20Sopenharmony_ci return MTK_AFE_RATE_96K; 828c2ecf20Sopenharmony_ci case 130000: 838c2ecf20Sopenharmony_ci return MTK_AFE_RATE_130K; 848c2ecf20Sopenharmony_ci case 176400: 858c2ecf20Sopenharmony_ci return MTK_AFE_RATE_176K; 868c2ecf20Sopenharmony_ci case 192000: 878c2ecf20Sopenharmony_ci return MTK_AFE_RATE_192K; 888c2ecf20Sopenharmony_ci case 260000: 898c2ecf20Sopenharmony_ci return MTK_AFE_RATE_260K; 908c2ecf20Sopenharmony_ci default: 918c2ecf20Sopenharmony_ci dev_warn(dev, "%s(), rate %u invalid, use %d!!!\n", 928c2ecf20Sopenharmony_ci __func__, rate, MTK_AFE_RATE_48K); 938c2ecf20Sopenharmony_ci return MTK_AFE_RATE_48K; 948c2ecf20Sopenharmony_ci } 958c2ecf20Sopenharmony_ci} 968c2ecf20Sopenharmony_ci 978c2ecf20Sopenharmony_cistatic unsigned int dai_memif_rate_transform(struct device *dev, 988c2ecf20Sopenharmony_ci unsigned int rate) 998c2ecf20Sopenharmony_ci{ 1008c2ecf20Sopenharmony_ci switch (rate) { 1018c2ecf20Sopenharmony_ci case 8000: 1028c2ecf20Sopenharmony_ci return MTK_AFE_DAI_MEMIF_RATE_8K; 1038c2ecf20Sopenharmony_ci case 16000: 1048c2ecf20Sopenharmony_ci return MTK_AFE_DAI_MEMIF_RATE_16K; 1058c2ecf20Sopenharmony_ci case 32000: 1068c2ecf20Sopenharmony_ci return MTK_AFE_DAI_MEMIF_RATE_32K; 1078c2ecf20Sopenharmony_ci case 48000: 1088c2ecf20Sopenharmony_ci return MTK_AFE_DAI_MEMIF_RATE_48K; 1098c2ecf20Sopenharmony_ci default: 1108c2ecf20Sopenharmony_ci dev_warn(dev, "%s(), rate %u invalid, use %d!!!\n", 1118c2ecf20Sopenharmony_ci __func__, rate, MTK_AFE_DAI_MEMIF_RATE_16K); 1128c2ecf20Sopenharmony_ci return MTK_AFE_DAI_MEMIF_RATE_16K; 1138c2ecf20Sopenharmony_ci } 1148c2ecf20Sopenharmony_ci} 1158c2ecf20Sopenharmony_ci 1168c2ecf20Sopenharmony_ciunsigned int mt8183_rate_transform(struct device *dev, 1178c2ecf20Sopenharmony_ci unsigned int rate, int aud_blk) 1188c2ecf20Sopenharmony_ci{ 1198c2ecf20Sopenharmony_ci switch (aud_blk) { 1208c2ecf20Sopenharmony_ci case MT8183_MEMIF_MOD_DAI: 1218c2ecf20Sopenharmony_ci return dai_memif_rate_transform(dev, rate); 1228c2ecf20Sopenharmony_ci default: 1238c2ecf20Sopenharmony_ci return mt8183_general_rate_transform(dev, rate); 1248c2ecf20Sopenharmony_ci } 1258c2ecf20Sopenharmony_ci} 1268c2ecf20Sopenharmony_ci 1278c2ecf20Sopenharmony_cistatic const struct snd_pcm_hardware mt8183_afe_hardware = { 1288c2ecf20Sopenharmony_ci .info = SNDRV_PCM_INFO_MMAP | 1298c2ecf20Sopenharmony_ci SNDRV_PCM_INFO_INTERLEAVED | 1308c2ecf20Sopenharmony_ci SNDRV_PCM_INFO_MMAP_VALID, 1318c2ecf20Sopenharmony_ci .formats = SNDRV_PCM_FMTBIT_S16_LE | 1328c2ecf20Sopenharmony_ci SNDRV_PCM_FMTBIT_S24_LE | 1338c2ecf20Sopenharmony_ci SNDRV_PCM_FMTBIT_S32_LE, 1348c2ecf20Sopenharmony_ci .period_bytes_min = 256, 1358c2ecf20Sopenharmony_ci .period_bytes_max = 4 * 48 * 1024, 1368c2ecf20Sopenharmony_ci .periods_min = 2, 1378c2ecf20Sopenharmony_ci .periods_max = 256, 1388c2ecf20Sopenharmony_ci .buffer_bytes_max = 8 * 48 * 1024, 1398c2ecf20Sopenharmony_ci .fifo_size = 0, 1408c2ecf20Sopenharmony_ci}; 1418c2ecf20Sopenharmony_ci 1428c2ecf20Sopenharmony_cistatic int mt8183_memif_fs(struct snd_pcm_substream *substream, 1438c2ecf20Sopenharmony_ci unsigned int rate) 1448c2ecf20Sopenharmony_ci{ 1458c2ecf20Sopenharmony_ci struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); 1468c2ecf20Sopenharmony_ci struct snd_soc_component *component = 1478c2ecf20Sopenharmony_ci snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME); 1488c2ecf20Sopenharmony_ci struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component); 1498c2ecf20Sopenharmony_ci int id = asoc_rtd_to_cpu(rtd, 0)->id; 1508c2ecf20Sopenharmony_ci 1518c2ecf20Sopenharmony_ci return mt8183_rate_transform(afe->dev, rate, id); 1528c2ecf20Sopenharmony_ci} 1538c2ecf20Sopenharmony_ci 1548c2ecf20Sopenharmony_cistatic int mt8183_irq_fs(struct snd_pcm_substream *substream, unsigned int rate) 1558c2ecf20Sopenharmony_ci{ 1568c2ecf20Sopenharmony_ci struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); 1578c2ecf20Sopenharmony_ci struct snd_soc_component *component = 1588c2ecf20Sopenharmony_ci snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME); 1598c2ecf20Sopenharmony_ci struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component); 1608c2ecf20Sopenharmony_ci 1618c2ecf20Sopenharmony_ci return mt8183_general_rate_transform(afe->dev, rate); 1628c2ecf20Sopenharmony_ci} 1638c2ecf20Sopenharmony_ci 1648c2ecf20Sopenharmony_ci#define MTK_PCM_RATES (SNDRV_PCM_RATE_8000_48000 |\ 1658c2ecf20Sopenharmony_ci SNDRV_PCM_RATE_88200 |\ 1668c2ecf20Sopenharmony_ci SNDRV_PCM_RATE_96000 |\ 1678c2ecf20Sopenharmony_ci SNDRV_PCM_RATE_176400 |\ 1688c2ecf20Sopenharmony_ci SNDRV_PCM_RATE_192000) 1698c2ecf20Sopenharmony_ci 1708c2ecf20Sopenharmony_ci#define MTK_PCM_DAI_RATES (SNDRV_PCM_RATE_8000 |\ 1718c2ecf20Sopenharmony_ci SNDRV_PCM_RATE_16000 |\ 1728c2ecf20Sopenharmony_ci SNDRV_PCM_RATE_32000 |\ 1738c2ecf20Sopenharmony_ci SNDRV_PCM_RATE_48000) 1748c2ecf20Sopenharmony_ci 1758c2ecf20Sopenharmony_ci#define MTK_PCM_FORMATS (SNDRV_PCM_FMTBIT_S16_LE |\ 1768c2ecf20Sopenharmony_ci SNDRV_PCM_FMTBIT_S24_LE |\ 1778c2ecf20Sopenharmony_ci SNDRV_PCM_FMTBIT_S32_LE) 1788c2ecf20Sopenharmony_ci 1798c2ecf20Sopenharmony_cistatic struct snd_soc_dai_driver mt8183_memif_dai_driver[] = { 1808c2ecf20Sopenharmony_ci /* FE DAIs: memory intefaces to CPU */ 1818c2ecf20Sopenharmony_ci { 1828c2ecf20Sopenharmony_ci .name = "DL1", 1838c2ecf20Sopenharmony_ci .id = MT8183_MEMIF_DL1, 1848c2ecf20Sopenharmony_ci .playback = { 1858c2ecf20Sopenharmony_ci .stream_name = "DL1", 1868c2ecf20Sopenharmony_ci .channels_min = 1, 1878c2ecf20Sopenharmony_ci .channels_max = 2, 1888c2ecf20Sopenharmony_ci .rates = MTK_PCM_RATES, 1898c2ecf20Sopenharmony_ci .formats = MTK_PCM_FORMATS, 1908c2ecf20Sopenharmony_ci }, 1918c2ecf20Sopenharmony_ci .ops = &mtk_afe_fe_ops, 1928c2ecf20Sopenharmony_ci }, 1938c2ecf20Sopenharmony_ci { 1948c2ecf20Sopenharmony_ci .name = "DL2", 1958c2ecf20Sopenharmony_ci .id = MT8183_MEMIF_DL2, 1968c2ecf20Sopenharmony_ci .playback = { 1978c2ecf20Sopenharmony_ci .stream_name = "DL2", 1988c2ecf20Sopenharmony_ci .channels_min = 1, 1998c2ecf20Sopenharmony_ci .channels_max = 2, 2008c2ecf20Sopenharmony_ci .rates = MTK_PCM_RATES, 2018c2ecf20Sopenharmony_ci .formats = MTK_PCM_FORMATS, 2028c2ecf20Sopenharmony_ci }, 2038c2ecf20Sopenharmony_ci .ops = &mtk_afe_fe_ops, 2048c2ecf20Sopenharmony_ci }, 2058c2ecf20Sopenharmony_ci { 2068c2ecf20Sopenharmony_ci .name = "DL3", 2078c2ecf20Sopenharmony_ci .id = MT8183_MEMIF_DL3, 2088c2ecf20Sopenharmony_ci .playback = { 2098c2ecf20Sopenharmony_ci .stream_name = "DL3", 2108c2ecf20Sopenharmony_ci .channels_min = 1, 2118c2ecf20Sopenharmony_ci .channels_max = 2, 2128c2ecf20Sopenharmony_ci .rates = MTK_PCM_RATES, 2138c2ecf20Sopenharmony_ci .formats = MTK_PCM_FORMATS, 2148c2ecf20Sopenharmony_ci }, 2158c2ecf20Sopenharmony_ci .ops = &mtk_afe_fe_ops, 2168c2ecf20Sopenharmony_ci }, 2178c2ecf20Sopenharmony_ci { 2188c2ecf20Sopenharmony_ci .name = "UL1", 2198c2ecf20Sopenharmony_ci .id = MT8183_MEMIF_VUL12, 2208c2ecf20Sopenharmony_ci .capture = { 2218c2ecf20Sopenharmony_ci .stream_name = "UL1", 2228c2ecf20Sopenharmony_ci .channels_min = 1, 2238c2ecf20Sopenharmony_ci .channels_max = 2, 2248c2ecf20Sopenharmony_ci .rates = MTK_PCM_RATES, 2258c2ecf20Sopenharmony_ci .formats = MTK_PCM_FORMATS, 2268c2ecf20Sopenharmony_ci }, 2278c2ecf20Sopenharmony_ci .ops = &mtk_afe_fe_ops, 2288c2ecf20Sopenharmony_ci }, 2298c2ecf20Sopenharmony_ci { 2308c2ecf20Sopenharmony_ci .name = "UL2", 2318c2ecf20Sopenharmony_ci .id = MT8183_MEMIF_AWB, 2328c2ecf20Sopenharmony_ci .capture = { 2338c2ecf20Sopenharmony_ci .stream_name = "UL2", 2348c2ecf20Sopenharmony_ci .channels_min = 1, 2358c2ecf20Sopenharmony_ci .channels_max = 2, 2368c2ecf20Sopenharmony_ci .rates = MTK_PCM_RATES, 2378c2ecf20Sopenharmony_ci .formats = MTK_PCM_FORMATS, 2388c2ecf20Sopenharmony_ci }, 2398c2ecf20Sopenharmony_ci .ops = &mtk_afe_fe_ops, 2408c2ecf20Sopenharmony_ci }, 2418c2ecf20Sopenharmony_ci { 2428c2ecf20Sopenharmony_ci .name = "UL3", 2438c2ecf20Sopenharmony_ci .id = MT8183_MEMIF_VUL2, 2448c2ecf20Sopenharmony_ci .capture = { 2458c2ecf20Sopenharmony_ci .stream_name = "UL3", 2468c2ecf20Sopenharmony_ci .channels_min = 1, 2478c2ecf20Sopenharmony_ci .channels_max = 2, 2488c2ecf20Sopenharmony_ci .rates = MTK_PCM_RATES, 2498c2ecf20Sopenharmony_ci .formats = MTK_PCM_FORMATS, 2508c2ecf20Sopenharmony_ci }, 2518c2ecf20Sopenharmony_ci .ops = &mtk_afe_fe_ops, 2528c2ecf20Sopenharmony_ci }, 2538c2ecf20Sopenharmony_ci { 2548c2ecf20Sopenharmony_ci .name = "UL4", 2558c2ecf20Sopenharmony_ci .id = MT8183_MEMIF_AWB2, 2568c2ecf20Sopenharmony_ci .capture = { 2578c2ecf20Sopenharmony_ci .stream_name = "UL4", 2588c2ecf20Sopenharmony_ci .channels_min = 1, 2598c2ecf20Sopenharmony_ci .channels_max = 2, 2608c2ecf20Sopenharmony_ci .rates = MTK_PCM_RATES, 2618c2ecf20Sopenharmony_ci .formats = MTK_PCM_FORMATS, 2628c2ecf20Sopenharmony_ci }, 2638c2ecf20Sopenharmony_ci .ops = &mtk_afe_fe_ops, 2648c2ecf20Sopenharmony_ci }, 2658c2ecf20Sopenharmony_ci { 2668c2ecf20Sopenharmony_ci .name = "UL_MONO_1", 2678c2ecf20Sopenharmony_ci .id = MT8183_MEMIF_MOD_DAI, 2688c2ecf20Sopenharmony_ci .capture = { 2698c2ecf20Sopenharmony_ci .stream_name = "UL_MONO_1", 2708c2ecf20Sopenharmony_ci .channels_min = 1, 2718c2ecf20Sopenharmony_ci .channels_max = 1, 2728c2ecf20Sopenharmony_ci .rates = MTK_PCM_DAI_RATES, 2738c2ecf20Sopenharmony_ci .formats = MTK_PCM_FORMATS, 2748c2ecf20Sopenharmony_ci }, 2758c2ecf20Sopenharmony_ci .ops = &mtk_afe_fe_ops, 2768c2ecf20Sopenharmony_ci }, 2778c2ecf20Sopenharmony_ci { 2788c2ecf20Sopenharmony_ci .name = "HDMI", 2798c2ecf20Sopenharmony_ci .id = MT8183_MEMIF_HDMI, 2808c2ecf20Sopenharmony_ci .playback = { 2818c2ecf20Sopenharmony_ci .stream_name = "HDMI", 2828c2ecf20Sopenharmony_ci .channels_min = 2, 2838c2ecf20Sopenharmony_ci .channels_max = 8, 2848c2ecf20Sopenharmony_ci .rates = MTK_PCM_RATES, 2858c2ecf20Sopenharmony_ci .formats = MTK_PCM_FORMATS, 2868c2ecf20Sopenharmony_ci }, 2878c2ecf20Sopenharmony_ci .ops = &mtk_afe_fe_ops, 2888c2ecf20Sopenharmony_ci }, 2898c2ecf20Sopenharmony_ci}; 2908c2ecf20Sopenharmony_ci 2918c2ecf20Sopenharmony_ci/* dma widget & routes*/ 2928c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new memif_ul1_ch1_mix[] = { 2938c2ecf20Sopenharmony_ci SOC_DAPM_SINGLE_AUTODISABLE("ADDA_UL_CH1", AFE_CONN21, 2948c2ecf20Sopenharmony_ci I_ADDA_UL_CH1, 1, 0), 2958c2ecf20Sopenharmony_ci SOC_DAPM_SINGLE_AUTODISABLE("I2S0_CH1", AFE_CONN21, 2968c2ecf20Sopenharmony_ci I_I2S0_CH1, 1, 0), 2978c2ecf20Sopenharmony_ci}; 2988c2ecf20Sopenharmony_ci 2998c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new memif_ul1_ch2_mix[] = { 3008c2ecf20Sopenharmony_ci SOC_DAPM_SINGLE_AUTODISABLE("ADDA_UL_CH2", AFE_CONN22, 3018c2ecf20Sopenharmony_ci I_ADDA_UL_CH2, 1, 0), 3028c2ecf20Sopenharmony_ci SOC_DAPM_SINGLE_AUTODISABLE("I2S0_CH2", AFE_CONN21, 3038c2ecf20Sopenharmony_ci I_I2S0_CH2, 1, 0), 3048c2ecf20Sopenharmony_ci}; 3058c2ecf20Sopenharmony_ci 3068c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new memif_ul2_ch1_mix[] = { 3078c2ecf20Sopenharmony_ci SOC_DAPM_SINGLE_AUTODISABLE("ADDA_UL_CH1", AFE_CONN5, 3088c2ecf20Sopenharmony_ci I_ADDA_UL_CH1, 1, 0), 3098c2ecf20Sopenharmony_ci SOC_DAPM_SINGLE_AUTODISABLE("DL1_CH1", AFE_CONN5, 3108c2ecf20Sopenharmony_ci I_DL1_CH1, 1, 0), 3118c2ecf20Sopenharmony_ci SOC_DAPM_SINGLE_AUTODISABLE("DL2_CH1", AFE_CONN5, 3128c2ecf20Sopenharmony_ci I_DL2_CH1, 1, 0), 3138c2ecf20Sopenharmony_ci SOC_DAPM_SINGLE_AUTODISABLE("DL3_CH1", AFE_CONN5, 3148c2ecf20Sopenharmony_ci I_DL3_CH1, 1, 0), 3158c2ecf20Sopenharmony_ci SOC_DAPM_SINGLE_AUTODISABLE("I2S2_CH1", AFE_CONN5, 3168c2ecf20Sopenharmony_ci I_I2S2_CH1, 1, 0), 3178c2ecf20Sopenharmony_ci}; 3188c2ecf20Sopenharmony_ci 3198c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new memif_ul2_ch2_mix[] = { 3208c2ecf20Sopenharmony_ci SOC_DAPM_SINGLE_AUTODISABLE("ADDA_UL_CH2", AFE_CONN6, 3218c2ecf20Sopenharmony_ci I_ADDA_UL_CH2, 1, 0), 3228c2ecf20Sopenharmony_ci SOC_DAPM_SINGLE_AUTODISABLE("DL1_CH2", AFE_CONN6, 3238c2ecf20Sopenharmony_ci I_DL1_CH2, 1, 0), 3248c2ecf20Sopenharmony_ci SOC_DAPM_SINGLE_AUTODISABLE("DL2_CH2", AFE_CONN6, 3258c2ecf20Sopenharmony_ci I_DL2_CH2, 1, 0), 3268c2ecf20Sopenharmony_ci SOC_DAPM_SINGLE_AUTODISABLE("DL3_CH2", AFE_CONN6, 3278c2ecf20Sopenharmony_ci I_DL3_CH2, 1, 0), 3288c2ecf20Sopenharmony_ci SOC_DAPM_SINGLE_AUTODISABLE("I2S2_CH2", AFE_CONN6, 3298c2ecf20Sopenharmony_ci I_I2S2_CH2, 1, 0), 3308c2ecf20Sopenharmony_ci}; 3318c2ecf20Sopenharmony_ci 3328c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new memif_ul3_ch1_mix[] = { 3338c2ecf20Sopenharmony_ci SOC_DAPM_SINGLE_AUTODISABLE("ADDA_UL_CH1", AFE_CONN32, 3348c2ecf20Sopenharmony_ci I_ADDA_UL_CH1, 1, 0), 3358c2ecf20Sopenharmony_ci SOC_DAPM_SINGLE_AUTODISABLE("I2S2_CH1", AFE_CONN32, 3368c2ecf20Sopenharmony_ci I_I2S2_CH1, 1, 0), 3378c2ecf20Sopenharmony_ci}; 3388c2ecf20Sopenharmony_ci 3398c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new memif_ul3_ch2_mix[] = { 3408c2ecf20Sopenharmony_ci SOC_DAPM_SINGLE_AUTODISABLE("ADDA_UL_CH2", AFE_CONN33, 3418c2ecf20Sopenharmony_ci I_ADDA_UL_CH2, 1, 0), 3428c2ecf20Sopenharmony_ci SOC_DAPM_SINGLE_AUTODISABLE("I2S2_CH2", AFE_CONN33, 3438c2ecf20Sopenharmony_ci I_I2S2_CH2, 1, 0), 3448c2ecf20Sopenharmony_ci}; 3458c2ecf20Sopenharmony_ci 3468c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new memif_ul4_ch1_mix[] = { 3478c2ecf20Sopenharmony_ci SOC_DAPM_SINGLE_AUTODISABLE("ADDA_UL_CH1", AFE_CONN38, 3488c2ecf20Sopenharmony_ci I_ADDA_UL_CH1, 1, 0), 3498c2ecf20Sopenharmony_ci}; 3508c2ecf20Sopenharmony_ci 3518c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new memif_ul4_ch2_mix[] = { 3528c2ecf20Sopenharmony_ci SOC_DAPM_SINGLE_AUTODISABLE("ADDA_UL_CH2", AFE_CONN39, 3538c2ecf20Sopenharmony_ci I_ADDA_UL_CH2, 1, 0), 3548c2ecf20Sopenharmony_ci}; 3558c2ecf20Sopenharmony_ci 3568c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new memif_ul_mono_1_mix[] = { 3578c2ecf20Sopenharmony_ci SOC_DAPM_SINGLE_AUTODISABLE("ADDA_UL_CH1", AFE_CONN12, 3588c2ecf20Sopenharmony_ci I_ADDA_UL_CH1, 1, 0), 3598c2ecf20Sopenharmony_ci SOC_DAPM_SINGLE_AUTODISABLE("ADDA_UL_CH2", AFE_CONN12, 3608c2ecf20Sopenharmony_ci I_ADDA_UL_CH2, 1, 0), 3618c2ecf20Sopenharmony_ci}; 3628c2ecf20Sopenharmony_ci 3638c2ecf20Sopenharmony_cistatic const struct snd_soc_dapm_widget mt8183_memif_widgets[] = { 3648c2ecf20Sopenharmony_ci /* memif */ 3658c2ecf20Sopenharmony_ci SND_SOC_DAPM_MIXER("UL1_CH1", SND_SOC_NOPM, 0, 0, 3668c2ecf20Sopenharmony_ci memif_ul1_ch1_mix, ARRAY_SIZE(memif_ul1_ch1_mix)), 3678c2ecf20Sopenharmony_ci SND_SOC_DAPM_MIXER("UL1_CH2", SND_SOC_NOPM, 0, 0, 3688c2ecf20Sopenharmony_ci memif_ul1_ch2_mix, ARRAY_SIZE(memif_ul1_ch2_mix)), 3698c2ecf20Sopenharmony_ci 3708c2ecf20Sopenharmony_ci SND_SOC_DAPM_MIXER("UL2_CH1", SND_SOC_NOPM, 0, 0, 3718c2ecf20Sopenharmony_ci memif_ul2_ch1_mix, ARRAY_SIZE(memif_ul2_ch1_mix)), 3728c2ecf20Sopenharmony_ci SND_SOC_DAPM_MIXER("UL2_CH2", SND_SOC_NOPM, 0, 0, 3738c2ecf20Sopenharmony_ci memif_ul2_ch2_mix, ARRAY_SIZE(memif_ul2_ch2_mix)), 3748c2ecf20Sopenharmony_ci 3758c2ecf20Sopenharmony_ci SND_SOC_DAPM_MIXER("UL3_CH1", SND_SOC_NOPM, 0, 0, 3768c2ecf20Sopenharmony_ci memif_ul3_ch1_mix, ARRAY_SIZE(memif_ul3_ch1_mix)), 3778c2ecf20Sopenharmony_ci SND_SOC_DAPM_MIXER("UL3_CH2", SND_SOC_NOPM, 0, 0, 3788c2ecf20Sopenharmony_ci memif_ul3_ch2_mix, ARRAY_SIZE(memif_ul3_ch2_mix)), 3798c2ecf20Sopenharmony_ci 3808c2ecf20Sopenharmony_ci SND_SOC_DAPM_MIXER("UL4_CH1", SND_SOC_NOPM, 0, 0, 3818c2ecf20Sopenharmony_ci memif_ul4_ch1_mix, ARRAY_SIZE(memif_ul4_ch1_mix)), 3828c2ecf20Sopenharmony_ci SND_SOC_DAPM_MIXER("UL4_CH2", SND_SOC_NOPM, 0, 0, 3838c2ecf20Sopenharmony_ci memif_ul4_ch2_mix, ARRAY_SIZE(memif_ul4_ch2_mix)), 3848c2ecf20Sopenharmony_ci 3858c2ecf20Sopenharmony_ci SND_SOC_DAPM_MIXER("UL_MONO_1_CH1", SND_SOC_NOPM, 0, 0, 3868c2ecf20Sopenharmony_ci memif_ul_mono_1_mix, 3878c2ecf20Sopenharmony_ci ARRAY_SIZE(memif_ul_mono_1_mix)), 3888c2ecf20Sopenharmony_ci}; 3898c2ecf20Sopenharmony_ci 3908c2ecf20Sopenharmony_cistatic const struct snd_soc_dapm_route mt8183_memif_routes[] = { 3918c2ecf20Sopenharmony_ci /* capture */ 3928c2ecf20Sopenharmony_ci {"UL1", NULL, "UL1_CH1"}, 3938c2ecf20Sopenharmony_ci {"UL1", NULL, "UL1_CH2"}, 3948c2ecf20Sopenharmony_ci {"UL1_CH1", "ADDA_UL_CH1", "ADDA Capture"}, 3958c2ecf20Sopenharmony_ci {"UL1_CH2", "ADDA_UL_CH2", "ADDA Capture"}, 3968c2ecf20Sopenharmony_ci {"UL1_CH1", "I2S0_CH1", "I2S0"}, 3978c2ecf20Sopenharmony_ci {"UL1_CH2", "I2S0_CH2", "I2S0"}, 3988c2ecf20Sopenharmony_ci 3998c2ecf20Sopenharmony_ci {"UL2", NULL, "UL2_CH1"}, 4008c2ecf20Sopenharmony_ci {"UL2", NULL, "UL2_CH2"}, 4018c2ecf20Sopenharmony_ci {"UL2_CH1", "ADDA_UL_CH1", "ADDA Capture"}, 4028c2ecf20Sopenharmony_ci {"UL2_CH2", "ADDA_UL_CH2", "ADDA Capture"}, 4038c2ecf20Sopenharmony_ci {"UL2_CH1", "I2S2_CH1", "I2S2"}, 4048c2ecf20Sopenharmony_ci {"UL2_CH2", "I2S2_CH2", "I2S2"}, 4058c2ecf20Sopenharmony_ci 4068c2ecf20Sopenharmony_ci {"UL3", NULL, "UL3_CH1"}, 4078c2ecf20Sopenharmony_ci {"UL3", NULL, "UL3_CH2"}, 4088c2ecf20Sopenharmony_ci {"UL3_CH1", "ADDA_UL_CH1", "ADDA Capture"}, 4098c2ecf20Sopenharmony_ci {"UL3_CH2", "ADDA_UL_CH2", "ADDA Capture"}, 4108c2ecf20Sopenharmony_ci {"UL3_CH1", "I2S2_CH1", "I2S2"}, 4118c2ecf20Sopenharmony_ci {"UL3_CH2", "I2S2_CH2", "I2S2"}, 4128c2ecf20Sopenharmony_ci 4138c2ecf20Sopenharmony_ci {"UL4", NULL, "UL4_CH1"}, 4148c2ecf20Sopenharmony_ci {"UL4", NULL, "UL4_CH2"}, 4158c2ecf20Sopenharmony_ci {"UL4_CH1", "ADDA_UL_CH1", "ADDA Capture"}, 4168c2ecf20Sopenharmony_ci {"UL4_CH2", "ADDA_UL_CH2", "ADDA Capture"}, 4178c2ecf20Sopenharmony_ci 4188c2ecf20Sopenharmony_ci {"UL_MONO_1", NULL, "UL_MONO_1_CH1"}, 4198c2ecf20Sopenharmony_ci {"UL_MONO_1_CH1", "ADDA_UL_CH1", "ADDA Capture"}, 4208c2ecf20Sopenharmony_ci {"UL_MONO_1_CH1", "ADDA_UL_CH2", "ADDA Capture"}, 4218c2ecf20Sopenharmony_ci}; 4228c2ecf20Sopenharmony_ci 4238c2ecf20Sopenharmony_cistatic const struct snd_soc_component_driver mt8183_afe_pcm_dai_component = { 4248c2ecf20Sopenharmony_ci .name = "mt8183-afe-pcm-dai", 4258c2ecf20Sopenharmony_ci}; 4268c2ecf20Sopenharmony_ci 4278c2ecf20Sopenharmony_cistatic const struct mtk_base_memif_data memif_data[MT8183_MEMIF_NUM] = { 4288c2ecf20Sopenharmony_ci [MT8183_MEMIF_DL1] = { 4298c2ecf20Sopenharmony_ci .name = "DL1", 4308c2ecf20Sopenharmony_ci .id = MT8183_MEMIF_DL1, 4318c2ecf20Sopenharmony_ci .reg_ofs_base = AFE_DL1_BASE, 4328c2ecf20Sopenharmony_ci .reg_ofs_cur = AFE_DL1_CUR, 4338c2ecf20Sopenharmony_ci .fs_reg = AFE_DAC_CON1, 4348c2ecf20Sopenharmony_ci .fs_shift = DL1_MODE_SFT, 4358c2ecf20Sopenharmony_ci .fs_maskbit = DL1_MODE_MASK, 4368c2ecf20Sopenharmony_ci .mono_reg = AFE_DAC_CON1, 4378c2ecf20Sopenharmony_ci .mono_shift = DL1_DATA_SFT, 4388c2ecf20Sopenharmony_ci .enable_reg = AFE_DAC_CON0, 4398c2ecf20Sopenharmony_ci .enable_shift = DL1_ON_SFT, 4408c2ecf20Sopenharmony_ci .hd_reg = AFE_MEMIF_HD_MODE, 4418c2ecf20Sopenharmony_ci .hd_align_reg = AFE_MEMIF_HDALIGN, 4428c2ecf20Sopenharmony_ci .hd_shift = DL1_HD_SFT, 4438c2ecf20Sopenharmony_ci .hd_align_mshift = DL1_HD_ALIGN_SFT, 4448c2ecf20Sopenharmony_ci .agent_disable_reg = -1, 4458c2ecf20Sopenharmony_ci .agent_disable_shift = -1, 4468c2ecf20Sopenharmony_ci .msb_reg = -1, 4478c2ecf20Sopenharmony_ci .msb_shift = -1, 4488c2ecf20Sopenharmony_ci }, 4498c2ecf20Sopenharmony_ci [MT8183_MEMIF_DL2] = { 4508c2ecf20Sopenharmony_ci .name = "DL2", 4518c2ecf20Sopenharmony_ci .id = MT8183_MEMIF_DL2, 4528c2ecf20Sopenharmony_ci .reg_ofs_base = AFE_DL2_BASE, 4538c2ecf20Sopenharmony_ci .reg_ofs_cur = AFE_DL2_CUR, 4548c2ecf20Sopenharmony_ci .fs_reg = AFE_DAC_CON1, 4558c2ecf20Sopenharmony_ci .fs_shift = DL2_MODE_SFT, 4568c2ecf20Sopenharmony_ci .fs_maskbit = DL2_MODE_MASK, 4578c2ecf20Sopenharmony_ci .mono_reg = AFE_DAC_CON1, 4588c2ecf20Sopenharmony_ci .mono_shift = DL2_DATA_SFT, 4598c2ecf20Sopenharmony_ci .enable_reg = AFE_DAC_CON0, 4608c2ecf20Sopenharmony_ci .enable_shift = DL2_ON_SFT, 4618c2ecf20Sopenharmony_ci .hd_reg = AFE_MEMIF_HD_MODE, 4628c2ecf20Sopenharmony_ci .hd_align_reg = AFE_MEMIF_HDALIGN, 4638c2ecf20Sopenharmony_ci .hd_shift = DL2_HD_SFT, 4648c2ecf20Sopenharmony_ci .hd_align_mshift = DL2_HD_ALIGN_SFT, 4658c2ecf20Sopenharmony_ci .agent_disable_reg = -1, 4668c2ecf20Sopenharmony_ci .agent_disable_shift = -1, 4678c2ecf20Sopenharmony_ci .msb_reg = -1, 4688c2ecf20Sopenharmony_ci .msb_shift = -1, 4698c2ecf20Sopenharmony_ci }, 4708c2ecf20Sopenharmony_ci [MT8183_MEMIF_DL3] = { 4718c2ecf20Sopenharmony_ci .name = "DL3", 4728c2ecf20Sopenharmony_ci .id = MT8183_MEMIF_DL3, 4738c2ecf20Sopenharmony_ci .reg_ofs_base = AFE_DL3_BASE, 4748c2ecf20Sopenharmony_ci .reg_ofs_cur = AFE_DL3_CUR, 4758c2ecf20Sopenharmony_ci .fs_reg = AFE_DAC_CON2, 4768c2ecf20Sopenharmony_ci .fs_shift = DL3_MODE_SFT, 4778c2ecf20Sopenharmony_ci .fs_maskbit = DL3_MODE_MASK, 4788c2ecf20Sopenharmony_ci .mono_reg = AFE_DAC_CON1, 4798c2ecf20Sopenharmony_ci .mono_shift = DL3_DATA_SFT, 4808c2ecf20Sopenharmony_ci .enable_reg = AFE_DAC_CON0, 4818c2ecf20Sopenharmony_ci .enable_shift = DL3_ON_SFT, 4828c2ecf20Sopenharmony_ci .hd_reg = AFE_MEMIF_HD_MODE, 4838c2ecf20Sopenharmony_ci .hd_align_reg = AFE_MEMIF_HDALIGN, 4848c2ecf20Sopenharmony_ci .hd_shift = DL3_HD_SFT, 4858c2ecf20Sopenharmony_ci .hd_align_mshift = DL3_HD_ALIGN_SFT, 4868c2ecf20Sopenharmony_ci .agent_disable_reg = -1, 4878c2ecf20Sopenharmony_ci .agent_disable_shift = -1, 4888c2ecf20Sopenharmony_ci .msb_reg = -1, 4898c2ecf20Sopenharmony_ci .msb_shift = -1, 4908c2ecf20Sopenharmony_ci }, 4918c2ecf20Sopenharmony_ci [MT8183_MEMIF_VUL2] = { 4928c2ecf20Sopenharmony_ci .name = "VUL2", 4938c2ecf20Sopenharmony_ci .id = MT8183_MEMIF_VUL2, 4948c2ecf20Sopenharmony_ci .reg_ofs_base = AFE_VUL2_BASE, 4958c2ecf20Sopenharmony_ci .reg_ofs_cur = AFE_VUL2_CUR, 4968c2ecf20Sopenharmony_ci .fs_reg = AFE_DAC_CON2, 4978c2ecf20Sopenharmony_ci .fs_shift = VUL2_MODE_SFT, 4988c2ecf20Sopenharmony_ci .fs_maskbit = VUL2_MODE_MASK, 4998c2ecf20Sopenharmony_ci .mono_reg = AFE_DAC_CON2, 5008c2ecf20Sopenharmony_ci .mono_shift = VUL2_DATA_SFT, 5018c2ecf20Sopenharmony_ci .enable_reg = AFE_DAC_CON0, 5028c2ecf20Sopenharmony_ci .enable_shift = VUL2_ON_SFT, 5038c2ecf20Sopenharmony_ci .hd_reg = AFE_MEMIF_HD_MODE, 5048c2ecf20Sopenharmony_ci .hd_align_reg = AFE_MEMIF_HDALIGN, 5058c2ecf20Sopenharmony_ci .hd_shift = VUL2_HD_SFT, 5068c2ecf20Sopenharmony_ci .hd_align_mshift = VUL2_HD_ALIGN_SFT, 5078c2ecf20Sopenharmony_ci .agent_disable_reg = -1, 5088c2ecf20Sopenharmony_ci .agent_disable_shift = -1, 5098c2ecf20Sopenharmony_ci .msb_reg = -1, 5108c2ecf20Sopenharmony_ci .msb_shift = -1, 5118c2ecf20Sopenharmony_ci }, 5128c2ecf20Sopenharmony_ci [MT8183_MEMIF_AWB] = { 5138c2ecf20Sopenharmony_ci .name = "AWB", 5148c2ecf20Sopenharmony_ci .id = MT8183_MEMIF_AWB, 5158c2ecf20Sopenharmony_ci .reg_ofs_base = AFE_AWB_BASE, 5168c2ecf20Sopenharmony_ci .reg_ofs_cur = AFE_AWB_CUR, 5178c2ecf20Sopenharmony_ci .fs_reg = AFE_DAC_CON1, 5188c2ecf20Sopenharmony_ci .fs_shift = AWB_MODE_SFT, 5198c2ecf20Sopenharmony_ci .fs_maskbit = AWB_MODE_MASK, 5208c2ecf20Sopenharmony_ci .mono_reg = AFE_DAC_CON1, 5218c2ecf20Sopenharmony_ci .mono_shift = AWB_DATA_SFT, 5228c2ecf20Sopenharmony_ci .enable_reg = AFE_DAC_CON0, 5238c2ecf20Sopenharmony_ci .enable_shift = AWB_ON_SFT, 5248c2ecf20Sopenharmony_ci .hd_reg = AFE_MEMIF_HD_MODE, 5258c2ecf20Sopenharmony_ci .hd_align_reg = AFE_MEMIF_HDALIGN, 5268c2ecf20Sopenharmony_ci .hd_shift = AWB_HD_SFT, 5278c2ecf20Sopenharmony_ci .hd_align_mshift = AWB_HD_ALIGN_SFT, 5288c2ecf20Sopenharmony_ci .agent_disable_reg = -1, 5298c2ecf20Sopenharmony_ci .agent_disable_shift = -1, 5308c2ecf20Sopenharmony_ci .msb_reg = -1, 5318c2ecf20Sopenharmony_ci .msb_shift = -1, 5328c2ecf20Sopenharmony_ci }, 5338c2ecf20Sopenharmony_ci [MT8183_MEMIF_AWB2] = { 5348c2ecf20Sopenharmony_ci .name = "AWB2", 5358c2ecf20Sopenharmony_ci .id = MT8183_MEMIF_AWB2, 5368c2ecf20Sopenharmony_ci .reg_ofs_base = AFE_AWB2_BASE, 5378c2ecf20Sopenharmony_ci .reg_ofs_cur = AFE_AWB2_CUR, 5388c2ecf20Sopenharmony_ci .fs_reg = AFE_DAC_CON2, 5398c2ecf20Sopenharmony_ci .fs_shift = AWB2_MODE_SFT, 5408c2ecf20Sopenharmony_ci .fs_maskbit = AWB2_MODE_MASK, 5418c2ecf20Sopenharmony_ci .mono_reg = AFE_DAC_CON2, 5428c2ecf20Sopenharmony_ci .mono_shift = AWB2_DATA_SFT, 5438c2ecf20Sopenharmony_ci .enable_reg = AFE_DAC_CON0, 5448c2ecf20Sopenharmony_ci .enable_shift = AWB2_ON_SFT, 5458c2ecf20Sopenharmony_ci .hd_reg = AFE_MEMIF_HD_MODE, 5468c2ecf20Sopenharmony_ci .hd_align_reg = AFE_MEMIF_HDALIGN, 5478c2ecf20Sopenharmony_ci .hd_shift = AWB2_HD_SFT, 5488c2ecf20Sopenharmony_ci .hd_align_mshift = AWB2_ALIGN_SFT, 5498c2ecf20Sopenharmony_ci .agent_disable_reg = -1, 5508c2ecf20Sopenharmony_ci .agent_disable_shift = -1, 5518c2ecf20Sopenharmony_ci .msb_reg = -1, 5528c2ecf20Sopenharmony_ci .msb_shift = -1, 5538c2ecf20Sopenharmony_ci }, 5548c2ecf20Sopenharmony_ci [MT8183_MEMIF_VUL12] = { 5558c2ecf20Sopenharmony_ci .name = "VUL12", 5568c2ecf20Sopenharmony_ci .id = MT8183_MEMIF_VUL12, 5578c2ecf20Sopenharmony_ci .reg_ofs_base = AFE_VUL_D2_BASE, 5588c2ecf20Sopenharmony_ci .reg_ofs_cur = AFE_VUL_D2_CUR, 5598c2ecf20Sopenharmony_ci .fs_reg = AFE_DAC_CON0, 5608c2ecf20Sopenharmony_ci .fs_shift = VUL12_MODE_SFT, 5618c2ecf20Sopenharmony_ci .fs_maskbit = VUL12_MODE_MASK, 5628c2ecf20Sopenharmony_ci .mono_reg = AFE_DAC_CON0, 5638c2ecf20Sopenharmony_ci .mono_shift = VUL12_MONO_SFT, 5648c2ecf20Sopenharmony_ci .enable_reg = AFE_DAC_CON0, 5658c2ecf20Sopenharmony_ci .enable_shift = VUL12_ON_SFT, 5668c2ecf20Sopenharmony_ci .hd_reg = AFE_MEMIF_HD_MODE, 5678c2ecf20Sopenharmony_ci .hd_align_reg = AFE_MEMIF_HDALIGN, 5688c2ecf20Sopenharmony_ci .hd_shift = VUL12_HD_SFT, 5698c2ecf20Sopenharmony_ci .hd_align_mshift = VUL12_HD_ALIGN_SFT, 5708c2ecf20Sopenharmony_ci .agent_disable_reg = -1, 5718c2ecf20Sopenharmony_ci .agent_disable_shift = -1, 5728c2ecf20Sopenharmony_ci .msb_reg = -1, 5738c2ecf20Sopenharmony_ci .msb_shift = -1, 5748c2ecf20Sopenharmony_ci }, 5758c2ecf20Sopenharmony_ci [MT8183_MEMIF_MOD_DAI] = { 5768c2ecf20Sopenharmony_ci .name = "MOD_DAI", 5778c2ecf20Sopenharmony_ci .id = MT8183_MEMIF_MOD_DAI, 5788c2ecf20Sopenharmony_ci .reg_ofs_base = AFE_MOD_DAI_BASE, 5798c2ecf20Sopenharmony_ci .reg_ofs_cur = AFE_MOD_DAI_CUR, 5808c2ecf20Sopenharmony_ci .fs_reg = AFE_DAC_CON1, 5818c2ecf20Sopenharmony_ci .fs_shift = MOD_DAI_MODE_SFT, 5828c2ecf20Sopenharmony_ci .fs_maskbit = MOD_DAI_MODE_MASK, 5838c2ecf20Sopenharmony_ci .mono_reg = -1, 5848c2ecf20Sopenharmony_ci .mono_shift = 0, 5858c2ecf20Sopenharmony_ci .enable_reg = AFE_DAC_CON0, 5868c2ecf20Sopenharmony_ci .enable_shift = MOD_DAI_ON_SFT, 5878c2ecf20Sopenharmony_ci .hd_reg = AFE_MEMIF_HD_MODE, 5888c2ecf20Sopenharmony_ci .hd_align_reg = AFE_MEMIF_HDALIGN, 5898c2ecf20Sopenharmony_ci .hd_shift = MOD_DAI_HD_SFT, 5908c2ecf20Sopenharmony_ci .hd_align_mshift = MOD_DAI_HD_ALIGN_SFT, 5918c2ecf20Sopenharmony_ci .agent_disable_reg = -1, 5928c2ecf20Sopenharmony_ci .agent_disable_shift = -1, 5938c2ecf20Sopenharmony_ci .msb_reg = -1, 5948c2ecf20Sopenharmony_ci .msb_shift = -1, 5958c2ecf20Sopenharmony_ci }, 5968c2ecf20Sopenharmony_ci [MT8183_MEMIF_HDMI] = { 5978c2ecf20Sopenharmony_ci .name = "HDMI", 5988c2ecf20Sopenharmony_ci .id = MT8183_MEMIF_HDMI, 5998c2ecf20Sopenharmony_ci .reg_ofs_base = AFE_HDMI_OUT_BASE, 6008c2ecf20Sopenharmony_ci .reg_ofs_cur = AFE_HDMI_OUT_CUR, 6018c2ecf20Sopenharmony_ci .fs_reg = -1, 6028c2ecf20Sopenharmony_ci .fs_shift = -1, 6038c2ecf20Sopenharmony_ci .fs_maskbit = -1, 6048c2ecf20Sopenharmony_ci .mono_reg = -1, 6058c2ecf20Sopenharmony_ci .mono_shift = -1, 6068c2ecf20Sopenharmony_ci .enable_reg = -1, /* control in tdm for sync start */ 6078c2ecf20Sopenharmony_ci .enable_shift = -1, 6088c2ecf20Sopenharmony_ci .hd_reg = AFE_MEMIF_HD_MODE, 6098c2ecf20Sopenharmony_ci .hd_align_reg = AFE_MEMIF_HDALIGN, 6108c2ecf20Sopenharmony_ci .hd_shift = HDMI_HD_SFT, 6118c2ecf20Sopenharmony_ci .hd_align_mshift = HDMI_HD_ALIGN_SFT, 6128c2ecf20Sopenharmony_ci .agent_disable_reg = -1, 6138c2ecf20Sopenharmony_ci .agent_disable_shift = -1, 6148c2ecf20Sopenharmony_ci .msb_reg = -1, 6158c2ecf20Sopenharmony_ci .msb_shift = -1, 6168c2ecf20Sopenharmony_ci }, 6178c2ecf20Sopenharmony_ci}; 6188c2ecf20Sopenharmony_ci 6198c2ecf20Sopenharmony_cistatic const struct mtk_base_irq_data irq_data[MT8183_IRQ_NUM] = { 6208c2ecf20Sopenharmony_ci [MT8183_IRQ_0] = { 6218c2ecf20Sopenharmony_ci .id = MT8183_IRQ_0, 6228c2ecf20Sopenharmony_ci .irq_cnt_reg = AFE_IRQ_MCU_CNT0, 6238c2ecf20Sopenharmony_ci .irq_cnt_shift = 0, 6248c2ecf20Sopenharmony_ci .irq_cnt_maskbit = 0x3ffff, 6258c2ecf20Sopenharmony_ci .irq_fs_reg = AFE_IRQ_MCU_CON1, 6268c2ecf20Sopenharmony_ci .irq_fs_shift = IRQ0_MCU_MODE_SFT, 6278c2ecf20Sopenharmony_ci .irq_fs_maskbit = IRQ0_MCU_MODE_MASK, 6288c2ecf20Sopenharmony_ci .irq_en_reg = AFE_IRQ_MCU_CON0, 6298c2ecf20Sopenharmony_ci .irq_en_shift = IRQ0_MCU_ON_SFT, 6308c2ecf20Sopenharmony_ci .irq_clr_reg = AFE_IRQ_MCU_CLR, 6318c2ecf20Sopenharmony_ci .irq_clr_shift = IRQ0_MCU_CLR_SFT, 6328c2ecf20Sopenharmony_ci }, 6338c2ecf20Sopenharmony_ci [MT8183_IRQ_1] = { 6348c2ecf20Sopenharmony_ci .id = MT8183_IRQ_1, 6358c2ecf20Sopenharmony_ci .irq_cnt_reg = AFE_IRQ_MCU_CNT1, 6368c2ecf20Sopenharmony_ci .irq_cnt_shift = 0, 6378c2ecf20Sopenharmony_ci .irq_cnt_maskbit = 0x3ffff, 6388c2ecf20Sopenharmony_ci .irq_fs_reg = AFE_IRQ_MCU_CON1, 6398c2ecf20Sopenharmony_ci .irq_fs_shift = IRQ1_MCU_MODE_SFT, 6408c2ecf20Sopenharmony_ci .irq_fs_maskbit = IRQ1_MCU_MODE_MASK, 6418c2ecf20Sopenharmony_ci .irq_en_reg = AFE_IRQ_MCU_CON0, 6428c2ecf20Sopenharmony_ci .irq_en_shift = IRQ1_MCU_ON_SFT, 6438c2ecf20Sopenharmony_ci .irq_clr_reg = AFE_IRQ_MCU_CLR, 6448c2ecf20Sopenharmony_ci .irq_clr_shift = IRQ1_MCU_CLR_SFT, 6458c2ecf20Sopenharmony_ci }, 6468c2ecf20Sopenharmony_ci [MT8183_IRQ_2] = { 6478c2ecf20Sopenharmony_ci .id = MT8183_IRQ_2, 6488c2ecf20Sopenharmony_ci .irq_cnt_reg = AFE_IRQ_MCU_CNT2, 6498c2ecf20Sopenharmony_ci .irq_cnt_shift = 0, 6508c2ecf20Sopenharmony_ci .irq_cnt_maskbit = 0x3ffff, 6518c2ecf20Sopenharmony_ci .irq_fs_reg = AFE_IRQ_MCU_CON1, 6528c2ecf20Sopenharmony_ci .irq_fs_shift = IRQ2_MCU_MODE_SFT, 6538c2ecf20Sopenharmony_ci .irq_fs_maskbit = IRQ2_MCU_MODE_MASK, 6548c2ecf20Sopenharmony_ci .irq_en_reg = AFE_IRQ_MCU_CON0, 6558c2ecf20Sopenharmony_ci .irq_en_shift = IRQ2_MCU_ON_SFT, 6568c2ecf20Sopenharmony_ci .irq_clr_reg = AFE_IRQ_MCU_CLR, 6578c2ecf20Sopenharmony_ci .irq_clr_shift = IRQ2_MCU_CLR_SFT, 6588c2ecf20Sopenharmony_ci }, 6598c2ecf20Sopenharmony_ci [MT8183_IRQ_3] = { 6608c2ecf20Sopenharmony_ci .id = MT8183_IRQ_3, 6618c2ecf20Sopenharmony_ci .irq_cnt_reg = AFE_IRQ_MCU_CNT3, 6628c2ecf20Sopenharmony_ci .irq_cnt_shift = 0, 6638c2ecf20Sopenharmony_ci .irq_cnt_maskbit = 0x3ffff, 6648c2ecf20Sopenharmony_ci .irq_fs_reg = AFE_IRQ_MCU_CON1, 6658c2ecf20Sopenharmony_ci .irq_fs_shift = IRQ3_MCU_MODE_SFT, 6668c2ecf20Sopenharmony_ci .irq_fs_maskbit = IRQ3_MCU_MODE_MASK, 6678c2ecf20Sopenharmony_ci .irq_en_reg = AFE_IRQ_MCU_CON0, 6688c2ecf20Sopenharmony_ci .irq_en_shift = IRQ3_MCU_ON_SFT, 6698c2ecf20Sopenharmony_ci .irq_clr_reg = AFE_IRQ_MCU_CLR, 6708c2ecf20Sopenharmony_ci .irq_clr_shift = IRQ3_MCU_CLR_SFT, 6718c2ecf20Sopenharmony_ci }, 6728c2ecf20Sopenharmony_ci [MT8183_IRQ_4] = { 6738c2ecf20Sopenharmony_ci .id = MT8183_IRQ_4, 6748c2ecf20Sopenharmony_ci .irq_cnt_reg = AFE_IRQ_MCU_CNT4, 6758c2ecf20Sopenharmony_ci .irq_cnt_shift = 0, 6768c2ecf20Sopenharmony_ci .irq_cnt_maskbit = 0x3ffff, 6778c2ecf20Sopenharmony_ci .irq_fs_reg = AFE_IRQ_MCU_CON1, 6788c2ecf20Sopenharmony_ci .irq_fs_shift = IRQ4_MCU_MODE_SFT, 6798c2ecf20Sopenharmony_ci .irq_fs_maskbit = IRQ4_MCU_MODE_MASK, 6808c2ecf20Sopenharmony_ci .irq_en_reg = AFE_IRQ_MCU_CON0, 6818c2ecf20Sopenharmony_ci .irq_en_shift = IRQ4_MCU_ON_SFT, 6828c2ecf20Sopenharmony_ci .irq_clr_reg = AFE_IRQ_MCU_CLR, 6838c2ecf20Sopenharmony_ci .irq_clr_shift = IRQ4_MCU_CLR_SFT, 6848c2ecf20Sopenharmony_ci }, 6858c2ecf20Sopenharmony_ci [MT8183_IRQ_5] = { 6868c2ecf20Sopenharmony_ci .id = MT8183_IRQ_5, 6878c2ecf20Sopenharmony_ci .irq_cnt_reg = AFE_IRQ_MCU_CNT5, 6888c2ecf20Sopenharmony_ci .irq_cnt_shift = 0, 6898c2ecf20Sopenharmony_ci .irq_cnt_maskbit = 0x3ffff, 6908c2ecf20Sopenharmony_ci .irq_fs_reg = AFE_IRQ_MCU_CON1, 6918c2ecf20Sopenharmony_ci .irq_fs_shift = IRQ5_MCU_MODE_SFT, 6928c2ecf20Sopenharmony_ci .irq_fs_maskbit = IRQ5_MCU_MODE_MASK, 6938c2ecf20Sopenharmony_ci .irq_en_reg = AFE_IRQ_MCU_CON0, 6948c2ecf20Sopenharmony_ci .irq_en_shift = IRQ5_MCU_ON_SFT, 6958c2ecf20Sopenharmony_ci .irq_clr_reg = AFE_IRQ_MCU_CLR, 6968c2ecf20Sopenharmony_ci .irq_clr_shift = IRQ5_MCU_CLR_SFT, 6978c2ecf20Sopenharmony_ci }, 6988c2ecf20Sopenharmony_ci [MT8183_IRQ_6] = { 6998c2ecf20Sopenharmony_ci .id = MT8183_IRQ_6, 7008c2ecf20Sopenharmony_ci .irq_cnt_reg = AFE_IRQ_MCU_CNT6, 7018c2ecf20Sopenharmony_ci .irq_cnt_shift = 0, 7028c2ecf20Sopenharmony_ci .irq_cnt_maskbit = 0x3ffff, 7038c2ecf20Sopenharmony_ci .irq_fs_reg = AFE_IRQ_MCU_CON1, 7048c2ecf20Sopenharmony_ci .irq_fs_shift = IRQ6_MCU_MODE_SFT, 7058c2ecf20Sopenharmony_ci .irq_fs_maskbit = IRQ6_MCU_MODE_MASK, 7068c2ecf20Sopenharmony_ci .irq_en_reg = AFE_IRQ_MCU_CON0, 7078c2ecf20Sopenharmony_ci .irq_en_shift = IRQ6_MCU_ON_SFT, 7088c2ecf20Sopenharmony_ci .irq_clr_reg = AFE_IRQ_MCU_CLR, 7098c2ecf20Sopenharmony_ci .irq_clr_shift = IRQ6_MCU_CLR_SFT, 7108c2ecf20Sopenharmony_ci }, 7118c2ecf20Sopenharmony_ci [MT8183_IRQ_7] = { 7128c2ecf20Sopenharmony_ci .id = MT8183_IRQ_7, 7138c2ecf20Sopenharmony_ci .irq_cnt_reg = AFE_IRQ_MCU_CNT7, 7148c2ecf20Sopenharmony_ci .irq_cnt_shift = 0, 7158c2ecf20Sopenharmony_ci .irq_cnt_maskbit = 0x3ffff, 7168c2ecf20Sopenharmony_ci .irq_fs_reg = AFE_IRQ_MCU_CON1, 7178c2ecf20Sopenharmony_ci .irq_fs_shift = IRQ7_MCU_MODE_SFT, 7188c2ecf20Sopenharmony_ci .irq_fs_maskbit = IRQ7_MCU_MODE_MASK, 7198c2ecf20Sopenharmony_ci .irq_en_reg = AFE_IRQ_MCU_CON0, 7208c2ecf20Sopenharmony_ci .irq_en_shift = IRQ7_MCU_ON_SFT, 7218c2ecf20Sopenharmony_ci .irq_clr_reg = AFE_IRQ_MCU_CLR, 7228c2ecf20Sopenharmony_ci .irq_clr_shift = IRQ7_MCU_CLR_SFT, 7238c2ecf20Sopenharmony_ci }, 7248c2ecf20Sopenharmony_ci [MT8183_IRQ_8] = { 7258c2ecf20Sopenharmony_ci .id = MT8183_IRQ_8, 7268c2ecf20Sopenharmony_ci .irq_cnt_reg = AFE_IRQ_MCU_CNT8, 7278c2ecf20Sopenharmony_ci .irq_cnt_shift = 0, 7288c2ecf20Sopenharmony_ci .irq_cnt_maskbit = 0x3ffff, 7298c2ecf20Sopenharmony_ci .irq_fs_reg = -1, 7308c2ecf20Sopenharmony_ci .irq_fs_shift = -1, 7318c2ecf20Sopenharmony_ci .irq_fs_maskbit = -1, 7328c2ecf20Sopenharmony_ci .irq_en_reg = AFE_IRQ_MCU_CON0, 7338c2ecf20Sopenharmony_ci .irq_en_shift = IRQ8_MCU_ON_SFT, 7348c2ecf20Sopenharmony_ci .irq_clr_reg = AFE_IRQ_MCU_CLR, 7358c2ecf20Sopenharmony_ci .irq_clr_shift = IRQ8_MCU_CLR_SFT, 7368c2ecf20Sopenharmony_ci }, 7378c2ecf20Sopenharmony_ci [MT8183_IRQ_11] = { 7388c2ecf20Sopenharmony_ci .id = MT8183_IRQ_11, 7398c2ecf20Sopenharmony_ci .irq_cnt_reg = AFE_IRQ_MCU_CNT11, 7408c2ecf20Sopenharmony_ci .irq_cnt_shift = 0, 7418c2ecf20Sopenharmony_ci .irq_cnt_maskbit = 0x3ffff, 7428c2ecf20Sopenharmony_ci .irq_fs_reg = AFE_IRQ_MCU_CON2, 7438c2ecf20Sopenharmony_ci .irq_fs_shift = IRQ11_MCU_MODE_SFT, 7448c2ecf20Sopenharmony_ci .irq_fs_maskbit = IRQ11_MCU_MODE_MASK, 7458c2ecf20Sopenharmony_ci .irq_en_reg = AFE_IRQ_MCU_CON0, 7468c2ecf20Sopenharmony_ci .irq_en_shift = IRQ11_MCU_ON_SFT, 7478c2ecf20Sopenharmony_ci .irq_clr_reg = AFE_IRQ_MCU_CLR, 7488c2ecf20Sopenharmony_ci .irq_clr_shift = IRQ11_MCU_CLR_SFT, 7498c2ecf20Sopenharmony_ci }, 7508c2ecf20Sopenharmony_ci [MT8183_IRQ_12] = { 7518c2ecf20Sopenharmony_ci .id = MT8183_IRQ_12, 7528c2ecf20Sopenharmony_ci .irq_cnt_reg = AFE_IRQ_MCU_CNT12, 7538c2ecf20Sopenharmony_ci .irq_cnt_shift = 0, 7548c2ecf20Sopenharmony_ci .irq_cnt_maskbit = 0x3ffff, 7558c2ecf20Sopenharmony_ci .irq_fs_reg = AFE_IRQ_MCU_CON2, 7568c2ecf20Sopenharmony_ci .irq_fs_shift = IRQ12_MCU_MODE_SFT, 7578c2ecf20Sopenharmony_ci .irq_fs_maskbit = IRQ12_MCU_MODE_MASK, 7588c2ecf20Sopenharmony_ci .irq_en_reg = AFE_IRQ_MCU_CON0, 7598c2ecf20Sopenharmony_ci .irq_en_shift = IRQ12_MCU_ON_SFT, 7608c2ecf20Sopenharmony_ci .irq_clr_reg = AFE_IRQ_MCU_CLR, 7618c2ecf20Sopenharmony_ci .irq_clr_shift = IRQ12_MCU_CLR_SFT, 7628c2ecf20Sopenharmony_ci }, 7638c2ecf20Sopenharmony_ci}; 7648c2ecf20Sopenharmony_ci 7658c2ecf20Sopenharmony_cistatic bool mt8183_is_volatile_reg(struct device *dev, unsigned int reg) 7668c2ecf20Sopenharmony_ci{ 7678c2ecf20Sopenharmony_ci /* these auto-gen reg has read-only bit, so put it as volatile */ 7688c2ecf20Sopenharmony_ci /* volatile reg cannot be cached, so cannot be set when power off */ 7698c2ecf20Sopenharmony_ci switch (reg) { 7708c2ecf20Sopenharmony_ci case AUDIO_TOP_CON0: /* reg bit controlled by CCF */ 7718c2ecf20Sopenharmony_ci case AUDIO_TOP_CON1: /* reg bit controlled by CCF */ 7728c2ecf20Sopenharmony_ci case AUDIO_TOP_CON3: 7738c2ecf20Sopenharmony_ci case AFE_DL1_CUR: 7748c2ecf20Sopenharmony_ci case AFE_DL1_END: 7758c2ecf20Sopenharmony_ci case AFE_DL2_CUR: 7768c2ecf20Sopenharmony_ci case AFE_DL2_END: 7778c2ecf20Sopenharmony_ci case AFE_AWB_END: 7788c2ecf20Sopenharmony_ci case AFE_AWB_CUR: 7798c2ecf20Sopenharmony_ci case AFE_VUL_END: 7808c2ecf20Sopenharmony_ci case AFE_VUL_CUR: 7818c2ecf20Sopenharmony_ci case AFE_MEMIF_MON0: 7828c2ecf20Sopenharmony_ci case AFE_MEMIF_MON1: 7838c2ecf20Sopenharmony_ci case AFE_MEMIF_MON2: 7848c2ecf20Sopenharmony_ci case AFE_MEMIF_MON3: 7858c2ecf20Sopenharmony_ci case AFE_MEMIF_MON4: 7868c2ecf20Sopenharmony_ci case AFE_MEMIF_MON5: 7878c2ecf20Sopenharmony_ci case AFE_MEMIF_MON6: 7888c2ecf20Sopenharmony_ci case AFE_MEMIF_MON7: 7898c2ecf20Sopenharmony_ci case AFE_MEMIF_MON8: 7908c2ecf20Sopenharmony_ci case AFE_MEMIF_MON9: 7918c2ecf20Sopenharmony_ci case AFE_ADDA_SRC_DEBUG_MON0: 7928c2ecf20Sopenharmony_ci case AFE_ADDA_SRC_DEBUG_MON1: 7938c2ecf20Sopenharmony_ci case AFE_ADDA_UL_SRC_MON0: 7948c2ecf20Sopenharmony_ci case AFE_ADDA_UL_SRC_MON1: 7958c2ecf20Sopenharmony_ci case AFE_SIDETONE_MON: 7968c2ecf20Sopenharmony_ci case AFE_SIDETONE_CON0: 7978c2ecf20Sopenharmony_ci case AFE_SIDETONE_COEFF: 7988c2ecf20Sopenharmony_ci case AFE_BUS_MON0: 7998c2ecf20Sopenharmony_ci case AFE_MRGIF_MON0: 8008c2ecf20Sopenharmony_ci case AFE_MRGIF_MON1: 8018c2ecf20Sopenharmony_ci case AFE_MRGIF_MON2: 8028c2ecf20Sopenharmony_ci case AFE_I2S_MON: 8038c2ecf20Sopenharmony_ci case AFE_DAC_MON: 8048c2ecf20Sopenharmony_ci case AFE_VUL2_END: 8058c2ecf20Sopenharmony_ci case AFE_VUL2_CUR: 8068c2ecf20Sopenharmony_ci case AFE_IRQ0_MCU_CNT_MON: 8078c2ecf20Sopenharmony_ci case AFE_IRQ6_MCU_CNT_MON: 8088c2ecf20Sopenharmony_ci case AFE_MOD_DAI_END: 8098c2ecf20Sopenharmony_ci case AFE_MOD_DAI_CUR: 8108c2ecf20Sopenharmony_ci case AFE_VUL_D2_END: 8118c2ecf20Sopenharmony_ci case AFE_VUL_D2_CUR: 8128c2ecf20Sopenharmony_ci case AFE_DL3_CUR: 8138c2ecf20Sopenharmony_ci case AFE_DL3_END: 8148c2ecf20Sopenharmony_ci case AFE_HDMI_OUT_CON0: 8158c2ecf20Sopenharmony_ci case AFE_HDMI_OUT_CUR: 8168c2ecf20Sopenharmony_ci case AFE_HDMI_OUT_END: 8178c2ecf20Sopenharmony_ci case AFE_IRQ3_MCU_CNT_MON: 8188c2ecf20Sopenharmony_ci case AFE_IRQ4_MCU_CNT_MON: 8198c2ecf20Sopenharmony_ci case AFE_IRQ_MCU_STATUS: 8208c2ecf20Sopenharmony_ci case AFE_IRQ_MCU_CLR: 8218c2ecf20Sopenharmony_ci case AFE_IRQ_MCU_MON2: 8228c2ecf20Sopenharmony_ci case AFE_IRQ1_MCU_CNT_MON: 8238c2ecf20Sopenharmony_ci case AFE_IRQ2_MCU_CNT_MON: 8248c2ecf20Sopenharmony_ci case AFE_IRQ1_MCU_EN_CNT_MON: 8258c2ecf20Sopenharmony_ci case AFE_IRQ5_MCU_CNT_MON: 8268c2ecf20Sopenharmony_ci case AFE_IRQ7_MCU_CNT_MON: 8278c2ecf20Sopenharmony_ci case AFE_GAIN1_CUR: 8288c2ecf20Sopenharmony_ci case AFE_GAIN2_CUR: 8298c2ecf20Sopenharmony_ci case AFE_SRAM_DELSEL_CON0: 8308c2ecf20Sopenharmony_ci case AFE_SRAM_DELSEL_CON2: 8318c2ecf20Sopenharmony_ci case AFE_SRAM_DELSEL_CON3: 8328c2ecf20Sopenharmony_ci case AFE_ASRC_2CH_CON12: 8338c2ecf20Sopenharmony_ci case AFE_ASRC_2CH_CON13: 8348c2ecf20Sopenharmony_ci case PCM_INTF_CON2: 8358c2ecf20Sopenharmony_ci case FPGA_CFG0: 8368c2ecf20Sopenharmony_ci case FPGA_CFG1: 8378c2ecf20Sopenharmony_ci case FPGA_CFG2: 8388c2ecf20Sopenharmony_ci case FPGA_CFG3: 8398c2ecf20Sopenharmony_ci case AUDIO_TOP_DBG_MON0: 8408c2ecf20Sopenharmony_ci case AUDIO_TOP_DBG_MON1: 8418c2ecf20Sopenharmony_ci case AFE_IRQ8_MCU_CNT_MON: 8428c2ecf20Sopenharmony_ci case AFE_IRQ11_MCU_CNT_MON: 8438c2ecf20Sopenharmony_ci case AFE_IRQ12_MCU_CNT_MON: 8448c2ecf20Sopenharmony_ci case AFE_CBIP_MON0: 8458c2ecf20Sopenharmony_ci case AFE_CBIP_SLV_MUX_MON0: 8468c2ecf20Sopenharmony_ci case AFE_CBIP_SLV_DECODER_MON0: 8478c2ecf20Sopenharmony_ci case AFE_ADDA6_SRC_DEBUG_MON0: 8488c2ecf20Sopenharmony_ci case AFE_ADD6A_UL_SRC_MON0: 8498c2ecf20Sopenharmony_ci case AFE_ADDA6_UL_SRC_MON1: 8508c2ecf20Sopenharmony_ci case AFE_DL1_CUR_MSB: 8518c2ecf20Sopenharmony_ci case AFE_DL2_CUR_MSB: 8528c2ecf20Sopenharmony_ci case AFE_AWB_CUR_MSB: 8538c2ecf20Sopenharmony_ci case AFE_VUL_CUR_MSB: 8548c2ecf20Sopenharmony_ci case AFE_VUL2_CUR_MSB: 8558c2ecf20Sopenharmony_ci case AFE_MOD_DAI_CUR_MSB: 8568c2ecf20Sopenharmony_ci case AFE_VUL_D2_CUR_MSB: 8578c2ecf20Sopenharmony_ci case AFE_DL3_CUR_MSB: 8588c2ecf20Sopenharmony_ci case AFE_HDMI_OUT_CUR_MSB: 8598c2ecf20Sopenharmony_ci case AFE_AWB2_END: 8608c2ecf20Sopenharmony_ci case AFE_AWB2_CUR: 8618c2ecf20Sopenharmony_ci case AFE_AWB2_CUR_MSB: 8628c2ecf20Sopenharmony_ci case AFE_ADDA_DL_SDM_FIFO_MON: 8638c2ecf20Sopenharmony_ci case AFE_ADDA_DL_SRC_LCH_MON: 8648c2ecf20Sopenharmony_ci case AFE_ADDA_DL_SRC_RCH_MON: 8658c2ecf20Sopenharmony_ci case AFE_ADDA_DL_SDM_OUT_MON: 8668c2ecf20Sopenharmony_ci case AFE_CONNSYS_I2S_MON: 8678c2ecf20Sopenharmony_ci case AFE_ASRC_2CH_CON0: 8688c2ecf20Sopenharmony_ci case AFE_ASRC_2CH_CON2: 8698c2ecf20Sopenharmony_ci case AFE_ASRC_2CH_CON3: 8708c2ecf20Sopenharmony_ci case AFE_ASRC_2CH_CON4: 8718c2ecf20Sopenharmony_ci case AFE_ASRC_2CH_CON5: 8728c2ecf20Sopenharmony_ci case AFE_ASRC_2CH_CON7: 8738c2ecf20Sopenharmony_ci case AFE_ASRC_2CH_CON8: 8748c2ecf20Sopenharmony_ci case AFE_MEMIF_MON12: 8758c2ecf20Sopenharmony_ci case AFE_MEMIF_MON13: 8768c2ecf20Sopenharmony_ci case AFE_MEMIF_MON14: 8778c2ecf20Sopenharmony_ci case AFE_MEMIF_MON15: 8788c2ecf20Sopenharmony_ci case AFE_MEMIF_MON16: 8798c2ecf20Sopenharmony_ci case AFE_MEMIF_MON17: 8808c2ecf20Sopenharmony_ci case AFE_MEMIF_MON18: 8818c2ecf20Sopenharmony_ci case AFE_MEMIF_MON19: 8828c2ecf20Sopenharmony_ci case AFE_MEMIF_MON20: 8838c2ecf20Sopenharmony_ci case AFE_MEMIF_MON21: 8848c2ecf20Sopenharmony_ci case AFE_MEMIF_MON22: 8858c2ecf20Sopenharmony_ci case AFE_MEMIF_MON23: 8868c2ecf20Sopenharmony_ci case AFE_MEMIF_MON24: 8878c2ecf20Sopenharmony_ci case AFE_ADDA_MTKAIF_MON0: 8888c2ecf20Sopenharmony_ci case AFE_ADDA_MTKAIF_MON1: 8898c2ecf20Sopenharmony_ci case AFE_AUD_PAD_TOP: 8908c2ecf20Sopenharmony_ci case AFE_GENERAL1_ASRC_2CH_CON0: 8918c2ecf20Sopenharmony_ci case AFE_GENERAL1_ASRC_2CH_CON2: 8928c2ecf20Sopenharmony_ci case AFE_GENERAL1_ASRC_2CH_CON3: 8938c2ecf20Sopenharmony_ci case AFE_GENERAL1_ASRC_2CH_CON4: 8948c2ecf20Sopenharmony_ci case AFE_GENERAL1_ASRC_2CH_CON5: 8958c2ecf20Sopenharmony_ci case AFE_GENERAL1_ASRC_2CH_CON7: 8968c2ecf20Sopenharmony_ci case AFE_GENERAL1_ASRC_2CH_CON8: 8978c2ecf20Sopenharmony_ci case AFE_GENERAL1_ASRC_2CH_CON12: 8988c2ecf20Sopenharmony_ci case AFE_GENERAL1_ASRC_2CH_CON13: 8998c2ecf20Sopenharmony_ci case AFE_GENERAL2_ASRC_2CH_CON0: 9008c2ecf20Sopenharmony_ci case AFE_GENERAL2_ASRC_2CH_CON2: 9018c2ecf20Sopenharmony_ci case AFE_GENERAL2_ASRC_2CH_CON3: 9028c2ecf20Sopenharmony_ci case AFE_GENERAL2_ASRC_2CH_CON4: 9038c2ecf20Sopenharmony_ci case AFE_GENERAL2_ASRC_2CH_CON5: 9048c2ecf20Sopenharmony_ci case AFE_GENERAL2_ASRC_2CH_CON7: 9058c2ecf20Sopenharmony_ci case AFE_GENERAL2_ASRC_2CH_CON8: 9068c2ecf20Sopenharmony_ci case AFE_GENERAL2_ASRC_2CH_CON12: 9078c2ecf20Sopenharmony_ci case AFE_GENERAL2_ASRC_2CH_CON13: 9088c2ecf20Sopenharmony_ci return true; 9098c2ecf20Sopenharmony_ci default: 9108c2ecf20Sopenharmony_ci return false; 9118c2ecf20Sopenharmony_ci }; 9128c2ecf20Sopenharmony_ci} 9138c2ecf20Sopenharmony_ci 9148c2ecf20Sopenharmony_cistatic const struct regmap_config mt8183_afe_regmap_config = { 9158c2ecf20Sopenharmony_ci .reg_bits = 32, 9168c2ecf20Sopenharmony_ci .reg_stride = 4, 9178c2ecf20Sopenharmony_ci .val_bits = 32, 9188c2ecf20Sopenharmony_ci 9198c2ecf20Sopenharmony_ci .volatile_reg = mt8183_is_volatile_reg, 9208c2ecf20Sopenharmony_ci 9218c2ecf20Sopenharmony_ci .max_register = AFE_MAX_REGISTER, 9228c2ecf20Sopenharmony_ci .num_reg_defaults_raw = AFE_MAX_REGISTER, 9238c2ecf20Sopenharmony_ci 9248c2ecf20Sopenharmony_ci .cache_type = REGCACHE_FLAT, 9258c2ecf20Sopenharmony_ci}; 9268c2ecf20Sopenharmony_ci 9278c2ecf20Sopenharmony_cistatic irqreturn_t mt8183_afe_irq_handler(int irq_id, void *dev) 9288c2ecf20Sopenharmony_ci{ 9298c2ecf20Sopenharmony_ci struct mtk_base_afe *afe = dev; 9308c2ecf20Sopenharmony_ci struct mtk_base_afe_irq *irq; 9318c2ecf20Sopenharmony_ci unsigned int status; 9328c2ecf20Sopenharmony_ci unsigned int status_mcu; 9338c2ecf20Sopenharmony_ci unsigned int mcu_en; 9348c2ecf20Sopenharmony_ci int ret; 9358c2ecf20Sopenharmony_ci int i; 9368c2ecf20Sopenharmony_ci irqreturn_t irq_ret = IRQ_HANDLED; 9378c2ecf20Sopenharmony_ci 9388c2ecf20Sopenharmony_ci /* get irq that is sent to MCU */ 9398c2ecf20Sopenharmony_ci regmap_read(afe->regmap, AFE_IRQ_MCU_EN, &mcu_en); 9408c2ecf20Sopenharmony_ci 9418c2ecf20Sopenharmony_ci ret = regmap_read(afe->regmap, AFE_IRQ_MCU_STATUS, &status); 9428c2ecf20Sopenharmony_ci /* only care IRQ which is sent to MCU */ 9438c2ecf20Sopenharmony_ci status_mcu = status & mcu_en & AFE_IRQ_STATUS_BITS; 9448c2ecf20Sopenharmony_ci 9458c2ecf20Sopenharmony_ci if (ret || status_mcu == 0) { 9468c2ecf20Sopenharmony_ci dev_err(afe->dev, "%s(), irq status err, ret %d, status 0x%x, mcu_en 0x%x\n", 9478c2ecf20Sopenharmony_ci __func__, ret, status, mcu_en); 9488c2ecf20Sopenharmony_ci 9498c2ecf20Sopenharmony_ci irq_ret = IRQ_NONE; 9508c2ecf20Sopenharmony_ci goto err_irq; 9518c2ecf20Sopenharmony_ci } 9528c2ecf20Sopenharmony_ci 9538c2ecf20Sopenharmony_ci for (i = 0; i < MT8183_MEMIF_NUM; i++) { 9548c2ecf20Sopenharmony_ci struct mtk_base_afe_memif *memif = &afe->memif[i]; 9558c2ecf20Sopenharmony_ci 9568c2ecf20Sopenharmony_ci if (!memif->substream) 9578c2ecf20Sopenharmony_ci continue; 9588c2ecf20Sopenharmony_ci 9598c2ecf20Sopenharmony_ci if (memif->irq_usage < 0) 9608c2ecf20Sopenharmony_ci continue; 9618c2ecf20Sopenharmony_ci 9628c2ecf20Sopenharmony_ci irq = &afe->irqs[memif->irq_usage]; 9638c2ecf20Sopenharmony_ci 9648c2ecf20Sopenharmony_ci if (status_mcu & (1 << irq->irq_data->irq_en_shift)) 9658c2ecf20Sopenharmony_ci snd_pcm_period_elapsed(memif->substream); 9668c2ecf20Sopenharmony_ci } 9678c2ecf20Sopenharmony_ci 9688c2ecf20Sopenharmony_cierr_irq: 9698c2ecf20Sopenharmony_ci /* clear irq */ 9708c2ecf20Sopenharmony_ci regmap_write(afe->regmap, 9718c2ecf20Sopenharmony_ci AFE_IRQ_MCU_CLR, 9728c2ecf20Sopenharmony_ci status_mcu); 9738c2ecf20Sopenharmony_ci 9748c2ecf20Sopenharmony_ci return irq_ret; 9758c2ecf20Sopenharmony_ci} 9768c2ecf20Sopenharmony_ci 9778c2ecf20Sopenharmony_cistatic int mt8183_afe_runtime_suspend(struct device *dev) 9788c2ecf20Sopenharmony_ci{ 9798c2ecf20Sopenharmony_ci struct mtk_base_afe *afe = dev_get_drvdata(dev); 9808c2ecf20Sopenharmony_ci struct mt8183_afe_private *afe_priv = afe->platform_priv; 9818c2ecf20Sopenharmony_ci unsigned int value; 9828c2ecf20Sopenharmony_ci int ret; 9838c2ecf20Sopenharmony_ci 9848c2ecf20Sopenharmony_ci if (!afe->regmap || afe_priv->pm_runtime_bypass_reg_ctl) 9858c2ecf20Sopenharmony_ci goto skip_regmap; 9868c2ecf20Sopenharmony_ci 9878c2ecf20Sopenharmony_ci /* disable AFE */ 9888c2ecf20Sopenharmony_ci regmap_update_bits(afe->regmap, AFE_DAC_CON0, AFE_ON_MASK_SFT, 0x0); 9898c2ecf20Sopenharmony_ci 9908c2ecf20Sopenharmony_ci ret = regmap_read_poll_timeout(afe->regmap, 9918c2ecf20Sopenharmony_ci AFE_DAC_MON, 9928c2ecf20Sopenharmony_ci value, 9938c2ecf20Sopenharmony_ci (value & AFE_ON_RETM_MASK_SFT) == 0, 9948c2ecf20Sopenharmony_ci 20, 9958c2ecf20Sopenharmony_ci 1 * 1000 * 1000); 9968c2ecf20Sopenharmony_ci if (ret) 9978c2ecf20Sopenharmony_ci dev_warn(afe->dev, "%s(), ret %d\n", __func__, ret); 9988c2ecf20Sopenharmony_ci 9998c2ecf20Sopenharmony_ci /* make sure all irq status are cleared, twice intended */ 10008c2ecf20Sopenharmony_ci regmap_update_bits(afe->regmap, AFE_IRQ_MCU_CLR, 0xffff, 0xffff); 10018c2ecf20Sopenharmony_ci regmap_update_bits(afe->regmap, AFE_IRQ_MCU_CLR, 0xffff, 0xffff); 10028c2ecf20Sopenharmony_ci 10038c2ecf20Sopenharmony_ci /* cache only */ 10048c2ecf20Sopenharmony_ci regcache_cache_only(afe->regmap, true); 10058c2ecf20Sopenharmony_ci regcache_mark_dirty(afe->regmap); 10068c2ecf20Sopenharmony_ci 10078c2ecf20Sopenharmony_ciskip_regmap: 10088c2ecf20Sopenharmony_ci return mt8183_afe_disable_clock(afe); 10098c2ecf20Sopenharmony_ci} 10108c2ecf20Sopenharmony_ci 10118c2ecf20Sopenharmony_cistatic int mt8183_afe_runtime_resume(struct device *dev) 10128c2ecf20Sopenharmony_ci{ 10138c2ecf20Sopenharmony_ci struct mtk_base_afe *afe = dev_get_drvdata(dev); 10148c2ecf20Sopenharmony_ci struct mt8183_afe_private *afe_priv = afe->platform_priv; 10158c2ecf20Sopenharmony_ci int ret; 10168c2ecf20Sopenharmony_ci 10178c2ecf20Sopenharmony_ci ret = mt8183_afe_enable_clock(afe); 10188c2ecf20Sopenharmony_ci if (ret) 10198c2ecf20Sopenharmony_ci return ret; 10208c2ecf20Sopenharmony_ci 10218c2ecf20Sopenharmony_ci if (!afe->regmap || afe_priv->pm_runtime_bypass_reg_ctl) 10228c2ecf20Sopenharmony_ci goto skip_regmap; 10238c2ecf20Sopenharmony_ci 10248c2ecf20Sopenharmony_ci regcache_cache_only(afe->regmap, false); 10258c2ecf20Sopenharmony_ci regcache_sync(afe->regmap); 10268c2ecf20Sopenharmony_ci 10278c2ecf20Sopenharmony_ci /* enable audio sys DCM for power saving */ 10288c2ecf20Sopenharmony_ci regmap_update_bits(afe->regmap, AUDIO_TOP_CON0, 0x1 << 29, 0x1 << 29); 10298c2ecf20Sopenharmony_ci 10308c2ecf20Sopenharmony_ci /* force cpu use 8_24 format when writing 32bit data */ 10318c2ecf20Sopenharmony_ci regmap_update_bits(afe->regmap, AFE_MEMIF_MSB, 10328c2ecf20Sopenharmony_ci CPU_HD_ALIGN_MASK_SFT, 0 << CPU_HD_ALIGN_SFT); 10338c2ecf20Sopenharmony_ci 10348c2ecf20Sopenharmony_ci /* set all output port to 24bit */ 10358c2ecf20Sopenharmony_ci regmap_write(afe->regmap, AFE_CONN_24BIT, 0xffffffff); 10368c2ecf20Sopenharmony_ci regmap_write(afe->regmap, AFE_CONN_24BIT_1, 0xffffffff); 10378c2ecf20Sopenharmony_ci 10388c2ecf20Sopenharmony_ci /* enable AFE */ 10398c2ecf20Sopenharmony_ci regmap_update_bits(afe->regmap, AFE_DAC_CON0, 0x1, 0x1); 10408c2ecf20Sopenharmony_ci 10418c2ecf20Sopenharmony_ciskip_regmap: 10428c2ecf20Sopenharmony_ci return 0; 10438c2ecf20Sopenharmony_ci} 10448c2ecf20Sopenharmony_ci 10458c2ecf20Sopenharmony_cistatic int mt8183_afe_component_probe(struct snd_soc_component *component) 10468c2ecf20Sopenharmony_ci{ 10478c2ecf20Sopenharmony_ci return mtk_afe_add_sub_dai_control(component); 10488c2ecf20Sopenharmony_ci} 10498c2ecf20Sopenharmony_ci 10508c2ecf20Sopenharmony_cistatic const struct snd_soc_component_driver mt8183_afe_component = { 10518c2ecf20Sopenharmony_ci .name = AFE_PCM_NAME, 10528c2ecf20Sopenharmony_ci .probe = mt8183_afe_component_probe, 10538c2ecf20Sopenharmony_ci .pointer = mtk_afe_pcm_pointer, 10548c2ecf20Sopenharmony_ci .pcm_construct = mtk_afe_pcm_new, 10558c2ecf20Sopenharmony_ci}; 10568c2ecf20Sopenharmony_ci 10578c2ecf20Sopenharmony_cistatic int mt8183_dai_memif_register(struct mtk_base_afe *afe) 10588c2ecf20Sopenharmony_ci{ 10598c2ecf20Sopenharmony_ci struct mtk_base_afe_dai *dai; 10608c2ecf20Sopenharmony_ci 10618c2ecf20Sopenharmony_ci dai = devm_kzalloc(afe->dev, sizeof(*dai), GFP_KERNEL); 10628c2ecf20Sopenharmony_ci if (!dai) 10638c2ecf20Sopenharmony_ci return -ENOMEM; 10648c2ecf20Sopenharmony_ci 10658c2ecf20Sopenharmony_ci list_add(&dai->list, &afe->sub_dais); 10668c2ecf20Sopenharmony_ci 10678c2ecf20Sopenharmony_ci dai->dai_drivers = mt8183_memif_dai_driver; 10688c2ecf20Sopenharmony_ci dai->num_dai_drivers = ARRAY_SIZE(mt8183_memif_dai_driver); 10698c2ecf20Sopenharmony_ci 10708c2ecf20Sopenharmony_ci dai->dapm_widgets = mt8183_memif_widgets; 10718c2ecf20Sopenharmony_ci dai->num_dapm_widgets = ARRAY_SIZE(mt8183_memif_widgets); 10728c2ecf20Sopenharmony_ci dai->dapm_routes = mt8183_memif_routes; 10738c2ecf20Sopenharmony_ci dai->num_dapm_routes = ARRAY_SIZE(mt8183_memif_routes); 10748c2ecf20Sopenharmony_ci return 0; 10758c2ecf20Sopenharmony_ci} 10768c2ecf20Sopenharmony_ci 10778c2ecf20Sopenharmony_citypedef int (*dai_register_cb)(struct mtk_base_afe *); 10788c2ecf20Sopenharmony_cistatic const dai_register_cb dai_register_cbs[] = { 10798c2ecf20Sopenharmony_ci mt8183_dai_adda_register, 10808c2ecf20Sopenharmony_ci mt8183_dai_i2s_register, 10818c2ecf20Sopenharmony_ci mt8183_dai_pcm_register, 10828c2ecf20Sopenharmony_ci mt8183_dai_tdm_register, 10838c2ecf20Sopenharmony_ci mt8183_dai_hostless_register, 10848c2ecf20Sopenharmony_ci mt8183_dai_memif_register, 10858c2ecf20Sopenharmony_ci}; 10868c2ecf20Sopenharmony_ci 10878c2ecf20Sopenharmony_cistatic int mt8183_afe_pcm_dev_probe(struct platform_device *pdev) 10888c2ecf20Sopenharmony_ci{ 10898c2ecf20Sopenharmony_ci struct mtk_base_afe *afe; 10908c2ecf20Sopenharmony_ci struct mt8183_afe_private *afe_priv; 10918c2ecf20Sopenharmony_ci struct device *dev; 10928c2ecf20Sopenharmony_ci struct reset_control *rstc; 10938c2ecf20Sopenharmony_ci int i, irq_id, ret; 10948c2ecf20Sopenharmony_ci 10958c2ecf20Sopenharmony_ci afe = devm_kzalloc(&pdev->dev, sizeof(*afe), GFP_KERNEL); 10968c2ecf20Sopenharmony_ci if (!afe) 10978c2ecf20Sopenharmony_ci return -ENOMEM; 10988c2ecf20Sopenharmony_ci platform_set_drvdata(pdev, afe); 10998c2ecf20Sopenharmony_ci 11008c2ecf20Sopenharmony_ci afe->platform_priv = devm_kzalloc(&pdev->dev, sizeof(*afe_priv), 11018c2ecf20Sopenharmony_ci GFP_KERNEL); 11028c2ecf20Sopenharmony_ci if (!afe->platform_priv) 11038c2ecf20Sopenharmony_ci return -ENOMEM; 11048c2ecf20Sopenharmony_ci 11058c2ecf20Sopenharmony_ci afe_priv = afe->platform_priv; 11068c2ecf20Sopenharmony_ci afe->dev = &pdev->dev; 11078c2ecf20Sopenharmony_ci dev = afe->dev; 11088c2ecf20Sopenharmony_ci 11098c2ecf20Sopenharmony_ci /* initial audio related clock */ 11108c2ecf20Sopenharmony_ci ret = mt8183_init_clock(afe); 11118c2ecf20Sopenharmony_ci if (ret) { 11128c2ecf20Sopenharmony_ci dev_err(dev, "init clock error\n"); 11138c2ecf20Sopenharmony_ci return ret; 11148c2ecf20Sopenharmony_ci } 11158c2ecf20Sopenharmony_ci 11168c2ecf20Sopenharmony_ci pm_runtime_enable(dev); 11178c2ecf20Sopenharmony_ci 11188c2ecf20Sopenharmony_ci /* regmap init */ 11198c2ecf20Sopenharmony_ci afe->regmap = syscon_node_to_regmap(dev->parent->of_node); 11208c2ecf20Sopenharmony_ci if (IS_ERR(afe->regmap)) { 11218c2ecf20Sopenharmony_ci dev_err(dev, "could not get regmap from parent\n"); 11228c2ecf20Sopenharmony_ci ret = PTR_ERR(afe->regmap); 11238c2ecf20Sopenharmony_ci goto err_pm_disable; 11248c2ecf20Sopenharmony_ci } 11258c2ecf20Sopenharmony_ci ret = regmap_attach_dev(dev, afe->regmap, &mt8183_afe_regmap_config); 11268c2ecf20Sopenharmony_ci if (ret) { 11278c2ecf20Sopenharmony_ci dev_warn(dev, "regmap_attach_dev fail, ret %d\n", ret); 11288c2ecf20Sopenharmony_ci goto err_pm_disable; 11298c2ecf20Sopenharmony_ci } 11308c2ecf20Sopenharmony_ci 11318c2ecf20Sopenharmony_ci rstc = devm_reset_control_get(dev, "audiosys"); 11328c2ecf20Sopenharmony_ci if (IS_ERR(rstc)) { 11338c2ecf20Sopenharmony_ci ret = PTR_ERR(rstc); 11348c2ecf20Sopenharmony_ci dev_err(dev, "could not get audiosys reset:%d\n", ret); 11358c2ecf20Sopenharmony_ci goto err_pm_disable; 11368c2ecf20Sopenharmony_ci } 11378c2ecf20Sopenharmony_ci 11388c2ecf20Sopenharmony_ci ret = reset_control_reset(rstc); 11398c2ecf20Sopenharmony_ci if (ret) { 11408c2ecf20Sopenharmony_ci dev_err(dev, "failed to trigger audio reset:%d\n", ret); 11418c2ecf20Sopenharmony_ci goto err_pm_disable; 11428c2ecf20Sopenharmony_ci } 11438c2ecf20Sopenharmony_ci 11448c2ecf20Sopenharmony_ci /* enable clock for regcache get default value from hw */ 11458c2ecf20Sopenharmony_ci afe_priv->pm_runtime_bypass_reg_ctl = true; 11468c2ecf20Sopenharmony_ci pm_runtime_get_sync(&pdev->dev); 11478c2ecf20Sopenharmony_ci 11488c2ecf20Sopenharmony_ci ret = regmap_reinit_cache(afe->regmap, &mt8183_afe_regmap_config); 11498c2ecf20Sopenharmony_ci if (ret) { 11508c2ecf20Sopenharmony_ci dev_err(dev, "regmap_reinit_cache fail, ret %d\n", ret); 11518c2ecf20Sopenharmony_ci goto err_pm_disable; 11528c2ecf20Sopenharmony_ci } 11538c2ecf20Sopenharmony_ci 11548c2ecf20Sopenharmony_ci pm_runtime_put_sync(&pdev->dev); 11558c2ecf20Sopenharmony_ci afe_priv->pm_runtime_bypass_reg_ctl = false; 11568c2ecf20Sopenharmony_ci 11578c2ecf20Sopenharmony_ci regcache_cache_only(afe->regmap, true); 11588c2ecf20Sopenharmony_ci regcache_mark_dirty(afe->regmap); 11598c2ecf20Sopenharmony_ci 11608c2ecf20Sopenharmony_ci /* init memif */ 11618c2ecf20Sopenharmony_ci afe->memif_size = MT8183_MEMIF_NUM; 11628c2ecf20Sopenharmony_ci afe->memif = devm_kcalloc(dev, afe->memif_size, sizeof(*afe->memif), 11638c2ecf20Sopenharmony_ci GFP_KERNEL); 11648c2ecf20Sopenharmony_ci if (!afe->memif) { 11658c2ecf20Sopenharmony_ci ret = -ENOMEM; 11668c2ecf20Sopenharmony_ci goto err_pm_disable; 11678c2ecf20Sopenharmony_ci } 11688c2ecf20Sopenharmony_ci 11698c2ecf20Sopenharmony_ci for (i = 0; i < afe->memif_size; i++) { 11708c2ecf20Sopenharmony_ci afe->memif[i].data = &memif_data[i]; 11718c2ecf20Sopenharmony_ci afe->memif[i].irq_usage = -1; 11728c2ecf20Sopenharmony_ci } 11738c2ecf20Sopenharmony_ci 11748c2ecf20Sopenharmony_ci afe->memif[MT8183_MEMIF_HDMI].irq_usage = MT8183_IRQ_8; 11758c2ecf20Sopenharmony_ci afe->memif[MT8183_MEMIF_HDMI].const_irq = 1; 11768c2ecf20Sopenharmony_ci 11778c2ecf20Sopenharmony_ci mutex_init(&afe->irq_alloc_lock); 11788c2ecf20Sopenharmony_ci 11798c2ecf20Sopenharmony_ci /* init memif */ 11808c2ecf20Sopenharmony_ci /* irq initialize */ 11818c2ecf20Sopenharmony_ci afe->irqs_size = MT8183_IRQ_NUM; 11828c2ecf20Sopenharmony_ci afe->irqs = devm_kcalloc(dev, afe->irqs_size, sizeof(*afe->irqs), 11838c2ecf20Sopenharmony_ci GFP_KERNEL); 11848c2ecf20Sopenharmony_ci if (!afe->irqs) { 11858c2ecf20Sopenharmony_ci ret = -ENOMEM; 11868c2ecf20Sopenharmony_ci goto err_pm_disable; 11878c2ecf20Sopenharmony_ci } 11888c2ecf20Sopenharmony_ci 11898c2ecf20Sopenharmony_ci for (i = 0; i < afe->irqs_size; i++) 11908c2ecf20Sopenharmony_ci afe->irqs[i].irq_data = &irq_data[i]; 11918c2ecf20Sopenharmony_ci 11928c2ecf20Sopenharmony_ci /* request irq */ 11938c2ecf20Sopenharmony_ci irq_id = platform_get_irq(pdev, 0); 11948c2ecf20Sopenharmony_ci if (irq_id < 0) { 11958c2ecf20Sopenharmony_ci ret = irq_id; 11968c2ecf20Sopenharmony_ci goto err_pm_disable; 11978c2ecf20Sopenharmony_ci } 11988c2ecf20Sopenharmony_ci 11998c2ecf20Sopenharmony_ci ret = devm_request_irq(dev, irq_id, mt8183_afe_irq_handler, 12008c2ecf20Sopenharmony_ci IRQF_TRIGGER_NONE, "asys-isr", (void *)afe); 12018c2ecf20Sopenharmony_ci if (ret) { 12028c2ecf20Sopenharmony_ci dev_err(dev, "could not request_irq for asys-isr\n"); 12038c2ecf20Sopenharmony_ci goto err_pm_disable; 12048c2ecf20Sopenharmony_ci } 12058c2ecf20Sopenharmony_ci 12068c2ecf20Sopenharmony_ci /* init sub_dais */ 12078c2ecf20Sopenharmony_ci INIT_LIST_HEAD(&afe->sub_dais); 12088c2ecf20Sopenharmony_ci 12098c2ecf20Sopenharmony_ci for (i = 0; i < ARRAY_SIZE(dai_register_cbs); i++) { 12108c2ecf20Sopenharmony_ci ret = dai_register_cbs[i](afe); 12118c2ecf20Sopenharmony_ci if (ret) { 12128c2ecf20Sopenharmony_ci dev_warn(afe->dev, "dai register i %d fail, ret %d\n", 12138c2ecf20Sopenharmony_ci i, ret); 12148c2ecf20Sopenharmony_ci goto err_pm_disable; 12158c2ecf20Sopenharmony_ci } 12168c2ecf20Sopenharmony_ci } 12178c2ecf20Sopenharmony_ci 12188c2ecf20Sopenharmony_ci /* init dai_driver and component_driver */ 12198c2ecf20Sopenharmony_ci ret = mtk_afe_combine_sub_dai(afe); 12208c2ecf20Sopenharmony_ci if (ret) { 12218c2ecf20Sopenharmony_ci dev_warn(afe->dev, "mtk_afe_combine_sub_dai fail, ret %d\n", 12228c2ecf20Sopenharmony_ci ret); 12238c2ecf20Sopenharmony_ci goto err_pm_disable; 12248c2ecf20Sopenharmony_ci } 12258c2ecf20Sopenharmony_ci 12268c2ecf20Sopenharmony_ci afe->mtk_afe_hardware = &mt8183_afe_hardware; 12278c2ecf20Sopenharmony_ci afe->memif_fs = mt8183_memif_fs; 12288c2ecf20Sopenharmony_ci afe->irq_fs = mt8183_irq_fs; 12298c2ecf20Sopenharmony_ci 12308c2ecf20Sopenharmony_ci afe->runtime_resume = mt8183_afe_runtime_resume; 12318c2ecf20Sopenharmony_ci afe->runtime_suspend = mt8183_afe_runtime_suspend; 12328c2ecf20Sopenharmony_ci 12338c2ecf20Sopenharmony_ci /* register component */ 12348c2ecf20Sopenharmony_ci ret = devm_snd_soc_register_component(&pdev->dev, 12358c2ecf20Sopenharmony_ci &mt8183_afe_component, 12368c2ecf20Sopenharmony_ci NULL, 0); 12378c2ecf20Sopenharmony_ci if (ret) { 12388c2ecf20Sopenharmony_ci dev_warn(dev, "err_platform\n"); 12398c2ecf20Sopenharmony_ci goto err_pm_disable; 12408c2ecf20Sopenharmony_ci } 12418c2ecf20Sopenharmony_ci 12428c2ecf20Sopenharmony_ci ret = devm_snd_soc_register_component(afe->dev, 12438c2ecf20Sopenharmony_ci &mt8183_afe_pcm_dai_component, 12448c2ecf20Sopenharmony_ci afe->dai_drivers, 12458c2ecf20Sopenharmony_ci afe->num_dai_drivers); 12468c2ecf20Sopenharmony_ci if (ret) { 12478c2ecf20Sopenharmony_ci dev_warn(dev, "err_dai_component\n"); 12488c2ecf20Sopenharmony_ci goto err_pm_disable; 12498c2ecf20Sopenharmony_ci } 12508c2ecf20Sopenharmony_ci 12518c2ecf20Sopenharmony_ci return ret; 12528c2ecf20Sopenharmony_ci 12538c2ecf20Sopenharmony_cierr_pm_disable: 12548c2ecf20Sopenharmony_ci pm_runtime_disable(&pdev->dev); 12558c2ecf20Sopenharmony_ci return ret; 12568c2ecf20Sopenharmony_ci} 12578c2ecf20Sopenharmony_ci 12588c2ecf20Sopenharmony_cistatic int mt8183_afe_pcm_dev_remove(struct platform_device *pdev) 12598c2ecf20Sopenharmony_ci{ 12608c2ecf20Sopenharmony_ci pm_runtime_disable(&pdev->dev); 12618c2ecf20Sopenharmony_ci if (!pm_runtime_status_suspended(&pdev->dev)) 12628c2ecf20Sopenharmony_ci mt8183_afe_runtime_suspend(&pdev->dev); 12638c2ecf20Sopenharmony_ci 12648c2ecf20Sopenharmony_ci return 0; 12658c2ecf20Sopenharmony_ci} 12668c2ecf20Sopenharmony_ci 12678c2ecf20Sopenharmony_cistatic const struct of_device_id mt8183_afe_pcm_dt_match[] = { 12688c2ecf20Sopenharmony_ci { .compatible = "mediatek,mt8183-audio", }, 12698c2ecf20Sopenharmony_ci {}, 12708c2ecf20Sopenharmony_ci}; 12718c2ecf20Sopenharmony_ciMODULE_DEVICE_TABLE(of, mt8183_afe_pcm_dt_match); 12728c2ecf20Sopenharmony_ci 12738c2ecf20Sopenharmony_cistatic const struct dev_pm_ops mt8183_afe_pm_ops = { 12748c2ecf20Sopenharmony_ci SET_RUNTIME_PM_OPS(mt8183_afe_runtime_suspend, 12758c2ecf20Sopenharmony_ci mt8183_afe_runtime_resume, NULL) 12768c2ecf20Sopenharmony_ci}; 12778c2ecf20Sopenharmony_ci 12788c2ecf20Sopenharmony_cistatic struct platform_driver mt8183_afe_pcm_driver = { 12798c2ecf20Sopenharmony_ci .driver = { 12808c2ecf20Sopenharmony_ci .name = "mt8183-audio", 12818c2ecf20Sopenharmony_ci .of_match_table = mt8183_afe_pcm_dt_match, 12828c2ecf20Sopenharmony_ci#ifdef CONFIG_PM 12838c2ecf20Sopenharmony_ci .pm = &mt8183_afe_pm_ops, 12848c2ecf20Sopenharmony_ci#endif 12858c2ecf20Sopenharmony_ci }, 12868c2ecf20Sopenharmony_ci .probe = mt8183_afe_pcm_dev_probe, 12878c2ecf20Sopenharmony_ci .remove = mt8183_afe_pcm_dev_remove, 12888c2ecf20Sopenharmony_ci}; 12898c2ecf20Sopenharmony_ci 12908c2ecf20Sopenharmony_cimodule_platform_driver(mt8183_afe_pcm_driver); 12918c2ecf20Sopenharmony_ci 12928c2ecf20Sopenharmony_ciMODULE_DESCRIPTION("Mediatek ALSA SoC AFE platform driver for 8183"); 12938c2ecf20Sopenharmony_ciMODULE_AUTHOR("KaiChieh Chuang <kaichieh.chuang@mediatek.com>"); 12948c2ecf20Sopenharmony_ciMODULE_LICENSE("GPL v2"); 1295