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