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
350 struct hdac_bus *bus = sof_to_bus(sdev); in hda_dsp_wait_d0i3c_done()
362 static int hda_dsp_send_pm_gate_ipc(struct snd_sof_dev *sdev, u32 flags) in hda_dsp_send_pm_gate_ipc() argument
375 return sof_ipc_tx_message_no_pm(sdev->ipc, &pm_gate, sizeof(pm_gate), in hda_dsp_send_pm_gate_ipc()
379 static int hda_dsp_update_d0i3c_register(struct snd_sof_dev *sdev, u8 value) in hda_dsp_update_d0i3c_register() argument
381 struct hdac_bus *bus = sof_to_bus(sdev); in hda_dsp_update_d0i3c_register()
385 ret = hda_dsp_wait_d0i3c_done(sdev); in hda_dsp_update_d0i3c_register()
395 ret = hda_dsp_wait_d0i3c_done(sdev); in hda_dsp_update_d0i3c_register()
401 trace_sof_intel_D0I3C_updated(sdev, snd_hdac_chip_readb(bus, VS_D0I3C)); in hda_dsp_update_d0i3c_register()
406 static int hda_dsp_set_D0_state(struct snd_sof_dev *sdev, in hda_dsp_set_D0_state() argument
420 switch (sdev->dsp_power_state.state) { in hda_dsp_set_D0_state()
428 dev_err(sdev->dev, "error: transition from %d to %d not allowed\n", in hda_dsp_set_D0_state()
429 sdev->dsp_power_state.state, target_state->state); in hda_dsp_set_D0_state()
443 if (!sdev->fw_trace_is_supported || in hda_dsp_set_D0_state()
445 sdev->system_suspend_target != SOF_SUSPEND_NONE) in hda_dsp_set_D0_state()
453 ret = hda_dsp_update_d0i3c_register(sdev, value); in hda_dsp_set_D0_state()
462 ret = hda_dsp_send_pm_gate_ipc(sdev, flags); in hda_dsp_set_D0_state()
464 dev_err(sdev->dev, in hda_dsp_set_D0_state()
479 hda_dsp_update_d0i3c_register(sdev, value); in hda_dsp_set_D0_state()
485 static void hda_dsp_state_log(struct snd_sof_dev *sdev) in hda_dsp_state_log() argument
487 switch (sdev->dsp_power_state.state) { in hda_dsp_state_log()
489 switch (sdev->dsp_power_state.substate) { in hda_dsp_state_log()
491 dev_dbg(sdev->dev, "Current DSP power state: D0I0\n"); in hda_dsp_state_log()
494 dev_dbg(sdev->dev, "Current DSP power state: D0I3\n"); in hda_dsp_state_log()
497 dev_dbg(sdev->dev, "Unknown DSP D0 substate: %d\n", in hda_dsp_state_log()
498 sdev->dsp_power_state.substate); in hda_dsp_state_log()
503 dev_dbg(sdev->dev, "Current DSP power state: D1\n"); in hda_dsp_state_log()
506 dev_dbg(sdev->dev, "Current DSP power state: D2\n"); in hda_dsp_state_log()
509 dev_dbg(sdev->dev, "Current DSP power state: D3\n"); in hda_dsp_state_log()
512 dev_dbg(sdev->dev, "Unknown DSP power state: %d\n", in hda_dsp_state_log()
513 sdev->dsp_power_state.state); in hda_dsp_state_log()
525 int hda_dsp_set_power_state(struct snd_sof_dev *sdev, in hda_dsp_set_power_state() argument
538 sdev->system_suspend_target == SOF_SUSPEND_S0IX) in hda_dsp_set_power_state()
545 if (target_state->state == sdev->dsp_power_state.state && in hda_dsp_set_power_state()
546 target_state->substate == sdev->dsp_power_state.substate) in hda_dsp_set_power_state()
552 ret = hda_dsp_set_D0_state(sdev, target_state); in hda_dsp_set_power_state()
556 if (sdev->dsp_power_state.state == SOF_DSP_PM_D0 && in hda_dsp_set_power_state()
557 sdev->dsp_power_state.substate == SOF_HDA_DSP_PM_D0I0) in hda_dsp_set_power_state()
560 dev_err(sdev->dev, in hda_dsp_set_power_state()
562 sdev->dsp_power_state.state, target_state->state); in hda_dsp_set_power_state()
565 dev_err(sdev->dev, "error: target state unsupported %d\n", in hda_dsp_set_power_state()
570 dev_err(sdev->dev, in hda_dsp_set_power_state()
576 sdev->dsp_power_state = *target_state; in hda_dsp_set_power_state()
577 hda_dsp_state_log(sdev); in hda_dsp_set_power_state()
611 static int hda_suspend(struct snd_sof_dev *sdev, bool runtime_suspend) in hda_suspend() argument
613 struct sof_intel_hda_dev *hda = sdev->pdata->hw_pdata; in hda_suspend()
616 struct hdac_bus *bus = sof_to_bus(sdev); in hda_suspend()
627 if (sdev->system_suspend_target > SOF_SUSPEND_S3 || in hda_suspend()
628 sdev->fw_state == SOF_FW_CRASHED || in hda_suspend()
629 sdev->fw_state == SOF_FW_BOOT_FAILED) in hda_suspend()
632 ret = chip->disable_interrupts(sdev); in hda_suspend()
637 hda_codec_jack_wake_enable(sdev, runtime_suspend); in hda_suspend()
643 ret = chip->power_down_dsp(sdev); in hda_suspend()
645 dev_err(sdev->dev, "failed to power down DSP during suspend\n"); in hda_suspend()
651 sdev->dsp_core_ref_count[j] = 0; in hda_suspend()
654 hda_dsp_ctrl_ppcap_enable(sdev, false); in hda_suspend()
655 hda_dsp_ctrl_ppcap_int_enable(sdev, false); in hda_suspend()
658 hda_dsp_ctrl_stop_chip(sdev); in hda_suspend()
661 snd_sof_pci_update_bits(sdev, PCI_PGCTL, in hda_suspend()
665 ret = hda_dsp_ctrl_link_reset(sdev, true); in hda_suspend()
667 dev_err(sdev->dev, in hda_suspend()
673 hda_codec_i915_display_power(sdev, false); in hda_suspend()
678 static int hda_resume(struct snd_sof_dev *sdev, bool runtime_resume) in hda_resume() argument
681 struct hdac_bus *bus = sof_to_bus(sdev); in hda_resume()
687 hda_codec_i915_display_power(sdev, true); in hda_resume()
693 snd_sof_pci_update_bits(sdev, PCI_TCSEL, 0x07, 0); in hda_resume()
696 ret = hda_dsp_ctrl_init_chip(sdev, true); in hda_resume()
698 dev_err(sdev->dev, in hda_resume()
706 hda_codec_jack_wake_enable(sdev, false); in hda_resume()
707 if (sdev->system_suspend_target == SOF_SUSPEND_NONE) in hda_resume()
708 hda_codec_jack_check(sdev); in hda_resume()
723 hda_dsp_ctrl_ppcap_enable(sdev, true); in hda_resume()
724 hda_dsp_ctrl_ppcap_int_enable(sdev, true); in hda_resume()
728 hda_codec_i915_display_power(sdev, false); in hda_resume()
733 int hda_dsp_resume(struct snd_sof_dev *sdev) in hda_dsp_resume() argument
735 struct sof_intel_hda_dev *hda = sdev->pdata->hw_pdata; in hda_dsp_resume()
736 struct pci_dev *pci = to_pci_dev(sdev->dev); in hda_dsp_resume()
742 struct hdac_bus *bus = sof_to_bus(sdev); in hda_dsp_resume()
748 if (sdev->dsp_power_state.state == SOF_DSP_PM_D0) { in hda_dsp_resume()
755 dev_err(sdev->dev, in hda_dsp_resume()
769 ret = snd_sof_dsp_set_power_state(sdev, &target_state); in hda_dsp_resume()
771 dev_err(sdev->dev, "error: setting dsp state %d substate %d\n", in hda_dsp_resume()
778 snd_sof_dsp_update_bits(sdev, HDA_DSP_HDA_BAR, in hda_dsp_resume()
789 ret = hda_resume(sdev, false); in hda_dsp_resume()
793 return snd_sof_dsp_set_power_state(sdev, &target_state); in hda_dsp_resume()
796 int hda_dsp_runtime_resume(struct snd_sof_dev *sdev) in hda_dsp_runtime_resume() argument
804 ret = hda_resume(sdev, true); in hda_dsp_runtime_resume()
808 return snd_sof_dsp_set_power_state(sdev, &target_state); in hda_dsp_runtime_resume()
811 int hda_dsp_runtime_idle(struct snd_sof_dev *sdev) in hda_dsp_runtime_idle() argument
813 struct hdac_bus *hbus = sof_to_bus(sdev); in hda_dsp_runtime_idle()
816 dev_dbg(sdev->dev, "some codecs still powered (%08X), not idle\n", in hda_dsp_runtime_idle()
824 int hda_dsp_runtime_suspend(struct snd_sof_dev *sdev) in hda_dsp_runtime_suspend() argument
826 struct sof_intel_hda_dev *hda = sdev->pdata->hw_pdata; in hda_dsp_runtime_suspend()
836 ret = hda_suspend(sdev, true); in hda_dsp_runtime_suspend()
840 return snd_sof_dsp_set_power_state(sdev, &target_state); in hda_dsp_runtime_suspend()
843 int hda_dsp_suspend(struct snd_sof_dev *sdev, u32 target_state) in hda_dsp_suspend() argument
845 struct sof_intel_hda_dev *hda = sdev->pdata->hw_pdata; in hda_dsp_suspend()
846 struct hdac_bus *bus = sof_to_bus(sdev); in hda_dsp_suspend()
847 struct pci_dev *pci = to_pci_dev(sdev->dev); in hda_dsp_suspend()
860 ret = snd_sof_dsp_set_power_state(sdev, &target_dsp_state); in hda_dsp_suspend()
862 dev_err(sdev->dev, "error: setting dsp state %d substate %d\n", in hda_dsp_suspend()
870 snd_sof_dsp_update_bits(sdev, HDA_DSP_HDA_BAR, in hda_dsp_suspend()
883 dev_err(sdev->dev, in hda_dsp_suspend()
897 ret = hda_suspend(sdev, false); in hda_dsp_suspend()
903 return snd_sof_dsp_set_power_state(sdev, &target_dsp_state); in hda_dsp_suspend()
906 int hda_dsp_shutdown(struct snd_sof_dev *sdev) in hda_dsp_shutdown() argument
908 sdev->system_suspend_target = SOF_SUSPEND_S3; in hda_dsp_shutdown()
909 return snd_sof_suspend(sdev->dev); in hda_dsp_shutdown()
912 int hda_dsp_set_hw_params_upon_resume(struct snd_sof_dev *sdev) in hda_dsp_set_hw_params_upon_resume() argument
917 ret = hda_dsp_dais_suspend(sdev); in hda_dsp_set_hw_params_upon_resume()
919 dev_warn(sdev->dev, "%s: failure in hda_dsp_dais_suspend\n", __func__); in hda_dsp_set_hw_params_upon_resume()
930 struct snd_sof_dev *sdev = dev_get_drvdata(bus->dev); in hda_dsp_d0i3_work() local
938 if (!snd_sof_dsp_only_d0i3_compatible_stream_active(sdev)) in hda_dsp_d0i3_work()
943 ret = snd_sof_dsp_set_power_state(sdev, &target_state); in hda_dsp_d0i3_work()
945 dev_err_ratelimited(sdev->dev, in hda_dsp_d0i3_work()
950 int hda_dsp_core_get(struct snd_sof_dev *sdev, int core) in hda_dsp_core_get() argument
952 const struct sof_ipc_pm_ops *pm_ops = sdev->ipc->ops->pm; in hda_dsp_core_get()
956 ret = hda_dsp_enable_core(sdev, BIT(core)); in hda_dsp_core_get()
958 dev_err(sdev->dev, "failed to power up core %d with err: %d\n", in hda_dsp_core_get()
964 if (sdev->fw_state != SOF_FW_BOOT_COMPLETE || core == SOF_DSP_PRIMARY_CORE) in hda_dsp_core_get()
972 ret = pm_ops->set_core_state(sdev, core, true); in hda_dsp_core_get()
974 dev_err(sdev->dev, "failed to enable secondary core '%d' failed with %d\n", in hda_dsp_core_get()
983 ret1 = hda_dsp_core_reset_power_down(sdev, BIT(core)); in hda_dsp_core_get()
985 dev_err(sdev->dev, "failed to power down core: %d with err: %d\n", core, ret1); in hda_dsp_core_get()
990 int hda_dsp_disable_interrupts(struct snd_sof_dev *sdev) in hda_dsp_disable_interrupts() argument
992 hda_sdw_int_enable(sdev, false); in hda_dsp_disable_interrupts()
993 hda_dsp_ipc_int_disable(sdev); in hda_dsp_disable_interrupts()