• 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-nhlt.h>
28 #include "../sof-audio.h"
33 #include <sound/soc-acpi-intel-match.h>
45 const struct sof_dev_desc *desc = pdata->desc; in get_chip_info()
48 chip_info = desc->chip_info; in get_chip_info()
56 * The default for SoundWire clock stop quirks is to power gate the IP
63 MODULE_PARM_DESC(sdw_clock_stop_quirks, "SOF SoundWire clock stop quirks");
69 struct snd_soc_dai *d = params_data->dai; in sdw_params_stream()
72 int link_id = params_data->link_id; in sdw_params_stream()
73 int alh_stream_id = params_data->alh_stream_id; in sdw_params_stream()
81 config.dai_index = (link_id << 8) | (d->id); in sdw_params_stream()
85 ret = sof_ipc_tx_message(sdev->ipc, in sdw_params_stream()
89 dev_err(sdev->dev, in sdw_params_stream()
90 "error: failed to set DAI hw_params for link %d dai->id %d ALH %d\n", in sdw_params_stream()
91 link_id, d->id, alh_stream_id); in sdw_params_stream()
101 struct snd_soc_dai *d = free_data->dai; in sdw_free_stream()
104 int link_id = free_data->link_id; in sdw_free_stream()
112 config.dai_index = (link_id << 8) | d->id; in sdw_free_stream()
116 ret = sof_ipc_tx_message(sdev->ipc, in sdw_free_stream()
120 dev_err(sdev->dev, in sdw_free_stream()
121 "error: failed to free stream for link %d dai->id %d\n", in sdw_free_stream()
122 link_id, d->id); in sdw_free_stream()
135 sdw_intel_enable_irq(sdev->bar[HDA_DSP_BAR], enable); in hda_sdw_int_enable()
144 handle = ACPI_HANDLE(sdev->dev); in hda_sdw_acpi_scan()
147 hdev = sdev->pdata->hw_pdata; in hda_sdw_acpi_scan()
149 ret = sdw_intel_acpi_scan(handle, &hdev->info); in hda_sdw_acpi_scan()
151 return -EINVAL; in hda_sdw_acpi_scan()
162 hdev = sdev->pdata->hw_pdata; in hda_sdw_probe()
166 res.mmio_base = sdev->bar[HDA_DSP_BAR]; in hda_sdw_probe()
167 res.irq = sdev->ipc_irq; in hda_sdw_probe()
168 res.handle = hdev->info.handle; in hda_sdw_probe()
169 res.parent = sdev->dev; in hda_sdw_probe()
171 res.dev = sdev->dev; in hda_sdw_probe()
181 res.count = hdev->info.count; in hda_sdw_probe()
182 res.link_mask = hdev->info.link_mask; in hda_sdw_probe()
186 dev_err(sdev->dev, "error: SoundWire probe failed\n"); in hda_sdw_probe()
187 return -EINVAL; in hda_sdw_probe()
191 hdev->sdw = sdw; in hda_sdw_probe()
200 hdev = sdev->pdata->hw_pdata; in hda_sdw_startup()
202 if (!hdev->sdw) in hda_sdw_startup()
205 return sdw_intel_startup(hdev->sdw); in hda_sdw_startup()
212 hdev = sdev->pdata->hw_pdata; in hda_sdw_exit()
216 if (hdev->sdw) in hda_sdw_exit()
217 sdw_intel_exit(hdev->sdw); in hda_sdw_exit()
218 hdev->sdw = NULL; in hda_sdw_exit()
229 hdev = sdev->pdata->hw_pdata; in hda_dsp_check_sdw_irq()
231 if (!hdev->sdw) in hda_dsp_check_sdw_irq()
258 hdev = sdev->pdata->hw_pdata; in hda_sdw_check_wakeen_irq()
259 if (hdev->sdw && in hda_sdw_check_wakeen_irq()
271 hdev = sdev->pdata->hw_pdata; in hda_sdw_process_wakeen()
272 if (!hdev->sdw) in hda_sdw_process_wakeen()
275 sdw_intel_process_wakeen_event(hdev->sdw); in hda_sdw_process_wakeen()
300 static int hda_dmic_num = -1;
341 dev_err(sdev->dev, "%s - code %8.8x\n", in hda_dsp_get_status_skl()
348 dev_dbg(sdev->dev, "unknown ROM status value %8.8x\n", status); in hda_dsp_get_status_skl()
361 dev_err(sdev->dev, "%s - code %8.8x\n", in hda_dsp_get_status()
368 dev_dbg(sdev->dev, "unknown ROM status value %8.8x\n", status); in hda_dsp_get_status()
376 u32 offset = sdev->dsp_oops_offset; in hda_dsp_get_registers()
384 if (xoops->arch_hdr.totalsize > EXCEPT_MAX_HDR_SIZE) { in hda_dsp_get_registers()
385 dev_err(sdev->dev, "invalid header size 0x%x. FW oops is bogus\n", in hda_dsp_get_registers()
386 xoops->arch_hdr.totalsize); in hda_dsp_get_registers()
389 offset += xoops->arch_hdr.totalsize; in hda_dsp_get_registers()
390 sof_block_read(sdev, sdev->mmio_bar, offset, in hda_dsp_get_registers()
395 sof_block_read(sdev, sdev->mmio_bar, offset, stack, in hda_dsp_get_registers()
417 if (sdev->fw_state == SOF_FW_BOOT_COMPLETE) { in hda_dsp_dump_skl()
423 dev_err(sdev->dev, "error: status = 0x%8.8x panic = 0x%8.8x\n", in hda_dsp_dump_skl()
432 struct sof_intel_hda_dev *hda = sdev->pdata->hw_pdata; in hda_dsp_dump_ext_rom_status()
440 len += snprintf(msg + len, sizeof(msg) - len, " 0x%x", value); in hda_dsp_dump_ext_rom_status()
443 sof_dev_dbg_or_err(sdev->dev, hda->boot_iteration == HDA_FW_BOOT_ATTEMPTS, in hda_dsp_dump_ext_rom_status()
450 struct sof_intel_hda_dev *hda = sdev->pdata->hw_pdata; in hda_dsp_dump()
464 if (sdev->fw_state == SOF_FW_BOOT_COMPLETE) { in hda_dsp_dump()
470 sof_dev_dbg_or_err(sdev->dev, hda->boot_iteration == HDA_FW_BOOT_ATTEMPTS, in hda_dsp_dump()
495 dev_err(sdev->dev, in hda_ipc_irq_dump()
498 dev_err(sdev->dev, in hda_ipc_irq_dump()
518 dev_err(sdev->dev, in hda_ipc_dump()
527 struct pci_dev *pci = to_pci_dev(sdev->dev); in hda_init()
534 sof_hda_bus_init(bus, &pci->dev); in hda_init()
536 bus->use_posbuf = 1; in hda_init()
537 bus->bdl_pos_adj = 0; in hda_init()
538 bus->sync_write = 1; in hda_init()
540 mutex_init(&hbus->prepare_mutex); in hda_init()
541 hbus->pci = pci; in hda_init()
542 hbus->mixer_assigned = -1; in hda_init()
543 hbus->modelname = hda_model; in hda_init()
546 bus->addr = pci_resource_start(pci, 0); in hda_init()
548 bus->remap_addr = pci_ioremap_bar(pci, 0); in hda_init()
550 if (!bus->remap_addr) { in hda_init()
551 dev_err(bus->dev, "error: ioremap error\n"); in hda_init()
552 return -ENXIO; in hda_init()
556 sdev->bar[HDA_DSP_HDA_BAR] = bus->remap_addr; in hda_init()
561 dev_warn(sdev->dev, "init of i915 and HDMI codec failed\n"); in hda_init()
563 /* get controller capabilities */ in hda_init()
566 dev_err(sdev->dev, "error: get caps error\n"); in hda_init()
578 nhlt = intel_nhlt_init(sdev->dev); in check_nhlt_dmic()
580 dmic_num = intel_nhlt_get_dmic_geo(sdev->dev, nhlt); in check_nhlt_dmic()
598 filename = devm_kstrdup(sdev->dev, sof_tplg_filename, GFP_KERNEL); in fixup_tplg_name()
605 tplg_filename = devm_kasprintf(sdev->dev, GFP_KERNEL, in fixup_tplg_name()
619 struct snd_sof_pdata *pdata = sdev->pdata; in hda_init_caps()
623 struct sof_intel_hda_dev *hdev = pdata->hw_pdata; in hda_init_caps()
627 device_disable_async_suspend(bus->dev); in hda_init_caps()
630 if (bus->ppcap) in hda_init_caps()
631 dev_dbg(sdev->dev, "PP capability, will probe DSP later.\n"); in hda_init_caps()
633 /* Init HDA controller after i915 init */ in hda_init_caps()
636 dev_err(bus->dev, "error: init chip failed with ret: %d\n", in hda_init_caps()
641 /* scan SoundWire capabilities exposed by DSDT */ in hda_init_caps()
644 dev_dbg(sdev->dev, "skipping SoundWire, not detected with ACPI scan\n"); in hda_init_caps()
648 link_mask = hdev->info.link_mask; in hda_init_caps()
650 dev_dbg(sdev->dev, "skipping SoundWire, no links enabled\n"); in hda_init_caps()
655 * probe/allocate SoundWire resources. in hda_init_caps()
658 * It's entirely possible to have a mix of I2S/DMIC/SoundWire in hda_init_caps()
663 dev_err(sdev->dev, "error: SoundWire probe error\n"); in hda_init_caps()
670 if (bus->mlcap) in hda_init_caps()
676 if (!HDA_IDISP_CODEC(bus->codec_mask)) in hda_init_caps()
682 list_for_each_entry(hlink, &bus->hlink_list, list) in hda_init_caps()
694 * sources in the Intel HD Audio controller. in hda_dsp_interrupt_handler()
714 struct sof_intel_hda_dev *hdev = sdev->pdata->hw_pdata; in hda_dsp_interrupt_thread()
716 /* deal with streams and controller first */ in hda_dsp_interrupt_thread()
721 sof_ops(sdev)->irq_thread(irq, sdev); in hda_dsp_interrupt_thread()
724 hda_dsp_sdw_thread(irq, hdev->sdw); in hda_dsp_interrupt_thread()
740 struct pci_dev *pci = to_pci_dev(sdev->dev); in hda_dsp_probe()
747 * detect DSP by checking class/subclass/prog-id information in hda_dsp_probe()
748 * class=04 subclass 03 prog-if 00: no DSP, legacy driver is required in hda_dsp_probe()
749 * class=04 subclass 01 prog-if 00: DSP is present in hda_dsp_probe()
751 * class=04 subclass 03 prog-if 80: either of DSP or legacy mode works in hda_dsp_probe()
753 if (pci->class == 0x040300) { in hda_dsp_probe()
754 dev_err(sdev->dev, "error: the DSP is not enabled on this platform, aborting probe\n"); in hda_dsp_probe()
755 return -ENODEV; in hda_dsp_probe()
756 } else if (pci->class != 0x040100 && pci->class != 0x040380) { in hda_dsp_probe()
757 …dev_err(sdev->dev, "error: unknown PCI class/subclass/prog-if 0x%06x found, aborting probe\n", pci in hda_dsp_probe()
758 return -ENODEV; in hda_dsp_probe()
760 dev_info(sdev->dev, "DSP detected with PCI class/subclass/prog-if 0x%06x\n", pci->class); in hda_dsp_probe()
762 chip = get_chip_info(sdev->pdata); in hda_dsp_probe()
764 dev_err(sdev->dev, "error: no such device supported, chip id:%x\n", in hda_dsp_probe()
765 pci->device); in hda_dsp_probe()
766 ret = -EIO; in hda_dsp_probe()
770 hdev = devm_kzalloc(sdev->dev, sizeof(*hdev), GFP_KERNEL); in hda_dsp_probe()
772 return -ENOMEM; in hda_dsp_probe()
773 sdev->pdata->hw_pdata = hdev; in hda_dsp_probe()
774 hdev->desc = chip; in hda_dsp_probe()
776 hdev->dmic_dev = platform_device_register_data(sdev->dev, "dmic-codec", in hda_dsp_probe()
779 if (IS_ERR(hdev->dmic_dev)) { in hda_dsp_probe()
780 dev_err(sdev->dev, "error: failed to create DMIC device\n"); in hda_dsp_probe()
781 return PTR_ERR(hdev->dmic_dev); in hda_dsp_probe()
789 hdev->no_ipc_position = 0; in hda_dsp_probe()
791 hdev->no_ipc_position = sof_ops(sdev)->pcm_pointer ? 1 : 0; in hda_dsp_probe()
802 sdev->bar[HDA_DSP_BAR] = pci_ioremap_bar(pci, HDA_DSP_BAR); in hda_dsp_probe()
804 if (!sdev->bar[HDA_DSP_BAR]) { in hda_dsp_probe()
805 dev_err(sdev->dev, "error: ioremap error\n"); in hda_dsp_probe()
806 ret = -ENXIO; in hda_dsp_probe()
810 sdev->mmio_bar = HDA_DSP_BAR; in hda_dsp_probe()
811 sdev->mailbox_bar = HDA_DSP_BAR; in hda_dsp_probe()
814 if (!dma_set_mask(&pci->dev, DMA_BIT_MASK(64))) { in hda_dsp_probe()
815 dev_dbg(sdev->dev, "DMA mask is 64 bit\n"); in hda_dsp_probe()
816 dma_set_coherent_mask(&pci->dev, DMA_BIT_MASK(64)); in hda_dsp_probe()
818 dev_dbg(sdev->dev, "DMA mask is 32 bit\n"); in hda_dsp_probe()
819 dma_set_mask(&pci->dev, DMA_BIT_MASK(32)); in hda_dsp_probe()
820 dma_set_coherent_mask(&pci->dev, DMA_BIT_MASK(32)); in hda_dsp_probe()
826 dev_err(sdev->dev, "error: failed to init streams\n"); in hda_dsp_probe()
841 dev_info(sdev->dev, "use msi interrupt mode\n"); in hda_dsp_probe()
842 sdev->ipc_irq = pci_irq_vector(pci, 0); in hda_dsp_probe()
844 sdev->msi_enabled = true; in hda_dsp_probe()
847 if (!sdev->msi_enabled) { in hda_dsp_probe()
848 dev_info(sdev->dev, "use legacy interrupt mode\n"); in hda_dsp_probe()
850 * in IO-APIC mode, hda->irq and ipc_irq are using the same in hda_dsp_probe()
851 * irq number of pci->irq in hda_dsp_probe()
853 sdev->ipc_irq = pci->irq; in hda_dsp_probe()
856 dev_dbg(sdev->dev, "using IPC IRQ %d\n", sdev->ipc_irq); in hda_dsp_probe()
857 ret = request_threaded_irq(sdev->ipc_irq, hda_dsp_interrupt_handler, in hda_dsp_probe()
861 dev_err(sdev->dev, "error: failed to register IPC IRQ %d\n", in hda_dsp_probe()
862 sdev->ipc_irq); in hda_dsp_probe()
867 synchronize_irq(pci->irq); in hda_dsp_probe()
885 sdev->dsp_box.offset = HDA_DSP_MBOX_UPLINK_OFFSET; in hda_dsp_probe()
887 INIT_DELAYED_WORK(&hdev->d0i3_work, hda_dsp_d0i3_work); in hda_dsp_probe()
892 free_irq(sdev->ipc_irq, sdev); in hda_dsp_probe()
894 if (sdev->msi_enabled) in hda_dsp_probe()
899 iounmap(sdev->bar[HDA_DSP_BAR]); in hda_dsp_probe()
901 platform_device_unregister(hdev->dmic_dev); in hda_dsp_probe()
902 iounmap(bus->remap_addr); in hda_dsp_probe()
910 struct sof_intel_hda_dev *hda = sdev->pdata->hw_pdata; in hda_dsp_remove()
912 struct pci_dev *pci = to_pci_dev(sdev->dev); in hda_dsp_remove()
913 const struct sof_intel_dsp_desc *chip = hda->desc; in hda_dsp_remove()
916 cancel_delayed_work_sync(&hda->d0i3_work); in hda_dsp_remove()
925 if (!IS_ERR_OR_NULL(hda->dmic_dev)) in hda_dsp_remove()
926 platform_device_unregister(hda->dmic_dev); in hda_dsp_remove()
938 hda_dsp_core_reset_power_down(sdev, chip->host_managed_cores_mask); in hda_dsp_remove()
944 free_irq(sdev->ipc_irq, sdev); in hda_dsp_remove()
945 if (sdev->msi_enabled) in hda_dsp_remove()
953 iounmap(sdev->bar[HDA_DSP_BAR]); in hda_dsp_remove()
954 iounmap(bus->remap_addr); in hda_dsp_remove()
970 struct snd_sof_pdata *pdata = sdev->pdata; in hda_generic_machine_select()
979 if (!bus->codec_mask) { in hda_generic_machine_select()
980 dev_info(bus->dev, "no hda codecs found!\n"); in hda_generic_machine_select()
982 dev_info(bus->dev, "hda codecs found, mask %lx\n", in hda_generic_machine_select()
983 bus->codec_mask); in hda_generic_machine_select()
986 if (bus->codec_mask & (1 << i)) in hda_generic_machine_select()
994 * - one HDMI codec, and/or in hda_generic_machine_select()
995 * - one external HDAudio codec in hda_generic_machine_select()
997 if (!pdata->machine && codec_num <= 2) { in hda_generic_machine_select()
1001 pdata->tplg_filename = in hda_generic_machine_select()
1002 hda_mach->sof_tplg_filename; in hda_generic_machine_select()
1004 dev_info(bus->dev, "using HDA machine driver %s now\n", in hda_generic_machine_select()
1005 hda_mach->drv_name); in hda_generic_machine_select()
1007 if (codec_num == 1 && HDA_IDISP_CODEC(bus->codec_mask)) in hda_generic_machine_select()
1008 idisp_str = "-idisp"; in hda_generic_machine_select()
1016 if (hda_dmic_num != -1) in hda_generic_machine_select()
1021 dmic_str = "-1ch"; in hda_generic_machine_select()
1024 dmic_str = "-2ch"; in hda_generic_machine_select()
1027 dmic_str = "-3ch"; in hda_generic_machine_select()
1030 dmic_str = "-4ch"; in hda_generic_machine_select()
1038 tplg_filename = pdata->tplg_filename; in hda_generic_machine_select()
1042 return -EINVAL; in hda_generic_machine_select()
1044 dev_info(bus->dev, in hda_generic_machine_select()
1048 pdata->machine = hda_mach; in hda_generic_machine_select()
1049 pdata->tplg_filename = tplg_filename; in hda_generic_machine_select()
1054 if (pdata->machine) { in hda_generic_machine_select()
1056 &pdata->machine->mach_params; in hda_generic_machine_select()
1057 mach_params->codec_mask = bus->codec_mask; in hda_generic_machine_select()
1058 mach_params->common_hdmi_codec_drv = hda_codec_use_common_hdmi; in hda_generic_machine_select()
1059 mach_params->dmic_num = dmic_num; in hda_generic_machine_select()
1078 struct sdw_intel_slave_id *ids = sdw->ids; in link_slaves_found()
1079 int num_slaves = sdw->num_slaves; in link_slaves_found()
1083 for (i = 0; i < link->num_adr; i++) { in link_slaves_found()
1084 u64 adr = link->adr_d[i].adr; in link_slaves_found()
1100 if (link->num_adr == 1 || in link_slaves_found()
1103 dev_dbg(bus->dev, in link_slaves_found()
1110 dev_dbg(bus->dev, in link_slaves_found()
1121 struct snd_sof_pdata *pdata = sdev->pdata; in hda_sdw_machine_select()
1129 hdev = pdata->hw_pdata; in hda_sdw_machine_select()
1130 link_mask = hdev->info.link_mask; in hda_sdw_machine_select()
1133 * Select SoundWire machine driver if needed using the in hda_sdw_machine_select()
1134 * alternate tables. This case deals with SoundWire-only in hda_sdw_machine_select()
1138 if (link_mask && !pdata->machine) { in hda_sdw_machine_select()
1139 for (mach = pdata->desc->alt_machines; in hda_sdw_machine_select()
1140 mach && mach->link_mask; mach++) { in hda_sdw_machine_select()
1149 if (~link_mask & mach->link_mask) in hda_sdw_machine_select()
1153 if (!mach->links) in hda_sdw_machine_select()
1156 link = mach->links; in hda_sdw_machine_select()
1157 for (i = 0; i < hdev->info.count && link->num_adr; in hda_sdw_machine_select()
1163 if (!link_slaves_found(sdev, link, hdev->sdw)) in hda_sdw_machine_select()
1167 if (i == hdev->info.count || !link->num_adr) in hda_sdw_machine_select()
1170 if (mach && mach->link_mask) { in hda_sdw_machine_select()
1171 dev_dbg(bus->dev, in hda_sdw_machine_select()
1172 "SoundWire machine driver %s topology %s\n", in hda_sdw_machine_select()
1173 mach->drv_name, in hda_sdw_machine_select()
1174 mach->sof_tplg_filename); in hda_sdw_machine_select()
1175 pdata->machine = mach; in hda_sdw_machine_select()
1176 mach->mach_params.links = mach->links; in hda_sdw_machine_select()
1177 mach->mach_params.link_mask = mach->link_mask; in hda_sdw_machine_select()
1178 mach->mach_params.platform = dev_name(sdev->dev); in hda_sdw_machine_select()
1179 pdata->fw_filename = mach->sof_fw_filename; in hda_sdw_machine_select()
1180 pdata->tplg_filename = mach->sof_tplg_filename; in hda_sdw_machine_select()
1182 dev_info(sdev->dev, in hda_sdw_machine_select()
1183 "No SoundWire machine driver found\n"); in hda_sdw_machine_select()
1201 mach_params = (struct snd_soc_acpi_mach_params *)&mach->mach_params; in hda_set_mach_params()
1202 mach_params->platform = dev_name(dev); in hda_set_mach_params()
1207 struct snd_sof_pdata *sof_pdata = sdev->pdata; in hda_machine_select()
1208 const struct sof_dev_desc *desc = sof_pdata->desc; in hda_machine_select()
1211 mach = snd_soc_acpi_find_machine(desc->machines); in hda_machine_select()
1217 if (!sof_pdata->tplg_filename) in hda_machine_select()
1218 sof_pdata->tplg_filename = mach->sof_tplg_filename; in hda_machine_select()
1220 sof_pdata->machine = mach; in hda_machine_select()
1222 if (mach->link_mask) { in hda_machine_select()
1223 mach->mach_params.links = mach->links; in hda_machine_select()
1224 mach->mach_params.link_mask = mach->link_mask; in hda_machine_select()
1229 * If I2S fails, try SoundWire in hda_machine_select()
1239 if (!sof_pdata->machine) in hda_machine_select()
1240 dev_warn(sdev->dev, "warning: No matching ASoC machine driver found\n"); in hda_machine_select()