xref: /linux/sound/soc/amd/acp-config.c (revision ef51cddf014b3e4909e9656025d1f7c2b4cc4117)
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 
85*ef51cddfSVenkata Prasad Potturu static struct snd_soc_acpi_codecs amp_max98388 = {
86*ef51cddfSVenkata Prasad Potturu 	.num_codecs = 1,
87*ef51cddfSVenkata Prasad Potturu 	.codecs = {"ADS8388"}
88*ef51cddfSVenkata Prasad Potturu };
89*ef51cddfSVenkata Prasad Potturu 
90f1bdd8d3SAjit Kumar Pandey struct snd_soc_acpi_mach snd_soc_acpi_amd_sof_machines[] = {
91f1bdd8d3SAjit Kumar Pandey 	{
92f4872013SAjit Kumar Pandey 		.id = "10EC5682",
93f4872013SAjit Kumar Pandey 		.drv_name = "rt5682-rt1019",
94f4872013SAjit Kumar Pandey 		.pdata = (void *)&acp_quirk_data,
95f4872013SAjit Kumar Pandey 		.machine_quirk = snd_soc_acpi_codec_list,
96f4872013SAjit Kumar Pandey 		.quirk_data = &amp_rt1019,
97f4872013SAjit Kumar Pandey 		.fw_filename = "sof-rn.ri",
980082e329SAjit Kumar Pandey 		.sof_tplg_filename = "sof-rn-rt5682-rt1019.tplg",
99f4872013SAjit Kumar Pandey 	},
100f4872013SAjit Kumar Pandey 	{
101f4872013SAjit Kumar Pandey 		.id = "10EC5682",
102f4872013SAjit Kumar Pandey 		.drv_name = "rt5682-max",
103f4872013SAjit Kumar Pandey 		.pdata = (void *)&acp_quirk_data,
104f4872013SAjit Kumar Pandey 		.machine_quirk = snd_soc_acpi_codec_list,
105f4872013SAjit Kumar Pandey 		.quirk_data = &amp_max,
106f4872013SAjit Kumar Pandey 		.fw_filename = "sof-rn.ri",
1070082e329SAjit Kumar Pandey 		.sof_tplg_filename = "sof-rn-rt5682-max98360.tplg",
108f4872013SAjit Kumar Pandey 	},
109f4872013SAjit Kumar Pandey 	{
110f4872013SAjit Kumar Pandey 		.id = "RTL5682",
111f4872013SAjit Kumar Pandey 		.drv_name = "rt5682s-max",
112f4872013SAjit Kumar Pandey 		.pdata = (void *)&acp_quirk_data,
113f4872013SAjit Kumar Pandey 		.machine_quirk = snd_soc_acpi_codec_list,
114f4872013SAjit Kumar Pandey 		.quirk_data = &amp_max,
115f4872013SAjit Kumar Pandey 		.fw_filename = "sof-rn.ri",
1160082e329SAjit Kumar Pandey 		.sof_tplg_filename = "sof-rn-rt5682-max98360.tplg",
117f4872013SAjit Kumar Pandey 	},
118f4872013SAjit Kumar Pandey 	{
119330dc183SV sujith kumar Reddy 		.id = "RTL5682",
120330dc183SV sujith kumar Reddy 		.drv_name = "rt5682s-rt1019",
121330dc183SV sujith kumar Reddy 		.pdata = (void *)&acp_quirk_data,
122330dc183SV sujith kumar Reddy 		.machine_quirk = snd_soc_acpi_codec_list,
123330dc183SV sujith kumar Reddy 		.quirk_data = &amp_rt1019,
124330dc183SV sujith kumar Reddy 		.fw_filename = "sof-rn.ri",
125330dc183SV sujith kumar Reddy 		.sof_tplg_filename = "sof-rn-rt5682-rt1019.tplg",
126330dc183SV sujith kumar Reddy 	},
127330dc183SV sujith kumar Reddy 	{
128f1bdd8d3SAjit Kumar Pandey 		.id = "AMDI1019",
129f1bdd8d3SAjit Kumar Pandey 		.drv_name = "renoir-dsp",
130f1bdd8d3SAjit Kumar Pandey 		.pdata = (void *)&acp_quirk_data,
131f1bdd8d3SAjit Kumar Pandey 		.fw_filename = "sof-rn.ri",
132f1bdd8d3SAjit Kumar Pandey 		.sof_tplg_filename = "sof-acp.tplg",
133f1bdd8d3SAjit Kumar Pandey 	},
134f1bdd8d3SAjit Kumar Pandey 	{},
135f1bdd8d3SAjit Kumar Pandey };
136f1bdd8d3SAjit Kumar Pandey EXPORT_SYMBOL(snd_soc_acpi_amd_sof_machines);
137f1bdd8d3SAjit Kumar Pandey 
138*ef51cddfSVenkata Prasad Potturu struct snd_soc_acpi_mach snd_soc_acpi_amd_vangogh_sof_machines[] = {
139*ef51cddfSVenkata Prasad Potturu 	{
140*ef51cddfSVenkata Prasad Potturu 		.id = "NVTN2020",
141*ef51cddfSVenkata Prasad Potturu 		.drv_name = "nau8821-max",
142*ef51cddfSVenkata Prasad Potturu 		.pdata = &acp_quirk_data,
143*ef51cddfSVenkata Prasad Potturu 		.machine_quirk = snd_soc_acpi_codec_list,
144*ef51cddfSVenkata Prasad Potturu 		.quirk_data = &amp_max98388,
145*ef51cddfSVenkata Prasad Potturu 		.fw_filename = "sof-vangogh.ri",
146*ef51cddfSVenkata Prasad Potturu 		.sof_tplg_filename = "sof-vangogh-nau8821-max.tplg",
147*ef51cddfSVenkata Prasad Potturu 	},
148*ef51cddfSVenkata Prasad Potturu 	{},
149*ef51cddfSVenkata Prasad Potturu };
150*ef51cddfSVenkata Prasad Potturu EXPORT_SYMBOL(snd_soc_acpi_amd_vangogh_sof_machines);
151*ef51cddfSVenkata Prasad Potturu 
1520439eb4dSV sujith kumar Reddy struct snd_soc_acpi_mach snd_soc_acpi_amd_rmb_sof_machines[] = {
1530439eb4dSV sujith kumar Reddy 	{
1540439eb4dSV sujith kumar Reddy 		.id = "AMDI1019",
1550439eb4dSV sujith kumar Reddy 		.drv_name = "rmb-dsp",
1560439eb4dSV sujith kumar Reddy 		.pdata = &acp_quirk_data,
1570439eb4dSV sujith kumar Reddy 		.fw_filename = "sof-rmb.ri",
1580439eb4dSV sujith kumar Reddy 		.sof_tplg_filename = "sof-acp-rmb.tplg",
1590439eb4dSV sujith kumar Reddy 	},
1600439eb4dSV sujith kumar Reddy 	{
1610439eb4dSV sujith kumar Reddy 		.id = "10508825",
1620439eb4dSV sujith kumar Reddy 		.drv_name = "nau8825-max",
1630439eb4dSV sujith kumar Reddy 		.pdata = &acp_quirk_data,
1640439eb4dSV sujith kumar Reddy 		.machine_quirk = snd_soc_acpi_codec_list,
1650439eb4dSV sujith kumar Reddy 		.quirk_data = &amp_max,
1660439eb4dSV sujith kumar Reddy 		.fw_filename = "sof-rmb.ri",
1670439eb4dSV sujith kumar Reddy 		.sof_tplg_filename = "sof-rmb-nau8825-max98360.tplg",
1680439eb4dSV sujith kumar Reddy 	},
1694dc6737cSV sujith kumar Reddy 	{
1704dc6737cSV sujith kumar Reddy 		.id = "RTL5682",
1714dc6737cSV sujith kumar Reddy 		.drv_name = "rt5682s-hs-rt1019",
1724dc6737cSV sujith kumar Reddy 		.pdata = &acp_quirk_data,
1734dc6737cSV sujith kumar Reddy 		.machine_quirk = snd_soc_acpi_codec_list,
1744dc6737cSV sujith kumar Reddy 		.quirk_data = &amp_rt1019,
1754dc6737cSV sujith kumar Reddy 		.fw_filename = "sof-rmb.ri",
1764dc6737cSV sujith kumar Reddy 		.sof_tplg_filename = "sof-rmb-rt5682s-rt1019.tplg",
1774dc6737cSV sujith kumar Reddy 	},
1780439eb4dSV sujith kumar Reddy 	{},
1790439eb4dSV sujith kumar Reddy };
1800439eb4dSV sujith kumar Reddy EXPORT_SYMBOL(snd_soc_acpi_amd_rmb_sof_machines);
1810439eb4dSV sujith kumar Reddy 
182f1bdd8d3SAjit Kumar Pandey MODULE_LICENSE("Dual BSD/GPL");
183