spi: spi-fsl-qspi: Fix return value check of devm_ioremap() in probe
[linux/fpc-iii.git] / sound / hda / intel-dsp-config.c
blobbe1df80ed01337f40654623cf2e2c78dd824fa24
1 // SPDX-License-Identifier: GPL-2.0
2 // Copyright (c) 2019 Jaroslav Kysela <perex@perex.cz>
4 #include <linux/bits.h>
5 #include <linux/dmi.h>
6 #include <linux/module.h>
7 #include <linux/pci.h>
8 #include <sound/core.h>
9 #include <sound/intel-dsp-config.h>
10 #include <sound/intel-nhlt.h>
12 static int dsp_driver;
14 module_param(dsp_driver, int, 0444);
15 MODULE_PARM_DESC(dsp_driver, "Force the DSP driver for Intel DSP (0=auto, 1=legacy, 2=SST, 3=SOF)");
17 #define FLAG_SST BIT(0)
18 #define FLAG_SOF BIT(1)
19 #define FLAG_SOF_ONLY_IF_DMIC BIT(16)
21 struct config_entry {
22 u32 flags;
23 u16 device;
24 const struct dmi_system_id *dmi_table;
28 * configuration table
29 * - the order of similar PCI ID entries is important!
30 * - the first successful match will win
32 static const struct config_entry config_table[] = {
33 /* Merrifield */
34 #if IS_ENABLED(CONFIG_SND_SOC_SOF_MERRIFIELD)
36 .flags = FLAG_SOF,
37 .device = 0x119a,
39 #endif
40 /* Broxton-T */
41 #if IS_ENABLED(CONFIG_SND_SOC_SOF_APOLLOLAKE)
43 .flags = FLAG_SOF,
44 .device = 0x1a98,
46 #endif
48 * Apollolake (Broxton-P)
49 * the legacy HDaudio driver is used except on Up Squared (SOF) and
50 * Chromebooks (SST)
52 #if IS_ENABLED(CONFIG_SND_SOC_SOF_APOLLOLAKE)
54 .flags = FLAG_SOF,
55 .device = 0x5a98,
56 .dmi_table = (const struct dmi_system_id []) {
58 .ident = "Up Squared",
59 .matches = {
60 DMI_MATCH(DMI_SYS_VENDOR, "AAEON"),
61 DMI_MATCH(DMI_BOARD_NAME, "UP-APL01"),
67 #endif
68 #if IS_ENABLED(CONFIG_SND_SOC_INTEL_APL)
70 .flags = FLAG_SST,
71 .device = 0x5a98,
72 .dmi_table = (const struct dmi_system_id []) {
74 .ident = "Google Chromebooks",
75 .matches = {
76 DMI_MATCH(DMI_SYS_VENDOR, "Google"),
82 #endif
84 * Skylake and Kabylake use legacy HDaudio driver except for Google
85 * Chromebooks (SST)
88 /* Sunrise Point-LP */
89 #if IS_ENABLED(CONFIG_SND_SOC_INTEL_SKL)
91 .flags = FLAG_SST,
92 .device = 0x9d70,
93 .dmi_table = (const struct dmi_system_id []) {
95 .ident = "Google Chromebooks",
96 .matches = {
97 DMI_MATCH(DMI_SYS_VENDOR, "Google"),
103 #endif
104 /* Kabylake-LP */
105 #if IS_ENABLED(CONFIG_SND_SOC_INTEL_KBL)
107 .flags = FLAG_SST,
108 .device = 0x9d71,
109 .dmi_table = (const struct dmi_system_id []) {
111 .ident = "Google Chromebooks",
112 .matches = {
113 DMI_MATCH(DMI_SYS_VENDOR, "Google"),
119 #endif
122 * Geminilake uses legacy HDaudio driver except for Google
123 * Chromebooks
125 /* Geminilake */
126 #if IS_ENABLED(CONFIG_SND_SOC_SOF_GEMINILAKE)
128 .flags = FLAG_SOF,
129 .device = 0x3198,
130 .dmi_table = (const struct dmi_system_id []) {
132 .ident = "Google Chromebooks",
133 .matches = {
134 DMI_MATCH(DMI_SYS_VENDOR, "Google"),
140 #endif
143 * CoffeeLake, CannonLake, CometLake, IceLake, TigerLake use legacy
144 * HDaudio driver except for Google Chromebooks and when DMICs are
145 * present. Two cases are required since Coreboot does not expose NHLT
146 * tables.
148 * When the Chromebook quirk is not present, it's based on information
149 * that no such device exists. When the quirk is present, it could be
150 * either based on product information or a placeholder.
153 /* Cannonlake */
154 #if IS_ENABLED(CONFIG_SND_SOC_SOF_CANNONLAKE)
156 .flags = FLAG_SOF,
157 .device = 0x9dc8,
158 .dmi_table = (const struct dmi_system_id []) {
160 .ident = "Google Chromebooks",
161 .matches = {
162 DMI_MATCH(DMI_SYS_VENDOR, "Google"),
169 .flags = FLAG_SOF | FLAG_SOF_ONLY_IF_DMIC,
170 .device = 0x9dc8,
172 #endif
174 /* Coffelake */
175 #if IS_ENABLED(CONFIG_SND_SOC_SOF_COFFEELAKE)
177 .flags = FLAG_SOF,
178 .device = 0xa348,
179 .dmi_table = (const struct dmi_system_id []) {
181 .ident = "Google Chromebooks",
182 .matches = {
183 DMI_MATCH(DMI_SYS_VENDOR, "Google"),
190 .flags = FLAG_SOF | FLAG_SOF_ONLY_IF_DMIC,
191 .device = 0xa348,
193 #endif
195 /* Cometlake-LP */
196 #if IS_ENABLED(CONFIG_SND_SOC_SOF_COMETLAKE_LP)
198 .flags = FLAG_SOF,
199 .device = 0x02c8,
200 .dmi_table = (const struct dmi_system_id []) {
202 .ident = "Google Chromebooks",
203 .matches = {
204 DMI_MATCH(DMI_SYS_VENDOR, "Google"),
211 .flags = FLAG_SOF | FLAG_SOF_ONLY_IF_DMIC,
212 .device = 0x02c8,
214 #endif
215 /* Cometlake-H */
216 #if IS_ENABLED(CONFIG_SND_SOC_SOF_COMETLAKE_H)
218 .flags = FLAG_SOF | FLAG_SOF_ONLY_IF_DMIC,
219 .device = 0x06c8,
221 #endif
223 /* Icelake */
224 #if IS_ENABLED(CONFIG_SND_SOC_SOF_ICELAKE)
226 .flags = FLAG_SOF,
227 .device = 0x34c8,
228 .dmi_table = (const struct dmi_system_id []) {
230 .ident = "Google Chromebooks",
231 .matches = {
232 DMI_MATCH(DMI_SYS_VENDOR, "Google"),
239 .flags = FLAG_SOF | FLAG_SOF_ONLY_IF_DMIC,
240 .device = 0x34c8,
242 #endif
244 /* Tigerlake */
245 #if IS_ENABLED(CONFIG_SND_SOC_SOF_TIGERLAKE)
247 .flags = FLAG_SOF,
248 .device = 0xa0c8,
249 .dmi_table = (const struct dmi_system_id []) {
251 .ident = "Google Chromebooks",
252 .matches = {
253 DMI_MATCH(DMI_SYS_VENDOR, "Google"),
261 .flags = FLAG_SOF | FLAG_SOF_ONLY_IF_DMIC,
262 .device = 0xa0c8,
264 #endif
266 /* Elkhart Lake */
267 #if IS_ENABLED(CONFIG_SND_SOC_SOF_ELKHARTLAKE)
269 .flags = FLAG_SOF | FLAG_SOF_ONLY_IF_DMIC,
270 .device = 0x4b55,
272 #endif
276 static const struct config_entry *snd_intel_dsp_find_config
277 (struct pci_dev *pci, const struct config_entry *table, u32 len)
279 u16 device;
281 device = pci->device;
282 for (; len > 0; len--, table++) {
283 if (table->device != device)
284 continue;
285 if (table->dmi_table && !dmi_check_system(table->dmi_table))
286 continue;
287 return table;
289 return NULL;
292 static int snd_intel_dsp_check_dmic(struct pci_dev *pci)
294 struct nhlt_acpi_table *nhlt;
295 int ret = 0;
297 nhlt = intel_nhlt_init(&pci->dev);
298 if (nhlt) {
299 if (intel_nhlt_get_dmic_geo(&pci->dev, nhlt))
300 ret = 1;
301 intel_nhlt_free(nhlt);
303 return ret;
306 int snd_intel_dsp_driver_probe(struct pci_dev *pci)
308 const struct config_entry *cfg;
310 /* Intel vendor only */
311 if (pci->vendor != 0x8086)
312 return SND_INTEL_DSP_DRIVER_ANY;
314 if (dsp_driver > 0 && dsp_driver <= SND_INTEL_DSP_DRIVER_LAST)
315 return dsp_driver;
318 * detect DSP by checking class/subclass/prog-id information
319 * class=04 subclass 03 prog-if 00: no DSP, use legacy driver
320 * class=04 subclass 01 prog-if 00: DSP is present
321 * (and may be required e.g. for DMIC or SSP support)
322 * class=04 subclass 03 prog-if 80: use DSP or legacy mode
324 if (pci->class == 0x040300)
325 return SND_INTEL_DSP_DRIVER_LEGACY;
326 if (pci->class != 0x040100 && pci->class != 0x040380) {
327 dev_err(&pci->dev, "Unknown PCI class/subclass/prog-if information (0x%06x) found, selecting HDA legacy driver\n", pci->class);
328 return SND_INTEL_DSP_DRIVER_LEGACY;
331 dev_info(&pci->dev, "DSP detected with PCI class/subclass/prog-if info 0x%06x\n", pci->class);
333 /* find the configuration for the specific device */
334 cfg = snd_intel_dsp_find_config(pci, config_table, ARRAY_SIZE(config_table));
335 if (!cfg)
336 return SND_INTEL_DSP_DRIVER_ANY;
338 if (cfg->flags & FLAG_SOF) {
339 if (cfg->flags & FLAG_SOF_ONLY_IF_DMIC) {
340 if (snd_intel_dsp_check_dmic(pci)) {
341 dev_info(&pci->dev, "Digital mics found on Skylake+ platform, using SOF driver\n");
342 return SND_INTEL_DSP_DRIVER_SOF;
344 } else {
345 return SND_INTEL_DSP_DRIVER_SOF;
349 if (cfg->flags & FLAG_SST)
350 return SND_INTEL_DSP_DRIVER_SST;
352 return SND_INTEL_DSP_DRIVER_LEGACY;
354 EXPORT_SYMBOL_GPL(snd_intel_dsp_driver_probe);
356 MODULE_LICENSE("GPL v2");
357 MODULE_DESCRIPTION("Intel DSP config driver");