xref: /linux/sound/soc/amd/acp-config.c (revision bb98b592cfd387eccc9430d4cd5ebc1678775a88)
1f1bdd8d3SAjit Kumar Pandey // SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause)
2f1bdd8d3SAjit Kumar Pandey //
3f1bdd8d3SAjit Kumar Pandey // This file is provided under a dual BSD/GPLv2 license. When using or
4f1bdd8d3SAjit Kumar Pandey // redistributing this file, you may do so under either license.
5f1bdd8d3SAjit Kumar Pandey //
6f1bdd8d3SAjit Kumar Pandey // Copyright(c) 2021 Advanced Micro Devices, Inc.
7f1bdd8d3SAjit Kumar Pandey //
8f1bdd8d3SAjit Kumar Pandey // Authors: Ajit Kumar Pandey <AjitKumar.Pandey@amd.com>
9f1bdd8d3SAjit Kumar Pandey //
10f1bdd8d3SAjit Kumar Pandey 
11f1bdd8d3SAjit Kumar Pandey /* ACP machine configuration module */
12f1bdd8d3SAjit Kumar Pandey 
13f1bdd8d3SAjit Kumar Pandey #include <linux/acpi.h>
14f1bdd8d3SAjit Kumar Pandey #include <linux/bits.h>
15f1bdd8d3SAjit Kumar Pandey #include <linux/dmi.h>
16f1bdd8d3SAjit Kumar Pandey #include <linux/module.h>
17f1bdd8d3SAjit Kumar Pandey #include <linux/pci.h>
18f1bdd8d3SAjit Kumar Pandey 
19f1bdd8d3SAjit Kumar Pandey #include "../sof/amd/acp.h"
20f1bdd8d3SAjit Kumar Pandey #include "mach-config.h"
21f1bdd8d3SAjit Kumar Pandey 
22f1bdd8d3SAjit Kumar Pandey static int acp_quirk_data;
23f1bdd8d3SAjit Kumar Pandey 
24f1bdd8d3SAjit Kumar Pandey static const struct config_entry config_table[] = {
25f1bdd8d3SAjit Kumar Pandey 	{
26f1bdd8d3SAjit Kumar Pandey 		.flags = FLAG_AMD_SOF,
27f1bdd8d3SAjit Kumar Pandey 		.device = ACP_PCI_DEV_ID,
28f1bdd8d3SAjit Kumar Pandey 		.dmi_table = (const struct dmi_system_id []) {
29f1bdd8d3SAjit Kumar Pandey 			{
30f1bdd8d3SAjit Kumar Pandey 				.matches = {
31f1bdd8d3SAjit Kumar Pandey 					DMI_MATCH(DMI_SYS_VENDOR, "AMD"),
32f1bdd8d3SAjit Kumar Pandey 					DMI_MATCH(DMI_PRODUCT_NAME, "Majolica-CZN"),
33f1bdd8d3SAjit Kumar Pandey 				},
34f1bdd8d3SAjit Kumar Pandey 			},
35f1bdd8d3SAjit Kumar Pandey 			{}
36f1bdd8d3SAjit Kumar Pandey 		},
37f1bdd8d3SAjit Kumar Pandey 	},
38f4872013SAjit Kumar Pandey 	{
39f4872013SAjit Kumar Pandey 		.flags = FLAG_AMD_SOF,
40f4872013SAjit Kumar Pandey 		.device = ACP_PCI_DEV_ID,
41f4872013SAjit Kumar Pandey 		.dmi_table = (const struct dmi_system_id []) {
42f4872013SAjit Kumar Pandey 			{
43f4872013SAjit Kumar Pandey 				.matches = {
44f4872013SAjit Kumar Pandey 					DMI_MATCH(DMI_SYS_VENDOR, "Google"),
45f4872013SAjit Kumar Pandey 				},
46f4872013SAjit Kumar Pandey 			},
47f4872013SAjit Kumar Pandey 			{}
48f4872013SAjit Kumar Pandey 		},
49f4872013SAjit Kumar Pandey 	},
50197b1f7fSVenkata Prasad Potturu 	{
51197b1f7fSVenkata Prasad Potturu 		.flags = FLAG_AMD_SOF,
52197b1f7fSVenkata Prasad Potturu 		.device = ACP_PCI_DEV_ID,
53197b1f7fSVenkata Prasad Potturu 		.dmi_table = (const struct dmi_system_id []) {
54197b1f7fSVenkata Prasad Potturu 			{
55197b1f7fSVenkata Prasad Potturu 				.matches = {
56197b1f7fSVenkata Prasad Potturu 					DMI_MATCH(DMI_SYS_VENDOR, "Valve"),
57197b1f7fSVenkata Prasad Potturu 					DMI_MATCH(DMI_PRODUCT_NAME, "Galileo"),
58197b1f7fSVenkata Prasad Potturu 					DMI_MATCH(DMI_PRODUCT_FAMILY, "Sephiroth"),
59197b1f7fSVenkata Prasad Potturu 				},
60197b1f7fSVenkata Prasad Potturu 			},
61197b1f7fSVenkata Prasad Potturu 			{}
62197b1f7fSVenkata Prasad Potturu 		},
63197b1f7fSVenkata Prasad Potturu 	},
6454fcd9ddSMarian Postevca 	{
6554fcd9ddSMarian Postevca 		.flags = FLAG_AMD_LEGACY,
6654fcd9ddSMarian Postevca 		.device = ACP_PCI_DEV_ID,
6754fcd9ddSMarian Postevca 		.dmi_table = (const struct dmi_system_id []) {
6854fcd9ddSMarian Postevca 			{
6954fcd9ddSMarian Postevca 				.matches = {
7054fcd9ddSMarian Postevca 					DMI_EXACT_MATCH(DMI_BOARD_VENDOR, "HUAWEI"),
7154fcd9ddSMarian Postevca 					DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "KLVL-WXXW"),
7254fcd9ddSMarian Postevca 					DMI_EXACT_MATCH(DMI_PRODUCT_VERSION, "M1010"),
7354fcd9ddSMarian Postevca 				},
7454fcd9ddSMarian Postevca 			},
7554fcd9ddSMarian Postevca 			{}
7654fcd9ddSMarian Postevca 		},
7754fcd9ddSMarian Postevca 	},
7854fcd9ddSMarian Postevca 	{
7954fcd9ddSMarian Postevca 		.flags = FLAG_AMD_LEGACY,
8054fcd9ddSMarian Postevca 		.device = ACP_PCI_DEV_ID,
8154fcd9ddSMarian Postevca 		.dmi_table = (const struct dmi_system_id []) {
8254fcd9ddSMarian Postevca 			{
8354fcd9ddSMarian Postevca 				.matches = {
8454fcd9ddSMarian Postevca 					DMI_EXACT_MATCH(DMI_BOARD_VENDOR, "HUAWEI"),
8554fcd9ddSMarian Postevca 					DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "KLVL-WXX9"),
8654fcd9ddSMarian Postevca 					DMI_EXACT_MATCH(DMI_PRODUCT_VERSION, "M1010"),
8754fcd9ddSMarian Postevca 				},
8854fcd9ddSMarian Postevca 			},
8954fcd9ddSMarian Postevca 			{}
9054fcd9ddSMarian Postevca 		},
9154fcd9ddSMarian Postevca 	},
9254fcd9ddSMarian Postevca 	{
9354fcd9ddSMarian Postevca 		.flags = FLAG_AMD_LEGACY,
9454fcd9ddSMarian Postevca 		.device = ACP_PCI_DEV_ID,
9554fcd9ddSMarian Postevca 		.dmi_table = (const struct dmi_system_id []) {
9654fcd9ddSMarian Postevca 			{
9754fcd9ddSMarian Postevca 				.matches = {
9854fcd9ddSMarian Postevca 					DMI_EXACT_MATCH(DMI_BOARD_VENDOR, "HUAWEI"),
9954fcd9ddSMarian Postevca 					DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "BOM-WXX9"),
10054fcd9ddSMarian Postevca 					DMI_EXACT_MATCH(DMI_PRODUCT_VERSION, "M1010"),
10154fcd9ddSMarian Postevca 				},
10254fcd9ddSMarian Postevca 			},
10354fcd9ddSMarian Postevca 			{}
10454fcd9ddSMarian Postevca 		},
10554fcd9ddSMarian Postevca 	},
10654fcd9ddSMarian Postevca 	{
10754fcd9ddSMarian Postevca 		.flags = FLAG_AMD_LEGACY,
10854fcd9ddSMarian Postevca 		.device = ACP_PCI_DEV_ID,
10954fcd9ddSMarian Postevca 		.dmi_table = (const struct dmi_system_id []) {
11054fcd9ddSMarian Postevca 			{
11154fcd9ddSMarian Postevca 				.matches = {
11254fcd9ddSMarian Postevca 					DMI_EXACT_MATCH(DMI_BOARD_VENDOR, "HUAWEI"),
11354fcd9ddSMarian Postevca 					DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "HVY-WXX9"),
11454fcd9ddSMarian Postevca 					DMI_EXACT_MATCH(DMI_PRODUCT_VERSION, "M1020"),
11554fcd9ddSMarian Postevca 				},
11654fcd9ddSMarian Postevca 			},
11754fcd9ddSMarian Postevca 			{}
11854fcd9ddSMarian Postevca 		},
11954fcd9ddSMarian Postevca 	},
12054fcd9ddSMarian Postevca 	{
12154fcd9ddSMarian Postevca 		.flags = FLAG_AMD_LEGACY,
12254fcd9ddSMarian Postevca 		.device = ACP_PCI_DEV_ID,
12354fcd9ddSMarian Postevca 		.dmi_table = (const struct dmi_system_id []) {
12454fcd9ddSMarian Postevca 			{
12554fcd9ddSMarian Postevca 				.matches = {
12654fcd9ddSMarian Postevca 					DMI_EXACT_MATCH(DMI_BOARD_VENDOR, "HUAWEI"),
12754fcd9ddSMarian Postevca 					DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "HVY-WXX9"),
12854fcd9ddSMarian Postevca 					DMI_EXACT_MATCH(DMI_PRODUCT_VERSION, "M1040"),
12954fcd9ddSMarian Postevca 				},
13054fcd9ddSMarian Postevca 			},
13154fcd9ddSMarian Postevca 			{}
13254fcd9ddSMarian Postevca 		},
13354fcd9ddSMarian Postevca 	},
134f1bdd8d3SAjit Kumar Pandey };
135f1bdd8d3SAjit Kumar Pandey 
136f1bdd8d3SAjit Kumar Pandey int snd_amd_acp_find_config(struct pci_dev *pci)
137f1bdd8d3SAjit Kumar Pandey {
138f1bdd8d3SAjit Kumar Pandey 	const struct config_entry *table = config_table;
139f1bdd8d3SAjit Kumar Pandey 	u16 device = pci->device;
140f1bdd8d3SAjit Kumar Pandey 	int i;
141f1bdd8d3SAjit Kumar Pandey 
142f4872013SAjit Kumar Pandey 	/* Do not enable FLAGS on older platforms with Rev id zero */
143f4872013SAjit Kumar Pandey 	if (!pci->revision)
144f4872013SAjit Kumar Pandey 		return 0;
145f4872013SAjit Kumar Pandey 
146f1bdd8d3SAjit Kumar Pandey 	for (i = 0; i < ARRAY_SIZE(config_table); i++, table++) {
147f1bdd8d3SAjit Kumar Pandey 		if (table->device != device)
148f1bdd8d3SAjit Kumar Pandey 			continue;
149f1bdd8d3SAjit Kumar Pandey 		if (table->dmi_table && !dmi_check_system(table->dmi_table))
150f1bdd8d3SAjit Kumar Pandey 			continue;
151f1bdd8d3SAjit Kumar Pandey 		acp_quirk_data = table->flags;
152f1bdd8d3SAjit Kumar Pandey 		return table->flags;
153f1bdd8d3SAjit Kumar Pandey 	}
154f1bdd8d3SAjit Kumar Pandey 
155f1bdd8d3SAjit Kumar Pandey 	return 0;
156f1bdd8d3SAjit Kumar Pandey }
157f1bdd8d3SAjit Kumar Pandey EXPORT_SYMBOL(snd_amd_acp_find_config);
158f1bdd8d3SAjit Kumar Pandey 
159f4872013SAjit Kumar Pandey static struct snd_soc_acpi_codecs amp_rt1019 = {
160f4872013SAjit Kumar Pandey 	.num_codecs = 1,
161f4872013SAjit Kumar Pandey 	.codecs = {"10EC1019"}
162f4872013SAjit Kumar Pandey };
163f4872013SAjit Kumar Pandey 
164f4872013SAjit Kumar Pandey static struct snd_soc_acpi_codecs amp_max = {
165f4872013SAjit Kumar Pandey 	.num_codecs = 1,
166f4872013SAjit Kumar Pandey 	.codecs = {"MX98360A"}
167f4872013SAjit Kumar Pandey };
168f4872013SAjit Kumar Pandey 
169ef51cddfSVenkata Prasad Potturu static struct snd_soc_acpi_codecs amp_max98388 = {
170ef51cddfSVenkata Prasad Potturu 	.num_codecs = 1,
171ef51cddfSVenkata Prasad Potturu 	.codecs = {"ADS8388"}
172ef51cddfSVenkata Prasad Potturu };
173ef51cddfSVenkata Prasad Potturu 
174f1bdd8d3SAjit Kumar Pandey struct snd_soc_acpi_mach snd_soc_acpi_amd_sof_machines[] = {
175f1bdd8d3SAjit Kumar Pandey 	{
176f4872013SAjit Kumar Pandey 		.id = "10EC5682",
177f4872013SAjit Kumar Pandey 		.drv_name = "rt5682-rt1019",
178f4872013SAjit Kumar Pandey 		.pdata = (void *)&acp_quirk_data,
179f4872013SAjit Kumar Pandey 		.machine_quirk = snd_soc_acpi_codec_list,
180f4872013SAjit Kumar Pandey 		.quirk_data = &amp_rt1019,
181f4872013SAjit Kumar Pandey 		.fw_filename = "sof-rn.ri",
1820082e329SAjit Kumar Pandey 		.sof_tplg_filename = "sof-rn-rt5682-rt1019.tplg",
183f4872013SAjit Kumar Pandey 	},
184f4872013SAjit Kumar Pandey 	{
185f4872013SAjit Kumar Pandey 		.id = "10EC5682",
186f4872013SAjit Kumar Pandey 		.drv_name = "rt5682-max",
187f4872013SAjit Kumar Pandey 		.pdata = (void *)&acp_quirk_data,
188f4872013SAjit Kumar Pandey 		.machine_quirk = snd_soc_acpi_codec_list,
189f4872013SAjit Kumar Pandey 		.quirk_data = &amp_max,
190f4872013SAjit Kumar Pandey 		.fw_filename = "sof-rn.ri",
1910082e329SAjit Kumar Pandey 		.sof_tplg_filename = "sof-rn-rt5682-max98360.tplg",
192f4872013SAjit Kumar Pandey 	},
193f4872013SAjit Kumar Pandey 	{
194f4872013SAjit Kumar Pandey 		.id = "RTL5682",
195f4872013SAjit Kumar Pandey 		.drv_name = "rt5682s-max",
196f4872013SAjit Kumar Pandey 		.pdata = (void *)&acp_quirk_data,
197f4872013SAjit Kumar Pandey 		.machine_quirk = snd_soc_acpi_codec_list,
198f4872013SAjit Kumar Pandey 		.quirk_data = &amp_max,
199f4872013SAjit Kumar Pandey 		.fw_filename = "sof-rn.ri",
2000082e329SAjit Kumar Pandey 		.sof_tplg_filename = "sof-rn-rt5682-max98360.tplg",
201f4872013SAjit Kumar Pandey 	},
202f4872013SAjit Kumar Pandey 	{
203330dc183SV sujith kumar Reddy 		.id = "RTL5682",
204330dc183SV sujith kumar Reddy 		.drv_name = "rt5682s-rt1019",
205330dc183SV sujith kumar Reddy 		.pdata = (void *)&acp_quirk_data,
206330dc183SV sujith kumar Reddy 		.machine_quirk = snd_soc_acpi_codec_list,
207330dc183SV sujith kumar Reddy 		.quirk_data = &amp_rt1019,
208330dc183SV sujith kumar Reddy 		.fw_filename = "sof-rn.ri",
209330dc183SV sujith kumar Reddy 		.sof_tplg_filename = "sof-rn-rt5682-rt1019.tplg",
210330dc183SV sujith kumar Reddy 	},
211330dc183SV sujith kumar Reddy 	{
212f1bdd8d3SAjit Kumar Pandey 		.id = "AMDI1019",
213f1bdd8d3SAjit Kumar Pandey 		.drv_name = "renoir-dsp",
214f1bdd8d3SAjit Kumar Pandey 		.pdata = (void *)&acp_quirk_data,
215f1bdd8d3SAjit Kumar Pandey 		.fw_filename = "sof-rn.ri",
216f1bdd8d3SAjit Kumar Pandey 		.sof_tplg_filename = "sof-acp.tplg",
217f1bdd8d3SAjit Kumar Pandey 	},
218f1bdd8d3SAjit Kumar Pandey 	{},
219f1bdd8d3SAjit Kumar Pandey };
220f1bdd8d3SAjit Kumar Pandey EXPORT_SYMBOL(snd_soc_acpi_amd_sof_machines);
221f1bdd8d3SAjit Kumar Pandey 
222ef51cddfSVenkata Prasad Potturu struct snd_soc_acpi_mach snd_soc_acpi_amd_vangogh_sof_machines[] = {
223ef51cddfSVenkata Prasad Potturu 	{
224ef51cddfSVenkata Prasad Potturu 		.id = "NVTN2020",
225ef51cddfSVenkata Prasad Potturu 		.drv_name = "nau8821-max",
226ef51cddfSVenkata Prasad Potturu 		.pdata = &acp_quirk_data,
227ef51cddfSVenkata Prasad Potturu 		.machine_quirk = snd_soc_acpi_codec_list,
228ef51cddfSVenkata Prasad Potturu 		.quirk_data = &amp_max98388,
229ef51cddfSVenkata Prasad Potturu 		.fw_filename = "sof-vangogh.ri",
230ef51cddfSVenkata Prasad Potturu 		.sof_tplg_filename = "sof-vangogh-nau8821-max.tplg",
231ef51cddfSVenkata Prasad Potturu 	},
232ef51cddfSVenkata Prasad Potturu 	{},
233ef51cddfSVenkata Prasad Potturu };
234ef51cddfSVenkata Prasad Potturu EXPORT_SYMBOL(snd_soc_acpi_amd_vangogh_sof_machines);
235ef51cddfSVenkata Prasad Potturu 
2360439eb4dSV sujith kumar Reddy struct snd_soc_acpi_mach snd_soc_acpi_amd_rmb_sof_machines[] = {
2370439eb4dSV sujith kumar Reddy 	{
2380439eb4dSV sujith kumar Reddy 		.id = "AMDI1019",
2390439eb4dSV sujith kumar Reddy 		.drv_name = "rmb-dsp",
2400439eb4dSV sujith kumar Reddy 		.pdata = &acp_quirk_data,
2410439eb4dSV sujith kumar Reddy 		.fw_filename = "sof-rmb.ri",
2420439eb4dSV sujith kumar Reddy 		.sof_tplg_filename = "sof-acp-rmb.tplg",
2430439eb4dSV sujith kumar Reddy 	},
2440439eb4dSV sujith kumar Reddy 	{
2450439eb4dSV sujith kumar Reddy 		.id = "10508825",
2460439eb4dSV sujith kumar Reddy 		.drv_name = "nau8825-max",
2470439eb4dSV sujith kumar Reddy 		.pdata = &acp_quirk_data,
2480439eb4dSV sujith kumar Reddy 		.machine_quirk = snd_soc_acpi_codec_list,
2490439eb4dSV sujith kumar Reddy 		.quirk_data = &amp_max,
2500439eb4dSV sujith kumar Reddy 		.fw_filename = "sof-rmb.ri",
2510439eb4dSV sujith kumar Reddy 		.sof_tplg_filename = "sof-rmb-nau8825-max98360.tplg",
2520439eb4dSV sujith kumar Reddy 	},
2534dc6737cSV sujith kumar Reddy 	{
2544dc6737cSV sujith kumar Reddy 		.id = "RTL5682",
2554dc6737cSV sujith kumar Reddy 		.drv_name = "rt5682s-hs-rt1019",
2564dc6737cSV sujith kumar Reddy 		.pdata = &acp_quirk_data,
2574dc6737cSV sujith kumar Reddy 		.machine_quirk = snd_soc_acpi_codec_list,
2584dc6737cSV sujith kumar Reddy 		.quirk_data = &amp_rt1019,
2594dc6737cSV sujith kumar Reddy 		.fw_filename = "sof-rmb.ri",
2604dc6737cSV sujith kumar Reddy 		.sof_tplg_filename = "sof-rmb-rt5682s-rt1019.tplg",
2614dc6737cSV sujith kumar Reddy 	},
2620439eb4dSV sujith kumar Reddy 	{},
2630439eb4dSV sujith kumar Reddy };
2640439eb4dSV sujith kumar Reddy EXPORT_SYMBOL(snd_soc_acpi_amd_rmb_sof_machines);
2650439eb4dSV sujith kumar Reddy 
266*bb98b592SVijendar Mukunda struct snd_soc_acpi_mach snd_soc_acpi_amd_acp63_sof_machines[] = {
267*bb98b592SVijendar Mukunda 	{
268*bb98b592SVijendar Mukunda 		.id = "AMDI1019",
269*bb98b592SVijendar Mukunda 		.drv_name = "acp63-dsp",
270*bb98b592SVijendar Mukunda 		.pdata = &acp_quirk_data,
271*bb98b592SVijendar Mukunda 		.fw_filename = "sof-acp_6_3.ri",
272*bb98b592SVijendar Mukunda 		.sof_tplg_filename = "sof-acp_6_3.tplg",
273*bb98b592SVijendar Mukunda 	},
274*bb98b592SVijendar Mukunda 	{},
275*bb98b592SVijendar Mukunda };
276*bb98b592SVijendar Mukunda EXPORT_SYMBOL(snd_soc_acpi_amd_acp63_sof_machines);
277*bb98b592SVijendar Mukunda 
278f1bdd8d3SAjit Kumar Pandey MODULE_LICENSE("Dual BSD/GPL");
279