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