xref: /openbmc/linux/sound/soc/amd/acp-config.c (revision 8e4319a4)
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 
79 int snd_amd_acp_find_config(struct pci_dev *pci)
80 {
81 	const struct config_entry *table = config_table;
82 	u16 device = pci->device;
83 	int i;
84 
85 	/* Do not enable FLAGS on older platforms with Rev id zero */
86 	if (!pci->revision)
87 		return 0;
88 
89 	for (i = 0; i < ARRAY_SIZE(config_table); i++, table++) {
90 		if (table->device != device)
91 			continue;
92 		if (table->dmi_table && !dmi_check_system(table->dmi_table))
93 			continue;
94 		acp_quirk_data = table->flags;
95 		return table->flags;
96 	}
97 
98 	return 0;
99 }
100 EXPORT_SYMBOL(snd_amd_acp_find_config);
101 
102 static struct snd_soc_acpi_codecs amp_rt1019 = {
103 	.num_codecs = 1,
104 	.codecs = {"10EC1019"}
105 };
106 
107 static struct snd_soc_acpi_codecs amp_max = {
108 	.num_codecs = 1,
109 	.codecs = {"MX98360A"}
110 };
111 
112 static struct snd_soc_acpi_codecs amp_max98388 = {
113 	.num_codecs = 1,
114 	.codecs = {"ADS8388"}
115 };
116 
117 struct snd_soc_acpi_mach snd_soc_acpi_amd_sof_machines[] = {
118 	{
119 		.id = "10EC5682",
120 		.drv_name = "rt5682-rt1019",
121 		.pdata = (void *)&acp_quirk_data,
122 		.machine_quirk = snd_soc_acpi_codec_list,
123 		.quirk_data = &amp_rt1019,
124 		.fw_filename = "sof-rn.ri",
125 		.sof_tplg_filename = "sof-rn-rt5682-rt1019.tplg",
126 	},
127 	{
128 		.id = "10EC5682",
129 		.drv_name = "rt5682-max",
130 		.pdata = (void *)&acp_quirk_data,
131 		.machine_quirk = snd_soc_acpi_codec_list,
132 		.quirk_data = &amp_max,
133 		.fw_filename = "sof-rn.ri",
134 		.sof_tplg_filename = "sof-rn-rt5682-max98360.tplg",
135 	},
136 	{
137 		.id = "RTL5682",
138 		.drv_name = "rt5682s-max",
139 		.pdata = (void *)&acp_quirk_data,
140 		.machine_quirk = snd_soc_acpi_codec_list,
141 		.quirk_data = &amp_max,
142 		.fw_filename = "sof-rn.ri",
143 		.sof_tplg_filename = "sof-rn-rt5682-max98360.tplg",
144 	},
145 	{
146 		.id = "RTL5682",
147 		.drv_name = "rt5682s-rt1019",
148 		.pdata = (void *)&acp_quirk_data,
149 		.machine_quirk = snd_soc_acpi_codec_list,
150 		.quirk_data = &amp_rt1019,
151 		.fw_filename = "sof-rn.ri",
152 		.sof_tplg_filename = "sof-rn-rt5682-rt1019.tplg",
153 	},
154 	{
155 		.id = "AMDI1019",
156 		.drv_name = "renoir-dsp",
157 		.pdata = (void *)&acp_quirk_data,
158 		.fw_filename = "sof-rn.ri",
159 		.sof_tplg_filename = "sof-acp.tplg",
160 	},
161 	{},
162 };
163 EXPORT_SYMBOL(snd_soc_acpi_amd_sof_machines);
164 
165 struct snd_soc_acpi_mach snd_soc_acpi_amd_vangogh_sof_machines[] = {
166 	{
167 		.id = "NVTN2020",
168 		.drv_name = "nau8821-max",
169 		.pdata = &acp_quirk_data,
170 		.machine_quirk = snd_soc_acpi_codec_list,
171 		.quirk_data = &amp_max98388,
172 		.fw_filename = "sof-vangogh.ri",
173 		.sof_tplg_filename = "sof-vangogh-nau8821-max.tplg",
174 	},
175 	{},
176 };
177 EXPORT_SYMBOL(snd_soc_acpi_amd_vangogh_sof_machines);
178 
179 struct snd_soc_acpi_mach snd_soc_acpi_amd_rmb_sof_machines[] = {
180 	{
181 		.id = "AMDI1019",
182 		.drv_name = "rmb-dsp",
183 		.pdata = &acp_quirk_data,
184 		.fw_filename = "sof-rmb.ri",
185 		.sof_tplg_filename = "sof-acp-rmb.tplg",
186 	},
187 	{
188 		.id = "10508825",
189 		.drv_name = "nau8825-max",
190 		.pdata = &acp_quirk_data,
191 		.machine_quirk = snd_soc_acpi_codec_list,
192 		.quirk_data = &amp_max,
193 		.fw_filename = "sof-rmb.ri",
194 		.sof_tplg_filename = "sof-rmb-nau8825-max98360.tplg",
195 	},
196 	{
197 		.id = "RTL5682",
198 		.drv_name = "rt5682s-hs-rt1019",
199 		.pdata = &acp_quirk_data,
200 		.machine_quirk = snd_soc_acpi_codec_list,
201 		.quirk_data = &amp_rt1019,
202 		.fw_filename = "sof-rmb.ri",
203 		.sof_tplg_filename = "sof-rmb-rt5682s-rt1019.tplg",
204 	},
205 	{},
206 };
207 EXPORT_SYMBOL(snd_soc_acpi_amd_rmb_sof_machines);
208 
209 MODULE_LICENSE("Dual BSD/GPL");
210