1// SPDX-License-Identifier: GPL-2.0-only
2/*
3 * soc-acpi-intel-mtl-match.c - tables and support for MTL ACPI enumeration.
4 *
5 * Copyright (c) 2022, Intel Corporation.
6 *
7 */
8
9#include <sound/soc-acpi.h>
10#include <sound/soc-acpi-intel-match.h>
11#include "soc-acpi-intel-sdw-mockup-match.h"
12
13static const struct snd_soc_acpi_codecs mtl_max98357a_amp = {
14	.num_codecs = 1,
15	.codecs = {"MX98357A"}
16};
17
18static const struct snd_soc_acpi_codecs mtl_max98360a_amp = {
19	.num_codecs = 1,
20	.codecs = {"MX98360A"}
21};
22
23static const struct snd_soc_acpi_codecs mtl_rt1019p_amp = {
24	.num_codecs = 1,
25	.codecs = {"RTL1019"}
26};
27
28static const struct snd_soc_acpi_codecs mtl_rt5682_rt5682s_hp = {
29	.num_codecs = 2,
30	.codecs = {"10EC5682", "RTL5682"},
31};
32
33static const struct snd_soc_acpi_codecs mtl_essx_83x6 = {
34	.num_codecs = 3,
35	.codecs = { "ESSX8316", "ESSX8326", "ESSX8336"},
36};
37
38static const struct snd_soc_acpi_codecs mtl_lt6911_hdmi = {
39	.num_codecs = 1,
40	.codecs = {"INTC10B0"}
41};
42
43struct snd_soc_acpi_mach snd_soc_acpi_intel_mtl_machines[] = {
44	{
45		.comp_ids = &mtl_rt5682_rt5682s_hp,
46		.drv_name = "mtl_mx98357_rt5682",
47		.machine_quirk = snd_soc_acpi_codec_list,
48		.quirk_data = &mtl_max98357a_amp,
49		.sof_tplg_filename = "sof-mtl-max98357a-rt5682.tplg",
50	},
51	{
52		.comp_ids = &mtl_rt5682_rt5682s_hp,
53		.drv_name = "mtl_mx98360_rt5682",
54		.machine_quirk = snd_soc_acpi_codec_list,
55		.quirk_data = &mtl_max98360a_amp,
56		.sof_tplg_filename = "sof-mtl-max98360a-rt5682.tplg",
57	},
58	{
59		.comp_ids = &mtl_rt5682_rt5682s_hp,
60		.drv_name = "mtl_rt1019_rt5682",
61		.machine_quirk = snd_soc_acpi_codec_list,
62		.quirk_data = &mtl_rt1019p_amp,
63		.sof_tplg_filename = "sof-mtl-rt1019-rt5682.tplg",
64	},
65	{
66		.comp_ids = &mtl_essx_83x6,
67		.drv_name = "mtl_es83x6_c1_h02",
68		.machine_quirk = snd_soc_acpi_codec_list,
69		.quirk_data = &mtl_lt6911_hdmi,
70		.sof_tplg_filename = "sof-mtl-es83x6-ssp1-hdmi-ssp02.tplg",
71	},
72	{
73		.comp_ids = &mtl_essx_83x6,
74		.drv_name = "sof-essx8336",
75		.sof_tplg_filename = "sof-mtl-es8336", /* the tplg suffix is added at run time */
76		.tplg_quirk_mask = SND_SOC_ACPI_TPLG_INTEL_SSP_NUMBER |
77					SND_SOC_ACPI_TPLG_INTEL_SSP_MSB |
78					SND_SOC_ACPI_TPLG_INTEL_DMIC_NUMBER,
79	},
80	{},
81};
82EXPORT_SYMBOL_GPL(snd_soc_acpi_intel_mtl_machines);
83
84static const struct snd_soc_acpi_endpoint single_endpoint = {
85	.num = 0,
86	.aggregated = 0,
87	.group_position = 0,
88	.group_id = 0,
89};
90
91static const struct snd_soc_acpi_endpoint spk_l_endpoint = {
92	.num = 0,
93	.aggregated = 1,
94	.group_position = 0,
95	.group_id = 1,
96};
97
98static const struct snd_soc_acpi_endpoint spk_r_endpoint = {
99	.num = 0,
100	.aggregated = 1,
101	.group_position = 1,
102	.group_id = 1,
103};
104
105static const struct snd_soc_acpi_endpoint rt712_endpoints[] = {
106	{
107		.num = 0,
108		.aggregated = 0,
109		.group_position = 0,
110		.group_id = 0,
111	},
112	{
113		.num = 1,
114		.aggregated = 0,
115		.group_position = 0,
116		.group_id = 0,
117	},
118};
119
120static const struct snd_soc_acpi_adr_device rt711_sdca_0_adr[] = {
121	{
122		.adr = 0x000030025D071101ull,
123		.num_endpoints = 1,
124		.endpoints = &single_endpoint,
125		.name_prefix = "rt711"
126	}
127};
128
129static const struct snd_soc_acpi_adr_device rt712_0_single_adr[] = {
130	{
131		.adr = 0x000030025D071201ull,
132		.num_endpoints = ARRAY_SIZE(rt712_endpoints),
133		.endpoints = rt712_endpoints,
134		.name_prefix = "rt712"
135	}
136};
137
138static const struct snd_soc_acpi_adr_device rt1712_3_single_adr[] = {
139	{
140		.adr = 0x000330025D171201ull,
141		.num_endpoints = 1,
142		.endpoints = &single_endpoint,
143		.name_prefix = "rt712-dmic"
144	}
145};
146
147static const struct snd_soc_acpi_adr_device mx8373_0_adr[] = {
148	{
149		.adr = 0x000023019F837300ull,
150		.num_endpoints = 1,
151		.endpoints = &spk_l_endpoint,
152		.name_prefix = "Left"
153	},
154	{
155		.adr = 0x000027019F837300ull,
156		.num_endpoints = 1,
157		.endpoints = &spk_r_endpoint,
158		.name_prefix = "Right"
159	}
160};
161
162static const struct snd_soc_acpi_adr_device rt5682_2_adr[] = {
163	{
164		.adr = 0x000221025D568200ull,
165		.num_endpoints = 1,
166		.endpoints = &single_endpoint,
167		.name_prefix = "rt5682"
168	}
169};
170
171static const struct snd_soc_acpi_adr_device rt1316_2_group1_adr[] = {
172	{
173		.adr = 0x000230025D131601ull,
174		.num_endpoints = 1,
175		.endpoints = &spk_l_endpoint,
176		.name_prefix = "rt1316-1"
177	}
178};
179
180static const struct snd_soc_acpi_adr_device rt1316_3_group1_adr[] = {
181	{
182		.adr = 0x000331025D131601ull,
183		.num_endpoints = 1,
184		.endpoints = &spk_r_endpoint,
185		.name_prefix = "rt1316-2"
186	}
187};
188
189static const struct snd_soc_acpi_adr_device rt1318_1_group1_adr[] = {
190	{
191		.adr = 0x000130025D131801ull,
192		.num_endpoints = 1,
193		.endpoints = &spk_l_endpoint,
194		.name_prefix = "rt1318-1"
195	}
196};
197
198static const struct snd_soc_acpi_adr_device rt1318_2_group1_adr[] = {
199	{
200		.adr = 0x000232025D131801ull,
201		.num_endpoints = 1,
202		.endpoints = &spk_r_endpoint,
203		.name_prefix = "rt1318-2"
204	}
205};
206
207static const struct snd_soc_acpi_adr_device rt714_0_adr[] = {
208	{
209		.adr = 0x000030025D071401ull,
210		.num_endpoints = 1,
211		.endpoints = &single_endpoint,
212		.name_prefix = "rt714"
213	}
214};
215
216static const struct snd_soc_acpi_adr_device rt714_1_adr[] = {
217	{
218		.adr = 0x000130025D071401ull,
219		.num_endpoints = 1,
220		.endpoints = &single_endpoint,
221		.name_prefix = "rt714"
222	}
223};
224
225static const struct snd_soc_acpi_link_adr mtl_712_only[] = {
226	{
227		.mask = BIT(0),
228		.num_adr = ARRAY_SIZE(rt712_0_single_adr),
229		.adr_d = rt712_0_single_adr,
230	},
231	{
232		.mask = BIT(3),
233		.num_adr = ARRAY_SIZE(rt1712_3_single_adr),
234		.adr_d = rt1712_3_single_adr,
235	},
236	{}
237};
238
239static const struct snd_soc_acpi_link_adr rt5682_link2_max98373_link0[] = {
240	/* Expected order: jack -> amp */
241	{
242		.mask = BIT(2),
243		.num_adr = ARRAY_SIZE(rt5682_2_adr),
244		.adr_d = rt5682_2_adr,
245	},
246	{
247		.mask = BIT(0),
248		.num_adr = ARRAY_SIZE(mx8373_0_adr),
249		.adr_d = mx8373_0_adr,
250	},
251	{}
252};
253
254static const struct snd_soc_acpi_link_adr mtl_rvp[] = {
255	{
256		.mask = BIT(0),
257		.num_adr = ARRAY_SIZE(rt711_sdca_0_adr),
258		.adr_d = rt711_sdca_0_adr,
259	},
260	{}
261};
262
263static const struct snd_soc_acpi_link_adr mtl_3_in_1_sdca[] = {
264	{
265		.mask = BIT(0),
266		.num_adr = ARRAY_SIZE(rt711_sdca_0_adr),
267		.adr_d = rt711_sdca_0_adr,
268	},
269	{
270		.mask = BIT(2),
271		.num_adr = ARRAY_SIZE(rt1316_2_group1_adr),
272		.adr_d = rt1316_2_group1_adr,
273	},
274	{
275		.mask = BIT(3),
276		.num_adr = ARRAY_SIZE(rt1316_3_group1_adr),
277		.adr_d = rt1316_3_group1_adr,
278	},
279	{
280		.mask = BIT(1),
281		.num_adr = ARRAY_SIZE(rt714_1_adr),
282		.adr_d = rt714_1_adr,
283	},
284	{}
285};
286
287static const struct snd_soc_acpi_link_adr mtl_sdw_rt1318_l12_rt714_l0[] = {
288	{
289		.mask = BIT(1),
290		.num_adr = ARRAY_SIZE(rt1318_1_group1_adr),
291		.adr_d = rt1318_1_group1_adr,
292	},
293	{
294		.mask = BIT(2),
295		.num_adr = ARRAY_SIZE(rt1318_2_group1_adr),
296		.adr_d = rt1318_2_group1_adr,
297	},
298	{
299		.mask = BIT(0),
300		.num_adr = ARRAY_SIZE(rt714_0_adr),
301		.adr_d = rt714_0_adr,
302	},
303	{}
304};
305
306static const struct snd_soc_acpi_adr_device mx8363_2_adr[] = {
307	{
308		.adr = 0x000230019F836300ull,
309		.num_endpoints = 1,
310		.endpoints = &spk_l_endpoint,
311		.name_prefix = "Left"
312	},
313	{
314		.adr = 0x000231019F836300ull,
315		.num_endpoints = 1,
316		.endpoints = &spk_r_endpoint,
317		.name_prefix = "Right"
318	}
319};
320
321static const struct snd_soc_acpi_adr_device cs42l42_0_adr[] = {
322	{
323		.adr = 0x00001001FA424200ull,
324		.num_endpoints = 1,
325		.endpoints = &single_endpoint,
326		.name_prefix = "cs42l42"
327	}
328};
329
330static const struct snd_soc_acpi_link_adr cs42l42_link0_max98363_link2[] = {
331	/* Expected order: jack -> amp */
332	{
333		.mask = BIT(0),
334		.num_adr = ARRAY_SIZE(cs42l42_0_adr),
335		.adr_d = cs42l42_0_adr,
336	},
337	{
338		.mask = BIT(2),
339		.num_adr = ARRAY_SIZE(mx8363_2_adr),
340		.adr_d = mx8363_2_adr,
341	},
342	{}
343};
344
345/* this table is used when there is no I2S codec present */
346struct snd_soc_acpi_mach snd_soc_acpi_intel_mtl_sdw_machines[] = {
347	/* mockup tests need to be first */
348	{
349		.link_mask = GENMASK(3, 0),
350		.links = sdw_mockup_headset_2amps_mic,
351		.drv_name = "sof_sdw",
352		.sof_tplg_filename = "sof-mtl-rt711-rt1308-rt715.tplg",
353	},
354	{
355		.link_mask = BIT(0) | BIT(1) | BIT(3),
356		.links = sdw_mockup_headset_1amp_mic,
357		.drv_name = "sof_sdw",
358		.sof_tplg_filename = "sof-mtl-rt711-rt1308-mono-rt715.tplg",
359	},
360	{
361		.link_mask = GENMASK(2, 0),
362		.links = sdw_mockup_mic_headset_1amp,
363		.drv_name = "sof_sdw",
364		.sof_tplg_filename = "sof-mtl-rt715-rt711-rt1308-mono.tplg",
365	},
366	{
367		.link_mask = BIT(3) | BIT(0),
368		.links = mtl_712_only,
369		.drv_name = "sof_sdw",
370		.sof_tplg_filename = "sof-mtl-rt712-l0-rt1712-l3.tplg",
371	},
372	{
373		.link_mask = GENMASK(2, 0),
374		.links = mtl_sdw_rt1318_l12_rt714_l0,
375		.drv_name = "sof_sdw",
376		.sof_tplg_filename = "sof-mtl-rt1318-l12-rt714-l0.tplg"
377	},
378	{
379		.link_mask = GENMASK(3, 0),
380		.links = mtl_3_in_1_sdca,
381		.drv_name = "sof_sdw",
382		.sof_tplg_filename = "sof-mtl-rt711-l0-rt1316-l23-rt714-l1.tplg",
383	},
384	{
385		.link_mask = BIT(0),
386		.links = mtl_rvp,
387		.drv_name = "sof_sdw",
388		.sof_tplg_filename = "sof-mtl-rt711.tplg",
389	},
390	{
391		.link_mask = BIT(0) | BIT(2),
392		.links = rt5682_link2_max98373_link0,
393		.drv_name = "sof_sdw",
394		.sof_tplg_filename = "sof-mtl-sdw-rt5682-l2-max98373-l0.tplg",
395	},
396	{
397		.link_mask = BIT(0) | BIT(2),
398		.links = cs42l42_link0_max98363_link2,
399		.drv_name = "sof_sdw",
400		.sof_tplg_filename = "sof-mtl-sdw-cs42l42-l0-max98363-l2.tplg",
401	},
402	{},
403};
404EXPORT_SYMBOL_GPL(snd_soc_acpi_intel_mtl_sdw_machines);
405