Lines Matching full:bus
57 struct hdac_bus *bus = skl_to_bus(skl); in skl_init_pci() local
66 dev_dbg(bus->dev, "Clearing TCSEL\n"); in skl_init_pci()
106 struct hdac_bus *bus = pci_get_drvdata(pci); in skl_clock_power_gating() local
115 snd_hdac_chip_updatel(bus, VS_EM2, AZX_REG_VS_EM2_L1SEN, val); in skl_clock_power_gating()
127 static int skl_init_chip(struct hdac_bus *bus, bool full_reset) in skl_init_chip() argument
132 skl_enable_miscbdcge(bus->dev, false); in skl_init_chip()
133 ret = snd_hdac_bus_init_chip(bus, full_reset); in skl_init_chip()
136 list_for_each_entry(hlink, &bus->hlink_list, list) in skl_init_chip()
139 skl_enable_miscbdcge(bus->dev, true); in skl_init_chip()
147 struct hdac_bus *bus = pci_get_drvdata(pci); in skl_update_d0i3c() local
151 reg = snd_hdac_chip_readb(bus, VS_D0I3C); in skl_update_d0i3c()
155 reg = snd_hdac_chip_readb(bus, VS_D0I3C); in skl_update_d0i3c()
160 dev_err(bus->dev, "Before D0I3C update: D0I3C CIP timeout\n"); in skl_update_d0i3c()
169 snd_hdac_chip_writeb(bus, VS_D0I3C, reg); in skl_update_d0i3c()
173 reg = snd_hdac_chip_readb(bus, VS_D0I3C); in skl_update_d0i3c()
176 reg = snd_hdac_chip_readb(bus, VS_D0I3C); in skl_update_d0i3c()
181 dev_err(bus->dev, "After D0I3C update: D0I3C CIP timeout\n"); in skl_update_d0i3c()
185 dev_dbg(bus->dev, "D0I3C register = 0x%x\n", in skl_update_d0i3c()
186 snd_hdac_chip_readb(bus, VS_D0I3C)); in skl_update_d0i3c()
191 * @bus: HD-audio core bus
196 static void skl_dum_set(struct hdac_bus *bus) in skl_dum_set() argument
199 if (!(snd_hdac_chip_readb(bus, GCTL) & AZX_GCTL_RESET)) { in skl_dum_set()
200 skl_enable_miscbdcge(bus->dev, false); in skl_dum_set()
201 snd_hdac_bus_exit_link_reset(bus); in skl_dum_set()
202 skl_enable_miscbdcge(bus->dev, true); in skl_dum_set()
205 snd_hdac_chip_updatel(bus, VS_EM2, AZX_VS_EM2_DUM, AZX_VS_EM2_DUM); in skl_dum_set()
209 static void skl_stream_update(struct hdac_bus *bus, struct hdac_stream *hstr) in skl_stream_update() argument
216 struct hdac_bus *bus = dev_id; in skl_interrupt() local
219 if (!pm_runtime_active(bus->dev)) in skl_interrupt()
222 spin_lock(&bus->reg_lock); in skl_interrupt()
224 status = snd_hdac_chip_readl(bus, INTSTS); in skl_interrupt()
226 spin_unlock(&bus->reg_lock); in skl_interrupt()
231 status = snd_hdac_chip_readb(bus, RIRBSTS); in skl_interrupt()
234 snd_hdac_bus_update_rirb(bus); in skl_interrupt()
235 snd_hdac_chip_writeb(bus, RIRBSTS, RIRB_INT_MASK); in skl_interrupt()
238 spin_unlock(&bus->reg_lock); in skl_interrupt()
240 return snd_hdac_chip_readl(bus, INTSTS) ? IRQ_WAKE_THREAD : IRQ_HANDLED; in skl_interrupt()
245 struct hdac_bus *bus = dev_id; in skl_threaded_handler() local
248 status = snd_hdac_chip_readl(bus, INTSTS); in skl_threaded_handler()
250 snd_hdac_bus_handle_stream_irq(bus, status, skl_stream_update); in skl_threaded_handler()
255 static int skl_acquire_irq(struct hdac_bus *bus, int do_disconnect) in skl_acquire_irq() argument
257 struct skl_dev *skl = bus_to_skl(bus); in skl_acquire_irq()
263 KBUILD_MODNAME, bus); in skl_acquire_irq()
265 dev_err(bus->dev, in skl_acquire_irq()
271 bus->irq = skl->pci->irq; in skl_acquire_irq()
280 struct hdac_bus *bus = pci_get_drvdata(pci); in skl_suspend_late() local
281 struct skl_dev *skl = bus_to_skl(bus); in skl_suspend_late()
287 static int _skl_suspend(struct hdac_bus *bus) in _skl_suspend() argument
289 struct skl_dev *skl = bus_to_skl(bus); in _skl_suspend()
290 struct pci_dev *pci = to_pci_dev(bus->dev); in _skl_suspend()
293 snd_hdac_ext_bus_link_power_down_all(bus); in _skl_suspend()
299 snd_hdac_bus_stop_chip(bus); in _skl_suspend()
302 skl_enable_miscbdcge(bus->dev, false); in _skl_suspend()
303 snd_hdac_bus_enter_link_reset(bus); in _skl_suspend()
304 skl_enable_miscbdcge(bus->dev, true); in _skl_suspend()
310 static int _skl_resume(struct hdac_bus *bus) in _skl_resume() argument
312 struct skl_dev *skl = bus_to_skl(bus); in _skl_resume()
315 skl_dum_set(bus); in _skl_resume()
316 skl_init_chip(bus, true); in _skl_resume()
329 struct hdac_bus *bus = pci_get_drvdata(pci); in skl_suspend() local
330 struct skl_dev *skl = bus_to_skl(bus); in skl_suspend()
339 snd_hdac_ext_bus_link_power_down_all(bus); in skl_suspend()
341 if (bus->cmd_dma_state) in skl_suspend()
342 snd_hdac_bus_stop_cmd_io(bus); in skl_suspend()
344 enable_irq_wake(bus->irq); in skl_suspend()
347 ret = _skl_suspend(bus); in skl_suspend()
359 struct hdac_bus *bus = pci_get_drvdata(pci); in skl_resume() local
360 struct skl_dev *skl = bus_to_skl(bus); in skl_resume()
370 snd_hdac_ext_bus_link_power_up_all(bus); in skl_resume()
371 disable_irq_wake(bus->irq); in skl_resume()
377 list_for_each_entry(hlink, &bus->hlink_list, list) { in skl_resume()
383 if (bus->cmd_dma_state) in skl_resume()
384 snd_hdac_bus_init_cmd_io(bus); in skl_resume()
386 ret = _skl_resume(bus); in skl_resume()
389 list_for_each_entry(hlink, &bus->hlink_list, list) { in skl_resume()
394 if (!bus->cmd_dma_state) in skl_resume()
395 snd_hdac_bus_stop_cmd_io(bus); in skl_resume()
406 struct hdac_bus *bus = pci_get_drvdata(pci); in skl_runtime_suspend() local
408 dev_dbg(bus->dev, "in %s\n", __func__); in skl_runtime_suspend()
410 return _skl_suspend(bus); in skl_runtime_suspend()
416 struct hdac_bus *bus = pci_get_drvdata(pci); in skl_runtime_resume() local
418 dev_dbg(bus->dev, "in %s\n", __func__); in skl_runtime_resume()
420 return _skl_resume(bus); in skl_runtime_resume()
433 static int skl_free(struct hdac_bus *bus) in skl_free() argument
435 struct skl_dev *skl = bus_to_skl(bus); in skl_free()
439 snd_hdac_ext_stop_streams(bus); in skl_free()
441 if (bus->irq >= 0) in skl_free()
442 free_irq(bus->irq, (void *)bus); in skl_free()
443 snd_hdac_bus_free_stream_pages(bus); in skl_free()
444 snd_hdac_stream_free_all(bus); in skl_free()
445 snd_hdac_link_free_all(bus); in skl_free()
447 if (bus->remap_addr) in skl_free()
448 iounmap(bus->remap_addr); in skl_free()
453 snd_hdac_ext_bus_exit(bus); in skl_free()
456 snd_hdac_display_power(bus, HDA_CODEC_IDX_CONTROLLER, false); in skl_free()
457 snd_hdac_i915_exit(bus); in skl_free()
483 struct hdac_bus *bus = skl_to_bus(skl); in skl_find_hda_machine() local
486 /* check if we have any codecs detected on bus */ in skl_find_hda_machine()
487 if (bus->codec_mask == 0) in skl_find_hda_machine()
501 struct hdac_bus *bus = skl_to_bus(skl); in skl_find_machine() local
507 dev_dbg(bus->dev, "No matching I2S machine driver found\n"); in skl_find_machine()
510 dev_err(bus->dev, "No matching machine driver found\n"); in skl_find_machine()
532 struct hdac_bus *bus = skl_to_bus(skl); in skl_machine_device_register() local
538 dev_err(bus->dev, "platform device alloc failed\n"); in skl_machine_device_register()
542 mach->mach_params.platform = dev_name(bus->dev); in skl_machine_device_register()
543 mach->mach_params.codec_mask = bus->codec_mask; in skl_machine_device_register()
547 dev_err(bus->dev, "failed to add machine device platform data\n"); in skl_machine_device_register()
554 dev_err(bus->dev, "failed to add machine device\n"); in skl_machine_device_register()
573 struct hdac_bus *bus = skl_to_bus(skl); in skl_dmic_device_register() local
580 dev_err(bus->dev, "failed to allocate dmic device\n"); in skl_dmic_device_register()
586 dev_err(bus->dev, "failed to add dmic device: %d\n", ret); in skl_dmic_device_register()
694 static int probe_codec(struct hdac_bus *bus, int addr) in probe_codec() argument
699 struct skl_dev *skl = bus_to_skl(bus); in probe_codec()
706 mutex_lock(&bus->cmd_mutex); in probe_codec()
707 snd_hdac_bus_send_cmd(bus, cmd); in probe_codec()
708 snd_hdac_bus_get_response(bus, addr, &res); in probe_codec()
709 mutex_unlock(&bus->cmd_mutex); in probe_codec()
712 dev_dbg(bus->dev, "codec #%d probed OK: %x\n", addr, res); in probe_codec()
720 hda_codec->codec.bus = skl_to_hbus(skl); in probe_codec()
723 err = snd_hdac_ext_bus_device_init(bus, addr, hdev); in probe_codec()
727 /* use legacy bus only for HDA codecs, idisp uses ext bus */ in probe_codec()
738 return snd_hdac_ext_bus_device_init(bus, addr, hdev); in probe_codec()
743 static void skl_codec_create(struct hdac_bus *bus) in skl_codec_create() argument
751 if ((bus->codec_mask & (1 << c))) { in skl_codec_create()
752 if (probe_codec(bus, c) < 0) { in skl_codec_create()
757 dev_warn(bus->dev, in skl_codec_create()
759 bus->codec_mask &= ~(1 << c); in skl_codec_create()
762 * codec often screws up the controller bus, in skl_codec_create()
765 * better to reset the controller bus to get in skl_codec_create()
768 snd_hdac_bus_stop_chip(bus); in skl_codec_create()
769 skl_init_chip(bus, true); in skl_codec_create()
780 static int skl_i915_init(struct hdac_bus *bus) in skl_i915_init() argument
788 err = snd_hdac_i915_init(bus); in skl_i915_init()
792 snd_hdac_display_power(bus, HDA_CODEC_IDX_CONTROLLER, true); in skl_i915_init()
800 struct hdac_bus *bus = skl_to_bus(skl); in skl_probe_work() local
805 err = skl_i915_init(bus); in skl_probe_work()
810 err = skl_init_chip(bus, true); in skl_probe_work()
812 dev_err(bus->dev, "Init chip failed with err: %d\n", err); in skl_probe_work()
817 if (!bus->codec_mask) in skl_probe_work()
818 dev_info(bus->dev, "no hda codecs found!\n"); in skl_probe_work()
821 skl_codec_create(bus); in skl_probe_work()
824 err = skl_platform_register(bus->dev); in skl_probe_work()
826 dev_err(bus->dev, "platform register failed: %d\n", err); in skl_probe_work()
832 dev_err(bus->dev, "machine register failed: %d\n", err); in skl_probe_work()
839 list_for_each_entry(hlink, &bus->hlink_list, list) in skl_probe_work()
840 snd_hdac_ext_bus_link_put(bus, hlink); in skl_probe_work()
843 snd_hdac_display_power(bus, HDA_CODEC_IDX_CONTROLLER, false); in skl_probe_work()
846 pm_runtime_put_noidle(bus->dev); in skl_probe_work()
847 pm_runtime_allow(bus->dev); in skl_probe_work()
854 snd_hdac_display_power(bus, HDA_CODEC_IDX_CONTROLLER, false); in skl_probe_work()
865 struct hdac_bus *bus; in skl_create() local
882 bus = skl_to_bus(skl); in skl_create()
890 snd_hdac_ext_bus_init(bus, &pci->dev, &bus_core_ops, ext_ops); in skl_create()
891 bus->use_posbuf = 1; in skl_create()
894 bus->bdl_pos_adj = 0; in skl_create()
906 static int skl_first_init(struct hdac_bus *bus) in skl_first_init() argument
908 struct skl_dev *skl = bus_to_skl(bus); in skl_first_init()
918 bus->addr = pci_resource_start(pci, 0); in skl_first_init()
919 bus->remap_addr = pci_ioremap_bar(pci, 0); in skl_first_init()
920 if (bus->remap_addr == NULL) { in skl_first_init()
921 dev_err(bus->dev, "ioremap error\n"); in skl_first_init()
925 snd_hdac_bus_reset_link(bus, true); in skl_first_init()
927 snd_hdac_bus_parse_capabilities(bus); in skl_first_init()
930 if (!bus->ppcap) { in skl_first_init()
931 dev_err(bus->dev, "bus ppcap not set, HDaudio or DSP not present?\n"); in skl_first_init()
935 if (skl_acquire_irq(bus, 0) < 0) in skl_first_init()
939 synchronize_irq(bus->irq); in skl_first_init()
941 gcap = snd_hdac_chip_readw(bus, GCAP); in skl_first_init()
942 dev_dbg(bus->dev, "chipset global capabilities = 0x%x\n", gcap); in skl_first_init()
949 dev_err(bus->dev, "no streams found in GCAP definitions?\n"); in skl_first_init()
953 bus->num_streams = cp_streams + pb_streams; in skl_first_init()
956 if (!dma_set_mask(bus->dev, DMA_BIT_MASK(64))) { in skl_first_init()
957 dma_set_coherent_mask(bus->dev, DMA_BIT_MASK(64)); in skl_first_init()
959 dma_set_mask(bus->dev, DMA_BIT_MASK(32)); in skl_first_init()
960 dma_set_coherent_mask(bus->dev, DMA_BIT_MASK(32)); in skl_first_init()
965 (bus, 0, cp_streams, SNDRV_PCM_STREAM_CAPTURE); in skl_first_init()
968 (bus, start_idx, pb_streams, SNDRV_PCM_STREAM_PLAYBACK); in skl_first_init()
970 err = snd_hdac_bus_alloc_stream_pages(bus); in skl_first_init()
976 skl_dum_set(bus); in skl_first_init()
978 return skl_init_chip(bus, true); in skl_first_init()
985 struct hdac_bus *bus = NULL; in skl_probe() local
1023 bus = skl_to_bus(skl); in skl_probe()
1025 err = skl_first_init(bus); in skl_probe()
1027 dev_err(bus->dev, "skl_first_init failed with err: %d\n", err); in skl_probe()
1033 device_disable_async_suspend(bus->dev); in skl_probe()
1035 skl->nhlt = intel_nhlt_init(bus->dev); in skl_probe()
1039 dev_err(bus->dev, "no nhlt info found\n"); in skl_probe()
1043 dev_warn(bus->dev, "no nhlt info found, continuing to try to enable HDaudio codec\n"); in skl_probe()
1049 dev_err(bus->dev, "skl_nhlt_create_sysfs failed with err: %d\n", err); in skl_probe()
1058 dev_err(bus->dev, "skl_clock_device_register failed with err: %d\n", err); in skl_probe()
1063 pci_set_drvdata(skl->pci, bus); in skl_probe()
1068 dev_err(bus->dev, "skl_find_machine failed with err: %d\n", err); in skl_probe()
1074 dev_dbg(bus->dev, "error failed to register dsp\n"); in skl_probe()
1080 if (bus->mlcap) in skl_probe()
1081 snd_hdac_ext_bus_get_ml_capabilities(bus); in skl_probe()
1083 snd_hdac_bus_stop_chip(bus); in skl_probe()
1088 dev_err(bus->dev, "skl_dmic_device_register failed with err: %d\n", err); in skl_probe()
1103 skl_free(bus); in skl_probe()
1110 struct hdac_bus *bus = pci_get_drvdata(pci); in skl_shutdown() local
1115 if (!bus) in skl_shutdown()
1118 skl = bus_to_skl(bus); in skl_shutdown()
1123 snd_hdac_ext_stop_streams(bus); in skl_shutdown()
1124 list_for_each_entry(s, &bus->stream_list, list) { in skl_shutdown()
1126 snd_hdac_ext_stream_decouple(bus, stream, false); in skl_shutdown()
1129 snd_hdac_bus_stop_chip(bus); in skl_shutdown()
1134 struct hdac_bus *bus = pci_get_drvdata(pci); in skl_remove() local
1135 struct skl_dev *skl = bus_to_skl(bus); in skl_remove()
1142 snd_hdac_ext_bus_device_remove(bus); in skl_remove()
1151 skl_free(bus); in skl_remove()