1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3 * soc-acpi-intel-cht-match.c - tables and support for CHT ACPI enumeration.
4 *
5 * Copyright (c) 2017, Intel Corporation.
6 */
7
8 #include <linux/dmi.h>
9 #include <sound/soc-acpi.h>
10 #include <sound/soc-acpi-intel-match.h>
11
12 static unsigned long cht_machine_id;
13
14 #define CHT_SURFACE_MACH 1
15
cht_surface_quirk_cb(const struct dmi_system_id * id)16 static int cht_surface_quirk_cb(const struct dmi_system_id *id)
17 {
18 cht_machine_id = CHT_SURFACE_MACH;
19 return 1;
20 }
21
22 static const struct dmi_system_id cht_table[] = {
23 {
24 .callback = cht_surface_quirk_cb,
25 .matches = {
26 DMI_MATCH(DMI_SYS_VENDOR, "Microsoft Corporation"),
27 DMI_MATCH(DMI_PRODUCT_NAME, "Surface 3"),
28 },
29 },
30 { }
31 };
32
33 static struct snd_soc_acpi_mach cht_surface_mach = {
34 .id = "10EC5640",
35 .drv_name = "cht-bsw-rt5645",
36 .fw_filename = "intel/fw_sst_22a8.bin",
37 .board = "cht-bsw",
38 .sof_tplg_filename = "sof-cht-rt5645.tplg",
39 };
40
cht_quirk(void * arg)41 static struct snd_soc_acpi_mach *cht_quirk(void *arg)
42 {
43 struct snd_soc_acpi_mach *mach = arg;
44
45 dmi_check_system(cht_table);
46
47 if (cht_machine_id == CHT_SURFACE_MACH)
48 return &cht_surface_mach;
49 else
50 return mach;
51 }
52
53 /*
54 * Some tablets with Android factory OS have buggy DSDTs with an ESSX8316 device
55 * in the ACPI tables. While they are not using an ESS8316 codec. These DSDTs
56 * also have an ACPI device for the correct codec, ignore the ESSX8316.
57 */
58 static const struct dmi_system_id cht_ess8316_not_present_table[] = {
59 {
60 /* Nextbook Ares 8A */
61 .matches = {
62 DMI_MATCH(DMI_SYS_VENDOR, "Insyde"),
63 DMI_MATCH(DMI_PRODUCT_NAME, "CherryTrail"),
64 DMI_MATCH(DMI_BIOS_VERSION, "M882"),
65 },
66 },
67 { }
68 };
69
cht_ess8316_quirk(void * arg)70 static struct snd_soc_acpi_mach *cht_ess8316_quirk(void *arg)
71 {
72 if (dmi_check_system(cht_ess8316_not_present_table))
73 return NULL;
74
75 return arg;
76 }
77
78 /*
79 * The Lenovo Yoga Tab 3 Pro YT3-X90, with Android factory OS has a buggy DSDT
80 * with the coded not being listed at all.
81 */
82 static const struct dmi_system_id lenovo_yoga_tab3_x90[] = {
83 {
84 /* Lenovo Yoga Tab 3 Pro YT3-X90, codec missing from DSDT */
85 .matches = {
86 DMI_MATCH(DMI_SYS_VENDOR, "Intel Corporation"),
87 DMI_MATCH(DMI_PRODUCT_VERSION, "Blade3-10A-001"),
88 },
89 },
90 { }
91 };
92
93 static struct snd_soc_acpi_mach cht_lenovo_yoga_tab3_x90_mach = {
94 .id = "10WM5102",
95 .drv_name = "bytcr_wm5102",
96 .fw_filename = "intel/fw_sst_22a8.bin",
97 .board = "bytcr_wm5102",
98 .sof_tplg_filename = "sof-cht-wm5102.tplg",
99 };
100
lenovo_yt3_x90_quirk(void * arg)101 static struct snd_soc_acpi_mach *lenovo_yt3_x90_quirk(void *arg)
102 {
103 if (dmi_check_system(lenovo_yoga_tab3_x90))
104 return &cht_lenovo_yoga_tab3_x90_mach;
105
106 /* Skip wildcard match snd_soc_acpi_intel_cherrytrail_machines[] entry */
107 return NULL;
108 }
109
110 static const struct snd_soc_acpi_codecs rt5640_comp_ids = {
111 .num_codecs = 2,
112 .codecs = { "10EC5640", "10EC3276" },
113 };
114
115 static const struct snd_soc_acpi_codecs rt5670_comp_ids = {
116 .num_codecs = 2,
117 .codecs = { "10EC5670", "10EC5672" },
118 };
119
120 static const struct snd_soc_acpi_codecs rt5645_comp_ids = {
121 .num_codecs = 3,
122 .codecs = { "10EC5645", "10EC5650", "10EC3270" },
123 };
124
125 static const struct snd_soc_acpi_codecs da7213_comp_ids = {
126 .num_codecs = 2,
127 .codecs = { "DGLS7212", "DGLS7213"},
128
129 };
130
131 /* Cherryview-based platforms: CherryTrail and Braswell */
132 struct snd_soc_acpi_mach snd_soc_acpi_intel_cherrytrail_machines[] = {
133 {
134 .comp_ids = &rt5670_comp_ids,
135 .drv_name = "cht-bsw-rt5672",
136 .fw_filename = "intel/fw_sst_22a8.bin",
137 .board = "cht-bsw",
138 .sof_tplg_filename = "sof-cht-rt5670.tplg",
139 },
140 {
141 .comp_ids = &rt5645_comp_ids,
142 .drv_name = "cht-bsw-rt5645",
143 .fw_filename = "intel/fw_sst_22a8.bin",
144 .board = "cht-bsw",
145 .sof_tplg_filename = "sof-cht-rt5645.tplg",
146 },
147 {
148 .id = "193C9890",
149 .drv_name = "cht-bsw-max98090",
150 .fw_filename = "intel/fw_sst_22a8.bin",
151 .board = "cht-bsw",
152 .sof_tplg_filename = "sof-cht-max98090.tplg",
153 },
154 {
155 .id = "10508824",
156 .drv_name = "cht-bsw-nau8824",
157 .fw_filename = "intel/fw_sst_22a8.bin",
158 .board = "cht-bsw",
159 .sof_tplg_filename = "sof-cht-nau8824.tplg",
160 },
161 {
162 .comp_ids = &da7213_comp_ids,
163 .drv_name = "bytcht_da7213",
164 .fw_filename = "intel/fw_sst_22a8.bin",
165 .board = "bytcht_da7213",
166 .sof_tplg_filename = "sof-cht-da7213.tplg",
167 },
168 {
169 .id = "ESSX8316",
170 .drv_name = "bytcht_es8316",
171 .fw_filename = "intel/fw_sst_22a8.bin",
172 .board = "bytcht_es8316",
173 .machine_quirk = cht_ess8316_quirk,
174 .sof_tplg_filename = "sof-cht-es8316.tplg",
175 },
176 /* some CHT-T platforms rely on RT5640, use Baytrail machine driver */
177 {
178 .comp_ids = &rt5640_comp_ids,
179 .drv_name = "bytcr_rt5640",
180 .fw_filename = "intel/fw_sst_22a8.bin",
181 .board = "bytcr_rt5640",
182 .machine_quirk = cht_quirk,
183 .sof_tplg_filename = "sof-cht-rt5640.tplg",
184 },
185 {
186 .id = "10EC5682",
187 .drv_name = "sof_rt5682",
188 .sof_tplg_filename = "sof-cht-rt5682.tplg",
189 },
190 /* some CHT-T platforms rely on RT5651, use Baytrail machine driver */
191 {
192 .id = "10EC5651",
193 .drv_name = "bytcr_rt5651",
194 .fw_filename = "intel/fw_sst_22a8.bin",
195 .board = "bytcr_rt5651",
196 .sof_tplg_filename = "sof-cht-rt5651.tplg",
197 },
198 {
199 .id = "14F10720",
200 .drv_name = "bytcht_cx2072x",
201 .fw_filename = "intel/fw_sst_22a8.bin",
202 .board = "bytcht_cx2072x",
203 .sof_tplg_filename = "sof-cht-cx2072x.tplg",
204 },
205 {
206 .id = "104C5122",
207 .drv_name = "sof_pcm512x",
208 .sof_tplg_filename = "sof-cht-src-50khz-pcm512x.tplg",
209 },
210 /*
211 * Special case for the Lenovo Yoga Tab 3 Pro YT3-X90 where the DSDT
212 * misses the codec. Match on the SST id instead, lenovo_yt3_x90_quirk()
213 * will return a YT3 specific mach or NULL when called on other hw,
214 * skipping this entry.
215 */
216 {
217 .id = "808622A8",
218 .machine_quirk = lenovo_yt3_x90_quirk,
219 },
220
221 #if IS_ENABLED(CONFIG_SND_SOC_INTEL_BYT_CHT_NOCODEC_MACH)
222 /*
223 * This is always last in the table so that it is selected only when
224 * enabled explicitly and there is no codec-related information in SSDT
225 */
226 {
227 .id = "808622A8",
228 .drv_name = "bytcht_nocodec",
229 .fw_filename = "intel/fw_sst_22a8.bin",
230 .board = "bytcht_nocodec",
231 },
232 #endif
233 {},
234 };
235 EXPORT_SYMBOL_GPL(snd_soc_acpi_intel_cherrytrail_machines);
236