1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3  * soc-apci-intel-adl-match.c - tables and support for ADL ACPI enumeration.
4  *
5  * Copyright (c) 2020, Intel Corporation.
6  */
7 
8 #include <sound/soc-acpi.h>
9 #include <sound/soc-acpi-intel-match.h>
10 
11 static const struct snd_soc_acpi_endpoint single_endpoint = {
12 	.num = 0,
13 	.aggregated = 0,
14 	.group_position = 0,
15 	.group_id = 0,
16 };
17 
18 static const struct snd_soc_acpi_endpoint spk_l_endpoint = {
19 	.num = 0,
20 	.aggregated = 1,
21 	.group_position = 0,
22 	.group_id = 1,
23 };
24 
25 static const struct snd_soc_acpi_endpoint spk_r_endpoint = {
26 	.num = 0,
27 	.aggregated = 1,
28 	.group_position = 1,
29 	.group_id = 1,
30 };
31 
32 static const struct snd_soc_acpi_adr_device rt711_0_adr[] = {
33 	{
34 		.adr = 0x000020025D071100ull,
35 		.num_endpoints = 1,
36 		.endpoints = &single_endpoint,
37 		.name_prefix = "rt711"
38 	}
39 };
40 
41 static const struct snd_soc_acpi_adr_device rt1308_1_group1_adr[] = {
42 	{
43 		.adr = 0x000120025D130800ull,
44 		.num_endpoints = 1,
45 		.endpoints = &spk_l_endpoint,
46 		.name_prefix = "rt1308-1"
47 	}
48 };
49 
50 static const struct snd_soc_acpi_adr_device rt1308_2_group1_adr[] = {
51 	{
52 		.adr = 0x000220025D130800ull,
53 		.num_endpoints = 1,
54 		.endpoints = &spk_r_endpoint,
55 		.name_prefix = "rt1308-2"
56 	}
57 };
58 
59 static const struct snd_soc_acpi_adr_device rt715_3_adr[] = {
60 	{
61 		.adr = 0x000320025D071500ull,
62 		.num_endpoints = 1,
63 		.endpoints = &single_endpoint,
64 		.name_prefix = "rt715"
65 	}
66 };
67 
68 static const struct snd_soc_acpi_adr_device rt711_sdca_0_adr[] = {
69 	{
70 		.adr = 0x000030025D071101ull,
71 		.num_endpoints = 1,
72 		.endpoints = &single_endpoint,
73 		.name_prefix = "rt711"
74 	}
75 };
76 
77 static const struct snd_soc_acpi_adr_device rt711_sdca_2_adr[] = {
78 	{
79 		.adr = 0x000230025D071101ull,
80 		.num_endpoints = 1,
81 		.endpoints = &single_endpoint,
82 		.name_prefix = "rt711"
83 	}
84 };
85 
86 static const struct snd_soc_acpi_adr_device rt1316_1_group1_adr[] = {
87 	{
88 		.adr = 0x000131025D131601ull, /* unique ID is set for some reason */
89 		.num_endpoints = 1,
90 		.endpoints = &spk_l_endpoint,
91 		.name_prefix = "rt1316-1"
92 	}
93 };
94 
95 static const struct snd_soc_acpi_adr_device rt1316_2_group1_adr[] = {
96 	{
97 		.adr = 0x000230025D131601ull,
98 		.num_endpoints = 1,
99 		.endpoints = &spk_r_endpoint,
100 		.name_prefix = "rt1316-2"
101 	}
102 };
103 
104 static const struct snd_soc_acpi_adr_device rt1316_3_group1_adr[] = {
105 	{
106 		.adr = 0x000330025D131601ull,
107 		.num_endpoints = 1,
108 		.endpoints = &spk_r_endpoint,
109 		.name_prefix = "rt1316-2"
110 	}
111 };
112 
113 static const struct snd_soc_acpi_adr_device rt1316_0_group2_adr[] = {
114 	{
115 		.adr = 0x000031025D131601ull,
116 		.num_endpoints = 1,
117 		.endpoints = &spk_l_endpoint,
118 		.name_prefix = "rt1316-1"
119 	}
120 };
121 
122 static const struct snd_soc_acpi_adr_device rt1316_1_group2_adr[] = {
123 	{
124 		.adr = 0x000130025D131601ull,
125 		.num_endpoints = 1,
126 		.endpoints = &spk_r_endpoint,
127 		.name_prefix = "rt1316-2"
128 	}
129 };
130 
131 static const struct snd_soc_acpi_adr_device rt1316_2_single_adr[] = {
132 	{
133 		.adr = 0x000230025D131601ull,
134 		.num_endpoints = 1,
135 		.endpoints = &single_endpoint,
136 		.name_prefix = "rt1316-1"
137 	}
138 };
139 
140 static const struct snd_soc_acpi_adr_device rt714_0_adr[] = {
141 	{
142 		.adr = 0x000030025D071401ull,
143 		.num_endpoints = 1,
144 		.endpoints = &single_endpoint,
145 		.name_prefix = "rt714"
146 	}
147 };
148 
149 static const struct snd_soc_acpi_adr_device rt714_2_adr[] = {
150 	{
151 		.adr = 0x000230025D071401ull,
152 		.num_endpoints = 1,
153 		.endpoints = &single_endpoint,
154 		.name_prefix = "rt714"
155 	}
156 };
157 
158 static const struct snd_soc_acpi_adr_device rt714_3_adr[] = {
159 	{
160 		.adr = 0x000330025D071401ull,
161 		.num_endpoints = 1,
162 		.endpoints = &single_endpoint,
163 		.name_prefix = "rt714"
164 	}
165 };
166 
167 static const struct snd_soc_acpi_link_adr adl_default[] = {
168 	{
169 		.mask = BIT(0),
170 		.num_adr = ARRAY_SIZE(rt711_0_adr),
171 		.adr_d = rt711_0_adr,
172 	},
173 	{
174 		.mask = BIT(1),
175 		.num_adr = ARRAY_SIZE(rt1308_1_group1_adr),
176 		.adr_d = rt1308_1_group1_adr,
177 	},
178 	{
179 		.mask = BIT(2),
180 		.num_adr = ARRAY_SIZE(rt1308_2_group1_adr),
181 		.adr_d = rt1308_2_group1_adr,
182 	},
183 	{
184 		.mask = BIT(3),
185 		.num_adr = ARRAY_SIZE(rt715_3_adr),
186 		.adr_d = rt715_3_adr,
187 	},
188 	{}
189 };
190 
191 static const struct snd_soc_acpi_link_adr adl_sdca_default[] = {
192 	{
193 		.mask = BIT(0),
194 		.num_adr = ARRAY_SIZE(rt711_sdca_0_adr),
195 		.adr_d = rt711_sdca_0_adr,
196 	},
197 	{
198 		.mask = BIT(1),
199 		.num_adr = ARRAY_SIZE(rt1316_1_group1_adr),
200 		.adr_d = rt1316_1_group1_adr,
201 	},
202 	{
203 		.mask = BIT(2),
204 		.num_adr = ARRAY_SIZE(rt1316_2_group1_adr),
205 		.adr_d = rt1316_2_group1_adr,
206 	},
207 	{
208 		.mask = BIT(3),
209 		.num_adr = ARRAY_SIZE(rt714_3_adr),
210 		.adr_d = rt714_3_adr,
211 	},
212 	{}
213 };
214 
215 static const struct snd_soc_acpi_link_adr adl_sdca_3_in_1[] = {
216 	{
217 		.mask = BIT(0),
218 		.num_adr = ARRAY_SIZE(rt711_sdca_0_adr),
219 		.adr_d = rt711_sdca_0_adr,
220 	},
221 	{
222 		.mask = BIT(1),
223 		.num_adr = ARRAY_SIZE(rt1316_1_group1_adr),
224 		.adr_d = rt1316_1_group1_adr,
225 	},
226 	{
227 		.mask = BIT(2),
228 		.num_adr = ARRAY_SIZE(rt714_2_adr),
229 		.adr_d = rt714_2_adr,
230 	},
231 	{
232 		.mask = BIT(3),
233 		.num_adr = ARRAY_SIZE(rt1316_3_group1_adr),
234 		.adr_d = rt1316_3_group1_adr,
235 	},
236 	{}
237 };
238 
239 static const struct snd_soc_acpi_link_adr adl_sdw_rt711_link2_rt1316_link01_rt714_link3[] = {
240 	{
241 		.mask = BIT(2),
242 		.num_adr = ARRAY_SIZE(rt711_sdca_2_adr),
243 		.adr_d = rt711_sdca_2_adr,
244 	},
245 	{
246 		.mask = BIT(0),
247 		.num_adr = ARRAY_SIZE(rt1316_0_group2_adr),
248 		.adr_d = rt1316_0_group2_adr,
249 	},
250 	{
251 		.mask = BIT(1),
252 		.num_adr = ARRAY_SIZE(rt1316_1_group2_adr),
253 		.adr_d = rt1316_1_group2_adr,
254 	},
255 	{
256 		.mask = BIT(3),
257 		.num_adr = ARRAY_SIZE(rt714_3_adr),
258 		.adr_d = rt714_3_adr,
259 	},
260 	{}
261 };
262 
263 static const struct snd_soc_acpi_link_adr adl_sdw_rt1316_link12_rt714_link0[] = {
264 	{
265 		.mask = BIT(1),
266 		.num_adr = ARRAY_SIZE(rt1316_1_group1_adr),
267 		.adr_d = rt1316_1_group1_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(0),
276 		.num_adr = ARRAY_SIZE(rt714_0_adr),
277 		.adr_d = rt714_0_adr,
278 	},
279 	{}
280 };
281 
282 static const struct snd_soc_acpi_link_adr adl_sdw_rt1316_link2_rt714_link3[] = {
283 	{
284 		.mask = BIT(2),
285 		.num_adr = ARRAY_SIZE(rt1316_2_single_adr),
286 		.adr_d = rt1316_2_single_adr,
287 	},
288 	{
289 		.mask = BIT(3),
290 		.num_adr = ARRAY_SIZE(rt714_3_adr),
291 		.adr_d = rt714_3_adr,
292 	},
293 	{}
294 };
295 
296 static const struct snd_soc_acpi_link_adr adl_sdw_rt1316_link2_rt714_link0[] = {
297 	{
298 		.mask = BIT(2),
299 		.num_adr = ARRAY_SIZE(rt1316_2_single_adr),
300 		.adr_d = rt1316_2_single_adr,
301 	},
302 	{
303 		.mask = BIT(0),
304 		.num_adr = ARRAY_SIZE(rt714_0_adr),
305 		.adr_d = rt714_0_adr,
306 	},
307 	{}
308 };
309 
310 static const struct snd_soc_acpi_adr_device mx8373_2_adr[] = {
311 	{
312 		.adr = 0x000223019F837300ull,
313 		.num_endpoints = 1,
314 		.endpoints = &spk_l_endpoint,
315 		.name_prefix = "Left"
316 	},
317 	{
318 		.adr = 0x000227019F837300ull,
319 		.num_endpoints = 1,
320 		.endpoints = &spk_r_endpoint,
321 		.name_prefix = "Right"
322 	}
323 };
324 
325 static const struct snd_soc_acpi_adr_device rt5682_0_adr[] = {
326 	{
327 		.adr = 0x000021025D568200ull,
328 		.num_endpoints = 1,
329 		.endpoints = &single_endpoint,
330 		.name_prefix = "rt5682"
331 	}
332 };
333 
334 static const struct snd_soc_acpi_link_adr adl_rvp[] = {
335 	{
336 		.mask = BIT(0),
337 		.num_adr = ARRAY_SIZE(rt711_0_adr),
338 		.adr_d = rt711_0_adr,
339 	},
340 	{}
341 };
342 
343 static const struct snd_soc_acpi_link_adr adl_chromebook_base[] = {
344 	{
345 		.mask = BIT(0),
346 		.num_adr = ARRAY_SIZE(rt5682_0_adr),
347 		.adr_d = rt5682_0_adr,
348 	},
349 	{
350 		.mask = BIT(2),
351 		.num_adr = ARRAY_SIZE(mx8373_2_adr),
352 		.adr_d = mx8373_2_adr,
353 	},
354 	{}
355 };
356 
357 static const struct snd_soc_acpi_codecs adl_max98373_amp = {
358 	.num_codecs = 1,
359 	.codecs = {"MX98373"}
360 };
361 
362 static const struct snd_soc_acpi_codecs adl_max98357a_amp = {
363 	.num_codecs = 1,
364 	.codecs = {"MX98357A"}
365 };
366 
367 static const struct snd_soc_acpi_codecs adl_max98360a_amp = {
368 	.num_codecs = 1,
369 	.codecs = {"MX98360A"}
370 };
371 
372 static const struct snd_soc_acpi_codecs adl_rt5682_rt5682s_hp = {
373 	.num_codecs = 2,
374 	.codecs = {"10EC5682", "RTL5682"},
375 };
376 
377 static const struct snd_soc_acpi_codecs adl_rt1019p_amp = {
378 	.num_codecs = 1,
379 	.codecs = {"RTL1019"}
380 };
381 
382 static const struct snd_soc_acpi_codecs adl_max98390_amp = {
383 	.num_codecs = 1,
384 	.codecs = {"MX98390"}
385 };
386 
387 struct snd_soc_acpi_mach snd_soc_acpi_intel_adl_machines[] = {
388 	{
389 		.comp_ids = &adl_rt5682_rt5682s_hp,
390 		.drv_name = "adl_mx98373_rt5682",
391 		.machine_quirk = snd_soc_acpi_codec_list,
392 		.quirk_data = &adl_max98373_amp,
393 		.sof_fw_filename = "sof-adl.ri",
394 		.sof_tplg_filename = "sof-adl-max98373-rt5682.tplg",
395 	},
396 	{
397 		.comp_ids = &adl_rt5682_rt5682s_hp,
398 		.drv_name = "adl_mx98357_rt5682",
399 		.machine_quirk = snd_soc_acpi_codec_list,
400 		.quirk_data = &adl_max98357a_amp,
401 		.sof_fw_filename = "sof-adl.ri",
402 		.sof_tplg_filename = "sof-adl-max98357a-rt5682.tplg",
403 	},
404 	{
405 		.comp_ids = &adl_rt5682_rt5682s_hp,
406 		.drv_name = "adl_mx98360_rt5682",
407 		.machine_quirk = snd_soc_acpi_codec_list,
408 		.quirk_data = &adl_max98360a_amp,
409 		.sof_fw_filename = "sof-adl.ri",
410 		.sof_tplg_filename = "sof-adl-max98360a-rt5682.tplg",
411 	},
412 	{
413 		.id = "10508825",
414 		.drv_name = "adl_rt1019p_nau8825",
415 		.machine_quirk = snd_soc_acpi_codec_list,
416 		.quirk_data = &adl_rt1019p_amp,
417 		.sof_fw_filename = "sof-adl.ri",
418 		.sof_tplg_filename = "sof-adl-rt1019-nau8825.tplg",
419 	},
420 	{
421 		.id = "10508825",
422 		.drv_name = "adl_max98373_nau8825",
423 		.machine_quirk = snd_soc_acpi_codec_list,
424 		.quirk_data = &adl_max98373_amp,
425 		.sof_fw_filename = "sof-adl.ri",
426 		.sof_tplg_filename = "sof-adl-max98373-nau8825.tplg",
427 	},
428 	{
429 		.id = "10508825",
430 		.drv_name = "adl_mx98360a_nau8825",
431 		.machine_quirk = snd_soc_acpi_codec_list,
432 		.quirk_data = &adl_max98360a_amp,
433 		.sof_fw_filename = "sof-adl.ri",
434 		.sof_tplg_filename = "sof-adl-mx98360a-nau8825.tplg",
435 	},
436 	{
437 		.id = "10508825",
438 		.drv_name = "sof_nau8825",
439 		.sof_fw_filename = "sof-adl.ri",
440 		.sof_tplg_filename = "sof-adl-nau8825.tplg",
441 	},
442 	{
443 		.comp_ids = &adl_rt5682_rt5682s_hp,
444 		.drv_name = "adl_max98390_rt5682",
445 		.machine_quirk = snd_soc_acpi_codec_list,
446 		.quirk_data = &adl_max98390_amp,
447 		.sof_fw_filename = "sof-adl.ri",
448 		.sof_tplg_filename = "sof-adl-max98390-rt5682.tplg",
449 	},
450 	{},
451 };
452 EXPORT_SYMBOL_GPL(snd_soc_acpi_intel_adl_machines);
453 
454 /* this table is used when there is no I2S codec present */
455 struct snd_soc_acpi_mach snd_soc_acpi_intel_adl_sdw_machines[] = {
456 	{
457 		.link_mask = 0xF, /* 4 active links required */
458 		.links = adl_default,
459 		.drv_name = "sof_sdw",
460 		.sof_tplg_filename = "sof-adl-rt711-l0-rt1308-l12-rt715-l3.tplg",
461 	},
462 	{
463 		.link_mask = 0xF, /* 4 active links required */
464 		.links = adl_sdca_default,
465 		.drv_name = "sof_sdw",
466 		.sof_tplg_filename = "sof-adl-rt711-l0-rt1316-l12-rt714-l3.tplg",
467 	},
468 	{
469 		.link_mask = 0xF, /* 4 active links required */
470 		.links = adl_sdca_3_in_1,
471 		.drv_name = "sof_sdw",
472 		.sof_tplg_filename = "sof-adl-rt711-l0-rt1316-l13-rt714-l2.tplg",
473 	},
474 	{
475 		.link_mask = 0xF, /* 4 active links required */
476 		.links = adl_sdw_rt711_link2_rt1316_link01_rt714_link3,
477 		.drv_name = "sof_sdw",
478 		.sof_fw_filename = "sof-adl.ri",
479 		.sof_tplg_filename = "sof-adl-rt711-l2-rt1316-l01-rt714-l3.tplg",
480 	},
481 	{
482 		.link_mask = 0xC, /* rt1316 on link2 & rt714 on link3 */
483 		.links = adl_sdw_rt1316_link2_rt714_link3,
484 		.drv_name = "sof_sdw",
485 		.sof_fw_filename = "sof-adl.ri",
486 		.sof_tplg_filename = "sof-adl-rt1316-l2-mono-rt714-l3.tplg",
487 	},
488 	{
489 		.link_mask = 0x7, /* rt714 on link0 & two rt1316s on link1 and link2 */
490 		.links = adl_sdw_rt1316_link12_rt714_link0,
491 		.drv_name = "sof_sdw",
492 		.sof_fw_filename = "sof-adl.ri",
493 		.sof_tplg_filename = "sof-adl-rt1316-l12-rt714-l0.tplg",
494 	},
495 	{
496 		.link_mask = 0x5, /* 2 active links required */
497 		.links = adl_sdw_rt1316_link2_rt714_link0,
498 		.drv_name = "sof_sdw",
499 		.sof_tplg_filename = "sof-adl-rt1316-l2-mono-rt714-l0.tplg",
500 	},
501 	{
502 		.link_mask = 0x1, /* link0 required */
503 		.links = adl_rvp,
504 		.drv_name = "sof_sdw",
505 		.sof_tplg_filename = "sof-adl-rt711.tplg",
506 	},
507 	{
508 		.link_mask = 0x5, /* rt5682 on link0 & 2xmax98373 on link 2 */
509 		.links = adl_chromebook_base,
510 		.drv_name = "sof_sdw",
511 		.sof_fw_filename = "sof-adl.ri",
512 		.sof_tplg_filename = "sof-adl-sdw-max98373-rt5682.tplg",
513 	},
514 	{},
515 };
516 EXPORT_SYMBOL_GPL(snd_soc_acpi_intel_adl_sdw_machines);
517