Lines Matching refs:sdev
68 struct snd_sof_dev *sdev = dev_get_drvdata(dev);
85 ret = sof_ipc_tx_message(sdev->ipc,
89 dev_err(sdev->dev,
100 struct snd_sof_dev *sdev = dev_get_drvdata(dev);
116 ret = sof_ipc_tx_message(sdev->ipc,
120 dev_err(sdev->dev,
133 void hda_sdw_int_enable(struct snd_sof_dev *sdev, bool enable)
135 sdw_intel_enable_irq(sdev->bar[HDA_DSP_BAR], enable);
138 static int hda_sdw_acpi_scan(struct snd_sof_dev *sdev)
144 handle = ACPI_HANDLE(sdev->dev);
147 hdev = sdev->pdata->hw_pdata;
156 static int hda_sdw_probe(struct snd_sof_dev *sdev)
162 hdev = sdev->pdata->hw_pdata;
166 res.mmio_base = sdev->bar[HDA_DSP_BAR];
167 res.irq = sdev->ipc_irq;
169 res.parent = sdev->dev;
171 res.dev = sdev->dev;
186 dev_err(sdev->dev, "error: SoundWire probe failed\n");
196 int hda_sdw_startup(struct snd_sof_dev *sdev)
200 hdev = sdev->pdata->hw_pdata;
208 static int hda_sdw_exit(struct snd_sof_dev *sdev)
212 hdev = sdev->pdata->hw_pdata;
214 hda_sdw_int_enable(sdev, false);
223 static bool hda_dsp_check_sdw_irq(struct snd_sof_dev *sdev)
229 hdev = sdev->pdata->hw_pdata;
235 irq_status = snd_sof_dsp_read(sdev, HDA_DSP_BAR, HDA_DSP_REG_ADSPIS2);
254 static bool hda_sdw_check_wakeen_irq(struct snd_sof_dev *sdev)
258 hdev = sdev->pdata->hw_pdata;
260 snd_sof_dsp_read(sdev, HDA_DSP_BAR,
267 void hda_sdw_process_wakeen(struct snd_sof_dev *sdev)
271 hdev = sdev->pdata->hw_pdata;
331 static void hda_dsp_get_status_skl(struct snd_sof_dev *sdev)
336 status = snd_sof_dsp_read(sdev, HDA_DSP_BAR,
341 dev_err(sdev->dev, "%s - code %8.8x\n",
348 dev_dbg(sdev->dev, "unknown ROM status value %8.8x\n", status);
351 static void hda_dsp_get_status(struct snd_sof_dev *sdev)
356 status = snd_sof_dsp_read(sdev, HDA_DSP_BAR,
361 dev_err(sdev->dev, "%s - code %8.8x\n",
368 dev_dbg(sdev->dev, "unknown ROM status value %8.8x\n", status);
371 static void hda_dsp_get_registers(struct snd_sof_dev *sdev,
376 u32 offset = sdev->dsp_oops_offset;
379 sof_mailbox_read(sdev, offset, xoops, sizeof(*xoops));
385 dev_err(sdev->dev, "invalid header size 0x%x. FW oops is bogus\n",
390 sof_block_read(sdev, sdev->mmio_bar, offset,
395 sof_block_read(sdev, sdev->mmio_bar, offset, stack,
399 void hda_dsp_dump_skl(struct snd_sof_dev *sdev, u32 flags)
407 hda_dsp_get_status_skl(sdev);
410 status = snd_sof_dsp_read(sdev, HDA_DSP_BAR,
414 panic = snd_sof_dsp_read(sdev, HDA_DSP_BAR,
417 if (sdev->fw_state == SOF_FW_BOOT_COMPLETE) {
418 hda_dsp_get_registers(sdev, &xoops, &panic_info, stack,
420 snd_sof_get_status(sdev, status, panic, &xoops, &panic_info,
423 dev_err(sdev->dev, "error: status = 0x%8.8x panic = 0x%8.8x\n",
425 hda_dsp_get_status_skl(sdev);
430 static void hda_dsp_dump_ext_rom_status(struct snd_sof_dev *sdev)
432 struct sof_intel_hda_dev *hda = sdev->pdata->hw_pdata;
439 value = snd_sof_dsp_read(sdev, HDA_DSP_BAR, HDA_DSP_SRAM_REG_ROM_STATUS + i * 0x4);
443 sof_dev_dbg_or_err(sdev->dev, hda->boot_iteration == HDA_FW_BOOT_ATTEMPTS,
448 void hda_dsp_dump(struct snd_sof_dev *sdev, u32 flags)
450 struct sof_intel_hda_dev *hda = sdev->pdata->hw_pdata;
457 hda_dsp_get_status(sdev);
460 status = snd_sof_dsp_read(sdev, HDA_DSP_BAR,
462 panic = snd_sof_dsp_read(sdev, HDA_DSP_BAR, HDA_DSP_SRAM_REG_FW_TRACEP);
464 if (sdev->fw_state == SOF_FW_BOOT_COMPLETE) {
465 hda_dsp_get_registers(sdev, &xoops, &panic_info, stack,
467 snd_sof_get_status(sdev, status, panic, &xoops, &panic_info,
470 sof_dev_dbg_or_err(sdev->dev, hda->boot_iteration == HDA_FW_BOOT_ATTEMPTS,
474 hda_dsp_dump_ext_rom_status(sdev);
475 hda_dsp_get_status(sdev);
479 void hda_ipc_irq_dump(struct snd_sof_dev *sdev)
481 struct hdac_bus *bus = sof_to_bus(sdev);
489 adspis = snd_sof_dsp_read(sdev, HDA_DSP_BAR, HDA_DSP_REG_ADSPIS);
490 intsts = snd_sof_dsp_read(sdev, HDA_DSP_HDA_BAR, SOF_HDA_INTSTS);
491 intctl = snd_sof_dsp_read(sdev, HDA_DSP_HDA_BAR, SOF_HDA_INTCTL);
492 ppsts = snd_sof_dsp_read(sdev, HDA_DSP_PP_BAR, SOF_HDA_REG_PP_PPSTS);
495 dev_err(sdev->dev,
498 dev_err(sdev->dev,
503 void hda_ipc_dump(struct snd_sof_dev *sdev)
509 hda_ipc_irq_dump(sdev);
512 hipcie = snd_sof_dsp_read(sdev, HDA_DSP_BAR, HDA_DSP_REG_HIPCIE);
513 hipct = snd_sof_dsp_read(sdev, HDA_DSP_BAR, HDA_DSP_REG_HIPCT);
514 hipcctl = snd_sof_dsp_read(sdev, HDA_DSP_BAR, HDA_DSP_REG_HIPCCTL);
518 dev_err(sdev->dev,
523 static int hda_init(struct snd_sof_dev *sdev)
527 struct pci_dev *pci = to_pci_dev(sdev->dev);
530 hbus = sof_to_hbus(sdev);
531 bus = sof_to_bus(sdev);
556 sdev->bar[HDA_DSP_HDA_BAR] = bus->remap_addr;
559 ret = hda_codec_i915_init(sdev);
561 dev_warn(sdev->dev, "init of i915 and HDMI codec failed\n");
564 ret = hda_dsp_ctrl_get_caps(sdev);
566 dev_err(sdev->dev, "error: get caps error\n");
573 static int check_nhlt_dmic(struct snd_sof_dev *sdev)
578 nhlt = intel_nhlt_init(sdev->dev);
580 dmic_num = intel_nhlt_get_dmic_geo(sdev->dev, nhlt);
589 static const char *fixup_tplg_name(struct snd_sof_dev *sdev,
598 filename = devm_kstrdup(sdev->dev, sof_tplg_filename, GFP_KERNEL);
605 tplg_filename = devm_kasprintf(sdev->dev, GFP_KERNEL,
616 static int hda_init_caps(struct snd_sof_dev *sdev)
618 struct hdac_bus *bus = sof_to_bus(sdev);
619 struct snd_sof_pdata *pdata = sdev->pdata;
631 dev_dbg(sdev->dev, "PP capability, will probe DSP later.\n");
634 ret = hda_dsp_ctrl_init_chip(sdev, true);
642 ret = hda_sdw_acpi_scan(sdev);
644 dev_dbg(sdev->dev, "skipping SoundWire, not detected with ACPI scan\n");
650 dev_dbg(sdev->dev, "skipping SoundWire, no links enabled\n");
661 ret = hda_sdw_probe(sdev);
663 dev_err(sdev->dev, "error: SoundWire probe error\n");
674 hda_codec_probe_bus(sdev, hda_codec_use_common_hdmi);
677 hda_codec_i915_display_power(sdev, false);
690 struct snd_sof_dev *sdev = context;
696 if (snd_sof_dsp_read(sdev, HDA_DSP_HDA_BAR, SOF_HDA_INTSTS) &
700 snd_sof_dsp_update_bits(sdev, HDA_DSP_HDA_BAR,
713 struct snd_sof_dev *sdev = context;
714 struct sof_intel_hda_dev *hdev = sdev->pdata->hw_pdata;
717 if (hda_dsp_check_stream_irq(sdev))
718 hda_dsp_stream_threaded_handler(irq, sdev);
720 if (hda_dsp_check_ipc_irq(sdev))
721 sof_ops(sdev)->irq_thread(irq, sdev);
723 if (hda_dsp_check_sdw_irq(sdev))
726 if (hda_sdw_check_wakeen_irq(sdev))
727 hda_sdw_process_wakeen(sdev);
730 snd_sof_dsp_update_bits(sdev, HDA_DSP_HDA_BAR,
738 int hda_dsp_probe(struct snd_sof_dev *sdev)
740 struct pci_dev *pci = to_pci_dev(sdev->dev);
754 dev_err(sdev->dev, "error: the DSP is not enabled on this platform, aborting probe\n");
757 dev_err(sdev->dev, "error: unknown PCI class/subclass/prog-if 0x%06x found, aborting probe\n", pci->class);
760 dev_info(sdev->dev, "DSP detected with PCI class/subclass/prog-if 0x%06x\n", pci->class);
762 chip = get_chip_info(sdev->pdata);
764 dev_err(sdev->dev, "error: no such device supported, chip id:%x\n",
770 hdev = devm_kzalloc(sdev->dev, sizeof(*hdev), GFP_KERNEL);
773 sdev->pdata->hw_pdata = hdev;
776 hdev->dmic_dev = platform_device_register_data(sdev->dev, "dmic-codec",
780 dev_err(sdev->dev, "error: failed to create DMIC device\n");
791 hdev->no_ipc_position = sof_ops(sdev)->pcm_pointer ? 1 : 0;
795 bus = sof_to_bus(sdev);
796 ret = hda_init(sdev);
802 sdev->bar[HDA_DSP_BAR] = pci_ioremap_bar(pci, HDA_DSP_BAR);
804 if (!sdev->bar[HDA_DSP_BAR]) {
805 dev_err(sdev->dev, "error: ioremap error\n");
810 sdev->mmio_bar = HDA_DSP_BAR;
811 sdev->mailbox_bar = HDA_DSP_BAR;
815 dev_dbg(sdev->dev, "DMA mask is 64 bit\n");
818 dev_dbg(sdev->dev, "DMA mask is 32 bit\n");
824 ret = hda_dsp_stream_init(sdev);
826 dev_err(sdev->dev, "error: failed to init streams\n");
841 dev_info(sdev->dev, "use msi interrupt mode\n");
842 sdev->ipc_irq = pci_irq_vector(pci, 0);
844 sdev->msi_enabled = true;
847 if (!sdev->msi_enabled) {
848 dev_info(sdev->dev, "use legacy interrupt mode\n");
853 sdev->ipc_irq = pci->irq;
856 dev_dbg(sdev->dev, "using IPC IRQ %d\n", sdev->ipc_irq);
857 ret = request_threaded_irq(sdev->ipc_irq, hda_dsp_interrupt_handler,
859 IRQF_SHARED, "AudioDSP", sdev);
861 dev_err(sdev->dev, "error: failed to register IPC IRQ %d\n",
862 sdev->ipc_irq);
873 snd_sof_pci_update_bits(sdev, PCI_TCSEL, 0x07, 0);
876 ret = hda_init_caps(sdev);
881 hda_dsp_ctrl_ppcap_enable(sdev, true);
882 hda_dsp_ctrl_ppcap_int_enable(sdev, true);
885 sdev->dsp_box.offset = HDA_DSP_MBOX_UPLINK_OFFSET;
892 free_irq(sdev->ipc_irq, sdev);
894 if (sdev->msi_enabled)
897 hda_dsp_stream_free(sdev);
899 iounmap(sdev->bar[HDA_DSP_BAR]);
903 hda_codec_i915_exit(sdev);
908 int hda_dsp_remove(struct snd_sof_dev *sdev)
910 struct sof_intel_hda_dev *hda = sdev->pdata->hw_pdata;
911 struct hdac_bus *bus = sof_to_bus(sdev);
912 struct pci_dev *pci = to_pci_dev(sdev->dev);
923 hda_sdw_exit(sdev);
929 snd_sof_dsp_update_bits(sdev, HDA_DSP_PP_BAR, SOF_HDA_REG_PP_PPCTL,
933 snd_sof_dsp_update_bits(sdev, HDA_DSP_HDA_BAR, SOF_HDA_INTCTL,
938 hda_dsp_core_reset_power_down(sdev, chip->host_managed_cores_mask);
941 snd_sof_dsp_update_bits(sdev, HDA_DSP_PP_BAR, SOF_HDA_REG_PP_PPCTL,
944 free_irq(sdev->ipc_irq, sdev);
945 if (sdev->msi_enabled)
948 hda_dsp_stream_free(sdev);
953 iounmap(sdev->bar[HDA_DSP_BAR]);
959 hda_codec_i915_exit(sdev);
965 static int hda_generic_machine_select(struct snd_sof_dev *sdev)
967 struct hdac_bus *bus = sof_to_bus(sdev);
970 struct snd_sof_pdata *pdata = sdev->pdata;
1013 dmic_num = check_nhlt_dmic(sdev);
1039 tplg_filename = fixup_tplg_name(sdev, tplg_filename,
1065 static int hda_generic_machine_select(struct snd_sof_dev *sdev)
1073 static bool link_slaves_found(struct snd_sof_dev *sdev,
1077 struct hdac_bus *bus = sof_to_bus(sdev);
1119 static int hda_sdw_machine_select(struct snd_sof_dev *sdev)
1121 struct snd_sof_pdata *pdata = sdev->pdata;
1123 struct hdac_bus *bus = sof_to_bus(sdev);
1163 if (!link_slaves_found(sdev, link, hdev->sdw))
1178 mach->mach_params.platform = dev_name(sdev->dev);
1182 dev_info(sdev->dev,
1190 static int hda_sdw_machine_select(struct snd_sof_dev *sdev)
1205 void hda_machine_select(struct snd_sof_dev *sdev)
1207 struct snd_sof_pdata *sof_pdata = sdev->pdata;
1231 hda_sdw_machine_select(sdev);
1237 hda_generic_machine_select(sdev);
1240 dev_warn(sdev->dev, "warning: No matching ASoC machine driver found\n");