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 static const struct snd_soc_acpi_adr_device cs35l56_2_lr_adr[] = {
48 	{
49 		.adr = 0x00023001FA355601ull,
50 		.num_endpoints = 1,
51 		.endpoints = &spk_l_endpoint,
52 		.name_prefix = "AMP1"
53 	},
54 	{
55 		.adr = 0x00023101FA355601ull,
56 		.num_endpoints = 1,
57 		.endpoints = &spk_r_endpoint,
58 		.name_prefix = "AMP2"
59 	}
60 };
61 
62 static const struct snd_soc_acpi_adr_device cs35l56_3_lr_adr[] = {
63 	{
64 		.adr = 0x00033001FA355601ull,
65 		.num_endpoints = 1,
66 		.endpoints = &spk_l_endpoint,
67 		.name_prefix = "AMP1"
68 	},
69 	{
70 		.adr = 0x00033401FA355601ull,
71 		.num_endpoints = 1,
72 		.endpoints = &spk_r_endpoint,
73 		.name_prefix = "AMP2"
74 	}
75 };
76 
77 static const struct snd_soc_acpi_adr_device cs35l56_2_r_adr[] = {
78 	{
79 		.adr = 0x00023201FA355601ull,
80 		.num_endpoints = 1,
81 		.endpoints = &spk_r_endpoint,
82 		.name_prefix = "AMP3"
83 	},
84 	{
85 		.adr = 0x00023301FA355601ull,
86 		.num_endpoints = 1,
87 		.endpoints = &spk_3_endpoint,
88 		.name_prefix = "AMP4"
89 	}
90 };
91 
92 static const struct snd_soc_acpi_adr_device cs35l56_3_l_adr[] = {
93 	{
94 		.adr = 0x00033001fa355601ull,
95 		.num_endpoints = 1,
96 		.endpoints = &spk_l_endpoint,
97 		.name_prefix = "AMP1"
98 	},
99 	{
100 		.adr = 0x00033101fa355601ull,
101 		.num_endpoints = 1,
102 		.endpoints = &spk_2_endpoint,
103 		.name_prefix = "AMP2"
104 	}
105 };
106 
107 static const struct snd_soc_acpi_adr_device cs35l56_2_r1_adr[] = {
108 	{
109 		.adr = 0x00023101FA355601ull,
110 		.num_endpoints = 1,
111 		.endpoints = &spk_r_endpoint,
112 		.name_prefix = "AMP2"
113 	},
114 };
115 
116 static const struct snd_soc_acpi_adr_device cs35l56_3_l1_adr[] = {
117 	{
118 		.adr = 0x00033301fa355601ull,
119 		.num_endpoints = 1,
120 		.endpoints = &spk_l_endpoint,
121 		.name_prefix = "AMP1"
122 	},
123 };
124 
125 static const struct snd_soc_acpi_endpoint cs42l43_endpoints[] = {
126 	{ /* Jack Playback Endpoint */
127 		.num = 0,
128 		.aggregated = 0,
129 		.group_position = 0,
130 		.group_id = 0,
131 	},
132 	{ /* DMIC Capture Endpoint */
133 		.num = 1,
134 		.aggregated = 0,
135 		.group_position = 0,
136 		.group_id = 0,
137 	},
138 	{ /* Jack Capture Endpoint */
139 		.num = 2,
140 		.aggregated = 0,
141 		.group_position = 0,
142 		.group_id = 0,
143 	},
144 	{ /* Speaker Playback Endpoint */
145 		.num = 3,
146 		.aggregated = 0,
147 		.group_position = 0,
148 		.group_id = 0,
149 	},
150 };
151 
152 static const struct snd_soc_acpi_adr_device cs42l43_0_adr[] = {
153 	{
154 		.adr = 0x00003001FA424301ull,
155 		.num_endpoints = ARRAY_SIZE(cs42l43_endpoints),
156 		.endpoints = cs42l43_endpoints,
157 		.name_prefix = "cs42l43"
158 	}
159 };
160 
161 static const struct snd_soc_acpi_adr_device cs42l43_2_adr[] = {
162 	{
163 		.adr = 0x00023001FA424301ull,
164 		.num_endpoints = ARRAY_SIZE(cs42l43_endpoints),
165 		.endpoints = cs42l43_endpoints,
166 		.name_prefix = "cs42l43"
167 	}
168 };
169 
170 static const struct snd_soc_acpi_adr_device rt711_0_adr[] = {
171 	{
172 		.adr = 0x000020025D071100ull,
173 		.num_endpoints = 1,
174 		.endpoints = &single_endpoint,
175 		.name_prefix = "rt711"
176 	}
177 };
178 
179 static const struct snd_soc_acpi_adr_device rt711_sdca_0_adr[] = {
180 	{
181 		.adr = 0x000030025D071101ull,
182 		.num_endpoints = 1,
183 		.endpoints = &single_endpoint,
184 		.name_prefix = "rt711"
185 	}
186 };
187 
188 static const struct snd_soc_acpi_link_adr arl_cs42l43_l0[] = {
189 	{
190 		.mask = BIT(0),
191 		.num_adr = ARRAY_SIZE(cs42l43_0_adr),
192 		.adr_d = cs42l43_0_adr,
193 	},
194 	{}
195 };
196 
197 static const struct snd_soc_acpi_link_adr arl_cs42l43_l2[] = {
198 	{
199 		.mask = BIT(2),
200 		.num_adr = ARRAY_SIZE(cs42l43_2_adr),
201 		.adr_d = cs42l43_2_adr,
202 	},
203 	{}
204 };
205 
206 static const struct snd_soc_acpi_link_adr arl_cs42l43_l2_cs35l56_l3[] = {
207 	{
208 		.mask = BIT(2),
209 		.num_adr = ARRAY_SIZE(cs42l43_2_adr),
210 		.adr_d = cs42l43_2_adr,
211 	},
212 	{
213 		.mask = BIT(3),
214 		.num_adr = ARRAY_SIZE(cs35l56_3_lr_adr),
215 		.adr_d = cs35l56_3_lr_adr,
216 	},
217 	{}
218 };
219 
220 static const struct snd_soc_acpi_link_adr arl_cs42l43_l0_cs35l56_l2[] = {
221 	{
222 		.mask = BIT(0),
223 		.num_adr = ARRAY_SIZE(cs42l43_0_adr),
224 		.adr_d = cs42l43_0_adr,
225 	},
226 	{
227 		.mask = BIT(2),
228 		.num_adr = ARRAY_SIZE(cs35l56_2_lr_adr),
229 		.adr_d = cs35l56_2_lr_adr,
230 	},
231 	{}
232 };
233 
234 static const struct snd_soc_acpi_link_adr arl_cs42l43_l0_cs35l56_l23[] = {
235 	{
236 		.mask = BIT(0),
237 		.num_adr = ARRAY_SIZE(cs42l43_0_adr),
238 		.adr_d = cs42l43_0_adr,
239 	},
240 	{
241 		.mask = BIT(2),
242 		.num_adr = ARRAY_SIZE(cs35l56_2_r_adr),
243 		.adr_d = cs35l56_2_r_adr,
244 	},
245 	{
246 		.mask = BIT(3),
247 		.num_adr = ARRAY_SIZE(cs35l56_3_l_adr),
248 		.adr_d = cs35l56_3_l_adr,
249 	},
250 	{}
251 };
252 
253 static const struct snd_soc_acpi_link_adr arl_cs42l43_l0_cs35l56_2_l23[] = {
254 	{
255 		.mask = BIT(0),
256 		.num_adr = ARRAY_SIZE(cs42l43_0_adr),
257 		.adr_d = cs42l43_0_adr,
258 	},
259 	{
260 		.mask = BIT(2),
261 		.num_adr = ARRAY_SIZE(cs35l56_2_r1_adr),
262 		.adr_d = cs35l56_2_r1_adr,
263 	},
264 	{
265 		.mask = BIT(3),
266 		.num_adr = ARRAY_SIZE(cs35l56_3_l1_adr),
267 		.adr_d = cs35l56_3_l1_adr,
268 	},
269 	{}
270 };
271 
272 static const struct snd_soc_acpi_link_adr arl_rvp[] = {
273 	{
274 		.mask = BIT(0),
275 		.num_adr = ARRAY_SIZE(rt711_0_adr),
276 		.adr_d = rt711_0_adr,
277 	},
278 	{}
279 };
280 
281 static const struct snd_soc_acpi_link_adr arl_sdca_rvp[] = {
282 	{
283 		.mask = BIT(0),
284 		.num_adr = ARRAY_SIZE(rt711_sdca_0_adr),
285 		.adr_d = rt711_sdca_0_adr,
286 	},
287 	{}
288 };
289 
290 static const struct snd_soc_acpi_codecs arl_essx_83x6 = {
291 	.num_codecs = 3,
292 	.codecs = { "ESSX8316", "ESSX8326", "ESSX8336"},
293 };
294 
295 static const struct snd_soc_acpi_codecs arl_rt5682_hp = {
296 	.num_codecs = 2,
297 	.codecs = {RT5682_ACPI_HID, RT5682S_ACPI_HID},
298 };
299 
300 static const struct snd_soc_acpi_codecs arl_lt6911_hdmi = {
301 	.num_codecs = 1,
302 	.codecs = {"INTC10B0"}
303 };
304 
305 struct snd_soc_acpi_mach snd_soc_acpi_intel_arl_machines[] = {
306 	{
307 		.comp_ids = &arl_essx_83x6,
308 		.drv_name = "arl_es83x6_c1_h02",
309 		.machine_quirk = snd_soc_acpi_codec_list,
310 		.quirk_data = &arl_lt6911_hdmi,
311 		.sof_tplg_filename = "sof-arl-es83x6-ssp1-hdmi-ssp02.tplg",
312 	},
313 	{
314 		.comp_ids = &arl_essx_83x6,
315 		.drv_name = "sof-essx8336",
316 		.sof_tplg_filename = "sof-arl-es8336", /* the tplg suffix is added at run time */
317 		.tplg_quirk_mask = SND_SOC_ACPI_TPLG_INTEL_SSP_NUMBER |
318 			SND_SOC_ACPI_TPLG_INTEL_SSP_MSB |
319 			SND_SOC_ACPI_TPLG_INTEL_DMIC_NUMBER,
320 	},
321 	{
322 		.comp_ids = &arl_rt5682_hp,
323 		.drv_name = "arl_rt5682_c1_h02",
324 		.machine_quirk = snd_soc_acpi_codec_list,
325 		.quirk_data = &arl_lt6911_hdmi,
326 		.sof_tplg_filename = "sof-arl-rt5682-ssp1-hdmi-ssp02.tplg",
327 	},
328 	/* place amp-only boards in the end of table */
329 	{
330 		.id = "INTC10B0",
331 		.drv_name = "arl_lt6911_hdmi_ssp",
332 		.sof_tplg_filename = "sof-arl-hdmi-ssp02.tplg",
333 	},
334 	{},
335 };
336 EXPORT_SYMBOL_GPL(snd_soc_acpi_intel_arl_machines);
337 
338 /* this table is used when there is no I2S codec present */
339 struct snd_soc_acpi_mach snd_soc_acpi_intel_arl_sdw_machines[] = {
340 	{
341 		.link_mask = BIT(0) | BIT(2) | BIT(3),
342 		.links = arl_cs42l43_l0_cs35l56_l23,
343 		.drv_name = "sof_sdw",
344 		.sof_tplg_filename = "sof-arl-cs42l43-l0-cs35l56-l23.tplg",
345 	},
346 	{
347 		.link_mask = BIT(0) | BIT(2) | BIT(3),
348 		.links = arl_cs42l43_l0_cs35l56_2_l23,
349 		.drv_name = "sof_sdw",
350 		.sof_tplg_filename = "sof-arl-cs42l43-l0-cs35l56-l23.tplg",
351 	},
352 	{
353 		.link_mask = BIT(0) | BIT(2),
354 		.links = arl_cs42l43_l0_cs35l56_l2,
355 		.drv_name = "sof_sdw",
356 		.sof_tplg_filename = "sof-arl-cs42l43-l0-cs35l56-l2.tplg",
357 	},
358 	{
359 		.link_mask = BIT(0),
360 		.links = arl_cs42l43_l0,
361 		.drv_name = "sof_sdw",
362 		.sof_tplg_filename = "sof-arl-cs42l43-l0.tplg",
363 	},
364 	{
365 		.link_mask = BIT(2),
366 		.links = arl_cs42l43_l2,
367 		.drv_name = "sof_sdw",
368 		.sof_tplg_filename = "sof-arl-cs42l43-l2.tplg",
369 	},
370 	{
371 		.link_mask = BIT(2) | BIT(3),
372 		.links = arl_cs42l43_l2_cs35l56_l3,
373 		.drv_name = "sof_sdw",
374 		.sof_tplg_filename = "sof-arl-cs42l43-l2-cs35l56-l3.tplg",
375 	},
376 	{
377 		.link_mask = 0x1, /* link0 required */
378 		.links = arl_rvp,
379 		.drv_name = "sof_sdw",
380 		.sof_tplg_filename = "sof-arl-rt711.tplg",
381 	},
382 	{
383 		.link_mask = 0x1, /* link0 required */
384 		.links = arl_sdca_rvp,
385 		.drv_name = "sof_sdw",
386 		.sof_tplg_filename = "sof-arl-rt711-l0.tplg",
387 	},
388 	{},
389 };
390 EXPORT_SYMBOL_GPL(snd_soc_acpi_intel_arl_sdw_machines);
391