xref: /linux/sound/soc/sof/intel/hda.c (revision c31f4aa8fed048fa70e742c4bb49bb48dc489ab3)
1 // SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause)
2 //
3 // This file is provided under a dual BSD/GPLv2 license.  When using or
4 // redistributing this file, you may do so under either license.
5 //
6 // Copyright(c) 2018 Intel Corporation
7 //
8 // Authors: Liam Girdwood <liam.r.girdwood@linux.intel.com>
9 //	    Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
10 //	    Rander Wang <rander.wang@intel.com>
11 //          Keyon Jie <yang.jie@linux.intel.com>
12 //
13 
14 /*
15  * Hardware interface for generic Intel audio DSP HDA IP
16  */
17 
18 #include <sound/hdaudio_ext.h>
19 #include <sound/hda_register.h>
20 
21 #include <linux/acpi.h>
22 #include <linux/debugfs.h>
23 #include <linux/module.h>
24 #include <linux/soundwire/sdw.h>
25 #include <linux/soundwire/sdw_intel.h>
26 #include <sound/intel-dsp-config.h>
27 #include <sound/intel-nhlt.h>
28 #include <sound/soc-acpi-intel-ssp-common.h>
29 #include <sound/soc_sdw_utils.h>
30 #include <sound/sof.h>
31 #include <sound/sof/xtensa.h>
32 #include <sound/hda-mlink.h>
33 #include "../sof-audio.h"
34 #include "../sof-pci-dev.h"
35 #include "../ops.h"
36 #include "../ipc4-topology.h"
37 #include "../../intel/common/sof-function-topology-lib.h"
38 #include "hda.h"
39 
40 #include <trace/events/sof_intel.h>
41 
42 #if IS_ENABLED(CONFIG_SND_SOC_SOF_HDA)
43 #include <sound/soc-acpi-intel-match.h>
44 #endif
45 
46 /* platform specific devices */
47 #include "shim.h"
48 
49 #if IS_ENABLED(CONFIG_SND_SOC_SOF_INTEL_SOUNDWIRE)
50 
51 /*
52  * The default for SoundWire clock stop quirks is to power gate the IP
53  * and do a Bus Reset, this will need to be modified when the DSP
54  * needs to remain in D0i3 so that the Master does not lose context
55  * and enumeration is not required on clock restart
56  */
57 static int sdw_clock_stop_quirks = SDW_INTEL_CLK_STOP_BUS_RESET;
58 module_param(sdw_clock_stop_quirks, int, 0444);
59 MODULE_PARM_DESC(sdw_clock_stop_quirks, "SOF SoundWire clock stop quirks");
60 
61 static int sdw_params_stream(struct device *dev,
62 			     struct sdw_intel_stream_params_data *params_data)
63 {
64 	struct snd_soc_dai *d = params_data->dai;
65 	struct snd_soc_dapm_widget *w = snd_soc_dai_get_widget(d, params_data->substream->stream);
66 	struct snd_sof_dai_config_data data = { 0 };
67 
68 	if (!w) {
69 		dev_err(dev, "%s widget not found, check amp link num in the topology\n",
70 			d->name);
71 		return -EINVAL;
72 	}
73 	data.dai_index = (params_data->link_id << 8) | d->id;
74 	data.dai_data = params_data->alh_stream_id;
75 	data.dai_node_id = data.dai_data;
76 
77 	return hda_dai_config(w, SOF_DAI_CONFIG_FLAGS_HW_PARAMS, &data);
78 }
79 
80 static int sdw_params_free(struct device *dev, struct sdw_intel_stream_free_data *free_data)
81 {
82 	struct snd_soc_dai *d = free_data->dai;
83 	struct snd_soc_dapm_widget *w = snd_soc_dai_get_widget(d, free_data->substream->stream);
84 	struct snd_sof_dev *sdev = widget_to_sdev(w);
85 
86 	if (sdev->pdata->ipc_type == SOF_IPC_TYPE_4) {
87 		struct snd_sof_widget *swidget = w->dobj.private;
88 		struct snd_sof_dai *dai = swidget->private;
89 		struct sof_ipc4_copier_data *copier_data;
90 		struct sof_ipc4_copier *ipc4_copier;
91 
92 		ipc4_copier = dai->private;
93 		ipc4_copier->dai_index = 0;
94 		copier_data = &ipc4_copier->data;
95 
96 		/* clear the node ID */
97 		copier_data->gtw_cfg.node_id &= ~SOF_IPC4_NODE_INDEX_MASK;
98 	}
99 
100 	return 0;
101 }
102 
103 struct sdw_intel_ops sdw_callback = {
104 	.params_stream = sdw_params_stream,
105 	.free_stream = sdw_params_free,
106 };
107 
108 static int sdw_ace2x_params_stream(struct device *dev,
109 				   struct sdw_intel_stream_params_data *params_data)
110 {
111 	return sdw_hda_dai_hw_params(params_data->substream,
112 				     params_data->hw_params,
113 				     params_data->dai,
114 				     params_data->link_id,
115 				     params_data->alh_stream_id);
116 }
117 
118 static int sdw_ace2x_free_stream(struct device *dev,
119 				 struct sdw_intel_stream_free_data *free_data)
120 {
121 	return sdw_hda_dai_hw_free(free_data->substream,
122 				   free_data->dai,
123 				   free_data->link_id);
124 }
125 
126 static int sdw_ace2x_trigger(struct snd_pcm_substream *substream, int cmd, struct snd_soc_dai *dai)
127 {
128 	return sdw_hda_dai_trigger(substream, cmd, dai);
129 }
130 
131 static struct sdw_intel_ops sdw_ace2x_callback = {
132 	.params_stream = sdw_ace2x_params_stream,
133 	.free_stream = sdw_ace2x_free_stream,
134 	.trigger = sdw_ace2x_trigger,
135 };
136 
137 static int hda_sdw_acpi_scan(struct snd_sof_dev *sdev)
138 {
139 	u32 interface_mask = hda_get_interface_mask(sdev);
140 	struct sof_intel_hda_dev *hdev;
141 	acpi_handle handle;
142 	int ret;
143 
144 	if (!(interface_mask & BIT(SOF_DAI_INTEL_ALH)))
145 		return -EINVAL;
146 
147 	handle = ACPI_HANDLE(sdev->dev);
148 
149 	/* save ACPI info for the probe step */
150 	hdev = sdev->pdata->hw_pdata;
151 
152 	ret = sdw_intel_acpi_scan(handle, &hdev->info);
153 	if (ret < 0)
154 		return -EINVAL;
155 
156 	return 0;
157 }
158 
159 static int hda_sdw_probe(struct snd_sof_dev *sdev)
160 {
161 	const struct sof_intel_dsp_desc *chip;
162 	struct sof_intel_hda_dev *hdev;
163 	struct sdw_intel_res res;
164 	void *sdw;
165 
166 	hdev = sdev->pdata->hw_pdata;
167 
168 	memset(&res, 0, sizeof(res));
169 
170 	chip = get_chip_info(sdev->pdata);
171 	if (chip->hw_ip_version < SOF_INTEL_ACE_2_0) {
172 		res.mmio_base = sdev->bar[HDA_DSP_BAR];
173 		res.hw_ops = &sdw_intel_cnl_hw_ops;
174 		res.shim_base = hdev->desc->sdw_shim_base;
175 		res.alh_base = hdev->desc->sdw_alh_base;
176 		res.ext = false;
177 		res.ops = &sdw_callback;
178 	} else {
179 		/*
180 		 * retrieve eml_lock needed to protect shared registers
181 		 * in the HDaudio multi-link areas
182 		 */
183 		res.eml_lock = hdac_bus_eml_get_mutex(sof_to_bus(sdev), true,
184 						      AZX_REG_ML_LEPTR_ID_SDW);
185 		if (!res.eml_lock)
186 			return -ENODEV;
187 
188 		res.mmio_base = sdev->bar[HDA_DSP_HDA_BAR];
189 		/*
190 		 * the SHIM and SoundWire register offsets are link-specific
191 		 * and will be determined when adding auxiliary devices
192 		 */
193 		res.hw_ops = &sdw_intel_lnl_hw_ops;
194 		res.ext = true;
195 		res.ops = &sdw_ace2x_callback;
196 
197 		/* ACE3+ supports microphone privacy */
198 		if (chip->hw_ip_version >= SOF_INTEL_ACE_3_0)
199 			res.mic_privacy = true;
200 	}
201 	res.irq = sdev->ipc_irq;
202 	res.handle = hdev->info.handle;
203 	res.parent = sdev->dev;
204 
205 	res.dev = sdev->dev;
206 	res.clock_stop_quirks = sdw_clock_stop_quirks;
207 	res.hbus = sof_to_bus(sdev);
208 
209 	/*
210 	 * ops and arg fields are not populated for now,
211 	 * they will be needed when the DAI callbacks are
212 	 * provided
213 	 */
214 
215 	/* we could filter links here if needed, e.g for quirks */
216 	res.count = hdev->info.count;
217 	res.link_mask = hdev->info.link_mask;
218 
219 	sdw = sdw_intel_probe(&res);
220 	if (!sdw) {
221 		dev_err(sdev->dev, "error: SoundWire probe failed\n");
222 		return -EINVAL;
223 	}
224 
225 	/* save context */
226 	hdev->sdw = sdw;
227 
228 	return 0;
229 }
230 
231 int hda_sdw_startup(struct snd_sof_dev *sdev)
232 {
233 	struct sof_intel_hda_dev *hdev;
234 	struct snd_sof_pdata *pdata = sdev->pdata;
235 	int ret;
236 
237 	hdev = sdev->pdata->hw_pdata;
238 
239 	if (!hdev->sdw)
240 		return 0;
241 
242 	if (pdata->machine && !pdata->machine->mach_params.link_mask)
243 		return 0;
244 
245 	ret = hda_sdw_check_lcount(sdev);
246 	if (ret < 0)
247 		return ret;
248 
249 	return sdw_intel_startup(hdev->sdw);
250 }
251 EXPORT_SYMBOL_NS(hda_sdw_startup, "SND_SOC_SOF_INTEL_HDA_GENERIC");
252 
253 static int hda_sdw_exit(struct snd_sof_dev *sdev)
254 {
255 	struct sof_intel_hda_dev *hdev;
256 
257 	hdev = sdev->pdata->hw_pdata;
258 
259 	if (hdev->sdw)
260 		sdw_intel_exit(hdev->sdw);
261 	hdev->sdw = NULL;
262 
263 	hda_sdw_int_enable(sdev, false);
264 
265 	return 0;
266 }
267 
268 bool hda_common_check_sdw_irq(struct snd_sof_dev *sdev)
269 {
270 	struct sof_intel_hda_dev *hdev;
271 	bool ret = false;
272 	u32 irq_status;
273 
274 	hdev = sdev->pdata->hw_pdata;
275 
276 	if (!hdev->sdw)
277 		return ret;
278 
279 	/* store status */
280 	irq_status = snd_sof_dsp_read(sdev, HDA_DSP_BAR, HDA_DSP_REG_ADSPIS2);
281 
282 	/* invalid message ? */
283 	if (irq_status == 0xffffffff)
284 		goto out;
285 
286 	/* SDW message ? */
287 	if (irq_status & HDA_DSP_REG_ADSPIS2_SNDW)
288 		ret = true;
289 
290 out:
291 	return ret;
292 }
293 EXPORT_SYMBOL_NS(hda_common_check_sdw_irq, "SND_SOC_SOF_INTEL_HDA_GENERIC");
294 
295 static bool hda_dsp_check_sdw_irq(struct snd_sof_dev *sdev)
296 {
297 	u32 interface_mask = hda_get_interface_mask(sdev);
298 	const struct sof_intel_dsp_desc *chip;
299 
300 	if (!(interface_mask & BIT(SOF_DAI_INTEL_ALH)))
301 		return false;
302 
303 	chip = get_chip_info(sdev->pdata);
304 	if (chip && chip->check_sdw_irq)
305 		return chip->check_sdw_irq(sdev);
306 
307 	return false;
308 }
309 
310 static irqreturn_t hda_dsp_sdw_thread(int irq, void *context)
311 {
312 	return sdw_intel_thread(irq, context);
313 }
314 
315 bool hda_sdw_check_wakeen_irq_common(struct snd_sof_dev *sdev)
316 {
317 	struct sof_intel_hda_dev *hdev;
318 
319 	hdev = sdev->pdata->hw_pdata;
320 	if (hdev->sdw &&
321 	    snd_sof_dsp_read(sdev, HDA_DSP_BAR,
322 			     hdev->desc->sdw_shim_base + SDW_SHIM_WAKESTS))
323 		return true;
324 
325 	return false;
326 }
327 EXPORT_SYMBOL_NS(hda_sdw_check_wakeen_irq_common, "SND_SOC_SOF_INTEL_HDA_GENERIC");
328 
329 static bool hda_sdw_check_wakeen_irq(struct snd_sof_dev *sdev)
330 {
331 	u32 interface_mask = hda_get_interface_mask(sdev);
332 	const struct sof_intel_dsp_desc *chip;
333 
334 	if (!(interface_mask & BIT(SOF_DAI_INTEL_ALH)))
335 		return false;
336 
337 	chip = get_chip_info(sdev->pdata);
338 	if (chip && chip->check_sdw_wakeen_irq)
339 		return chip->check_sdw_wakeen_irq(sdev);
340 
341 	return false;
342 }
343 
344 void hda_sdw_process_wakeen_common(struct snd_sof_dev *sdev)
345 {
346 	u32 interface_mask = hda_get_interface_mask(sdev);
347 	struct sof_intel_hda_dev *hdev;
348 
349 	if (!(interface_mask & BIT(SOF_DAI_INTEL_ALH)))
350 		return;
351 
352 	hdev = sdev->pdata->hw_pdata;
353 	if (!hdev->sdw)
354 		return;
355 
356 	sdw_intel_process_wakeen_event(hdev->sdw);
357 }
358 EXPORT_SYMBOL_NS(hda_sdw_process_wakeen_common, "SND_SOC_SOF_INTEL_HDA_GENERIC");
359 
360 static bool hda_dsp_sdw_check_mic_privacy_irq(struct snd_sof_dev *sdev)
361 {
362 	const struct sof_intel_dsp_desc *chip;
363 
364 	chip = get_chip_info(sdev->pdata);
365 	if (chip && chip->check_mic_privacy_irq)
366 		return chip->check_mic_privacy_irq(sdev, true,
367 						   AZX_REG_ML_LEPTR_ID_SDW);
368 
369 	return false;
370 }
371 
372 static void hda_dsp_sdw_process_mic_privacy(struct snd_sof_dev *sdev)
373 {
374 	const struct sof_intel_dsp_desc *chip;
375 
376 	chip = get_chip_info(sdev->pdata);
377 	if (chip && chip->process_mic_privacy)
378 		chip->process_mic_privacy(sdev, true, AZX_REG_ML_LEPTR_ID_SDW);
379 }
380 
381 #else /* IS_ENABLED(CONFIG_SND_SOC_SOF_INTEL_SOUNDWIRE) */
382 static inline int hda_sdw_acpi_scan(struct snd_sof_dev *sdev)
383 {
384 	return 0;
385 }
386 
387 static inline int hda_sdw_probe(struct snd_sof_dev *sdev)
388 {
389 	return 0;
390 }
391 
392 static inline int hda_sdw_exit(struct snd_sof_dev *sdev)
393 {
394 	return 0;
395 }
396 
397 static inline bool hda_dsp_check_sdw_irq(struct snd_sof_dev *sdev)
398 {
399 	return false;
400 }
401 
402 static inline irqreturn_t hda_dsp_sdw_thread(int irq, void *context)
403 {
404 	return IRQ_HANDLED;
405 }
406 
407 static inline bool hda_sdw_check_wakeen_irq(struct snd_sof_dev *sdev)
408 {
409 	return false;
410 }
411 
412 static inline bool hda_dsp_sdw_check_mic_privacy_irq(struct snd_sof_dev *sdev)
413 {
414 	return false;
415 }
416 
417 static inline void hda_dsp_sdw_process_mic_privacy(struct snd_sof_dev *sdev) { }
418 
419 #endif /* IS_ENABLED(CONFIG_SND_SOC_SOF_INTEL_SOUNDWIRE) */
420 
421 /* pre fw run operations */
422 int hda_dsp_pre_fw_run(struct snd_sof_dev *sdev)
423 {
424 	/* disable clock gating and power gating */
425 	return hda_dsp_ctrl_clock_power_gating(sdev, false);
426 }
427 
428 /* post fw run operations */
429 int hda_dsp_post_fw_run(struct snd_sof_dev *sdev)
430 {
431 	int ret;
432 
433 	if (sdev->first_boot) {
434 		struct sof_intel_hda_dev *hdev = sdev->pdata->hw_pdata;
435 
436 		ret = hda_sdw_startup(sdev);
437 		if (ret < 0) {
438 			dev_err(sdev->dev,
439 				"error: could not startup SoundWire links\n");
440 			return ret;
441 		}
442 
443 		/* Check if IMR boot is usable */
444 		if (!sof_debug_check_flag(SOF_DBG_IGNORE_D3_PERSISTENT) &&
445 		    (sdev->fw_ready.flags & SOF_IPC_INFO_D3_PERSISTENT ||
446 		     sdev->pdata->ipc_type == SOF_IPC_TYPE_4)) {
447 			hdev->imrboot_supported = true;
448 			debugfs_create_bool("skip_imr_boot",
449 					    0644, sdev->debugfs_root,
450 					    &hdev->skip_imr_boot);
451 		}
452 	}
453 
454 	hda_sdw_int_enable(sdev, true);
455 
456 	/* re-enable clock gating and power gating */
457 	return hda_dsp_ctrl_clock_power_gating(sdev, true);
458 }
459 EXPORT_SYMBOL_NS(hda_dsp_post_fw_run, "SND_SOC_SOF_INTEL_HDA_GENERIC");
460 
461 /*
462  * Debug
463  */
464 
465 #if IS_ENABLED(CONFIG_SND_SOC_SOF_DEBUG)
466 static bool hda_use_msi = true;
467 module_param_named(use_msi, hda_use_msi, bool, 0444);
468 MODULE_PARM_DESC(use_msi, "SOF HDA use PCI MSI mode");
469 #else
470 #define hda_use_msi	(1)
471 #endif
472 
473 static char *hda_model;
474 module_param(hda_model, charp, 0444);
475 MODULE_PARM_DESC(hda_model, "Use the given HDA board model.");
476 
477 static int dmic_num_override = -1;
478 module_param_named(dmic_num, dmic_num_override, int, 0444);
479 MODULE_PARM_DESC(dmic_num, "SOF HDA DMIC number");
480 
481 static int mclk_id_override = -1;
482 module_param_named(mclk_id, mclk_id_override, int, 0444);
483 MODULE_PARM_DESC(mclk_id, "SOF SSP mclk_id");
484 
485 static int bt_link_mask_override;
486 module_param_named(bt_link_mask, bt_link_mask_override, int, 0444);
487 MODULE_PARM_DESC(bt_link_mask, "SOF BT offload link mask");
488 
489 static int hda_init(struct snd_sof_dev *sdev)
490 {
491 	struct hda_bus *hbus;
492 	struct hdac_bus *bus;
493 	struct pci_dev *pci = to_pci_dev(sdev->dev);
494 	int ret;
495 
496 	hbus = sof_to_hbus(sdev);
497 	bus = sof_to_bus(sdev);
498 
499 	/* HDA bus init */
500 	sof_hda_bus_init(sdev, &pci->dev);
501 
502 	if (sof_hda_position_quirk == SOF_HDA_POSITION_QUIRK_USE_DPIB_REGISTERS)
503 		bus->use_posbuf = 0;
504 	else
505 		bus->use_posbuf = 1;
506 	bus->bdl_pos_adj = 0;
507 	bus->sync_write = 1;
508 
509 	mutex_init(&hbus->prepare_mutex);
510 	hbus->pci = pci;
511 	hbus->mixer_assigned = -1;
512 	hbus->modelname = hda_model;
513 
514 	/* initialise hdac bus */
515 	bus->addr = pci_resource_start(pci, 0);
516 	bus->remap_addr = pci_ioremap_bar(pci, 0);
517 	if (!bus->remap_addr) {
518 		dev_err(bus->dev, "error: ioremap error\n");
519 		return -ENXIO;
520 	}
521 
522 	/* HDA base */
523 	sdev->bar[HDA_DSP_HDA_BAR] = bus->remap_addr;
524 
525 	/* init i915 and HDMI codecs */
526 	ret = hda_codec_i915_init(sdev);
527 	if (ret < 0 && ret != -ENODEV) {
528 		dev_err_probe(sdev->dev, ret, "init of i915 and HDMI codec failed\n");
529 		goto out;
530 	}
531 
532 	/* get controller capabilities */
533 	ret = hda_dsp_ctrl_get_caps(sdev);
534 	if (ret < 0) {
535 		dev_err(sdev->dev, "error: get caps error\n");
536 		hda_codec_i915_exit(sdev);
537 	}
538 
539 out:
540 	if (ret < 0)
541 		iounmap(sof_to_bus(sdev)->remap_addr);
542 
543 	return ret;
544 }
545 
546 static int check_dmic_num(struct snd_sof_dev *sdev)
547 {
548 	struct sof_intel_hda_dev *hdev = sdev->pdata->hw_pdata;
549 	struct nhlt_acpi_table *nhlt;
550 	int dmic_num = 0;
551 
552 	nhlt = hdev->nhlt;
553 	if (nhlt)
554 		dmic_num = intel_nhlt_get_dmic_geo(sdev->dev, nhlt);
555 
556 	dev_info(sdev->dev, "DMICs detected in NHLT tables: %d\n", dmic_num);
557 
558 	/* allow for module parameter override */
559 	if (dmic_num_override != -1) {
560 		dev_dbg(sdev->dev,
561 			"overriding DMICs detected in NHLT tables %d by kernel param %d\n",
562 			dmic_num, dmic_num_override);
563 		dmic_num = dmic_num_override;
564 	}
565 
566 	if (dmic_num < 0 || dmic_num > 4) {
567 		dev_dbg(sdev->dev, "invalid dmic_number %d\n", dmic_num);
568 		dmic_num = 0;
569 	}
570 
571 	return dmic_num;
572 }
573 
574 static int check_nhlt_ssp_mask(struct snd_sof_dev *sdev, u8 device_type)
575 {
576 	struct sof_intel_hda_dev *hdev = sdev->pdata->hw_pdata;
577 	struct nhlt_acpi_table *nhlt;
578 	int ssp_mask = 0;
579 
580 	nhlt = hdev->nhlt;
581 	if (!nhlt)
582 		return ssp_mask;
583 
584 	if (intel_nhlt_has_endpoint_type(nhlt, NHLT_LINK_SSP)) {
585 		ssp_mask = intel_nhlt_ssp_endpoint_mask(nhlt, device_type);
586 		if (ssp_mask)
587 			dev_info(sdev->dev, "NHLT device %s(%d) detected, ssp_mask %#x\n",
588 				 device_type == NHLT_DEVICE_BT ? "BT" : "I2S",
589 				 device_type, ssp_mask);
590 	}
591 
592 	return ssp_mask;
593 }
594 
595 static int check_nhlt_ssp_mclk_mask(struct snd_sof_dev *sdev, int ssp_num)
596 {
597 	struct sof_intel_hda_dev *hdev = sdev->pdata->hw_pdata;
598 	struct nhlt_acpi_table *nhlt;
599 
600 	nhlt = hdev->nhlt;
601 	if (!nhlt)
602 		return 0;
603 
604 	return intel_nhlt_ssp_mclk_mask(nhlt, ssp_num);
605 }
606 
607 static int hda_init_caps(struct snd_sof_dev *sdev)
608 {
609 	u32 interface_mask = hda_get_interface_mask(sdev);
610 	struct hdac_bus *bus = sof_to_bus(sdev);
611 	struct snd_sof_pdata *pdata = sdev->pdata;
612 	struct sof_intel_hda_dev *hdev = pdata->hw_pdata;
613 	u32 link_mask;
614 	int ret = 0;
615 
616 	/* check if dsp is there */
617 	if (bus->ppcap)
618 		dev_dbg(sdev->dev, "PP capability, will probe DSP later.\n");
619 
620 	/* Init HDA controller after i915 init */
621 	ret = hda_dsp_ctrl_init_chip(sdev, true);
622 	if (ret < 0) {
623 		dev_err(bus->dev, "error: init chip failed with ret: %d\n",
624 			ret);
625 		return ret;
626 	}
627 
628 	hda_bus_ml_init(bus);
629 
630 	/* Skip SoundWire if it is not supported */
631 	if (!(interface_mask & BIT(SOF_DAI_INTEL_ALH)))
632 		goto skip_soundwire;
633 
634 	/* Skip SoundWire in nocodec mode */
635 	if (IS_ENABLED(CONFIG_SND_SOC_SOF_NOCODEC_DEBUG_SUPPORT) &&
636 	    sof_debug_check_flag(SOF_DBG_FORCE_NOCODEC))
637 		goto skip_soundwire;
638 
639 	/* scan SoundWire capabilities exposed by DSDT */
640 	ret = hda_sdw_acpi_scan(sdev);
641 	if (ret < 0) {
642 		dev_dbg(sdev->dev, "skipping SoundWire, not detected with ACPI scan\n");
643 		goto skip_soundwire;
644 	}
645 
646 	link_mask = hdev->info.link_mask;
647 	if (!link_mask) {
648 		dev_dbg(sdev->dev, "skipping SoundWire, no links enabled\n");
649 		goto skip_soundwire;
650 	}
651 
652 	/*
653 	 * probe/allocate SoundWire resources.
654 	 * The hardware configuration takes place in hda_sdw_startup
655 	 * after power rails are enabled.
656 	 * It's entirely possible to have a mix of I2S/DMIC/SoundWire
657 	 * devices, so we allocate the resources in all cases.
658 	 */
659 	ret = hda_sdw_probe(sdev);
660 	if (ret < 0) {
661 		dev_err(sdev->dev, "error: SoundWire probe error\n");
662 		return ret;
663 	}
664 
665 skip_soundwire:
666 
667 	/* create codec instances */
668 	hda_codec_probe_bus(sdev);
669 
670 	if (!HDA_IDISP_CODEC(bus->codec_mask))
671 		hda_codec_i915_display_power(sdev, false);
672 
673 	hda_bus_ml_put_all(bus);
674 
675 	return 0;
676 }
677 
678 static irqreturn_t hda_dsp_interrupt_handler(int irq, void *context)
679 {
680 	struct snd_sof_dev *sdev = context;
681 
682 	/*
683 	 * Get global interrupt status. It includes all hardware interrupt
684 	 * sources in the Intel HD Audio controller.
685 	 */
686 	if (snd_sof_dsp_read(sdev, HDA_DSP_HDA_BAR, SOF_HDA_INTSTS) &
687 	    SOF_HDA_INTSTS_GIS) {
688 
689 		/* disable GIE interrupt */
690 		snd_sof_dsp_update_bits(sdev, HDA_DSP_HDA_BAR,
691 					SOF_HDA_INTCTL,
692 					SOF_HDA_INT_GLOBAL_EN,
693 					0);
694 
695 		return IRQ_WAKE_THREAD;
696 	}
697 
698 	return IRQ_NONE;
699 }
700 
701 static irqreturn_t hda_dsp_interrupt_thread(int irq, void *context)
702 {
703 	struct snd_sof_dev *sdev = context;
704 	struct sof_intel_hda_dev *hdev = sdev->pdata->hw_pdata;
705 
706 	/* deal with streams and controller first */
707 	if (hda_dsp_check_stream_irq(sdev)) {
708 		trace_sof_intel_hda_irq(sdev, "stream");
709 		hda_dsp_stream_threaded_handler(irq, sdev);
710 	}
711 
712 	if (hda_check_ipc_irq(sdev)) {
713 		trace_sof_intel_hda_irq(sdev, "ipc");
714 		sof_ops(sdev)->irq_thread(irq, sdev);
715 	}
716 
717 	if (hda_dsp_check_sdw_irq(sdev)) {
718 		trace_sof_intel_hda_irq(sdev, "sdw");
719 
720 		hda_dsp_sdw_thread(irq, hdev->sdw);
721 
722 		if (hda_dsp_sdw_check_mic_privacy_irq(sdev)) {
723 			trace_sof_intel_hda_irq(sdev, "mic privacy");
724 			hda_dsp_sdw_process_mic_privacy(sdev);
725 		}
726 	}
727 
728 	if (hda_sdw_check_wakeen_irq(sdev)) {
729 		trace_sof_intel_hda_irq(sdev, "wakeen");
730 		hda_sdw_process_wakeen(sdev);
731 	}
732 
733 	hda_codec_check_for_state_change(sdev);
734 
735 	/* enable GIE interrupt */
736 	snd_sof_dsp_update_bits(sdev, HDA_DSP_HDA_BAR,
737 				SOF_HDA_INTCTL,
738 				SOF_HDA_INT_GLOBAL_EN,
739 				SOF_HDA_INT_GLOBAL_EN);
740 
741 	return IRQ_HANDLED;
742 }
743 
744 int hda_dsp_probe_early(struct snd_sof_dev *sdev)
745 {
746 	struct pci_dev *pci = to_pci_dev(sdev->dev);
747 	struct sof_intel_hda_dev *hdev;
748 	const struct sof_intel_dsp_desc *chip;
749 	int ret = 0;
750 
751 	if (!sdev->dspless_mode_selected) {
752 		/*
753 		 * detect DSP by checking class/subclass/prog-id information
754 		 * class=04 subclass 03 prog-if 00: no DSP, legacy driver is required
755 		 * class=04 subclass 01 prog-if 00: DSP is present
756 		 *   (and may be required e.g. for DMIC or SSP support)
757 		 * class=04 subclass 03 prog-if 80: either of DSP or legacy mode works
758 		 */
759 		if (pci->class == 0x040300) {
760 			dev_err(sdev->dev, "the DSP is not enabled on this platform, aborting probe\n");
761 			return -ENODEV;
762 		} else if (pci->class != 0x040100 && pci->class != 0x040380) {
763 			dev_err(sdev->dev, "unknown PCI class/subclass/prog-if 0x%06x found, aborting probe\n",
764 				pci->class);
765 			return -ENODEV;
766 		}
767 		dev_info_once(sdev->dev, "DSP detected with PCI class/subclass/prog-if 0x%06x\n",
768 			      pci->class);
769 	}
770 
771 	chip = get_chip_info(sdev->pdata);
772 	if (!chip) {
773 		dev_err(sdev->dev, "error: no such device supported, chip id:%x\n",
774 			pci->device);
775 		ret = -EIO;
776 		goto err;
777 	}
778 
779 	sdev->num_cores = chip->cores_num;
780 
781 	hdev = devm_kzalloc(sdev->dev, sizeof(*hdev), GFP_KERNEL);
782 	if (!hdev)
783 		return -ENOMEM;
784 	sdev->pdata->hw_pdata = hdev;
785 	hdev->desc = chip;
786 	ret = hda_init(sdev);
787 
788 err:
789 	return ret;
790 }
791 EXPORT_SYMBOL_NS(hda_dsp_probe_early, "SND_SOC_SOF_INTEL_HDA_GENERIC");
792 
793 int hda_dsp_probe(struct snd_sof_dev *sdev)
794 {
795 	struct pci_dev *pci = to_pci_dev(sdev->dev);
796 	struct sof_intel_hda_dev *hdev = sdev->pdata->hw_pdata;
797 	const struct sof_intel_dsp_desc *chip;
798 	int ret = 0;
799 
800 	hdev->dmic_dev = platform_device_register_data(sdev->dev, "dmic-codec",
801 						       PLATFORM_DEVID_NONE,
802 						       NULL, 0);
803 	if (IS_ERR(hdev->dmic_dev)) {
804 		dev_err(sdev->dev, "error: failed to create DMIC device\n");
805 		return PTR_ERR(hdev->dmic_dev);
806 	}
807 
808 	/*
809 	 * use position update IPC if either it is forced
810 	 * or we don't have other choice
811 	 */
812 #if IS_ENABLED(CONFIG_SND_SOC_SOF_DEBUG_FORCE_IPC_POSITION)
813 	hdev->no_ipc_position = 0;
814 #else
815 	hdev->no_ipc_position = sof_ops(sdev)->pcm_pointer ? 1 : 0;
816 #endif
817 
818 	if (sdev->dspless_mode_selected)
819 		hdev->no_ipc_position = 1;
820 
821 	if (sdev->dspless_mode_selected)
822 		goto skip_dsp_setup;
823 
824 	/* DSP base */
825 	sdev->bar[HDA_DSP_BAR] = pci_ioremap_bar(pci, HDA_DSP_BAR);
826 	if (!sdev->bar[HDA_DSP_BAR]) {
827 		dev_err(sdev->dev, "error: ioremap error\n");
828 		ret = -ENXIO;
829 		goto hdac_bus_unmap;
830 	}
831 
832 	sdev->mmio_bar = HDA_DSP_BAR;
833 	sdev->mailbox_bar = HDA_DSP_BAR;
834 skip_dsp_setup:
835 
836 	/* allow 64bit DMA address if supported by H/W */
837 	if (dma_set_mask_and_coherent(&pci->dev, DMA_BIT_MASK(64))) {
838 		dev_dbg(sdev->dev, "DMA mask is 32 bit\n");
839 		dma_set_mask_and_coherent(&pci->dev, DMA_BIT_MASK(32));
840 	}
841 	dma_set_max_seg_size(&pci->dev, UINT_MAX);
842 
843 	/* init streams */
844 	ret = hda_dsp_stream_init(sdev);
845 	if (ret < 0) {
846 		dev_err(sdev->dev, "error: failed to init streams\n");
847 		/*
848 		 * not all errors are due to memory issues, but trying
849 		 * to free everything does not harm
850 		 */
851 		goto free_streams;
852 	}
853 
854 	/*
855 	 * register our IRQ
856 	 * let's try to enable msi firstly
857 	 * if it fails, use legacy interrupt mode
858 	 * TODO: support msi multiple vectors
859 	 */
860 	if (hda_use_msi && pci_alloc_irq_vectors(pci, 1, 1, PCI_IRQ_MSI) > 0) {
861 		dev_info(sdev->dev, "use msi interrupt mode\n");
862 		sdev->ipc_irq = pci_irq_vector(pci, 0);
863 		/* initialised to "false" by kzalloc() */
864 		sdev->msi_enabled = true;
865 	}
866 
867 	if (!sdev->msi_enabled) {
868 		dev_info(sdev->dev, "use legacy interrupt mode\n");
869 		/*
870 		 * in IO-APIC mode, hda->irq and ipc_irq are using the same
871 		 * irq number of pci->irq
872 		 */
873 		sdev->ipc_irq = pci->irq;
874 	}
875 
876 	dev_dbg(sdev->dev, "using IPC IRQ %d\n", sdev->ipc_irq);
877 	ret = request_threaded_irq(sdev->ipc_irq, hda_dsp_interrupt_handler,
878 				   hda_dsp_interrupt_thread,
879 				   IRQF_SHARED, "AudioDSP", sdev);
880 	if (ret < 0) {
881 		dev_err(sdev->dev, "error: failed to register IPC IRQ %d\n",
882 			sdev->ipc_irq);
883 		goto free_irq_vector;
884 	}
885 
886 	pci_set_master(pci);
887 	synchronize_irq(pci->irq);
888 
889 	/*
890 	 * clear TCSEL to clear playback on some HD Audio
891 	 * codecs. PCI TCSEL is defined in the Intel manuals.
892 	 */
893 	snd_sof_pci_update_bits(sdev, PCI_TCSEL, 0x07, 0);
894 
895 	/* init HDA capabilities */
896 	ret = hda_init_caps(sdev);
897 	if (ret < 0)
898 		goto free_ipc_irq;
899 
900 	if (!sdev->dspless_mode_selected) {
901 		/* enable ppcap interrupt */
902 		hda_dsp_ctrl_ppcap_enable(sdev, true);
903 		hda_dsp_ctrl_ppcap_int_enable(sdev, true);
904 
905 		/* set default mailbox offset for FW ready message */
906 		sdev->dsp_box.offset = HDA_DSP_MBOX_UPLINK_OFFSET;
907 
908 		INIT_DELAYED_WORK(&hdev->d0i3_work, hda_dsp_d0i3_work);
909 	}
910 
911 	chip = get_chip_info(sdev->pdata);
912 	if (chip && chip->hw_ip_version >= SOF_INTEL_ACE_2_0) {
913 		ret = hda_sdw_startup(sdev);
914 		if (ret < 0) {
915 			dev_err(sdev->dev, "could not startup SoundWire links\n");
916 			goto disable_pp_cap;
917 		}
918 	}
919 
920 	init_waitqueue_head(&hdev->waitq);
921 
922 	hdev->nhlt = intel_nhlt_init(sdev->dev);
923 
924 	return 0;
925 
926 disable_pp_cap:
927 	if (!sdev->dspless_mode_selected) {
928 		hda_dsp_ctrl_ppcap_int_enable(sdev, false);
929 		hda_dsp_ctrl_ppcap_enable(sdev, false);
930 	}
931 free_ipc_irq:
932 	free_irq(sdev->ipc_irq, sdev);
933 free_irq_vector:
934 	if (sdev->msi_enabled)
935 		pci_free_irq_vectors(pci);
936 free_streams:
937 	hda_dsp_stream_free(sdev);
938 /* dsp_unmap: not currently used */
939 	if (!sdev->dspless_mode_selected)
940 		iounmap(sdev->bar[HDA_DSP_BAR]);
941 hdac_bus_unmap:
942 	platform_device_unregister(hdev->dmic_dev);
943 
944 	return ret;
945 }
946 EXPORT_SYMBOL_NS(hda_dsp_probe, "SND_SOC_SOF_INTEL_HDA_GENERIC");
947 
948 void hda_dsp_remove(struct snd_sof_dev *sdev)
949 {
950 	struct sof_intel_hda_dev *hda = sdev->pdata->hw_pdata;
951 	const struct sof_intel_dsp_desc *chip = hda->desc;
952 	struct pci_dev *pci = to_pci_dev(sdev->dev);
953 	struct nhlt_acpi_table *nhlt = hda->nhlt;
954 
955 	if (nhlt)
956 		intel_nhlt_free(nhlt);
957 
958 	if (!sdev->dspless_mode_selected)
959 		/* cancel any attempt for DSP D0I3 */
960 		cancel_delayed_work_sync(&hda->d0i3_work);
961 
962 	hda_codec_device_remove(sdev);
963 
964 	hda_sdw_exit(sdev);
965 
966 	if (!IS_ERR_OR_NULL(hda->dmic_dev))
967 		platform_device_unregister(hda->dmic_dev);
968 
969 	if (!sdev->dspless_mode_selected) {
970 		/* disable DSP IRQ */
971 		hda_dsp_ctrl_ppcap_int_enable(sdev, false);
972 	}
973 
974 	/* disable CIE and GIE interrupts */
975 	snd_sof_dsp_update_bits(sdev, HDA_DSP_HDA_BAR, SOF_HDA_INTCTL,
976 				SOF_HDA_INT_CTRL_EN | SOF_HDA_INT_GLOBAL_EN, 0);
977 
978 	if (sdev->dspless_mode_selected)
979 		goto skip_disable_dsp;
980 
981 	/* Cancel the microphone privacy work if mic privacy is active */
982 	if (hda->mic_privacy.active)
983 		cancel_work_sync(&hda->mic_privacy.work);
984 
985 	/* no need to check for error as the DSP will be disabled anyway */
986 	if (chip && chip->power_down_dsp)
987 		chip->power_down_dsp(sdev);
988 
989 	/* disable DSP */
990 	hda_dsp_ctrl_ppcap_enable(sdev, false);
991 
992 	/* Free the persistent DMA buffers used for base firmware download */
993 	if (hda->cl_dmab.area)
994 		snd_dma_free_pages(&hda->cl_dmab);
995 	if (hda->iccmax_dmab.area)
996 		snd_dma_free_pages(&hda->iccmax_dmab);
997 
998 skip_disable_dsp:
999 	free_irq(sdev->ipc_irq, sdev);
1000 	if (sdev->msi_enabled)
1001 		pci_free_irq_vectors(pci);
1002 
1003 	hda_dsp_stream_free(sdev);
1004 
1005 	hda_bus_ml_free(sof_to_bus(sdev));
1006 
1007 	if (!sdev->dspless_mode_selected)
1008 		iounmap(sdev->bar[HDA_DSP_BAR]);
1009 }
1010 EXPORT_SYMBOL_NS(hda_dsp_remove, "SND_SOC_SOF_INTEL_HDA_GENERIC");
1011 
1012 void hda_dsp_remove_late(struct snd_sof_dev *sdev)
1013 {
1014 	iounmap(sof_to_bus(sdev)->remap_addr);
1015 	sof_hda_bus_exit(sdev);
1016 	hda_codec_i915_exit(sdev);
1017 }
1018 
1019 int hda_power_down_dsp(struct snd_sof_dev *sdev)
1020 {
1021 	struct sof_intel_hda_dev *hda = sdev->pdata->hw_pdata;
1022 	const struct sof_intel_dsp_desc *chip = hda->desc;
1023 
1024 	return hda_dsp_core_reset_power_down(sdev, chip->host_managed_cores_mask);
1025 }
1026 EXPORT_SYMBOL_NS(hda_power_down_dsp, "SND_SOC_SOF_INTEL_HDA_GENERIC");
1027 
1028 #if IS_ENABLED(CONFIG_SND_SOC_SOF_HDA_AUDIO_CODEC)
1029 static void hda_generic_machine_select(struct snd_sof_dev *sdev,
1030 				       struct snd_soc_acpi_mach **mach)
1031 {
1032 	struct hdac_bus *bus = sof_to_bus(sdev);
1033 	struct snd_soc_acpi_mach_params *mach_params;
1034 	struct snd_soc_acpi_mach *hda_mach;
1035 	struct snd_sof_pdata *pdata = sdev->pdata;
1036 	const char *tplg_filename;
1037 	int codec_num = 0;
1038 	int i;
1039 
1040 	/* codec detection */
1041 	if (!bus->codec_mask) {
1042 		dev_info(bus->dev, "no hda codecs found!\n");
1043 	} else {
1044 		dev_info(bus->dev, "hda codecs found, mask %lx\n",
1045 			 bus->codec_mask);
1046 
1047 		for (i = 0; i < HDA_MAX_CODECS; i++) {
1048 			if (bus->codec_mask & (1 << i))
1049 				codec_num++;
1050 		}
1051 
1052 		/*
1053 		 * If no machine driver is found, then:
1054 		 *
1055 		 * generic hda machine driver can handle:
1056 		 *  - one HDMI codec, and/or
1057 		 *  - one external HDAudio codec
1058 		 */
1059 		if (!*mach && codec_num <= 2) {
1060 			bool tplg_fixup = false;
1061 
1062 			/*
1063 			 * make a local copy of the match array since we might
1064 			 * be modifying it
1065 			 */
1066 			hda_mach = devm_kmemdup_array(sdev->dev,
1067 					snd_soc_acpi_intel_hda_machines,
1068 					2, /* we have one entry + sentinel in the array */
1069 					sizeof(snd_soc_acpi_intel_hda_machines[0]),
1070 					GFP_KERNEL);
1071 			if (!hda_mach) {
1072 				dev_err(bus->dev,
1073 					"%s: failed to duplicate the HDA match table\n",
1074 					__func__);
1075 				return;
1076 			}
1077 
1078 			dev_info(bus->dev, "using HDA machine driver %s now\n",
1079 				 hda_mach->drv_name);
1080 
1081 			/*
1082 			 * topology: use the info from hda_machines since tplg file name
1083 			 * is not overwritten
1084 			 */
1085 			if (!pdata->tplg_filename)
1086 				tplg_fixup = true;
1087 
1088 			if (tplg_fixup &&
1089 			    codec_num == 1 && HDA_IDISP_CODEC(bus->codec_mask)) {
1090 				tplg_filename = devm_kasprintf(sdev->dev, GFP_KERNEL,
1091 							       "%s-idisp",
1092 							       hda_mach->sof_tplg_filename);
1093 				if (!tplg_filename)
1094 					return;
1095 
1096 				hda_mach->sof_tplg_filename = tplg_filename;
1097 			}
1098 
1099 			if (codec_num == 2 ||
1100 			    (codec_num == 1 && !HDA_IDISP_CODEC(bus->codec_mask))) {
1101 				/*
1102 				 * Prevent SoundWire links from starting when an external
1103 				 * HDaudio codec is used
1104 				 */
1105 				hda_mach->mach_params.link_mask = 0;
1106 			} else {
1107 				/*
1108 				 * Allow SoundWire links to start when no external HDaudio codec
1109 				 * was detected. This will not create a SoundWire card but
1110 				 * will help detect if any SoundWire codec reports as ATTACHED.
1111 				 */
1112 				struct sof_intel_hda_dev *hdev = sdev->pdata->hw_pdata;
1113 
1114 				hda_mach->mach_params.link_mask = hdev->info.link_mask;
1115 			}
1116 
1117 			*mach = hda_mach;
1118 		}
1119 	}
1120 
1121 	/* used by hda machine driver to create dai links */
1122 	if (*mach) {
1123 		mach_params = &(*mach)->mach_params;
1124 		mach_params->codec_mask = bus->codec_mask;
1125 	}
1126 }
1127 #else
1128 static void hda_generic_machine_select(struct snd_sof_dev *sdev,
1129 				       struct snd_soc_acpi_mach **mach)
1130 {
1131 }
1132 #endif
1133 
1134 #if IS_ENABLED(CONFIG_SND_SOC_SOF_INTEL_SOUNDWIRE)
1135 
1136 static bool is_endpoint_present(struct sdw_slave *sdw_device,
1137 				struct asoc_sdw_codec_info *dai_info, int dai_type)
1138 {
1139 	int i;
1140 
1141 	for (i = 0; i < sdw_device->sdca_data.num_functions; i++) {
1142 		if (dai_type == dai_info->dais[i].dai_type)
1143 			return true;
1144 	}
1145 	dev_dbg(&sdw_device->dev, "Endpoint DAI type %d not found\n", dai_type);
1146 	return false;
1147 }
1148 
1149 static struct snd_soc_acpi_adr_device *find_acpi_adr_device(struct device *dev,
1150 							    struct sdw_slave *sdw_device,
1151 							    struct snd_soc_acpi_link_adr *link,
1152 							    int *amp_index)
1153 {
1154 	struct snd_soc_acpi_adr_device *adr_dev;
1155 	const char *name_prefix = "";
1156 	int index = link->num_adr;
1157 	bool is_amp = true; /* Set it to false if the codec wiah any NON-AMP DAI type */
1158 	int ep_index = 0;
1159 	int i, j;
1160 
1161 	link->mask = BIT(sdw_device->bus->link_id);
1162 	/* index is 0 based, we need allocate index + 1 for the array size */
1163 	if (!index)
1164 		adr_dev = devm_kzalloc(dev, sizeof(*adr_dev), GFP_KERNEL);
1165 	else
1166 		adr_dev = devm_krealloc(dev, (struct snd_soc_acpi_adr_device *)link->adr_d,
1167 					(index + 1) * sizeof(*adr_dev), GFP_KERNEL);
1168 
1169 	if (!adr_dev)
1170 		return NULL;
1171 
1172 	for (i = 0; i < asoc_sdw_get_codec_info_list_count(); i++) {
1173 		struct snd_soc_acpi_endpoint *endpoints;
1174 		int amp_group_id = 1;
1175 
1176 		if (sdw_device->id.part_id != codec_info_list[i].part_id)
1177 			continue;
1178 
1179 		endpoints = devm_kcalloc(dev, codec_info_list[i].dai_num,
1180 					 sizeof(struct snd_soc_acpi_endpoint), GFP_KERNEL);
1181 		if (!endpoints)
1182 			return NULL;
1183 
1184 		name_prefix = codec_info_list[i].name_prefix;
1185 		/*
1186 		 * This should not happen, but add a paranoid check to avoid NULL pointer
1187 		 * dereference
1188 		 */
1189 		if (!name_prefix) {
1190 			dev_err(dev, "codec_info_list name_prefix of part id %#x is missing\n",
1191 				codec_info_list[i].part_id);
1192 			return NULL;
1193 		}
1194 		for (j = 0; j < codec_info_list[i].dai_num; j++) {
1195 			/* Check if the endpoint is present by the SDCA DisCo table */
1196 			if (!is_endpoint_present(sdw_device, &codec_info_list[i],
1197 						 codec_info_list[i].dais[j].dai_type))
1198 				continue;
1199 
1200 			endpoints[ep_index].num = ep_index;
1201 			if (codec_info_list[i].dais[j].dai_type == SOC_SDW_DAI_TYPE_AMP) {
1202 				/* Assume all amp are aggregated */
1203 				endpoints[ep_index].aggregated = 1;
1204 				endpoints[ep_index].group_id = amp_group_id;
1205 				endpoints[ep_index].group_position = *amp_index;
1206 				/* Set group id = 2 for feedback capture endpoint */
1207 				amp_group_id++;
1208 			} else {
1209 				endpoints[ep_index].aggregated = 0;
1210 				endpoints[ep_index].group_id = 0;
1211 				endpoints[ep_index].group_position = 0;
1212 				is_amp = false;
1213 			}
1214 			ep_index++;
1215 		}
1216 		adr_dev[index].endpoints = endpoints;
1217 		adr_dev[index].num_endpoints = ep_index;
1218 		break;
1219 	}
1220 
1221 	if (i == asoc_sdw_get_codec_info_list_count()) {
1222 		dev_err(dev, "part id %#x is not supported\n", sdw_device->id.part_id);
1223 		return NULL;
1224 	}
1225 
1226 	adr_dev[index].adr = ((u64)sdw_device->id.class_id & 0xFF) |
1227 			((u64)sdw_device->id.part_id & 0xFFFF) << 8 |
1228 			((u64)sdw_device->id.mfg_id & 0xFFFF) << 24 |
1229 			((u64)(sdw_device->id.unique_id & 0xF) << 40) |
1230 			((u64)(sdw_device->id.sdw_version & 0xF) << 44) |
1231 			((u64)(sdw_device->bus->link_id & 0xF) << 48);
1232 
1233 	if (!is_amp) {
1234 		/* For non-amp codecs, get name_prefix from codec_info_list[] */
1235 		adr_dev[index].name_prefix = devm_kasprintf(dev, GFP_KERNEL, "%s", name_prefix);
1236 		goto done_name_prefix;
1237 	}
1238 
1239 	/*
1240 	 * The name_prefix comes from codec_info_list which has a name_prefix per codec.
1241 	 * And we need to give a unique name_prefix for each amp and should be backwards
1242 	 * compatible to the existing acpi match tables to not break existing UCMs.
1243 	 * For the common name_prefix, we append the amp index to it. However, for the
1244 	 * "Left" name_prefix, we convert the second amp name_prefix to "Right" and
1245 	 * for the third and further amps, we set the name_prefix to "AMP<amp_index>".
1246 	 */
1247 	if (!strcmp(name_prefix, "Left")) {
1248 		switch (*amp_index) {
1249 		case 1:
1250 			adr_dev[index].name_prefix = devm_kasprintf(dev, GFP_KERNEL,
1251 								    "%s", "Left");
1252 			break;
1253 		case 2:
1254 			adr_dev[index].name_prefix = devm_kasprintf(dev, GFP_KERNEL,
1255 								    "%s", "Right");
1256 			break;
1257 		default:
1258 			/* Set the name_fix to AMP<amp_index> if there are more than 2 amps */
1259 			adr_dev[index].name_prefix = devm_kasprintf(dev, GFP_KERNEL, "%s%d",
1260 								    "AMP", *amp_index);
1261 			break;
1262 		}
1263 	} else if (!strcmp(name_prefix, "AMP")) {
1264 		adr_dev[index].name_prefix = devm_kasprintf(dev, GFP_KERNEL, "%s%d",
1265 							    name_prefix,
1266 							    *amp_index);
1267 	} else {
1268 		/*
1269 		 * The name_prefix will be the amp name if it is not "Left" or "AMP", set it to
1270 		 * <name_prefix>-<amp_index> format. Like rt1320-1
1271 		 */
1272 		adr_dev[index].name_prefix = devm_kasprintf(dev, GFP_KERNEL, "%s-%d",
1273 							    name_prefix,
1274 							    *amp_index);
1275 	}
1276 	(*amp_index)++;
1277 
1278 done_name_prefix:
1279 	if (!adr_dev[index].name_prefix) {
1280 		dev_err(dev, "failed to allocate memory for name_prefix\n");
1281 		return NULL;
1282 	}
1283 
1284 	dev_dbg(dev, "adr[%d] 0x%llx link id %d name_prefix \"%s\" is found\n",
1285 		index, adr_dev[index].adr, sdw_device->bus->link_id, adr_dev[index].name_prefix);
1286 
1287 	link->num_adr++;
1288 
1289 	return adr_dev;
1290 }
1291 
1292 static struct snd_soc_acpi_mach *hda_sdw_machine_select(struct snd_sof_dev *sdev)
1293 {
1294 	struct snd_sof_pdata *pdata = sdev->pdata;
1295 	const struct snd_soc_acpi_link_adr *link;
1296 	const struct sof_intel_dsp_desc *chip;
1297 	struct snd_soc_acpi_link_adr *links;
1298 	struct sdw_peripherals *peripherals;
1299 	struct snd_soc_acpi_mach *mach;
1300 	struct sof_intel_hda_dev *hdev;
1301 	int link_index, link_num;
1302 	int amp_index = 1;
1303 	u32 link_mask = 0;
1304 	int i;
1305 
1306 	hdev = pdata->hw_pdata;
1307 	link_mask = hdev->info.link_mask;
1308 
1309 	if (!link_mask) {
1310 		dev_info(sdev->dev, "SoundWire links not enabled\n");
1311 		return NULL;
1312 	}
1313 
1314 	if (!hdev->sdw) {
1315 		dev_dbg(sdev->dev, "SoundWire context not allocated\n");
1316 		return NULL;
1317 	}
1318 
1319 	if (!hdev->sdw->peripherals || !hdev->sdw->peripherals->num_peripherals) {
1320 		dev_warn(sdev->dev, "No SoundWire peripheral detected in ACPI tables\n");
1321 		return NULL;
1322 	}
1323 
1324 	/*
1325 	 * Select SoundWire machine driver if needed using the
1326 	 * alternate tables. This case deals with SoundWire-only
1327 	 * machines, for mixed cases with I2C/I2S the detection relies
1328 	 * on the HID list.
1329 	 */
1330 	for (mach = pdata->desc->alt_machines;
1331 	     mach && mach->link_mask; mach++) {
1332 		/*
1333 		 * On some platforms such as Up Extreme all links
1334 		 * are enabled but only one link can be used by
1335 		 * external codec. Instead of exact match of two masks,
1336 		 * first check whether link_mask of mach is subset of
1337 		 * link_mask supported by hw and then go on searching
1338 		 * link_adr
1339 		 */
1340 		if (~link_mask & mach->link_mask)
1341 			continue;
1342 
1343 		/* No need to match adr if there is no links defined */
1344 		if (!mach->links)
1345 			break;
1346 
1347 		link = mach->links;
1348 		for (i = 0; i < hdev->info.count && link->num_adr;
1349 		     i++, link++) {
1350 			/*
1351 			 * Try next machine if any expected Slaves
1352 			 * are not found on this link.
1353 			 */
1354 			if (!snd_soc_acpi_sdw_link_slaves_found(sdev->dev, link,
1355 								hdev->sdw->peripherals))
1356 				break;
1357 		}
1358 		/* Found if all Slaves are checked */
1359 		if (i == hdev->info.count || !link->num_adr)
1360 			if (!mach->machine_check || mach->machine_check(hdev->sdw))
1361 				break;
1362 	}
1363 	if (mach && mach->link_mask) {
1364 		mach->mach_params.links = mach->links;
1365 		mach->mach_params.link_mask = mach->link_mask;
1366 		mach->mach_params.platform = dev_name(sdev->dev);
1367 
1368 		return mach;
1369 	}
1370 
1371 	dev_info(sdev->dev, "No SoundWire machine driver found for the ACPI-reported configuration:\n");
1372 	peripherals = hdev->sdw->peripherals;
1373 	for (i = 0; i < peripherals->num_peripherals; i++)
1374 		dev_info(sdev->dev, "link %d mfg_id 0x%04x part_id 0x%04x version %#x\n",
1375 			 peripherals->array[i]->bus->link_id,
1376 			 peripherals->array[i]->id.mfg_id,
1377 			 peripherals->array[i]->id.part_id,
1378 			 peripherals->array[i]->id.sdw_version);
1379 
1380 	chip = get_chip_info(sdev->pdata);
1381 
1382 	/* SDCA was not well supported in the BIOS before ACE2.0 */
1383 	if (chip->hw_ip_version < SOF_INTEL_ACE_2_0)
1384 		return NULL;
1385 
1386 	if (!peripherals->num_peripherals)
1387 		return NULL;
1388 
1389 	/* Create default SDW mach */
1390 	mach = devm_kzalloc(sdev->dev, sizeof(*mach), GFP_KERNEL);
1391 	if (!mach)
1392 		return NULL;
1393 
1394 	/* Get link mask and link number */
1395 	for (i = 0; i < peripherals->num_peripherals; i++)
1396 		link_mask |= BIT(peripherals->array[i]->bus->link_id);
1397 
1398 	link_num = hweight32(link_mask);
1399 	links = devm_kcalloc(sdev->dev, link_num, sizeof(*links), GFP_KERNEL);
1400 	if (!links)
1401 		return NULL;
1402 
1403 	/* Generate snd_soc_acpi_link_adr struct for each peripheral reported by the ACPI table */
1404 	for (i = 0; i < peripherals->num_peripherals; i++) {
1405 		/* link_index = the number of used links below the current link */
1406 		link_index = hweight32(link_mask & (BIT(peripherals->array[i]->bus->link_id) - 1));
1407 		links[link_index].adr_d = find_acpi_adr_device(sdev->dev, peripherals->array[i],
1408 							       &links[link_index], &amp_index);
1409 		if (!links[link_index].adr_d)
1410 			return NULL;
1411 	}
1412 
1413 	mach->drv_name = "sof_sdw";
1414 	mach->mach_params.links = links;
1415 	mach->mach_params.link_mask = link_mask;
1416 	mach->mach_params.platform = dev_name(sdev->dev);
1417 	mach->get_function_tplg_files = sof_sdw_get_tplg_files;
1418 	/*
1419 	 * Set mach->sof_tplg_filename as a dummy topology to avoid tplg file checking
1420 	 * and being used.
1421 	 */
1422 	mach->sof_tplg_filename = devm_kasprintf(sdev->dev, GFP_KERNEL,
1423 						 "sof-%s-dummy.tplg", chip->platform);
1424 
1425 	dev_info(sdev->dev, "Use SoundWire default machine driver with function topologies\n");
1426 	return mach;
1427 }
1428 #else
1429 static struct snd_soc_acpi_mach *hda_sdw_machine_select(struct snd_sof_dev *sdev)
1430 {
1431 	return NULL;
1432 }
1433 #endif
1434 
1435 void hda_set_mach_params(struct snd_soc_acpi_mach *mach,
1436 			 struct snd_sof_dev *sdev)
1437 {
1438 	struct snd_sof_pdata *pdata = sdev->pdata;
1439 	const struct sof_dev_desc *desc = pdata->desc;
1440 	struct snd_soc_acpi_mach_params *mach_params;
1441 
1442 	mach_params = &mach->mach_params;
1443 	mach_params->platform = dev_name(sdev->dev);
1444 	if (IS_ENABLED(CONFIG_SND_SOC_SOF_NOCODEC_DEBUG_SUPPORT) &&
1445 	    sof_debug_check_flag(SOF_DBG_FORCE_NOCODEC))
1446 		mach_params->num_dai_drivers = SOF_SKL_NUM_DAIS_NOCODEC;
1447 	else
1448 		mach_params->num_dai_drivers = desc->ops->num_drv;
1449 	mach_params->dai_drivers = desc->ops->drv;
1450 }
1451 
1452 static int check_tplg_quirk_mask(struct snd_soc_acpi_mach *mach)
1453 {
1454 	u32 dmic_ssp_quirk;
1455 	u32 codec_amp_name_quirk;
1456 
1457 	/*
1458 	 * In current implementation dmic and ssp quirks are designed for es8336
1459 	 * machine driver and could not be mixed with codec name and amp name
1460 	 * quirks.
1461 	 */
1462 	dmic_ssp_quirk = mach->tplg_quirk_mask &
1463 			 (SND_SOC_ACPI_TPLG_INTEL_DMIC_NUMBER | SND_SOC_ACPI_TPLG_INTEL_SSP_NUMBER);
1464 	codec_amp_name_quirk = mach->tplg_quirk_mask &
1465 			 (SND_SOC_ACPI_TPLG_INTEL_AMP_NAME | SND_SOC_ACPI_TPLG_INTEL_CODEC_NAME);
1466 
1467 	if (dmic_ssp_quirk && codec_amp_name_quirk)
1468 		return -EINVAL;
1469 
1470 	return 0;
1471 }
1472 
1473 static char *remove_file_ext(struct device *dev, const char *tplg_filename)
1474 {
1475 	char *filename, *tmp;
1476 
1477 	filename = devm_kstrdup(dev, tplg_filename, GFP_KERNEL);
1478 	if (!filename)
1479 		return NULL;
1480 
1481 	/* remove file extension if exist */
1482 	tmp = filename;
1483 	return strsep(&tmp, ".");
1484 }
1485 
1486 struct snd_soc_acpi_mach *hda_machine_select(struct snd_sof_dev *sdev)
1487 {
1488 	u32 interface_mask = hda_get_interface_mask(sdev);
1489 	struct snd_sof_pdata *sof_pdata = sdev->pdata;
1490 	const struct sof_dev_desc *desc = sof_pdata->desc;
1491 	struct hdac_bus *bus = sof_to_bus(sdev);
1492 	struct snd_soc_acpi_mach *mach = NULL;
1493 	enum snd_soc_acpi_intel_codec codec_type, amp_type;
1494 	const char *tplg_filename;
1495 	const char *tplg_suffix;
1496 	bool amp_name_valid;
1497 	bool i2s_mach_found = false;
1498 	bool sdw_mach_found = false;
1499 
1500 	/* Try I2S or DMIC if it is supported */
1501 	if (interface_mask & (BIT(SOF_DAI_INTEL_SSP) | BIT(SOF_DAI_INTEL_DMIC))) {
1502 		mach = snd_soc_acpi_find_machine(desc->machines);
1503 		if (mach)
1504 			i2s_mach_found = true;
1505 	}
1506 
1507 	/*
1508 	 * If I2S fails and no external HDaudio codec is detected,
1509 	 * try SoundWire if it is supported
1510 	 */
1511 	if (!mach && !HDA_EXT_CODEC(bus->codec_mask) &&
1512 	    (interface_mask & BIT(SOF_DAI_INTEL_ALH))) {
1513 		mach = hda_sdw_machine_select(sdev);
1514 		if (mach)
1515 			sdw_mach_found = true;
1516 	}
1517 
1518 	/*
1519 	 * Choose HDA generic machine driver if mach is NULL.
1520 	 * Otherwise, set certain mach params.
1521 	 */
1522 	hda_generic_machine_select(sdev, &mach);
1523 	if (!mach) {
1524 		dev_warn(sdev->dev, "warning: No matching ASoC machine driver found\n");
1525 		return NULL;
1526 	}
1527 
1528 	/* report BT offload link mask to machine driver */
1529 	mach->mach_params.bt_link_mask = check_nhlt_ssp_mask(sdev, NHLT_DEVICE_BT);
1530 
1531 	dev_info(sdev->dev, "BT link detected in NHLT tables: %#x\n",
1532 		 mach->mach_params.bt_link_mask);
1533 
1534 	/* allow for module parameter override */
1535 	if (bt_link_mask_override) {
1536 		dev_dbg(sdev->dev, "overriding BT link detected in NHLT tables %#x by kernel param %#x\n",
1537 			mach->mach_params.bt_link_mask, bt_link_mask_override);
1538 		mach->mach_params.bt_link_mask = bt_link_mask_override;
1539 	}
1540 
1541 	if (hweight_long(mach->mach_params.bt_link_mask) > 1) {
1542 		dev_warn(sdev->dev, "invalid BT link mask %#x found, reset the mask\n",
1543 			mach->mach_params.bt_link_mask);
1544 		mach->mach_params.bt_link_mask = 0;
1545 	}
1546 
1547 	/*
1548 	 * Fixup tplg file name by appending dmic num, ssp num, codec/amplifier
1549 	 * name string if quirk flag is set.
1550 	 */
1551 	if (mach) {
1552 		bool tplg_fixup = false;
1553 		bool dmic_fixup = false;
1554 
1555 		/*
1556 		 * If tplg file name is overridden, use it instead of
1557 		 * the one set in mach table
1558 		 */
1559 		if (!sof_pdata->tplg_filename) {
1560 			/* remove file extension if it exists */
1561 			tplg_filename = remove_file_ext(sdev->dev, mach->sof_tplg_filename);
1562 			if (!tplg_filename)
1563 				return NULL;
1564 
1565 			sof_pdata->tplg_filename = tplg_filename;
1566 			tplg_fixup = true;
1567 		}
1568 
1569 		/*
1570 		 * Checking quirk mask integrity; some quirk flags could not be
1571 		 * set concurrently.
1572 		 */
1573 		if (tplg_fixup &&
1574 		    check_tplg_quirk_mask(mach)) {
1575 			dev_err(sdev->dev, "Invalid tplg quirk mask 0x%x\n",
1576 				mach->tplg_quirk_mask);
1577 			return NULL;
1578 		}
1579 
1580 		/* report to machine driver if any DMICs are found */
1581 		mach->mach_params.dmic_num = check_dmic_num(sdev);
1582 
1583 		if (sdw_mach_found || mach->tplg_quirk_mask & SND_SOC_ACPI_TPLG_INTEL_DMIC_NUMBER)
1584 			dmic_fixup = true;
1585 
1586 		if (tplg_fixup &&
1587 		    dmic_fixup &&
1588 		    mach->mach_params.dmic_num) {
1589 			tplg_filename = devm_kasprintf(sdev->dev, GFP_KERNEL,
1590 						       "%s%s%d%s",
1591 						       sof_pdata->tplg_filename,
1592 						       i2s_mach_found ? "-dmic" : "-",
1593 						       mach->mach_params.dmic_num,
1594 						       "ch");
1595 			if (!tplg_filename)
1596 				return NULL;
1597 
1598 			sof_pdata->tplg_filename = tplg_filename;
1599 		}
1600 
1601 		if (mach->link_mask) {
1602 			mach->mach_params.links = mach->links;
1603 			mach->mach_params.link_mask = mach->link_mask;
1604 		}
1605 
1606 		/* report SSP link mask to machine driver */
1607 		mach->mach_params.i2s_link_mask = check_nhlt_ssp_mask(sdev, NHLT_DEVICE_I2S);
1608 
1609 		if (tplg_fixup &&
1610 		    mach->tplg_quirk_mask & SND_SOC_ACPI_TPLG_INTEL_SSP_NUMBER &&
1611 		    mach->mach_params.i2s_link_mask) {
1612 			const struct sof_intel_dsp_desc *chip = get_chip_info(sdev->pdata);
1613 			int ssp_num;
1614 			int mclk_mask;
1615 
1616 			if (hweight_long(mach->mach_params.i2s_link_mask) > 1 &&
1617 			    !(mach->tplg_quirk_mask & SND_SOC_ACPI_TPLG_INTEL_SSP_MSB))
1618 				dev_warn(sdev->dev, "More than one SSP exposed by NHLT, choosing MSB\n");
1619 
1620 			/* fls returns 1-based results, SSPs indices are 0-based */
1621 			ssp_num = fls(mach->mach_params.i2s_link_mask) - 1;
1622 
1623 			if (ssp_num >= chip->ssp_count) {
1624 				dev_err(sdev->dev, "Invalid SSP %d, max on this platform is %d\n",
1625 					ssp_num, chip->ssp_count);
1626 				return NULL;
1627 			}
1628 
1629 			tplg_filename = devm_kasprintf(sdev->dev, GFP_KERNEL,
1630 						       "%s%s%d",
1631 						       sof_pdata->tplg_filename,
1632 						       "-ssp",
1633 						       ssp_num);
1634 			if (!tplg_filename)
1635 				return NULL;
1636 
1637 			sof_pdata->tplg_filename = tplg_filename;
1638 
1639 			mclk_mask = check_nhlt_ssp_mclk_mask(sdev, ssp_num);
1640 
1641 			if (mclk_mask < 0) {
1642 				dev_err(sdev->dev, "Invalid MCLK configuration\n");
1643 				return NULL;
1644 			}
1645 
1646 			dev_dbg(sdev->dev, "MCLK mask %#x found in NHLT\n", mclk_mask);
1647 
1648 			if (mclk_mask) {
1649 				dev_info(sdev->dev, "Overriding topology with MCLK mask %#x from NHLT\n", mclk_mask);
1650 				sdev->mclk_id_override = true;
1651 				sdev->mclk_id_quirk = (mclk_mask & BIT(0)) ? 0 : 1;
1652 			}
1653 		}
1654 
1655 		amp_type = snd_soc_acpi_intel_detect_amp_type(sdev->dev);
1656 		codec_type = snd_soc_acpi_intel_detect_codec_type(sdev->dev);
1657 		amp_name_valid = amp_type != CODEC_NONE && amp_type != codec_type;
1658 
1659 		if (tplg_fixup && amp_name_valid &&
1660 		    mach->tplg_quirk_mask & SND_SOC_ACPI_TPLG_INTEL_AMP_NAME) {
1661 			tplg_suffix = snd_soc_acpi_intel_get_amp_tplg_suffix(amp_type);
1662 			if (!tplg_suffix) {
1663 				dev_err(sdev->dev, "no tplg suffix found, amp %d\n",
1664 					amp_type);
1665 				return NULL;
1666 			}
1667 
1668 			tplg_filename = devm_kasprintf(sdev->dev, GFP_KERNEL,
1669 						       "%s-%s",
1670 						       sof_pdata->tplg_filename,
1671 						       tplg_suffix);
1672 			if (!tplg_filename)
1673 				return NULL;
1674 
1675 			sof_pdata->tplg_filename = tplg_filename;
1676 		}
1677 
1678 
1679 		if (tplg_fixup &&
1680 		    mach->tplg_quirk_mask & SND_SOC_ACPI_TPLG_INTEL_CODEC_NAME &&
1681 		    codec_type != CODEC_NONE) {
1682 			tplg_suffix = snd_soc_acpi_intel_get_codec_tplg_suffix(codec_type);
1683 			if (!tplg_suffix) {
1684 				dev_err(sdev->dev, "no tplg suffix found, codec %d\n",
1685 					codec_type);
1686 				return NULL;
1687 			}
1688 
1689 			tplg_filename = devm_kasprintf(sdev->dev, GFP_KERNEL,
1690 						       "%s-%s",
1691 						       sof_pdata->tplg_filename,
1692 						       tplg_suffix);
1693 			if (!tplg_filename)
1694 				return NULL;
1695 
1696 			sof_pdata->tplg_filename = tplg_filename;
1697 		}
1698 
1699 		if (tplg_fixup) {
1700 			tplg_filename = devm_kasprintf(sdev->dev, GFP_KERNEL,
1701 						       "%s%s",
1702 						       sof_pdata->tplg_filename,
1703 						       ".tplg");
1704 			if (!tplg_filename)
1705 				return NULL;
1706 
1707 			sof_pdata->tplg_filename = tplg_filename;
1708 		}
1709 
1710 		/* check if mclk_id should be modified from topology defaults */
1711 		if (mclk_id_override >= 0) {
1712 			dev_info(sdev->dev, "Overriding topology with MCLK %d from kernel_parameter\n", mclk_id_override);
1713 			sdev->mclk_id_override = true;
1714 			sdev->mclk_id_quirk = mclk_id_override;
1715 		}
1716 	}
1717 
1718 	return mach;
1719 }
1720 
1721 int hda_pci_intel_probe(struct pci_dev *pci, const struct pci_device_id *pci_id)
1722 {
1723 	int ret;
1724 
1725 	ret = snd_intel_dsp_driver_probe(pci);
1726 	if (ret != SND_INTEL_DSP_DRIVER_ANY && ret != SND_INTEL_DSP_DRIVER_SOF) {
1727 		dev_dbg(&pci->dev, "SOF PCI driver not selected, aborting probe\n");
1728 		return -ENODEV;
1729 	}
1730 
1731 	return sof_pci_probe(pci, pci_id);
1732 }
1733 EXPORT_SYMBOL_NS(hda_pci_intel_probe, "SND_SOC_SOF_INTEL_HDA_GENERIC");
1734 
1735 int hda_register_clients(struct snd_sof_dev *sdev)
1736 {
1737 	return hda_probes_register(sdev);
1738 }
1739 
1740 void hda_unregister_clients(struct snd_sof_dev *sdev)
1741 {
1742 	hda_probes_unregister(sdev);
1743 }
1744 
1745 MODULE_LICENSE("Dual BSD/GPL");
1746 MODULE_DESCRIPTION("SOF support for HDaudio platforms");
1747 MODULE_IMPORT_NS("SND_SOC_SOF_PCI_DEV");
1748 MODULE_IMPORT_NS("SND_SOC_SOF_HDA_AUDIO_CODEC");
1749 MODULE_IMPORT_NS("SND_SOC_SOF_HDA_AUDIO_CODEC_I915");
1750 MODULE_IMPORT_NS("SND_SOC_SOF_XTENSA");
1751 MODULE_IMPORT_NS("SND_INTEL_SOUNDWIRE_ACPI");
1752 MODULE_IMPORT_NS("SOUNDWIRE_INTEL_INIT");
1753 MODULE_IMPORT_NS("SOUNDWIRE_INTEL");
1754 MODULE_IMPORT_NS("SND_SOC_SDW_UTILS");
1755 MODULE_IMPORT_NS("SND_SOC_SOF_HDA_MLINK");
1756 MODULE_IMPORT_NS("SND_SOC_SOF_INTEL_HDA_COMMON");
1757 MODULE_IMPORT_NS("SND_SOC_ACPI_INTEL_MATCH");
1758