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_rt711_link2_rt1316_link01[] = {
264 	{
265 		.mask = BIT(2),
266 		.num_adr = ARRAY_SIZE(rt711_sdca_2_adr),
267 		.adr_d = rt711_sdca_2_adr,
268 	},
269 	{
270 		.mask = BIT(0),
271 		.num_adr = ARRAY_SIZE(rt1316_0_group2_adr),
272 		.adr_d = rt1316_0_group2_adr,
273 	},
274 	{
275 		.mask = BIT(1),
276 		.num_adr = ARRAY_SIZE(rt1316_1_group2_adr),
277 		.adr_d = rt1316_1_group2_adr,
278 	},
279 	{}
280 };
281 
282 static const struct snd_soc_acpi_link_adr adl_sdw_rt1316_link12_rt714_link0[] = {
283 	{
284 		.mask = BIT(1),
285 		.num_adr = ARRAY_SIZE(rt1316_1_group1_adr),
286 		.adr_d = rt1316_1_group1_adr,
287 	},
288 	{
289 		.mask = BIT(2),
290 		.num_adr = ARRAY_SIZE(rt1316_2_group1_adr),
291 		.adr_d = rt1316_2_group1_adr,
292 	},
293 	{
294 		.mask = BIT(0),
295 		.num_adr = ARRAY_SIZE(rt714_0_adr),
296 		.adr_d = rt714_0_adr,
297 	},
298 	{}
299 };
300 
301 static const struct snd_soc_acpi_link_adr adl_sdw_rt1316_link2_rt714_link3[] = {
302 	{
303 		.mask = BIT(2),
304 		.num_adr = ARRAY_SIZE(rt1316_2_single_adr),
305 		.adr_d = rt1316_2_single_adr,
306 	},
307 	{
308 		.mask = BIT(3),
309 		.num_adr = ARRAY_SIZE(rt714_3_adr),
310 		.adr_d = rt714_3_adr,
311 	},
312 	{}
313 };
314 
315 static const struct snd_soc_acpi_link_adr adl_sdw_rt1316_link2_rt714_link0[] = {
316 	{
317 		.mask = BIT(2),
318 		.num_adr = ARRAY_SIZE(rt1316_2_single_adr),
319 		.adr_d = rt1316_2_single_adr,
320 	},
321 	{
322 		.mask = BIT(0),
323 		.num_adr = ARRAY_SIZE(rt714_0_adr),
324 		.adr_d = rt714_0_adr,
325 	},
326 	{}
327 };
328 
329 static const struct snd_soc_acpi_adr_device mx8373_2_adr[] = {
330 	{
331 		.adr = 0x000223019F837300ull,
332 		.num_endpoints = 1,
333 		.endpoints = &spk_l_endpoint,
334 		.name_prefix = "Left"
335 	},
336 	{
337 		.adr = 0x000227019F837300ull,
338 		.num_endpoints = 1,
339 		.endpoints = &spk_r_endpoint,
340 		.name_prefix = "Right"
341 	}
342 };
343 
344 static const struct snd_soc_acpi_adr_device rt5682_0_adr[] = {
345 	{
346 		.adr = 0x000021025D568200ull,
347 		.num_endpoints = 1,
348 		.endpoints = &single_endpoint,
349 		.name_prefix = "rt5682"
350 	}
351 };
352 
353 static const struct snd_soc_acpi_link_adr adl_rvp[] = {
354 	{
355 		.mask = BIT(0),
356 		.num_adr = ARRAY_SIZE(rt711_0_adr),
357 		.adr_d = rt711_0_adr,
358 	},
359 	{}
360 };
361 
362 static const struct snd_soc_acpi_link_adr adlps_rvp[] = {
363 	{
364 		.mask = BIT(0),
365 		.num_adr = ARRAY_SIZE(rt711_sdca_0_adr),
366 		.adr_d = rt711_sdca_0_adr,
367 	},
368 	{}
369 };
370 
371 static const struct snd_soc_acpi_link_adr adl_chromebook_base[] = {
372 	{
373 		.mask = BIT(0),
374 		.num_adr = ARRAY_SIZE(rt5682_0_adr),
375 		.adr_d = rt5682_0_adr,
376 	},
377 	{
378 		.mask = BIT(2),
379 		.num_adr = ARRAY_SIZE(mx8373_2_adr),
380 		.adr_d = mx8373_2_adr,
381 	},
382 	{}
383 };
384 
385 static const struct snd_soc_acpi_codecs adl_max98373_amp = {
386 	.num_codecs = 1,
387 	.codecs = {"MX98373"}
388 };
389 
390 static const struct snd_soc_acpi_codecs adl_max98357a_amp = {
391 	.num_codecs = 1,
392 	.codecs = {"MX98357A"}
393 };
394 
395 static const struct snd_soc_acpi_codecs adl_max98360a_amp = {
396 	.num_codecs = 1,
397 	.codecs = {"MX98360A"}
398 };
399 
400 static const struct snd_soc_acpi_codecs adl_rt5682_rt5682s_hp = {
401 	.num_codecs = 2,
402 	.codecs = {"10EC5682", "RTL5682"},
403 };
404 
405 static const struct snd_soc_acpi_codecs adl_rt1019p_amp = {
406 	.num_codecs = 1,
407 	.codecs = {"RTL1019"}
408 };
409 
410 static const struct snd_soc_acpi_codecs adl_max98390_amp = {
411 	.num_codecs = 1,
412 	.codecs = {"MX98390"}
413 };
414 
415 struct snd_soc_acpi_mach snd_soc_acpi_intel_adl_machines[] = {
416 	{
417 		.comp_ids = &adl_rt5682_rt5682s_hp,
418 		.drv_name = "adl_mx98373_rt5682",
419 		.machine_quirk = snd_soc_acpi_codec_list,
420 		.quirk_data = &adl_max98373_amp,
421 		.sof_tplg_filename = "sof-adl-max98373-rt5682.tplg",
422 	},
423 	{
424 		.comp_ids = &adl_rt5682_rt5682s_hp,
425 		.drv_name = "adl_mx98357_rt5682",
426 		.machine_quirk = snd_soc_acpi_codec_list,
427 		.quirk_data = &adl_max98357a_amp,
428 		.sof_tplg_filename = "sof-adl-max98357a-rt5682.tplg",
429 	},
430 	{
431 		.comp_ids = &adl_rt5682_rt5682s_hp,
432 		.drv_name = "adl_mx98360_rt5682",
433 		.machine_quirk = snd_soc_acpi_codec_list,
434 		.quirk_data = &adl_max98360a_amp,
435 		.sof_tplg_filename = "sof-adl-max98360a-rt5682.tplg",
436 	},
437 	{
438 		.id = "10508825",
439 		.drv_name = "adl_rt1019p_nau8825",
440 		.machine_quirk = snd_soc_acpi_codec_list,
441 		.quirk_data = &adl_rt1019p_amp,
442 		.sof_tplg_filename = "sof-adl-rt1019-nau8825.tplg",
443 	},
444 	{
445 		.id = "10508825",
446 		.drv_name = "adl_max98373_nau8825",
447 		.machine_quirk = snd_soc_acpi_codec_list,
448 		.quirk_data = &adl_max98373_amp,
449 		.sof_tplg_filename = "sof-adl-max98373-nau8825.tplg",
450 	},
451 	{
452 		.id = "10508825",
453 		.drv_name = "adl_mx98360a_nau8825",
454 		.machine_quirk = snd_soc_acpi_codec_list,
455 		.quirk_data = &adl_max98360a_amp,
456 		.sof_tplg_filename = "sof-adl-max98360a-nau8825.tplg",
457 	},
458 	{
459 		.id = "RTL5682",
460 		.drv_name = "adl_rt1019_rt5682s",
461 		.machine_quirk = snd_soc_acpi_codec_list,
462 		.quirk_data = &adl_rt1019p_amp,
463 		.sof_tplg_filename = "sof-adl-rt1019-rt5682.tplg",
464 	},
465 	{
466 		.id = "10508825",
467 		.drv_name = "sof_nau8825",
468 		.sof_tplg_filename = "sof-adl-nau8825.tplg",
469 	},
470 	{
471 		.comp_ids = &adl_rt5682_rt5682s_hp,
472 		.drv_name = "adl_max98390_rt5682",
473 		.machine_quirk = snd_soc_acpi_codec_list,
474 		.quirk_data = &adl_max98390_amp,
475 		.sof_tplg_filename = "sof-adl-max98390-rt5682.tplg",
476 	},
477 	{
478 		.comp_ids = &adl_rt5682_rt5682s_hp,
479 		.drv_name = "adl_rt5682",
480 		.sof_tplg_filename = "sof-adl-rt5682.tplg",
481 	},
482 	/* place amp-only boards in the end of table */
483 	{
484 		.id = "CSC3541",
485 		.drv_name = "adl_cs35l41",
486 		.sof_tplg_filename = "sof-adl-cs35l41.tplg",
487 	},
488 	{},
489 };
490 EXPORT_SYMBOL_GPL(snd_soc_acpi_intel_adl_machines);
491 
492 /* this table is used when there is no I2S codec present */
493 struct snd_soc_acpi_mach snd_soc_acpi_intel_adl_sdw_machines[] = {
494 	{
495 		.link_mask = 0xF, /* 4 active links required */
496 		.links = adl_default,
497 		.drv_name = "sof_sdw",
498 		.sof_tplg_filename = "sof-adl-rt711-l0-rt1308-l12-rt715-l3.tplg",
499 	},
500 	{
501 		.link_mask = 0xF, /* 4 active links required */
502 		.links = adl_sdca_default,
503 		.drv_name = "sof_sdw",
504 		.sof_tplg_filename = "sof-adl-rt711-l0-rt1316-l12-rt714-l3.tplg",
505 	},
506 	{
507 		.link_mask = 0xF, /* 4 active links required */
508 		.links = adl_sdca_3_in_1,
509 		.drv_name = "sof_sdw",
510 		.sof_tplg_filename = "sof-adl-rt711-l0-rt1316-l13-rt714-l2.tplg",
511 	},
512 	{
513 		.link_mask = 0xF, /* 4 active links required */
514 		.links = adl_sdw_rt711_link2_rt1316_link01_rt714_link3,
515 		.drv_name = "sof_sdw",
516 		.sof_tplg_filename = "sof-adl-rt711-l2-rt1316-l01-rt714-l3.tplg",
517 	},
518 	{
519 		.link_mask = 0x7, /* rt1316 on link0 and link1 & rt711 on link2*/
520 		.links = adl_sdw_rt711_link2_rt1316_link01,
521 		.drv_name = "sof_sdw",
522 		.sof_tplg_filename = "sof-adl-rt711-l2-rt1316-l01.tplg",
523 	},
524 	{
525 		.link_mask = 0xC, /* rt1316 on link2 & rt714 on link3 */
526 		.links = adl_sdw_rt1316_link2_rt714_link3,
527 		.drv_name = "sof_sdw",
528 		.sof_tplg_filename = "sof-adl-rt1316-l2-mono-rt714-l3.tplg",
529 	},
530 	{
531 		.link_mask = 0x7, /* rt714 on link0 & two rt1316s on link1 and link2 */
532 		.links = adl_sdw_rt1316_link12_rt714_link0,
533 		.drv_name = "sof_sdw",
534 		.sof_tplg_filename = "sof-adl-rt1316-l12-rt714-l0.tplg",
535 	},
536 	{
537 		.link_mask = 0x5, /* 2 active links required */
538 		.links = adl_sdw_rt1316_link2_rt714_link0,
539 		.drv_name = "sof_sdw",
540 		.sof_tplg_filename = "sof-adl-rt1316-l2-mono-rt714-l0.tplg",
541 	},
542 	{
543 		.link_mask = 0x1, /* link0 required */
544 		.links = adl_rvp,
545 		.drv_name = "sof_sdw",
546 		.sof_tplg_filename = "sof-adl-rt711.tplg",
547 	},
548 	{
549 		.link_mask = 0x1, /* link0 required */
550 		.links = adlps_rvp,
551 		.drv_name = "sof_sdw",
552 		.sof_tplg_filename = "sof-adl-rt711.tplg",
553 	},
554 	{
555 		.link_mask = 0x5, /* rt5682 on link0 & 2xmax98373 on link 2 */
556 		.links = adl_chromebook_base,
557 		.drv_name = "sof_sdw",
558 		.sof_tplg_filename = "sof-adl-sdw-max98373-rt5682.tplg",
559 	},
560 	{},
561 };
562 EXPORT_SYMBOL_GPL(snd_soc_acpi_intel_adl_sdw_machines);
563