xref: /linux/sound/soc/amd/acp-config.c (revision 54fcd9dd44b2c82a0262e29b288c2d0b36c6bba5)
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 	},
64*54fcd9ddSMarian Postevca 	{
65*54fcd9ddSMarian Postevca 		.flags = FLAG_AMD_LEGACY,
66*54fcd9ddSMarian Postevca 		.device = ACP_PCI_DEV_ID,
67*54fcd9ddSMarian Postevca 		.dmi_table = (const struct dmi_system_id []) {
68*54fcd9ddSMarian Postevca 			{
69*54fcd9ddSMarian Postevca 				.matches = {
70*54fcd9ddSMarian Postevca 					DMI_EXACT_MATCH(DMI_BOARD_VENDOR, "HUAWEI"),
71*54fcd9ddSMarian Postevca 					DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "KLVL-WXXW"),
72*54fcd9ddSMarian Postevca 					DMI_EXACT_MATCH(DMI_PRODUCT_VERSION, "M1010"),
73*54fcd9ddSMarian Postevca 				},
74*54fcd9ddSMarian Postevca 			},
75*54fcd9ddSMarian Postevca 			{}
76*54fcd9ddSMarian Postevca 		},
77*54fcd9ddSMarian Postevca 	},
78*54fcd9ddSMarian Postevca 	{
79*54fcd9ddSMarian Postevca 		.flags = FLAG_AMD_LEGACY,
80*54fcd9ddSMarian Postevca 		.device = ACP_PCI_DEV_ID,
81*54fcd9ddSMarian Postevca 		.dmi_table = (const struct dmi_system_id []) {
82*54fcd9ddSMarian Postevca 			{
83*54fcd9ddSMarian Postevca 				.matches = {
84*54fcd9ddSMarian Postevca 					DMI_EXACT_MATCH(DMI_BOARD_VENDOR, "HUAWEI"),
85*54fcd9ddSMarian Postevca 					DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "KLVL-WXX9"),
86*54fcd9ddSMarian Postevca 					DMI_EXACT_MATCH(DMI_PRODUCT_VERSION, "M1010"),
87*54fcd9ddSMarian Postevca 				},
88*54fcd9ddSMarian Postevca 			},
89*54fcd9ddSMarian Postevca 			{}
90*54fcd9ddSMarian Postevca 		},
91*54fcd9ddSMarian Postevca 	},
92*54fcd9ddSMarian Postevca 	{
93*54fcd9ddSMarian Postevca 		.flags = FLAG_AMD_LEGACY,
94*54fcd9ddSMarian Postevca 		.device = ACP_PCI_DEV_ID,
95*54fcd9ddSMarian Postevca 		.dmi_table = (const struct dmi_system_id []) {
96*54fcd9ddSMarian Postevca 			{
97*54fcd9ddSMarian Postevca 				.matches = {
98*54fcd9ddSMarian Postevca 					DMI_EXACT_MATCH(DMI_BOARD_VENDOR, "HUAWEI"),
99*54fcd9ddSMarian Postevca 					DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "BOM-WXX9"),
100*54fcd9ddSMarian Postevca 					DMI_EXACT_MATCH(DMI_PRODUCT_VERSION, "M1010"),
101*54fcd9ddSMarian Postevca 				},
102*54fcd9ddSMarian Postevca 			},
103*54fcd9ddSMarian Postevca 			{}
104*54fcd9ddSMarian Postevca 		},
105*54fcd9ddSMarian Postevca 	},
106*54fcd9ddSMarian Postevca 	{
107*54fcd9ddSMarian Postevca 		.flags = FLAG_AMD_LEGACY,
108*54fcd9ddSMarian Postevca 		.device = ACP_PCI_DEV_ID,
109*54fcd9ddSMarian Postevca 		.dmi_table = (const struct dmi_system_id []) {
110*54fcd9ddSMarian Postevca 			{
111*54fcd9ddSMarian Postevca 				.matches = {
112*54fcd9ddSMarian Postevca 					DMI_EXACT_MATCH(DMI_BOARD_VENDOR, "HUAWEI"),
113*54fcd9ddSMarian Postevca 					DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "HVY-WXX9"),
114*54fcd9ddSMarian Postevca 					DMI_EXACT_MATCH(DMI_PRODUCT_VERSION, "M1020"),
115*54fcd9ddSMarian Postevca 				},
116*54fcd9ddSMarian Postevca 			},
117*54fcd9ddSMarian Postevca 			{}
118*54fcd9ddSMarian Postevca 		},
119*54fcd9ddSMarian Postevca 	},
120*54fcd9ddSMarian Postevca 	{
121*54fcd9ddSMarian Postevca 		.flags = FLAG_AMD_LEGACY,
122*54fcd9ddSMarian Postevca 		.device = ACP_PCI_DEV_ID,
123*54fcd9ddSMarian Postevca 		.dmi_table = (const struct dmi_system_id []) {
124*54fcd9ddSMarian Postevca 			{
125*54fcd9ddSMarian Postevca 				.matches = {
126*54fcd9ddSMarian Postevca 					DMI_EXACT_MATCH(DMI_BOARD_VENDOR, "HUAWEI"),
127*54fcd9ddSMarian Postevca 					DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "HVY-WXX9"),
128*54fcd9ddSMarian Postevca 					DMI_EXACT_MATCH(DMI_PRODUCT_VERSION, "M1040"),
129*54fcd9ddSMarian Postevca 				},
130*54fcd9ddSMarian Postevca 			},
131*54fcd9ddSMarian Postevca 			{}
132*54fcd9ddSMarian Postevca 		},
133*54fcd9ddSMarian 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 
266f1bdd8d3SAjit Kumar Pandey MODULE_LICENSE("Dual BSD/GPL");
267