Lines Matching +full:dsp +full:- +full:irq

1 // SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause)
15 * Hardware interface for generic Intel audio DSP HDA IP
26 #include <sound/intel-dsp-config.h>
27 #include <sound/intel-nhlt.h>
28 #include <sound/soc-acpi-intel-ssp-common.h>
31 #include <sound/hda-mlink.h>
32 #include "../sof-audio.h"
33 #include "../sof-pci-dev.h"
35 #include "../ipc4-topology.h"
41 #include <sound/soc-acpi-intel-match.h>
51 * and do a Bus Reset, this will need to be modified when the DSP
62 struct snd_soc_dai *d = params_data->dai; in sdw_params_stream()
63 struct snd_soc_dapm_widget *w = snd_soc_dai_get_widget(d, params_data->substream->stream); in sdw_params_stream()
68 d->name); in sdw_params_stream()
69 return -EINVAL; in sdw_params_stream()
71 data.dai_index = (params_data->link_id << 8) | d->id; in sdw_params_stream()
72 data.dai_data = params_data->alh_stream_id; in sdw_params_stream()
80 struct snd_soc_dai *d = free_data->dai; in sdw_params_free()
81 struct snd_soc_dapm_widget *w = snd_soc_dai_get_widget(d, free_data->substream->stream); in sdw_params_free()
84 if (sdev->pdata->ipc_type == SOF_IPC_TYPE_4) { in sdw_params_free()
85 struct snd_sof_widget *swidget = w->dobj.private; in sdw_params_free()
86 struct snd_sof_dai *dai = swidget->private; in sdw_params_free()
90 ipc4_copier = dai->private; in sdw_params_free()
91 ipc4_copier->dai_index = 0; in sdw_params_free()
92 copier_data = &ipc4_copier->data; in sdw_params_free()
95 copier_data->gtw_cfg.node_id &= ~SOF_IPC4_NODE_INDEX_MASK; in sdw_params_free()
109 return sdw_hda_dai_hw_params(params_data->substream, in sdw_ace2x_params_stream()
110 params_data->hw_params, in sdw_ace2x_params_stream()
111 params_data->dai, in sdw_ace2x_params_stream()
112 params_data->link_id, in sdw_ace2x_params_stream()
113 params_data->alh_stream_id); in sdw_ace2x_params_stream()
119 return sdw_hda_dai_hw_free(free_data->substream, in sdw_ace2x_free_stream()
120 free_data->dai, in sdw_ace2x_free_stream()
121 free_data->link_id); in sdw_ace2x_free_stream()
143 return -EINVAL; in hda_sdw_acpi_scan()
145 handle = ACPI_HANDLE(sdev->dev); in hda_sdw_acpi_scan()
148 hdev = sdev->pdata->hw_pdata; in hda_sdw_acpi_scan()
150 ret = sdw_intel_acpi_scan(handle, &hdev->info); in hda_sdw_acpi_scan()
152 return -EINVAL; in hda_sdw_acpi_scan()
164 hdev = sdev->pdata->hw_pdata; in hda_sdw_probe()
168 chip = get_chip_info(sdev->pdata); in hda_sdw_probe()
169 if (chip->hw_ip_version < SOF_INTEL_ACE_2_0) { in hda_sdw_probe()
170 res.mmio_base = sdev->bar[HDA_DSP_BAR]; in hda_sdw_probe()
172 res.shim_base = hdev->desc->sdw_shim_base; in hda_sdw_probe()
173 res.alh_base = hdev->desc->sdw_alh_base; in hda_sdw_probe()
179 * in the HDaudio multi-link areas in hda_sdw_probe()
184 return -ENODEV; in hda_sdw_probe()
186 res.mmio_base = sdev->bar[HDA_DSP_HDA_BAR]; in hda_sdw_probe()
188 * the SHIM and SoundWire register offsets are link-specific in hda_sdw_probe()
196 if (chip->hw_ip_version >= SOF_INTEL_ACE_3_0) in hda_sdw_probe()
199 res.irq = sdev->ipc_irq; in hda_sdw_probe()
200 res.handle = hdev->info.handle; in hda_sdw_probe()
201 res.parent = sdev->dev; in hda_sdw_probe()
203 res.dev = sdev->dev; in hda_sdw_probe()
214 res.count = hdev->info.count; in hda_sdw_probe()
215 res.link_mask = hdev->info.link_mask; in hda_sdw_probe()
219 dev_err(sdev->dev, "error: SoundWire probe failed\n"); in hda_sdw_probe()
220 return -EINVAL; in hda_sdw_probe()
224 hdev->sdw = sdw; in hda_sdw_probe()
232 struct snd_sof_pdata *pdata = sdev->pdata; in hda_sdw_startup()
235 hdev = sdev->pdata->hw_pdata; in hda_sdw_startup()
237 if (!hdev->sdw) in hda_sdw_startup()
240 if (pdata->machine && !pdata->machine->mach_params.link_mask) in hda_sdw_startup()
247 return sdw_intel_startup(hdev->sdw); in hda_sdw_startup()
255 hdev = sdev->pdata->hw_pdata; in hda_sdw_exit()
257 if (hdev->sdw) in hda_sdw_exit()
258 sdw_intel_exit(hdev->sdw); in hda_sdw_exit()
259 hdev->sdw = NULL; in hda_sdw_exit()
272 hdev = sdev->pdata->hw_pdata; in hda_common_check_sdw_irq()
274 if (!hdev->sdw) in hda_common_check_sdw_irq()
301 chip = get_chip_info(sdev->pdata); in hda_dsp_check_sdw_irq()
302 if (chip && chip->check_sdw_irq) in hda_dsp_check_sdw_irq()
303 return chip->check_sdw_irq(sdev); in hda_dsp_check_sdw_irq()
308 static irqreturn_t hda_dsp_sdw_thread(int irq, void *context) in hda_dsp_sdw_thread() argument
310 return sdw_intel_thread(irq, context); in hda_dsp_sdw_thread()
317 hdev = sdev->pdata->hw_pdata; in hda_sdw_check_wakeen_irq_common()
318 if (hdev->sdw && in hda_sdw_check_wakeen_irq_common()
320 hdev->desc->sdw_shim_base + SDW_SHIM_WAKESTS)) in hda_sdw_check_wakeen_irq_common()
335 chip = get_chip_info(sdev->pdata); in hda_sdw_check_wakeen_irq()
336 if (chip && chip->check_sdw_wakeen_irq) in hda_sdw_check_wakeen_irq()
337 return chip->check_sdw_wakeen_irq(sdev); in hda_sdw_check_wakeen_irq()
350 hdev = sdev->pdata->hw_pdata; in hda_sdw_process_wakeen_common()
351 if (!hdev->sdw) in hda_sdw_process_wakeen_common()
354 sdw_intel_process_wakeen_event(hdev->sdw); in hda_sdw_process_wakeen_common()
362 chip = get_chip_info(sdev->pdata); in hda_dsp_sdw_check_mic_privacy_irq()
363 if (chip && chip->check_mic_privacy_irq) in hda_dsp_sdw_check_mic_privacy_irq()
364 return chip->check_mic_privacy_irq(sdev, true, in hda_dsp_sdw_check_mic_privacy_irq()
374 chip = get_chip_info(sdev->pdata); in hda_dsp_sdw_process_mic_privacy()
375 if (chip && chip->process_mic_privacy) in hda_dsp_sdw_process_mic_privacy()
376 chip->process_mic_privacy(sdev, true, AZX_REG_ML_LEPTR_ID_SDW); in hda_dsp_sdw_process_mic_privacy()
400 static inline irqreturn_t hda_dsp_sdw_thread(int irq, void *context) in hda_dsp_sdw_thread() argument
431 if (sdev->first_boot) { in hda_dsp_post_fw_run()
432 struct sof_intel_hda_dev *hdev = sdev->pdata->hw_pdata; in hda_dsp_post_fw_run()
436 dev_err(sdev->dev, in hda_dsp_post_fw_run()
443 (sdev->fw_ready.flags & SOF_IPC_INFO_D3_PERSISTENT || in hda_dsp_post_fw_run()
444 sdev->pdata->ipc_type == SOF_IPC_TYPE_4)) { in hda_dsp_post_fw_run()
445 hdev->imrboot_supported = true; in hda_dsp_post_fw_run()
447 0644, sdev->debugfs_root, in hda_dsp_post_fw_run()
448 &hdev->skip_imr_boot); in hda_dsp_post_fw_run()
454 /* re-enable clock gating and power gating */ in hda_dsp_post_fw_run()
475 static int dmic_num_override = -1;
479 static int mclk_id_override = -1;
491 struct pci_dev *pci = to_pci_dev(sdev->dev); in hda_init()
498 sof_hda_bus_init(sdev, &pci->dev); in hda_init()
501 bus->use_posbuf = 0; in hda_init()
503 bus->use_posbuf = 1; in hda_init()
504 bus->bdl_pos_adj = 0; in hda_init()
505 bus->sync_write = 1; in hda_init()
507 mutex_init(&hbus->prepare_mutex); in hda_init()
508 hbus->pci = pci; in hda_init()
509 hbus->mixer_assigned = -1; in hda_init()
510 hbus->modelname = hda_model; in hda_init()
513 bus->addr = pci_resource_start(pci, 0); in hda_init()
514 bus->remap_addr = pci_ioremap_bar(pci, 0); in hda_init()
515 if (!bus->remap_addr) { in hda_init()
516 dev_err(bus->dev, "error: ioremap error\n"); in hda_init()
517 return -ENXIO; in hda_init()
521 sdev->bar[HDA_DSP_HDA_BAR] = bus->remap_addr; in hda_init()
525 if (ret < 0 && ret != -ENODEV) { in hda_init()
526 dev_err_probe(sdev->dev, ret, "init of i915 and HDMI codec failed\n"); in hda_init()
533 dev_err(sdev->dev, "error: get caps error\n"); in hda_init()
539 iounmap(sof_to_bus(sdev)->remap_addr); in hda_init()
546 struct sof_intel_hda_dev *hdev = sdev->pdata->hw_pdata; in check_dmic_num()
550 nhlt = hdev->nhlt; in check_dmic_num()
552 dmic_num = intel_nhlt_get_dmic_geo(sdev->dev, nhlt); in check_dmic_num()
554 dev_info(sdev->dev, "DMICs detected in NHLT tables: %d\n", dmic_num); in check_dmic_num()
557 if (dmic_num_override != -1) { in check_dmic_num()
558 dev_dbg(sdev->dev, in check_dmic_num()
565 dev_dbg(sdev->dev, "invalid dmic_number %d\n", dmic_num); in check_dmic_num()
574 struct sof_intel_hda_dev *hdev = sdev->pdata->hw_pdata; in check_nhlt_ssp_mask()
578 nhlt = hdev->nhlt; in check_nhlt_ssp_mask()
585 dev_info(sdev->dev, "NHLT device %s(%d) detected, ssp_mask %#x\n", in check_nhlt_ssp_mask()
595 struct sof_intel_hda_dev *hdev = sdev->pdata->hw_pdata; in check_nhlt_ssp_mclk_mask()
598 nhlt = hdev->nhlt; in check_nhlt_ssp_mclk_mask()
609 struct snd_sof_pdata *pdata = sdev->pdata; in hda_init_caps()
610 struct sof_intel_hda_dev *hdev = pdata->hw_pdata; in hda_init_caps()
614 /* check if dsp is there */ in hda_init_caps()
615 if (bus->ppcap) in hda_init_caps()
616 dev_dbg(sdev->dev, "PP capability, will probe DSP later.\n"); in hda_init_caps()
621 dev_err(bus->dev, "error: init chip failed with ret: %d\n", in hda_init_caps()
640 dev_dbg(sdev->dev, "skipping SoundWire, not detected with ACPI scan\n"); in hda_init_caps()
644 link_mask = hdev->info.link_mask; in hda_init_caps()
646 dev_dbg(sdev->dev, "skipping SoundWire, no links enabled\n"); in hda_init_caps()
659 dev_err(sdev->dev, "error: SoundWire probe error\n"); in hda_init_caps()
668 if (!HDA_IDISP_CODEC(bus->codec_mask)) in hda_init_caps()
676 static irqreturn_t hda_dsp_interrupt_handler(int irq, void *context) in hda_dsp_interrupt_handler() argument
699 static irqreturn_t hda_dsp_interrupt_thread(int irq, void *context) in hda_dsp_interrupt_thread() argument
702 struct sof_intel_hda_dev *hdev = sdev->pdata->hw_pdata; in hda_dsp_interrupt_thread()
707 hda_dsp_stream_threaded_handler(irq, sdev); in hda_dsp_interrupt_thread()
712 sof_ops(sdev)->irq_thread(irq, sdev); in hda_dsp_interrupt_thread()
718 hda_dsp_sdw_thread(irq, hdev->sdw); in hda_dsp_interrupt_thread()
744 struct pci_dev *pci = to_pci_dev(sdev->dev); in hda_dsp_probe_early()
749 if (!sdev->dspless_mode_selected) { in hda_dsp_probe_early()
751 * detect DSP by checking class/subclass/prog-id information in hda_dsp_probe_early()
752 * class=04 subclass 03 prog-if 00: no DSP, legacy driver is required in hda_dsp_probe_early()
753 * class=04 subclass 01 prog-if 00: DSP is present in hda_dsp_probe_early()
755 * class=04 subclass 03 prog-if 80: either of DSP or legacy mode works in hda_dsp_probe_early()
757 if (pci->class == 0x040300) { in hda_dsp_probe_early()
758 dev_err(sdev->dev, "the DSP is not enabled on this platform, aborting probe\n"); in hda_dsp_probe_early()
759 return -ENODEV; in hda_dsp_probe_early()
760 } else if (pci->class != 0x040100 && pci->class != 0x040380) { in hda_dsp_probe_early()
761 dev_err(sdev->dev, "unknown PCI class/subclass/prog-if 0x%06x found, aborting probe\n", in hda_dsp_probe_early()
762 pci->class); in hda_dsp_probe_early()
763 return -ENODEV; in hda_dsp_probe_early()
765 dev_info_once(sdev->dev, "DSP detected with PCI class/subclass/prog-if 0x%06x\n", in hda_dsp_probe_early()
766 pci->class); in hda_dsp_probe_early()
769 chip = get_chip_info(sdev->pdata); in hda_dsp_probe_early()
771 dev_err(sdev->dev, "error: no such device supported, chip id:%x\n", in hda_dsp_probe_early()
772 pci->device); in hda_dsp_probe_early()
773 ret = -EIO; in hda_dsp_probe_early()
777 sdev->num_cores = chip->cores_num; in hda_dsp_probe_early()
779 hdev = devm_kzalloc(sdev->dev, sizeof(*hdev), GFP_KERNEL); in hda_dsp_probe_early()
781 return -ENOMEM; in hda_dsp_probe_early()
782 sdev->pdata->hw_pdata = hdev; in hda_dsp_probe_early()
783 hdev->desc = chip; in hda_dsp_probe_early()
793 struct pci_dev *pci = to_pci_dev(sdev->dev); in hda_dsp_probe()
794 struct sof_intel_hda_dev *hdev = sdev->pdata->hw_pdata; in hda_dsp_probe()
798 hdev->dmic_dev = platform_device_register_data(sdev->dev, "dmic-codec", in hda_dsp_probe()
801 if (IS_ERR(hdev->dmic_dev)) { in hda_dsp_probe()
802 dev_err(sdev->dev, "error: failed to create DMIC device\n"); in hda_dsp_probe()
803 return PTR_ERR(hdev->dmic_dev); in hda_dsp_probe()
811 hdev->no_ipc_position = 0; in hda_dsp_probe()
813 hdev->no_ipc_position = sof_ops(sdev)->pcm_pointer ? 1 : 0; in hda_dsp_probe()
816 if (sdev->dspless_mode_selected) in hda_dsp_probe()
817 hdev->no_ipc_position = 1; in hda_dsp_probe()
819 if (sdev->dspless_mode_selected) in hda_dsp_probe()
822 /* DSP base */ in hda_dsp_probe()
823 sdev->bar[HDA_DSP_BAR] = pci_ioremap_bar(pci, HDA_DSP_BAR); in hda_dsp_probe()
824 if (!sdev->bar[HDA_DSP_BAR]) { in hda_dsp_probe()
825 dev_err(sdev->dev, "error: ioremap error\n"); in hda_dsp_probe()
826 ret = -ENXIO; in hda_dsp_probe()
830 sdev->mmio_bar = HDA_DSP_BAR; in hda_dsp_probe()
831 sdev->mailbox_bar = HDA_DSP_BAR; in hda_dsp_probe()
835 if (dma_set_mask_and_coherent(&pci->dev, DMA_BIT_MASK(64))) { in hda_dsp_probe()
836 dev_dbg(sdev->dev, "DMA mask is 32 bit\n"); in hda_dsp_probe()
837 dma_set_mask_and_coherent(&pci->dev, DMA_BIT_MASK(32)); in hda_dsp_probe()
839 dma_set_max_seg_size(&pci->dev, UINT_MAX); in hda_dsp_probe()
844 dev_err(sdev->dev, "error: failed to init streams\n"); in hda_dsp_probe()
853 * register our IRQ in hda_dsp_probe()
859 dev_info(sdev->dev, "use msi interrupt mode\n"); in hda_dsp_probe()
860 sdev->ipc_irq = pci_irq_vector(pci, 0); in hda_dsp_probe()
862 sdev->msi_enabled = true; in hda_dsp_probe()
865 if (!sdev->msi_enabled) { in hda_dsp_probe()
866 dev_info(sdev->dev, "use legacy interrupt mode\n"); in hda_dsp_probe()
868 * in IO-APIC mode, hda->irq and ipc_irq are using the same in hda_dsp_probe()
869 * irq number of pci->irq in hda_dsp_probe()
871 sdev->ipc_irq = pci->irq; in hda_dsp_probe()
874 dev_dbg(sdev->dev, "using IPC IRQ %d\n", sdev->ipc_irq); in hda_dsp_probe()
875 ret = request_threaded_irq(sdev->ipc_irq, hda_dsp_interrupt_handler, in hda_dsp_probe()
879 dev_err(sdev->dev, "error: failed to register IPC IRQ %d\n", in hda_dsp_probe()
880 sdev->ipc_irq); in hda_dsp_probe()
885 synchronize_irq(pci->irq); in hda_dsp_probe()
898 if (!sdev->dspless_mode_selected) { in hda_dsp_probe()
904 sdev->dsp_box.offset = HDA_DSP_MBOX_UPLINK_OFFSET; in hda_dsp_probe()
906 INIT_DELAYED_WORK(&hdev->d0i3_work, hda_dsp_d0i3_work); in hda_dsp_probe()
909 chip = get_chip_info(sdev->pdata); in hda_dsp_probe()
910 if (chip && chip->hw_ip_version >= SOF_INTEL_ACE_2_0) { in hda_dsp_probe()
913 dev_err(sdev->dev, "could not startup SoundWire links\n"); in hda_dsp_probe()
918 init_waitqueue_head(&hdev->waitq); in hda_dsp_probe()
920 hdev->nhlt = intel_nhlt_init(sdev->dev); in hda_dsp_probe()
925 if (!sdev->dspless_mode_selected) { in hda_dsp_probe()
930 free_irq(sdev->ipc_irq, sdev); in hda_dsp_probe()
932 if (sdev->msi_enabled) in hda_dsp_probe()
937 if (!sdev->dspless_mode_selected) in hda_dsp_probe()
938 iounmap(sdev->bar[HDA_DSP_BAR]); in hda_dsp_probe()
940 platform_device_unregister(hdev->dmic_dev); in hda_dsp_probe()
948 struct sof_intel_hda_dev *hda = sdev->pdata->hw_pdata; in hda_dsp_remove()
949 const struct sof_intel_dsp_desc *chip = hda->desc; in hda_dsp_remove()
950 struct pci_dev *pci = to_pci_dev(sdev->dev); in hda_dsp_remove()
951 struct nhlt_acpi_table *nhlt = hda->nhlt; in hda_dsp_remove()
956 if (!sdev->dspless_mode_selected) in hda_dsp_remove()
957 /* cancel any attempt for DSP D0I3 */ in hda_dsp_remove()
958 cancel_delayed_work_sync(&hda->d0i3_work); in hda_dsp_remove()
964 if (!IS_ERR_OR_NULL(hda->dmic_dev)) in hda_dsp_remove()
965 platform_device_unregister(hda->dmic_dev); in hda_dsp_remove()
967 if (!sdev->dspless_mode_selected) { in hda_dsp_remove()
968 /* disable DSP IRQ */ in hda_dsp_remove()
976 if (sdev->dspless_mode_selected) in hda_dsp_remove()
980 if (hda->mic_privacy.active) in hda_dsp_remove()
981 cancel_work_sync(&hda->mic_privacy.work); in hda_dsp_remove()
983 /* no need to check for error as the DSP will be disabled anyway */ in hda_dsp_remove()
984 if (chip && chip->power_down_dsp) in hda_dsp_remove()
985 chip->power_down_dsp(sdev); in hda_dsp_remove()
987 /* disable DSP */ in hda_dsp_remove()
991 if (hda->cl_dmab.area) in hda_dsp_remove()
992 snd_dma_free_pages(&hda->cl_dmab); in hda_dsp_remove()
993 if (hda->iccmax_dmab.area) in hda_dsp_remove()
994 snd_dma_free_pages(&hda->iccmax_dmab); in hda_dsp_remove()
997 free_irq(sdev->ipc_irq, sdev); in hda_dsp_remove()
998 if (sdev->msi_enabled) in hda_dsp_remove()
1005 if (!sdev->dspless_mode_selected) in hda_dsp_remove()
1006 iounmap(sdev->bar[HDA_DSP_BAR]); in hda_dsp_remove()
1012 iounmap(sof_to_bus(sdev)->remap_addr); in hda_dsp_remove_late()
1019 struct sof_intel_hda_dev *hda = sdev->pdata->hw_pdata; in hda_power_down_dsp()
1020 const struct sof_intel_dsp_desc *chip = hda->desc; in hda_power_down_dsp()
1022 return hda_dsp_core_reset_power_down(sdev, chip->host_managed_cores_mask); in hda_power_down_dsp()
1033 struct snd_sof_pdata *pdata = sdev->pdata; in hda_generic_machine_select()
1039 if (!bus->codec_mask) { in hda_generic_machine_select()
1040 dev_info(bus->dev, "no hda codecs found!\n"); in hda_generic_machine_select()
1042 dev_info(bus->dev, "hda codecs found, mask %lx\n", in hda_generic_machine_select()
1043 bus->codec_mask); in hda_generic_machine_select()
1046 if (bus->codec_mask & (1 << i)) in hda_generic_machine_select()
1054 * - one HDMI codec, and/or in hda_generic_machine_select()
1055 * - one external HDAudio codec in hda_generic_machine_select()
1064 hda_mach = devm_kmemdup_array(sdev->dev, in hda_generic_machine_select()
1070 dev_err(bus->dev, in hda_generic_machine_select()
1076 dev_info(bus->dev, "using HDA machine driver %s now\n", in hda_generic_machine_select()
1077 hda_mach->drv_name); in hda_generic_machine_select()
1083 if (!pdata->tplg_filename) in hda_generic_machine_select()
1087 codec_num == 1 && HDA_IDISP_CODEC(bus->codec_mask)) { in hda_generic_machine_select()
1088 tplg_filename = devm_kasprintf(sdev->dev, GFP_KERNEL, in hda_generic_machine_select()
1089 "%s-idisp", in hda_generic_machine_select()
1090 hda_mach->sof_tplg_filename); in hda_generic_machine_select()
1094 hda_mach->sof_tplg_filename = tplg_filename; in hda_generic_machine_select()
1098 (codec_num == 1 && !HDA_IDISP_CODEC(bus->codec_mask))) { in hda_generic_machine_select()
1103 hda_mach->mach_params.link_mask = 0; in hda_generic_machine_select()
1110 struct sof_intel_hda_dev *hdev = sdev->pdata->hw_pdata; in hda_generic_machine_select()
1112 hda_mach->mach_params.link_mask = hdev->info.link_mask; in hda_generic_machine_select()
1121 mach_params = &(*mach)->mach_params; in hda_generic_machine_select()
1122 mach_params->codec_mask = bus->codec_mask; in hda_generic_machine_select()
1136 struct snd_sof_pdata *pdata = sdev->pdata; in hda_sdw_machine_select()
1144 hdev = pdata->hw_pdata; in hda_sdw_machine_select()
1145 link_mask = hdev->info.link_mask; in hda_sdw_machine_select()
1148 dev_info(sdev->dev, "SoundWire links not enabled\n"); in hda_sdw_machine_select()
1152 if (!hdev->sdw) { in hda_sdw_machine_select()
1153 dev_dbg(sdev->dev, "SoundWire context not allocated\n"); in hda_sdw_machine_select()
1157 if (!hdev->sdw->peripherals || !hdev->sdw->peripherals->num_peripherals) { in hda_sdw_machine_select()
1158 dev_warn(sdev->dev, "No SoundWire peripheral detected in ACPI tables\n"); in hda_sdw_machine_select()
1164 * alternate tables. This case deals with SoundWire-only in hda_sdw_machine_select()
1168 for (mach = pdata->desc->alt_machines; in hda_sdw_machine_select()
1169 mach && mach->link_mask; mach++) { in hda_sdw_machine_select()
1178 if (~link_mask & mach->link_mask) in hda_sdw_machine_select()
1182 if (!mach->links) in hda_sdw_machine_select()
1185 link = mach->links; in hda_sdw_machine_select()
1186 for (i = 0; i < hdev->info.count && link->num_adr; in hda_sdw_machine_select()
1192 if (!snd_soc_acpi_sdw_link_slaves_found(sdev->dev, link, in hda_sdw_machine_select()
1193 hdev->sdw->peripherals)) in hda_sdw_machine_select()
1197 if (i == hdev->info.count || !link->num_adr) in hda_sdw_machine_select()
1198 if (!mach->machine_check || mach->machine_check(hdev->sdw)) in hda_sdw_machine_select()
1201 if (mach && mach->link_mask) { in hda_sdw_machine_select()
1202 mach->mach_params.links = mach->links; in hda_sdw_machine_select()
1203 mach->mach_params.link_mask = mach->link_mask; in hda_sdw_machine_select()
1204 mach->mach_params.platform = dev_name(sdev->dev); in hda_sdw_machine_select()
1209 dev_info(sdev->dev, "No SoundWire machine driver found for the ACPI-reported configuration:\n"); in hda_sdw_machine_select()
1210 peripherals = hdev->sdw->peripherals; in hda_sdw_machine_select()
1211 for (i = 0; i < peripherals->num_peripherals; i++) in hda_sdw_machine_select()
1212 dev_info(sdev->dev, "link %d mfg_id 0x%04x part_id 0x%04x version %#x\n", in hda_sdw_machine_select()
1213 peripherals->array[i]->bus->link_id, in hda_sdw_machine_select()
1214 peripherals->array[i]->id.mfg_id, in hda_sdw_machine_select()
1215 peripherals->array[i]->id.part_id, in hda_sdw_machine_select()
1216 peripherals->array[i]->id.sdw_version); in hda_sdw_machine_select()
1230 struct snd_sof_pdata *pdata = sdev->pdata; in hda_set_mach_params()
1231 const struct sof_dev_desc *desc = pdata->desc; in hda_set_mach_params()
1234 mach_params = &mach->mach_params; in hda_set_mach_params()
1235 mach_params->platform = dev_name(sdev->dev); in hda_set_mach_params()
1238 mach_params->num_dai_drivers = SOF_SKL_NUM_DAIS_NOCODEC; in hda_set_mach_params()
1240 mach_params->num_dai_drivers = desc->ops->num_drv; in hda_set_mach_params()
1241 mach_params->dai_drivers = desc->ops->drv; in hda_set_mach_params()
1254 dmic_ssp_quirk = mach->tplg_quirk_mask & in check_tplg_quirk_mask()
1256 codec_amp_name_quirk = mach->tplg_quirk_mask & in check_tplg_quirk_mask()
1260 return -EINVAL; in check_tplg_quirk_mask()
1281 struct snd_sof_pdata *sof_pdata = sdev->pdata; in hda_machine_select()
1282 const struct sof_dev_desc *desc = sof_pdata->desc; in hda_machine_select()
1294 mach = snd_soc_acpi_find_machine(desc->machines); in hda_machine_select()
1303 if (!mach && !HDA_EXT_CODEC(bus->codec_mask) && in hda_machine_select()
1316 dev_warn(sdev->dev, "warning: No matching ASoC machine driver found\n"); in hda_machine_select()
1321 mach->mach_params.bt_link_mask = check_nhlt_ssp_mask(sdev, NHLT_DEVICE_BT); in hda_machine_select()
1323 dev_info(sdev->dev, "BT link detected in NHLT tables: %#x\n", in hda_machine_select()
1324 mach->mach_params.bt_link_mask); in hda_machine_select()
1328 dev_dbg(sdev->dev, "overriding BT link detected in NHLT tables %#x by kernel param %#x\n", in hda_machine_select()
1329 mach->mach_params.bt_link_mask, bt_link_mask_override); in hda_machine_select()
1330 mach->mach_params.bt_link_mask = bt_link_mask_override; in hda_machine_select()
1333 if (hweight_long(mach->mach_params.bt_link_mask) > 1) { in hda_machine_select()
1334 dev_warn(sdev->dev, "invalid BT link mask %#x found, reset the mask\n", in hda_machine_select()
1335 mach->mach_params.bt_link_mask); in hda_machine_select()
1336 mach->mach_params.bt_link_mask = 0; in hda_machine_select()
1351 if (!sof_pdata->tplg_filename) { in hda_machine_select()
1353 tplg_filename = remove_file_ext(sdev->dev, mach->sof_tplg_filename); in hda_machine_select()
1357 sof_pdata->tplg_filename = tplg_filename; in hda_machine_select()
1367 dev_err(sdev->dev, "Invalid tplg quirk mask 0x%x\n", in hda_machine_select()
1368 mach->tplg_quirk_mask); in hda_machine_select()
1373 mach->mach_params.dmic_num = check_dmic_num(sdev); in hda_machine_select()
1375 if (sdw_mach_found || mach->tplg_quirk_mask & SND_SOC_ACPI_TPLG_INTEL_DMIC_NUMBER) in hda_machine_select()
1380 mach->mach_params.dmic_num) { in hda_machine_select()
1381 tplg_filename = devm_kasprintf(sdev->dev, GFP_KERNEL, in hda_machine_select()
1383 sof_pdata->tplg_filename, in hda_machine_select()
1384 i2s_mach_found ? "-dmic" : "-", in hda_machine_select()
1385 mach->mach_params.dmic_num, in hda_machine_select()
1390 sof_pdata->tplg_filename = tplg_filename; in hda_machine_select()
1393 if (mach->link_mask) { in hda_machine_select()
1394 mach->mach_params.links = mach->links; in hda_machine_select()
1395 mach->mach_params.link_mask = mach->link_mask; in hda_machine_select()
1399 mach->mach_params.i2s_link_mask = check_nhlt_ssp_mask(sdev, NHLT_DEVICE_I2S); in hda_machine_select()
1402 mach->tplg_quirk_mask & SND_SOC_ACPI_TPLG_INTEL_SSP_NUMBER && in hda_machine_select()
1403 mach->mach_params.i2s_link_mask) { in hda_machine_select()
1404 const struct sof_intel_dsp_desc *chip = get_chip_info(sdev->pdata); in hda_machine_select()
1408 if (hweight_long(mach->mach_params.i2s_link_mask) > 1 && in hda_machine_select()
1409 !(mach->tplg_quirk_mask & SND_SOC_ACPI_TPLG_INTEL_SSP_MSB)) in hda_machine_select()
1410 dev_warn(sdev->dev, "More than one SSP exposed by NHLT, choosing MSB\n"); in hda_machine_select()
1412 /* fls returns 1-based results, SSPs indices are 0-based */ in hda_machine_select()
1413 ssp_num = fls(mach->mach_params.i2s_link_mask) - 1; in hda_machine_select()
1415 if (ssp_num >= chip->ssp_count) { in hda_machine_select()
1416 dev_err(sdev->dev, "Invalid SSP %d, max on this platform is %d\n", in hda_machine_select()
1417 ssp_num, chip->ssp_count); in hda_machine_select()
1421 tplg_filename = devm_kasprintf(sdev->dev, GFP_KERNEL, in hda_machine_select()
1423 sof_pdata->tplg_filename, in hda_machine_select()
1424 "-ssp", in hda_machine_select()
1429 sof_pdata->tplg_filename = tplg_filename; in hda_machine_select()
1434 dev_err(sdev->dev, "Invalid MCLK configuration\n"); in hda_machine_select()
1438 dev_dbg(sdev->dev, "MCLK mask %#x found in NHLT\n", mclk_mask); in hda_machine_select()
1441 dev_info(sdev->dev, "Overriding topology with MCLK mask %#x from NHLT\n", mclk_mask); in hda_machine_select()
1442 sdev->mclk_id_override = true; in hda_machine_select()
1443 sdev->mclk_id_quirk = (mclk_mask & BIT(0)) ? 0 : 1; in hda_machine_select()
1447 amp_type = snd_soc_acpi_intel_detect_amp_type(sdev->dev); in hda_machine_select()
1448 codec_type = snd_soc_acpi_intel_detect_codec_type(sdev->dev); in hda_machine_select()
1452 mach->tplg_quirk_mask & SND_SOC_ACPI_TPLG_INTEL_AMP_NAME) { in hda_machine_select()
1455 dev_err(sdev->dev, "no tplg suffix found, amp %d\n", in hda_machine_select()
1460 tplg_filename = devm_kasprintf(sdev->dev, GFP_KERNEL, in hda_machine_select()
1461 "%s-%s", in hda_machine_select()
1462 sof_pdata->tplg_filename, in hda_machine_select()
1467 sof_pdata->tplg_filename = tplg_filename; in hda_machine_select()
1472 mach->tplg_quirk_mask & SND_SOC_ACPI_TPLG_INTEL_CODEC_NAME && in hda_machine_select()
1476 dev_err(sdev->dev, "no tplg suffix found, codec %d\n", in hda_machine_select()
1481 tplg_filename = devm_kasprintf(sdev->dev, GFP_KERNEL, in hda_machine_select()
1482 "%s-%s", in hda_machine_select()
1483 sof_pdata->tplg_filename, in hda_machine_select()
1488 sof_pdata->tplg_filename = tplg_filename; in hda_machine_select()
1492 tplg_filename = devm_kasprintf(sdev->dev, GFP_KERNEL, in hda_machine_select()
1494 sof_pdata->tplg_filename, in hda_machine_select()
1499 sof_pdata->tplg_filename = tplg_filename; in hda_machine_select()
1504 … dev_info(sdev->dev, "Overriding topology with MCLK %d from kernel_parameter\n", mclk_id_override); in hda_machine_select()
1505 sdev->mclk_id_override = true; in hda_machine_select()
1506 sdev->mclk_id_quirk = mclk_id_override; in hda_machine_select()
1519 dev_dbg(&pci->dev, "SOF PCI driver not selected, aborting probe\n"); in hda_pci_intel_probe()
1520 return -ENODEV; in hda_pci_intel_probe()