Lines Matching refs:sdev

38 static int hda_dsp_core_reset_enter(struct snd_sof_dev *sdev, unsigned int core_mask)  in hda_dsp_core_reset_enter()  argument
46 snd_sof_dsp_update_bits_unlocked(sdev, HDA_DSP_BAR, in hda_dsp_core_reset_enter()
51 ret = snd_sof_dsp_read_poll_timeout(sdev, HDA_DSP_BAR, in hda_dsp_core_reset_enter()
57 dev_err(sdev->dev, in hda_dsp_core_reset_enter()
64 adspcs = snd_sof_dsp_read(sdev, HDA_DSP_BAR, in hda_dsp_core_reset_enter()
68 dev_err(sdev->dev, in hda_dsp_core_reset_enter()
77 static int hda_dsp_core_reset_leave(struct snd_sof_dev *sdev, unsigned int core_mask) in hda_dsp_core_reset_leave() argument
84 snd_sof_dsp_update_bits_unlocked(sdev, HDA_DSP_BAR, in hda_dsp_core_reset_leave()
91 ret = snd_sof_dsp_read_poll_timeout(sdev, HDA_DSP_BAR, in hda_dsp_core_reset_leave()
98 dev_err(sdev->dev, in hda_dsp_core_reset_leave()
105 adspcs = snd_sof_dsp_read(sdev, HDA_DSP_BAR, in hda_dsp_core_reset_leave()
108 dev_err(sdev->dev, in hda_dsp_core_reset_leave()
117 int hda_dsp_core_stall_reset(struct snd_sof_dev *sdev, unsigned int core_mask) in hda_dsp_core_stall_reset() argument
120 snd_sof_dsp_update_bits_unlocked(sdev, HDA_DSP_BAR, in hda_dsp_core_stall_reset()
126 return hda_dsp_core_reset_enter(sdev, core_mask); in hda_dsp_core_stall_reset()
129 bool hda_dsp_core_is_enabled(struct snd_sof_dev *sdev, unsigned int core_mask) in hda_dsp_core_is_enabled() argument
134 val = snd_sof_dsp_read(sdev, HDA_DSP_BAR, HDA_DSP_REG_ADSPCS); in hda_dsp_core_is_enabled()
148 dev_dbg(sdev->dev, "DSP core(s) enabled? %d : core_mask %x\n", in hda_dsp_core_is_enabled()
154 int hda_dsp_core_run(struct snd_sof_dev *sdev, unsigned int core_mask) in hda_dsp_core_run() argument
159 ret = hda_dsp_core_reset_leave(sdev, core_mask); in hda_dsp_core_run()
164 dev_dbg(sdev->dev, "unstall/run core: core_mask = %x\n", core_mask); in hda_dsp_core_run()
165 snd_sof_dsp_update_bits_unlocked(sdev, HDA_DSP_BAR, in hda_dsp_core_run()
171 if (!hda_dsp_core_is_enabled(sdev, core_mask)) { in hda_dsp_core_run()
172 hda_dsp_core_stall_reset(sdev, core_mask); in hda_dsp_core_run()
173 dev_err(sdev->dev, "error: DSP start core failed: core_mask %x\n", in hda_dsp_core_run()
185 int hda_dsp_core_power_up(struct snd_sof_dev *sdev, unsigned int core_mask) in hda_dsp_core_power_up() argument
187 struct sof_intel_hda_dev *hda = sdev->pdata->hw_pdata; in hda_dsp_core_power_up()
200 snd_sof_dsp_update_bits(sdev, HDA_DSP_BAR, HDA_DSP_REG_ADSPCS, in hda_dsp_core_power_up()
206 ret = snd_sof_dsp_read_poll_timeout(sdev, HDA_DSP_BAR, in hda_dsp_core_power_up()
212 dev_err(sdev->dev, in hda_dsp_core_power_up()
219 adspcs = snd_sof_dsp_read(sdev, HDA_DSP_BAR, in hda_dsp_core_power_up()
223 dev_err(sdev->dev, in hda_dsp_core_power_up()
232 static int hda_dsp_core_power_down(struct snd_sof_dev *sdev, unsigned int core_mask) in hda_dsp_core_power_down() argument
238 snd_sof_dsp_update_bits_unlocked(sdev, HDA_DSP_BAR, in hda_dsp_core_power_down()
242 ret = snd_sof_dsp_read_poll_timeout(sdev, HDA_DSP_BAR, in hda_dsp_core_power_down()
248 dev_err(sdev->dev, in hda_dsp_core_power_down()
255 int hda_dsp_enable_core(struct snd_sof_dev *sdev, unsigned int core_mask) in hda_dsp_enable_core() argument
257 struct sof_intel_hda_dev *hda = sdev->pdata->hw_pdata; in hda_dsp_enable_core()
265 if (!core_mask || hda_dsp_core_is_enabled(sdev, core_mask)) in hda_dsp_enable_core()
269 ret = hda_dsp_core_power_up(sdev, core_mask); in hda_dsp_enable_core()
271 dev_err(sdev->dev, "error: dsp core power up failed: core_mask %x\n", in hda_dsp_enable_core()
276 return hda_dsp_core_run(sdev, core_mask); in hda_dsp_enable_core()
279 int hda_dsp_core_reset_power_down(struct snd_sof_dev *sdev, in hda_dsp_core_reset_power_down() argument
282 struct sof_intel_hda_dev *hda = sdev->pdata->hw_pdata; in hda_dsp_core_reset_power_down()
294 ret = hda_dsp_core_stall_reset(sdev, core_mask); in hda_dsp_core_reset_power_down()
296 dev_err(sdev->dev, "error: dsp core reset failed: core_mask %x\n", in hda_dsp_core_reset_power_down()
302 ret = hda_dsp_core_power_down(sdev, core_mask); in hda_dsp_core_reset_power_down()
304 dev_err(sdev->dev, "error: dsp core power down fail mask %x: %d\n", in hda_dsp_core_reset_power_down()
310 if (hda_dsp_core_is_enabled(sdev, core_mask)) { in hda_dsp_core_reset_power_down()
311 dev_err(sdev->dev, "error: dsp core disable fail mask %x: %d\n", in hda_dsp_core_reset_power_down()
319 void hda_dsp_ipc_int_enable(struct snd_sof_dev *sdev) in hda_dsp_ipc_int_enable() argument
321 struct sof_intel_hda_dev *hda = sdev->pdata->hw_pdata; in hda_dsp_ipc_int_enable()
325 snd_sof_dsp_update_bits(sdev, HDA_DSP_BAR, chip->ipc_ctl, in hda_dsp_ipc_int_enable()
330 snd_sof_dsp_update_bits(sdev, HDA_DSP_BAR, HDA_DSP_REG_ADSPIC, in hda_dsp_ipc_int_enable()
334 void hda_dsp_ipc_int_disable(struct snd_sof_dev *sdev) in hda_dsp_ipc_int_disable() argument
336 struct sof_intel_hda_dev *hda = sdev->pdata->hw_pdata; in hda_dsp_ipc_int_disable()
340 snd_sof_dsp_update_bits(sdev, HDA_DSP_BAR, HDA_DSP_REG_ADSPIC, in hda_dsp_ipc_int_disable()
344 snd_sof_dsp_update_bits(sdev, HDA_DSP_BAR, chip->ipc_ctl, in hda_dsp_ipc_int_disable()
348 static int hda_dsp_wait_d0i3c_done(struct snd_sof_dev *sdev) in hda_dsp_wait_d0i3c_done() argument
351 struct snd_sof_pdata *pdata = sdev->pdata; in hda_dsp_wait_d0i3c_done()
355 while (snd_sof_dsp_read8(sdev, HDA_DSP_HDA_BAR, chip->d0i3_offset) & in hda_dsp_wait_d0i3c_done()
365 static int hda_dsp_send_pm_gate_ipc(struct snd_sof_dev *sdev, u32 flags) in hda_dsp_send_pm_gate_ipc() argument
367 const struct sof_ipc_pm_ops *pm_ops = sof_ipc_get_ops(sdev, pm); in hda_dsp_send_pm_gate_ipc()
370 return pm_ops->set_pm_gate(sdev, flags); in hda_dsp_send_pm_gate_ipc()
375 static int hda_dsp_update_d0i3c_register(struct snd_sof_dev *sdev, u8 value) in hda_dsp_update_d0i3c_register() argument
377 struct snd_sof_pdata *pdata = sdev->pdata; in hda_dsp_update_d0i3c_register()
385 ret = hda_dsp_wait_d0i3c_done(sdev); in hda_dsp_update_d0i3c_register()
387 dev_err(sdev->dev, "CIP timeout before D0I3C update!\n"); in hda_dsp_update_d0i3c_register()
392 snd_sof_dsp_update8(sdev, HDA_DSP_HDA_BAR, chip->d0i3_offset, in hda_dsp_update_d0i3c_register()
396 ret = hda_dsp_wait_d0i3c_done(sdev); in hda_dsp_update_d0i3c_register()
398 dev_err(sdev->dev, "CIP timeout after D0I3C update!\n"); in hda_dsp_update_d0i3c_register()
402 reg = snd_sof_dsp_read8(sdev, HDA_DSP_HDA_BAR, chip->d0i3_offset); in hda_dsp_update_d0i3c_register()
403 trace_sof_intel_D0I3C_updated(sdev, reg); in hda_dsp_update_d0i3c_register()
412 static bool hda_dsp_d0i3_streaming_applicable(struct snd_sof_dev *sdev) in hda_dsp_d0i3_streaming_applicable() argument
419 list_for_each_entry(spcm, &sdev->pcm_list, list) { in hda_dsp_d0i3_streaming_applicable()
436 static int hda_dsp_set_D0_state(struct snd_sof_dev *sdev, in hda_dsp_set_D0_state() argument
450 switch (sdev->dsp_power_state.state) { in hda_dsp_set_D0_state()
458 dev_err(sdev->dev, "error: transition from %d to %d not allowed\n", in hda_dsp_set_D0_state()
459 sdev->dsp_power_state.state, target_state->state); in hda_dsp_set_D0_state()
473 if (!sdev->fw_trace_is_supported || in hda_dsp_set_D0_state()
475 sdev->system_suspend_target != SOF_SUSPEND_NONE) in hda_dsp_set_D0_state()
478 if (hda_dsp_d0i3_streaming_applicable(sdev)) in hda_dsp_set_D0_state()
486 ret = hda_dsp_update_d0i3c_register(sdev, value); in hda_dsp_set_D0_state()
495 ret = hda_dsp_send_pm_gate_ipc(sdev, flags); in hda_dsp_set_D0_state()
497 dev_err(sdev->dev, in hda_dsp_set_D0_state()
512 hda_dsp_update_d0i3c_register(sdev, value); in hda_dsp_set_D0_state()
518 static void hda_dsp_state_log(struct snd_sof_dev *sdev) in hda_dsp_state_log() argument
520 switch (sdev->dsp_power_state.state) { in hda_dsp_state_log()
522 switch (sdev->dsp_power_state.substate) { in hda_dsp_state_log()
524 dev_dbg(sdev->dev, "Current DSP power state: D0I0\n"); in hda_dsp_state_log()
527 dev_dbg(sdev->dev, "Current DSP power state: D0I3\n"); in hda_dsp_state_log()
530 dev_dbg(sdev->dev, "Unknown DSP D0 substate: %d\n", in hda_dsp_state_log()
531 sdev->dsp_power_state.substate); in hda_dsp_state_log()
536 dev_dbg(sdev->dev, "Current DSP power state: D1\n"); in hda_dsp_state_log()
539 dev_dbg(sdev->dev, "Current DSP power state: D2\n"); in hda_dsp_state_log()
542 dev_dbg(sdev->dev, "Current DSP power state: D3\n"); in hda_dsp_state_log()
545 dev_dbg(sdev->dev, "Unknown DSP power state: %d\n", in hda_dsp_state_log()
546 sdev->dsp_power_state.state); in hda_dsp_state_log()
558 int hda_dsp_set_power_state(struct snd_sof_dev *sdev, in hda_dsp_set_power_state() argument
571 sdev->system_suspend_target == SOF_SUSPEND_S0IX) in hda_dsp_set_power_state()
578 if (target_state->state == sdev->dsp_power_state.state && in hda_dsp_set_power_state()
579 target_state->substate == sdev->dsp_power_state.substate) in hda_dsp_set_power_state()
585 ret = hda_dsp_set_D0_state(sdev, target_state); in hda_dsp_set_power_state()
589 if (sdev->dsp_power_state.state == SOF_DSP_PM_D0 && in hda_dsp_set_power_state()
590 sdev->dsp_power_state.substate == SOF_HDA_DSP_PM_D0I0) in hda_dsp_set_power_state()
593 dev_err(sdev->dev, in hda_dsp_set_power_state()
595 sdev->dsp_power_state.state, target_state->state); in hda_dsp_set_power_state()
598 dev_err(sdev->dev, "error: target state unsupported %d\n", in hda_dsp_set_power_state()
603 dev_err(sdev->dev, in hda_dsp_set_power_state()
609 sdev->dsp_power_state = *target_state; in hda_dsp_set_power_state()
610 hda_dsp_state_log(sdev); in hda_dsp_set_power_state()
644 static int hda_suspend(struct snd_sof_dev *sdev, bool runtime_suspend) in hda_suspend() argument
646 struct sof_intel_hda_dev *hda = sdev->pdata->hw_pdata; in hda_suspend()
648 struct hdac_bus *bus = sof_to_bus(sdev); in hda_suspend()
658 if (sdev->system_suspend_target > SOF_SUSPEND_S3 || in hda_suspend()
659 sdev->fw_state == SOF_FW_CRASHED || in hda_suspend()
660 sdev->fw_state == SOF_FW_BOOT_FAILED) in hda_suspend()
663 ret = chip->disable_interrupts(sdev); in hda_suspend()
667 hda_codec_jack_wake_enable(sdev, runtime_suspend); in hda_suspend()
672 ret = chip->power_down_dsp(sdev); in hda_suspend()
674 dev_err(sdev->dev, "failed to power down DSP during suspend\n"); in hda_suspend()
680 sdev->dsp_core_ref_count[j] = 0; in hda_suspend()
683 hda_dsp_ctrl_ppcap_enable(sdev, false); in hda_suspend()
684 hda_dsp_ctrl_ppcap_int_enable(sdev, false); in hda_suspend()
687 hda_dsp_ctrl_stop_chip(sdev); in hda_suspend()
690 snd_sof_pci_update_bits(sdev, PCI_PGCTL, in hda_suspend()
694 ret = hda_dsp_ctrl_link_reset(sdev, true); in hda_suspend()
696 dev_err(sdev->dev, in hda_suspend()
702 hda_codec_i915_display_power(sdev, false); in hda_suspend()
707 static int hda_resume(struct snd_sof_dev *sdev, bool runtime_resume) in hda_resume() argument
712 hda_codec_i915_display_power(sdev, true); in hda_resume()
718 snd_sof_pci_update_bits(sdev, PCI_TCSEL, 0x07, 0); in hda_resume()
721 ret = hda_dsp_ctrl_init_chip(sdev); in hda_resume()
723 dev_err(sdev->dev, in hda_resume()
730 hda_codec_jack_wake_enable(sdev, false); in hda_resume()
731 if (sdev->system_suspend_target == SOF_SUSPEND_NONE) in hda_resume()
732 hda_codec_jack_check(sdev); in hda_resume()
736 hda_dsp_ctrl_ppcap_enable(sdev, true); in hda_resume()
737 hda_dsp_ctrl_ppcap_int_enable(sdev, true); in hda_resume()
741 hda_codec_i915_display_power(sdev, false); in hda_resume()
746 int hda_dsp_resume(struct snd_sof_dev *sdev) in hda_dsp_resume() argument
748 struct sof_intel_hda_dev *hda = sdev->pdata->hw_pdata; in hda_dsp_resume()
749 struct hdac_bus *bus = sof_to_bus(sdev); in hda_dsp_resume()
750 struct pci_dev *pci = to_pci_dev(sdev->dev); in hda_dsp_resume()
758 if (sdev->dsp_power_state.state == SOF_DSP_PM_D0) { in hda_dsp_resume()
761 dev_err(sdev->dev, in hda_dsp_resume()
768 hda_codec_resume_cmd_io(sdev); in hda_dsp_resume()
771 ret = snd_sof_dsp_set_power_state(sdev, &target_state); in hda_dsp_resume()
773 dev_err(sdev->dev, "error: setting dsp state %d substate %d\n", in hda_dsp_resume()
780 snd_sof_dsp_update_bits(sdev, HDA_DSP_HDA_BAR, in hda_dsp_resume()
791 ret = hda_resume(sdev, false); in hda_dsp_resume()
795 return snd_sof_dsp_set_power_state(sdev, &target_state); in hda_dsp_resume()
798 int hda_dsp_runtime_resume(struct snd_sof_dev *sdev) in hda_dsp_runtime_resume() argument
806 ret = hda_resume(sdev, true); in hda_dsp_runtime_resume()
810 return snd_sof_dsp_set_power_state(sdev, &target_state); in hda_dsp_runtime_resume()
813 int hda_dsp_runtime_idle(struct snd_sof_dev *sdev) in hda_dsp_runtime_idle() argument
815 struct hdac_bus *hbus = sof_to_bus(sdev); in hda_dsp_runtime_idle()
818 dev_dbg(sdev->dev, "some codecs still powered (%08X), not idle\n", in hda_dsp_runtime_idle()
826 int hda_dsp_runtime_suspend(struct snd_sof_dev *sdev) in hda_dsp_runtime_suspend() argument
828 struct sof_intel_hda_dev *hda = sdev->pdata->hw_pdata; in hda_dsp_runtime_suspend()
838 ret = hda_suspend(sdev, true); in hda_dsp_runtime_suspend()
842 return snd_sof_dsp_set_power_state(sdev, &target_state); in hda_dsp_runtime_suspend()
845 int hda_dsp_suspend(struct snd_sof_dev *sdev, u32 target_state) in hda_dsp_suspend() argument
847 struct sof_intel_hda_dev *hda = sdev->pdata->hw_pdata; in hda_dsp_suspend()
848 struct hdac_bus *bus = sof_to_bus(sdev); in hda_dsp_suspend()
849 struct pci_dev *pci = to_pci_dev(sdev->dev); in hda_dsp_suspend()
862 ret = snd_sof_dsp_set_power_state(sdev, &target_dsp_state); in hda_dsp_suspend()
864 dev_err(sdev->dev, "error: setting dsp state %d substate %d\n", in hda_dsp_suspend()
872 snd_sof_dsp_update_bits(sdev, HDA_DSP_HDA_BAR, in hda_dsp_suspend()
878 hda_codec_suspend_cmd_io(sdev); in hda_dsp_suspend()
883 dev_err(sdev->dev, in hda_dsp_suspend()
896 ret = hda_suspend(sdev, false); in hda_dsp_suspend()
902 return snd_sof_dsp_set_power_state(sdev, &target_dsp_state); in hda_dsp_suspend()
905 static unsigned int hda_dsp_check_for_dma_streams(struct snd_sof_dev *sdev) in hda_dsp_check_for_dma_streams() argument
907 struct hdac_bus *bus = sof_to_bus(sdev); in hda_dsp_check_for_dma_streams()
915 val = snd_sof_dsp_read(sdev, HDA_DSP_HDA_BAR, in hda_dsp_check_for_dma_streams()
924 static int hda_dsp_s5_quirk(struct snd_sof_dev *sdev) in hda_dsp_s5_quirk() argument
940 ret = hda_dsp_ctrl_link_reset(sdev, false); in hda_dsp_s5_quirk()
947 ret = hda_dsp_ctrl_link_reset(sdev, true); in hda_dsp_s5_quirk()
954 int hda_dsp_shutdown_dma_flush(struct snd_sof_dev *sdev) in hda_dsp_shutdown_dma_flush() argument
960 active_streams = hda_dsp_check_for_dma_streams(sdev); in hda_dsp_shutdown_dma_flush()
962 sdev->system_suspend_target = SOF_SUSPEND_S3; in hda_dsp_shutdown_dma_flush()
963 ret = snd_sof_suspend(sdev->dev); in hda_dsp_shutdown_dma_flush()
966 dev_warn(sdev->dev, in hda_dsp_shutdown_dma_flush()
969 ret2 = hda_dsp_s5_quirk(sdev); in hda_dsp_shutdown_dma_flush()
971 dev_err(sdev->dev, "shutdown recovery failed (%d)\n", ret2); in hda_dsp_shutdown_dma_flush()
977 int hda_dsp_shutdown(struct snd_sof_dev *sdev) in hda_dsp_shutdown() argument
979 sdev->system_suspend_target = SOF_SUSPEND_S3; in hda_dsp_shutdown()
980 return snd_sof_suspend(sdev->dev); in hda_dsp_shutdown()
983 int hda_dsp_set_hw_params_upon_resume(struct snd_sof_dev *sdev) in hda_dsp_set_hw_params_upon_resume() argument
988 ret = hda_dsp_dais_suspend(sdev); in hda_dsp_set_hw_params_upon_resume()
990 dev_warn(sdev->dev, "%s: failure in hda_dsp_dais_suspend\n", __func__); in hda_dsp_set_hw_params_upon_resume()
1001 struct snd_sof_dev *sdev = dev_get_drvdata(bus->dev); in hda_dsp_d0i3_work() local
1009 if (!snd_sof_dsp_only_d0i3_compatible_stream_active(sdev)) in hda_dsp_d0i3_work()
1014 ret = snd_sof_dsp_set_power_state(sdev, &target_state); in hda_dsp_d0i3_work()
1016 dev_err_ratelimited(sdev->dev, in hda_dsp_d0i3_work()
1021 int hda_dsp_core_get(struct snd_sof_dev *sdev, int core) in hda_dsp_core_get() argument
1023 const struct sof_ipc_pm_ops *pm_ops = sdev->ipc->ops->pm; in hda_dsp_core_get()
1027 ret = hda_dsp_enable_core(sdev, BIT(core)); in hda_dsp_core_get()
1029 dev_err(sdev->dev, "failed to power up core %d with err: %d\n", in hda_dsp_core_get()
1035 if (sdev->fw_state != SOF_FW_BOOT_COMPLETE || core == SOF_DSP_PRIMARY_CORE) in hda_dsp_core_get()
1043 ret = pm_ops->set_core_state(sdev, core, true); in hda_dsp_core_get()
1045 dev_err(sdev->dev, "failed to enable secondary core '%d' failed with %d\n", in hda_dsp_core_get()
1054 ret1 = hda_dsp_core_reset_power_down(sdev, BIT(core)); in hda_dsp_core_get()
1056 dev_err(sdev->dev, "failed to power down core: %d with err: %d\n", core, ret1); in hda_dsp_core_get()
1061 int hda_dsp_disable_interrupts(struct snd_sof_dev *sdev) in hda_dsp_disable_interrupts() argument
1063 hda_sdw_int_enable(sdev, false); in hda_dsp_disable_interrupts()
1064 hda_dsp_ipc_int_disable(sdev); in hda_dsp_disable_interrupts()