1 // SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause)
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.
6 // Copyright(c) 2021, 2023 Advanced Micro Devices, Inc.
8 // Authors: Ajit Kumar Pandey <AjitKumar.Pandey@amd.com>
11 /* ACP machine configuration module */
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>
19 #include "../sof/amd/acp.h"
20 #include "mach-config.h"
22 #define ACP_7_0_REV 0x70
24 static int acp_quirk_data
;
26 static const struct config_entry config_table
[] = {
28 .flags
= FLAG_AMD_SOF
,
29 .device
= ACP_PCI_DEV_ID
,
30 .dmi_table
= (const struct dmi_system_id
[]) {
33 DMI_MATCH(DMI_SYS_VENDOR
, "AMD"),
34 DMI_MATCH(DMI_PRODUCT_NAME
, "Majolica-CZN"),
41 .flags
= FLAG_AMD_SOF
,
42 .device
= ACP_PCI_DEV_ID
,
43 .dmi_table
= (const struct dmi_system_id
[]) {
46 DMI_MATCH(DMI_SYS_VENDOR
, "Google"),
53 .flags
= FLAG_AMD_LEGACY
,
54 .device
= ACP_PCI_DEV_ID
,
55 .dmi_table
= (const struct dmi_system_id
[]) {
58 DMI_MATCH(DMI_SYS_VENDOR
, "Valve"),
59 DMI_MATCH(DMI_PRODUCT_NAME
, "Jupiter"),
66 .flags
= FLAG_AMD_SOF
,
67 .device
= ACP_PCI_DEV_ID
,
68 .dmi_table
= (const struct dmi_system_id
[]) {
71 DMI_MATCH(DMI_SYS_VENDOR
, "Valve"),
72 DMI_MATCH(DMI_PRODUCT_NAME
, "Galileo"),
79 .flags
= FLAG_AMD_LEGACY
,
80 .device
= ACP_PCI_DEV_ID
,
81 .dmi_table
= (const struct dmi_system_id
[]) {
84 DMI_EXACT_MATCH(DMI_BOARD_VENDOR
, "HUAWEI"),
85 DMI_EXACT_MATCH(DMI_PRODUCT_NAME
, "KLVL-WXXW"),
86 DMI_EXACT_MATCH(DMI_PRODUCT_VERSION
, "M1010"),
93 .flags
= FLAG_AMD_LEGACY
,
94 .device
= ACP_PCI_DEV_ID
,
95 .dmi_table
= (const struct dmi_system_id
[]) {
98 DMI_EXACT_MATCH(DMI_BOARD_VENDOR
, "HUAWEI"),
99 DMI_EXACT_MATCH(DMI_PRODUCT_NAME
, "KLVL-WXX9"),
100 DMI_EXACT_MATCH(DMI_PRODUCT_VERSION
, "M1010"),
107 .flags
= FLAG_AMD_LEGACY
,
108 .device
= ACP_PCI_DEV_ID
,
109 .dmi_table
= (const struct dmi_system_id
[]) {
112 DMI_EXACT_MATCH(DMI_BOARD_VENDOR
, "HUAWEI"),
113 DMI_EXACT_MATCH(DMI_PRODUCT_NAME
, "BOM-WXX9"),
114 DMI_EXACT_MATCH(DMI_PRODUCT_VERSION
, "M1010"),
121 .flags
= FLAG_AMD_LEGACY
,
122 .device
= ACP_PCI_DEV_ID
,
123 .dmi_table
= (const struct dmi_system_id
[]) {
126 DMI_EXACT_MATCH(DMI_BOARD_VENDOR
, "HUAWEI"),
127 DMI_EXACT_MATCH(DMI_PRODUCT_NAME
, "HVY-WXX9"),
128 DMI_EXACT_MATCH(DMI_PRODUCT_VERSION
, "M1010"),
135 .flags
= FLAG_AMD_LEGACY
,
136 .device
= ACP_PCI_DEV_ID
,
137 .dmi_table
= (const struct dmi_system_id
[]) {
140 DMI_EXACT_MATCH(DMI_BOARD_VENDOR
, "HUAWEI"),
141 DMI_EXACT_MATCH(DMI_PRODUCT_NAME
, "HVY-WXX9"),
142 DMI_EXACT_MATCH(DMI_PRODUCT_VERSION
, "M1020"),
149 .flags
= FLAG_AMD_LEGACY
,
150 .device
= ACP_PCI_DEV_ID
,
151 .dmi_table
= (const struct dmi_system_id
[]) {
154 DMI_EXACT_MATCH(DMI_BOARD_VENDOR
, "HUAWEI"),
155 DMI_EXACT_MATCH(DMI_PRODUCT_NAME
, "HVY-WXX9"),
156 DMI_EXACT_MATCH(DMI_PRODUCT_VERSION
, "M1040"),
164 static int snd_amd_acp_acpi_find_config(struct pci_dev
*pci
)
166 const union acpi_object
*obj
;
167 int acp_flag
= FLAG_AMD_LEGACY_ONLY_DMIC
;
169 if (!acpi_dev_get_property(ACPI_COMPANION(&pci
->dev
), "acp-audio-config-flag",
170 ACPI_TYPE_INTEGER
, &obj
))
171 acp_flag
= obj
->integer
.value
;
176 int snd_amd_acp_find_config(struct pci_dev
*pci
)
178 const struct config_entry
*table
= config_table
;
179 u16 device
= pci
->device
;
182 /* Do not enable FLAGS on older platforms with Rev Id zero
183 * For platforms which has ACP 7.0 or higher, read the acp
184 * config flag from BIOS ACPI table and for older platforms
185 * read it from DMI tables.
189 else if (pci
->revision
>= ACP_7_0_REV
)
190 return snd_amd_acp_acpi_find_config(pci
);
192 for (i
= 0; i
< ARRAY_SIZE(config_table
); i
++, table
++) {
193 if (table
->device
!= device
)
195 if (table
->dmi_table
&& !dmi_check_system(table
->dmi_table
))
197 acp_quirk_data
= table
->flags
;
203 EXPORT_SYMBOL(snd_amd_acp_find_config
);
205 static struct snd_soc_acpi_codecs amp_rt1019
= {
207 .codecs
= {"10EC1019"}
210 static struct snd_soc_acpi_codecs amp_max
= {
212 .codecs
= {"MX98360A"}
215 static struct snd_soc_acpi_codecs amp_max98388
= {
217 .codecs
= {"ADS8388"}
220 struct snd_soc_acpi_mach snd_soc_acpi_amd_sof_machines
[] = {
223 .drv_name
= "rt5682-rt1019",
224 .pdata
= (void *)&acp_quirk_data
,
225 .machine_quirk
= snd_soc_acpi_codec_list
,
226 .quirk_data
= &_rt1019
,
227 .fw_filename
= "sof-rn.ri",
228 .sof_tplg_filename
= "sof-rn-rt5682-rt1019.tplg",
232 .drv_name
= "rt5682-max",
233 .pdata
= (void *)&acp_quirk_data
,
234 .machine_quirk
= snd_soc_acpi_codec_list
,
235 .quirk_data
= &_max
,
236 .fw_filename
= "sof-rn.ri",
237 .sof_tplg_filename
= "sof-rn-rt5682-max98360.tplg",
241 .drv_name
= "rt5682s-max",
242 .pdata
= (void *)&acp_quirk_data
,
243 .machine_quirk
= snd_soc_acpi_codec_list
,
244 .quirk_data
= &_max
,
245 .fw_filename
= "sof-rn.ri",
246 .sof_tplg_filename
= "sof-rn-rt5682-max98360.tplg",
250 .drv_name
= "rt5682s-rt1019",
251 .pdata
= (void *)&acp_quirk_data
,
252 .machine_quirk
= snd_soc_acpi_codec_list
,
253 .quirk_data
= &_rt1019
,
254 .fw_filename
= "sof-rn.ri",
255 .sof_tplg_filename
= "sof-rn-rt5682-rt1019.tplg",
259 .drv_name
= "renoir-dsp",
260 .pdata
= (void *)&acp_quirk_data
,
261 .fw_filename
= "sof-rn.ri",
262 .sof_tplg_filename
= "sof-acp.tplg",
266 EXPORT_SYMBOL(snd_soc_acpi_amd_sof_machines
);
268 struct snd_soc_acpi_mach snd_soc_acpi_amd_vangogh_sof_machines
[] = {
271 .drv_name
= "nau8821-max",
272 .pdata
= &acp_quirk_data
,
273 .machine_quirk
= snd_soc_acpi_codec_list
,
274 .quirk_data
= &_max98388
,
275 .fw_filename
= "sof-vangogh.ri",
276 .sof_tplg_filename
= "sof-vangogh-nau8821-max.tplg",
280 EXPORT_SYMBOL(snd_soc_acpi_amd_vangogh_sof_machines
);
282 struct snd_soc_acpi_mach snd_soc_acpi_amd_rmb_sof_machines
[] = {
285 .drv_name
= "rmb-dsp",
286 .pdata
= &acp_quirk_data
,
287 .fw_filename
= "sof-rmb.ri",
288 .sof_tplg_filename
= "sof-acp-rmb.tplg",
292 .drv_name
= "nau8825-max",
293 .pdata
= &acp_quirk_data
,
294 .machine_quirk
= snd_soc_acpi_codec_list
,
295 .quirk_data
= &_max
,
296 .fw_filename
= "sof-rmb.ri",
297 .sof_tplg_filename
= "sof-rmb-nau8825-max98360.tplg",
301 .drv_name
= "rt5682s-hs-rt1019",
302 .pdata
= &acp_quirk_data
,
303 .machine_quirk
= snd_soc_acpi_codec_list
,
304 .quirk_data
= &_rt1019
,
305 .fw_filename
= "sof-rmb.ri",
306 .sof_tplg_filename
= "sof-rmb-rt5682s-rt1019.tplg",
310 EXPORT_SYMBOL(snd_soc_acpi_amd_rmb_sof_machines
);
312 struct snd_soc_acpi_mach snd_soc_acpi_amd_acp63_sof_machines
[] = {
315 .drv_name
= "acp63-dsp",
316 .pdata
= &acp_quirk_data
,
317 .fw_filename
= "sof-acp_6_3.ri",
318 .sof_tplg_filename
= "sof-acp_6_3.tplg",
322 EXPORT_SYMBOL(snd_soc_acpi_amd_acp63_sof_machines
);
324 struct snd_soc_acpi_mach snd_soc_acpi_amd_acp70_sof_machines
[] = {
327 .drv_name
= "acp70-dsp",
328 .pdata
= &acp_quirk_data
,
329 .fw_filename
= "sof-acp_7_0.ri",
330 .sof_tplg_filename
= "sof-acp_7_0.tplg",
334 EXPORT_SYMBOL(snd_soc_acpi_amd_acp70_sof_machines
);
336 MODULE_DESCRIPTION("AMD ACP Machine Configuration Module");
337 MODULE_LICENSE("Dual BSD/GPL");