xref: /linux/sound/soc/amd/acp-config.c (revision c3ab23a10771bbe06300e5374efa809789c65455)
1 // SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause)
2 //
3 // This file is provided under a dual BSD/GPLv2 license. When using or
4 // redistributing this file, you may do so under either license.
5 //
6 // Copyright(c) 2021, 2023 Advanced Micro Devices, Inc.
7 //
8 // Authors: Ajit Kumar Pandey <AjitKumar.Pandey@amd.com>
9 //
10 
11 /* ACP machine configuration module */
12 
13 #include <linux/acpi.h>
14 #include <linux/bits.h>
15 #include <linux/dmi.h>
16 #include <linux/module.h>
17 #include <linux/pci.h>
18 
19 #include "../sof/amd/acp.h"
20 #include "mach-config.h"
21 
22 static int acp_quirk_data;
23 
24 static const struct config_entry config_table[] = {
25 	{
26 		.flags = FLAG_AMD_SOF,
27 		.device = ACP_PCI_DEV_ID,
28 		.dmi_table = (const struct dmi_system_id []) {
29 			{
30 				.matches = {
31 					DMI_MATCH(DMI_SYS_VENDOR, "AMD"),
32 					DMI_MATCH(DMI_PRODUCT_NAME, "Majolica-CZN"),
33 				},
34 			},
35 			{}
36 		},
37 	},
38 	{
39 		.flags = FLAG_AMD_SOF,
40 		.device = ACP_PCI_DEV_ID,
41 		.dmi_table = (const struct dmi_system_id []) {
42 			{
43 				.matches = {
44 					DMI_MATCH(DMI_SYS_VENDOR, "Google"),
45 				},
46 			},
47 			{}
48 		},
49 	},
50 	{
51 		.flags = FLAG_AMD_LEGACY,
52 		.device = ACP_PCI_DEV_ID,
53 		.dmi_table = (const struct dmi_system_id []) {
54 			{
55 				.matches = {
56 					DMI_MATCH(DMI_SYS_VENDOR, "Valve"),
57 					DMI_MATCH(DMI_PRODUCT_NAME, "Jupiter"),
58 				},
59 			},
60 			{}
61 		},
62 	},
63 	{
64 		.flags = FLAG_AMD_SOF,
65 		.device = ACP_PCI_DEV_ID,
66 		.dmi_table = (const struct dmi_system_id []) {
67 			{
68 				.matches = {
69 					DMI_MATCH(DMI_SYS_VENDOR, "Valve"),
70 					DMI_MATCH(DMI_PRODUCT_NAME, "Galileo"),
71 					DMI_MATCH(DMI_PRODUCT_FAMILY, "Sephiroth"),
72 				},
73 			},
74 			{}
75 		},
76 	},
77 	{
78 		.flags = FLAG_AMD_LEGACY,
79 		.device = ACP_PCI_DEV_ID,
80 		.dmi_table = (const struct dmi_system_id []) {
81 			{
82 				.matches = {
83 					DMI_EXACT_MATCH(DMI_BOARD_VENDOR, "HUAWEI"),
84 					DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "KLVL-WXXW"),
85 					DMI_EXACT_MATCH(DMI_PRODUCT_VERSION, "M1010"),
86 				},
87 			},
88 			{}
89 		},
90 	},
91 	{
92 		.flags = FLAG_AMD_LEGACY,
93 		.device = ACP_PCI_DEV_ID,
94 		.dmi_table = (const struct dmi_system_id []) {
95 			{
96 				.matches = {
97 					DMI_EXACT_MATCH(DMI_BOARD_VENDOR, "HUAWEI"),
98 					DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "KLVL-WXX9"),
99 					DMI_EXACT_MATCH(DMI_PRODUCT_VERSION, "M1010"),
100 				},
101 			},
102 			{}
103 		},
104 	},
105 	{
106 		.flags = FLAG_AMD_LEGACY,
107 		.device = ACP_PCI_DEV_ID,
108 		.dmi_table = (const struct dmi_system_id []) {
109 			{
110 				.matches = {
111 					DMI_EXACT_MATCH(DMI_BOARD_VENDOR, "HUAWEI"),
112 					DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "BOM-WXX9"),
113 					DMI_EXACT_MATCH(DMI_PRODUCT_VERSION, "M1010"),
114 				},
115 			},
116 			{}
117 		},
118 	},
119 	{
120 		.flags = FLAG_AMD_LEGACY,
121 		.device = ACP_PCI_DEV_ID,
122 		.dmi_table = (const struct dmi_system_id []) {
123 			{
124 				.matches = {
125 					DMI_EXACT_MATCH(DMI_BOARD_VENDOR, "HUAWEI"),
126 					DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "HVY-WXX9"),
127 					DMI_EXACT_MATCH(DMI_PRODUCT_VERSION, "M1020"),
128 				},
129 			},
130 			{}
131 		},
132 	},
133 	{
134 		.flags = FLAG_AMD_LEGACY,
135 		.device = ACP_PCI_DEV_ID,
136 		.dmi_table = (const struct dmi_system_id []) {
137 			{
138 				.matches = {
139 					DMI_EXACT_MATCH(DMI_BOARD_VENDOR, "HUAWEI"),
140 					DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "HVY-WXX9"),
141 					DMI_EXACT_MATCH(DMI_PRODUCT_VERSION, "M1040"),
142 				},
143 			},
144 			{}
145 		},
146 	},
147 };
148 
149 int snd_amd_acp_find_config(struct pci_dev *pci)
150 {
151 	const struct config_entry *table = config_table;
152 	u16 device = pci->device;
153 	int i;
154 
155 	/* Do not enable FLAGS on older platforms with Rev id zero */
156 	if (!pci->revision)
157 		return 0;
158 
159 	for (i = 0; i < ARRAY_SIZE(config_table); i++, table++) {
160 		if (table->device != device)
161 			continue;
162 		if (table->dmi_table && !dmi_check_system(table->dmi_table))
163 			continue;
164 		acp_quirk_data = table->flags;
165 		return table->flags;
166 	}
167 
168 	return 0;
169 }
170 EXPORT_SYMBOL(snd_amd_acp_find_config);
171 
172 static struct snd_soc_acpi_codecs amp_rt1019 = {
173 	.num_codecs = 1,
174 	.codecs = {"10EC1019"}
175 };
176 
177 static struct snd_soc_acpi_codecs amp_max = {
178 	.num_codecs = 1,
179 	.codecs = {"MX98360A"}
180 };
181 
182 static struct snd_soc_acpi_codecs amp_max98388 = {
183 	.num_codecs = 1,
184 	.codecs = {"ADS8388"}
185 };
186 
187 struct snd_soc_acpi_mach snd_soc_acpi_amd_sof_machines[] = {
188 	{
189 		.id = "10EC5682",
190 		.drv_name = "rt5682-rt1019",
191 		.pdata = (void *)&acp_quirk_data,
192 		.machine_quirk = snd_soc_acpi_codec_list,
193 		.quirk_data = &amp_rt1019,
194 		.fw_filename = "sof-rn.ri",
195 		.sof_tplg_filename = "sof-rn-rt5682-rt1019.tplg",
196 	},
197 	{
198 		.id = "10EC5682",
199 		.drv_name = "rt5682-max",
200 		.pdata = (void *)&acp_quirk_data,
201 		.machine_quirk = snd_soc_acpi_codec_list,
202 		.quirk_data = &amp_max,
203 		.fw_filename = "sof-rn.ri",
204 		.sof_tplg_filename = "sof-rn-rt5682-max98360.tplg",
205 	},
206 	{
207 		.id = "RTL5682",
208 		.drv_name = "rt5682s-max",
209 		.pdata = (void *)&acp_quirk_data,
210 		.machine_quirk = snd_soc_acpi_codec_list,
211 		.quirk_data = &amp_max,
212 		.fw_filename = "sof-rn.ri",
213 		.sof_tplg_filename = "sof-rn-rt5682-max98360.tplg",
214 	},
215 	{
216 		.id = "RTL5682",
217 		.drv_name = "rt5682s-rt1019",
218 		.pdata = (void *)&acp_quirk_data,
219 		.machine_quirk = snd_soc_acpi_codec_list,
220 		.quirk_data = &amp_rt1019,
221 		.fw_filename = "sof-rn.ri",
222 		.sof_tplg_filename = "sof-rn-rt5682-rt1019.tplg",
223 	},
224 	{
225 		.id = "AMDI1019",
226 		.drv_name = "renoir-dsp",
227 		.pdata = (void *)&acp_quirk_data,
228 		.fw_filename = "sof-rn.ri",
229 		.sof_tplg_filename = "sof-acp.tplg",
230 	},
231 	{},
232 };
233 EXPORT_SYMBOL(snd_soc_acpi_amd_sof_machines);
234 
235 struct snd_soc_acpi_mach snd_soc_acpi_amd_vangogh_sof_machines[] = {
236 	{
237 		.id = "NVTN2020",
238 		.drv_name = "nau8821-max",
239 		.pdata = &acp_quirk_data,
240 		.machine_quirk = snd_soc_acpi_codec_list,
241 		.quirk_data = &amp_max98388,
242 		.fw_filename = "sof-vangogh.ri",
243 		.sof_tplg_filename = "sof-vangogh-nau8821-max.tplg",
244 	},
245 	{},
246 };
247 EXPORT_SYMBOL(snd_soc_acpi_amd_vangogh_sof_machines);
248 
249 struct snd_soc_acpi_mach snd_soc_acpi_amd_rmb_sof_machines[] = {
250 	{
251 		.id = "AMDI1019",
252 		.drv_name = "rmb-dsp",
253 		.pdata = &acp_quirk_data,
254 		.fw_filename = "sof-rmb.ri",
255 		.sof_tplg_filename = "sof-acp-rmb.tplg",
256 	},
257 	{
258 		.id = "10508825",
259 		.drv_name = "nau8825-max",
260 		.pdata = &acp_quirk_data,
261 		.machine_quirk = snd_soc_acpi_codec_list,
262 		.quirk_data = &amp_max,
263 		.fw_filename = "sof-rmb.ri",
264 		.sof_tplg_filename = "sof-rmb-nau8825-max98360.tplg",
265 	},
266 	{
267 		.id = "RTL5682",
268 		.drv_name = "rt5682s-hs-rt1019",
269 		.pdata = &acp_quirk_data,
270 		.machine_quirk = snd_soc_acpi_codec_list,
271 		.quirk_data = &amp_rt1019,
272 		.fw_filename = "sof-rmb.ri",
273 		.sof_tplg_filename = "sof-rmb-rt5682s-rt1019.tplg",
274 	},
275 	{},
276 };
277 EXPORT_SYMBOL(snd_soc_acpi_amd_rmb_sof_machines);
278 
279 struct snd_soc_acpi_mach snd_soc_acpi_amd_acp63_sof_machines[] = {
280 	{
281 		.id = "AMDI1019",
282 		.drv_name = "acp63-dsp",
283 		.pdata = &acp_quirk_data,
284 		.fw_filename = "sof-acp_6_3.ri",
285 		.sof_tplg_filename = "sof-acp_6_3.tplg",
286 	},
287 	{},
288 };
289 EXPORT_SYMBOL(snd_soc_acpi_amd_acp63_sof_machines);
290 
291 MODULE_LICENSE("Dual BSD/GPL");
292