xref: /linux/sound/soc/intel/common/soc-acpi-intel-cml-match.c (revision 02680c23d7b3febe45ea3d4f9818c2b2dc89020a)
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 struct snd_soc_acpi_codecs rt1011_spk_codecs = {
13 	.num_codecs = 1,
14 	.codecs = {"10EC1011"}
15 };
16 
17 static struct snd_soc_acpi_codecs rt1015_spk_codecs = {
18 	.num_codecs = 1,
19 	.codecs = {"10EC1015"}
20 };
21 
22 static struct snd_soc_acpi_codecs max98357a_spk_codecs = {
23 	.num_codecs = 1,
24 	.codecs = {"MX98357A"}
25 };
26 
27 static 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_max98357a",
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_max98357a",
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 };
86 EXPORT_SYMBOL_GPL(snd_soc_acpi_intel_cml_machines);
87 
88 static const struct snd_soc_acpi_endpoint single_endpoint = {
89 	.num = 0,
90 	.aggregated = 0,
91 	.group_position = 0,
92 	.group_id = 0,
93 };
94 
95 static const struct snd_soc_acpi_endpoint spk_l_endpoint = {
96 	.num = 0,
97 	.aggregated = 1,
98 	.group_position = 0,
99 	.group_id = 1,
100 };
101 
102 static const struct snd_soc_acpi_endpoint spk_r_endpoint = {
103 	.num = 0,
104 	.aggregated = 1,
105 	.group_position = 1,
106 	.group_id = 1,
107 };
108 
109 static const struct snd_soc_acpi_adr_device rt700_1_adr[] = {
110 	{
111 		.adr = 0x000110025D070000,
112 		.num_endpoints = 1,
113 		.endpoints = &single_endpoint,
114 		.name_prefix = "rt700"
115 	}
116 };
117 
118 static const struct snd_soc_acpi_link_adr cml_rvp[] = {
119 	{
120 		.mask = BIT(1),
121 		.num_adr = ARRAY_SIZE(rt700_1_adr),
122 		.adr_d = rt700_1_adr,
123 	},
124 	{}
125 };
126 
127 static const struct snd_soc_acpi_adr_device rt711_0_adr[] = {
128 	{
129 		.adr = 0x000020025D071100,
130 		.num_endpoints = 1,
131 		.endpoints = &single_endpoint,
132 		.name_prefix = "rt711"
133 	}
134 };
135 
136 static const struct snd_soc_acpi_adr_device rt1308_1_single_adr[] = {
137 	{
138 		.adr = 0x000120025D130800,
139 		.num_endpoints = 1,
140 		.endpoints = &single_endpoint,
141 		.name_prefix = "rt1308-1"
142 	}
143 };
144 
145 static const struct snd_soc_acpi_adr_device rt1308_1_group1_adr[] = {
146 	{
147 		.adr = 0x000120025D130800,
148 		.num_endpoints = 1,
149 		.endpoints = &spk_l_endpoint,
150 		.name_prefix = "rt1308-1"
151 	}
152 };
153 
154 static const struct snd_soc_acpi_adr_device rt1308_2_group1_adr[] = {
155 	{
156 		.adr = 0x000220025D130800,
157 		.num_endpoints = 1,
158 		.endpoints = &spk_r_endpoint,
159 		.name_prefix = "rt1308-2"
160 	}
161 };
162 
163 static const struct snd_soc_acpi_adr_device rt715_3_adr[] = {
164 	{
165 		.adr = 0x000320025D071500,
166 		.num_endpoints = 1,
167 		.endpoints = &single_endpoint,
168 		.name_prefix = "rt715"
169 	}
170 };
171 
172 static const struct snd_soc_acpi_adr_device rt711_sdca_0_adr[] = {
173 	{
174 		.adr = 0x000030025D071101,
175 		.num_endpoints = 1,
176 		.endpoints = &single_endpoint,
177 		.name_prefix = "rt711"
178 	}
179 };
180 
181 static const struct snd_soc_acpi_adr_device rt1316_1_group1_adr[] = {
182 	{
183 		.adr = 0x000131025D131601, /* unique ID is set for some reason */
184 		.num_endpoints = 1,
185 		.endpoints = &spk_l_endpoint,
186 		.name_prefix = "rt1316-1"
187 	}
188 };
189 
190 static const struct snd_soc_acpi_adr_device rt1316_2_group1_adr[] = {
191 	{
192 		.adr = 0x000230025D131601,
193 		.num_endpoints = 1,
194 		.endpoints = &spk_r_endpoint,
195 		.name_prefix = "rt1316-2"
196 	}
197 };
198 
199 static const struct snd_soc_acpi_adr_device rt714_3_adr[] = {
200 	{
201 		.adr = 0x000330025D071401,
202 		.num_endpoints = 1,
203 		.endpoints = &single_endpoint,
204 		.name_prefix = "rt714"
205 	}
206 };
207 
208 static const struct snd_soc_acpi_link_adr cml_3_in_1_default[] = {
209 	{
210 		.mask = BIT(0),
211 		.num_adr = ARRAY_SIZE(rt711_0_adr),
212 		.adr_d = rt711_0_adr,
213 	},
214 	{
215 		.mask = BIT(1),
216 		.num_adr = ARRAY_SIZE(rt1308_1_group1_adr),
217 		.adr_d = rt1308_1_group1_adr,
218 	},
219 	{
220 		.mask = BIT(2),
221 		.num_adr = ARRAY_SIZE(rt1308_2_group1_adr),
222 		.adr_d = rt1308_2_group1_adr,
223 	},
224 	{
225 		.mask = BIT(3),
226 		.num_adr = ARRAY_SIZE(rt715_3_adr),
227 		.adr_d = rt715_3_adr,
228 	},
229 	{}
230 };
231 
232 static const struct snd_soc_acpi_link_adr cml_3_in_1_mono_amp[] = {
233 	{
234 		.mask = BIT(0),
235 		.num_adr = ARRAY_SIZE(rt711_0_adr),
236 		.adr_d = rt711_0_adr,
237 	},
238 	{
239 		.mask = BIT(1),
240 		.num_adr = ARRAY_SIZE(rt1308_1_single_adr),
241 		.adr_d = rt1308_1_single_adr,
242 	},
243 	{
244 		.mask = BIT(3),
245 		.num_adr = ARRAY_SIZE(rt715_3_adr),
246 		.adr_d = rt715_3_adr,
247 	},
248 	{}
249 };
250 
251 static const struct snd_soc_acpi_link_adr cml_3_in_1_sdca[] = {
252 	{
253 		.mask = BIT(0),
254 		.num_adr = ARRAY_SIZE(rt711_sdca_0_adr),
255 		.adr_d = rt711_sdca_0_adr,
256 	},
257 	{
258 		.mask = BIT(1),
259 		.num_adr = ARRAY_SIZE(rt1316_1_group1_adr),
260 		.adr_d = rt1316_1_group1_adr,
261 	},
262 	{
263 		.mask = BIT(2),
264 		.num_adr = ARRAY_SIZE(rt1316_2_group1_adr),
265 		.adr_d = rt1316_2_group1_adr,
266 	},
267 	{
268 		.mask = BIT(3),
269 		.num_adr = ARRAY_SIZE(rt714_3_adr),
270 		.adr_d = rt714_3_adr,
271 	},
272 	{}
273 };
274 
275 struct snd_soc_acpi_mach snd_soc_acpi_intel_cml_sdw_machines[] = {
276 	{
277 		.link_mask = 0xF, /* 4 active links required */
278 		.links = cml_3_in_1_default,
279 		.drv_name = "sof_sdw",
280 		.sof_fw_filename = "sof-cml.ri",
281 		.sof_tplg_filename = "sof-cml-rt711-rt1308-rt715.tplg",
282 	},
283 	{
284 		.link_mask = 0xF, /* 4 active links required */
285 		.links = cml_3_in_1_sdca,
286 		.drv_name = "sof_sdw",
287 		.sof_fw_filename = "sof-cml.ri",
288 		.sof_tplg_filename = "sof-cml-rt711-rt1316-rt714.tplg",
289 	},
290 	{
291 		/*
292 		 * link_mask should be 0xB, but all links are enabled by BIOS.
293 		 * This entry will be selected if there is no rt1308 exposed
294 		 * on link2 since it will fail to match the above entry.
295 		 */
296 		.link_mask = 0xF,
297 		.links = cml_3_in_1_mono_amp,
298 		.drv_name = "sof_sdw",
299 		.sof_fw_filename = "sof-cml.ri",
300 		.sof_tplg_filename = "sof-cml-rt711-rt1308-mono-rt715.tplg",
301 	},
302 	{
303 		.link_mask = 0x2, /* RT700 connected on Link1 */
304 		.links = cml_rvp,
305 		.drv_name = "sof_sdw",
306 		.sof_fw_filename = "sof-cml.ri",
307 		.sof_tplg_filename = "sof-cml-rt700.tplg",
308 	},
309 	{}
310 };
311 EXPORT_SYMBOL_GPL(snd_soc_acpi_intel_cml_sdw_machines);
312