1 // SPDX-License-Identifier: GPL-2.0
3 // mt6797-mt6351.c -- MT6797 MT6351 ALSA SoC machine driver
5 // Copyright (c) 2018 MediaTek Inc.
6 // Author: KaiChieh Chuang <kaichieh.chuang@mediatek.com>
8 #include <linux/module.h>
11 #include "mt6797-afe-common.h"
13 SND_SOC_DAILINK_DEFS(playback_1
,
14 DAILINK_COMP_ARRAY(COMP_CPU("DL1")),
15 DAILINK_COMP_ARRAY(COMP_DUMMY()),
16 DAILINK_COMP_ARRAY(COMP_EMPTY()));
18 SND_SOC_DAILINK_DEFS(playback_2
,
19 DAILINK_COMP_ARRAY(COMP_CPU("DL2")),
20 DAILINK_COMP_ARRAY(COMP_DUMMY()),
21 DAILINK_COMP_ARRAY(COMP_EMPTY()));
23 SND_SOC_DAILINK_DEFS(playback_3
,
24 DAILINK_COMP_ARRAY(COMP_CPU("DL3")),
25 DAILINK_COMP_ARRAY(COMP_DUMMY()),
26 DAILINK_COMP_ARRAY(COMP_EMPTY()));
28 SND_SOC_DAILINK_DEFS(capture_1
,
29 DAILINK_COMP_ARRAY(COMP_CPU("UL1")),
30 DAILINK_COMP_ARRAY(COMP_DUMMY()),
31 DAILINK_COMP_ARRAY(COMP_EMPTY()));
33 SND_SOC_DAILINK_DEFS(capture_2
,
34 DAILINK_COMP_ARRAY(COMP_CPU("UL2")),
35 DAILINK_COMP_ARRAY(COMP_DUMMY()),
36 DAILINK_COMP_ARRAY(COMP_EMPTY()));
38 SND_SOC_DAILINK_DEFS(capture_3
,
39 DAILINK_COMP_ARRAY(COMP_CPU("UL3")),
40 DAILINK_COMP_ARRAY(COMP_DUMMY()),
41 DAILINK_COMP_ARRAY(COMP_EMPTY()));
43 SND_SOC_DAILINK_DEFS(capture_mono_1
,
44 DAILINK_COMP_ARRAY(COMP_CPU("UL_MONO_1")),
45 DAILINK_COMP_ARRAY(COMP_DUMMY()),
46 DAILINK_COMP_ARRAY(COMP_EMPTY()));
48 SND_SOC_DAILINK_DEFS(hostless_lpbk
,
49 DAILINK_COMP_ARRAY(COMP_CPU("Hostless LPBK DAI")),
50 DAILINK_COMP_ARRAY(COMP_DUMMY()),
51 DAILINK_COMP_ARRAY(COMP_EMPTY()));
53 SND_SOC_DAILINK_DEFS(hostless_speech
,
54 DAILINK_COMP_ARRAY(COMP_CPU("Hostless Speech DAI")),
55 DAILINK_COMP_ARRAY(COMP_DUMMY()),
56 DAILINK_COMP_ARRAY(COMP_EMPTY()));
58 SND_SOC_DAILINK_DEFS(primary_codec
,
59 DAILINK_COMP_ARRAY(COMP_CPU("ADDA")),
60 DAILINK_COMP_ARRAY(COMP_CODEC(NULL
, "mt6351-snd-codec-aif1")),
61 DAILINK_COMP_ARRAY(COMP_EMPTY()));
63 SND_SOC_DAILINK_DEFS(pcm1
,
64 DAILINK_COMP_ARRAY(COMP_CPU("PCM 1")),
65 DAILINK_COMP_ARRAY(COMP_DUMMY()),
66 DAILINK_COMP_ARRAY(COMP_EMPTY()));
68 SND_SOC_DAILINK_DEFS(pcm2
,
69 DAILINK_COMP_ARRAY(COMP_CPU("PCM 2")),
70 DAILINK_COMP_ARRAY(COMP_DUMMY()),
71 DAILINK_COMP_ARRAY(COMP_EMPTY()));
73 static struct snd_soc_dai_link mt6797_mt6351_dai_links
[] = {
77 .stream_name
= "Playback_1",
78 .trigger
= {SND_SOC_DPCM_TRIGGER_PRE
,
79 SND_SOC_DPCM_TRIGGER_PRE
},
82 SND_SOC_DAILINK_REG(playback_1
),
86 .stream_name
= "Playback_2",
87 .trigger
= {SND_SOC_DPCM_TRIGGER_PRE
,
88 SND_SOC_DPCM_TRIGGER_PRE
},
91 SND_SOC_DAILINK_REG(playback_2
),
95 .stream_name
= "Playback_3",
96 .trigger
= {SND_SOC_DPCM_TRIGGER_PRE
,
97 SND_SOC_DPCM_TRIGGER_PRE
},
100 SND_SOC_DAILINK_REG(playback_3
),
104 .stream_name
= "Capture_1",
105 .trigger
= {SND_SOC_DPCM_TRIGGER_PRE
,
106 SND_SOC_DPCM_TRIGGER_PRE
},
109 SND_SOC_DAILINK_REG(capture_1
),
113 .stream_name
= "Capture_2",
114 .trigger
= {SND_SOC_DPCM_TRIGGER_PRE
,
115 SND_SOC_DPCM_TRIGGER_PRE
},
118 SND_SOC_DAILINK_REG(capture_2
),
122 .stream_name
= "Capture_3",
123 .trigger
= {SND_SOC_DPCM_TRIGGER_PRE
,
124 SND_SOC_DPCM_TRIGGER_PRE
},
127 SND_SOC_DAILINK_REG(capture_3
),
130 .name
= "Capture_Mono_1",
131 .stream_name
= "Capture_Mono_1",
132 .trigger
= {SND_SOC_DPCM_TRIGGER_PRE
,
133 SND_SOC_DPCM_TRIGGER_PRE
},
136 SND_SOC_DAILINK_REG(capture_mono_1
),
139 .name
= "Hostless_LPBK",
140 .stream_name
= "Hostless_LPBK",
141 .trigger
= {SND_SOC_DPCM_TRIGGER_PRE
,
142 SND_SOC_DPCM_TRIGGER_PRE
},
147 SND_SOC_DAILINK_REG(hostless_lpbk
),
150 .name
= "Hostless_Speech",
151 .stream_name
= "Hostless_Speech",
152 .trigger
= {SND_SOC_DPCM_TRIGGER_PRE
,
153 SND_SOC_DPCM_TRIGGER_PRE
},
158 SND_SOC_DAILINK_REG(hostless_speech
),
162 .name
= "Primary Codec",
167 SND_SOC_DAILINK_REG(primary_codec
),
175 SND_SOC_DAILINK_REG(pcm1
),
183 SND_SOC_DAILINK_REG(pcm2
),
187 static struct snd_soc_card mt6797_mt6351_card
= {
188 .name
= "mt6797-mt6351",
189 .owner
= THIS_MODULE
,
190 .dai_link
= mt6797_mt6351_dai_links
,
191 .num_links
= ARRAY_SIZE(mt6797_mt6351_dai_links
),
194 static int mt6797_mt6351_dev_probe(struct platform_device
*pdev
)
196 struct snd_soc_card
*card
= &mt6797_mt6351_card
;
197 struct device_node
*platform_node
, *codec_node
;
198 struct snd_soc_dai_link
*dai_link
;
201 card
->dev
= &pdev
->dev
;
203 platform_node
= of_parse_phandle(pdev
->dev
.of_node
,
204 "mediatek,platform", 0);
205 if (!platform_node
) {
206 dev_err(&pdev
->dev
, "Property 'platform' missing or invalid\n");
209 for_each_card_prelinks(card
, i
, dai_link
) {
210 if (dai_link
->platforms
->name
)
212 dai_link
->platforms
->of_node
= platform_node
;
215 codec_node
= of_parse_phandle(pdev
->dev
.of_node
,
216 "mediatek,audio-codec", 0);
219 "Property 'audio-codec' missing or invalid\n");
222 for_each_card_prelinks(card
, i
, dai_link
) {
223 if (dai_link
->codecs
->name
)
225 dai_link
->codecs
->of_node
= codec_node
;
228 ret
= devm_snd_soc_register_card(&pdev
->dev
, card
);
230 dev_err(&pdev
->dev
, "%s snd_soc_register_card fail %d\n",
237 static const struct of_device_id mt6797_mt6351_dt_match
[] = {
238 {.compatible
= "mediatek,mt6797-mt6351-sound",},
243 static struct platform_driver mt6797_mt6351_driver
= {
245 .name
= "mt6797-mt6351",
247 .of_match_table
= mt6797_mt6351_dt_match
,
250 .probe
= mt6797_mt6351_dev_probe
,
253 module_platform_driver(mt6797_mt6351_driver
);
255 /* Module information */
256 MODULE_DESCRIPTION("MT6797 MT6351 ALSA SoC machine driver");
257 MODULE_AUTHOR("KaiChieh Chuang <kaichieh.chuang@mediatek.com>");
258 MODULE_LICENSE("GPL v2");
259 MODULE_ALIAS("mt6797 mt6351 soc card");