Linux 6.7-rc7
[linux-modified.git] / sound / soc / amd / acp-config.c
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 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_SOF,
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, "Galileo"),
58                                         DMI_MATCH(DMI_PRODUCT_FAMILY, "Sephiroth"),
59                                 },
60                         },
61                         {}
62                 },
63         },
64         {
65                 .flags = FLAG_AMD_LEGACY,
66                 .device = ACP_PCI_DEV_ID,
67                 .dmi_table = (const struct dmi_system_id []) {
68                         {
69                                 .matches = {
70                                         DMI_EXACT_MATCH(DMI_BOARD_VENDOR, "HUAWEI"),
71                                         DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "KLVL-WXXW"),
72                                         DMI_EXACT_MATCH(DMI_PRODUCT_VERSION, "M1010"),
73                                 },
74                         },
75                         {}
76                 },
77         },
78         {
79                 .flags = FLAG_AMD_LEGACY,
80                 .device = ACP_PCI_DEV_ID,
81                 .dmi_table = (const struct dmi_system_id []) {
82                         {
83                                 .matches = {
84                                         DMI_EXACT_MATCH(DMI_BOARD_VENDOR, "HUAWEI"),
85                                         DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "KLVL-WXX9"),
86                                         DMI_EXACT_MATCH(DMI_PRODUCT_VERSION, "M1010"),
87                                 },
88                         },
89                         {}
90                 },
91         },
92         {
93                 .flags = FLAG_AMD_LEGACY,
94                 .device = ACP_PCI_DEV_ID,
95                 .dmi_table = (const struct dmi_system_id []) {
96                         {
97                                 .matches = {
98                                         DMI_EXACT_MATCH(DMI_BOARD_VENDOR, "HUAWEI"),
99                                         DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "BOM-WXX9"),
100                                         DMI_EXACT_MATCH(DMI_PRODUCT_VERSION, "M1010"),
101                                 },
102                         },
103                         {}
104                 },
105         },
106         {
107                 .flags = FLAG_AMD_LEGACY,
108                 .device = ACP_PCI_DEV_ID,
109                 .dmi_table = (const struct dmi_system_id []) {
110                         {
111                                 .matches = {
112                                         DMI_EXACT_MATCH(DMI_BOARD_VENDOR, "HUAWEI"),
113                                         DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "HVY-WXX9"),
114                                         DMI_EXACT_MATCH(DMI_PRODUCT_VERSION, "M1010"),
115                                 },
116                         },
117                         {}
118                 },
119         },
120         {
121                 .flags = FLAG_AMD_LEGACY,
122                 .device = ACP_PCI_DEV_ID,
123                 .dmi_table = (const struct dmi_system_id []) {
124                         {
125                                 .matches = {
126                                         DMI_EXACT_MATCH(DMI_BOARD_VENDOR, "HUAWEI"),
127                                         DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "HVY-WXX9"),
128                                         DMI_EXACT_MATCH(DMI_PRODUCT_VERSION, "M1020"),
129                                 },
130                         },
131                         {}
132                 },
133         },
134         {
135                 .flags = FLAG_AMD_LEGACY,
136                 .device = ACP_PCI_DEV_ID,
137                 .dmi_table = (const struct dmi_system_id []) {
138                         {
139                                 .matches = {
140                                         DMI_EXACT_MATCH(DMI_BOARD_VENDOR, "HUAWEI"),
141                                         DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "HVY-WXX9"),
142                                         DMI_EXACT_MATCH(DMI_PRODUCT_VERSION, "M1040"),
143                                 },
144                         },
145                         {}
146                 },
147         },
148 };
149
150 int snd_amd_acp_find_config(struct pci_dev *pci)
151 {
152         const struct config_entry *table = config_table;
153         u16 device = pci->device;
154         int i;
155
156         /* Do not enable FLAGS on older platforms with Rev id zero */
157         if (!pci->revision)
158                 return 0;
159
160         for (i = 0; i < ARRAY_SIZE(config_table); i++, table++) {
161                 if (table->device != device)
162                         continue;
163                 if (table->dmi_table && !dmi_check_system(table->dmi_table))
164                         continue;
165                 acp_quirk_data = table->flags;
166                 return table->flags;
167         }
168
169         return 0;
170 }
171 EXPORT_SYMBOL(snd_amd_acp_find_config);
172
173 static struct snd_soc_acpi_codecs amp_rt1019 = {
174         .num_codecs = 1,
175         .codecs = {"10EC1019"}
176 };
177
178 static struct snd_soc_acpi_codecs amp_max = {
179         .num_codecs = 1,
180         .codecs = {"MX98360A"}
181 };
182
183 static struct snd_soc_acpi_codecs amp_max98388 = {
184         .num_codecs = 1,
185         .codecs = {"ADS8388"}
186 };
187
188 struct snd_soc_acpi_mach snd_soc_acpi_amd_sof_machines[] = {
189         {
190                 .id = "10EC5682",
191                 .drv_name = "rt5682-rt1019",
192                 .pdata = (void *)&acp_quirk_data,
193                 .machine_quirk = snd_soc_acpi_codec_list,
194                 .quirk_data = &amp_rt1019,
195                 .fw_filename = "sof-rn.ri",
196                 .sof_tplg_filename = "sof-rn-rt5682-rt1019.tplg",
197         },
198         {
199                 .id = "10EC5682",
200                 .drv_name = "rt5682-max",
201                 .pdata = (void *)&acp_quirk_data,
202                 .machine_quirk = snd_soc_acpi_codec_list,
203                 .quirk_data = &amp_max,
204                 .fw_filename = "sof-rn.ri",
205                 .sof_tplg_filename = "sof-rn-rt5682-max98360.tplg",
206         },
207         {
208                 .id = "RTL5682",
209                 .drv_name = "rt5682s-max",
210                 .pdata = (void *)&acp_quirk_data,
211                 .machine_quirk = snd_soc_acpi_codec_list,
212                 .quirk_data = &amp_max,
213                 .fw_filename = "sof-rn.ri",
214                 .sof_tplg_filename = "sof-rn-rt5682-max98360.tplg",
215         },
216         {
217                 .id = "RTL5682",
218                 .drv_name = "rt5682s-rt1019",
219                 .pdata = (void *)&acp_quirk_data,
220                 .machine_quirk = snd_soc_acpi_codec_list,
221                 .quirk_data = &amp_rt1019,
222                 .fw_filename = "sof-rn.ri",
223                 .sof_tplg_filename = "sof-rn-rt5682-rt1019.tplg",
224         },
225         {
226                 .id = "AMDI1019",
227                 .drv_name = "renoir-dsp",
228                 .pdata = (void *)&acp_quirk_data,
229                 .fw_filename = "sof-rn.ri",
230                 .sof_tplg_filename = "sof-acp.tplg",
231         },
232         {},
233 };
234 EXPORT_SYMBOL(snd_soc_acpi_amd_sof_machines);
235
236 struct snd_soc_acpi_mach snd_soc_acpi_amd_vangogh_sof_machines[] = {
237         {
238                 .id = "NVTN2020",
239                 .drv_name = "nau8821-max",
240                 .pdata = &acp_quirk_data,
241                 .machine_quirk = snd_soc_acpi_codec_list,
242                 .quirk_data = &amp_max98388,
243                 .fw_filename = "sof-vangogh.ri",
244                 .sof_tplg_filename = "sof-vangogh-nau8821-max.tplg",
245         },
246         {},
247 };
248 EXPORT_SYMBOL(snd_soc_acpi_amd_vangogh_sof_machines);
249
250 struct snd_soc_acpi_mach snd_soc_acpi_amd_rmb_sof_machines[] = {
251         {
252                 .id = "AMDI1019",
253                 .drv_name = "rmb-dsp",
254                 .pdata = &acp_quirk_data,
255                 .fw_filename = "sof-rmb.ri",
256                 .sof_tplg_filename = "sof-acp-rmb.tplg",
257         },
258         {
259                 .id = "10508825",
260                 .drv_name = "nau8825-max",
261                 .pdata = &acp_quirk_data,
262                 .machine_quirk = snd_soc_acpi_codec_list,
263                 .quirk_data = &amp_max,
264                 .fw_filename = "sof-rmb.ri",
265                 .sof_tplg_filename = "sof-rmb-nau8825-max98360.tplg",
266         },
267         {
268                 .id = "RTL5682",
269                 .drv_name = "rt5682s-hs-rt1019",
270                 .pdata = &acp_quirk_data,
271                 .machine_quirk = snd_soc_acpi_codec_list,
272                 .quirk_data = &amp_rt1019,
273                 .fw_filename = "sof-rmb.ri",
274                 .sof_tplg_filename = "sof-rmb-rt5682s-rt1019.tplg",
275         },
276         {},
277 };
278 EXPORT_SYMBOL(snd_soc_acpi_amd_rmb_sof_machines);
279
280 struct snd_soc_acpi_mach snd_soc_acpi_amd_acp63_sof_machines[] = {
281         {
282                 .id = "AMDI1019",
283                 .drv_name = "acp63-dsp",
284                 .pdata = &acp_quirk_data,
285                 .fw_filename = "sof-acp_6_3.ri",
286                 .sof_tplg_filename = "sof-acp_6_3.tplg",
287         },
288         {},
289 };
290 EXPORT_SYMBOL(snd_soc_acpi_amd_acp63_sof_machines);
291
292 MODULE_LICENSE("Dual BSD/GPL");