xref: /linux/sound/soc/intel/common/soc-acpi-intel-rpl-match.c (revision 0b0e9cdb3d1f8fda823b592b0667b4b0595e2ba7)
1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3  * soc-apci-intel-rpl-match.c - tables and support for RPL ACPI enumeration.
4  *
5  * Copyright (c) 2022 Intel Corporation.
6  */
7 
8 #include <sound/soc-acpi.h>
9 #include <sound/soc-acpi-intel-match.h>
10 #include <sound/soc-acpi-intel-ssp-common.h>
11 
12 static const struct snd_soc_acpi_endpoint single_endpoint = {
13 	.num = 0,
14 	.aggregated = 0,
15 	.group_position = 0,
16 	.group_id = 0,
17 };
18 
19 static const struct snd_soc_acpi_endpoint spk_l_endpoint = {
20 	.num = 0,
21 	.aggregated = 1,
22 	.group_position = 0,
23 	.group_id = 1,
24 };
25 
26 static const struct snd_soc_acpi_endpoint spk_r_endpoint = {
27 	.num = 0,
28 	.aggregated = 1,
29 	.group_position = 1,
30 	.group_id = 1,
31 };
32 
33 static const struct snd_soc_acpi_endpoint cs42l43_endpoints[] = {
34 	{ /* Jack Playback Endpoint */
35 		.num = 0,
36 		.aggregated = 0,
37 		.group_position = 0,
38 		.group_id = 0,
39 	},
40 	{ /* DMIC Capture Endpoint */
41 		.num = 1,
42 		.aggregated = 0,
43 		.group_position = 0,
44 		.group_id = 0,
45 	},
46 	{ /* Jack Capture Endpoint */
47 		.num = 2,
48 		.aggregated = 0,
49 		.group_position = 0,
50 		.group_id = 0,
51 	},
52 	{ /* Speaker Playback Endpoint */
53 		.num = 3,
54 		.aggregated = 0,
55 		.group_position = 0,
56 		.group_id = 0,
57 	},
58 };
59 
60 static const struct snd_soc_acpi_adr_device cs42l43_0_adr[] = {
61 	{
62 		.adr = 0x00003001FA424301ull,
63 		.num_endpoints = ARRAY_SIZE(cs42l43_endpoints),
64 		.endpoints = cs42l43_endpoints,
65 		.name_prefix = "cs42l43"
66 	}
67 };
68 
69 static const struct snd_soc_acpi_adr_device rt711_0_adr[] = {
70 	{
71 		.adr = 0x000020025D071100ull,
72 		.num_endpoints = 1,
73 		.endpoints = &single_endpoint,
74 		.name_prefix = "rt711"
75 	}
76 };
77 
78 static const struct snd_soc_acpi_link_adr rpl_rvp[] = {
79 	{
80 		.mask = BIT(0),
81 		.num_adr = ARRAY_SIZE(rt711_0_adr),
82 		.adr_d = rt711_0_adr,
83 	},
84 	{}
85 };
86 
87 static const struct snd_soc_acpi_adr_device rt711_sdca_0_adr[] = {
88 	{
89 		.adr = 0x000030025D071101ull,
90 		.num_endpoints = 1,
91 		.endpoints = &single_endpoint,
92 		.name_prefix = "rt711"
93 	}
94 };
95 
96 static const struct snd_soc_acpi_adr_device rt711_sdca_2_adr[] = {
97 	{
98 		.adr = 0x000230025D071101ull,
99 		.num_endpoints = 1,
100 		.endpoints = &single_endpoint,
101 		.name_prefix = "rt711"
102 	}
103 };
104 
105 static const struct snd_soc_acpi_adr_device rt1316_1_group1_adr[] = {
106 	{
107 		.adr = 0x000131025D131601ull, /* unique ID is set for some reason */
108 		.num_endpoints = 1,
109 		.endpoints = &spk_l_endpoint,
110 		.name_prefix = "rt1316-1"
111 	}
112 };
113 
114 static const struct snd_soc_acpi_adr_device rt1316_2_group1_adr[] = {
115 	{
116 		.adr = 0x000230025D131601ull,
117 		.num_endpoints = 1,
118 		.endpoints = &spk_r_endpoint,
119 		.name_prefix = "rt1316-2"
120 	}
121 };
122 
123 static const struct snd_soc_acpi_adr_device rt1316_3_group1_adr[] = {
124 	{
125 		.adr = 0x000330025D131601ull,
126 		.num_endpoints = 1,
127 		.endpoints = &spk_r_endpoint,
128 		.name_prefix = "rt1316-2"
129 	}
130 };
131 
132 static const struct snd_soc_acpi_adr_device rt1316_0_group2_adr[] = {
133 	{
134 		.adr = 0x000030025D131601ull,
135 		.num_endpoints = 1,
136 		.endpoints = &spk_l_endpoint,
137 		.name_prefix = "rt1316-1"
138 	}
139 };
140 
141 static const struct snd_soc_acpi_adr_device rt1316_1_group2_adr[] = {
142 	{
143 		.adr = 0x000131025D131601ull,
144 		.num_endpoints = 1,
145 		.endpoints = &spk_r_endpoint,
146 		.name_prefix = "rt1316-2"
147 	}
148 };
149 
150 static const struct snd_soc_acpi_adr_device rt1318_1_group1_adr[] = {
151 	{
152 		.adr = 0x000132025D131801ull,
153 		.num_endpoints = 1,
154 		.endpoints = &spk_l_endpoint,
155 		.name_prefix = "rt1318-1"
156 	}
157 };
158 
159 static const struct snd_soc_acpi_adr_device rt1318_2_group1_adr[] = {
160 	{
161 		.adr = 0x000230025D131801ull,
162 		.num_endpoints = 1,
163 		.endpoints = &spk_r_endpoint,
164 		.name_prefix = "rt1318-2"
165 	}
166 };
167 
168 static const struct snd_soc_acpi_adr_device rt714_0_adr[] = {
169 	{
170 		.adr = 0x000030025D071401ull,
171 		.num_endpoints = 1,
172 		.endpoints = &single_endpoint,
173 		.name_prefix = "rt714"
174 	}
175 };
176 
177 static const struct snd_soc_acpi_adr_device rt714_2_adr[] = {
178 	{
179 		.adr = 0x000230025D071401ull,
180 		.num_endpoints = 1,
181 		.endpoints = &single_endpoint,
182 		.name_prefix = "rt714"
183 	}
184 };
185 
186 static const struct snd_soc_acpi_adr_device rt714_3_adr[] = {
187 	{
188 		.adr = 0x000330025D071401ull,
189 		.num_endpoints = 1,
190 		.endpoints = &single_endpoint,
191 		.name_prefix = "rt714"
192 	}
193 };
194 
195 static const struct snd_soc_acpi_link_adr rpl_cs42l43_l0[] = {
196 	{
197 		.mask = BIT(0),
198 		.num_adr = ARRAY_SIZE(cs42l43_0_adr),
199 		.adr_d = cs42l43_0_adr,
200 	},
201 };
202 
203 static const struct snd_soc_acpi_link_adr rpl_sdca_3_in_1[] = {
204 	{
205 		.mask = BIT(0),
206 		.num_adr = ARRAY_SIZE(rt711_sdca_0_adr),
207 		.adr_d = rt711_sdca_0_adr,
208 	},
209 	{
210 		.mask = BIT(1),
211 		.num_adr = ARRAY_SIZE(rt1316_1_group1_adr),
212 		.adr_d = rt1316_1_group1_adr,
213 	},
214 	{
215 		.mask = BIT(2),
216 		.num_adr = ARRAY_SIZE(rt714_2_adr),
217 		.adr_d = rt714_2_adr,
218 	},
219 	{
220 		.mask = BIT(3),
221 		.num_adr = ARRAY_SIZE(rt1316_3_group1_adr),
222 		.adr_d = rt1316_3_group1_adr,
223 	},
224 	{}
225 };
226 
227 static const struct snd_soc_acpi_link_adr rpl_sdw_rt711_link0_rt1316_link12_rt714_link3[] = {
228 	{
229 		.mask = BIT(0),
230 		.num_adr = ARRAY_SIZE(rt711_sdca_0_adr),
231 		.adr_d = rt711_sdca_0_adr,
232 	},
233 	{
234 		.mask = BIT(1),
235 		.num_adr = ARRAY_SIZE(rt1316_1_group1_adr),
236 		.adr_d = rt1316_1_group1_adr,
237 	},
238 	{
239 		.mask = BIT(2),
240 		.num_adr = ARRAY_SIZE(rt1316_2_group1_adr),
241 		.adr_d = rt1316_2_group1_adr,
242 	},
243 	{
244 		.mask = BIT(3),
245 		.num_adr = ARRAY_SIZE(rt714_3_adr),
246 		.adr_d = rt714_3_adr,
247 	},
248 	{}
249 };
250 
251 static const struct snd_soc_acpi_link_adr rpl_sdw_rt711_link2_rt1316_link01_rt714_link3[] = {
252 	{
253 		.mask = BIT(2),
254 		.num_adr = ARRAY_SIZE(rt711_sdca_2_adr),
255 		.adr_d = rt711_sdca_2_adr,
256 	},
257 	{
258 		.mask = BIT(0),
259 		.num_adr = ARRAY_SIZE(rt1316_0_group2_adr),
260 		.adr_d = rt1316_0_group2_adr,
261 	},
262 	{
263 		.mask = BIT(1),
264 		.num_adr = ARRAY_SIZE(rt1316_1_group2_adr),
265 		.adr_d = rt1316_1_group2_adr,
266 	},
267 	{
268 		.mask = BIT(3),
269 		.num_adr = ARRAY_SIZE(rt714_3_adr),
270 		.adr_d = rt714_3_adr,
271 	},
272 	{}
273 };
274 
275 static const struct snd_soc_acpi_link_adr rpl_sdw_rt711_link2_rt1316_link01[] = {
276 	{
277 		.mask = BIT(2),
278 		.num_adr = ARRAY_SIZE(rt711_sdca_2_adr),
279 		.adr_d = rt711_sdca_2_adr,
280 	},
281 	{
282 		.mask = BIT(0),
283 		.num_adr = ARRAY_SIZE(rt1316_0_group2_adr),
284 		.adr_d = rt1316_0_group2_adr,
285 	},
286 	{
287 		.mask = BIT(1),
288 		.num_adr = ARRAY_SIZE(rt1316_1_group2_adr),
289 		.adr_d = rt1316_1_group2_adr,
290 	},
291 	{}
292 };
293 
294 static const struct snd_soc_acpi_link_adr rpl_sdw_rt711_link0_rt1316_link12[] = {
295 	{
296 		.mask = BIT(0),
297 		.num_adr = ARRAY_SIZE(rt711_sdca_0_adr),
298 		.adr_d = rt711_sdca_0_adr,
299 	},
300 	{
301 		.mask = BIT(1),
302 		.num_adr = ARRAY_SIZE(rt1316_1_group1_adr),
303 		.adr_d = rt1316_1_group1_adr,
304 	},
305 	{
306 		.mask = BIT(2),
307 		.num_adr = ARRAY_SIZE(rt1316_2_group1_adr),
308 		.adr_d = rt1316_2_group1_adr,
309 	},
310 	{}
311 };
312 
313 static const struct snd_soc_acpi_link_adr rpl_sdw_rt711_link0_rt1318_link12_rt714_link3[] = {
314 	{
315 		.mask = BIT(0),
316 		.num_adr = ARRAY_SIZE(rt711_sdca_0_adr),
317 		.adr_d = rt711_sdca_0_adr,
318 	},
319 	{
320 		.mask = BIT(1),
321 		.num_adr = ARRAY_SIZE(rt1318_1_group1_adr),
322 		.adr_d = rt1318_1_group1_adr,
323 	},
324 	{
325 		.mask = BIT(2),
326 		.num_adr = ARRAY_SIZE(rt1318_2_group1_adr),
327 		.adr_d = rt1318_2_group1_adr,
328 	},
329 	{
330 		.mask = BIT(3),
331 		.num_adr = ARRAY_SIZE(rt714_3_adr),
332 		.adr_d = rt714_3_adr,
333 	},
334 	{}
335 };
336 
337 static const struct snd_soc_acpi_link_adr rpl_sdw_rt711_link0_rt1318_link12[] = {
338 	{
339 		.mask = BIT(0),
340 		.num_adr = ARRAY_SIZE(rt711_sdca_0_adr),
341 		.adr_d = rt711_sdca_0_adr,
342 	},
343 	{
344 		.mask = BIT(1),
345 		.num_adr = ARRAY_SIZE(rt1318_1_group1_adr),
346 		.adr_d = rt1318_1_group1_adr,
347 	},
348 	{
349 		.mask = BIT(2),
350 		.num_adr = ARRAY_SIZE(rt1318_2_group1_adr),
351 		.adr_d = rt1318_2_group1_adr,
352 	},
353 	{}
354 };
355 
356 static const struct snd_soc_acpi_link_adr rpl_sdw_rt1316_link12_rt714_link0[] = {
357 	{
358 		.mask = BIT(1),
359 		.num_adr = ARRAY_SIZE(rt1316_1_group1_adr),
360 		.adr_d = rt1316_1_group1_adr,
361 	},
362 	{
363 		.mask = BIT(2),
364 		.num_adr = ARRAY_SIZE(rt1316_2_group1_adr),
365 		.adr_d = rt1316_2_group1_adr,
366 	},
367 	{
368 		.mask = BIT(0),
369 		.num_adr = ARRAY_SIZE(rt714_0_adr),
370 		.adr_d = rt714_0_adr,
371 	},
372 	{}
373 };
374 
375 static const struct snd_soc_acpi_link_adr rpl_sdca_rvp[] = {
376 	{
377 		.mask = BIT(0),
378 		.num_adr = ARRAY_SIZE(rt711_sdca_0_adr),
379 		.adr_d = rt711_sdca_0_adr,
380 	},
381 	{}
382 };
383 
384 static const struct snd_soc_acpi_link_adr rplp_crb[] = {
385 	{
386 		.mask = BIT(2),
387 		.num_adr = ARRAY_SIZE(rt711_sdca_2_adr),
388 		.adr_d = rt711_sdca_2_adr,
389 	},
390 	{}
391 };
392 
393 static const struct snd_soc_acpi_codecs rpl_rt5682_hp = {
394 	.num_codecs = 2,
395 	.codecs = {RT5682_ACPI_HID, RT5682S_ACPI_HID},
396 };
397 
398 static const struct snd_soc_acpi_codecs rpl_essx_83x6 = {
399 	.num_codecs = 3,
400 	.codecs = { "ESSX8316", "ESSX8326", "ESSX8336"},
401 };
402 
403 static const struct snd_soc_acpi_codecs rpl_max98357a_amp = {
404 	.num_codecs = 1,
405 	.codecs = {"MX98357A"}
406 };
407 
408 static const struct snd_soc_acpi_codecs rpl_lt6911_hdmi = {
409 	.num_codecs = 1,
410 	.codecs = {"INTC10B0"}
411 };
412 
413 struct snd_soc_acpi_mach snd_soc_acpi_intel_rpl_machines[] = {
414 	{
415 		.comp_ids = &rpl_rt5682_hp,
416 		.drv_name = "rpl_mx98357_rt5682",
417 		.machine_quirk = snd_soc_acpi_codec_list,
418 		.quirk_data = &rpl_max98357a_amp,
419 		.sof_tplg_filename = "sof-rpl-max98357a-rt5682.tplg",
420 	},
421 	{
422 		.comp_ids = &rpl_rt5682_hp,
423 		.drv_name = "rpl_rt5682_c1_h02",
424 		.machine_quirk = snd_soc_acpi_codec_list,
425 		.quirk_data = &rpl_lt6911_hdmi,
426 		.sof_tplg_filename = "sof-rpl-rt5682-ssp1-hdmi-ssp02.tplg",
427 	},
428 	{
429 		.comp_ids = &rpl_essx_83x6,
430 		.drv_name = "rpl_es83x6_c1_h02",
431 		.machine_quirk = snd_soc_acpi_codec_list,
432 		.quirk_data = &rpl_lt6911_hdmi,
433 		.sof_tplg_filename = "sof-rpl-es83x6-ssp1-hdmi-ssp02.tplg",
434 	},
435 	{
436 		.comp_ids = &rpl_essx_83x6,
437 		.drv_name = "sof-essx8336",
438 		.sof_tplg_filename = "sof-rpl-es83x6", /* the tplg suffix is added at run time */
439 		.tplg_quirk_mask = SND_SOC_ACPI_TPLG_INTEL_SSP_NUMBER |
440 					SND_SOC_ACPI_TPLG_INTEL_SSP_MSB |
441 					SND_SOC_ACPI_TPLG_INTEL_DMIC_NUMBER,
442 	},
443 	/* place boards for each headphone codec: sof driver will complete the
444 	 * tplg name and machine driver will detect the amp type
445 	 */
446 	{
447 		.id = CS42L42_ACPI_HID,
448 		.drv_name = "rpl_cs42l42_def",
449 		.sof_tplg_filename = "sof-rpl", /* the tplg suffix is added at run time */
450 		.tplg_quirk_mask = SND_SOC_ACPI_TPLG_INTEL_AMP_NAME |
451 					SND_SOC_ACPI_TPLG_INTEL_CODEC_NAME,
452 	},
453 	{
454 		.id = DA7219_ACPI_HID,
455 		.drv_name = "rpl_da7219_def",
456 		.sof_tplg_filename = "sof-rpl", /* the tplg suffix is added at run time */
457 		.tplg_quirk_mask = SND_SOC_ACPI_TPLG_INTEL_AMP_NAME |
458 					SND_SOC_ACPI_TPLG_INTEL_CODEC_NAME,
459 	},
460 	{
461 		.id = NAU8825_ACPI_HID,
462 		.drv_name = "rpl_nau8825_def",
463 		.sof_tplg_filename = "sof-rpl", /* the tplg suffix is added at run time */
464 		.tplg_quirk_mask = SND_SOC_ACPI_TPLG_INTEL_AMP_NAME |
465 					SND_SOC_ACPI_TPLG_INTEL_CODEC_NAME,
466 	},
467 	{
468 		.id = RT5650_ACPI_HID,
469 		.drv_name = "rpl_rt5682_def",
470 		.sof_tplg_filename = "sof-rpl", /* the tplg suffix is added at run time */
471 		.tplg_quirk_mask = SND_SOC_ACPI_TPLG_INTEL_AMP_NAME |
472 					SND_SOC_ACPI_TPLG_INTEL_CODEC_NAME,
473 	},
474 	{
475 		.comp_ids = &rpl_rt5682_hp,
476 		.drv_name = "rpl_rt5682_def",
477 		.sof_tplg_filename = "sof-rpl", /* the tplg suffix is added at run time */
478 		.tplg_quirk_mask = SND_SOC_ACPI_TPLG_INTEL_AMP_NAME |
479 					SND_SOC_ACPI_TPLG_INTEL_CODEC_NAME,
480 	},
481 	/* place amp-only boards in the end of table */
482 	{
483 		.id = "INTC10B0",
484 		.drv_name = "rpl_lt6911_hdmi_ssp",
485 		.sof_tplg_filename = "sof-rpl-nocodec-hdmi-ssp02.tplg"
486 	},
487 	{},
488 };
489 EXPORT_SYMBOL_GPL(snd_soc_acpi_intel_rpl_machines);
490 
491 /* this table is used when there is no I2S codec present */
492 struct snd_soc_acpi_mach snd_soc_acpi_intel_rpl_sdw_machines[] = {
493 	{
494 		.link_mask = BIT(0),
495 		.links = rpl_cs42l43_l0,
496 		.drv_name = "sof_sdw",
497 		.sof_tplg_filename = "sof-rpl-cs42l43-l0.tplg",
498 	},
499 	{
500 		.link_mask = 0xF, /* 4 active links required */
501 		.links = rpl_sdca_3_in_1,
502 		.drv_name = "sof_sdw",
503 		.sof_tplg_filename = "sof-rpl-rt711-l0-rt1316-l13-rt714-l2.tplg",
504 	},
505 	{
506 		.link_mask = 0xF, /* 4 active links required */
507 		.links = rpl_sdw_rt711_link2_rt1316_link01_rt714_link3,
508 		.drv_name = "sof_sdw",
509 		.sof_tplg_filename = "sof-rpl-rt711-l2-rt1316-l01-rt714-l3.tplg",
510 	},
511 	{
512 		.link_mask = 0xF, /* 4 active links required */
513 		.links = rpl_sdw_rt711_link0_rt1316_link12_rt714_link3,
514 		.drv_name = "sof_sdw",
515 		.sof_tplg_filename = "sof-rpl-rt711-l0-rt1316-l12-rt714-l3.tplg",
516 	},
517 	{
518 		.link_mask = 0xF, /* 4 active links required */
519 		.links = rpl_sdw_rt711_link0_rt1318_link12_rt714_link3,
520 		.drv_name = "sof_sdw",
521 		.sof_tplg_filename = "sof-rpl-rt711-l0-rt1318-l12-rt714-l3.tplg",
522 	},
523 	{
524 		.link_mask = 0x7, /* rt711 on link0 & two rt1316s on link1 and link2 */
525 		.links = rpl_sdw_rt711_link0_rt1316_link12,
526 		.drv_name = "sof_sdw",
527 		.sof_tplg_filename = "sof-rpl-rt711-l0-rt1316-l12.tplg",
528 	},
529 	{
530 		.link_mask = 0x7, /* rt711 on link0 & two rt1318s on link1 and link2 */
531 		.links = rpl_sdw_rt711_link0_rt1318_link12,
532 		.drv_name = "sof_sdw",
533 		.sof_tplg_filename = "sof-rpl-rt711-l0-rt1318-l12.tplg",
534 	},
535 	{
536 		.link_mask = 0x7, /* rt714 on link0 & two rt1316s on link1 and link2 */
537 		.links = rpl_sdw_rt1316_link12_rt714_link0,
538 		.drv_name = "sof_sdw",
539 		.sof_tplg_filename = "sof-rpl-rt1316-l12-rt714-l0.tplg",
540 	},
541 	{
542 		.link_mask = 0x7, /* rt711 on link2 & two rt1316s on link0 and link1 */
543 		.links = rpl_sdw_rt711_link2_rt1316_link01,
544 		.drv_name = "sof_sdw",
545 		.sof_tplg_filename = "sof-rpl-rt711-l2-rt1316-l01.tplg",
546 	},
547 	{
548 		.link_mask = 0x1, /* link0 required */
549 		.links = rpl_rvp,
550 		.drv_name = "sof_sdw",
551 		.sof_tplg_filename = "sof-rpl-rt711-l0.tplg",
552 	},
553 	{
554 		.link_mask = 0x1, /* link0 required */
555 		.links = rpl_sdca_rvp,
556 		.drv_name = "sof_sdw",
557 		.sof_tplg_filename = "sof-rpl-rt711-l0.tplg",
558 	},
559 	{
560 		.link_mask = 0x4, /* link2 required */
561 		.links = rplp_crb,
562 		.drv_name = "sof_sdw",
563 		.sof_tplg_filename = "sof-rpl-rt711-l2.tplg",
564 	},
565 	{},
566 };
567 EXPORT_SYMBOL_GPL(snd_soc_acpi_intel_rpl_sdw_machines);
568