xref: /openbmc/linux/sound/soc/amd/acp-config.c (revision b868a02e)
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 
52 int snd_amd_acp_find_config(struct pci_dev *pci)
53 {
54 	const struct config_entry *table = config_table;
55 	u16 device = pci->device;
56 	int i;
57 
58 	/* Do not enable FLAGS on older platforms with Rev id zero */
59 	if (!pci->revision)
60 		return 0;
61 
62 	for (i = 0; i < ARRAY_SIZE(config_table); i++, table++) {
63 		if (table->device != device)
64 			continue;
65 		if (table->dmi_table && !dmi_check_system(table->dmi_table))
66 			continue;
67 		acp_quirk_data = table->flags;
68 		return table->flags;
69 	}
70 
71 	return 0;
72 }
73 EXPORT_SYMBOL(snd_amd_acp_find_config);
74 
75 static struct snd_soc_acpi_codecs amp_rt1019 = {
76 	.num_codecs = 1,
77 	.codecs = {"10EC1019"}
78 };
79 
80 static struct snd_soc_acpi_codecs amp_max = {
81 	.num_codecs = 1,
82 	.codecs = {"MX98360A"}
83 };
84 
85 struct snd_soc_acpi_mach snd_soc_acpi_amd_sof_machines[] = {
86 	{
87 		.id = "10EC5682",
88 		.drv_name = "rt5682-rt1019",
89 		.pdata = (void *)&acp_quirk_data,
90 		.machine_quirk = snd_soc_acpi_codec_list,
91 		.quirk_data = &amp_rt1019,
92 		.fw_filename = "sof-rn.ri",
93 		.sof_tplg_filename = "sof-rn-rt5682-rt1019.tplg",
94 	},
95 	{
96 		.id = "10EC5682",
97 		.drv_name = "rt5682-max",
98 		.pdata = (void *)&acp_quirk_data,
99 		.machine_quirk = snd_soc_acpi_codec_list,
100 		.quirk_data = &amp_max,
101 		.fw_filename = "sof-rn.ri",
102 		.sof_tplg_filename = "sof-rn-rt5682-max98360.tplg",
103 	},
104 	{
105 		.id = "RTL5682",
106 		.drv_name = "rt5682s-max",
107 		.pdata = (void *)&acp_quirk_data,
108 		.machine_quirk = snd_soc_acpi_codec_list,
109 		.quirk_data = &amp_max,
110 		.fw_filename = "sof-rn.ri",
111 		.sof_tplg_filename = "sof-rn-rt5682-max98360.tplg",
112 	},
113 	{
114 		.id = "RTL5682",
115 		.drv_name = "rt5682s-rt1019",
116 		.pdata = (void *)&acp_quirk_data,
117 		.machine_quirk = snd_soc_acpi_codec_list,
118 		.quirk_data = &amp_rt1019,
119 		.fw_filename = "sof-rn.ri",
120 		.sof_tplg_filename = "sof-rn-rt5682-rt1019.tplg",
121 	},
122 	{
123 		.id = "AMDI1019",
124 		.drv_name = "renoir-dsp",
125 		.pdata = (void *)&acp_quirk_data,
126 		.fw_filename = "sof-rn.ri",
127 		.sof_tplg_filename = "sof-acp.tplg",
128 	},
129 	{},
130 };
131 EXPORT_SYMBOL(snd_soc_acpi_amd_sof_machines);
132 
133 struct snd_soc_acpi_mach snd_soc_acpi_amd_rmb_sof_machines[] = {
134 	{
135 		.id = "AMDI1019",
136 		.drv_name = "rmb-dsp",
137 		.pdata = &acp_quirk_data,
138 		.fw_filename = "sof-rmb.ri",
139 		.sof_tplg_filename = "sof-acp-rmb.tplg",
140 	},
141 	{
142 		.id = "10508825",
143 		.drv_name = "nau8825-max",
144 		.pdata = &acp_quirk_data,
145 		.machine_quirk = snd_soc_acpi_codec_list,
146 		.quirk_data = &amp_max,
147 		.fw_filename = "sof-rmb.ri",
148 		.sof_tplg_filename = "sof-rmb-nau8825-max98360.tplg",
149 	},
150 	{
151 		.id = "RTL5682",
152 		.drv_name = "rt5682s-hs-rt1019",
153 		.pdata = &acp_quirk_data,
154 		.machine_quirk = snd_soc_acpi_codec_list,
155 		.quirk_data = &amp_rt1019,
156 		.fw_filename = "sof-rmb.ri",
157 		.sof_tplg_filename = "sof-rmb-rt5682s-rt1019.tplg",
158 	},
159 	{},
160 };
161 EXPORT_SYMBOL(snd_soc_acpi_amd_rmb_sof_machines);
162 
163 MODULE_LICENSE("Dual BSD/GPL");
164