Lines Matching full:bus

40 avs_hda_update_config_dword(struct hdac_bus *bus, u32 reg, u32 mask, u32 value)  in avs_hda_update_config_dword()  argument
42 struct pci_dev *pci = to_pci_dev(bus->dev); in avs_hda_update_config_dword()
58 static void avs_hdac_clock_gating_enable(struct hdac_bus *bus, bool enable) in avs_hdac_clock_gating_enable() argument
62 avs_hda_update_config_dword(bus, AZX_PCIREG_CGCTL, cgctl_mask, value); in avs_hdac_clock_gating_enable()
77 static int avs_hdac_bus_init_streams(struct hdac_bus *bus) in avs_hdac_bus_init_streams() argument
82 gcap = snd_hdac_chip_readw(bus, GCAP); in avs_hdac_bus_init_streams()
85 bus->num_streams = cp_streams + pb_streams; in avs_hdac_bus_init_streams()
87 snd_hdac_ext_stream_init_all(bus, 0, cp_streams, SNDRV_PCM_STREAM_CAPTURE); in avs_hdac_bus_init_streams()
88 snd_hdac_ext_stream_init_all(bus, cp_streams, pb_streams, SNDRV_PCM_STREAM_PLAYBACK); in avs_hdac_bus_init_streams()
90 return snd_hdac_bus_alloc_stream_pages(bus); in avs_hdac_bus_init_streams()
93 static bool avs_hdac_bus_init_chip(struct hdac_bus *bus, bool full_reset) in avs_hdac_bus_init_chip() argument
98 avs_hdac_clock_gating_enable(bus, false); in avs_hdac_bus_init_chip()
99 ret = snd_hdac_bus_init_chip(bus, full_reset); in avs_hdac_bus_init_chip()
102 list_for_each_entry(hlink, &bus->hlink_list, list) in avs_hdac_bus_init_chip()
105 avs_hdac_clock_gating_enable(bus, true); in avs_hdac_bus_init_chip()
110 snd_hdac_chip_updatel(bus, VS_EM2, AZX_VS_EM2_DUM, AZX_VS_EM2_DUM); in avs_hdac_bus_init_chip()
115 static int probe_codec(struct hdac_bus *bus, int addr) in probe_codec() argument
123 mutex_lock(&bus->cmd_mutex); in probe_codec()
124 snd_hdac_bus_send_cmd(bus, cmd); in probe_codec()
125 snd_hdac_bus_get_response(bus, addr, &res); in probe_codec()
126 mutex_unlock(&bus->cmd_mutex); in probe_codec()
130 dev_dbg(bus->dev, "codec #%d probed OK: 0x%x\n", addr, res); in probe_codec()
132 codec = snd_hda_codec_device_init(to_hda_bus(bus), addr, "hdaudioB%dD%d", bus->idx, addr); in probe_codec()
134 dev_err(bus->dev, "init codec failed: %ld\n", PTR_ERR(codec)); in probe_codec()
147 dev_err(bus->dev, "failed to config codec %d\n", ret); in probe_codec()
154 static void avs_hdac_bus_probe_codecs(struct hdac_bus *bus) in avs_hdac_bus_probe_codecs() argument
160 if (!(bus->codec_mask & BIT(c))) in avs_hdac_bus_probe_codecs()
163 if (!probe_codec(bus, c)) in avs_hdac_bus_probe_codecs()
171 dev_warn(bus->dev, "Codec #%d probe error; disabling it...\n", c); in avs_hdac_bus_probe_codecs()
172 bus->codec_mask &= ~BIT(c); in avs_hdac_bus_probe_codecs()
175 * codec often screws up the controller bus, in avs_hdac_bus_probe_codecs()
178 * better to reset the controller bus to get in avs_hdac_bus_probe_codecs()
181 snd_hdac_bus_stop_chip(bus); in avs_hdac_bus_probe_codecs()
182 avs_hdac_bus_init_chip(bus, true); in avs_hdac_bus_probe_codecs()
189 struct hdac_bus *bus = &adev->base.core; in avs_hda_probe_work() local
193 pm_runtime_set_active(bus->dev); /* clear runtime_error flag */ in avs_hda_probe_work()
195 snd_hdac_display_power(bus, HDA_CODEC_IDX_CONTROLLER, true); in avs_hda_probe_work()
196 avs_hdac_bus_init_chip(bus, true); in avs_hda_probe_work()
197 avs_hdac_bus_probe_codecs(bus); in avs_hda_probe_work()
198 snd_hdac_display_power(bus, HDA_CODEC_IDX_CONTROLLER, false); in avs_hda_probe_work()
201 list_for_each_entry(hlink, &bus->hlink_list, list) in avs_hda_probe_work()
202 snd_hdac_ext_bus_link_put(bus, hlink); in avs_hda_probe_work()
204 snd_hdac_ext_bus_ppcap_enable(bus, true); in avs_hda_probe_work()
205 snd_hdac_ext_bus_ppcap_int_enable(bus, true); in avs_hda_probe_work()
213 dev_info(bus->dev, "platform has no NHLT\n"); in avs_hda_probe_work()
219 pm_runtime_set_autosuspend_delay(bus->dev, 2000); in avs_hda_probe_work()
220 pm_runtime_use_autosuspend(bus->dev); in avs_hda_probe_work()
221 pm_runtime_mark_last_busy(bus->dev); in avs_hda_probe_work()
222 pm_runtime_put_autosuspend(bus->dev); in avs_hda_probe_work()
223 pm_runtime_allow(bus->dev); in avs_hda_probe_work()
242 static void hdac_update_stream(struct hdac_bus *bus, struct hdac_stream *stream) in hdac_update_stream() argument
256 struct hdac_bus *bus = context; in hdac_bus_irq_handler() local
261 if (!pm_runtime_active(bus->dev)) in hdac_bus_irq_handler()
264 spin_lock(&bus->reg_lock); in hdac_bus_irq_handler()
266 status = snd_hdac_chip_readl(bus, INTSTS); in hdac_bus_irq_handler()
268 spin_unlock(&bus->reg_lock); in hdac_bus_irq_handler()
273 status = snd_hdac_chip_readb(bus, RIRBSTS); in hdac_bus_irq_handler()
276 snd_hdac_bus_update_rirb(bus); in hdac_bus_irq_handler()
277 snd_hdac_chip_writeb(bus, RIRBSTS, RIRB_INT_MASK); in hdac_bus_irq_handler()
280 mask = (0x1 << bus->num_streams) - 1; in hdac_bus_irq_handler()
282 status = snd_hdac_chip_readl(bus, INTSTS); in hdac_bus_irq_handler()
286 int_enable = snd_hdac_chip_readl(bus, INTCTL); in hdac_bus_irq_handler()
287 snd_hdac_chip_writel(bus, INTCTL, (int_enable & (~mask))); in hdac_bus_irq_handler()
293 spin_unlock(&bus->reg_lock); in hdac_bus_irq_handler()
299 struct hdac_bus *bus = context; in hdac_bus_irq_thread() local
305 status = snd_hdac_chip_readl(bus, INTSTS); in hdac_bus_irq_thread()
307 snd_hdac_bus_handle_stream_irq(bus, status, hdac_update_stream); in hdac_bus_irq_thread()
310 mask = (0x1 << bus->num_streams) - 1; in hdac_bus_irq_thread()
311 spin_lock_irqsave(&bus->reg_lock, flags); in hdac_bus_irq_thread()
312 int_enable = snd_hdac_chip_readl(bus, INTCTL); in hdac_bus_irq_thread()
313 snd_hdac_chip_writel(bus, INTCTL, (int_enable | mask)); in hdac_bus_irq_thread()
314 spin_unlock_irqrestore(&bus->reg_lock, flags); in hdac_bus_irq_thread()
321 struct hdac_bus *bus = &adev->base.core; in avs_hdac_acquire_irq() local
322 struct pci_dev *pci = to_pci_dev(bus->dev); in avs_hdac_acquire_irq()
332 ret = pci_request_irq(pci, 0, hdac_bus_irq_handler, hdac_bus_irq_thread, bus, in avs_hdac_acquire_irq()
349 pci_free_irq(pci, 0, bus); in avs_hdac_acquire_irq()
357 struct hda_bus *bus = &adev->base; in avs_bus_init() local
362 ret = snd_hdac_ext_bus_init(&bus->core, dev, NULL, &soc_hda_ext_bus_ops); in avs_bus_init()
366 bus->core.use_posbuf = 1; in avs_bus_init()
367 bus->core.bdl_pos_adj = 0; in avs_bus_init()
368 bus->core.sync_write = 1; in avs_bus_init()
369 bus->pci = pci; in avs_bus_init()
370 bus->mixer_assigned = -1; in avs_bus_init()
371 mutex_init(&bus->prepare_mutex); in avs_bus_init()
403 struct hdac_bus *bus; in avs_pci_probe() local
421 dev_err(dev, "failed to init avs bus: %d\n", ret); in avs_pci_probe()
429 bus = &adev->base.core; in avs_pci_probe()
430 bus->addr = pci_resource_start(pci, 0); in avs_pci_probe()
431 bus->remap_addr = pci_ioremap_bar(pci, 0); in avs_pci_probe()
432 if (!bus->remap_addr) { in avs_pci_probe()
433 dev_err(bus->dev, "ioremap error\n"); in avs_pci_probe()
440 dev_err(bus->dev, "ioremap error\n"); in avs_pci_probe()
445 snd_hdac_bus_parse_capabilities(bus); in avs_pci_probe()
446 if (bus->mlcap) in avs_pci_probe()
447 snd_hdac_ext_bus_get_ml_capabilities(bus); in avs_pci_probe()
453 ret = avs_hdac_bus_init_streams(bus); in avs_pci_probe()
461 dev_err(bus->dev, "failed to acquire irq: %d\n", ret); in avs_pci_probe()
466 pci_set_drvdata(pci, bus); in avs_pci_probe()
469 ret = snd_hdac_i915_init(bus); in avs_pci_probe()
473 dev_info(bus->dev, "i915 init unsuccessful: %d\n", ret); in avs_pci_probe()
481 pci_free_irq(pci, 0, bus); in avs_pci_probe()
486 snd_hdac_bus_free_stream_pages(bus); in avs_pci_probe()
487 snd_hdac_ext_stream_free_all(bus); in avs_pci_probe()
491 iounmap(bus->remap_addr); in avs_pci_probe()
499 struct hdac_bus *bus = pci_get_drvdata(pci); in avs_pci_shutdown() local
500 struct avs_dev *adev = hdac_to_avs(bus); in avs_pci_shutdown()
505 snd_hdac_stop_streams(bus); in avs_pci_shutdown()
507 snd_hdac_ext_bus_ppcap_int_enable(bus, false); in avs_pci_shutdown()
508 snd_hdac_ext_bus_link_power_down_all(bus); in avs_pci_shutdown()
510 snd_hdac_bus_stop_chip(bus); in avs_pci_shutdown()
511 snd_hdac_display_power(bus, HDA_CODEC_IDX_CONTROLLER, false); in avs_pci_shutdown()
516 pci_free_irq(pci, 0, bus); in avs_pci_shutdown()
523 struct hdac_bus *bus = pci_get_drvdata(pci); in avs_pci_remove() local
524 struct avs_dev *adev = hdac_to_avs(bus); in avs_pci_remove()
538 snd_hdac_stop_streams_and_chip(bus); in avs_pci_remove()
540 snd_hdac_ext_bus_ppcap_int_enable(bus, false); in avs_pci_remove()
543 list_for_each_entry_safe(hdev, save, &bus->codec_list, list) in avs_pci_remove()
546 snd_hdac_bus_free_stream_pages(bus); in avs_pci_remove()
547 snd_hdac_ext_stream_free_all(bus); in avs_pci_remove()
549 snd_hdac_ext_link_free_all(bus); in avs_pci_remove()
550 snd_hdac_ext_bus_exit(bus); in avs_pci_remove()
553 snd_hdac_ext_bus_ppcap_enable(bus, false); in avs_pci_remove()
556 snd_hdac_bus_stop_chip(bus); in avs_pci_remove()
557 snd_hdac_display_power(bus, HDA_CODEC_IDX_CONTROLLER, false); in avs_pci_remove()
558 if (bus->audio_component) in avs_pci_remove()
559 snd_hdac_i915_exit(bus); in avs_pci_remove()
563 pci_free_irq(pci, 0, bus); in avs_pci_remove()
565 iounmap(bus->remap_addr); in avs_pci_remove()
581 struct hdac_bus *bus = &adev->base.core; in avs_suspend_standby() local
584 if (bus->cmd_dma_state) in avs_suspend_standby()
585 snd_hdac_bus_stop_cmd_io(bus); in avs_suspend_standby()
587 snd_hdac_ext_bus_link_power_down_all(bus); in avs_suspend_standby()
597 struct hdac_bus *bus = &adev->base.core; in avs_suspend_common() local
604 snd_hdac_ext_bus_link_power_down_all(bus); in avs_suspend_common()
618 snd_hdac_ext_bus_ppcap_int_enable(bus, false); in avs_suspend_common()
626 snd_hdac_ext_bus_ppcap_enable(bus, false); in avs_suspend_common()
629 snd_hdac_bus_stop_chip(bus); in avs_suspend_common()
631 avs_hdac_clock_gating_enable(bus, false); in avs_suspend_common()
632 snd_hdac_bus_enter_link_reset(bus); in avs_suspend_common()
633 avs_hdac_clock_gating_enable(bus, true); in avs_suspend_common()
635 snd_hdac_display_power(bus, HDA_CODEC_IDX_CONTROLLER, false); in avs_suspend_common()
642 struct hdac_bus *bus = &adev->base.core; in avs_resume_standby() local
648 snd_hdac_ext_bus_link_power_up_all(bus); in avs_resume_standby()
650 if (bus->cmd_dma_state) in avs_resume_standby()
651 snd_hdac_bus_init_cmd_io(bus); in avs_resume_standby()
658 struct hdac_bus *bus = &adev->base.core; in avs_resume_common() local
664 snd_hdac_display_power(bus, HDA_CODEC_IDX_CONTROLLER, true); in avs_resume_common()
665 avs_hdac_bus_init_chip(bus, true); in avs_resume_common()
667 snd_hdac_ext_bus_ppcap_enable(bus, true); in avs_resume_common()
668 snd_hdac_ext_bus_ppcap_int_enable(bus, true); in avs_resume_common()