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 rt1316_1_group1_adr[] = {
78 	{
79 		.adr = 0x000131025D131601ull, /* unique ID is set for some reason */
80 		.num_endpoints = 1,
81 		.endpoints = &spk_l_endpoint,
82 		.name_prefix = "rt1316-1"
83 	}
84 };
85 
86 static const struct snd_soc_acpi_adr_device rt1316_2_group1_adr[] = {
87 	{
88 		.adr = 0x000230025D131601ull,
89 		.num_endpoints = 1,
90 		.endpoints = &spk_r_endpoint,
91 		.name_prefix = "rt1316-2"
92 	}
93 };
94 
95 static const struct snd_soc_acpi_adr_device rt1316_3_group1_adr[] = {
96 	{
97 		.adr = 0x000330025D131601ull,
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_2_single_adr[] = {
105 	{
106 		.adr = 0x000230025D131601ull,
107 		.num_endpoints = 1,
108 		.endpoints = &single_endpoint,
109 		.name_prefix = "rt1316-1"
110 	}
111 };
112 
113 static const struct snd_soc_acpi_adr_device rt714_0_adr[] = {
114 	{
115 		.adr = 0x000030025D071401ull,
116 		.num_endpoints = 1,
117 		.endpoints = &single_endpoint,
118 		.name_prefix = "rt714"
119 	}
120 };
121 
122 static const struct snd_soc_acpi_adr_device rt714_2_adr[] = {
123 	{
124 		.adr = 0x000230025D071401ull,
125 		.num_endpoints = 1,
126 		.endpoints = &single_endpoint,
127 		.name_prefix = "rt714"
128 	}
129 };
130 
131 static const struct snd_soc_acpi_adr_device rt714_3_adr[] = {
132 	{
133 		.adr = 0x000330025D071401ull,
134 		.num_endpoints = 1,
135 		.endpoints = &single_endpoint,
136 		.name_prefix = "rt714"
137 	}
138 };
139 
140 static const struct snd_soc_acpi_link_adr adl_default[] = {
141 	{
142 		.mask = BIT(0),
143 		.num_adr = ARRAY_SIZE(rt711_0_adr),
144 		.adr_d = rt711_0_adr,
145 	},
146 	{
147 		.mask = BIT(1),
148 		.num_adr = ARRAY_SIZE(rt1308_1_group1_adr),
149 		.adr_d = rt1308_1_group1_adr,
150 	},
151 	{
152 		.mask = BIT(2),
153 		.num_adr = ARRAY_SIZE(rt1308_2_group1_adr),
154 		.adr_d = rt1308_2_group1_adr,
155 	},
156 	{
157 		.mask = BIT(3),
158 		.num_adr = ARRAY_SIZE(rt715_3_adr),
159 		.adr_d = rt715_3_adr,
160 	},
161 	{}
162 };
163 
164 static const struct snd_soc_acpi_link_adr adl_sdca_default[] = {
165 	{
166 		.mask = BIT(0),
167 		.num_adr = ARRAY_SIZE(rt711_sdca_0_adr),
168 		.adr_d = rt711_sdca_0_adr,
169 	},
170 	{
171 		.mask = BIT(1),
172 		.num_adr = ARRAY_SIZE(rt1316_1_group1_adr),
173 		.adr_d = rt1316_1_group1_adr,
174 	},
175 	{
176 		.mask = BIT(2),
177 		.num_adr = ARRAY_SIZE(rt1316_2_group1_adr),
178 		.adr_d = rt1316_2_group1_adr,
179 	},
180 	{
181 		.mask = BIT(3),
182 		.num_adr = ARRAY_SIZE(rt714_3_adr),
183 		.adr_d = rt714_3_adr,
184 	},
185 	{}
186 };
187 
188 static const struct snd_soc_acpi_link_adr adl_sdca_3_in_1[] = {
189 	{
190 		.mask = BIT(0),
191 		.num_adr = ARRAY_SIZE(rt711_sdca_0_adr),
192 		.adr_d = rt711_sdca_0_adr,
193 	},
194 	{
195 		.mask = BIT(1),
196 		.num_adr = ARRAY_SIZE(rt1316_1_group1_adr),
197 		.adr_d = rt1316_1_group1_adr,
198 	},
199 	{
200 		.mask = BIT(2),
201 		.num_adr = ARRAY_SIZE(rt714_2_adr),
202 		.adr_d = rt714_2_adr,
203 	},
204 	{
205 		.mask = BIT(3),
206 		.num_adr = ARRAY_SIZE(rt1316_3_group1_adr),
207 		.adr_d = rt1316_3_group1_adr,
208 	},
209 	{}
210 };
211 
212 static const struct snd_soc_acpi_link_adr adl_sdw_rt1316_link2_rt714_link0[] = {
213 	{
214 		.mask = BIT(2),
215 		.num_adr = ARRAY_SIZE(rt1316_2_single_adr),
216 		.adr_d = rt1316_2_single_adr,
217 	},
218 	{
219 		.mask = BIT(0),
220 		.num_adr = ARRAY_SIZE(rt714_0_adr),
221 		.adr_d = rt714_0_adr,
222 	},
223 	{}
224 };
225 
226 static const struct snd_soc_acpi_adr_device mx8373_2_adr[] = {
227 	{
228 		.adr = 0x000223019F837300ull,
229 		.num_endpoints = 1,
230 		.endpoints = &spk_l_endpoint,
231 		.name_prefix = "Left"
232 	},
233 	{
234 		.adr = 0x000227019F837300ull,
235 		.num_endpoints = 1,
236 		.endpoints = &spk_r_endpoint,
237 		.name_prefix = "Right"
238 	}
239 };
240 
241 static const struct snd_soc_acpi_adr_device rt5682_0_adr[] = {
242 	{
243 		.adr = 0x000021025D568200ull,
244 		.num_endpoints = 1,
245 		.endpoints = &single_endpoint,
246 		.name_prefix = "rt5682"
247 	}
248 };
249 
250 static const struct snd_soc_acpi_link_adr adl_rvp[] = {
251 	{
252 		.mask = BIT(0),
253 		.num_adr = ARRAY_SIZE(rt711_0_adr),
254 		.adr_d = rt711_0_adr,
255 	},
256 	{}
257 };
258 
259 static const struct snd_soc_acpi_link_adr adl_chromebook_base[] = {
260 	{
261 		.mask = BIT(0),
262 		.num_adr = ARRAY_SIZE(rt5682_0_adr),
263 		.adr_d = rt5682_0_adr,
264 	},
265 	{
266 		.mask = BIT(2),
267 		.num_adr = ARRAY_SIZE(mx8373_2_adr),
268 		.adr_d = mx8373_2_adr,
269 	},
270 	{}
271 };
272 
273 static const struct snd_soc_acpi_codecs adl_max98373_amp = {
274 	.num_codecs = 1,
275 	.codecs = {"MX98373"}
276 };
277 
278 static const struct snd_soc_acpi_codecs adl_max98357a_amp = {
279 	.num_codecs = 1,
280 	.codecs = {"MX98357A"}
281 };
282 
283 static const struct snd_soc_acpi_codecs adl_max98360a_amp = {
284 	.num_codecs = 1,
285 	.codecs = {"MX98360A"}
286 };
287 
288 static const struct snd_soc_acpi_codecs adl_rt5682_rt5682s_hp = {
289 	.num_codecs = 2,
290 	.codecs = {"10EC5682", "RTL5682"},
291 };
292 
293 struct snd_soc_acpi_mach snd_soc_acpi_intel_adl_machines[] = {
294 	{
295 		.comp_ids = &adl_rt5682_rt5682s_hp,
296 		.drv_name = "adl_mx98373_rt5682",
297 		.machine_quirk = snd_soc_acpi_codec_list,
298 		.quirk_data = &adl_max98373_amp,
299 		.sof_fw_filename = "sof-adl.ri",
300 		.sof_tplg_filename = "sof-adl-max98373-rt5682.tplg",
301 	},
302 	{
303 		.comp_ids = &adl_rt5682_rt5682s_hp,
304 		.drv_name = "adl_mx98357_rt5682",
305 		.machine_quirk = snd_soc_acpi_codec_list,
306 		.quirk_data = &adl_max98357a_amp,
307 		.sof_fw_filename = "sof-adl.ri",
308 		.sof_tplg_filename = "sof-adl-max98357a-rt5682.tplg",
309 	},
310 	{
311 		.comp_ids = &adl_rt5682_rt5682s_hp,
312 		.drv_name = "adl_mx98360_rt5682",
313 		.machine_quirk = snd_soc_acpi_codec_list,
314 		.quirk_data = &adl_max98360a_amp,
315 		.sof_fw_filename = "sof-adl.ri",
316 		.sof_tplg_filename = "sof-adl-max98360a-rt5682.tplg",
317 	},
318 	{},
319 };
320 EXPORT_SYMBOL_GPL(snd_soc_acpi_intel_adl_machines);
321 
322 /* this table is used when there is no I2S codec present */
323 struct snd_soc_acpi_mach snd_soc_acpi_intel_adl_sdw_machines[] = {
324 	{
325 		.link_mask = 0xF, /* 4 active links required */
326 		.links = adl_default,
327 		.drv_name = "sof_sdw",
328 		.sof_tplg_filename = "sof-adl-rt711-l0-rt1308-l12-rt715-l3.tplg",
329 	},
330 	{
331 		.link_mask = 0xF, /* 4 active links required */
332 		.links = adl_sdca_default,
333 		.drv_name = "sof_sdw",
334 		.sof_tplg_filename = "sof-adl-rt711-l0-rt1316-l12-rt714-l3.tplg",
335 	},
336 	{
337 		.link_mask = 0xF, /* 4 active links required */
338 		.links = adl_sdca_3_in_1,
339 		.drv_name = "sof_sdw",
340 		.sof_tplg_filename = "sof-adl-rt711-l0-rt1316-l13-rt714-l2.tplg",
341 	},
342 	{
343 		.link_mask = 0x5, /* 2 active links required */
344 		.links = adl_sdw_rt1316_link2_rt714_link0,
345 		.drv_name = "sof_sdw",
346 		.sof_tplg_filename = "sof-adl-rt1316-l2-mono-rt714-l0.tplg",
347 	},
348 	{
349 		.link_mask = 0x1, /* link0 required */
350 		.links = adl_rvp,
351 		.drv_name = "sof_sdw",
352 		.sof_tplg_filename = "sof-adl-rt711.tplg",
353 	},
354 	{
355 		.link_mask = 0x5, /* rt5682 on link0 & 2xmax98373 on link 2 */
356 		.links = adl_chromebook_base,
357 		.drv_name = "sof_sdw",
358 		.sof_fw_filename = "sof-adl.ri",
359 		.sof_tplg_filename = "sof-adl-sdw-max98373-rt5682.tplg",
360 	},
361 	{},
362 };
363 EXPORT_SYMBOL_GPL(snd_soc_acpi_intel_adl_sdw_machines);
364