Lines Matching defs:bus

43 avs_hda_update_config_dword(struct hdac_bus *bus, u32 reg, u32 mask, u32 value)
45 struct pci_dev *pci = to_pci_dev(bus->dev);
62 static void avs_hdac_clock_gating_enable(struct hdac_bus *bus, bool enable)
64 struct avs_dev *adev = hdac_to_avs(bus);
68 avs_hda_update_config_dword(bus, AZX_PCIREG_CGCTL, cgctl_mask, value);
90 static int avs_hdac_bus_init_streams(struct hdac_bus *bus)
95 gcap = snd_hdac_chip_readw(bus, GCAP);
98 bus->num_streams = cp_streams + pb_streams;
100 snd_hdac_ext_stream_init_all(bus, 0, cp_streams, SNDRV_PCM_STREAM_CAPTURE);
101 snd_hdac_ext_stream_init_all(bus, cp_streams, pb_streams, SNDRV_PCM_STREAM_PLAYBACK);
103 return snd_hdac_bus_alloc_stream_pages(bus);
106 static bool avs_hdac_bus_init_chip(struct hdac_bus *bus, bool full_reset)
108 struct avs_dev *adev = hdac_to_avs(bus);
112 avs_hdac_clock_gating_enable(bus, false);
113 ret = snd_hdac_bus_init_chip(bus, full_reset);
116 list_for_each_entry(hlink, &bus->hlink_list, list)
119 avs_hdac_clock_gating_enable(bus, true);
125 snd_hdac_chip_updatel(bus, VS_EM2, AZX_VS_EM2_DUM, AZX_VS_EM2_DUM);
130 static int probe_codec(struct hdac_bus *bus, int addr)
138 mutex_lock(&bus->cmd_mutex);
139 snd_hdac_bus_send_cmd(bus, cmd);
140 snd_hdac_bus_get_response(bus, addr, &res);
141 mutex_unlock(&bus->cmd_mutex);
145 dev_dbg(bus->dev, "codec #%d probed OK: 0x%x\n", addr, res);
147 codec = snd_hda_codec_device_init(to_hda_bus(bus), addr, "hdaudioB%dD%d", bus->idx, addr);
149 dev_err(bus->dev, "init codec failed: %ld\n", PTR_ERR(codec));
162 dev_warn(bus->dev, "failed to config codec #%d: %d\n", addr, ret);
169 static void avs_hdac_bus_probe_codecs(struct hdac_bus *bus)
175 if (!(bus->codec_mask & BIT(c)))
178 ret = probe_codec(bus, c);
187 dev_warn(bus->dev, "Codec #%d probe error; disabling it...\n", c);
188 bus->codec_mask &= ~BIT(c);
191 * codec often screws up the controller bus,
194 * better to reset the controller bus to get
197 snd_hdac_bus_stop_chip(bus);
198 avs_hdac_bus_init_chip(bus, true);
205 struct hdac_bus *bus = &adev->base.core;
209 pm_runtime_set_active(bus->dev); /* clear runtime_error flag */
211 snd_hdac_display_power(bus, HDA_CODEC_IDX_CONTROLLER, true);
212 avs_hdac_bus_init_chip(bus, true);
213 avs_hdac_bus_probe_codecs(bus);
214 snd_hdac_display_power(bus, HDA_CODEC_IDX_CONTROLLER, false);
217 list_for_each_entry(hlink, &bus->hlink_list, list)
218 snd_hdac_ext_bus_link_put(bus, hlink);
220 snd_hdac_ext_bus_ppcap_enable(bus, true);
221 snd_hdac_ext_bus_ppcap_int_enable(bus, true);
233 pm_runtime_set_autosuspend_delay(bus->dev, 2000);
234 pm_runtime_use_autosuspend(bus->dev);
235 pm_runtime_put_autosuspend(bus->dev);
236 pm_runtime_allow(bus->dev);
255 static void hdac_update_stream(struct hdac_bus *bus, struct hdac_stream *stream)
267 static irqreturn_t avs_hda_interrupt(struct hdac_bus *bus)
272 status = snd_hdac_chip_readl(bus, INTSTS);
273 if (snd_hdac_bus_handle_stream_irq(bus, status, hdac_update_stream))
276 spin_lock_irq(&bus->reg_lock);
278 status = snd_hdac_chip_readb(bus, RIRBSTS);
281 snd_hdac_bus_update_rirb(bus);
282 snd_hdac_chip_writeb(bus, RIRBSTS, RIRB_INT_MASK);
286 spin_unlock_irq(&bus->reg_lock);
292 struct hdac_bus *bus = dev_id;
295 intsts = snd_hdac_chip_readl(bus, INTSTS);
300 snd_hdac_chip_updatel(bus, INTCTL, AZX_INT_GLOBAL_EN, 0);
307 struct hdac_bus *bus = dev_id;
310 status = snd_hdac_chip_readl(bus, INTSTS);
312 avs_hda_interrupt(bus);
315 snd_hdac_chip_updatel(bus, INTCTL, AZX_INT_GLOBAL_EN, AZX_INT_GLOBAL_EN);
330 struct hdac_bus *bus = &adev->base.core;
333 status = readl(bus->ppcap + AZX_REG_PP_PPSTS);
338 snd_hdac_chip_updatel(bus, INTCTL, AZX_INT_GLOBAL_EN, AZX_INT_GLOBAL_EN);
345 struct hdac_bus *bus = &adev->base.core;
346 struct pci_dev *pci = to_pci_dev(bus->dev);
356 ret = pci_request_irq(pci, 0, avs_hda_irq_handler, avs_hda_irq_thread, bus,
373 pci_free_irq(pci, 0, bus);
381 struct hda_bus *bus = &adev->base;
386 ret = snd_hdac_ext_bus_init(&bus->core, dev, NULL, &soc_hda_ext_bus_ops);
390 bus->core.use_posbuf = 1;
391 bus->core.bdl_pos_adj = 0;
392 bus->core.sync_write = 1;
393 bus->pci = pci;
394 bus->mixer_assigned = -1;
395 mutex_init(&bus->prepare_mutex);
427 struct hdac_bus *bus;
449 bus = &adev->base.core;
453 dev_err(dev, "failed to init avs bus: %d\n", ret);
461 bus->addr = pci_resource_start(pci, 0);
462 bus->remap_addr = pci_ioremap_bar(pci, 0);
463 if (!bus->remap_addr) {
464 dev_err(bus->dev, "ioremap error\n");
470 dev_err(bus->dev, "ioremap error\n");
475 snd_hdac_bus_parse_capabilities(bus);
476 if (bus->mlcap)
477 snd_hdac_ext_bus_get_ml_capabilities(bus);
483 ret = avs_hdac_bus_init_streams(bus);
491 dev_err(bus->dev, "failed to acquire irq: %d\n", ret);
496 pci_set_drvdata(pci, bus);
499 ret = snd_hdac_i915_init(bus);
503 dev_info(bus->dev, "i915 init unsuccessful: %d\n", ret);
511 pci_free_irq(pci, 0, bus);
516 snd_hdac_bus_free_stream_pages(bus);
517 snd_hdac_ext_stream_free_all(bus);
521 iounmap(bus->remap_addr);
527 struct hdac_bus *bus = pci_get_drvdata(pci);
528 struct avs_dev *adev = hdac_to_avs(bus);
533 snd_hdac_stop_streams(bus);
535 snd_hdac_ext_bus_ppcap_int_enable(bus, false);
536 snd_hdac_ext_bus_link_power_down_all(bus);
538 snd_hdac_bus_stop_chip(bus);
539 snd_hdac_display_power(bus, HDA_CODEC_IDX_CONTROLLER, false);
542 pci_free_irq(pci, 0, bus);
549 struct hdac_bus *bus = pci_get_drvdata(pci);
550 struct avs_dev *adev = hdac_to_avs(bus);
563 snd_hdac_stop_streams_and_chip(bus);
565 snd_hdac_ext_bus_ppcap_int_enable(bus, false);
568 list_for_each_entry_safe(hdev, save, &bus->codec_list, list)
571 snd_hdac_bus_free_stream_pages(bus);
572 snd_hdac_ext_stream_free_all(bus);
574 snd_hdac_ext_link_free_all(bus);
575 snd_hdac_ext_bus_exit(bus);
578 snd_hdac_ext_bus_ppcap_enable(bus, false);
581 snd_hdac_bus_stop_chip(bus);
582 snd_hdac_display_power(bus, HDA_CODEC_IDX_CONTROLLER, false);
583 if (bus->audio_component)
584 snd_hdac_i915_exit(bus);
588 pci_free_irq(pci, 0, bus);
590 iounmap(bus->remap_addr);
605 struct hdac_bus *bus = &adev->base.core;
608 if (bus->cmd_dma_state)
609 snd_hdac_bus_stop_cmd_io(bus);
611 snd_hdac_ext_bus_link_power_down_all(bus);
621 struct hdac_bus *bus = &adev->base.core;
628 snd_hdac_ext_bus_link_power_down_all(bus);
642 snd_hdac_ext_bus_ppcap_int_enable(bus, false);
650 snd_hdac_ext_bus_ppcap_enable(bus, false);
653 snd_hdac_bus_stop_chip(bus);
655 avs_hdac_clock_gating_enable(bus, false);
656 snd_hdac_bus_enter_link_reset(bus);
657 avs_hdac_clock_gating_enable(bus, true);
659 snd_hdac_display_power(bus, HDA_CODEC_IDX_CONTROLLER, false);
666 struct hdac_bus *bus = &adev->base.core;
672 snd_hdac_ext_bus_link_power_up_all(bus);
674 if (bus->cmd_dma_state)
675 snd_hdac_bus_init_cmd_io(bus);
682 struct hdac_bus *bus = &adev->base.core;
688 snd_hdac_display_power(bus, HDA_CODEC_IDX_CONTROLLER, true);
689 avs_hdac_bus_init_chip(bus, true);
691 snd_hdac_ext_bus_ppcap_enable(bus, true);
692 snd_hdac_ext_bus_ppcap_int_enable(bus, true);