14135d8b6SKai Chieh Chuang // SPDX-License-Identifier: GPL-2.0
24135d8b6SKai Chieh Chuang //
34135d8b6SKai Chieh Chuang // Mediatek ALSA SoC AFE platform driver for 6797
44135d8b6SKai Chieh Chuang //
54135d8b6SKai Chieh Chuang // Copyright (c) 2018 MediaTek Inc.
64135d8b6SKai Chieh Chuang // Author: KaiChieh Chuang <kaichieh.chuang@mediatek.com>
73901b9fcSKai Chieh Chuang
83901b9fcSKai Chieh Chuang #include <linux/delay.h>
93901b9fcSKai Chieh Chuang #include <linux/module.h>
103901b9fcSKai Chieh Chuang #include <linux/mfd/syscon.h>
113901b9fcSKai Chieh Chuang #include <linux/of.h>
123901b9fcSKai Chieh Chuang #include <linux/of_address.h>
133901b9fcSKai Chieh Chuang #include <linux/pm_runtime.h>
143901b9fcSKai Chieh Chuang
153901b9fcSKai Chieh Chuang #include "mt6797-afe-common.h"
163901b9fcSKai Chieh Chuang #include "mt6797-afe-clk.h"
173901b9fcSKai Chieh Chuang #include "mt6797-interconnection.h"
183901b9fcSKai Chieh Chuang #include "mt6797-reg.h"
193901b9fcSKai Chieh Chuang #include "../common/mtk-afe-platform-driver.h"
203901b9fcSKai Chieh Chuang #include "../common/mtk-afe-fe-dai.h"
213901b9fcSKai Chieh Chuang
223901b9fcSKai Chieh Chuang enum {
233901b9fcSKai Chieh Chuang MTK_AFE_RATE_8K = 0,
243901b9fcSKai Chieh Chuang MTK_AFE_RATE_11K = 1,
253901b9fcSKai Chieh Chuang MTK_AFE_RATE_12K = 2,
263901b9fcSKai Chieh Chuang MTK_AFE_RATE_384K = 3,
273901b9fcSKai Chieh Chuang MTK_AFE_RATE_16K = 4,
283901b9fcSKai Chieh Chuang MTK_AFE_RATE_22K = 5,
293901b9fcSKai Chieh Chuang MTK_AFE_RATE_24K = 6,
303901b9fcSKai Chieh Chuang MTK_AFE_RATE_130K = 7,
313901b9fcSKai Chieh Chuang MTK_AFE_RATE_32K = 8,
323901b9fcSKai Chieh Chuang MTK_AFE_RATE_44K = 9,
333901b9fcSKai Chieh Chuang MTK_AFE_RATE_48K = 10,
343901b9fcSKai Chieh Chuang MTK_AFE_RATE_88K = 11,
353901b9fcSKai Chieh Chuang MTK_AFE_RATE_96K = 12,
363901b9fcSKai Chieh Chuang MTK_AFE_RATE_174K = 13,
373901b9fcSKai Chieh Chuang MTK_AFE_RATE_192K = 14,
383901b9fcSKai Chieh Chuang MTK_AFE_RATE_260K = 15,
393901b9fcSKai Chieh Chuang };
403901b9fcSKai Chieh Chuang
413901b9fcSKai Chieh Chuang enum {
423901b9fcSKai Chieh Chuang MTK_AFE_DAI_MEMIF_RATE_8K = 0,
433901b9fcSKai Chieh Chuang MTK_AFE_DAI_MEMIF_RATE_16K = 1,
443901b9fcSKai Chieh Chuang MTK_AFE_DAI_MEMIF_RATE_32K = 2,
453901b9fcSKai Chieh Chuang };
463901b9fcSKai Chieh Chuang
473901b9fcSKai Chieh Chuang enum {
483901b9fcSKai Chieh Chuang MTK_AFE_PCM_RATE_8K = 0,
493901b9fcSKai Chieh Chuang MTK_AFE_PCM_RATE_16K = 1,
503901b9fcSKai Chieh Chuang MTK_AFE_PCM_RATE_32K = 2,
513901b9fcSKai Chieh Chuang MTK_AFE_PCM_RATE_48K = 3,
523901b9fcSKai Chieh Chuang };
533901b9fcSKai Chieh Chuang
mt6797_general_rate_transform(struct device * dev,unsigned int rate)543901b9fcSKai Chieh Chuang unsigned int mt6797_general_rate_transform(struct device *dev,
553901b9fcSKai Chieh Chuang unsigned int rate)
563901b9fcSKai Chieh Chuang {
573901b9fcSKai Chieh Chuang switch (rate) {
583901b9fcSKai Chieh Chuang case 8000:
593901b9fcSKai Chieh Chuang return MTK_AFE_RATE_8K;
603901b9fcSKai Chieh Chuang case 11025:
613901b9fcSKai Chieh Chuang return MTK_AFE_RATE_11K;
623901b9fcSKai Chieh Chuang case 12000:
633901b9fcSKai Chieh Chuang return MTK_AFE_RATE_12K;
643901b9fcSKai Chieh Chuang case 16000:
653901b9fcSKai Chieh Chuang return MTK_AFE_RATE_16K;
663901b9fcSKai Chieh Chuang case 22050:
673901b9fcSKai Chieh Chuang return MTK_AFE_RATE_22K;
683901b9fcSKai Chieh Chuang case 24000:
693901b9fcSKai Chieh Chuang return MTK_AFE_RATE_24K;
703901b9fcSKai Chieh Chuang case 32000:
713901b9fcSKai Chieh Chuang return MTK_AFE_RATE_32K;
723901b9fcSKai Chieh Chuang case 44100:
733901b9fcSKai Chieh Chuang return MTK_AFE_RATE_44K;
743901b9fcSKai Chieh Chuang case 48000:
753901b9fcSKai Chieh Chuang return MTK_AFE_RATE_48K;
763901b9fcSKai Chieh Chuang case 88200:
773901b9fcSKai Chieh Chuang return MTK_AFE_RATE_88K;
783901b9fcSKai Chieh Chuang case 96000:
793901b9fcSKai Chieh Chuang return MTK_AFE_RATE_96K;
803901b9fcSKai Chieh Chuang case 130000:
813901b9fcSKai Chieh Chuang return MTK_AFE_RATE_130K;
823901b9fcSKai Chieh Chuang case 176400:
833901b9fcSKai Chieh Chuang return MTK_AFE_RATE_174K;
843901b9fcSKai Chieh Chuang case 192000:
853901b9fcSKai Chieh Chuang return MTK_AFE_RATE_192K;
863901b9fcSKai Chieh Chuang case 260000:
873901b9fcSKai Chieh Chuang return MTK_AFE_RATE_260K;
883901b9fcSKai Chieh Chuang default:
893901b9fcSKai Chieh Chuang dev_warn(dev, "%s(), rate %u invalid, use %d!!!\n",
903901b9fcSKai Chieh Chuang __func__, rate, MTK_AFE_RATE_48K);
913901b9fcSKai Chieh Chuang return MTK_AFE_RATE_48K;
923901b9fcSKai Chieh Chuang }
933901b9fcSKai Chieh Chuang }
943901b9fcSKai Chieh Chuang
dai_memif_rate_transform(struct device * dev,unsigned int rate)953901b9fcSKai Chieh Chuang static unsigned int dai_memif_rate_transform(struct device *dev,
963901b9fcSKai Chieh Chuang unsigned int rate)
973901b9fcSKai Chieh Chuang {
983901b9fcSKai Chieh Chuang switch (rate) {
993901b9fcSKai Chieh Chuang case 8000:
1003901b9fcSKai Chieh Chuang return MTK_AFE_DAI_MEMIF_RATE_8K;
1013901b9fcSKai Chieh Chuang case 16000:
1023901b9fcSKai Chieh Chuang return MTK_AFE_DAI_MEMIF_RATE_16K;
1033901b9fcSKai Chieh Chuang case 32000:
1043901b9fcSKai Chieh Chuang return MTK_AFE_DAI_MEMIF_RATE_32K;
1053901b9fcSKai Chieh Chuang default:
1063901b9fcSKai Chieh Chuang dev_warn(dev, "%s(), rate %u invalid, use %d!!!\n",
1073901b9fcSKai Chieh Chuang __func__, rate, MTK_AFE_DAI_MEMIF_RATE_16K);
1083901b9fcSKai Chieh Chuang return MTK_AFE_DAI_MEMIF_RATE_16K;
1093901b9fcSKai Chieh Chuang }
1103901b9fcSKai Chieh Chuang }
1113901b9fcSKai Chieh Chuang
mt6797_rate_transform(struct device * dev,unsigned int rate,int aud_blk)1123901b9fcSKai Chieh Chuang unsigned int mt6797_rate_transform(struct device *dev,
1133901b9fcSKai Chieh Chuang unsigned int rate, int aud_blk)
1143901b9fcSKai Chieh Chuang {
1153901b9fcSKai Chieh Chuang switch (aud_blk) {
1163901b9fcSKai Chieh Chuang case MT6797_MEMIF_DAI:
1173901b9fcSKai Chieh Chuang case MT6797_MEMIF_MOD_DAI:
1183901b9fcSKai Chieh Chuang return dai_memif_rate_transform(dev, rate);
1193901b9fcSKai Chieh Chuang default:
1203901b9fcSKai Chieh Chuang return mt6797_general_rate_transform(dev, rate);
1213901b9fcSKai Chieh Chuang }
1223901b9fcSKai Chieh Chuang }
1233901b9fcSKai Chieh Chuang
1243901b9fcSKai Chieh Chuang static const struct snd_pcm_hardware mt6797_afe_hardware = {
1253901b9fcSKai Chieh Chuang .info = SNDRV_PCM_INFO_MMAP |
1263901b9fcSKai Chieh Chuang SNDRV_PCM_INFO_INTERLEAVED |
1273901b9fcSKai Chieh Chuang SNDRV_PCM_INFO_MMAP_VALID,
1283901b9fcSKai Chieh Chuang .formats = SNDRV_PCM_FMTBIT_S16_LE |
1293901b9fcSKai Chieh Chuang SNDRV_PCM_FMTBIT_S24_LE |
1303901b9fcSKai Chieh Chuang SNDRV_PCM_FMTBIT_S32_LE,
1313901b9fcSKai Chieh Chuang .period_bytes_min = 256,
1323901b9fcSKai Chieh Chuang .period_bytes_max = 4 * 48 * 1024,
1333901b9fcSKai Chieh Chuang .periods_min = 2,
1343901b9fcSKai Chieh Chuang .periods_max = 256,
1353901b9fcSKai Chieh Chuang .buffer_bytes_max = 8 * 48 * 1024,
1363901b9fcSKai Chieh Chuang .fifo_size = 0,
1373901b9fcSKai Chieh Chuang };
1383901b9fcSKai Chieh Chuang
mt6797_memif_fs(struct snd_pcm_substream * substream,unsigned int rate)1393901b9fcSKai Chieh Chuang static int mt6797_memif_fs(struct snd_pcm_substream *substream,
1403901b9fcSKai Chieh Chuang unsigned int rate)
1413901b9fcSKai Chieh Chuang {
1420cd08b10SKuninori Morimoto struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
1433901b9fcSKai Chieh Chuang struct snd_soc_component *component =
1443901b9fcSKai Chieh Chuang snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME);
1453901b9fcSKai Chieh Chuang struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component);
146c8ac8212SKuninori Morimoto int id = asoc_rtd_to_cpu(rtd, 0)->id;
1473901b9fcSKai Chieh Chuang
1483901b9fcSKai Chieh Chuang return mt6797_rate_transform(afe->dev, rate, id);
1493901b9fcSKai Chieh Chuang }
1503901b9fcSKai Chieh Chuang
mt6797_irq_fs(struct snd_pcm_substream * substream,unsigned int rate)1513901b9fcSKai Chieh Chuang static int mt6797_irq_fs(struct snd_pcm_substream *substream, unsigned int rate)
1523901b9fcSKai Chieh Chuang {
1530cd08b10SKuninori Morimoto struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
1543901b9fcSKai Chieh Chuang struct snd_soc_component *component =
1553901b9fcSKai Chieh Chuang snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME);
1563901b9fcSKai Chieh Chuang struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component);
1573901b9fcSKai Chieh Chuang
1583901b9fcSKai Chieh Chuang return mt6797_general_rate_transform(afe->dev, rate);
1593901b9fcSKai Chieh Chuang }
1603901b9fcSKai Chieh Chuang
1613901b9fcSKai Chieh Chuang #define MTK_PCM_RATES (SNDRV_PCM_RATE_8000_48000 |\
1623901b9fcSKai Chieh Chuang SNDRV_PCM_RATE_88200 |\
1633901b9fcSKai Chieh Chuang SNDRV_PCM_RATE_96000 |\
1643901b9fcSKai Chieh Chuang SNDRV_PCM_RATE_176400 |\
1653901b9fcSKai Chieh Chuang SNDRV_PCM_RATE_192000)
1663901b9fcSKai Chieh Chuang
1673901b9fcSKai Chieh Chuang #define MTK_PCM_DAI_RATES (SNDRV_PCM_RATE_8000 |\
1683901b9fcSKai Chieh Chuang SNDRV_PCM_RATE_16000 |\
1693901b9fcSKai Chieh Chuang SNDRV_PCM_RATE_32000)
1703901b9fcSKai Chieh Chuang
1713901b9fcSKai Chieh Chuang #define MTK_PCM_FORMATS (SNDRV_PCM_FMTBIT_S16_LE |\
1723901b9fcSKai Chieh Chuang SNDRV_PCM_FMTBIT_S24_LE |\
1733901b9fcSKai Chieh Chuang SNDRV_PCM_FMTBIT_S32_LE)
1743901b9fcSKai Chieh Chuang
175b3c702f5SKaiChieh Chuang static struct snd_soc_dai_driver mt6797_memif_dai_driver[] = {
1763901b9fcSKai Chieh Chuang /* FE DAIs: memory intefaces to CPU */
1773901b9fcSKai Chieh Chuang {
1783901b9fcSKai Chieh Chuang .name = "DL1",
1793901b9fcSKai Chieh Chuang .id = MT6797_MEMIF_DL1,
1803901b9fcSKai Chieh Chuang .playback = {
1813901b9fcSKai Chieh Chuang .stream_name = "DL1",
1823901b9fcSKai Chieh Chuang .channels_min = 1,
1833901b9fcSKai Chieh Chuang .channels_max = 2,
1843901b9fcSKai Chieh Chuang .rates = MTK_PCM_RATES,
1853901b9fcSKai Chieh Chuang .formats = MTK_PCM_FORMATS,
1863901b9fcSKai Chieh Chuang },
1873901b9fcSKai Chieh Chuang .ops = &mtk_afe_fe_ops,
1883901b9fcSKai Chieh Chuang },
1893901b9fcSKai Chieh Chuang {
1903901b9fcSKai Chieh Chuang .name = "DL2",
1913901b9fcSKai Chieh Chuang .id = MT6797_MEMIF_DL2,
1923901b9fcSKai Chieh Chuang .playback = {
1933901b9fcSKai Chieh Chuang .stream_name = "DL2",
1943901b9fcSKai Chieh Chuang .channels_min = 1,
1953901b9fcSKai Chieh Chuang .channels_max = 2,
1963901b9fcSKai Chieh Chuang .rates = MTK_PCM_RATES,
1973901b9fcSKai Chieh Chuang .formats = MTK_PCM_FORMATS,
1983901b9fcSKai Chieh Chuang },
1993901b9fcSKai Chieh Chuang .ops = &mtk_afe_fe_ops,
2003901b9fcSKai Chieh Chuang },
2013901b9fcSKai Chieh Chuang {
2023901b9fcSKai Chieh Chuang .name = "DL3",
2033901b9fcSKai Chieh Chuang .id = MT6797_MEMIF_DL3,
2043901b9fcSKai Chieh Chuang .playback = {
2053901b9fcSKai Chieh Chuang .stream_name = "DL3",
2063901b9fcSKai Chieh Chuang .channels_min = 1,
2073901b9fcSKai Chieh Chuang .channels_max = 2,
2083901b9fcSKai Chieh Chuang .rates = MTK_PCM_RATES,
2093901b9fcSKai Chieh Chuang .formats = MTK_PCM_FORMATS,
2103901b9fcSKai Chieh Chuang },
2113901b9fcSKai Chieh Chuang .ops = &mtk_afe_fe_ops,
2123901b9fcSKai Chieh Chuang },
2133901b9fcSKai Chieh Chuang {
2143901b9fcSKai Chieh Chuang .name = "UL1",
2153901b9fcSKai Chieh Chuang .id = MT6797_MEMIF_VUL12,
2163901b9fcSKai Chieh Chuang .capture = {
2173901b9fcSKai Chieh Chuang .stream_name = "UL1",
2183901b9fcSKai Chieh Chuang .channels_min = 1,
2193901b9fcSKai Chieh Chuang .channels_max = 2,
2203901b9fcSKai Chieh Chuang .rates = MTK_PCM_RATES,
2213901b9fcSKai Chieh Chuang .formats = MTK_PCM_FORMATS,
2223901b9fcSKai Chieh Chuang },
2233901b9fcSKai Chieh Chuang .ops = &mtk_afe_fe_ops,
2243901b9fcSKai Chieh Chuang },
2253901b9fcSKai Chieh Chuang {
2263901b9fcSKai Chieh Chuang .name = "UL2",
2273901b9fcSKai Chieh Chuang .id = MT6797_MEMIF_AWB,
2283901b9fcSKai Chieh Chuang .capture = {
2293901b9fcSKai Chieh Chuang .stream_name = "UL2",
2303901b9fcSKai Chieh Chuang .channels_min = 1,
2313901b9fcSKai Chieh Chuang .channels_max = 2,
2323901b9fcSKai Chieh Chuang .rates = MTK_PCM_RATES,
2333901b9fcSKai Chieh Chuang .formats = MTK_PCM_FORMATS,
2343901b9fcSKai Chieh Chuang },
2353901b9fcSKai Chieh Chuang .ops = &mtk_afe_fe_ops,
2363901b9fcSKai Chieh Chuang },
2373901b9fcSKai Chieh Chuang {
2383901b9fcSKai Chieh Chuang .name = "UL3",
2393901b9fcSKai Chieh Chuang .id = MT6797_MEMIF_VUL,
2403901b9fcSKai Chieh Chuang .capture = {
2413901b9fcSKai Chieh Chuang .stream_name = "UL3",
2423901b9fcSKai Chieh Chuang .channels_min = 1,
2433901b9fcSKai Chieh Chuang .channels_max = 2,
2443901b9fcSKai Chieh Chuang .rates = MTK_PCM_RATES,
2453901b9fcSKai Chieh Chuang .formats = MTK_PCM_FORMATS,
2463901b9fcSKai Chieh Chuang },
2473901b9fcSKai Chieh Chuang .ops = &mtk_afe_fe_ops,
2483901b9fcSKai Chieh Chuang },
2493901b9fcSKai Chieh Chuang {
2503901b9fcSKai Chieh Chuang .name = "UL_MONO_1",
2513901b9fcSKai Chieh Chuang .id = MT6797_MEMIF_MOD_DAI,
2523901b9fcSKai Chieh Chuang .capture = {
2533901b9fcSKai Chieh Chuang .stream_name = "UL_MONO_1",
2543901b9fcSKai Chieh Chuang .channels_min = 1,
2553901b9fcSKai Chieh Chuang .channels_max = 1,
2563901b9fcSKai Chieh Chuang .rates = MTK_PCM_DAI_RATES,
2573901b9fcSKai Chieh Chuang .formats = MTK_PCM_FORMATS,
2583901b9fcSKai Chieh Chuang },
2593901b9fcSKai Chieh Chuang .ops = &mtk_afe_fe_ops,
2603901b9fcSKai Chieh Chuang },
2613901b9fcSKai Chieh Chuang {
2623901b9fcSKai Chieh Chuang .name = "UL_MONO_2",
2633901b9fcSKai Chieh Chuang .id = MT6797_MEMIF_DAI,
2643901b9fcSKai Chieh Chuang .capture = {
2653901b9fcSKai Chieh Chuang .stream_name = "UL_MONO_2",
2663901b9fcSKai Chieh Chuang .channels_min = 1,
2673901b9fcSKai Chieh Chuang .channels_max = 1,
2683901b9fcSKai Chieh Chuang .rates = MTK_PCM_DAI_RATES,
2693901b9fcSKai Chieh Chuang .formats = MTK_PCM_FORMATS,
2703901b9fcSKai Chieh Chuang },
2713901b9fcSKai Chieh Chuang .ops = &mtk_afe_fe_ops,
2723901b9fcSKai Chieh Chuang },
2733901b9fcSKai Chieh Chuang };
2743901b9fcSKai Chieh Chuang
2753901b9fcSKai Chieh Chuang /* dma widget & routes*/
2763901b9fcSKai Chieh Chuang static const struct snd_kcontrol_new memif_ul1_ch1_mix[] = {
2773901b9fcSKai Chieh Chuang SOC_DAPM_SINGLE_AUTODISABLE("ADDA_UL_CH1", AFE_CONN21,
2783901b9fcSKai Chieh Chuang I_ADDA_UL_CH1, 1, 0),
2793901b9fcSKai Chieh Chuang };
2803901b9fcSKai Chieh Chuang
2813901b9fcSKai Chieh Chuang static const struct snd_kcontrol_new memif_ul1_ch2_mix[] = {
2823901b9fcSKai Chieh Chuang SOC_DAPM_SINGLE_AUTODISABLE("ADDA_UL_CH2", AFE_CONN22,
2833901b9fcSKai Chieh Chuang I_ADDA_UL_CH2, 1, 0),
2843901b9fcSKai Chieh Chuang };
2853901b9fcSKai Chieh Chuang
2863901b9fcSKai Chieh Chuang static const struct snd_kcontrol_new memif_ul2_ch1_mix[] = {
2873901b9fcSKai Chieh Chuang SOC_DAPM_SINGLE_AUTODISABLE("ADDA_UL_CH1", AFE_CONN5,
2883901b9fcSKai Chieh Chuang I_ADDA_UL_CH1, 1, 0),
2893901b9fcSKai Chieh Chuang SOC_DAPM_SINGLE_AUTODISABLE("DL1_CH1", AFE_CONN5,
2903901b9fcSKai Chieh Chuang I_DL1_CH1, 1, 0),
2913901b9fcSKai Chieh Chuang SOC_DAPM_SINGLE_AUTODISABLE("DL2_CH1", AFE_CONN5,
2923901b9fcSKai Chieh Chuang I_DL2_CH1, 1, 0),
2933901b9fcSKai Chieh Chuang SOC_DAPM_SINGLE_AUTODISABLE("DL3_CH1", AFE_CONN5,
2943901b9fcSKai Chieh Chuang I_DL3_CH1, 1, 0),
2953901b9fcSKai Chieh Chuang };
2963901b9fcSKai Chieh Chuang
2973901b9fcSKai Chieh Chuang static const struct snd_kcontrol_new memif_ul2_ch2_mix[] = {
2983901b9fcSKai Chieh Chuang SOC_DAPM_SINGLE_AUTODISABLE("ADDA_UL_CH2", AFE_CONN6,
2993901b9fcSKai Chieh Chuang I_ADDA_UL_CH2, 1, 0),
3003901b9fcSKai Chieh Chuang SOC_DAPM_SINGLE_AUTODISABLE("DL1_CH2", AFE_CONN6,
3013901b9fcSKai Chieh Chuang I_DL1_CH2, 1, 0),
3023901b9fcSKai Chieh Chuang SOC_DAPM_SINGLE_AUTODISABLE("DL2_CH2", AFE_CONN6,
3033901b9fcSKai Chieh Chuang I_DL2_CH2, 1, 0),
3043901b9fcSKai Chieh Chuang SOC_DAPM_SINGLE_AUTODISABLE("DL3_CH2", AFE_CONN6,
3053901b9fcSKai Chieh Chuang I_DL3_CH2, 1, 0),
3063901b9fcSKai Chieh Chuang };
3073901b9fcSKai Chieh Chuang
3083901b9fcSKai Chieh Chuang static const struct snd_kcontrol_new memif_ul3_ch1_mix[] = {
3093901b9fcSKai Chieh Chuang SOC_DAPM_SINGLE_AUTODISABLE("ADDA_UL_CH1", AFE_CONN9,
3103901b9fcSKai Chieh Chuang I_ADDA_UL_CH1, 1, 0),
3113901b9fcSKai Chieh Chuang };
3123901b9fcSKai Chieh Chuang
3133901b9fcSKai Chieh Chuang static const struct snd_kcontrol_new memif_ul3_ch2_mix[] = {
3143901b9fcSKai Chieh Chuang SOC_DAPM_SINGLE_AUTODISABLE("ADDA_UL_CH2", AFE_CONN10,
3153901b9fcSKai Chieh Chuang I_ADDA_UL_CH2, 1, 0),
3163901b9fcSKai Chieh Chuang };
3173901b9fcSKai Chieh Chuang
3183901b9fcSKai Chieh Chuang static const struct snd_kcontrol_new memif_ul_mono_1_mix[] = {
3193901b9fcSKai Chieh Chuang SOC_DAPM_SINGLE_AUTODISABLE("ADDA_UL_CH1", AFE_CONN12,
3203901b9fcSKai Chieh Chuang I_ADDA_UL_CH1, 1, 0),
3213901b9fcSKai Chieh Chuang SOC_DAPM_SINGLE_AUTODISABLE("ADDA_UL_CH2", AFE_CONN12,
3223901b9fcSKai Chieh Chuang I_ADDA_UL_CH2, 1, 0),
3233901b9fcSKai Chieh Chuang };
3243901b9fcSKai Chieh Chuang
3253901b9fcSKai Chieh Chuang static const struct snd_kcontrol_new memif_ul_mono_2_mix[] = {
3263901b9fcSKai Chieh Chuang SOC_DAPM_SINGLE_AUTODISABLE("ADDA_UL_CH1", AFE_CONN11,
3273901b9fcSKai Chieh Chuang I_ADDA_UL_CH1, 1, 0),
3283901b9fcSKai Chieh Chuang SOC_DAPM_SINGLE_AUTODISABLE("ADDA_UL_CH2", AFE_CONN11,
3293901b9fcSKai Chieh Chuang I_ADDA_UL_CH2, 1, 0),
3303901b9fcSKai Chieh Chuang };
3313901b9fcSKai Chieh Chuang
332b3c702f5SKaiChieh Chuang static const struct snd_soc_dapm_widget mt6797_memif_widgets[] = {
3333901b9fcSKai Chieh Chuang /* memif */
3343901b9fcSKai Chieh Chuang SND_SOC_DAPM_MIXER("UL1_CH1", SND_SOC_NOPM, 0, 0,
3353901b9fcSKai Chieh Chuang memif_ul1_ch1_mix, ARRAY_SIZE(memif_ul1_ch1_mix)),
3363901b9fcSKai Chieh Chuang SND_SOC_DAPM_MIXER("UL1_CH2", SND_SOC_NOPM, 0, 0,
3373901b9fcSKai Chieh Chuang memif_ul1_ch2_mix, ARRAY_SIZE(memif_ul1_ch2_mix)),
3383901b9fcSKai Chieh Chuang
3393901b9fcSKai Chieh Chuang SND_SOC_DAPM_MIXER("UL2_CH1", SND_SOC_NOPM, 0, 0,
3403901b9fcSKai Chieh Chuang memif_ul2_ch1_mix, ARRAY_SIZE(memif_ul2_ch1_mix)),
3413901b9fcSKai Chieh Chuang SND_SOC_DAPM_MIXER("UL2_CH2", SND_SOC_NOPM, 0, 0,
3423901b9fcSKai Chieh Chuang memif_ul2_ch2_mix, ARRAY_SIZE(memif_ul2_ch2_mix)),
3433901b9fcSKai Chieh Chuang
3443901b9fcSKai Chieh Chuang SND_SOC_DAPM_MIXER("UL3_CH1", SND_SOC_NOPM, 0, 0,
3453901b9fcSKai Chieh Chuang memif_ul3_ch1_mix, ARRAY_SIZE(memif_ul3_ch1_mix)),
3463901b9fcSKai Chieh Chuang SND_SOC_DAPM_MIXER("UL3_CH2", SND_SOC_NOPM, 0, 0,
3473901b9fcSKai Chieh Chuang memif_ul3_ch2_mix, ARRAY_SIZE(memif_ul3_ch2_mix)),
3483901b9fcSKai Chieh Chuang
3493901b9fcSKai Chieh Chuang SND_SOC_DAPM_MIXER("UL_MONO_1_CH1", SND_SOC_NOPM, 0, 0,
3503901b9fcSKai Chieh Chuang memif_ul_mono_1_mix,
3513901b9fcSKai Chieh Chuang ARRAY_SIZE(memif_ul_mono_1_mix)),
3523901b9fcSKai Chieh Chuang
3533901b9fcSKai Chieh Chuang SND_SOC_DAPM_MIXER("UL_MONO_2_CH1", SND_SOC_NOPM, 0, 0,
3543901b9fcSKai Chieh Chuang memif_ul_mono_2_mix,
3553901b9fcSKai Chieh Chuang ARRAY_SIZE(memif_ul_mono_2_mix)),
3563901b9fcSKai Chieh Chuang };
3573901b9fcSKai Chieh Chuang
358b3c702f5SKaiChieh Chuang static const struct snd_soc_dapm_route mt6797_memif_routes[] = {
3593901b9fcSKai Chieh Chuang /* capture */
3603901b9fcSKai Chieh Chuang {"UL1", NULL, "UL1_CH1"},
3613901b9fcSKai Chieh Chuang {"UL1", NULL, "UL1_CH2"},
3623901b9fcSKai Chieh Chuang {"UL1_CH1", "ADDA_UL_CH1", "ADDA Capture"},
3633901b9fcSKai Chieh Chuang {"UL1_CH2", "ADDA_UL_CH2", "ADDA Capture"},
3643901b9fcSKai Chieh Chuang
3653901b9fcSKai Chieh Chuang {"UL2", NULL, "UL2_CH1"},
3663901b9fcSKai Chieh Chuang {"UL2", NULL, "UL2_CH2"},
3673901b9fcSKai Chieh Chuang {"UL2_CH1", "ADDA_UL_CH1", "ADDA Capture"},
3683901b9fcSKai Chieh Chuang {"UL2_CH2", "ADDA_UL_CH2", "ADDA Capture"},
3693901b9fcSKai Chieh Chuang
3703901b9fcSKai Chieh Chuang {"UL3", NULL, "UL3_CH1"},
3713901b9fcSKai Chieh Chuang {"UL3", NULL, "UL3_CH2"},
3723901b9fcSKai Chieh Chuang {"UL3_CH1", "ADDA_UL_CH1", "ADDA Capture"},
3733901b9fcSKai Chieh Chuang {"UL3_CH2", "ADDA_UL_CH2", "ADDA Capture"},
3743901b9fcSKai Chieh Chuang
3753901b9fcSKai Chieh Chuang {"UL_MONO_1", NULL, "UL_MONO_1_CH1"},
3763901b9fcSKai Chieh Chuang {"UL_MONO_1_CH1", "ADDA_UL_CH1", "ADDA Capture"},
3773901b9fcSKai Chieh Chuang {"UL_MONO_1_CH1", "ADDA_UL_CH2", "ADDA Capture"},
3783901b9fcSKai Chieh Chuang
3793901b9fcSKai Chieh Chuang {"UL_MONO_2", NULL, "UL_MONO_2_CH1"},
3803901b9fcSKai Chieh Chuang {"UL_MONO_2_CH1", "ADDA_UL_CH1", "ADDA Capture"},
3813901b9fcSKai Chieh Chuang {"UL_MONO_2_CH1", "ADDA_UL_CH2", "ADDA Capture"},
3823901b9fcSKai Chieh Chuang };
3833901b9fcSKai Chieh Chuang
3843901b9fcSKai Chieh Chuang static const struct snd_soc_component_driver mt6797_afe_pcm_dai_component = {
3853901b9fcSKai Chieh Chuang .name = "mt6797-afe-pcm-dai",
3863901b9fcSKai Chieh Chuang };
3873901b9fcSKai Chieh Chuang
3883901b9fcSKai Chieh Chuang static const struct mtk_base_memif_data memif_data[MT6797_MEMIF_NUM] = {
3893901b9fcSKai Chieh Chuang [MT6797_MEMIF_DL1] = {
3903901b9fcSKai Chieh Chuang .name = "DL1",
3913901b9fcSKai Chieh Chuang .id = MT6797_MEMIF_DL1,
3923901b9fcSKai Chieh Chuang .reg_ofs_base = AFE_DL1_BASE,
3933901b9fcSKai Chieh Chuang .reg_ofs_cur = AFE_DL1_CUR,
3943901b9fcSKai Chieh Chuang .fs_reg = AFE_DAC_CON1,
3953901b9fcSKai Chieh Chuang .fs_shift = DL1_MODE_SFT,
3963901b9fcSKai Chieh Chuang .fs_maskbit = DL1_MODE_MASK,
3973901b9fcSKai Chieh Chuang .mono_reg = AFE_DAC_CON1,
3983901b9fcSKai Chieh Chuang .mono_shift = DL1_DATA_SFT,
3993901b9fcSKai Chieh Chuang .enable_reg = AFE_DAC_CON0,
4003901b9fcSKai Chieh Chuang .enable_shift = DL1_ON_SFT,
4013901b9fcSKai Chieh Chuang .hd_reg = AFE_MEMIF_HD_MODE,
4023901b9fcSKai Chieh Chuang .hd_shift = DL1_HD_SFT,
4033901b9fcSKai Chieh Chuang .agent_disable_reg = -1,
4043901b9fcSKai Chieh Chuang .msb_reg = -1,
4053901b9fcSKai Chieh Chuang },
4063901b9fcSKai Chieh Chuang [MT6797_MEMIF_DL2] = {
4073901b9fcSKai Chieh Chuang .name = "DL2",
4083901b9fcSKai Chieh Chuang .id = MT6797_MEMIF_DL2,
4093901b9fcSKai Chieh Chuang .reg_ofs_base = AFE_DL2_BASE,
4103901b9fcSKai Chieh Chuang .reg_ofs_cur = AFE_DL2_CUR,
4113901b9fcSKai Chieh Chuang .fs_reg = AFE_DAC_CON1,
4123901b9fcSKai Chieh Chuang .fs_shift = DL2_MODE_SFT,
4133901b9fcSKai Chieh Chuang .fs_maskbit = DL2_MODE_MASK,
4143901b9fcSKai Chieh Chuang .mono_reg = AFE_DAC_CON1,
4153901b9fcSKai Chieh Chuang .mono_shift = DL2_DATA_SFT,
4163901b9fcSKai Chieh Chuang .enable_reg = AFE_DAC_CON0,
4173901b9fcSKai Chieh Chuang .enable_shift = DL2_ON_SFT,
4183901b9fcSKai Chieh Chuang .hd_reg = AFE_MEMIF_HD_MODE,
4193901b9fcSKai Chieh Chuang .hd_shift = DL2_HD_SFT,
4203901b9fcSKai Chieh Chuang .agent_disable_reg = -1,
4213901b9fcSKai Chieh Chuang .msb_reg = -1,
4223901b9fcSKai Chieh Chuang },
4233901b9fcSKai Chieh Chuang [MT6797_MEMIF_DL3] = {
4243901b9fcSKai Chieh Chuang .name = "DL3",
4253901b9fcSKai Chieh Chuang .id = MT6797_MEMIF_DL3,
4263901b9fcSKai Chieh Chuang .reg_ofs_base = AFE_DL3_BASE,
4273901b9fcSKai Chieh Chuang .reg_ofs_cur = AFE_DL3_CUR,
4283901b9fcSKai Chieh Chuang .fs_reg = AFE_DAC_CON0,
4293901b9fcSKai Chieh Chuang .fs_shift = DL3_MODE_SFT,
4303901b9fcSKai Chieh Chuang .fs_maskbit = DL3_MODE_MASK,
4313901b9fcSKai Chieh Chuang .mono_reg = AFE_DAC_CON1,
4323901b9fcSKai Chieh Chuang .mono_shift = DL3_DATA_SFT,
4333901b9fcSKai Chieh Chuang .enable_reg = AFE_DAC_CON0,
4343901b9fcSKai Chieh Chuang .enable_shift = DL3_ON_SFT,
4353901b9fcSKai Chieh Chuang .hd_reg = AFE_MEMIF_HD_MODE,
4363901b9fcSKai Chieh Chuang .hd_shift = DL3_HD_SFT,
4373901b9fcSKai Chieh Chuang .agent_disable_reg = -1,
4383901b9fcSKai Chieh Chuang .msb_reg = -1,
4393901b9fcSKai Chieh Chuang },
4403901b9fcSKai Chieh Chuang [MT6797_MEMIF_VUL] = {
4413901b9fcSKai Chieh Chuang .name = "VUL",
4423901b9fcSKai Chieh Chuang .id = MT6797_MEMIF_VUL,
4433901b9fcSKai Chieh Chuang .reg_ofs_base = AFE_VUL_BASE,
4443901b9fcSKai Chieh Chuang .reg_ofs_cur = AFE_VUL_CUR,
4453901b9fcSKai Chieh Chuang .fs_reg = AFE_DAC_CON1,
4463901b9fcSKai Chieh Chuang .fs_shift = VUL_MODE_SFT,
4473901b9fcSKai Chieh Chuang .fs_maskbit = VUL_MODE_MASK,
4483901b9fcSKai Chieh Chuang .mono_reg = AFE_DAC_CON1,
4493901b9fcSKai Chieh Chuang .mono_shift = VUL_DATA_SFT,
4503901b9fcSKai Chieh Chuang .enable_reg = AFE_DAC_CON0,
4513901b9fcSKai Chieh Chuang .enable_shift = VUL_ON_SFT,
4523901b9fcSKai Chieh Chuang .hd_reg = AFE_MEMIF_HD_MODE,
4533901b9fcSKai Chieh Chuang .hd_shift = VUL_HD_SFT,
4543901b9fcSKai Chieh Chuang .agent_disable_reg = -1,
4553901b9fcSKai Chieh Chuang .msb_reg = -1,
4563901b9fcSKai Chieh Chuang },
4573901b9fcSKai Chieh Chuang [MT6797_MEMIF_AWB] = {
4583901b9fcSKai Chieh Chuang .name = "AWB",
4593901b9fcSKai Chieh Chuang .id = MT6797_MEMIF_AWB,
4603901b9fcSKai Chieh Chuang .reg_ofs_base = AFE_AWB_BASE,
4613901b9fcSKai Chieh Chuang .reg_ofs_cur = AFE_AWB_CUR,
4623901b9fcSKai Chieh Chuang .fs_reg = AFE_DAC_CON1,
4633901b9fcSKai Chieh Chuang .fs_shift = AWB_MODE_SFT,
4643901b9fcSKai Chieh Chuang .fs_maskbit = AWB_MODE_MASK,
4653901b9fcSKai Chieh Chuang .mono_reg = AFE_DAC_CON1,
4663901b9fcSKai Chieh Chuang .mono_shift = AWB_DATA_SFT,
4673901b9fcSKai Chieh Chuang .enable_reg = AFE_DAC_CON0,
4683901b9fcSKai Chieh Chuang .enable_shift = AWB_ON_SFT,
4693901b9fcSKai Chieh Chuang .hd_reg = AFE_MEMIF_HD_MODE,
4703901b9fcSKai Chieh Chuang .hd_shift = AWB_HD_SFT,
4713901b9fcSKai Chieh Chuang .agent_disable_reg = -1,
4723901b9fcSKai Chieh Chuang .msb_reg = -1,
4733901b9fcSKai Chieh Chuang },
4743901b9fcSKai Chieh Chuang [MT6797_MEMIF_VUL12] = {
4753901b9fcSKai Chieh Chuang .name = "VUL12",
4763901b9fcSKai Chieh Chuang .id = MT6797_MEMIF_VUL12,
4773901b9fcSKai Chieh Chuang .reg_ofs_base = AFE_VUL_D2_BASE,
4783901b9fcSKai Chieh Chuang .reg_ofs_cur = AFE_VUL_D2_CUR,
4793901b9fcSKai Chieh Chuang .fs_reg = AFE_DAC_CON0,
4803901b9fcSKai Chieh Chuang .fs_shift = VUL_DATA2_MODE_SFT,
4813901b9fcSKai Chieh Chuang .fs_maskbit = VUL_DATA2_MODE_MASK,
4823901b9fcSKai Chieh Chuang .mono_reg = AFE_DAC_CON0,
4833901b9fcSKai Chieh Chuang .mono_shift = VUL_DATA2_DATA_SFT,
4843901b9fcSKai Chieh Chuang .enable_reg = AFE_DAC_CON0,
4853901b9fcSKai Chieh Chuang .enable_shift = VUL_DATA2_ON_SFT,
4863901b9fcSKai Chieh Chuang .hd_reg = AFE_MEMIF_HD_MODE,
4873901b9fcSKai Chieh Chuang .hd_shift = VUL_DATA2_HD_SFT,
4883901b9fcSKai Chieh Chuang .agent_disable_reg = -1,
4893901b9fcSKai Chieh Chuang .msb_reg = -1,
4903901b9fcSKai Chieh Chuang },
4913901b9fcSKai Chieh Chuang [MT6797_MEMIF_DAI] = {
4923901b9fcSKai Chieh Chuang .name = "DAI",
4933901b9fcSKai Chieh Chuang .id = MT6797_MEMIF_DAI,
4943901b9fcSKai Chieh Chuang .reg_ofs_base = AFE_DAI_BASE,
4953901b9fcSKai Chieh Chuang .reg_ofs_cur = AFE_DAI_CUR,
4963901b9fcSKai Chieh Chuang .fs_reg = AFE_DAC_CON0,
4973901b9fcSKai Chieh Chuang .fs_shift = DAI_MODE_SFT,
4983901b9fcSKai Chieh Chuang .fs_maskbit = DAI_MODE_MASK,
4993901b9fcSKai Chieh Chuang .mono_reg = -1,
5003901b9fcSKai Chieh Chuang .mono_shift = 0,
5013901b9fcSKai Chieh Chuang .enable_reg = AFE_DAC_CON0,
5023901b9fcSKai Chieh Chuang .enable_shift = DAI_ON_SFT,
5033901b9fcSKai Chieh Chuang .hd_reg = AFE_MEMIF_HD_MODE,
5043901b9fcSKai Chieh Chuang .hd_shift = DAI_HD_SFT,
5053901b9fcSKai Chieh Chuang .agent_disable_reg = -1,
5063901b9fcSKai Chieh Chuang .msb_reg = -1,
5073901b9fcSKai Chieh Chuang },
5083901b9fcSKai Chieh Chuang [MT6797_MEMIF_MOD_DAI] = {
5093901b9fcSKai Chieh Chuang .name = "MOD_DAI",
5103901b9fcSKai Chieh Chuang .id = MT6797_MEMIF_MOD_DAI,
5113901b9fcSKai Chieh Chuang .reg_ofs_base = AFE_MOD_DAI_BASE,
5123901b9fcSKai Chieh Chuang .reg_ofs_cur = AFE_MOD_DAI_CUR,
5133901b9fcSKai Chieh Chuang .fs_reg = AFE_DAC_CON1,
5143901b9fcSKai Chieh Chuang .fs_shift = MOD_DAI_MODE_SFT,
5153901b9fcSKai Chieh Chuang .fs_maskbit = MOD_DAI_MODE_MASK,
5163901b9fcSKai Chieh Chuang .mono_reg = -1,
5173901b9fcSKai Chieh Chuang .mono_shift = 0,
5183901b9fcSKai Chieh Chuang .enable_reg = AFE_DAC_CON0,
5193901b9fcSKai Chieh Chuang .enable_shift = MOD_DAI_ON_SFT,
5203901b9fcSKai Chieh Chuang .hd_reg = AFE_MEMIF_HD_MODE,
5213901b9fcSKai Chieh Chuang .hd_shift = MOD_DAI_HD_SFT,
5223901b9fcSKai Chieh Chuang .agent_disable_reg = -1,
5233901b9fcSKai Chieh Chuang .msb_reg = -1,
5243901b9fcSKai Chieh Chuang },
5253901b9fcSKai Chieh Chuang };
5263901b9fcSKai Chieh Chuang
5273901b9fcSKai Chieh Chuang static const struct mtk_base_irq_data irq_data[MT6797_IRQ_NUM] = {
5283901b9fcSKai Chieh Chuang [MT6797_IRQ_1] = {
5293901b9fcSKai Chieh Chuang .id = MT6797_IRQ_1,
5303901b9fcSKai Chieh Chuang .irq_cnt_reg = AFE_IRQ_MCU_CNT1,
5313901b9fcSKai Chieh Chuang .irq_cnt_shift = AFE_IRQ_MCU_CNT1_SFT,
5323901b9fcSKai Chieh Chuang .irq_cnt_maskbit = AFE_IRQ_MCU_CNT1_MASK,
5333901b9fcSKai Chieh Chuang .irq_fs_reg = AFE_IRQ_MCU_CON,
5343901b9fcSKai Chieh Chuang .irq_fs_shift = IRQ1_MCU_MODE_SFT,
5353901b9fcSKai Chieh Chuang .irq_fs_maskbit = IRQ1_MCU_MODE_MASK,
5363901b9fcSKai Chieh Chuang .irq_en_reg = AFE_IRQ_MCU_CON,
5373901b9fcSKai Chieh Chuang .irq_en_shift = IRQ1_MCU_ON_SFT,
5383901b9fcSKai Chieh Chuang .irq_clr_reg = AFE_IRQ_MCU_CLR,
5393901b9fcSKai Chieh Chuang .irq_clr_shift = IRQ1_MCU_CLR_SFT,
5403901b9fcSKai Chieh Chuang },
5413901b9fcSKai Chieh Chuang [MT6797_IRQ_2] = {
5423901b9fcSKai Chieh Chuang .id = MT6797_IRQ_2,
5433901b9fcSKai Chieh Chuang .irq_cnt_reg = AFE_IRQ_MCU_CNT2,
5443901b9fcSKai Chieh Chuang .irq_cnt_shift = AFE_IRQ_MCU_CNT2_SFT,
5453901b9fcSKai Chieh Chuang .irq_cnt_maskbit = AFE_IRQ_MCU_CNT2_MASK,
5463901b9fcSKai Chieh Chuang .irq_fs_reg = AFE_IRQ_MCU_CON,
5473901b9fcSKai Chieh Chuang .irq_fs_shift = IRQ2_MCU_MODE_SFT,
5483901b9fcSKai Chieh Chuang .irq_fs_maskbit = IRQ2_MCU_MODE_MASK,
5493901b9fcSKai Chieh Chuang .irq_en_reg = AFE_IRQ_MCU_CON,
5503901b9fcSKai Chieh Chuang .irq_en_shift = IRQ2_MCU_ON_SFT,
5513901b9fcSKai Chieh Chuang .irq_clr_reg = AFE_IRQ_MCU_CLR,
5523901b9fcSKai Chieh Chuang .irq_clr_shift = IRQ2_MCU_CLR_SFT,
5533901b9fcSKai Chieh Chuang },
5543901b9fcSKai Chieh Chuang [MT6797_IRQ_3] = {
5553901b9fcSKai Chieh Chuang .id = MT6797_IRQ_3,
5563901b9fcSKai Chieh Chuang .irq_cnt_reg = AFE_IRQ_MCU_CNT3,
5573901b9fcSKai Chieh Chuang .irq_cnt_shift = AFE_IRQ_MCU_CNT3_SFT,
5583901b9fcSKai Chieh Chuang .irq_cnt_maskbit = AFE_IRQ_MCU_CNT3_MASK,
5593901b9fcSKai Chieh Chuang .irq_fs_reg = AFE_IRQ_MCU_CON,
5603901b9fcSKai Chieh Chuang .irq_fs_shift = IRQ3_MCU_MODE_SFT,
5613901b9fcSKai Chieh Chuang .irq_fs_maskbit = IRQ3_MCU_MODE_MASK,
5623901b9fcSKai Chieh Chuang .irq_en_reg = AFE_IRQ_MCU_CON,
5633901b9fcSKai Chieh Chuang .irq_en_shift = IRQ3_MCU_ON_SFT,
5643901b9fcSKai Chieh Chuang .irq_clr_reg = AFE_IRQ_MCU_CLR,
5653901b9fcSKai Chieh Chuang .irq_clr_shift = IRQ3_MCU_CLR_SFT,
5663901b9fcSKai Chieh Chuang },
5673901b9fcSKai Chieh Chuang [MT6797_IRQ_4] = {
5683901b9fcSKai Chieh Chuang .id = MT6797_IRQ_4,
5693901b9fcSKai Chieh Chuang .irq_cnt_reg = AFE_IRQ_MCU_CNT4,
5703901b9fcSKai Chieh Chuang .irq_cnt_shift = AFE_IRQ_MCU_CNT4_SFT,
5713901b9fcSKai Chieh Chuang .irq_cnt_maskbit = AFE_IRQ_MCU_CNT4_MASK,
5723901b9fcSKai Chieh Chuang .irq_fs_reg = AFE_IRQ_MCU_CON,
5733901b9fcSKai Chieh Chuang .irq_fs_shift = IRQ4_MCU_MODE_SFT,
5743901b9fcSKai Chieh Chuang .irq_fs_maskbit = IRQ4_MCU_MODE_MASK,
5753901b9fcSKai Chieh Chuang .irq_en_reg = AFE_IRQ_MCU_CON,
5763901b9fcSKai Chieh Chuang .irq_en_shift = IRQ4_MCU_ON_SFT,
5773901b9fcSKai Chieh Chuang .irq_clr_reg = AFE_IRQ_MCU_CLR,
5783901b9fcSKai Chieh Chuang .irq_clr_shift = IRQ4_MCU_CLR_SFT,
5793901b9fcSKai Chieh Chuang },
5803901b9fcSKai Chieh Chuang [MT6797_IRQ_7] = {
5813901b9fcSKai Chieh Chuang .id = MT6797_IRQ_7,
5823901b9fcSKai Chieh Chuang .irq_cnt_reg = AFE_IRQ_MCU_CNT7,
5833901b9fcSKai Chieh Chuang .irq_cnt_shift = AFE_IRQ_MCU_CNT7_SFT,
5843901b9fcSKai Chieh Chuang .irq_cnt_maskbit = AFE_IRQ_MCU_CNT7_MASK,
5853901b9fcSKai Chieh Chuang .irq_fs_reg = AFE_IRQ_MCU_CON,
5863901b9fcSKai Chieh Chuang .irq_fs_shift = IRQ7_MCU_MODE_SFT,
5873901b9fcSKai Chieh Chuang .irq_fs_maskbit = IRQ7_MCU_MODE_MASK,
5883901b9fcSKai Chieh Chuang .irq_en_reg = AFE_IRQ_MCU_CON,
5893901b9fcSKai Chieh Chuang .irq_en_shift = IRQ7_MCU_ON_SFT,
5903901b9fcSKai Chieh Chuang .irq_clr_reg = AFE_IRQ_MCU_CLR,
5913901b9fcSKai Chieh Chuang .irq_clr_shift = IRQ7_MCU_CLR_SFT,
5923901b9fcSKai Chieh Chuang },
5933901b9fcSKai Chieh Chuang };
5943901b9fcSKai Chieh Chuang
5953901b9fcSKai Chieh Chuang static const struct regmap_config mt6797_afe_regmap_config = {
5963901b9fcSKai Chieh Chuang .reg_bits = 32,
5973901b9fcSKai Chieh Chuang .reg_stride = 4,
5983901b9fcSKai Chieh Chuang .val_bits = 32,
5993901b9fcSKai Chieh Chuang .max_register = AFE_MAX_REGISTER,
6003901b9fcSKai Chieh Chuang };
6013901b9fcSKai Chieh Chuang
mt6797_afe_irq_handler(int irq_id,void * dev)6023901b9fcSKai Chieh Chuang static irqreturn_t mt6797_afe_irq_handler(int irq_id, void *dev)
6033901b9fcSKai Chieh Chuang {
6043901b9fcSKai Chieh Chuang struct mtk_base_afe *afe = dev;
6053901b9fcSKai Chieh Chuang struct mtk_base_afe_irq *irq;
6063901b9fcSKai Chieh Chuang unsigned int status;
6073901b9fcSKai Chieh Chuang unsigned int mcu_en;
6083901b9fcSKai Chieh Chuang int ret;
6093901b9fcSKai Chieh Chuang int i;
6103901b9fcSKai Chieh Chuang irqreturn_t irq_ret = IRQ_HANDLED;
6113901b9fcSKai Chieh Chuang
6123901b9fcSKai Chieh Chuang /* get irq that is sent to MCU */
6133901b9fcSKai Chieh Chuang regmap_read(afe->regmap, AFE_IRQ_MCU_EN, &mcu_en);
6143901b9fcSKai Chieh Chuang
6153901b9fcSKai Chieh Chuang ret = regmap_read(afe->regmap, AFE_IRQ_MCU_STATUS, &status);
6163901b9fcSKai Chieh Chuang if (ret || (status & mcu_en) == 0) {
6173901b9fcSKai Chieh Chuang dev_err(afe->dev, "%s(), irq status err, ret %d, status 0x%x, mcu_en 0x%x\n",
6183901b9fcSKai Chieh Chuang __func__, ret, status, mcu_en);
6193901b9fcSKai Chieh Chuang
6203901b9fcSKai Chieh Chuang /* only clear IRQ which is sent to MCU */
6213901b9fcSKai Chieh Chuang status = mcu_en & AFE_IRQ_STATUS_BITS;
6223901b9fcSKai Chieh Chuang
6233901b9fcSKai Chieh Chuang irq_ret = IRQ_NONE;
6243901b9fcSKai Chieh Chuang goto err_irq;
6253901b9fcSKai Chieh Chuang }
6263901b9fcSKai Chieh Chuang
6273901b9fcSKai Chieh Chuang for (i = 0; i < MT6797_MEMIF_NUM; i++) {
6283901b9fcSKai Chieh Chuang struct mtk_base_afe_memif *memif = &afe->memif[i];
6293901b9fcSKai Chieh Chuang
6303901b9fcSKai Chieh Chuang if (!memif->substream)
6313901b9fcSKai Chieh Chuang continue;
6323901b9fcSKai Chieh Chuang
6333901b9fcSKai Chieh Chuang irq = &afe->irqs[memif->irq_usage];
6343901b9fcSKai Chieh Chuang
6353901b9fcSKai Chieh Chuang if (status & (1 << irq->irq_data->irq_en_shift))
6363901b9fcSKai Chieh Chuang snd_pcm_period_elapsed(memif->substream);
6373901b9fcSKai Chieh Chuang }
6383901b9fcSKai Chieh Chuang
6393901b9fcSKai Chieh Chuang err_irq:
6403901b9fcSKai Chieh Chuang /* clear irq */
6413901b9fcSKai Chieh Chuang regmap_write(afe->regmap,
6423901b9fcSKai Chieh Chuang AFE_IRQ_MCU_CLR,
6433901b9fcSKai Chieh Chuang status & AFE_IRQ_STATUS_BITS);
6443901b9fcSKai Chieh Chuang
6453901b9fcSKai Chieh Chuang return irq_ret;
6463901b9fcSKai Chieh Chuang }
6473901b9fcSKai Chieh Chuang
mt6797_afe_runtime_suspend(struct device * dev)6483901b9fcSKai Chieh Chuang static int mt6797_afe_runtime_suspend(struct device *dev)
6493901b9fcSKai Chieh Chuang {
6503901b9fcSKai Chieh Chuang struct mtk_base_afe *afe = dev_get_drvdata(dev);
6513901b9fcSKai Chieh Chuang unsigned int afe_on_retm;
6523901b9fcSKai Chieh Chuang int retry = 0;
6533901b9fcSKai Chieh Chuang
6543901b9fcSKai Chieh Chuang /* disable AFE */
6553901b9fcSKai Chieh Chuang regmap_update_bits(afe->regmap, AFE_DAC_CON0, AFE_ON_MASK_SFT, 0x0);
6563901b9fcSKai Chieh Chuang do {
6573901b9fcSKai Chieh Chuang regmap_read(afe->regmap, AFE_DAC_CON0, &afe_on_retm);
6583901b9fcSKai Chieh Chuang if ((afe_on_retm & AFE_ON_RETM_MASK_SFT) == 0)
6593901b9fcSKai Chieh Chuang break;
6603901b9fcSKai Chieh Chuang
6613901b9fcSKai Chieh Chuang udelay(10);
6623901b9fcSKai Chieh Chuang } while (++retry < 100000);
6633901b9fcSKai Chieh Chuang
6643901b9fcSKai Chieh Chuang if (retry)
6653901b9fcSKai Chieh Chuang dev_warn(afe->dev, "%s(), retry %d\n", __func__, retry);
6663901b9fcSKai Chieh Chuang
6673901b9fcSKai Chieh Chuang /* make sure all irq status are cleared */
6683901b9fcSKai Chieh Chuang regmap_update_bits(afe->regmap, AFE_IRQ_MCU_CLR, 0xffff, 0xffff);
6693901b9fcSKai Chieh Chuang
6703901b9fcSKai Chieh Chuang return mt6797_afe_disable_clock(afe);
6713901b9fcSKai Chieh Chuang }
6723901b9fcSKai Chieh Chuang
mt6797_afe_runtime_resume(struct device * dev)6733901b9fcSKai Chieh Chuang static int mt6797_afe_runtime_resume(struct device *dev)
6743901b9fcSKai Chieh Chuang {
6753901b9fcSKai Chieh Chuang struct mtk_base_afe *afe = dev_get_drvdata(dev);
6763901b9fcSKai Chieh Chuang int ret;
6773901b9fcSKai Chieh Chuang
6783901b9fcSKai Chieh Chuang ret = mt6797_afe_enable_clock(afe);
6793901b9fcSKai Chieh Chuang if (ret)
6803901b9fcSKai Chieh Chuang return ret;
6813901b9fcSKai Chieh Chuang
6823901b9fcSKai Chieh Chuang /* irq signal to mcu only */
6833901b9fcSKai Chieh Chuang regmap_write(afe->regmap, AFE_IRQ_MCU_EN, AFE_IRQ_MCU_EN_MASK_SFT);
6843901b9fcSKai Chieh Chuang
6853901b9fcSKai Chieh Chuang /* force all memif use normal mode */
6863901b9fcSKai Chieh Chuang regmap_update_bits(afe->regmap, AFE_MEMIF_HDALIGN,
6873901b9fcSKai Chieh Chuang 0x7ff << 16, 0x7ff << 16);
6883901b9fcSKai Chieh Chuang /* force cpu use normal mode when access sram data */
6893901b9fcSKai Chieh Chuang regmap_update_bits(afe->regmap, AFE_MEMIF_MSB,
6903901b9fcSKai Chieh Chuang CPU_COMPACT_MODE_MASK_SFT, 0);
6913901b9fcSKai Chieh Chuang /* force cpu use 8_24 format when writing 32bit data */
6923901b9fcSKai Chieh Chuang regmap_update_bits(afe->regmap, AFE_MEMIF_MSB,
6933901b9fcSKai Chieh Chuang CPU_HD_ALIGN_MASK_SFT, 0);
6943901b9fcSKai Chieh Chuang
6953901b9fcSKai Chieh Chuang /* set all output port to 24bit */
6963901b9fcSKai Chieh Chuang regmap_update_bits(afe->regmap, AFE_CONN_24BIT,
6973901b9fcSKai Chieh Chuang 0x3fffffff, 0x3fffffff);
6983901b9fcSKai Chieh Chuang
6993901b9fcSKai Chieh Chuang /* enable AFE */
7003901b9fcSKai Chieh Chuang regmap_update_bits(afe->regmap, AFE_DAC_CON0,
7013901b9fcSKai Chieh Chuang AFE_ON_MASK_SFT,
7023901b9fcSKai Chieh Chuang 0x1 << AFE_ON_SFT);
7033901b9fcSKai Chieh Chuang
7043901b9fcSKai Chieh Chuang return 0;
7053901b9fcSKai Chieh Chuang }
7063901b9fcSKai Chieh Chuang
mt6797_afe_component_probe(struct snd_soc_component * component)707b3c702f5SKaiChieh Chuang static int mt6797_afe_component_probe(struct snd_soc_component *component)
708b3c702f5SKaiChieh Chuang {
709b3c702f5SKaiChieh Chuang return mtk_afe_add_sub_dai_control(component);
710b3c702f5SKaiChieh Chuang }
711b3c702f5SKaiChieh Chuang
712b3c702f5SKaiChieh Chuang static const struct snd_soc_component_driver mt6797_afe_component = {
713b3c702f5SKaiChieh Chuang .name = AFE_PCM_NAME,
714b3c702f5SKaiChieh Chuang .probe = mt6797_afe_component_probe,
7151fddf424SKuninori Morimoto .pointer = mtk_afe_pcm_pointer,
7161fddf424SKuninori Morimoto .pcm_construct = mtk_afe_pcm_new,
717b3c702f5SKaiChieh Chuang };
718b3c702f5SKaiChieh Chuang
mt6797_dai_memif_register(struct mtk_base_afe * afe)719c1d9b419SKaiChieh Chuang static int mt6797_dai_memif_register(struct mtk_base_afe *afe)
720c1d9b419SKaiChieh Chuang {
721c1d9b419SKaiChieh Chuang struct mtk_base_afe_dai *dai;
722c1d9b419SKaiChieh Chuang
723c1d9b419SKaiChieh Chuang dai = devm_kzalloc(afe->dev, sizeof(*dai), GFP_KERNEL);
724c1d9b419SKaiChieh Chuang if (!dai)
725c1d9b419SKaiChieh Chuang return -ENOMEM;
726c1d9b419SKaiChieh Chuang
727c1d9b419SKaiChieh Chuang list_add(&dai->list, &afe->sub_dais);
728c1d9b419SKaiChieh Chuang
729c1d9b419SKaiChieh Chuang dai->dai_drivers = mt6797_memif_dai_driver;
730c1d9b419SKaiChieh Chuang dai->num_dai_drivers = ARRAY_SIZE(mt6797_memif_dai_driver);
731c1d9b419SKaiChieh Chuang
732c1d9b419SKaiChieh Chuang dai->dapm_widgets = mt6797_memif_widgets;
733c1d9b419SKaiChieh Chuang dai->num_dapm_widgets = ARRAY_SIZE(mt6797_memif_widgets);
734c1d9b419SKaiChieh Chuang dai->dapm_routes = mt6797_memif_routes;
735c1d9b419SKaiChieh Chuang dai->num_dapm_routes = ARRAY_SIZE(mt6797_memif_routes);
736c1d9b419SKaiChieh Chuang return 0;
737c1d9b419SKaiChieh Chuang }
738c1d9b419SKaiChieh Chuang
739c1d9b419SKaiChieh Chuang typedef int (*dai_register_cb)(struct mtk_base_afe *);
740c1d9b419SKaiChieh Chuang static const dai_register_cb dai_register_cbs[] = {
741c1d9b419SKaiChieh Chuang mt6797_dai_adda_register,
742c1d9b419SKaiChieh Chuang mt6797_dai_pcm_register,
743c1d9b419SKaiChieh Chuang mt6797_dai_hostless_register,
744c1d9b419SKaiChieh Chuang mt6797_dai_memif_register,
745c1d9b419SKaiChieh Chuang };
746c1d9b419SKaiChieh Chuang
mt6797_afe_pcm_dev_probe(struct platform_device * pdev)7473901b9fcSKai Chieh Chuang static int mt6797_afe_pcm_dev_probe(struct platform_device *pdev)
7483901b9fcSKai Chieh Chuang {
7493901b9fcSKai Chieh Chuang struct mtk_base_afe *afe;
7503901b9fcSKai Chieh Chuang struct mt6797_afe_private *afe_priv;
7513901b9fcSKai Chieh Chuang struct device *dev;
7523901b9fcSKai Chieh Chuang int i, irq_id, ret;
7533901b9fcSKai Chieh Chuang
7543901b9fcSKai Chieh Chuang afe = devm_kzalloc(&pdev->dev, sizeof(*afe), GFP_KERNEL);
7553901b9fcSKai Chieh Chuang if (!afe)
7563901b9fcSKai Chieh Chuang return -ENOMEM;
7573901b9fcSKai Chieh Chuang
7583901b9fcSKai Chieh Chuang afe->platform_priv = devm_kzalloc(&pdev->dev, sizeof(*afe_priv),
7593901b9fcSKai Chieh Chuang GFP_KERNEL);
7603901b9fcSKai Chieh Chuang if (!afe->platform_priv)
7613901b9fcSKai Chieh Chuang return -ENOMEM;
7623901b9fcSKai Chieh Chuang
7633901b9fcSKai Chieh Chuang afe_priv = afe->platform_priv;
7643901b9fcSKai Chieh Chuang afe->dev = &pdev->dev;
7653901b9fcSKai Chieh Chuang dev = afe->dev;
7663901b9fcSKai Chieh Chuang
7673901b9fcSKai Chieh Chuang /* initial audio related clock */
7683901b9fcSKai Chieh Chuang ret = mt6797_init_clock(afe);
7693901b9fcSKai Chieh Chuang if (ret) {
7703901b9fcSKai Chieh Chuang dev_err(dev, "init clock error\n");
7713901b9fcSKai Chieh Chuang return ret;
7723901b9fcSKai Chieh Chuang }
7733901b9fcSKai Chieh Chuang
7743901b9fcSKai Chieh Chuang /* regmap init */
77561e799e3SYueHaibing afe->base_addr = devm_platform_ioremap_resource(pdev, 0);
7763901b9fcSKai Chieh Chuang if (IS_ERR(afe->base_addr))
7773901b9fcSKai Chieh Chuang return PTR_ERR(afe->base_addr);
7783901b9fcSKai Chieh Chuang
7793901b9fcSKai Chieh Chuang afe->regmap = devm_regmap_init_mmio(&pdev->dev, afe->base_addr,
7803901b9fcSKai Chieh Chuang &mt6797_afe_regmap_config);
7813901b9fcSKai Chieh Chuang if (IS_ERR(afe->regmap))
7823901b9fcSKai Chieh Chuang return PTR_ERR(afe->regmap);
7833901b9fcSKai Chieh Chuang
7843901b9fcSKai Chieh Chuang /* init memif */
7853901b9fcSKai Chieh Chuang afe->memif_size = MT6797_MEMIF_NUM;
7863901b9fcSKai Chieh Chuang afe->memif = devm_kcalloc(dev, afe->memif_size, sizeof(*afe->memif),
7873901b9fcSKai Chieh Chuang GFP_KERNEL);
7883901b9fcSKai Chieh Chuang if (!afe->memif)
7893901b9fcSKai Chieh Chuang return -ENOMEM;
7903901b9fcSKai Chieh Chuang
7913901b9fcSKai Chieh Chuang for (i = 0; i < afe->memif_size; i++) {
7923901b9fcSKai Chieh Chuang afe->memif[i].data = &memif_data[i];
7933901b9fcSKai Chieh Chuang afe->memif[i].irq_usage = -1;
7943901b9fcSKai Chieh Chuang }
7953901b9fcSKai Chieh Chuang
7963901b9fcSKai Chieh Chuang mutex_init(&afe->irq_alloc_lock);
7973901b9fcSKai Chieh Chuang
7983901b9fcSKai Chieh Chuang /* irq initialize */
7993901b9fcSKai Chieh Chuang afe->irqs_size = MT6797_IRQ_NUM;
8003901b9fcSKai Chieh Chuang afe->irqs = devm_kcalloc(dev, afe->irqs_size, sizeof(*afe->irqs),
8013901b9fcSKai Chieh Chuang GFP_KERNEL);
8023901b9fcSKai Chieh Chuang if (!afe->irqs)
8033901b9fcSKai Chieh Chuang return -ENOMEM;
8043901b9fcSKai Chieh Chuang
8053901b9fcSKai Chieh Chuang for (i = 0; i < afe->irqs_size; i++)
8063901b9fcSKai Chieh Chuang afe->irqs[i].irq_data = &irq_data[i];
8073901b9fcSKai Chieh Chuang
8083901b9fcSKai Chieh Chuang /* request irq */
8093901b9fcSKai Chieh Chuang irq_id = platform_get_irq(pdev, 0);
810adb69968STang Bin if (irq_id < 0)
811adb69968STang Bin return irq_id;
812adb69968STang Bin
8133901b9fcSKai Chieh Chuang ret = devm_request_irq(dev, irq_id, mt6797_afe_irq_handler,
8143901b9fcSKai Chieh Chuang IRQF_TRIGGER_NONE, "asys-isr", (void *)afe);
8153901b9fcSKai Chieh Chuang if (ret) {
8163901b9fcSKai Chieh Chuang dev_err(dev, "could not request_irq for asys-isr\n");
8173901b9fcSKai Chieh Chuang return ret;
8183901b9fcSKai Chieh Chuang }
8193901b9fcSKai Chieh Chuang
820b3c702f5SKaiChieh Chuang /* init sub_dais */
821c1d9b419SKaiChieh Chuang INIT_LIST_HEAD(&afe->sub_dais);
822b3c702f5SKaiChieh Chuang
823c1d9b419SKaiChieh Chuang for (i = 0; i < ARRAY_SIZE(dai_register_cbs); i++) {
824c1d9b419SKaiChieh Chuang ret = dai_register_cbs[i](afe);
825c1d9b419SKaiChieh Chuang if (ret) {
826c1d9b419SKaiChieh Chuang dev_warn(afe->dev, "dai register i %d fail, ret %d\n",
827c1d9b419SKaiChieh Chuang i, ret);
828c1d9b419SKaiChieh Chuang return ret;
829c1d9b419SKaiChieh Chuang }
830c1d9b419SKaiChieh Chuang }
831b3c702f5SKaiChieh Chuang
832b3c702f5SKaiChieh Chuang /* init dai_driver and component_driver */
833c1d9b419SKaiChieh Chuang ret = mtk_afe_combine_sub_dai(afe);
834c1d9b419SKaiChieh Chuang if (ret) {
835c1d9b419SKaiChieh Chuang dev_warn(afe->dev, "mtk_afe_combine_sub_dai fail, ret %d\n",
836c1d9b419SKaiChieh Chuang ret);
837c1d9b419SKaiChieh Chuang return ret;
838c1d9b419SKaiChieh Chuang }
839b3c702f5SKaiChieh Chuang
8403901b9fcSKai Chieh Chuang afe->mtk_afe_hardware = &mt6797_afe_hardware;
8413901b9fcSKai Chieh Chuang afe->memif_fs = mt6797_memif_fs;
8423901b9fcSKai Chieh Chuang afe->irq_fs = mt6797_irq_fs;
8433901b9fcSKai Chieh Chuang
8443901b9fcSKai Chieh Chuang afe->runtime_resume = mt6797_afe_runtime_resume;
8453901b9fcSKai Chieh Chuang afe->runtime_suspend = mt6797_afe_runtime_suspend;
8463901b9fcSKai Chieh Chuang
8473901b9fcSKai Chieh Chuang platform_set_drvdata(pdev, afe);
8483901b9fcSKai Chieh Chuang
8493901b9fcSKai Chieh Chuang pm_runtime_enable(dev);
8503901b9fcSKai Chieh Chuang if (!pm_runtime_enabled(dev))
8513901b9fcSKai Chieh Chuang goto err_pm_disable;
8523901b9fcSKai Chieh Chuang pm_runtime_get_sync(&pdev->dev);
8533901b9fcSKai Chieh Chuang
854b3c702f5SKaiChieh Chuang /* register component */
855b3c702f5SKaiChieh Chuang ret = devm_snd_soc_register_component(dev, &mt6797_afe_component,
8563901b9fcSKai Chieh Chuang NULL, 0);
8573901b9fcSKai Chieh Chuang if (ret) {
8583901b9fcSKai Chieh Chuang dev_warn(dev, "err_platform\n");
8593901b9fcSKai Chieh Chuang goto err_pm_disable;
8603901b9fcSKai Chieh Chuang }
8613901b9fcSKai Chieh Chuang
8623901b9fcSKai Chieh Chuang ret = devm_snd_soc_register_component(afe->dev,
8633901b9fcSKai Chieh Chuang &mt6797_afe_pcm_dai_component,
864b3c702f5SKaiChieh Chuang afe->dai_drivers,
865b3c702f5SKaiChieh Chuang afe->num_dai_drivers);
8663901b9fcSKai Chieh Chuang if (ret) {
8673901b9fcSKai Chieh Chuang dev_warn(dev, "err_dai_component\n");
8683901b9fcSKai Chieh Chuang goto err_pm_disable;
8693901b9fcSKai Chieh Chuang }
8703901b9fcSKai Chieh Chuang
8713901b9fcSKai Chieh Chuang return 0;
8723901b9fcSKai Chieh Chuang
8733901b9fcSKai Chieh Chuang err_pm_disable:
8743901b9fcSKai Chieh Chuang pm_runtime_disable(dev);
8753901b9fcSKai Chieh Chuang
8763901b9fcSKai Chieh Chuang return ret;
8773901b9fcSKai Chieh Chuang }
8783901b9fcSKai Chieh Chuang
mt6797_afe_pcm_dev_remove(struct platform_device * pdev)879*edd8a5cdSUwe Kleine-König static void mt6797_afe_pcm_dev_remove(struct platform_device *pdev)
8803901b9fcSKai Chieh Chuang {
8813901b9fcSKai Chieh Chuang pm_runtime_disable(&pdev->dev);
8823901b9fcSKai Chieh Chuang if (!pm_runtime_status_suspended(&pdev->dev))
8833901b9fcSKai Chieh Chuang mt6797_afe_runtime_suspend(&pdev->dev);
8843901b9fcSKai Chieh Chuang pm_runtime_put_sync(&pdev->dev);
8853901b9fcSKai Chieh Chuang }
8863901b9fcSKai Chieh Chuang
8873901b9fcSKai Chieh Chuang static const struct of_device_id mt6797_afe_pcm_dt_match[] = {
8883901b9fcSKai Chieh Chuang { .compatible = "mediatek,mt6797-audio", },
8893901b9fcSKai Chieh Chuang {},
8903901b9fcSKai Chieh Chuang };
8913901b9fcSKai Chieh Chuang MODULE_DEVICE_TABLE(of, mt6797_afe_pcm_dt_match);
8923901b9fcSKai Chieh Chuang
8933901b9fcSKai Chieh Chuang static const struct dev_pm_ops mt6797_afe_pm_ops = {
8943901b9fcSKai Chieh Chuang SET_RUNTIME_PM_OPS(mt6797_afe_runtime_suspend,
8953901b9fcSKai Chieh Chuang mt6797_afe_runtime_resume, NULL)
8963901b9fcSKai Chieh Chuang };
8973901b9fcSKai Chieh Chuang
8983901b9fcSKai Chieh Chuang static struct platform_driver mt6797_afe_pcm_driver = {
8993901b9fcSKai Chieh Chuang .driver = {
9003901b9fcSKai Chieh Chuang .name = "mt6797-audio",
9013901b9fcSKai Chieh Chuang .of_match_table = mt6797_afe_pcm_dt_match,
9023901b9fcSKai Chieh Chuang .pm = &mt6797_afe_pm_ops,
9033901b9fcSKai Chieh Chuang },
9043901b9fcSKai Chieh Chuang .probe = mt6797_afe_pcm_dev_probe,
905*edd8a5cdSUwe Kleine-König .remove_new = mt6797_afe_pcm_dev_remove,
9063901b9fcSKai Chieh Chuang };
9073901b9fcSKai Chieh Chuang
9083901b9fcSKai Chieh Chuang module_platform_driver(mt6797_afe_pcm_driver);
9093901b9fcSKai Chieh Chuang
9103901b9fcSKai Chieh Chuang MODULE_DESCRIPTION("Mediatek ALSA SoC AFE platform driver for 6797");
9113901b9fcSKai Chieh Chuang MODULE_AUTHOR("KaiChieh Chuang <kaichieh.chuang@mediatek.com>");
9123901b9fcSKai Chieh Chuang MODULE_LICENSE("GPL v2");
913