• Home
  • Raw
  • Download

Lines Matching +full:soundwire +full:- +full:controller

1 // SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause)
23 #include <linux/soundwire/sdw.h>
24 #include <linux/soundwire/sdw_intel.h>
25 #include <sound/intel-dsp-config.h>
26 #include <sound/intel-nhlt.h>
29 #include <sound/hda-mlink.h>
30 #include "../sof-audio.h"
31 #include "../sof-pci-dev.h"
39 #include <sound/soc-acpi-intel-match.h>
53 chip = get_chip_info(sdev->pdata); in hda_get_interface_mask()
54 switch (chip->hw_ip_version) { in hda_get_interface_mask()
83 return interface_mask[sdev->dspless_mode_selected]; in hda_get_interface_mask()
89 * The default for SoundWire clock stop quirks is to power gate the IP
96 MODULE_PARM_DESC(sdw_clock_stop_quirks, "SOF SoundWire clock stop quirks");
101 struct snd_soc_dai *d = params_data->dai; in sdw_params_stream()
102 struct snd_soc_dapm_widget *w = snd_soc_dai_get_widget(d, params_data->substream->stream); in sdw_params_stream()
105 data.dai_index = (params_data->link_id << 8) | d->id; in sdw_params_stream()
106 data.dai_data = params_data->alh_stream_id; in sdw_params_stream()
118 return sdw_hda_dai_hw_params(params_data->substream, in sdw_ace2x_params_stream()
119 params_data->hw_params, in sdw_ace2x_params_stream()
120 params_data->dai, in sdw_ace2x_params_stream()
121 params_data->link_id); in sdw_ace2x_params_stream()
127 return sdw_hda_dai_hw_free(free_data->substream, in sdw_ace2x_free_stream()
128 free_data->dai, in sdw_ace2x_free_stream()
129 free_data->link_id); in sdw_ace2x_free_stream()
147 hdev = sdev->pdata->hw_pdata; in hda_common_enable_sdw_irq()
149 if (!hdev->sdw) in hda_common_enable_sdw_irq()
165 chip = get_chip_info(sdev->pdata); in hda_sdw_int_enable()
166 if (chip && chip->enable_sdw_irq) in hda_sdw_int_enable()
167 chip->enable_sdw_irq(sdev, enable); in hda_sdw_int_enable()
178 return -EINVAL; in hda_sdw_acpi_scan()
180 handle = ACPI_HANDLE(sdev->dev); in hda_sdw_acpi_scan()
183 hdev = sdev->pdata->hw_pdata; in hda_sdw_acpi_scan()
185 ret = sdw_intel_acpi_scan(handle, &hdev->info); in hda_sdw_acpi_scan()
187 return -EINVAL; in hda_sdw_acpi_scan()
199 hdev = sdev->pdata->hw_pdata; in hda_sdw_probe()
203 chip = get_chip_info(sdev->pdata); in hda_sdw_probe()
204 if (chip->hw_ip_version < SOF_INTEL_ACE_2_0) { in hda_sdw_probe()
205 res.mmio_base = sdev->bar[HDA_DSP_BAR]; in hda_sdw_probe()
207 res.shim_base = hdev->desc->sdw_shim_base; in hda_sdw_probe()
208 res.alh_base = hdev->desc->sdw_alh_base; in hda_sdw_probe()
214 * in the HDaudio multi-link areas in hda_sdw_probe()
219 return -ENODEV; in hda_sdw_probe()
221 res.mmio_base = sdev->bar[HDA_DSP_HDA_BAR]; in hda_sdw_probe()
223 * the SHIM and SoundWire register offsets are link-specific in hda_sdw_probe()
231 res.irq = sdev->ipc_irq; in hda_sdw_probe()
232 res.handle = hdev->info.handle; in hda_sdw_probe()
233 res.parent = sdev->dev; in hda_sdw_probe()
235 res.dev = sdev->dev; in hda_sdw_probe()
246 res.count = hdev->info.count; in hda_sdw_probe()
247 res.link_mask = hdev->info.link_mask; in hda_sdw_probe()
251 dev_err(sdev->dev, "error: SoundWire probe failed\n"); in hda_sdw_probe()
252 return -EINVAL; in hda_sdw_probe()
256 hdev->sdw = sdw; in hda_sdw_probe()
267 hdev = sdev->pdata->hw_pdata; in hda_sdw_check_lcount_common()
268 ctx = hdev->sdw; in hda_sdw_check_lcount_common()
270 caps = snd_sof_dsp_read(sdev, HDA_DSP_BAR, ctx->shim_base + SDW_SHIM_LCAP); in hda_sdw_check_lcount_common()
274 if (caps < ctx->count) { in hda_sdw_check_lcount_common()
275 dev_err(sdev->dev, in hda_sdw_check_lcount_common()
277 __func__, ctx->count, caps); in hda_sdw_check_lcount_common()
278 return -EINVAL; in hda_sdw_check_lcount_common()
293 hdev = sdev->pdata->hw_pdata; in hda_sdw_check_lcount_ext()
294 ctx = hdev->sdw; in hda_sdw_check_lcount_ext()
299 if (slcount < ctx->count) { in hda_sdw_check_lcount_ext()
300 dev_err(sdev->dev, in hda_sdw_check_lcount_ext()
302 __func__, ctx->count, slcount); in hda_sdw_check_lcount_ext()
303 return -EINVAL; in hda_sdw_check_lcount_ext()
313 chip = get_chip_info(sdev->pdata); in hda_sdw_check_lcount()
314 if (chip && chip->read_sdw_lcount) in hda_sdw_check_lcount()
315 return chip->read_sdw_lcount(sdev); in hda_sdw_check_lcount()
323 struct snd_sof_pdata *pdata = sdev->pdata; in hda_sdw_startup()
326 hdev = sdev->pdata->hw_pdata; in hda_sdw_startup()
328 if (!hdev->sdw) in hda_sdw_startup()
331 if (pdata->machine && !pdata->machine->mach_params.link_mask) in hda_sdw_startup()
338 return sdw_intel_startup(hdev->sdw); in hda_sdw_startup()
345 hdev = sdev->pdata->hw_pdata; in hda_sdw_exit()
349 if (hdev->sdw) in hda_sdw_exit()
350 sdw_intel_exit(hdev->sdw); in hda_sdw_exit()
351 hdev->sdw = NULL; in hda_sdw_exit()
362 hdev = sdev->pdata->hw_pdata; in hda_common_check_sdw_irq()
364 if (!hdev->sdw) in hda_common_check_sdw_irq()
390 chip = get_chip_info(sdev->pdata); in hda_dsp_check_sdw_irq()
391 if (chip && chip->check_sdw_irq) in hda_dsp_check_sdw_irq()
392 return chip->check_sdw_irq(sdev); in hda_dsp_check_sdw_irq()
406 hdev = sdev->pdata->hw_pdata; in hda_sdw_check_wakeen_irq_common()
407 if (hdev->sdw && in hda_sdw_check_wakeen_irq_common()
409 hdev->desc->sdw_shim_base + SDW_SHIM_WAKESTS)) in hda_sdw_check_wakeen_irq_common()
423 chip = get_chip_info(sdev->pdata); in hda_sdw_check_wakeen_irq()
424 if (chip && chip->check_sdw_wakeen_irq) in hda_sdw_check_wakeen_irq()
425 return chip->check_sdw_wakeen_irq(sdev); in hda_sdw_check_wakeen_irq()
438 hdev = sdev->pdata->hw_pdata; in hda_sdw_process_wakeen()
439 if (!hdev->sdw) in hda_sdw_process_wakeen()
442 sdw_intel_process_wakeen_event(hdev->sdw); in hda_sdw_process_wakeen()
503 static int dmic_num_override = -1;
507 static int mclk_id_override = -1;
600 const struct sof_intel_dsp_desc *chip = get_chip_info(sdev->pdata); in hda_dsp_get_state()
604 fsr = snd_sof_dsp_read(sdev, HDA_DSP_BAR, chip->rom_status_reg); in hda_dsp_get_state()
623 dev_printk(level, sdev->dev, "%#010x: unknown ROM status value\n", fsr); in hda_dsp_get_state()
635 dev_printk(level, sdev->dev, in hda_dsp_get_state()
640 dev_printk(level, sdev->dev, "%#010x: module: %s, state: %s, %s\n", in hda_dsp_get_state()
645 error_code = snd_sof_dsp_read(sdev, HDA_DSP_BAR, chip->rom_status_reg + 4); in hda_dsp_get_state()
655 dev_printk(level, sdev->dev, "status code: %#x (%s)\n", error_code, in hda_dsp_get_state()
658 dev_printk(level, sdev->dev, "error code: %#x (%s)\n", error_code, in hda_dsp_get_state()
667 u32 offset = sdev->dsp_oops_offset; in hda_dsp_get_registers()
675 if (xoops->arch_hdr.totalsize > EXCEPT_MAX_HDR_SIZE) { in hda_dsp_get_registers()
676 dev_err(sdev->dev, "invalid header size 0x%x. FW oops is bogus\n", in hda_dsp_get_registers()
677 xoops->arch_hdr.totalsize); in hda_dsp_get_registers()
680 offset += xoops->arch_hdr.totalsize; in hda_dsp_get_registers()
681 sof_block_read(sdev, sdev->mmio_bar, offset, in hda_dsp_get_registers()
686 sof_block_read(sdev, sdev->mmio_bar, offset, stack, in hda_dsp_get_registers()
700 chip = get_chip_info(sdev->pdata); in hda_dsp_dump_ext_rom_status()
702 value = snd_sof_dsp_read(sdev, HDA_DSP_BAR, chip->rom_status_reg + i * 0x4); in hda_dsp_dump_ext_rom_status()
703 len += scnprintf(msg + len, sizeof(msg) - len, " 0x%x", value); in hda_dsp_dump_ext_rom_status()
706 dev_printk(level, sdev->dev, "extended rom status: %s", msg); in hda_dsp_dump_ext_rom_status()
721 if (flags & SOF_DBG_DUMP_REGS && sdev->pdata->ipc_type == SOF_IPC) { in hda_dsp_dump()
738 chip = get_chip_info(sdev->pdata); in hda_check_ipc_irq()
739 if (chip && chip->check_ipc_irq) in hda_check_ipc_irq()
740 return chip->check_ipc_irq(sdev); in hda_check_ipc_irq()
760 dev_err(sdev->dev, "hda irq intsts 0x%8.8x intlctl 0x%8.8x rirb %2.2x\n", in hda_ipc_irq_dump()
762 dev_err(sdev->dev, "dsp irq ppsts 0x%8.8x adspis 0x%8.8x\n", ppsts, adspis); in hda_ipc_irq_dump()
780 dev_err(sdev->dev, "host status 0x%8.8x dsp status 0x%8.8x mask 0x%8.8x\n", in hda_ipc_dump()
798 dev_err(sdev->dev, "Host IPC initiator: %#x|%#x, target: %#x|%#x, ctl: %#x\n", in hda_ipc4_dump()
804 struct sof_intel_hda_dev *hda = sdev->pdata->hw_pdata; in hda_ipc4_tx_is_busy()
805 const struct sof_intel_dsp_desc *chip = hda->desc; in hda_ipc4_tx_is_busy()
808 val = snd_sof_dsp_read(sdev, HDA_DSP_BAR, chip->ipc_req); in hda_ipc4_tx_is_busy()
810 return !!(val & chip->ipc_req_mask); in hda_ipc4_tx_is_busy()
817 struct pci_dev *pci = to_pci_dev(sdev->dev); in hda_init()
824 sof_hda_bus_init(sdev, &pci->dev); in hda_init()
827 bus->use_posbuf = 0; in hda_init()
829 bus->use_posbuf = 1; in hda_init()
830 bus->bdl_pos_adj = 0; in hda_init()
831 bus->sync_write = 1; in hda_init()
833 mutex_init(&hbus->prepare_mutex); in hda_init()
834 hbus->pci = pci; in hda_init()
835 hbus->mixer_assigned = -1; in hda_init()
836 hbus->modelname = hda_model; in hda_init()
839 bus->addr = pci_resource_start(pci, 0); in hda_init()
840 bus->remap_addr = pci_ioremap_bar(pci, 0); in hda_init()
841 if (!bus->remap_addr) { in hda_init()
842 dev_err(bus->dev, "error: ioremap error\n"); in hda_init()
843 return -ENXIO; in hda_init()
847 sdev->bar[HDA_DSP_HDA_BAR] = bus->remap_addr; in hda_init()
852 dev_warn(sdev->dev, "init of i915 and HDMI codec failed\n"); in hda_init()
854 /* get controller capabilities */ in hda_init()
857 dev_err(sdev->dev, "error: get caps error\n"); in hda_init()
864 struct sof_intel_hda_dev *hdev = sdev->pdata->hw_pdata; in check_dmic_num()
868 nhlt = hdev->nhlt; in check_dmic_num()
870 dmic_num = intel_nhlt_get_dmic_geo(sdev->dev, nhlt); in check_dmic_num()
873 if (dmic_num_override != -1) { in check_dmic_num()
874 dev_dbg(sdev->dev, in check_dmic_num()
881 dev_dbg(sdev->dev, "invalid dmic_number %d\n", dmic_num); in check_dmic_num()
890 struct sof_intel_hda_dev *hdev = sdev->pdata->hw_pdata; in check_nhlt_ssp_mask()
894 nhlt = hdev->nhlt; in check_nhlt_ssp_mask()
901 dev_info(sdev->dev, "NHLT_DEVICE_I2S detected, ssp_mask %#x\n", ssp_mask); in check_nhlt_ssp_mask()
909 struct sof_intel_hda_dev *hdev = sdev->pdata->hw_pdata; in check_nhlt_ssp_mclk_mask()
912 nhlt = hdev->nhlt; in check_nhlt_ssp_mclk_mask()
938 tplg_filename = devm_kasprintf(sdev->dev, GFP_KERNEL, in fixup_tplg_name()
960 dmic_str = "-1ch"; in dmic_detect_topology_fixup()
963 dmic_str = "-2ch"; in dmic_detect_topology_fixup()
966 dmic_str = "-3ch"; in dmic_detect_topology_fixup()
969 dmic_str = "-4ch"; in dmic_detect_topology_fixup()
984 return -ENOMEM; in dmic_detect_topology_fixup()
988 dev_info(sdev->dev, "DMICs detected in NHLT tables: %d\n", dmic_num); in dmic_detect_topology_fixup()
999 struct snd_sof_pdata *pdata = sdev->pdata; in hda_init_caps()
1000 struct sof_intel_hda_dev *hdev = pdata->hw_pdata; in hda_init_caps()
1005 if (bus->ppcap) in hda_init_caps()
1006 dev_dbg(sdev->dev, "PP capability, will probe DSP later.\n"); in hda_init_caps()
1008 /* Init HDA controller after i915 init */ in hda_init_caps()
1011 dev_err(bus->dev, "error: init chip failed with ret: %d\n", in hda_init_caps()
1018 /* Skip SoundWire if it is not supported */ in hda_init_caps()
1022 /* scan SoundWire capabilities exposed by DSDT */ in hda_init_caps()
1025 dev_dbg(sdev->dev, "skipping SoundWire, not detected with ACPI scan\n"); in hda_init_caps()
1029 link_mask = hdev->info.link_mask; in hda_init_caps()
1031 dev_dbg(sdev->dev, "skipping SoundWire, no links enabled\n"); in hda_init_caps()
1036 * probe/allocate SoundWire resources. in hda_init_caps()
1039 * It's entirely possible to have a mix of I2S/DMIC/SoundWire in hda_init_caps()
1044 dev_err(sdev->dev, "error: SoundWire probe error\n"); in hda_init_caps()
1053 if (!HDA_IDISP_CODEC(bus->codec_mask)) in hda_init_caps()
1067 * sources in the Intel HD Audio controller. in hda_dsp_interrupt_handler()
1087 struct sof_intel_hda_dev *hdev = sdev->pdata->hw_pdata; in hda_dsp_interrupt_thread()
1089 /* deal with streams and controller first */ in hda_dsp_interrupt_thread()
1097 sof_ops(sdev)->irq_thread(irq, sdev); in hda_dsp_interrupt_thread()
1102 hda_dsp_sdw_thread(irq, hdev->sdw); in hda_dsp_interrupt_thread()
1123 struct pci_dev *pci = to_pci_dev(sdev->dev); in hda_dsp_probe()
1129 if (!sdev->dspless_mode_selected) { in hda_dsp_probe()
1131 * detect DSP by checking class/subclass/prog-id information in hda_dsp_probe()
1132 * class=04 subclass 03 prog-if 00: no DSP, legacy driver is required in hda_dsp_probe()
1133 * class=04 subclass 01 prog-if 00: DSP is present in hda_dsp_probe()
1135 * class=04 subclass 03 prog-if 80: either of DSP or legacy mode works in hda_dsp_probe()
1137 if (pci->class == 0x040300) { in hda_dsp_probe()
1138 dev_err(sdev->dev, "the DSP is not enabled on this platform, aborting probe\n"); in hda_dsp_probe()
1139 return -ENODEV; in hda_dsp_probe()
1140 } else if (pci->class != 0x040100 && pci->class != 0x040380) { in hda_dsp_probe()
1141 dev_err(sdev->dev, "unknown PCI class/subclass/prog-if 0x%06x found, aborting probe\n", in hda_dsp_probe()
1142 pci->class); in hda_dsp_probe()
1143 return -ENODEV; in hda_dsp_probe()
1145 dev_info(sdev->dev, "DSP detected with PCI class/subclass/prog-if 0x%06x\n", in hda_dsp_probe()
1146 pci->class); in hda_dsp_probe()
1149 chip = get_chip_info(sdev->pdata); in hda_dsp_probe()
1151 dev_err(sdev->dev, "error: no such device supported, chip id:%x\n", in hda_dsp_probe()
1152 pci->device); in hda_dsp_probe()
1153 ret = -EIO; in hda_dsp_probe()
1157 sdev->num_cores = chip->cores_num; in hda_dsp_probe()
1159 hdev = devm_kzalloc(sdev->dev, sizeof(*hdev), GFP_KERNEL); in hda_dsp_probe()
1161 return -ENOMEM; in hda_dsp_probe()
1162 sdev->pdata->hw_pdata = hdev; in hda_dsp_probe()
1163 hdev->desc = chip; in hda_dsp_probe()
1165 hdev->dmic_dev = platform_device_register_data(sdev->dev, "dmic-codec", in hda_dsp_probe()
1168 if (IS_ERR(hdev->dmic_dev)) { in hda_dsp_probe()
1169 dev_err(sdev->dev, "error: failed to create DMIC device\n"); in hda_dsp_probe()
1170 return PTR_ERR(hdev->dmic_dev); in hda_dsp_probe()
1178 hdev->no_ipc_position = 0; in hda_dsp_probe()
1180 hdev->no_ipc_position = sof_ops(sdev)->pcm_pointer ? 1 : 0; in hda_dsp_probe()
1183 if (sdev->dspless_mode_selected) in hda_dsp_probe()
1184 hdev->no_ipc_position = 1; in hda_dsp_probe()
1192 if (sdev->dspless_mode_selected) in hda_dsp_probe()
1196 sdev->bar[HDA_DSP_BAR] = pci_ioremap_bar(pci, HDA_DSP_BAR); in hda_dsp_probe()
1197 if (!sdev->bar[HDA_DSP_BAR]) { in hda_dsp_probe()
1198 dev_err(sdev->dev, "error: ioremap error\n"); in hda_dsp_probe()
1199 ret = -ENXIO; in hda_dsp_probe()
1203 sdev->mmio_bar = HDA_DSP_BAR; in hda_dsp_probe()
1204 sdev->mailbox_bar = HDA_DSP_BAR; in hda_dsp_probe()
1208 if (dma_set_mask_and_coherent(&pci->dev, DMA_BIT_MASK(64))) { in hda_dsp_probe()
1209 dev_dbg(sdev->dev, "DMA mask is 32 bit\n"); in hda_dsp_probe()
1210 dma_set_mask_and_coherent(&pci->dev, DMA_BIT_MASK(32)); in hda_dsp_probe()
1212 dma_set_max_seg_size(&pci->dev, UINT_MAX); in hda_dsp_probe()
1217 dev_err(sdev->dev, "error: failed to init streams\n"); in hda_dsp_probe()
1232 dev_info(sdev->dev, "use msi interrupt mode\n"); in hda_dsp_probe()
1233 sdev->ipc_irq = pci_irq_vector(pci, 0); in hda_dsp_probe()
1235 sdev->msi_enabled = true; in hda_dsp_probe()
1238 if (!sdev->msi_enabled) { in hda_dsp_probe()
1239 dev_info(sdev->dev, "use legacy interrupt mode\n"); in hda_dsp_probe()
1241 * in IO-APIC mode, hda->irq and ipc_irq are using the same in hda_dsp_probe()
1242 * irq number of pci->irq in hda_dsp_probe()
1244 sdev->ipc_irq = pci->irq; in hda_dsp_probe()
1247 dev_dbg(sdev->dev, "using IPC IRQ %d\n", sdev->ipc_irq); in hda_dsp_probe()
1248 ret = request_threaded_irq(sdev->ipc_irq, hda_dsp_interrupt_handler, in hda_dsp_probe()
1252 dev_err(sdev->dev, "error: failed to register IPC IRQ %d\n", in hda_dsp_probe()
1253 sdev->ipc_irq); in hda_dsp_probe()
1258 synchronize_irq(pci->irq); in hda_dsp_probe()
1271 if (!sdev->dspless_mode_selected) { in hda_dsp_probe()
1277 sdev->dsp_box.offset = HDA_DSP_MBOX_UPLINK_OFFSET; in hda_dsp_probe()
1279 INIT_DELAYED_WORK(&hdev->d0i3_work, hda_dsp_d0i3_work); in hda_dsp_probe()
1282 init_waitqueue_head(&hdev->waitq); in hda_dsp_probe()
1284 hdev->nhlt = intel_nhlt_init(sdev->dev); in hda_dsp_probe()
1289 free_irq(sdev->ipc_irq, sdev); in hda_dsp_probe()
1291 if (sdev->msi_enabled) in hda_dsp_probe()
1296 if (!sdev->dspless_mode_selected) in hda_dsp_probe()
1297 iounmap(sdev->bar[HDA_DSP_BAR]); in hda_dsp_probe()
1299 platform_device_unregister(hdev->dmic_dev); in hda_dsp_probe()
1300 iounmap(bus->remap_addr); in hda_dsp_probe()
1308 struct sof_intel_hda_dev *hda = sdev->pdata->hw_pdata; in hda_dsp_remove()
1309 const struct sof_intel_dsp_desc *chip = hda->desc; in hda_dsp_remove()
1311 struct pci_dev *pci = to_pci_dev(sdev->dev); in hda_dsp_remove()
1312 struct nhlt_acpi_table *nhlt = hda->nhlt; in hda_dsp_remove()
1317 if (!sdev->dspless_mode_selected) in hda_dsp_remove()
1319 cancel_delayed_work_sync(&hda->d0i3_work); in hda_dsp_remove()
1325 if (!IS_ERR_OR_NULL(hda->dmic_dev)) in hda_dsp_remove()
1326 platform_device_unregister(hda->dmic_dev); in hda_dsp_remove()
1328 if (!sdev->dspless_mode_selected) { in hda_dsp_remove()
1338 if (sdev->dspless_mode_selected) in hda_dsp_remove()
1342 if (chip && chip->power_down_dsp) in hda_dsp_remove()
1343 chip->power_down_dsp(sdev); in hda_dsp_remove()
1350 free_irq(sdev->ipc_irq, sdev); in hda_dsp_remove()
1351 if (sdev->msi_enabled) in hda_dsp_remove()
1358 if (!sdev->dspless_mode_selected) in hda_dsp_remove()
1359 iounmap(sdev->bar[HDA_DSP_BAR]); in hda_dsp_remove()
1361 iounmap(bus->remap_addr); in hda_dsp_remove()
1372 struct sof_intel_hda_dev *hda = sdev->pdata->hw_pdata; in hda_power_down_dsp()
1373 const struct sof_intel_dsp_desc *chip = hda->desc; in hda_power_down_dsp()
1375 return hda_dsp_core_reset_power_down(sdev, chip->host_managed_cores_mask); in hda_power_down_dsp()
1385 struct snd_sof_pdata *pdata = sdev->pdata; in hda_generic_machine_select()
1394 if (!bus->codec_mask) { in hda_generic_machine_select()
1395 dev_info(bus->dev, "no hda codecs found!\n"); in hda_generic_machine_select()
1397 dev_info(bus->dev, "hda codecs found, mask %lx\n", in hda_generic_machine_select()
1398 bus->codec_mask); in hda_generic_machine_select()
1401 if (bus->codec_mask & (1 << i)) in hda_generic_machine_select()
1409 * - one HDMI codec, and/or in hda_generic_machine_select()
1410 * - one external HDAudio codec in hda_generic_machine_select()
1417 dev_info(bus->dev, "using HDA machine driver %s now\n", in hda_generic_machine_select()
1418 hda_mach->drv_name); in hda_generic_machine_select()
1420 if (codec_num == 1 && HDA_IDISP_CODEC(bus->codec_mask)) in hda_generic_machine_select()
1421 idisp_str = "-idisp"; in hda_generic_machine_select()
1426 if (pdata->tplg_filename) { in hda_generic_machine_select()
1428 tplg_filename = pdata->tplg_filename; in hda_generic_machine_select()
1431 tplg_filename = hda_mach->sof_tplg_filename; in hda_generic_machine_select()
1438 hda_mach->mach_params.dmic_num = dmic_num; in hda_generic_machine_select()
1439 pdata->tplg_filename = tplg_filename; in hda_generic_machine_select()
1442 (codec_num == 1 && !HDA_IDISP_CODEC(bus->codec_mask))) { in hda_generic_machine_select()
1444 * Prevent SoundWire links from starting when an external in hda_generic_machine_select()
1447 hda_mach->mach_params.link_mask = 0; in hda_generic_machine_select()
1450 * Allow SoundWire links to start when no external HDaudio codec in hda_generic_machine_select()
1451 * was detected. This will not create a SoundWire card but in hda_generic_machine_select()
1452 * will help detect if any SoundWire codec reports as ATTACHED. in hda_generic_machine_select()
1454 struct sof_intel_hda_dev *hdev = sdev->pdata->hw_pdata; in hda_generic_machine_select()
1456 hda_mach->mach_params.link_mask = hdev->info.link_mask; in hda_generic_machine_select()
1465 mach_params = &(*mach)->mach_params; in hda_generic_machine_select()
1466 mach_params->codec_mask = bus->codec_mask; in hda_generic_machine_select()
1467 mach_params->common_hdmi_codec_drv = true; in hda_generic_machine_select()
1481 struct snd_sof_pdata *pdata = sdev->pdata; in hda_sdw_machine_select()
1488 hdev = pdata->hw_pdata; in hda_sdw_machine_select()
1489 link_mask = hdev->info.link_mask; in hda_sdw_machine_select()
1492 * Select SoundWire machine driver if needed using the in hda_sdw_machine_select()
1493 * alternate tables. This case deals with SoundWire-only in hda_sdw_machine_select()
1498 for (mach = pdata->desc->alt_machines; in hda_sdw_machine_select()
1499 mach && mach->link_mask; mach++) { in hda_sdw_machine_select()
1508 if (~link_mask & mach->link_mask) in hda_sdw_machine_select()
1512 if (!mach->links) in hda_sdw_machine_select()
1515 link = mach->links; in hda_sdw_machine_select()
1516 for (i = 0; i < hdev->info.count && link->num_adr; in hda_sdw_machine_select()
1522 if (!snd_soc_acpi_sdw_link_slaves_found(sdev->dev, link, in hda_sdw_machine_select()
1523 hdev->sdw->ids, in hda_sdw_machine_select()
1524 hdev->sdw->num_slaves)) in hda_sdw_machine_select()
1528 if (i == hdev->info.count || !link->num_adr) in hda_sdw_machine_select()
1531 if (mach && mach->link_mask) { in hda_sdw_machine_select()
1536 mach->mach_params.links = mach->links; in hda_sdw_machine_select()
1537 mach->mach_params.link_mask = mach->link_mask; in hda_sdw_machine_select()
1538 mach->mach_params.platform = dev_name(sdev->dev); in hda_sdw_machine_select()
1540 if (pdata->tplg_filename) { in hda_sdw_machine_select()
1544 tplg_filename = mach->sof_tplg_filename; in hda_sdw_machine_select()
1548 * DMICs use up to 4 pins and are typically pin-muxed with SoundWire in hda_sdw_machine_select()
1551 * a) 2 or fewer links are used by SoundWire in hda_sdw_machine_select()
1554 if (hweight_long(mach->link_mask) <= 2) { in hda_sdw_machine_select()
1563 pdata->tplg_filename = tplg_filename; in hda_sdw_machine_select()
1564 mach->mach_params.dmic_num = dmic_num; in hda_sdw_machine_select()
1566 dev_dbg(sdev->dev, in hda_sdw_machine_select()
1567 "SoundWire machine driver %s topology %s\n", in hda_sdw_machine_select()
1568 mach->drv_name, in hda_sdw_machine_select()
1569 pdata->tplg_filename); in hda_sdw_machine_select()
1574 dev_info(sdev->dev, "No SoundWire machine driver found\n"); in hda_sdw_machine_select()
1589 struct snd_sof_pdata *pdata = sdev->pdata; in hda_set_mach_params()
1590 const struct sof_dev_desc *desc = pdata->desc; in hda_set_mach_params()
1593 mach_params = &mach->mach_params; in hda_set_mach_params()
1594 mach_params->platform = dev_name(sdev->dev); in hda_set_mach_params()
1597 mach_params->num_dai_drivers = SOF_SKL_NUM_DAIS_NOCODEC; in hda_set_mach_params()
1599 mach_params->num_dai_drivers = desc->ops->num_drv; in hda_set_mach_params()
1600 mach_params->dai_drivers = desc->ops->drv; in hda_set_mach_params()
1606 struct snd_sof_pdata *sof_pdata = sdev->pdata; in hda_machine_select()
1607 const struct sof_dev_desc *desc = sof_pdata->desc; in hda_machine_select()
1613 mach = snd_soc_acpi_find_machine(desc->machines); in hda_machine_select()
1623 if (!sof_pdata->tplg_filename) { in hda_machine_select()
1624 sof_pdata->tplg_filename = mach->sof_tplg_filename; in hda_machine_select()
1629 mach->mach_params.dmic_num = check_dmic_num(sdev); in hda_machine_select()
1632 mach->tplg_quirk_mask & SND_SOC_ACPI_TPLG_INTEL_DMIC_NUMBER && in hda_machine_select()
1633 mach->mach_params.dmic_num) { in hda_machine_select()
1634 tplg_filename = devm_kasprintf(sdev->dev, GFP_KERNEL, in hda_machine_select()
1636 sof_pdata->tplg_filename, in hda_machine_select()
1637 "-dmic", in hda_machine_select()
1638 mach->mach_params.dmic_num, in hda_machine_select()
1643 sof_pdata->tplg_filename = tplg_filename; in hda_machine_select()
1647 if (mach->link_mask) { in hda_machine_select()
1648 mach->mach_params.links = mach->links; in hda_machine_select()
1649 mach->mach_params.link_mask = mach->link_mask; in hda_machine_select()
1653 mach->mach_params.i2s_link_mask = check_nhlt_ssp_mask(sdev); in hda_machine_select()
1656 mach->tplg_quirk_mask & SND_SOC_ACPI_TPLG_INTEL_SSP_NUMBER && in hda_machine_select()
1657 mach->mach_params.i2s_link_mask) { in hda_machine_select()
1658 const struct sof_intel_dsp_desc *chip = get_chip_info(sdev->pdata); in hda_machine_select()
1662 if (hweight_long(mach->mach_params.i2s_link_mask) > 1 && in hda_machine_select()
1663 !(mach->tplg_quirk_mask & SND_SOC_ACPI_TPLG_INTEL_SSP_MSB)) in hda_machine_select()
1664 dev_warn(sdev->dev, "More than one SSP exposed by NHLT, choosing MSB\n"); in hda_machine_select()
1666 /* fls returns 1-based results, SSPs indices are 0-based */ in hda_machine_select()
1667 ssp_num = fls(mach->mach_params.i2s_link_mask) - 1; in hda_machine_select()
1669 if (ssp_num >= chip->ssp_count) { in hda_machine_select()
1670 dev_err(sdev->dev, "Invalid SSP %d, max on this platform is %d\n", in hda_machine_select()
1671 ssp_num, chip->ssp_count); in hda_machine_select()
1675 tplg_filename = devm_kasprintf(sdev->dev, GFP_KERNEL, in hda_machine_select()
1677 sof_pdata->tplg_filename, in hda_machine_select()
1678 "-ssp", in hda_machine_select()
1683 sof_pdata->tplg_filename = tplg_filename; in hda_machine_select()
1689 dev_err(sdev->dev, "Invalid MCLK configuration\n"); in hda_machine_select()
1693 dev_dbg(sdev->dev, "MCLK mask %#x found in NHLT\n", mclk_mask); in hda_machine_select()
1696 dev_info(sdev->dev, "Overriding topology with MCLK mask %#x from NHLT\n", mclk_mask); in hda_machine_select()
1697 sdev->mclk_id_override = true; in hda_machine_select()
1698 sdev->mclk_id_quirk = (mclk_mask & BIT(0)) ? 0 : 1; in hda_machine_select()
1703 tplg_filename = devm_kasprintf(sdev->dev, GFP_KERNEL, in hda_machine_select()
1705 sof_pdata->tplg_filename, in hda_machine_select()
1710 sof_pdata->tplg_filename = tplg_filename; in hda_machine_select()
1715 … dev_info(sdev->dev, "Overriding topology with MCLK %d from kernel_parameter\n", mclk_id_override); in hda_machine_select()
1716 sdev->mclk_id_override = true; in hda_machine_select()
1717 sdev->mclk_id_quirk = mclk_id_override; in hda_machine_select()
1721 /* If I2S fails, try SoundWire if it is supported */ in hda_machine_select()
1731 dev_warn(sdev->dev, "warning: No matching ASoC machine driver found\n"); in hda_machine_select()
1742 dev_dbg(&pci->dev, "SOF PCI driver not selected, aborting probe\n"); in hda_pci_intel_probe()
1743 return -ENODEV; in hda_pci_intel_probe()