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