Lines Matching full:bus
31 avs_hda_update_config_dword(struct hdac_bus *bus, u32 reg, u32 mask, u32 value) in avs_hda_update_config_dword() argument
33 struct pci_dev *pci = to_pci_dev(bus->dev); in avs_hda_update_config_dword()
51 static void avs_hdac_clock_gating_enable(struct hdac_bus *bus, bool enable) in avs_hdac_clock_gating_enable() argument
56 avs_hda_update_config_dword(bus, AZX_PCIREG_CGCTL, AZX_CGCTL_MISCBDCGE_MASK, value); in avs_hdac_clock_gating_enable()
72 static int avs_hdac_bus_init_streams(struct hdac_bus *bus) in avs_hdac_bus_init_streams() argument
77 gcap = snd_hdac_chip_readw(bus, GCAP); in avs_hdac_bus_init_streams()
80 bus->num_streams = cp_streams + pb_streams; in avs_hdac_bus_init_streams()
82 snd_hdac_ext_stream_init_all(bus, 0, cp_streams, SNDRV_PCM_STREAM_CAPTURE); in avs_hdac_bus_init_streams()
83 snd_hdac_ext_stream_init_all(bus, cp_streams, pb_streams, SNDRV_PCM_STREAM_PLAYBACK); in avs_hdac_bus_init_streams()
85 return snd_hdac_bus_alloc_stream_pages(bus); in avs_hdac_bus_init_streams()
88 static bool avs_hdac_bus_init_chip(struct hdac_bus *bus, bool full_reset) in avs_hdac_bus_init_chip() argument
93 avs_hdac_clock_gating_enable(bus, false); in avs_hdac_bus_init_chip()
94 ret = snd_hdac_bus_init_chip(bus, full_reset); in avs_hdac_bus_init_chip()
97 list_for_each_entry(hlink, &bus->hlink_list, list) in avs_hdac_bus_init_chip()
100 avs_hdac_clock_gating_enable(bus, true); in avs_hdac_bus_init_chip()
105 snd_hdac_chip_updatel(bus, VS_EM2, AZX_VS_EM2_DUM, AZX_VS_EM2_DUM); in avs_hdac_bus_init_chip()
110 static int probe_codec(struct hdac_bus *bus, int addr) in probe_codec() argument
118 mutex_lock(&bus->cmd_mutex); in probe_codec()
119 snd_hdac_bus_send_cmd(bus, cmd); in probe_codec()
120 snd_hdac_bus_get_response(bus, addr, &res); in probe_codec()
121 mutex_unlock(&bus->cmd_mutex); in probe_codec()
125 dev_dbg(bus->dev, "codec #%d probed OK: 0x%x\n", addr, res); in probe_codec()
127 codec = snd_hda_codec_device_init(to_hda_bus(bus), addr, "hdaudioB%dD%d", bus->idx, addr); in probe_codec()
129 dev_err(bus->dev, "init codec failed: %ld\n", PTR_ERR(codec)); in probe_codec()
142 dev_err(bus->dev, "failed to config codec %d\n", ret); in probe_codec()
149 static void avs_hdac_bus_probe_codecs(struct hdac_bus *bus) in avs_hdac_bus_probe_codecs() argument
155 if (!(bus->codec_mask & BIT(c))) in avs_hdac_bus_probe_codecs()
158 if (!probe_codec(bus, c)) in avs_hdac_bus_probe_codecs()
166 dev_warn(bus->dev, "Codec #%d probe error; disabling it...\n", c); in avs_hdac_bus_probe_codecs()
167 bus->codec_mask &= ~BIT(c); in avs_hdac_bus_probe_codecs()
170 * codec often screws up the controller bus, in avs_hdac_bus_probe_codecs()
173 * better to reset the controller bus to get in avs_hdac_bus_probe_codecs()
176 snd_hdac_bus_stop_chip(bus); in avs_hdac_bus_probe_codecs()
177 avs_hdac_bus_init_chip(bus, true); in avs_hdac_bus_probe_codecs()
184 struct hdac_bus *bus = &adev->base.core; in avs_hda_probe_work() local
188 pm_runtime_set_active(bus->dev); /* clear runtime_error flag */ in avs_hda_probe_work()
190 ret = snd_hdac_i915_init(bus); in avs_hda_probe_work()
192 dev_info(bus->dev, "i915 init unsuccessful: %d\n", ret); in avs_hda_probe_work()
194 snd_hdac_display_power(bus, HDA_CODEC_IDX_CONTROLLER, true); in avs_hda_probe_work()
195 avs_hdac_bus_init_chip(bus, true); in avs_hda_probe_work()
196 avs_hdac_bus_probe_codecs(bus); in avs_hda_probe_work()
197 snd_hdac_display_power(bus, HDA_CODEC_IDX_CONTROLLER, false); in avs_hda_probe_work()
200 list_for_each_entry(hlink, &bus->hlink_list, list) in avs_hda_probe_work()
201 snd_hdac_ext_bus_link_put(bus, hlink); in avs_hda_probe_work()
203 snd_hdac_ext_bus_ppcap_enable(bus, true); in avs_hda_probe_work()
204 snd_hdac_ext_bus_ppcap_int_enable(bus, true); in avs_hda_probe_work()
212 dev_info(bus->dev, "platform has no NHLT\n"); in avs_hda_probe_work()
217 pm_runtime_set_autosuspend_delay(bus->dev, 2000); in avs_hda_probe_work()
218 pm_runtime_use_autosuspend(bus->dev); in avs_hda_probe_work()
219 pm_runtime_mark_last_busy(bus->dev); in avs_hda_probe_work()
220 pm_runtime_put_autosuspend(bus->dev); in avs_hda_probe_work()
221 pm_runtime_allow(bus->dev); in avs_hda_probe_work()
240 static void hdac_update_stream(struct hdac_bus *bus, struct hdac_stream *stream) in hdac_update_stream() argument
254 struct hdac_bus *bus = context; in hdac_bus_irq_handler() local
259 if (!pm_runtime_active(bus->dev)) in hdac_bus_irq_handler()
262 spin_lock(&bus->reg_lock); in hdac_bus_irq_handler()
264 status = snd_hdac_chip_readl(bus, INTSTS); in hdac_bus_irq_handler()
266 spin_unlock(&bus->reg_lock); in hdac_bus_irq_handler()
271 status = snd_hdac_chip_readb(bus, RIRBSTS); in hdac_bus_irq_handler()
274 snd_hdac_bus_update_rirb(bus); in hdac_bus_irq_handler()
275 snd_hdac_chip_writeb(bus, RIRBSTS, RIRB_INT_MASK); in hdac_bus_irq_handler()
278 mask = (0x1 << bus->num_streams) - 1; in hdac_bus_irq_handler()
280 status = snd_hdac_chip_readl(bus, INTSTS); in hdac_bus_irq_handler()
284 int_enable = snd_hdac_chip_readl(bus, INTCTL); in hdac_bus_irq_handler()
285 snd_hdac_chip_writel(bus, INTCTL, (int_enable & (~mask))); in hdac_bus_irq_handler()
291 spin_unlock(&bus->reg_lock); in hdac_bus_irq_handler()
297 struct hdac_bus *bus = context; in hdac_bus_irq_thread() local
303 status = snd_hdac_chip_readl(bus, INTSTS); in hdac_bus_irq_thread()
305 snd_hdac_bus_handle_stream_irq(bus, status, hdac_update_stream); in hdac_bus_irq_thread()
308 mask = (0x1 << bus->num_streams) - 1; in hdac_bus_irq_thread()
309 spin_lock_irqsave(&bus->reg_lock, flags); in hdac_bus_irq_thread()
310 int_enable = snd_hdac_chip_readl(bus, INTCTL); in hdac_bus_irq_thread()
311 snd_hdac_chip_writel(bus, INTCTL, (int_enable | mask)); in hdac_bus_irq_thread()
312 spin_unlock_irqrestore(&bus->reg_lock, flags); in hdac_bus_irq_thread()
319 struct hdac_bus *bus = &adev->base.core; in avs_hdac_acquire_irq() local
320 struct pci_dev *pci = to_pci_dev(bus->dev); in avs_hdac_acquire_irq()
330 ret = pci_request_irq(pci, 0, hdac_bus_irq_handler, hdac_bus_irq_thread, bus, in avs_hdac_acquire_irq()
347 pci_free_irq(pci, 0, bus); in avs_hdac_acquire_irq()
355 struct hda_bus *bus = &adev->base; in avs_bus_init() local
360 ret = snd_hdac_ext_bus_init(&bus->core, dev, NULL, &soc_hda_ext_bus_ops); in avs_bus_init()
364 bus->core.use_posbuf = 1; in avs_bus_init()
365 bus->core.bdl_pos_adj = 0; in avs_bus_init()
366 bus->core.sync_write = 1; in avs_bus_init()
367 bus->pci = pci; in avs_bus_init()
368 bus->mixer_assigned = -1; in avs_bus_init()
369 mutex_init(&bus->prepare_mutex); in avs_bus_init()
397 struct hdac_bus *bus; in avs_pci_probe() local
415 dev_err(dev, "failed to init avs bus: %d\n", ret); in avs_pci_probe()
423 bus = &adev->base.core; in avs_pci_probe()
424 bus->addr = pci_resource_start(pci, 0); in avs_pci_probe()
425 bus->remap_addr = pci_ioremap_bar(pci, 0); in avs_pci_probe()
426 if (!bus->remap_addr) { in avs_pci_probe()
427 dev_err(bus->dev, "ioremap error\n"); in avs_pci_probe()
434 dev_err(bus->dev, "ioremap error\n"); in avs_pci_probe()
439 snd_hdac_bus_parse_capabilities(bus); in avs_pci_probe()
440 if (bus->mlcap) in avs_pci_probe()
441 snd_hdac_ext_bus_get_ml_capabilities(bus); in avs_pci_probe()
447 ret = avs_hdac_bus_init_streams(bus); in avs_pci_probe()
455 dev_err(bus->dev, "failed to acquire irq: %d\n", ret); in avs_pci_probe()
460 pci_set_drvdata(pci, bus); in avs_pci_probe()
468 snd_hdac_bus_free_stream_pages(bus); in avs_pci_probe()
469 snd_hdac_ext_stream_free_all(bus); in avs_pci_probe()
473 iounmap(bus->remap_addr); in avs_pci_probe()
482 struct hdac_bus *bus = pci_get_drvdata(pci); in avs_pci_remove() local
483 struct avs_dev *adev = hdac_to_avs(bus); in avs_pci_remove()
496 snd_hdac_stop_streams_and_chip(bus); in avs_pci_remove()
498 snd_hdac_ext_bus_ppcap_int_enable(bus, false); in avs_pci_remove()
501 list_for_each_entry_safe(hdev, save, &bus->codec_list, list) in avs_pci_remove()
504 snd_hdac_bus_free_stream_pages(bus); in avs_pci_remove()
505 snd_hdac_ext_stream_free_all(bus); in avs_pci_remove()
507 snd_hdac_link_free_all(bus); in avs_pci_remove()
508 snd_hdac_ext_bus_exit(bus); in avs_pci_remove()
511 snd_hdac_ext_bus_ppcap_enable(bus, false); in avs_pci_remove()
514 snd_hdac_bus_stop_chip(bus); in avs_pci_remove()
515 snd_hdac_display_power(bus, HDA_CODEC_IDX_CONTROLLER, false); in avs_pci_remove()
516 if (bus->audio_component) in avs_pci_remove()
517 snd_hdac_i915_exit(bus); in avs_pci_remove()
521 pci_free_irq(pci, 0, bus); in avs_pci_remove()
523 iounmap(bus->remap_addr); in avs_pci_remove()
539 struct hdac_bus *bus = &adev->base.core; in avs_suspend_common() local
544 snd_hdac_ext_bus_link_power_down_all(bus); in avs_suspend_common()
558 snd_hdac_ext_bus_ppcap_int_enable(bus, false); in avs_suspend_common()
566 snd_hdac_ext_bus_ppcap_enable(bus, false); in avs_suspend_common()
569 snd_hdac_bus_stop_chip(bus); in avs_suspend_common()
571 avs_hdac_clock_gating_enable(bus, false); in avs_suspend_common()
572 snd_hdac_bus_enter_link_reset(bus); in avs_suspend_common()
573 avs_hdac_clock_gating_enable(bus, true); in avs_suspend_common()
575 snd_hdac_display_power(bus, HDA_CODEC_IDX_CONTROLLER, false); in avs_suspend_common()
582 struct hdac_bus *bus = &adev->base.core; in avs_resume_common() local
586 snd_hdac_display_power(bus, HDA_CODEC_IDX_CONTROLLER, true); in avs_resume_common()
587 avs_hdac_bus_init_chip(bus, true); in avs_resume_common()
589 snd_hdac_ext_bus_ppcap_enable(bus, true); in avs_resume_common()
590 snd_hdac_ext_bus_ppcap_int_enable(bus, true); in avs_resume_common()
599 list_for_each_entry(hlink, &bus->hlink_list, list) { in avs_resume_common()
605 if (!bus->cmd_dma_state) in avs_resume_common()
606 snd_hdac_bus_stop_cmd_io(bus); in avs_resume_common()