Lines Matching full:bus

39 avs_hda_update_config_dword(struct hdac_bus *bus, u32 reg, u32 mask, u32 value)  in avs_hda_update_config_dword()  argument
41 struct pci_dev *pci = to_pci_dev(bus->dev); in avs_hda_update_config_dword()
57 static void avs_hdac_clock_gating_enable(struct hdac_bus *bus, bool enable) in avs_hdac_clock_gating_enable() argument
61 avs_hda_update_config_dword(bus, AZX_PCIREG_CGCTL, cgctl_mask, value); in avs_hdac_clock_gating_enable()
76 static int avs_hdac_bus_init_streams(struct hdac_bus *bus) in avs_hdac_bus_init_streams() argument
81 gcap = snd_hdac_chip_readw(bus, GCAP); in avs_hdac_bus_init_streams()
84 bus->num_streams = cp_streams + pb_streams; in avs_hdac_bus_init_streams()
86 snd_hdac_ext_stream_init_all(bus, 0, cp_streams, SNDRV_PCM_STREAM_CAPTURE); in avs_hdac_bus_init_streams()
87 snd_hdac_ext_stream_init_all(bus, cp_streams, pb_streams, SNDRV_PCM_STREAM_PLAYBACK); in avs_hdac_bus_init_streams()
89 return snd_hdac_bus_alloc_stream_pages(bus); in avs_hdac_bus_init_streams()
92 static bool avs_hdac_bus_init_chip(struct hdac_bus *bus, bool full_reset) in avs_hdac_bus_init_chip() argument
97 avs_hdac_clock_gating_enable(bus, false); in avs_hdac_bus_init_chip()
98 ret = snd_hdac_bus_init_chip(bus, full_reset); in avs_hdac_bus_init_chip()
101 list_for_each_entry(hlink, &bus->hlink_list, list) in avs_hdac_bus_init_chip()
104 avs_hdac_clock_gating_enable(bus, true); in avs_hdac_bus_init_chip()
109 snd_hdac_chip_updatel(bus, VS_EM2, AZX_VS_EM2_DUM, AZX_VS_EM2_DUM); in avs_hdac_bus_init_chip()
114 static int probe_codec(struct hdac_bus *bus, int addr) in probe_codec() argument
122 mutex_lock(&bus->cmd_mutex); in probe_codec()
123 snd_hdac_bus_send_cmd(bus, cmd); in probe_codec()
124 snd_hdac_bus_get_response(bus, addr, &res); in probe_codec()
125 mutex_unlock(&bus->cmd_mutex); in probe_codec()
129 dev_dbg(bus->dev, "codec #%d probed OK: 0x%x\n", addr, res); in probe_codec()
131 codec = snd_hda_codec_device_init(to_hda_bus(bus), addr, "hdaudioB%dD%d", bus->idx, addr); in probe_codec()
133 dev_err(bus->dev, "init codec failed: %ld\n", PTR_ERR(codec)); in probe_codec()
146 dev_err(bus->dev, "failed to config codec %d\n", ret); in probe_codec()
153 static void avs_hdac_bus_probe_codecs(struct hdac_bus *bus) in avs_hdac_bus_probe_codecs() argument
159 if (!(bus->codec_mask & BIT(c))) in avs_hdac_bus_probe_codecs()
162 if (!probe_codec(bus, c)) in avs_hdac_bus_probe_codecs()
170 dev_warn(bus->dev, "Codec #%d probe error; disabling it...\n", c); in avs_hdac_bus_probe_codecs()
171 bus->codec_mask &= ~BIT(c); in avs_hdac_bus_probe_codecs()
174 * codec often screws up the controller bus, in avs_hdac_bus_probe_codecs()
177 * better to reset the controller bus to get in avs_hdac_bus_probe_codecs()
180 snd_hdac_bus_stop_chip(bus); in avs_hdac_bus_probe_codecs()
181 avs_hdac_bus_init_chip(bus, true); in avs_hdac_bus_probe_codecs()
188 struct hdac_bus *bus = &adev->base.core; in avs_hda_probe_work() local
192 pm_runtime_set_active(bus->dev); /* clear runtime_error flag */ in avs_hda_probe_work()
194 ret = snd_hdac_i915_init(bus); in avs_hda_probe_work()
196 dev_info(bus->dev, "i915 init unsuccessful: %d\n", ret); in avs_hda_probe_work()
198 snd_hdac_display_power(bus, HDA_CODEC_IDX_CONTROLLER, true); in avs_hda_probe_work()
199 avs_hdac_bus_init_chip(bus, true); in avs_hda_probe_work()
200 avs_hdac_bus_probe_codecs(bus); in avs_hda_probe_work()
201 snd_hdac_display_power(bus, HDA_CODEC_IDX_CONTROLLER, false); in avs_hda_probe_work()
204 list_for_each_entry(hlink, &bus->hlink_list, list) in avs_hda_probe_work()
205 snd_hdac_ext_bus_link_put(bus, hlink); in avs_hda_probe_work()
207 snd_hdac_ext_bus_ppcap_enable(bus, true); in avs_hda_probe_work()
208 snd_hdac_ext_bus_ppcap_int_enable(bus, true); in avs_hda_probe_work()
216 dev_info(bus->dev, "platform has no NHLT\n"); in avs_hda_probe_work()
222 pm_runtime_set_autosuspend_delay(bus->dev, 2000); in avs_hda_probe_work()
223 pm_runtime_use_autosuspend(bus->dev); in avs_hda_probe_work()
224 pm_runtime_mark_last_busy(bus->dev); in avs_hda_probe_work()
225 pm_runtime_put_autosuspend(bus->dev); in avs_hda_probe_work()
226 pm_runtime_allow(bus->dev); in avs_hda_probe_work()
245 static void hdac_update_stream(struct hdac_bus *bus, struct hdac_stream *stream) in hdac_update_stream() argument
259 struct hdac_bus *bus = context; in hdac_bus_irq_handler() local
264 if (!pm_runtime_active(bus->dev)) in hdac_bus_irq_handler()
267 spin_lock(&bus->reg_lock); in hdac_bus_irq_handler()
269 status = snd_hdac_chip_readl(bus, INTSTS); in hdac_bus_irq_handler()
271 spin_unlock(&bus->reg_lock); in hdac_bus_irq_handler()
276 status = snd_hdac_chip_readb(bus, RIRBSTS); in hdac_bus_irq_handler()
279 snd_hdac_bus_update_rirb(bus); in hdac_bus_irq_handler()
280 snd_hdac_chip_writeb(bus, RIRBSTS, RIRB_INT_MASK); in hdac_bus_irq_handler()
283 mask = (0x1 << bus->num_streams) - 1; in hdac_bus_irq_handler()
285 status = snd_hdac_chip_readl(bus, INTSTS); in hdac_bus_irq_handler()
289 int_enable = snd_hdac_chip_readl(bus, INTCTL); in hdac_bus_irq_handler()
290 snd_hdac_chip_writel(bus, INTCTL, (int_enable & (~mask))); in hdac_bus_irq_handler()
296 spin_unlock(&bus->reg_lock); in hdac_bus_irq_handler()
302 struct hdac_bus *bus = context; in hdac_bus_irq_thread() local
308 status = snd_hdac_chip_readl(bus, INTSTS); in hdac_bus_irq_thread()
310 snd_hdac_bus_handle_stream_irq(bus, status, hdac_update_stream); in hdac_bus_irq_thread()
313 mask = (0x1 << bus->num_streams) - 1; in hdac_bus_irq_thread()
314 spin_lock_irqsave(&bus->reg_lock, flags); in hdac_bus_irq_thread()
315 int_enable = snd_hdac_chip_readl(bus, INTCTL); in hdac_bus_irq_thread()
316 snd_hdac_chip_writel(bus, INTCTL, (int_enable | mask)); in hdac_bus_irq_thread()
317 spin_unlock_irqrestore(&bus->reg_lock, flags); in hdac_bus_irq_thread()
324 struct hdac_bus *bus = &adev->base.core; in avs_hdac_acquire_irq() local
325 struct pci_dev *pci = to_pci_dev(bus->dev); in avs_hdac_acquire_irq()
335 ret = pci_request_irq(pci, 0, hdac_bus_irq_handler, hdac_bus_irq_thread, bus, in avs_hdac_acquire_irq()
352 pci_free_irq(pci, 0, bus); in avs_hdac_acquire_irq()
360 struct hda_bus *bus = &adev->base; in avs_bus_init() local
365 ret = snd_hdac_ext_bus_init(&bus->core, dev, NULL, &soc_hda_ext_bus_ops); in avs_bus_init()
369 bus->core.use_posbuf = 1; in avs_bus_init()
370 bus->core.bdl_pos_adj = 0; in avs_bus_init()
371 bus->core.sync_write = 1; in avs_bus_init()
372 bus->pci = pci; in avs_bus_init()
373 bus->mixer_assigned = -1; in avs_bus_init()
374 mutex_init(&bus->prepare_mutex); in avs_bus_init()
402 struct hdac_bus *bus; in avs_pci_probe() local
420 dev_err(dev, "failed to init avs bus: %d\n", ret); in avs_pci_probe()
428 bus = &adev->base.core; in avs_pci_probe()
429 bus->addr = pci_resource_start(pci, 0); in avs_pci_probe()
430 bus->remap_addr = pci_ioremap_bar(pci, 0); in avs_pci_probe()
431 if (!bus->remap_addr) { in avs_pci_probe()
432 dev_err(bus->dev, "ioremap error\n"); in avs_pci_probe()
439 dev_err(bus->dev, "ioremap error\n"); in avs_pci_probe()
444 snd_hdac_bus_parse_capabilities(bus); in avs_pci_probe()
445 if (bus->mlcap) in avs_pci_probe()
446 snd_hdac_ext_bus_get_ml_capabilities(bus); in avs_pci_probe()
452 ret = avs_hdac_bus_init_streams(bus); in avs_pci_probe()
460 dev_err(bus->dev, "failed to acquire irq: %d\n", ret); in avs_pci_probe()
465 pci_set_drvdata(pci, bus); in avs_pci_probe()
473 snd_hdac_bus_free_stream_pages(bus); in avs_pci_probe()
474 snd_hdac_ext_stream_free_all(bus); in avs_pci_probe()
478 iounmap(bus->remap_addr); in avs_pci_probe()
486 struct hdac_bus *bus = pci_get_drvdata(pci); in avs_pci_shutdown() local
487 struct avs_dev *adev = hdac_to_avs(bus); in avs_pci_shutdown()
492 snd_hdac_stop_streams(bus); in avs_pci_shutdown()
494 snd_hdac_ext_bus_ppcap_int_enable(bus, false); in avs_pci_shutdown()
495 snd_hdac_ext_bus_link_power_down_all(bus); in avs_pci_shutdown()
497 snd_hdac_bus_stop_chip(bus); in avs_pci_shutdown()
498 snd_hdac_display_power(bus, HDA_CODEC_IDX_CONTROLLER, false); in avs_pci_shutdown()
503 pci_free_irq(pci, 0, bus); in avs_pci_shutdown()
510 struct hdac_bus *bus = pci_get_drvdata(pci); in avs_pci_remove() local
511 struct avs_dev *adev = hdac_to_avs(bus); in avs_pci_remove()
525 snd_hdac_stop_streams_and_chip(bus); in avs_pci_remove()
527 snd_hdac_ext_bus_ppcap_int_enable(bus, false); in avs_pci_remove()
530 list_for_each_entry_safe(hdev, save, &bus->codec_list, list) in avs_pci_remove()
533 snd_hdac_bus_free_stream_pages(bus); in avs_pci_remove()
534 snd_hdac_ext_stream_free_all(bus); in avs_pci_remove()
536 snd_hdac_ext_link_free_all(bus); in avs_pci_remove()
537 snd_hdac_ext_bus_exit(bus); in avs_pci_remove()
540 snd_hdac_ext_bus_ppcap_enable(bus, false); in avs_pci_remove()
543 snd_hdac_bus_stop_chip(bus); in avs_pci_remove()
544 snd_hdac_display_power(bus, HDA_CODEC_IDX_CONTROLLER, false); in avs_pci_remove()
545 if (bus->audio_component) in avs_pci_remove()
546 snd_hdac_i915_exit(bus); in avs_pci_remove()
550 pci_free_irq(pci, 0, bus); in avs_pci_remove()
552 iounmap(bus->remap_addr); in avs_pci_remove()
568 struct hdac_bus *bus = &adev->base.core; in avs_suspend_standby() local
571 if (bus->cmd_dma_state) in avs_suspend_standby()
572 snd_hdac_bus_stop_cmd_io(bus); in avs_suspend_standby()
574 snd_hdac_ext_bus_link_power_down_all(bus); in avs_suspend_standby()
584 struct hdac_bus *bus = &adev->base.core; in avs_suspend_common() local
591 snd_hdac_ext_bus_link_power_down_all(bus); in avs_suspend_common()
605 snd_hdac_ext_bus_ppcap_int_enable(bus, false); in avs_suspend_common()
613 snd_hdac_ext_bus_ppcap_enable(bus, false); in avs_suspend_common()
616 snd_hdac_bus_stop_chip(bus); in avs_suspend_common()
618 avs_hdac_clock_gating_enable(bus, false); in avs_suspend_common()
619 snd_hdac_bus_enter_link_reset(bus); in avs_suspend_common()
620 avs_hdac_clock_gating_enable(bus, true); in avs_suspend_common()
622 snd_hdac_display_power(bus, HDA_CODEC_IDX_CONTROLLER, false); in avs_suspend_common()
629 struct hdac_bus *bus = &adev->base.core; in avs_resume_standby() local
635 snd_hdac_ext_bus_link_power_up_all(bus); in avs_resume_standby()
637 if (bus->cmd_dma_state) in avs_resume_standby()
638 snd_hdac_bus_init_cmd_io(bus); in avs_resume_standby()
645 struct hdac_bus *bus = &adev->base.core; in avs_resume_common() local
651 snd_hdac_display_power(bus, HDA_CODEC_IDX_CONTROLLER, true); in avs_resume_common()
652 avs_hdac_bus_init_chip(bus, true); in avs_resume_common()
654 snd_hdac_ext_bus_ppcap_enable(bus, true); in avs_resume_common()
655 snd_hdac_ext_bus_ppcap_int_enable(bus, true); in avs_resume_common()