1 /*
2  * soc-apci-intel-cht-match.c - tables and support for CHT ACPI enumeration.
3  *
4  * Copyright (c) 2017, Intel Corporation.
5  *
6  *
7  * This program is free software; you can redistribute it and/or modify it
8  * under the terms and conditions of the GNU General Public License,
9  * version 2, as published by the Free Software Foundation.
10  *
11  * This program is distributed in the hope it will be useful, but WITHOUT
12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
14  * more details.
15  */
16 
17 #include <linux/dmi.h>
18 #include <sound/soc-acpi.h>
19 #include <sound/soc-acpi-intel-match.h>
20 
21 static unsigned long cht_machine_id;
22 
23 #define CHT_SURFACE_MACH 1
24 
25 static int cht_surface_quirk_cb(const struct dmi_system_id *id)
26 {
27 	cht_machine_id = CHT_SURFACE_MACH;
28 	return 1;
29 }
30 
31 static const struct dmi_system_id cht_table[] = {
32 	{
33 		.callback = cht_surface_quirk_cb,
34 		.matches = {
35 			DMI_MATCH(DMI_SYS_VENDOR, "Microsoft Corporation"),
36 			DMI_MATCH(DMI_PRODUCT_NAME, "Surface 3"),
37 		},
38 	},
39 	{ }
40 };
41 
42 static struct snd_soc_acpi_mach cht_surface_mach = {
43 	.id = "10EC5640",
44 	.drv_name = "cht-bsw-rt5645",
45 	.fw_filename = "intel/fw_sst_22a8.bin",
46 	.board = "cht-bsw",
47 	.sof_fw_filename = "sof-cht.ri",
48 	.sof_tplg_filename = "sof-cht-rt5645.tplg",
49 };
50 
51 static struct snd_soc_acpi_mach *cht_quirk(void *arg)
52 {
53 	struct snd_soc_acpi_mach *mach = arg;
54 
55 	dmi_check_system(cht_table);
56 
57 	if (cht_machine_id == CHT_SURFACE_MACH)
58 		return &cht_surface_mach;
59 	else
60 		return mach;
61 }
62 
63 /* Cherryview-based platforms: CherryTrail and Braswell */
64 struct snd_soc_acpi_mach  snd_soc_acpi_intel_cherrytrail_machines[] = {
65 	{
66 		.id = "10EC5670",
67 		.drv_name = "cht-bsw-rt5672",
68 		.fw_filename = "intel/fw_sst_22a8.bin",
69 		.board = "cht-bsw",
70 		.sof_fw_filename = "sof-cht.ri",
71 		.sof_tplg_filename = "sof-cht-rt5670.tplg",
72 	},
73 	{
74 		.id = "10EC5672",
75 		.drv_name = "cht-bsw-rt5672",
76 		.fw_filename = "intel/fw_sst_22a8.bin",
77 		.board = "cht-bsw",
78 		.sof_fw_filename = "sof-cht.ri",
79 		.sof_tplg_filename = "sof-cht-rt5670.tplg",
80 	},
81 	{
82 		.id = "10EC5645",
83 		.drv_name = "cht-bsw-rt5645",
84 		.fw_filename = "intel/fw_sst_22a8.bin",
85 		.board = "cht-bsw",
86 		.sof_fw_filename = "sof-cht.ri",
87 		.sof_tplg_filename = "sof-cht-rt5645.tplg",
88 	},
89 	{
90 		.id = "10EC5650",
91 		.drv_name = "cht-bsw-rt5645",
92 		.fw_filename = "intel/fw_sst_22a8.bin",
93 		.board = "cht-bsw",
94 		.sof_fw_filename = "sof-cht.ri",
95 		.sof_tplg_filename = "sof-cht-rt5645.tplg",
96 	},
97 	{
98 		.id = "10EC3270",
99 		.drv_name = "cht-bsw-rt5645",
100 		.fw_filename = "intel/fw_sst_22a8.bin",
101 		.board = "cht-bsw",
102 		.sof_fw_filename = "sof-cht.ri",
103 		.sof_tplg_filename = "sof-cht-rt5645.tplg",
104 	},
105 	{
106 		.id = "193C9890",
107 		.drv_name = "cht-bsw-max98090",
108 		.fw_filename = "intel/fw_sst_22a8.bin",
109 		.board = "cht-bsw",
110 		.sof_fw_filename = "sof-cht.ri",
111 		.sof_tplg_filename = "sof-cht-max98090.tplg",
112 	},
113 	{
114 		.id = "10508824",
115 		.drv_name = "cht-bsw-nau8824",
116 		.fw_filename = "intel/fw_sst_22a8.bin",
117 		.board = "cht-bsw",
118 		.sof_fw_filename = "sof-cht.ri",
119 		.sof_tplg_filename = "sof-cht-nau8824.tplg",
120 	},
121 	{
122 		.id = "DLGS7212",
123 		.drv_name = "bytcht_da7213",
124 		.fw_filename = "intel/fw_sst_22a8.bin",
125 		.board = "bytcht_da7213",
126 		.sof_fw_filename = "sof-cht.ri",
127 		.sof_tplg_filename = "sof-cht-da7213.tplg",
128 	},
129 	{
130 		.id = "DLGS7213",
131 		.drv_name = "bytcht_da7213",
132 		.fw_filename = "intel/fw_sst_22a8.bin",
133 		.board = "bytcht_da7213",
134 		.sof_fw_filename = "sof-cht.ri",
135 		.sof_tplg_filename = "sof-cht-da7213.tplg",
136 	},
137 	{
138 		.id = "ESSX8316",
139 		.drv_name = "bytcht_es8316",
140 		.fw_filename = "intel/fw_sst_22a8.bin",
141 		.board = "bytcht_es8316",
142 		.sof_fw_filename = "sof-cht.ri",
143 		.sof_tplg_filename = "sof-cht-es8316.tplg",
144 	},
145 	/* some CHT-T platforms rely on RT5640, use Baytrail machine driver */
146 	{
147 		.id = "10EC5640",
148 		.drv_name = "bytcr_rt5640",
149 		.fw_filename = "intel/fw_sst_22a8.bin",
150 		.board = "bytcr_rt5640",
151 		.machine_quirk = cht_quirk,
152 		.sof_fw_filename = "sof-cht.ri",
153 		.sof_tplg_filename = "sof-cht-rt5640.tplg",
154 	},
155 	{
156 		.id = "10EC3276",
157 		.drv_name = "bytcr_rt5640",
158 		.fw_filename = "intel/fw_sst_22a8.bin",
159 		.board = "bytcr_rt5640",
160 		.sof_fw_filename = "sof-cht.ri",
161 		.sof_tplg_filename = "sof-cht-rt5640.tplg",
162 	},
163 	{
164 		.id = "10EC5682",
165 		.drv_name = "sof_rt5682",
166 		.sof_fw_filename = "sof-cht.ri",
167 		.sof_tplg_filename = "sof-cht-rt5682.tplg",
168 	},
169 	/* some CHT-T platforms rely on RT5651, use Baytrail machine driver */
170 	{
171 		.id = "10EC5651",
172 		.drv_name = "bytcr_rt5651",
173 		.fw_filename = "intel/fw_sst_22a8.bin",
174 		.board = "bytcr_rt5651",
175 		.sof_fw_filename = "sof-cht.ri",
176 		.sof_tplg_filename = "sof-cht-rt5651.tplg",
177 	},
178 #if IS_ENABLED(CONFIG_SND_SOC_INTEL_BYT_CHT_NOCODEC_MACH)
179 	/*
180 	 * This is always last in the table so that it is selected only when
181 	 * enabled explicitly and there is no codec-related information in SSDT
182 	 */
183 	{
184 		.id = "808622A8",
185 		.drv_name = "bytcht_nocodec",
186 		.fw_filename = "intel/fw_sst_22a8.bin",
187 		.board = "bytcht_nocodec",
188 	},
189 #endif
190 	{},
191 };
192 EXPORT_SYMBOL_GPL(snd_soc_acpi_intel_cherrytrail_machines);
193 
194 MODULE_LICENSE("GPL v2");
195 MODULE_DESCRIPTION("Intel Common ACPI Match module");
196