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