xref: /linux/sound/soc/intel/common/soc-acpi-intel-ptl-match.c (revision 7a9b709e7cc5ce1ffb84ce07bf6d157e1de758df)
1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3  * soc-acpi-intel-ptl-match.c - tables and support for PTL ACPI enumeration.
4  *
5  * Copyright (c) 2024, Intel Corporation.
6  *
7  */
8 
9 #include <sound/soc-acpi.h>
10 #include <sound/soc-acpi-intel-match.h>
11 #include "soc-acpi-intel-sdca-quirks.h"
12 #include "soc-acpi-intel-sdw-mockup-match.h"
13 #include <sound/soc-acpi-intel-ssp-common.h>
14 
15 static const struct snd_soc_acpi_codecs ptl_rt5682_rt5682s_hp = {
16 	.num_codecs = 2,
17 	.codecs = {RT5682_ACPI_HID, RT5682S_ACPI_HID},
18 };
19 
20 struct snd_soc_acpi_mach snd_soc_acpi_intel_ptl_machines[] = {
21 	{
22 		.comp_ids = &ptl_rt5682_rt5682s_hp,
23 		.drv_name = "ptl_rt5682_def",
24 		.sof_tplg_filename = "sof-ptl", /* the tplg suffix is added at run time */
25 		.tplg_quirk_mask = SND_SOC_ACPI_TPLG_INTEL_AMP_NAME |
26 					SND_SOC_ACPI_TPLG_INTEL_CODEC_NAME,
27 	},
28 	{},
29 };
30 EXPORT_SYMBOL_GPL(snd_soc_acpi_intel_ptl_machines);
31 
32 static const struct snd_soc_acpi_endpoint single_endpoint = {
33 	.num = 0,
34 	.aggregated = 0,
35 	.group_position = 0,
36 	.group_id = 0,
37 };
38 
39 static const struct snd_soc_acpi_endpoint spk_l_endpoint = {
40 	.num = 0,
41 	.aggregated = 1,
42 	.group_position = 0,
43 	.group_id = 1,
44 };
45 
46 static const struct snd_soc_acpi_endpoint spk_r_endpoint = {
47 	.num = 0,
48 	.aggregated = 1,
49 	.group_position = 1,
50 	.group_id = 1,
51 };
52 
53 static const struct snd_soc_acpi_endpoint spk_1_endpoint = {
54 	.num = 0,
55 	.aggregated = 1,
56 	.group_position = 1,
57 	.group_id = 1,
58 };
59 
60 static const struct snd_soc_acpi_endpoint spk_2_endpoint = {
61 	.num = 0,
62 	.aggregated = 1,
63 	.group_position = 2,
64 	.group_id = 1,
65 };
66 
67 static const struct snd_soc_acpi_endpoint spk_3_endpoint = {
68 	.num = 0,
69 	.aggregated = 1,
70 	.group_position = 3,
71 	.group_id = 1,
72 };
73 
74 static const struct snd_soc_acpi_endpoint spk_4_endpoint = {
75 	.num = 0,
76 	.aggregated = 1,
77 	.group_position = 4,
78 	.group_id = 1,
79 };
80 
81 static const struct snd_soc_acpi_endpoint spk_5_endpoint = {
82 	.num = 0,
83 	.aggregated = 1,
84 	.group_position = 5,
85 	.group_id = 1,
86 };
87 
88 static const struct snd_soc_acpi_endpoint spk_6_endpoint = {
89 	.num = 0,
90 	.aggregated = 1,
91 	.group_position = 6,
92 	.group_id = 1,
93 };
94 
95 /*
96  * Multi-function codecs with three endpoints created for
97  * headset, amp and dmic functions.
98  */
99 static const struct snd_soc_acpi_endpoint rt_mf_endpoints[] = {
100 	{
101 		.num = 0,
102 		.aggregated = 0,
103 		.group_position = 0,
104 		.group_id = 0,
105 	},
106 	{
107 		.num = 1,
108 		.aggregated = 0,
109 		.group_position = 0,
110 		.group_id = 0,
111 	},
112 	{
113 		.num = 2,
114 		.aggregated = 0,
115 		.group_position = 0,
116 		.group_id = 0,
117 	},
118 };
119 
120 static const struct snd_soc_acpi_endpoint jack_dmic_endpoints[] = {
121 	/* Jack Endpoint */
122 	{
123 		.num = 0,
124 		.aggregated = 0,
125 		.group_position = 0,
126 		.group_id = 0,
127 	},
128 	/* DMIC Endpoint */
129 	{
130 		.num = 1,
131 		.aggregated = 0,
132 		.group_position = 0,
133 		.group_id = 0,
134 	},
135 };
136 
137 static const struct snd_soc_acpi_endpoint jack_amp_g1_dmic_endpoints_endpoints[] = {
138 	/* Jack Endpoint */
139 	{
140 		.num = 0,
141 		.aggregated = 0,
142 		.group_position = 0,
143 		.group_id = 0,
144 	},
145 	/* Amp Endpoint, work as spk_l_endpoint */
146 	{
147 		.num = 1,
148 		.aggregated = 1,
149 		.group_position = 0,
150 		.group_id = 1,
151 	},
152 	/* DMIC Endpoint */
153 	{
154 		.num = 2,
155 		.aggregated = 0,
156 		.group_position = 0,
157 		.group_id = 0,
158 	},
159 };
160 
161 static const struct snd_soc_acpi_endpoint cs42l43_amp_spkagg_endpoints[] = {
162 	{ /* Jack Playback Endpoint */
163 		.num = 0,
164 		.aggregated = 0,
165 		.group_position = 0,
166 		.group_id = 0,
167 	},
168 	{ /* DMIC Capture Endpoint */
169 		.num = 1,
170 		.aggregated = 0,
171 		.group_position = 0,
172 		.group_id = 0,
173 	},
174 	{ /* Jack Capture Endpoint */
175 		.num = 2,
176 		.aggregated = 0,
177 		.group_position = 0,
178 		.group_id = 0,
179 	},
180 	{ /* Speaker Playback Endpoint */
181 		.num = 3,
182 		.aggregated = 1,
183 		.group_position = 0,
184 		.group_id = 1,
185 	},
186 };
187 
188 static const struct snd_soc_acpi_endpoint cs42l43_endpoints[] = {
189 	{ /* Jack Playback Endpoint */
190 		.num = 0,
191 		.aggregated = 0,
192 		.group_position = 0,
193 		.group_id = 0,
194 	},
195 	{ /* DMIC Capture Endpoint */
196 		.num = 1,
197 		.aggregated = 0,
198 		.group_position = 0,
199 		.group_id = 0,
200 	},
201 	{ /* Jack Capture Endpoint */
202 		.num = 2,
203 		.aggregated = 0,
204 		.group_position = 0,
205 		.group_id = 0,
206 	},
207 	{ /* Speaker Playback Endpoint */
208 		.num = 3,
209 		.aggregated = 0,
210 		.group_position = 0,
211 		.group_id = 0,
212 	},
213 };
214 
215 static const struct snd_soc_acpi_adr_device cs42l43_2_adr[] = {
216 	{
217 		.adr = 0x00023001fa424301ull,
218 		.num_endpoints = ARRAY_SIZE(cs42l43_amp_spkagg_endpoints),
219 		.endpoints = cs42l43_amp_spkagg_endpoints,
220 		.name_prefix = "cs42l43"
221 	}
222 };
223 
224 static const struct snd_soc_acpi_adr_device cs35l56_1_3amp_adr[] = {
225 	{
226 		.adr = 0x00013001fa355601ull,
227 		.num_endpoints = 1,
228 		.endpoints = &spk_1_endpoint,
229 		.name_prefix = "AMP1"
230 	},
231 	{
232 		.adr = 0x00013101fa355601ull,
233 		.num_endpoints = 1,
234 		.endpoints = &spk_2_endpoint,
235 		.name_prefix = "AMP2"
236 	},
237 	{
238 		.adr = 0x00013201fa355601ull,
239 		.num_endpoints = 1,
240 		.endpoints = &spk_3_endpoint,
241 		.name_prefix = "AMP3"
242 	}
243 };
244 
245 static const struct snd_soc_acpi_adr_device cs35l56_3_3amp_adr[] = {
246 	{
247 		.adr = 0x00033301fa355601ull,
248 		.num_endpoints = 1,
249 		.endpoints = &spk_4_endpoint,
250 		.name_prefix = "AMP4"
251 	},
252 	{
253 		.adr = 0x00033401fa355601ull,
254 		.num_endpoints = 1,
255 		.endpoints = &spk_5_endpoint,
256 		.name_prefix = "AMP5"
257 	},
258 	{
259 		.adr = 0x00033501fa355601ull,
260 		.num_endpoints = 1,
261 		.endpoints = &spk_6_endpoint,
262 		.name_prefix = "AMP6"
263 	}
264 };
265 
266 static const struct snd_soc_acpi_adr_device cs42l43_3_adr[] = {
267 	{
268 		.adr = 0x00033001FA424301ull,
269 		.num_endpoints = ARRAY_SIZE(cs42l43_endpoints),
270 		.endpoints = cs42l43_endpoints,
271 		.name_prefix = "cs42l43"
272 	}
273 };
274 
275 static const struct snd_soc_acpi_adr_device rt711_sdca_0_adr[] = {
276 	{
277 		.adr = 0x000030025D071101ull,
278 		.num_endpoints = 1,
279 		.endpoints = &single_endpoint,
280 		.name_prefix = "rt711"
281 	}
282 };
283 
284 static const struct snd_soc_acpi_adr_device rt712_vb_2_group1_adr[] = {
285 	{
286 		.adr = 0x000230025D071201ull,
287 		.num_endpoints = ARRAY_SIZE(jack_amp_g1_dmic_endpoints_endpoints),
288 		.endpoints = jack_amp_g1_dmic_endpoints_endpoints,
289 		.name_prefix = "rt712"
290 	}
291 };
292 
293 static const struct snd_soc_acpi_adr_device rt712_vb_3_group1_adr[] = {
294 	{
295 		.adr = 0x000330025D071201ull,
296 		.num_endpoints = ARRAY_SIZE(jack_amp_g1_dmic_endpoints_endpoints),
297 		.endpoints = jack_amp_g1_dmic_endpoints_endpoints,
298 		.name_prefix = "rt712"
299 	}
300 };
301 
302 static const struct snd_soc_acpi_adr_device rt713_vb_2_adr[] = {
303 	{
304 		.adr = 0x000230025d071301ull,
305 		.num_endpoints = ARRAY_SIZE(jack_dmic_endpoints),
306 		.endpoints = jack_dmic_endpoints,
307 		.name_prefix = "rt713"
308 	}
309 };
310 
311 static const struct snd_soc_acpi_adr_device rt713_vb_3_adr[] = {
312 	{
313 		.adr = 0x000330025D071301ull,
314 		.num_endpoints = ARRAY_SIZE(jack_dmic_endpoints),
315 		.endpoints = jack_dmic_endpoints,
316 		.name_prefix = "rt713"
317 	}
318 };
319 
320 static const struct snd_soc_acpi_adr_device rt721_3_single_adr[] = {
321 	{
322 		.adr = 0x000330025d072101ull,
323 		.num_endpoints = ARRAY_SIZE(rt_mf_endpoints),
324 		.endpoints = rt_mf_endpoints,
325 		.name_prefix = "rt721"
326 	}
327 };
328 
329 static const struct snd_soc_acpi_link_adr ptl_rt721_l3[] = {
330 	{
331 		.mask = BIT(3),
332 		.num_adr = ARRAY_SIZE(rt721_3_single_adr),
333 		.adr_d = rt721_3_single_adr,
334 	},
335 	{},
336 };
337 
338 static const struct snd_soc_acpi_adr_device rt722_0_single_adr[] = {
339 	{
340 		.adr = 0x000030025d072201ull,
341 		.num_endpoints = ARRAY_SIZE(rt_mf_endpoints),
342 		.endpoints = rt_mf_endpoints,
343 		.name_prefix = "rt722"
344 	}
345 };
346 
347 static const struct snd_soc_acpi_adr_device rt722_1_single_adr[] = {
348 	{
349 		.adr = 0x000130025d072201ull,
350 		.num_endpoints = ARRAY_SIZE(rt_mf_endpoints),
351 		.endpoints = rt_mf_endpoints,
352 		.name_prefix = "rt722"
353 	}
354 };
355 
356 static const struct snd_soc_acpi_adr_device rt722_3_single_adr[] = {
357 	{
358 		.adr = 0x000330025d072201ull,
359 		.num_endpoints = ARRAY_SIZE(rt_mf_endpoints),
360 		.endpoints = rt_mf_endpoints,
361 		.name_prefix = "rt722"
362 	}
363 };
364 
365 static const struct snd_soc_acpi_adr_device rt1320_1_group1_adr[] = {
366 	{
367 		.adr = 0x000130025D132001ull,
368 		.num_endpoints = 1,
369 		.endpoints = &spk_r_endpoint,
370 		.name_prefix = "rt1320-1"
371 	}
372 };
373 
374 static const struct snd_soc_acpi_adr_device rt1320_1_group2_adr[] = {
375 	{
376 		.adr = 0x000130025D132001ull,
377 		.num_endpoints = 1,
378 		.endpoints = &spk_l_endpoint,
379 		.name_prefix = "rt1320-1"
380 	}
381 };
382 
383 static const struct snd_soc_acpi_adr_device rt1320_2_group1_adr[] = {
384 	{
385 		.adr = 0x000230025D132001ull,
386 		.num_endpoints = 1,
387 		.endpoints = &spk_r_endpoint,
388 		.name_prefix = "rt1320-1"
389 	}
390 };
391 
392 static const struct snd_soc_acpi_adr_device rt1320_2_group2_adr[] = {
393 	{
394 		.adr = 0x000230025D132001ull,
395 		.num_endpoints = 1,
396 		.endpoints = &spk_r_endpoint,
397 		.name_prefix = "rt1320-1"
398 	}
399 };
400 
401 static const struct snd_soc_acpi_adr_device rt1320_3_group2_adr[] = {
402 	{
403 		.adr = 0x000330025D132001ull,
404 		.num_endpoints = 1,
405 		.endpoints = &spk_r_endpoint,
406 		.name_prefix = "rt1320-2"
407 	}
408 };
409 
410 static const struct snd_soc_acpi_link_adr ptl_cs42l43_l2_cs35l56x6_l13[] = {
411 	{
412 		.mask = BIT(2),
413 		.num_adr = ARRAY_SIZE(cs42l43_2_adr),
414 		.adr_d = cs42l43_2_adr,
415 	},
416 	{
417 		.mask = BIT(1),
418 		.num_adr = ARRAY_SIZE(cs35l56_1_3amp_adr),
419 		.adr_d = cs35l56_1_3amp_adr,
420 	},
421 	{
422 		.mask = BIT(3),
423 		.num_adr = ARRAY_SIZE(cs35l56_3_3amp_adr),
424 		.adr_d = cs35l56_3_3amp_adr,
425 	},
426 	{}
427 };
428 
429 static const struct snd_soc_acpi_link_adr ptl_cs42l43_l3[] = {
430 	{
431 		.mask = BIT(3),
432 		.num_adr = ARRAY_SIZE(cs42l43_3_adr),
433 		.adr_d = cs42l43_3_adr,
434 	},
435 	{}
436 };
437 
438 static const struct snd_soc_acpi_link_adr ptl_rt722_only[] = {
439 	{
440 		.mask = BIT(0),
441 		.num_adr = ARRAY_SIZE(rt722_0_single_adr),
442 		.adr_d = rt722_0_single_adr,
443 	},
444 	{}
445 };
446 
447 static const struct snd_soc_acpi_link_adr ptl_rt722_l1[] = {
448 	{
449 		.mask = BIT(1),
450 		.num_adr = ARRAY_SIZE(rt722_1_single_adr),
451 		.adr_d = rt722_1_single_adr,
452 	},
453 	{}
454 };
455 
456 static const struct snd_soc_acpi_link_adr ptl_rt722_l3[] = {
457 	{
458 		.mask = BIT(3),
459 		.num_adr = ARRAY_SIZE(rt722_3_single_adr),
460 		.adr_d = rt722_3_single_adr,
461 	},
462 	{}
463 };
464 
465 static const struct snd_soc_acpi_link_adr ptl_rvp[] = {
466 	{
467 		.mask = BIT(0),
468 		.num_adr = ARRAY_SIZE(rt711_sdca_0_adr),
469 		.adr_d = rt711_sdca_0_adr,
470 	},
471 	{}
472 };
473 
474 static const struct snd_soc_acpi_link_adr ptl_sdw_rt713_vb_l2_rt1320_l13[] = {
475 	{
476 		.mask = BIT(2),
477 		.num_adr = ARRAY_SIZE(rt713_vb_2_adr),
478 		.adr_d = rt713_vb_2_adr,
479 	},
480 	{
481 		.mask = BIT(1),
482 		.num_adr = ARRAY_SIZE(rt1320_1_group2_adr),
483 		.adr_d = rt1320_1_group2_adr,
484 	},
485 	{
486 		.mask = BIT(3),
487 		.num_adr = ARRAY_SIZE(rt1320_3_group2_adr),
488 		.adr_d = rt1320_3_group2_adr,
489 	},
490 	{}
491 };
492 
493 static const struct snd_soc_acpi_link_adr ptl_sdw_rt713_vb_l3_rt1320_l12[] = {
494 	{
495 		.mask = BIT(3),
496 		.num_adr = ARRAY_SIZE(rt713_vb_3_adr),
497 		.adr_d = rt713_vb_3_adr,
498 	},
499 	{
500 		.mask = BIT(1),
501 		.num_adr = ARRAY_SIZE(rt1320_1_group2_adr),
502 		.adr_d = rt1320_1_group2_adr,
503 	},
504 	{
505 		.mask = BIT(2),
506 		.num_adr = ARRAY_SIZE(rt1320_2_group2_adr),
507 		.adr_d = rt1320_2_group2_adr,
508 	},
509 	{}
510 };
511 
512 static const struct snd_soc_acpi_link_adr ptl_sdw_rt712_vb_l2_rt1320_l1[] = {
513 	{
514 		.mask = BIT(2),
515 		.num_adr = ARRAY_SIZE(rt712_vb_2_group1_adr),
516 		.adr_d = rt712_vb_2_group1_adr,
517 	},
518 	{
519 		.mask = BIT(1),
520 		.num_adr = ARRAY_SIZE(rt1320_1_group1_adr),
521 		.adr_d = rt1320_1_group1_adr,
522 	},
523 	{}
524 };
525 
526 static const struct snd_soc_acpi_link_adr ptl_sdw_rt712_vb_l3_rt1320_l2[] = {
527 	{
528 		.mask = BIT(3),
529 		.num_adr = ARRAY_SIZE(rt712_vb_3_group1_adr),
530 		.adr_d = rt712_vb_3_group1_adr,
531 	},
532 	{
533 		.mask = BIT(2),
534 		.num_adr = ARRAY_SIZE(rt1320_2_group1_adr),
535 		.adr_d = rt1320_2_group1_adr,
536 	},
537 	{}
538 };
539 
540 /* this table is used when there is no I2S codec present */
541 struct snd_soc_acpi_mach snd_soc_acpi_intel_ptl_sdw_machines[] = {
542 	/* mockup tests need to be first */
543 	{
544 		.link_mask = GENMASK(3, 0),
545 		.links = sdw_mockup_headset_2amps_mic,
546 		.drv_name = "sof_sdw",
547 		.sof_tplg_filename = "sof-ptl-rt711-rt1308-rt715.tplg",
548 	},
549 	{
550 		.link_mask = BIT(0) | BIT(1) | BIT(3),
551 		.links = sdw_mockup_headset_1amp_mic,
552 		.drv_name = "sof_sdw",
553 		.sof_tplg_filename = "sof-ptl-rt711-rt1308-mono-rt715.tplg",
554 	},
555 	{
556 		.link_mask = GENMASK(2, 0),
557 		.links = sdw_mockup_mic_headset_1amp,
558 		.drv_name = "sof_sdw",
559 		.sof_tplg_filename = "sof-ptl-rt715-rt711-rt1308-mono.tplg",
560 	},
561 	{
562 		.link_mask = BIT(1) | BIT(2) | BIT(3),
563 		.links = ptl_cs42l43_l2_cs35l56x6_l13,
564 		.drv_name = "sof_sdw",
565 		.sof_tplg_filename = "sof-ptl-cs42l43-l2-cs35l56x6-l13.tplg",
566 	},
567 	{
568 		.link_mask = BIT(0),
569 		.links = sdw_mockup_multi_func,
570 		.drv_name = "sof_sdw",
571 		.sof_tplg_filename = "sof-ptl-rt722.tplg", /* Reuse the existing tplg file */
572 	},
573 	{
574 		.link_mask = BIT(0),
575 		.links = ptl_rvp,
576 		.drv_name = "sof_sdw",
577 		.sof_tplg_filename = "sof-ptl-rt711.tplg",
578 	},
579 	{
580 		.link_mask = BIT(3),
581 		.links = ptl_cs42l43_l3,
582 		.drv_name = "sof_sdw",
583 		.sof_tplg_filename = "sof-ptl-cs42l43-l3.tplg",
584 	},
585 	{
586 		.link_mask = BIT(3),
587 		.links = ptl_rt721_l3,
588 		.drv_name = "sof_sdw",
589 		.sof_tplg_filename = "sof-ptl-rt721.tplg",
590 	},
591 	{
592 		.link_mask = BIT(0),
593 		.links = ptl_rt722_only,
594 		.drv_name = "sof_sdw",
595 		.sof_tplg_filename = "sof-ptl-rt722.tplg",
596 	},
597 	{
598 		.link_mask = BIT(1),
599 		.links = ptl_rt722_l1,
600 		.drv_name = "sof_sdw",
601 		.sof_tplg_filename = "sof-ptl-rt722.tplg",
602 	},
603 	{
604 		.link_mask = BIT(3),
605 		.links = ptl_rt722_l3,
606 		.drv_name = "sof_sdw",
607 		.sof_tplg_filename = "sof-ptl-rt722.tplg",
608 	},
609 	{
610 		.link_mask = BIT(1) | BIT(2),
611 		.links = ptl_sdw_rt712_vb_l2_rt1320_l1,
612 		.drv_name = "sof_sdw",
613 		.machine_check = snd_soc_acpi_intel_sdca_is_device_rt712_vb,
614 		.sof_tplg_filename = "sof-ptl-rt712-l2-rt1320-l1.tplg"
615 	},
616 	{
617 		.link_mask = BIT(2) | BIT(3),
618 		.links = ptl_sdw_rt712_vb_l3_rt1320_l2,
619 		.drv_name = "sof_sdw",
620 		.machine_check = snd_soc_acpi_intel_sdca_is_device_rt712_vb,
621 		.sof_tplg_filename = "sof-ptl-rt712-l3-rt1320-l2.tplg"
622 	},
623 	{
624 		.link_mask = BIT(1) | BIT(2) | BIT(3),
625 		.links = ptl_sdw_rt713_vb_l2_rt1320_l13,
626 		.drv_name = "sof_sdw",
627 		.machine_check = snd_soc_acpi_intel_sdca_is_device_rt712_vb,
628 		.sof_tplg_filename = "sof-ptl-rt713-l2-rt1320-l13.tplg"
629 	},
630 	{
631 		.link_mask = BIT(1) | BIT(2) | BIT(3),
632 		.links = ptl_sdw_rt713_vb_l3_rt1320_l12,
633 		.drv_name = "sof_sdw",
634 		.machine_check = snd_soc_acpi_intel_sdca_is_device_rt712_vb,
635 		.sof_tplg_filename = "sof-ptl-rt713-l3-rt1320-l12.tplg"
636 	},
637 	{},
638 };
639 EXPORT_SYMBOL_GPL(snd_soc_acpi_intel_ptl_sdw_machines);
640