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