xref: /openbmc/linux/sound/soc/intel/common/soc-acpi-intel-mtl-match.c (revision 2e1dbea1f8a3584399ff15b1f1773dbbb1f0d10f)
1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3  * soc-acpi-intel-mtl-match.c - tables and support for MTL ACPI enumeration.
4  *
5  * Copyright (c) 2022, Intel Corporation.
6  *
7  */
8 
9 #include <sound/soc-acpi.h>
10 #include <sound/soc-acpi-intel-match.h>
11 #include "soc-acpi-intel-sdw-mockup-match.h"
12 
13 static const struct snd_soc_acpi_codecs mtl_max98357a_amp = {
14 	.num_codecs = 1,
15 	.codecs = {"MX98357A"}
16 };
17 
18 static const struct snd_soc_acpi_codecs mtl_max98360a_amp = {
19 	.num_codecs = 1,
20 	.codecs = {"MX98360A"}
21 };
22 
23 static const struct snd_soc_acpi_codecs mtl_rt5682_rt5682s_hp = {
24 	.num_codecs = 2,
25 	.codecs = {"10EC5682", "RTL5682"},
26 };
27 
28 struct snd_soc_acpi_mach snd_soc_acpi_intel_mtl_machines[] = {
29 	{
30 		.comp_ids = &mtl_rt5682_rt5682s_hp,
31 		.drv_name = "mtl_mx98357_rt5682",
32 		.machine_quirk = snd_soc_acpi_codec_list,
33 		.quirk_data = &mtl_max98357a_amp,
34 		.sof_tplg_filename = "sof-mtl-max98357a-rt5682.tplg",
35 	},
36 	{
37 		.comp_ids = &mtl_rt5682_rt5682s_hp,
38 		.drv_name = "mtl_mx98360_rt5682",
39 		.machine_quirk = snd_soc_acpi_codec_list,
40 		.quirk_data = &mtl_max98360a_amp,
41 		.sof_tplg_filename = "sof-mtl-max98360a-rt5682.tplg",
42 	},
43 	{},
44 };
45 EXPORT_SYMBOL_GPL(snd_soc_acpi_intel_mtl_machines);
46 
47 static const struct snd_soc_acpi_endpoint single_endpoint = {
48 	.num = 0,
49 	.aggregated = 0,
50 	.group_position = 0,
51 	.group_id = 0,
52 };
53 
54 static const struct snd_soc_acpi_endpoint spk_l_endpoint = {
55 	.num = 0,
56 	.aggregated = 1,
57 	.group_position = 0,
58 	.group_id = 1,
59 };
60 
61 static const struct snd_soc_acpi_endpoint spk_r_endpoint = {
62 	.num = 0,
63 	.aggregated = 1,
64 	.group_position = 1,
65 	.group_id = 1,
66 };
67 
68 static const struct snd_soc_acpi_endpoint rt712_endpoints[] = {
69 	{
70 		.num = 0,
71 		.aggregated = 0,
72 		.group_position = 0,
73 		.group_id = 0,
74 	},
75 	{
76 		.num = 1,
77 		.aggregated = 0,
78 		.group_position = 0,
79 		.group_id = 0,
80 	},
81 };
82 
83 static const struct snd_soc_acpi_adr_device rt711_sdca_0_adr[] = {
84 	{
85 		.adr = 0x000030025D071101ull,
86 		.num_endpoints = 1,
87 		.endpoints = &single_endpoint,
88 		.name_prefix = "rt711"
89 	}
90 };
91 
92 static const struct snd_soc_acpi_adr_device rt712_0_single_adr[] = {
93 	{
94 		.adr = 0x000030025D071201ull,
95 		.num_endpoints = ARRAY_SIZE(rt712_endpoints),
96 		.endpoints = rt712_endpoints,
97 		.name_prefix = "rt712"
98 	}
99 };
100 
101 static const struct snd_soc_acpi_adr_device rt1712_3_single_adr[] = {
102 	{
103 		.adr = 0x000330025D171201ull,
104 		.num_endpoints = 1,
105 		.endpoints = &single_endpoint,
106 		.name_prefix = "rt712-dmic"
107 	}
108 };
109 
110 static const struct snd_soc_acpi_adr_device mx8373_0_adr[] = {
111 	{
112 		.adr = 0x000023019F837300ull,
113 		.num_endpoints = 1,
114 		.endpoints = &spk_l_endpoint,
115 		.name_prefix = "Left"
116 	},
117 	{
118 		.adr = 0x000027019F837300ull,
119 		.num_endpoints = 1,
120 		.endpoints = &spk_r_endpoint,
121 		.name_prefix = "Right"
122 	}
123 };
124 
125 static const struct snd_soc_acpi_adr_device rt5682_2_adr[] = {
126 	{
127 		.adr = 0x000221025D568200ull,
128 		.num_endpoints = 1,
129 		.endpoints = &single_endpoint,
130 		.name_prefix = "rt5682"
131 	}
132 };
133 
134 static const struct snd_soc_acpi_adr_device rt1316_2_group1_adr[] = {
135 	{
136 		.adr = 0x000230025D131601ull,
137 		.num_endpoints = 1,
138 		.endpoints = &spk_l_endpoint,
139 		.name_prefix = "rt1316-1"
140 	}
141 };
142 
143 static const struct snd_soc_acpi_adr_device rt1316_3_group1_adr[] = {
144 	{
145 		.adr = 0x000331025D131601ull,
146 		.num_endpoints = 1,
147 		.endpoints = &spk_r_endpoint,
148 		.name_prefix = "rt1316-2"
149 	}
150 };
151 
152 static const struct snd_soc_acpi_adr_device rt714_1_adr[] = {
153 	{
154 		.adr = 0x000130025D071401ull,
155 		.num_endpoints = 1,
156 		.endpoints = &single_endpoint,
157 		.name_prefix = "rt714"
158 	}
159 };
160 
161 static const struct snd_soc_acpi_link_adr mtl_712_only[] = {
162 	{
163 		.mask = BIT(0),
164 		.num_adr = ARRAY_SIZE(rt712_0_single_adr),
165 		.adr_d = rt712_0_single_adr,
166 	},
167 	{
168 		.mask = BIT(3),
169 		.num_adr = ARRAY_SIZE(rt1712_3_single_adr),
170 		.adr_d = rt1712_3_single_adr,
171 	},
172 	{}
173 };
174 
175 static const struct snd_soc_acpi_link_adr rt5682_link2_max98373_link0[] = {
176 	/* Expected order: jack -> amp */
177 	{
178 		.mask = BIT(2),
179 		.num_adr = ARRAY_SIZE(rt5682_2_adr),
180 		.adr_d = rt5682_2_adr,
181 	},
182 	{
183 		.mask = BIT(0),
184 		.num_adr = ARRAY_SIZE(mx8373_0_adr),
185 		.adr_d = mx8373_0_adr,
186 	},
187 	{}
188 };
189 
190 static const struct snd_soc_acpi_link_adr mtl_rvp[] = {
191 	{
192 		.mask = BIT(0),
193 		.num_adr = ARRAY_SIZE(rt711_sdca_0_adr),
194 		.adr_d = rt711_sdca_0_adr,
195 	},
196 	{}
197 };
198 
199 static const struct snd_soc_acpi_link_adr mtl_3_in_1_sdca[] = {
200 	{
201 		.mask = BIT(0),
202 		.num_adr = ARRAY_SIZE(rt711_sdca_0_adr),
203 		.adr_d = rt711_sdca_0_adr,
204 	},
205 	{
206 		.mask = BIT(2),
207 		.num_adr = ARRAY_SIZE(rt1316_2_group1_adr),
208 		.adr_d = rt1316_2_group1_adr,
209 	},
210 	{
211 		.mask = BIT(3),
212 		.num_adr = ARRAY_SIZE(rt1316_3_group1_adr),
213 		.adr_d = rt1316_3_group1_adr,
214 	},
215 	{
216 		.mask = BIT(1),
217 		.num_adr = ARRAY_SIZE(rt714_1_adr),
218 		.adr_d = rt714_1_adr,
219 	},
220 	{}
221 };
222 
223 static const struct snd_soc_acpi_adr_device mx8363_2_adr[] = {
224 	{
225 		.adr = 0x000230019F836300ull,
226 		.num_endpoints = 1,
227 		.endpoints = &spk_l_endpoint,
228 		.name_prefix = "Left"
229 	},
230 	{
231 		.adr = 0x000231019F836300ull,
232 		.num_endpoints = 1,
233 		.endpoints = &spk_r_endpoint,
234 		.name_prefix = "Right"
235 	}
236 };
237 
238 static const struct snd_soc_acpi_adr_device cs42l42_0_adr[] = {
239 	{
240 		.adr = 0x00001001FA424200ull,
241 		.num_endpoints = 1,
242 		.endpoints = &single_endpoint,
243 		.name_prefix = "cs42l42"
244 	}
245 };
246 
247 static const struct snd_soc_acpi_link_adr cs42l42_link0_max98363_link2[] = {
248 	/* Expected order: jack -> amp */
249 	{
250 		.mask = BIT(0),
251 		.num_adr = ARRAY_SIZE(cs42l42_0_adr),
252 		.adr_d = cs42l42_0_adr,
253 	},
254 	{
255 		.mask = BIT(2),
256 		.num_adr = ARRAY_SIZE(mx8363_2_adr),
257 		.adr_d = mx8363_2_adr,
258 	},
259 	{}
260 };
261 
262 /* this table is used when there is no I2S codec present */
263 struct snd_soc_acpi_mach snd_soc_acpi_intel_mtl_sdw_machines[] = {
264 	/* mockup tests need to be first */
265 	{
266 		.link_mask = GENMASK(3, 0),
267 		.links = sdw_mockup_headset_2amps_mic,
268 		.drv_name = "sof_sdw",
269 		.sof_tplg_filename = "sof-mtl-rt711-rt1308-rt715.tplg",
270 	},
271 	{
272 		.link_mask = BIT(0) | BIT(1) | BIT(3),
273 		.links = sdw_mockup_headset_1amp_mic,
274 		.drv_name = "sof_sdw",
275 		.sof_tplg_filename = "sof-mtl-rt711-rt1308-mono-rt715.tplg",
276 	},
277 	{
278 		.link_mask = GENMASK(2, 0),
279 		.links = sdw_mockup_mic_headset_1amp,
280 		.drv_name = "sof_sdw",
281 		.sof_tplg_filename = "sof-mtl-rt715-rt711-rt1308-mono.tplg",
282 	},
283 	{
284 		.link_mask = BIT(3) | BIT(0),
285 		.links = mtl_712_only,
286 		.drv_name = "sof_sdw",
287 		.sof_tplg_filename = "sof-mtl-rt712-l0-rt1712-l3.tplg",
288 	},
289 	{
290 		.link_mask = GENMASK(3, 0),
291 		.links = mtl_3_in_1_sdca,
292 		.drv_name = "sof_sdw",
293 		.sof_tplg_filename = "sof-mtl-rt711-l0-rt1316-l23-rt714-l1.tplg",
294 	},
295 	{
296 		.link_mask = BIT(0),
297 		.links = mtl_rvp,
298 		.drv_name = "sof_sdw",
299 		.sof_tplg_filename = "sof-mtl-rt711.tplg",
300 	},
301 	{
302 		.link_mask = BIT(0) | BIT(2),
303 		.links = rt5682_link2_max98373_link0,
304 		.drv_name = "sof_sdw",
305 		.sof_tplg_filename = "sof-mtl-sdw-rt5682-l2-max98373-l0.tplg",
306 	},
307 	{
308 		.link_mask = BIT(0) | BIT(2),
309 		.links = cs42l42_link0_max98363_link2,
310 		.drv_name = "sof_sdw",
311 		.sof_tplg_filename = "sof-mtl-sdw-cs42l42-l0-max98363-l2.tplg",
312 	},
313 	{},
314 };
315 EXPORT_SYMBOL_GPL(snd_soc_acpi_intel_mtl_sdw_machines);
316