1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3  * soc-apci-intel-rpl-match.c - tables and support for RPL ACPI enumeration.
4  *
5  * Copyright (c) 2022 Intel Corporation.
6  */
7 
8 #include <sound/soc-acpi.h>
9 #include <sound/soc-acpi-intel-match.h>
10 
11 static const struct snd_soc_acpi_endpoint single_endpoint = {
12 	.num = 0,
13 	.aggregated = 0,
14 	.group_position = 0,
15 	.group_id = 0,
16 };
17 
18 static const struct snd_soc_acpi_endpoint spk_l_endpoint = {
19 	.num = 0,
20 	.aggregated = 1,
21 	.group_position = 0,
22 	.group_id = 1,
23 };
24 
25 static const struct snd_soc_acpi_endpoint spk_r_endpoint = {
26 	.num = 0,
27 	.aggregated = 1,
28 	.group_position = 1,
29 	.group_id = 1,
30 };
31 
32 static const struct snd_soc_acpi_adr_device rt711_0_adr[] = {
33 	{
34 		.adr = 0x000020025D071100ull,
35 		.num_endpoints = 1,
36 		.endpoints = &single_endpoint,
37 		.name_prefix = "rt711"
38 	}
39 };
40 
41 static const struct snd_soc_acpi_link_adr rpl_rvp[] = {
42 	{
43 		.mask = BIT(0),
44 		.num_adr = ARRAY_SIZE(rt711_0_adr),
45 		.adr_d = rt711_0_adr,
46 	},
47 	{}
48 };
49 
50 static const struct snd_soc_acpi_adr_device rt711_sdca_0_adr[] = {
51 	{
52 		.adr = 0x000030025D071101ull,
53 		.num_endpoints = 1,
54 		.endpoints = &single_endpoint,
55 		.name_prefix = "rt711"
56 	}
57 };
58 
59 static const struct snd_soc_acpi_adr_device rt711_sdca_2_adr[] = {
60 	{
61 		.adr = 0x000230025D071101ull,
62 		.num_endpoints = 1,
63 		.endpoints = &single_endpoint,
64 		.name_prefix = "rt711"
65 	}
66 };
67 
68 static const struct snd_soc_acpi_adr_device rt1316_1_group1_adr[] = {
69 	{
70 		.adr = 0x000131025D131601ull, /* unique ID is set for some reason */
71 		.num_endpoints = 1,
72 		.endpoints = &spk_l_endpoint,
73 		.name_prefix = "rt1316-1"
74 	}
75 };
76 
77 static const struct snd_soc_acpi_adr_device rt1316_2_group1_adr[] = {
78 	{
79 		.adr = 0x000230025D131601ull,
80 		.num_endpoints = 1,
81 		.endpoints = &spk_r_endpoint,
82 		.name_prefix = "rt1316-2"
83 	}
84 };
85 
86 static const struct snd_soc_acpi_adr_device rt1316_3_group1_adr[] = {
87 	{
88 		.adr = 0x000330025D131601ull,
89 		.num_endpoints = 1,
90 		.endpoints = &spk_r_endpoint,
91 		.name_prefix = "rt1316-2"
92 	}
93 };
94 
95 static const struct snd_soc_acpi_adr_device rt1316_0_group2_adr[] = {
96 	{
97 		.adr = 0x000030025D131601ull,
98 		.num_endpoints = 1,
99 		.endpoints = &spk_l_endpoint,
100 		.name_prefix = "rt1316-1"
101 	}
102 };
103 
104 static const struct snd_soc_acpi_adr_device rt1316_1_group2_adr[] = {
105 	{
106 		.adr = 0x000131025D131601ull,
107 		.num_endpoints = 1,
108 		.endpoints = &spk_r_endpoint,
109 		.name_prefix = "rt1316-2"
110 	}
111 };
112 
113 static const struct snd_soc_acpi_adr_device rt1318_1_group1_adr[] = {
114 	{
115 		.adr = 0x000132025D131801ull,
116 		.num_endpoints = 1,
117 		.endpoints = &spk_l_endpoint,
118 		.name_prefix = "rt1318-1"
119 	}
120 };
121 
122 static const struct snd_soc_acpi_adr_device rt1318_2_group1_adr[] = {
123 	{
124 		.adr = 0x000230025D131801ull,
125 		.num_endpoints = 1,
126 		.endpoints = &spk_r_endpoint,
127 		.name_prefix = "rt1318-2"
128 	}
129 };
130 
131 static const struct snd_soc_acpi_adr_device rt714_0_adr[] = {
132 	{
133 		.adr = 0x000030025D071401ull,
134 		.num_endpoints = 1,
135 		.endpoints = &single_endpoint,
136 		.name_prefix = "rt714"
137 	}
138 };
139 
140 static const struct snd_soc_acpi_adr_device rt714_2_adr[] = {
141 	{
142 		.adr = 0x000230025D071401ull,
143 		.num_endpoints = 1,
144 		.endpoints = &single_endpoint,
145 		.name_prefix = "rt714"
146 	}
147 };
148 
149 static const struct snd_soc_acpi_adr_device rt714_3_adr[] = {
150 	{
151 		.adr = 0x000330025D071401ull,
152 		.num_endpoints = 1,
153 		.endpoints = &single_endpoint,
154 		.name_prefix = "rt714"
155 	}
156 };
157 
158 static const struct snd_soc_acpi_link_adr rpl_sdca_3_in_1[] = {
159 	{
160 		.mask = BIT(0),
161 		.num_adr = ARRAY_SIZE(rt711_sdca_0_adr),
162 		.adr_d = rt711_sdca_0_adr,
163 	},
164 	{
165 		.mask = BIT(1),
166 		.num_adr = ARRAY_SIZE(rt1316_1_group1_adr),
167 		.adr_d = rt1316_1_group1_adr,
168 	},
169 	{
170 		.mask = BIT(2),
171 		.num_adr = ARRAY_SIZE(rt714_2_adr),
172 		.adr_d = rt714_2_adr,
173 	},
174 	{
175 		.mask = BIT(3),
176 		.num_adr = ARRAY_SIZE(rt1316_3_group1_adr),
177 		.adr_d = rt1316_3_group1_adr,
178 	},
179 	{}
180 };
181 
182 static const struct snd_soc_acpi_link_adr rpl_sdw_rt711_link2_rt1316_link01_rt714_link3[] = {
183 	{
184 		.mask = BIT(2),
185 		.num_adr = ARRAY_SIZE(rt711_sdca_2_adr),
186 		.adr_d = rt711_sdca_2_adr,
187 	},
188 	{
189 		.mask = BIT(0),
190 		.num_adr = ARRAY_SIZE(rt1316_0_group2_adr),
191 		.adr_d = rt1316_0_group2_adr,
192 	},
193 	{
194 		.mask = BIT(1),
195 		.num_adr = ARRAY_SIZE(rt1316_1_group2_adr),
196 		.adr_d = rt1316_1_group2_adr,
197 	},
198 	{
199 		.mask = BIT(3),
200 		.num_adr = ARRAY_SIZE(rt714_3_adr),
201 		.adr_d = rt714_3_adr,
202 	},
203 	{}
204 };
205 
206 static const struct snd_soc_acpi_link_adr rpl_sdw_rt711_link0_rt1318_link12_rt714_link3[] = {
207 	{
208 		.mask = BIT(0),
209 		.num_adr = ARRAY_SIZE(rt711_sdca_0_adr),
210 		.adr_d = rt711_sdca_0_adr,
211 	},
212 	{
213 		.mask = BIT(1),
214 		.num_adr = ARRAY_SIZE(rt1318_1_group1_adr),
215 		.adr_d = rt1318_1_group1_adr,
216 	},
217 	{
218 		.mask = BIT(2),
219 		.num_adr = ARRAY_SIZE(rt1318_2_group1_adr),
220 		.adr_d = rt1318_2_group1_adr,
221 	},
222 	{
223 		.mask = BIT(3),
224 		.num_adr = ARRAY_SIZE(rt714_3_adr),
225 		.adr_d = rt714_3_adr,
226 	},
227 	{}
228 };
229 
230 static const struct snd_soc_acpi_link_adr rpl_sdw_rt1316_link12_rt714_link0[] = {
231 	{
232 		.mask = BIT(1),
233 		.num_adr = ARRAY_SIZE(rt1316_1_group1_adr),
234 		.adr_d = rt1316_1_group1_adr,
235 	},
236 	{
237 		.mask = BIT(2),
238 		.num_adr = ARRAY_SIZE(rt1316_2_group1_adr),
239 		.adr_d = rt1316_2_group1_adr,
240 	},
241 	{
242 		.mask = BIT(0),
243 		.num_adr = ARRAY_SIZE(rt714_0_adr),
244 		.adr_d = rt714_0_adr,
245 	},
246 	{}
247 };
248 
249 struct snd_soc_acpi_mach snd_soc_acpi_intel_rpl_machines[] = {
250 	{},
251 };
252 EXPORT_SYMBOL_GPL(snd_soc_acpi_intel_rpl_machines);
253 
254 /* this table is used when there is no I2S codec present */
255 struct snd_soc_acpi_mach snd_soc_acpi_intel_rpl_sdw_machines[] = {
256 	{
257 		.link_mask = 0xF, /* 4 active links required */
258 		.links = rpl_sdca_3_in_1,
259 		.drv_name = "sof_sdw",
260 		.sof_tplg_filename = "sof-rpl-rt711-l0-rt1316-l13-rt714-l2.tplg",
261 	},
262 	{
263 		.link_mask = 0xF, /* 4 active links required */
264 		.links = rpl_sdw_rt711_link2_rt1316_link01_rt714_link3,
265 		.drv_name = "sof_sdw",
266 		.sof_tplg_filename = "sof-rpl-rt711-l2-rt1316-l01-rt714-l3.tplg",
267 	},
268 	{
269 		.link_mask = 0xF, /* 4 active links required */
270 		.links = rpl_sdw_rt711_link0_rt1318_link12_rt714_link3,
271 		.drv_name = "sof_sdw",
272 		.sof_tplg_filename = "sof-rpl-rt711-l0-rt1318-l12-rt714-l3.tplg",
273 	},
274 	{
275 		.link_mask = 0x7, /* rt714 on link0 & two rt1316s on link1 and link2 */
276 		.links = rpl_sdw_rt1316_link12_rt714_link0,
277 		.drv_name = "sof_sdw",
278 		.sof_tplg_filename = "sof-rpl-rt1316-l12-rt714-l0.tplg",
279 	},
280 	{
281 		.link_mask = 0x1, /* link0 required */
282 		.links = rpl_rvp,
283 		.drv_name = "sof_sdw",
284 		.sof_tplg_filename = "sof-rpl-rt711.tplg",
285 	},
286 	{},
287 };
288 EXPORT_SYMBOL_GPL(snd_soc_acpi_intel_rpl_sdw_machines);
289