xref: /linux/sound/soc/amd/acp-config.c (revision f487201343312faa697ac40124085a834e0e26d8)
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 	},
38*f4872013SAjit Kumar Pandey 	{
39*f4872013SAjit Kumar Pandey 		.flags = FLAG_AMD_SOF,
40*f4872013SAjit Kumar Pandey 		.device = ACP_PCI_DEV_ID,
41*f4872013SAjit Kumar Pandey 		.dmi_table = (const struct dmi_system_id []) {
42*f4872013SAjit Kumar Pandey 			{
43*f4872013SAjit Kumar Pandey 				.matches = {
44*f4872013SAjit Kumar Pandey 					DMI_MATCH(DMI_SYS_VENDOR, "Google"),
45*f4872013SAjit Kumar Pandey 				},
46*f4872013SAjit Kumar Pandey 			},
47*f4872013SAjit Kumar Pandey 			{}
48*f4872013SAjit Kumar Pandey 		},
49*f4872013SAjit 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 
58*f4872013SAjit Kumar Pandey 	/* Do not enable FLAGS on older platforms with Rev id zero */
59*f4872013SAjit Kumar Pandey 	if (!pci->revision)
60*f4872013SAjit Kumar Pandey 		return 0;
61*f4872013SAjit 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 
75*f4872013SAjit Kumar Pandey static struct snd_soc_acpi_codecs amp_rt1019 = {
76*f4872013SAjit Kumar Pandey 	.num_codecs = 1,
77*f4872013SAjit Kumar Pandey 	.codecs = {"10EC1019"}
78*f4872013SAjit Kumar Pandey };
79*f4872013SAjit Kumar Pandey 
80*f4872013SAjit Kumar Pandey static struct snd_soc_acpi_codecs amp_max = {
81*f4872013SAjit Kumar Pandey 	.num_codecs = 1,
82*f4872013SAjit Kumar Pandey 	.codecs = {"MX98360A"}
83*f4872013SAjit Kumar Pandey };
84*f4872013SAjit Kumar Pandey 
85f1bdd8d3SAjit Kumar Pandey struct snd_soc_acpi_mach snd_soc_acpi_amd_sof_machines[] = {
86f1bdd8d3SAjit Kumar Pandey 	{
87*f4872013SAjit Kumar Pandey 		.id = "10EC5682",
88*f4872013SAjit Kumar Pandey 		.drv_name = "rt5682-rt1019",
89*f4872013SAjit Kumar Pandey 		.pdata = (void *)&acp_quirk_data,
90*f4872013SAjit Kumar Pandey 		.machine_quirk = snd_soc_acpi_codec_list,
91*f4872013SAjit Kumar Pandey 		.quirk_data = &amp_rt1019,
92*f4872013SAjit Kumar Pandey 		.fw_filename = "sof-rn.ri",
93*f4872013SAjit Kumar Pandey 		.sof_tplg_filename = "sof-acp.tplg",
94*f4872013SAjit Kumar Pandey 	},
95*f4872013SAjit Kumar Pandey 	{
96*f4872013SAjit Kumar Pandey 		.id = "10EC5682",
97*f4872013SAjit Kumar Pandey 		.drv_name = "rt5682-max",
98*f4872013SAjit Kumar Pandey 		.pdata = (void *)&acp_quirk_data,
99*f4872013SAjit Kumar Pandey 		.machine_quirk = snd_soc_acpi_codec_list,
100*f4872013SAjit Kumar Pandey 		.quirk_data = &amp_max,
101*f4872013SAjit Kumar Pandey 		.fw_filename = "sof-rn.ri",
102*f4872013SAjit Kumar Pandey 		.sof_tplg_filename = "sof-acp.tplg",
103*f4872013SAjit Kumar Pandey 	},
104*f4872013SAjit Kumar Pandey 	{
105*f4872013SAjit Kumar Pandey 		.id = "RTL5682",
106*f4872013SAjit Kumar Pandey 		.drv_name = "rt5682s-max",
107*f4872013SAjit Kumar Pandey 		.pdata = (void *)&acp_quirk_data,
108*f4872013SAjit Kumar Pandey 		.machine_quirk = snd_soc_acpi_codec_list,
109*f4872013SAjit Kumar Pandey 		.quirk_data = &amp_max,
110*f4872013SAjit Kumar Pandey 		.fw_filename = "sof-rn.ri",
111*f4872013SAjit Kumar Pandey 		.sof_tplg_filename = "sof-acp.tplg",
112*f4872013SAjit Kumar Pandey 	},
113*f4872013SAjit 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