xref: /linux/sound/soc/amd/acp-config.c (revision 0082e3299a49286a7761f4d237530b07c00676fb)
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",
93*0082e329SAjit 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",
102*0082e329SAjit 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",
111*0082e329SAjit Kumar Pandey 		.sof_tplg_filename = "sof-rn-rt5682-max98360.tplg",
112f4872013SAjit Kumar Pandey 	},
113f4872013SAjit Kumar Pandey 	{
114f1bdd8d3SAjit Kumar Pandey 		.id = "AMDI1019",
115f1bdd8d3SAjit Kumar Pandey 		.drv_name = "renoir-dsp",
116f1bdd8d3SAjit Kumar Pandey 		.pdata = (void *)&acp_quirk_data,
117f1bdd8d3SAjit Kumar Pandey 		.fw_filename = "sof-rn.ri",
118f1bdd8d3SAjit Kumar Pandey 		.sof_tplg_filename = "sof-acp.tplg",
119f1bdd8d3SAjit Kumar Pandey 	},
120f1bdd8d3SAjit Kumar Pandey 	{},
121f1bdd8d3SAjit Kumar Pandey };
122f1bdd8d3SAjit Kumar Pandey EXPORT_SYMBOL(snd_soc_acpi_amd_sof_machines);
123f1bdd8d3SAjit Kumar Pandey 
124f1bdd8d3SAjit Kumar Pandey MODULE_LICENSE("Dual BSD/GPL");
125