1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3  * soc-apci-intel-arl-match.c - tables and support for ARL ACPI enumeration.
4  *
5  * Copyright (c) 2023 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 spk_2_endpoint = {
34 	.num = 0,
35 	.aggregated = 1,
36 	.group_position = 2,
37 	.group_id = 1,
38 };
39 
40 static const struct snd_soc_acpi_endpoint spk_3_endpoint = {
41 	.num = 0,
42 	.aggregated = 1,
43 	.group_position = 3,
44 	.group_id = 1,
45 };
46 
47 /*
48  * RT722 is a multi-function codec, three endpoints are created for
49  * its headset, amp and dmic functions.
50  */
51 static const struct snd_soc_acpi_endpoint rt722_endpoints[] = {
52 	{
53 		.num = 0,
54 		.aggregated = 0,
55 		.group_position = 0,
56 		.group_id = 0,
57 	},
58 	{
59 		.num = 1,
60 		.aggregated = 0,
61 		.group_position = 0,
62 		.group_id = 0,
63 	},
64 	{
65 		.num = 2,
66 		.aggregated = 0,
67 		.group_position = 0,
68 		.group_id = 0,
69 	},
70 };
71 
72 static const struct snd_soc_acpi_adr_device cs35l56_2_lr_adr[] = {
73 	{
74 		.adr = 0x00023001FA355601ull,
75 		.num_endpoints = 1,
76 		.endpoints = &spk_l_endpoint,
77 		.name_prefix = "AMP1"
78 	},
79 	{
80 		.adr = 0x00023101FA355601ull,
81 		.num_endpoints = 1,
82 		.endpoints = &spk_r_endpoint,
83 		.name_prefix = "AMP2"
84 	}
85 };
86 
87 static const struct snd_soc_acpi_adr_device cs35l56_3_lr_adr[] = {
88 	{
89 		.adr = 0x00033001FA355601ull,
90 		.num_endpoints = 1,
91 		.endpoints = &spk_l_endpoint,
92 		.name_prefix = "AMP1"
93 	},
94 	{
95 		.adr = 0x00033401FA355601ull,
96 		.num_endpoints = 1,
97 		.endpoints = &spk_r_endpoint,
98 		.name_prefix = "AMP2"
99 	}
100 };
101 
102 static const struct snd_soc_acpi_adr_device cs35l56_2_r_adr[] = {
103 	{
104 		.adr = 0x00023201FA355601ull,
105 		.num_endpoints = 1,
106 		.endpoints = &spk_r_endpoint,
107 		.name_prefix = "AMP3"
108 	},
109 	{
110 		.adr = 0x00023301FA355601ull,
111 		.num_endpoints = 1,
112 		.endpoints = &spk_3_endpoint,
113 		.name_prefix = "AMP4"
114 	}
115 };
116 
117 static const struct snd_soc_acpi_adr_device cs35l56_3_l_adr[] = {
118 	{
119 		.adr = 0x00033001fa355601ull,
120 		.num_endpoints = 1,
121 		.endpoints = &spk_l_endpoint,
122 		.name_prefix = "AMP1"
123 	},
124 	{
125 		.adr = 0x00033101fa355601ull,
126 		.num_endpoints = 1,
127 		.endpoints = &spk_2_endpoint,
128 		.name_prefix = "AMP2"
129 	}
130 };
131 
132 static const struct snd_soc_acpi_adr_device cs35l56_2_r1_adr[] = {
133 	{
134 		.adr = 0x00023101FA355601ull,
135 		.num_endpoints = 1,
136 		.endpoints = &spk_r_endpoint,
137 		.name_prefix = "AMP2"
138 	},
139 };
140 
141 static const struct snd_soc_acpi_adr_device cs35l56_3_l3_adr[] = {
142 	{
143 		.adr = 0x00033301fa355601ull,
144 		.num_endpoints = 1,
145 		.endpoints = &spk_l_endpoint,
146 		.name_prefix = "AMP1"
147 	},
148 };
149 
150 static const struct snd_soc_acpi_adr_device cs35l56_2_r3_adr[] = {
151 	{
152 		.adr = 0x00023301fa355601ull,
153 		.num_endpoints = 1,
154 		.endpoints = &spk_r_endpoint,
155 		.name_prefix = "AMP2"
156 	},
157 };
158 
159 static const struct snd_soc_acpi_adr_device cs35l56_3_l1_adr[] = {
160 	{
161 		.adr = 0x00033101fa355601ull,
162 		.num_endpoints = 1,
163 		.endpoints = &spk_l_endpoint,
164 		.name_prefix = "AMP1"
165 	},
166 };
167 
168 static const struct snd_soc_acpi_endpoint cs42l43_endpoints[] = {
169 	{ /* Jack Playback Endpoint */
170 		.num = 0,
171 		.aggregated = 0,
172 		.group_position = 0,
173 		.group_id = 0,
174 	},
175 	{ /* DMIC Capture Endpoint */
176 		.num = 1,
177 		.aggregated = 0,
178 		.group_position = 0,
179 		.group_id = 0,
180 	},
181 	{ /* Jack Capture Endpoint */
182 		.num = 2,
183 		.aggregated = 0,
184 		.group_position = 0,
185 		.group_id = 0,
186 	},
187 	{ /* Speaker Playback Endpoint */
188 		.num = 3,
189 		.aggregated = 0,
190 		.group_position = 0,
191 		.group_id = 0,
192 	},
193 };
194 
195 static const struct snd_soc_acpi_adr_device cs42l43_0_adr[] = {
196 	{
197 		.adr = 0x00003001FA424301ull,
198 		.num_endpoints = ARRAY_SIZE(cs42l43_endpoints),
199 		.endpoints = cs42l43_endpoints,
200 		.name_prefix = "cs42l43"
201 	}
202 };
203 
204 static const struct snd_soc_acpi_adr_device cs42l43_2_adr[] = {
205 	{
206 		.adr = 0x00023001FA424301ull,
207 		.num_endpoints = ARRAY_SIZE(cs42l43_endpoints),
208 		.endpoints = cs42l43_endpoints,
209 		.name_prefix = "cs42l43"
210 	}
211 };
212 
213 static const struct snd_soc_acpi_adr_device rt711_0_adr[] = {
214 	{
215 		.adr = 0x000020025D071100ull,
216 		.num_endpoints = 1,
217 		.endpoints = &single_endpoint,
218 		.name_prefix = "rt711"
219 	}
220 };
221 
222 static const struct snd_soc_acpi_adr_device rt711_sdca_0_adr[] = {
223 	{
224 		.adr = 0x000030025D071101ull,
225 		.num_endpoints = 1,
226 		.endpoints = &single_endpoint,
227 		.name_prefix = "rt711"
228 	}
229 };
230 
231 static const struct snd_soc_acpi_adr_device rt722_0_single_adr[] = {
232 	{
233 		.adr = 0x000030025D072201ull,
234 		.num_endpoints = ARRAY_SIZE(rt722_endpoints),
235 		.endpoints = rt722_endpoints,
236 		.name_prefix = "rt722"
237 	}
238 };
239 
240 static const struct snd_soc_acpi_adr_device rt1320_2_single_adr[] = {
241 	{
242 		.adr = 0x000230025D132001ull,
243 		.num_endpoints = 1,
244 		.endpoints = &single_endpoint,
245 		.name_prefix = "rt1320-1"
246 	}
247 };
248 
249 static const struct snd_soc_acpi_link_adr arl_cs42l43_l0[] = {
250 	{
251 		.mask = BIT(0),
252 		.num_adr = ARRAY_SIZE(cs42l43_0_adr),
253 		.adr_d = cs42l43_0_adr,
254 	},
255 	{}
256 };
257 
258 static const struct snd_soc_acpi_link_adr arl_cs42l43_l2[] = {
259 	{
260 		.mask = BIT(2),
261 		.num_adr = ARRAY_SIZE(cs42l43_2_adr),
262 		.adr_d = cs42l43_2_adr,
263 	},
264 	{}
265 };
266 
267 static const struct snd_soc_acpi_link_adr arl_cs42l43_l2_cs35l56_l3[] = {
268 	{
269 		.mask = BIT(2),
270 		.num_adr = ARRAY_SIZE(cs42l43_2_adr),
271 		.adr_d = cs42l43_2_adr,
272 	},
273 	{
274 		.mask = BIT(3),
275 		.num_adr = ARRAY_SIZE(cs35l56_3_lr_adr),
276 		.adr_d = cs35l56_3_lr_adr,
277 	},
278 	{}
279 };
280 
281 static const struct snd_soc_acpi_link_adr arl_cs42l43_l0_cs35l56_l2[] = {
282 	{
283 		.mask = BIT(0),
284 		.num_adr = ARRAY_SIZE(cs42l43_0_adr),
285 		.adr_d = cs42l43_0_adr,
286 	},
287 	{
288 		.mask = BIT(2),
289 		.num_adr = ARRAY_SIZE(cs35l56_2_lr_adr),
290 		.adr_d = cs35l56_2_lr_adr,
291 	},
292 	{}
293 };
294 
295 static const struct snd_soc_acpi_link_adr arl_cs42l43_l0_cs35l56_l23[] = {
296 	{
297 		.mask = BIT(0),
298 		.num_adr = ARRAY_SIZE(cs42l43_0_adr),
299 		.adr_d = cs42l43_0_adr,
300 	},
301 	{
302 		.mask = BIT(2),
303 		.num_adr = ARRAY_SIZE(cs35l56_2_r_adr),
304 		.adr_d = cs35l56_2_r_adr,
305 	},
306 	{
307 		.mask = BIT(3),
308 		.num_adr = ARRAY_SIZE(cs35l56_3_l_adr),
309 		.adr_d = cs35l56_3_l_adr,
310 	},
311 	{}
312 };
313 
314 static const struct snd_soc_acpi_link_adr arl_cs42l43_l0_cs35l56_2_l23[] = {
315 	{
316 		.mask = BIT(0),
317 		.num_adr = ARRAY_SIZE(cs42l43_0_adr),
318 		.adr_d = cs42l43_0_adr,
319 	},
320 	{
321 		.mask = BIT(2),
322 		.num_adr = ARRAY_SIZE(cs35l56_2_r1_adr),
323 		.adr_d = cs35l56_2_r1_adr,
324 	},
325 	{
326 		.mask = BIT(3),
327 		.num_adr = ARRAY_SIZE(cs35l56_3_l3_adr),
328 		.adr_d = cs35l56_3_l3_adr,
329 	},
330 	{}
331 };
332 
333 static const struct snd_soc_acpi_link_adr arl_cs42l43_l0_cs35l56_3_l23[] = {
334 	{
335 		.mask = BIT(0),
336 		.num_adr = ARRAY_SIZE(cs42l43_0_adr),
337 		.adr_d = cs42l43_0_adr,
338 	},
339 	{
340 		.mask = BIT(2),
341 		.num_adr = ARRAY_SIZE(cs35l56_2_r3_adr),
342 		.adr_d = cs35l56_2_r3_adr,
343 	},
344 	{
345 		.mask = BIT(3),
346 		.num_adr = ARRAY_SIZE(cs35l56_3_l1_adr),
347 		.adr_d = cs35l56_3_l1_adr,
348 	},
349 	{}
350 };
351 
352 static const struct snd_soc_acpi_link_adr arl_rvp[] = {
353 	{
354 		.mask = BIT(0),
355 		.num_adr = ARRAY_SIZE(rt711_0_adr),
356 		.adr_d = rt711_0_adr,
357 	},
358 	{}
359 };
360 
361 static const struct snd_soc_acpi_link_adr arl_sdca_rvp[] = {
362 	{
363 		.mask = BIT(0),
364 		.num_adr = ARRAY_SIZE(rt711_sdca_0_adr),
365 		.adr_d = rt711_sdca_0_adr,
366 	},
367 	{}
368 };
369 
370 static const struct snd_soc_acpi_link_adr arl_rt722_l0_rt1320_l2[] = {
371 	{
372 		.mask = BIT(0),
373 		.num_adr = ARRAY_SIZE(rt722_0_single_adr),
374 		.adr_d = rt722_0_single_adr,
375 	},
376 	{
377 		.mask = BIT(2),
378 		.num_adr = ARRAY_SIZE(rt1320_2_single_adr),
379 		.adr_d = rt1320_2_single_adr,
380 	},
381 	{}
382 };
383 
384 static const struct snd_soc_acpi_codecs arl_essx_83x6 = {
385 	.num_codecs = 3,
386 	.codecs = { "ESSX8316", "ESSX8326", "ESSX8336"},
387 };
388 
389 static const struct snd_soc_acpi_codecs arl_rt5682_hp = {
390 	.num_codecs = 2,
391 	.codecs = {RT5682_ACPI_HID, RT5682S_ACPI_HID},
392 };
393 
394 static const struct snd_soc_acpi_codecs arl_lt6911_hdmi = {
395 	.num_codecs = 1,
396 	.codecs = {"INTC10B0"}
397 };
398 
399 struct snd_soc_acpi_mach snd_soc_acpi_intel_arl_machines[] = {
400 	{
401 		.comp_ids = &arl_essx_83x6,
402 		.drv_name = "arl_es83x6_c1_h02",
403 		.machine_quirk = snd_soc_acpi_codec_list,
404 		.quirk_data = &arl_lt6911_hdmi,
405 		.sof_tplg_filename = "sof-arl-es83x6-ssp1-hdmi-ssp02.tplg",
406 	},
407 	{
408 		.comp_ids = &arl_essx_83x6,
409 		.drv_name = "sof-essx8336",
410 		.sof_tplg_filename = "sof-arl-es8336", /* the tplg suffix is added at run time */
411 		.tplg_quirk_mask = SND_SOC_ACPI_TPLG_INTEL_SSP_NUMBER |
412 			SND_SOC_ACPI_TPLG_INTEL_SSP_MSB |
413 			SND_SOC_ACPI_TPLG_INTEL_DMIC_NUMBER,
414 	},
415 	{
416 		.comp_ids = &arl_rt5682_hp,
417 		.drv_name = "arl_rt5682_c1_h02",
418 		.machine_quirk = snd_soc_acpi_codec_list,
419 		.quirk_data = &arl_lt6911_hdmi,
420 		.sof_tplg_filename = "sof-arl-rt5682-ssp1-hdmi-ssp02.tplg",
421 	},
422 	/* place amp-only boards in the end of table */
423 	{
424 		.id = "INTC10B0",
425 		.drv_name = "arl_lt6911_hdmi_ssp",
426 		.sof_tplg_filename = "sof-arl-hdmi-ssp02.tplg",
427 	},
428 	{},
429 };
430 EXPORT_SYMBOL_GPL(snd_soc_acpi_intel_arl_machines);
431 
432 /* this table is used when there is no I2S codec present */
433 struct snd_soc_acpi_mach snd_soc_acpi_intel_arl_sdw_machines[] = {
434 	{
435 		.link_mask = BIT(0) | BIT(2) | BIT(3),
436 		.links = arl_cs42l43_l0_cs35l56_l23,
437 		.drv_name = "sof_sdw",
438 		.sof_tplg_filename = "sof-arl-cs42l43-l0-cs35l56-l23.tplg",
439 	},
440 	{
441 		.link_mask = BIT(0) | BIT(2) | BIT(3),
442 		.links = arl_cs42l43_l0_cs35l56_2_l23,
443 		.drv_name = "sof_sdw",
444 		.sof_tplg_filename = "sof-arl-cs42l43-l0-cs35l56-l23.tplg",
445 	},
446 	{
447 		.link_mask = BIT(0) | BIT(2) | BIT(3),
448 		.links = arl_cs42l43_l0_cs35l56_3_l23,
449 		.drv_name = "sof_sdw",
450 		.sof_tplg_filename = "sof-arl-cs42l43-l0-cs35l56-l23.tplg",
451 	},
452 	{
453 		.link_mask = BIT(0) | BIT(2),
454 		.links = arl_cs42l43_l0_cs35l56_l2,
455 		.drv_name = "sof_sdw",
456 		.sof_tplg_filename = "sof-arl-cs42l43-l0-cs35l56-l2.tplg",
457 	},
458 	{
459 		.link_mask = BIT(0),
460 		.links = arl_cs42l43_l0,
461 		.drv_name = "sof_sdw",
462 		.sof_tplg_filename = "sof-arl-cs42l43-l0.tplg",
463 	},
464 	{
465 		.link_mask = BIT(2),
466 		.links = arl_cs42l43_l2,
467 		.drv_name = "sof_sdw",
468 		.sof_tplg_filename = "sof-arl-cs42l43-l2.tplg",
469 	},
470 	{
471 		.link_mask = BIT(2) | BIT(3),
472 		.links = arl_cs42l43_l2_cs35l56_l3,
473 		.drv_name = "sof_sdw",
474 		.sof_tplg_filename = "sof-arl-cs42l43-l2-cs35l56-l3.tplg",
475 	},
476 	{
477 		.link_mask = 0x1, /* link0 required */
478 		.links = arl_rvp,
479 		.drv_name = "sof_sdw",
480 		.sof_tplg_filename = "sof-arl-rt711.tplg",
481 	},
482 	{
483 		.link_mask = 0x1, /* link0 required */
484 		.links = arl_sdca_rvp,
485 		.drv_name = "sof_sdw",
486 		.sof_tplg_filename = "sof-arl-rt711-l0.tplg",
487 	},
488 	{
489 		.link_mask = BIT(0) | BIT(2),
490 		.links = arl_rt722_l0_rt1320_l2,
491 		.drv_name = "sof_sdw",
492 		.sof_tplg_filename = "sof-arl-rt722-l0_rt1320-l2.tplg",
493 	},
494 	{},
495 };
496 EXPORT_SYMBOL_GPL(snd_soc_acpi_intel_arl_sdw_machines);
497