1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3  * soc-acpi-intel-cml-match.c - tables and support for CML ACPI enumeration.
4  *
5  * Copyright (c) 2019, Intel Corporation.
6  *
7  */
8 
9 #include <sound/soc-acpi.h>
10 #include <sound/soc-acpi-intel-match.h>
11 
12 static const struct snd_soc_acpi_codecs rt1011_spk_codecs = {
13 	.num_codecs = 1,
14 	.codecs = {"10EC1011"}
15 };
16 
17 static const struct snd_soc_acpi_codecs rt1015_spk_codecs = {
18 	.num_codecs = 1,
19 	.codecs = {"10EC1015"}
20 };
21 
22 static const struct snd_soc_acpi_codecs max98357a_spk_codecs = {
23 	.num_codecs = 1,
24 	.codecs = {"MX98357A"}
25 };
26 
27 static const struct snd_soc_acpi_codecs max98390_spk_codecs = {
28 	.num_codecs = 1,
29 	.codecs = {"MX98390"}
30 };
31 
32 /*
33  * The order of the three entries with .id = "10EC5682" matters
34  * here, because DSDT tables expose an ACPI HID for the MAX98357A
35  * speaker amplifier which is not populated on the board.
36  */
37 struct snd_soc_acpi_mach snd_soc_acpi_intel_cml_machines[] = {
38 	{
39 		.id = "10EC5682",
40 		.drv_name = "cml_rt1011_rt5682",
41 		.machine_quirk = snd_soc_acpi_codec_list,
42 		.quirk_data = &rt1011_spk_codecs,
43 		.sof_fw_filename = "sof-cml.ri",
44 		.sof_tplg_filename = "sof-cml-rt1011-rt5682.tplg",
45 	},
46 	{
47 		.id = "10EC5682",
48 		.drv_name = "cml_rt1015_rt5682",
49 		.machine_quirk = snd_soc_acpi_codec_list,
50 		.quirk_data = &rt1015_spk_codecs,
51 		.sof_fw_filename = "sof-cml.ri",
52 		.sof_tplg_filename = "sof-cml-rt1011-rt5682.tplg",
53 	},
54 	{
55 		.id = "10EC5682",
56 		.drv_name = "sof_rt5682",
57 		.machine_quirk = snd_soc_acpi_codec_list,
58 		.quirk_data = &max98357a_spk_codecs,
59 		.sof_fw_filename = "sof-cml.ri",
60 		.sof_tplg_filename = "sof-cml-rt5682-max98357a.tplg",
61 	},
62 	{
63 		.id = "10EC5682",
64 		.drv_name = "sof_rt5682",
65 		.sof_fw_filename = "sof-cml.ri",
66 		.sof_tplg_filename = "sof-cml-rt5682.tplg",
67 	},
68 	{
69 		.id = "DLGS7219",
70 		.drv_name = "cml_da7219_mx98357a",
71 		.machine_quirk = snd_soc_acpi_codec_list,
72 		.quirk_data = &max98357a_spk_codecs,
73 		.sof_fw_filename = "sof-cml.ri",
74 		.sof_tplg_filename = "sof-cml-da7219-max98357a.tplg",
75 	},
76 	{
77 		.id = "DLGS7219",
78 		.drv_name = "cml_da7219_mx98357a",
79 		.machine_quirk = snd_soc_acpi_codec_list,
80 		.quirk_data = &max98390_spk_codecs,
81 		.sof_fw_filename = "sof-cml.ri",
82 		.sof_tplg_filename = "sof-cml-da7219-max98390.tplg",
83 	},
84 	{
85 		.id = "ESSX8336",
86 		.drv_name = "sof-essx8336",
87 		.sof_fw_filename = "sof-cml.ri",
88 		.sof_tplg_filename = "sof-cml-es8336.tplg",
89 	},
90 	{},
91 };
92 EXPORT_SYMBOL_GPL(snd_soc_acpi_intel_cml_machines);
93 
94 static const struct snd_soc_acpi_endpoint single_endpoint = {
95 	.num = 0,
96 	.aggregated = 0,
97 	.group_position = 0,
98 	.group_id = 0,
99 };
100 
101 static const struct snd_soc_acpi_endpoint spk_l_endpoint = {
102 	.num = 0,
103 	.aggregated = 1,
104 	.group_position = 0,
105 	.group_id = 1,
106 };
107 
108 static const struct snd_soc_acpi_endpoint spk_r_endpoint = {
109 	.num = 0,
110 	.aggregated = 1,
111 	.group_position = 1,
112 	.group_id = 1,
113 };
114 
115 static const struct snd_soc_acpi_adr_device rt700_1_adr[] = {
116 	{
117 		.adr = 0x000110025D070000ull,
118 		.num_endpoints = 1,
119 		.endpoints = &single_endpoint,
120 		.name_prefix = "rt700"
121 	}
122 };
123 
124 static const struct snd_soc_acpi_link_adr cml_rvp[] = {
125 	{
126 		.mask = BIT(1),
127 		.num_adr = ARRAY_SIZE(rt700_1_adr),
128 		.adr_d = rt700_1_adr,
129 	},
130 	{}
131 };
132 
133 static const struct snd_soc_acpi_adr_device rt711_0_adr[] = {
134 	{
135 		.adr = 0x000020025D071100ull,
136 		.num_endpoints = 1,
137 		.endpoints = &single_endpoint,
138 		.name_prefix = "rt711"
139 	}
140 };
141 
142 static const struct snd_soc_acpi_adr_device rt1308_1_single_adr[] = {
143 	{
144 		.adr = 0x000120025D130800ull,
145 		.num_endpoints = 1,
146 		.endpoints = &single_endpoint,
147 		.name_prefix = "rt1308-1"
148 	}
149 };
150 
151 static const struct snd_soc_acpi_adr_device rt1308_1_group1_adr[] = {
152 	{
153 		.adr = 0x000120025D130800ull,
154 		.num_endpoints = 1,
155 		.endpoints = &spk_l_endpoint,
156 		.name_prefix = "rt1308-1"
157 	}
158 };
159 
160 static const struct snd_soc_acpi_adr_device rt1308_2_group1_adr[] = {
161 	{
162 		.adr = 0x000220025D130800ull,
163 		.num_endpoints = 1,
164 		.endpoints = &spk_r_endpoint,
165 		.name_prefix = "rt1308-2"
166 	}
167 };
168 
169 static const struct snd_soc_acpi_adr_device rt715_3_adr[] = {
170 	{
171 		.adr = 0x000320025D071500ull,
172 		.num_endpoints = 1,
173 		.endpoints = &single_endpoint,
174 		.name_prefix = "rt715"
175 	}
176 };
177 
178 static const struct snd_soc_acpi_adr_device rt711_sdca_0_adr[] = {
179 	{
180 		.adr = 0x000030025D071101ull,
181 		.num_endpoints = 1,
182 		.endpoints = &single_endpoint,
183 		.name_prefix = "rt711"
184 	}
185 };
186 
187 static const struct snd_soc_acpi_adr_device rt1316_1_group1_adr[] = {
188 	{
189 		.adr = 0x000131025D131601ull, /* unique ID is set for some reason */
190 		.num_endpoints = 1,
191 		.endpoints = &spk_l_endpoint,
192 		.name_prefix = "rt1316-1"
193 	}
194 };
195 
196 static const struct snd_soc_acpi_adr_device rt1316_2_group1_adr[] = {
197 	{
198 		.adr = 0x000230025D131601ull,
199 		.num_endpoints = 1,
200 		.endpoints = &spk_r_endpoint,
201 		.name_prefix = "rt1316-2"
202 	}
203 };
204 
205 static const struct snd_soc_acpi_adr_device rt714_3_adr[] = {
206 	{
207 		.adr = 0x000330025D071401ull,
208 		.num_endpoints = 1,
209 		.endpoints = &single_endpoint,
210 		.name_prefix = "rt714"
211 	}
212 };
213 
214 static const struct snd_soc_acpi_link_adr cml_3_in_1_default[] = {
215 	{
216 		.mask = BIT(0),
217 		.num_adr = ARRAY_SIZE(rt711_0_adr),
218 		.adr_d = rt711_0_adr,
219 	},
220 	{
221 		.mask = BIT(1),
222 		.num_adr = ARRAY_SIZE(rt1308_1_group1_adr),
223 		.adr_d = rt1308_1_group1_adr,
224 	},
225 	{
226 		.mask = BIT(2),
227 		.num_adr = ARRAY_SIZE(rt1308_2_group1_adr),
228 		.adr_d = rt1308_2_group1_adr,
229 	},
230 	{
231 		.mask = BIT(3),
232 		.num_adr = ARRAY_SIZE(rt715_3_adr),
233 		.adr_d = rt715_3_adr,
234 	},
235 	{}
236 };
237 
238 static const struct snd_soc_acpi_link_adr cml_3_in_1_mono_amp[] = {
239 	{
240 		.mask = BIT(0),
241 		.num_adr = ARRAY_SIZE(rt711_0_adr),
242 		.adr_d = rt711_0_adr,
243 	},
244 	{
245 		.mask = BIT(1),
246 		.num_adr = ARRAY_SIZE(rt1308_1_single_adr),
247 		.adr_d = rt1308_1_single_adr,
248 	},
249 	{
250 		.mask = BIT(3),
251 		.num_adr = ARRAY_SIZE(rt715_3_adr),
252 		.adr_d = rt715_3_adr,
253 	},
254 	{}
255 };
256 
257 static const struct snd_soc_acpi_link_adr cml_3_in_1_sdca[] = {
258 	{
259 		.mask = BIT(0),
260 		.num_adr = ARRAY_SIZE(rt711_sdca_0_adr),
261 		.adr_d = rt711_sdca_0_adr,
262 	},
263 	{
264 		.mask = BIT(1),
265 		.num_adr = ARRAY_SIZE(rt1316_1_group1_adr),
266 		.adr_d = rt1316_1_group1_adr,
267 	},
268 	{
269 		.mask = BIT(2),
270 		.num_adr = ARRAY_SIZE(rt1316_2_group1_adr),
271 		.adr_d = rt1316_2_group1_adr,
272 	},
273 	{
274 		.mask = BIT(3),
275 		.num_adr = ARRAY_SIZE(rt714_3_adr),
276 		.adr_d = rt714_3_adr,
277 	},
278 	{}
279 };
280 
281 struct snd_soc_acpi_mach snd_soc_acpi_intel_cml_sdw_machines[] = {
282 	{
283 		.link_mask = 0xF, /* 4 active links required */
284 		.links = cml_3_in_1_default,
285 		.drv_name = "sof_sdw",
286 		.sof_fw_filename = "sof-cml.ri",
287 		.sof_tplg_filename = "sof-cml-rt711-rt1308-rt715.tplg",
288 	},
289 	{
290 		.link_mask = 0xF, /* 4 active links required */
291 		.links = cml_3_in_1_sdca,
292 		.drv_name = "sof_sdw",
293 		.sof_fw_filename = "sof-cml.ri",
294 		.sof_tplg_filename = "sof-cml-rt711-rt1316-rt714.tplg",
295 	},
296 	{
297 		/*
298 		 * link_mask should be 0xB, but all links are enabled by BIOS.
299 		 * This entry will be selected if there is no rt1308 exposed
300 		 * on link2 since it will fail to match the above entry.
301 		 */
302 		.link_mask = 0xF,
303 		.links = cml_3_in_1_mono_amp,
304 		.drv_name = "sof_sdw",
305 		.sof_fw_filename = "sof-cml.ri",
306 		.sof_tplg_filename = "sof-cml-rt711-rt1308-mono-rt715.tplg",
307 	},
308 	{
309 		.link_mask = 0x2, /* RT700 connected on Link1 */
310 		.links = cml_rvp,
311 		.drv_name = "sof_sdw",
312 		.sof_fw_filename = "sof-cml.ri",
313 		.sof_tplg_filename = "sof-cml-rt700.tplg",
314 	},
315 	{}
316 };
317 EXPORT_SYMBOL_GPL(snd_soc_acpi_intel_cml_sdw_machines);
318