Lines Matching refs:sdev

37 static int hda_dsp_core_reset_enter(struct snd_sof_dev *sdev, unsigned int core_mask)  in hda_dsp_core_reset_enter()  argument
45 snd_sof_dsp_update_bits_unlocked(sdev, HDA_DSP_BAR, in hda_dsp_core_reset_enter()
50 ret = snd_sof_dsp_read_poll_timeout(sdev, HDA_DSP_BAR, in hda_dsp_core_reset_enter()
56 dev_err(sdev->dev, in hda_dsp_core_reset_enter()
63 adspcs = snd_sof_dsp_read(sdev, HDA_DSP_BAR, in hda_dsp_core_reset_enter()
67 dev_err(sdev->dev, in hda_dsp_core_reset_enter()
76 static int hda_dsp_core_reset_leave(struct snd_sof_dev *sdev, unsigned int core_mask) in hda_dsp_core_reset_leave() argument
83 snd_sof_dsp_update_bits_unlocked(sdev, HDA_DSP_BAR, in hda_dsp_core_reset_leave()
90 ret = snd_sof_dsp_read_poll_timeout(sdev, HDA_DSP_BAR, in hda_dsp_core_reset_leave()
97 dev_err(sdev->dev, in hda_dsp_core_reset_leave()
104 adspcs = snd_sof_dsp_read(sdev, HDA_DSP_BAR, in hda_dsp_core_reset_leave()
107 dev_err(sdev->dev, in hda_dsp_core_reset_leave()
116 static int hda_dsp_core_stall_reset(struct snd_sof_dev *sdev, unsigned int core_mask) in hda_dsp_core_stall_reset() argument
119 snd_sof_dsp_update_bits_unlocked(sdev, HDA_DSP_BAR, in hda_dsp_core_stall_reset()
125 return hda_dsp_core_reset_enter(sdev, core_mask); in hda_dsp_core_stall_reset()
128 static bool hda_dsp_core_is_enabled(struct snd_sof_dev *sdev, unsigned int core_mask) in hda_dsp_core_is_enabled() argument
133 val = snd_sof_dsp_read(sdev, HDA_DSP_BAR, HDA_DSP_REG_ADSPCS); in hda_dsp_core_is_enabled()
147 dev_dbg(sdev->dev, "DSP core(s) enabled? %d : core_mask %x\n", in hda_dsp_core_is_enabled()
153 int hda_dsp_core_run(struct snd_sof_dev *sdev, unsigned int core_mask) in hda_dsp_core_run() argument
158 ret = hda_dsp_core_reset_leave(sdev, core_mask); in hda_dsp_core_run()
163 dev_dbg(sdev->dev, "unstall/run core: core_mask = %x\n", core_mask); in hda_dsp_core_run()
164 snd_sof_dsp_update_bits_unlocked(sdev, HDA_DSP_BAR, in hda_dsp_core_run()
170 if (!hda_dsp_core_is_enabled(sdev, core_mask)) { in hda_dsp_core_run()
171 hda_dsp_core_stall_reset(sdev, core_mask); in hda_dsp_core_run()
172 dev_err(sdev->dev, "error: DSP start core failed: core_mask %x\n", in hda_dsp_core_run()
184 static int hda_dsp_core_power_up(struct snd_sof_dev *sdev, unsigned int core_mask) in hda_dsp_core_power_up() argument
191 snd_sof_dsp_update_bits(sdev, HDA_DSP_BAR, HDA_DSP_REG_ADSPCS, in hda_dsp_core_power_up()
197 ret = snd_sof_dsp_read_poll_timeout(sdev, HDA_DSP_BAR, in hda_dsp_core_power_up()
203 dev_err(sdev->dev, in hda_dsp_core_power_up()
210 adspcs = snd_sof_dsp_read(sdev, HDA_DSP_BAR, in hda_dsp_core_power_up()
214 dev_err(sdev->dev, in hda_dsp_core_power_up()
223 static int hda_dsp_core_power_down(struct snd_sof_dev *sdev, unsigned int core_mask) in hda_dsp_core_power_down() argument
229 snd_sof_dsp_update_bits_unlocked(sdev, HDA_DSP_BAR, in hda_dsp_core_power_down()
233 ret = snd_sof_dsp_read_poll_timeout(sdev, HDA_DSP_BAR, in hda_dsp_core_power_down()
239 dev_err(sdev->dev, in hda_dsp_core_power_down()
246 int hda_dsp_enable_core(struct snd_sof_dev *sdev, unsigned int core_mask) in hda_dsp_enable_core() argument
248 struct sof_intel_hda_dev *hda = sdev->pdata->hw_pdata; in hda_dsp_enable_core()
256 if (!core_mask || hda_dsp_core_is_enabled(sdev, core_mask)) in hda_dsp_enable_core()
260 ret = hda_dsp_core_power_up(sdev, core_mask); in hda_dsp_enable_core()
262 dev_err(sdev->dev, "error: dsp core power up failed: core_mask %x\n", in hda_dsp_enable_core()
267 return hda_dsp_core_run(sdev, core_mask); in hda_dsp_enable_core()
270 int hda_dsp_core_reset_power_down(struct snd_sof_dev *sdev, in hda_dsp_core_reset_power_down() argument
273 struct sof_intel_hda_dev *hda = sdev->pdata->hw_pdata; in hda_dsp_core_reset_power_down()
285 ret = hda_dsp_core_stall_reset(sdev, core_mask); in hda_dsp_core_reset_power_down()
287 dev_err(sdev->dev, "error: dsp core reset failed: core_mask %x\n", in hda_dsp_core_reset_power_down()
293 ret = hda_dsp_core_power_down(sdev, core_mask); in hda_dsp_core_reset_power_down()
295 dev_err(sdev->dev, "error: dsp core power down fail mask %x: %d\n", in hda_dsp_core_reset_power_down()
301 if (hda_dsp_core_is_enabled(sdev, core_mask)) { in hda_dsp_core_reset_power_down()
302 dev_err(sdev->dev, "error: dsp core disable fail mask %x: %d\n", in hda_dsp_core_reset_power_down()
310 void hda_dsp_ipc_int_enable(struct snd_sof_dev *sdev) in hda_dsp_ipc_int_enable() argument
312 struct sof_intel_hda_dev *hda = sdev->pdata->hw_pdata; in hda_dsp_ipc_int_enable()
316 snd_sof_dsp_update_bits(sdev, HDA_DSP_BAR, chip->ipc_ctl, in hda_dsp_ipc_int_enable()
321 snd_sof_dsp_update_bits(sdev, HDA_DSP_BAR, HDA_DSP_REG_ADSPIC, in hda_dsp_ipc_int_enable()
325 void hda_dsp_ipc_int_disable(struct snd_sof_dev *sdev) in hda_dsp_ipc_int_disable() argument
327 struct sof_intel_hda_dev *hda = sdev->pdata->hw_pdata; in hda_dsp_ipc_int_disable()
331 snd_sof_dsp_update_bits(sdev, HDA_DSP_BAR, HDA_DSP_REG_ADSPIC, in hda_dsp_ipc_int_disable()
335 snd_sof_dsp_update_bits(sdev, HDA_DSP_BAR, chip->ipc_ctl, in hda_dsp_ipc_int_disable()
339 static int hda_dsp_wait_d0i3c_done(struct snd_sof_dev *sdev) in hda_dsp_wait_d0i3c_done() argument
341 struct hdac_bus *bus = sof_to_bus(sdev); in hda_dsp_wait_d0i3c_done()
353 static int hda_dsp_send_pm_gate_ipc(struct snd_sof_dev *sdev, u32 flags) in hda_dsp_send_pm_gate_ipc() argument
366 return sof_ipc_tx_message_no_pm(sdev->ipc, pm_gate.hdr.cmd, in hda_dsp_send_pm_gate_ipc()
371 static int hda_dsp_update_d0i3c_register(struct snd_sof_dev *sdev, u8 value) in hda_dsp_update_d0i3c_register() argument
373 struct hdac_bus *bus = sof_to_bus(sdev); in hda_dsp_update_d0i3c_register()
377 ret = hda_dsp_wait_d0i3c_done(sdev); in hda_dsp_update_d0i3c_register()
387 ret = hda_dsp_wait_d0i3c_done(sdev); in hda_dsp_update_d0i3c_register()
399 static int hda_dsp_set_D0_state(struct snd_sof_dev *sdev, in hda_dsp_set_D0_state() argument
413 switch (sdev->dsp_power_state.state) { in hda_dsp_set_D0_state()
421 dev_err(sdev->dev, "error: transition from %d to %d not allowed\n", in hda_dsp_set_D0_state()
422 sdev->dsp_power_state.state, target_state->state); in hda_dsp_set_D0_state()
436 if (!sdev->dtrace_is_supported || in hda_dsp_set_D0_state()
438 sdev->system_suspend_target != SOF_SUSPEND_NONE) in hda_dsp_set_D0_state()
446 ret = hda_dsp_update_d0i3c_register(sdev, value); in hda_dsp_set_D0_state()
455 ret = hda_dsp_send_pm_gate_ipc(sdev, flags); in hda_dsp_set_D0_state()
457 dev_err(sdev->dev, in hda_dsp_set_D0_state()
472 hda_dsp_update_d0i3c_register(sdev, value); in hda_dsp_set_D0_state()
478 static void hda_dsp_state_log(struct snd_sof_dev *sdev) in hda_dsp_state_log() argument
480 switch (sdev->dsp_power_state.state) { in hda_dsp_state_log()
482 switch (sdev->dsp_power_state.substate) { in hda_dsp_state_log()
484 dev_dbg(sdev->dev, "Current DSP power state: D0I0\n"); in hda_dsp_state_log()
487 dev_dbg(sdev->dev, "Current DSP power state: D0I3\n"); in hda_dsp_state_log()
490 dev_dbg(sdev->dev, "Unknown DSP D0 substate: %d\n", in hda_dsp_state_log()
491 sdev->dsp_power_state.substate); in hda_dsp_state_log()
496 dev_dbg(sdev->dev, "Current DSP power state: D1\n"); in hda_dsp_state_log()
499 dev_dbg(sdev->dev, "Current DSP power state: D2\n"); in hda_dsp_state_log()
502 dev_dbg(sdev->dev, "Current DSP power state: D3_HOT\n"); in hda_dsp_state_log()
505 dev_dbg(sdev->dev, "Current DSP power state: D3\n"); in hda_dsp_state_log()
508 dev_dbg(sdev->dev, "Current DSP power state: D3_COLD\n"); in hda_dsp_state_log()
511 dev_dbg(sdev->dev, "Unknown DSP power state: %d\n", in hda_dsp_state_log()
512 sdev->dsp_power_state.state); in hda_dsp_state_log()
524 int hda_dsp_set_power_state(struct snd_sof_dev *sdev, in hda_dsp_set_power_state() argument
537 sdev->system_suspend_target == SOF_SUSPEND_S0IX) in hda_dsp_set_power_state()
544 if (target_state->state == sdev->dsp_power_state.state && in hda_dsp_set_power_state()
545 target_state->substate == sdev->dsp_power_state.substate) in hda_dsp_set_power_state()
551 ret = hda_dsp_set_D0_state(sdev, target_state); in hda_dsp_set_power_state()
555 if (sdev->dsp_power_state.state == SOF_DSP_PM_D0 && in hda_dsp_set_power_state()
556 sdev->dsp_power_state.substate == SOF_HDA_DSP_PM_D0I0) in hda_dsp_set_power_state()
559 dev_err(sdev->dev, in hda_dsp_set_power_state()
561 sdev->dsp_power_state.state, target_state->state); in hda_dsp_set_power_state()
564 dev_err(sdev->dev, "error: target state unsupported %d\n", in hda_dsp_set_power_state()
569 dev_err(sdev->dev, in hda_dsp_set_power_state()
575 sdev->dsp_power_state = *target_state; in hda_dsp_set_power_state()
576 hda_dsp_state_log(sdev); in hda_dsp_set_power_state()
610 static int hda_suspend(struct snd_sof_dev *sdev, bool runtime_suspend) in hda_suspend() argument
612 struct sof_intel_hda_dev *hda = sdev->pdata->hw_pdata; in hda_suspend()
615 struct hdac_bus *bus = sof_to_bus(sdev); in hda_suspend()
619 hda_sdw_int_enable(sdev, false); in hda_suspend()
622 hda_dsp_ipc_int_disable(sdev); in hda_suspend()
625 hda_codec_jack_wake_enable(sdev, runtime_suspend); in hda_suspend()
632 ret = snd_sof_dsp_core_power_down(sdev, chip->host_managed_cores_mask); in hda_suspend()
634 dev_err(sdev->dev, in hda_suspend()
640 hda_dsp_ctrl_ppcap_enable(sdev, false); in hda_suspend()
641 hda_dsp_ctrl_ppcap_int_enable(sdev, false); in hda_suspend()
644 hda_dsp_ctrl_stop_chip(sdev); in hda_suspend()
647 snd_sof_pci_update_bits(sdev, PCI_PGCTL, in hda_suspend()
651 ret = hda_dsp_ctrl_link_reset(sdev, true); in hda_suspend()
653 dev_err(sdev->dev, in hda_suspend()
659 hda_codec_i915_display_power(sdev, false); in hda_suspend()
664 static int hda_resume(struct snd_sof_dev *sdev, bool runtime_resume) in hda_resume() argument
667 struct hdac_bus *bus = sof_to_bus(sdev); in hda_resume()
673 hda_codec_i915_display_power(sdev, true); in hda_resume()
679 snd_sof_pci_update_bits(sdev, PCI_TCSEL, 0x07, 0); in hda_resume()
682 ret = hda_dsp_ctrl_init_chip(sdev, true); in hda_resume()
684 dev_err(sdev->dev, in hda_resume()
692 hda_codec_jack_wake_enable(sdev, false); in hda_resume()
693 if (sdev->system_suspend_target == SOF_SUSPEND_NONE) in hda_resume()
694 hda_codec_jack_check(sdev); in hda_resume()
709 hda_dsp_ctrl_ppcap_enable(sdev, true); in hda_resume()
710 hda_dsp_ctrl_ppcap_int_enable(sdev, true); in hda_resume()
714 hda_codec_i915_display_power(sdev, false); in hda_resume()
719 int hda_dsp_resume(struct snd_sof_dev *sdev) in hda_dsp_resume() argument
721 struct sof_intel_hda_dev *hda = sdev->pdata->hw_pdata; in hda_dsp_resume()
722 struct pci_dev *pci = to_pci_dev(sdev->dev); in hda_dsp_resume()
728 struct hdac_bus *bus = sof_to_bus(sdev); in hda_dsp_resume()
734 if (sdev->dsp_power_state.state == SOF_DSP_PM_D0) { in hda_dsp_resume()
741 dev_dbg(sdev->dev, in hda_dsp_resume()
755 ret = snd_sof_dsp_set_power_state(sdev, &target_state); in hda_dsp_resume()
757 dev_err(sdev->dev, "error: setting dsp state %d substate %d\n", in hda_dsp_resume()
764 snd_sof_dsp_update_bits(sdev, HDA_DSP_HDA_BAR, in hda_dsp_resume()
775 ret = hda_resume(sdev, false); in hda_dsp_resume()
779 return snd_sof_dsp_set_power_state(sdev, &target_state); in hda_dsp_resume()
782 int hda_dsp_runtime_resume(struct snd_sof_dev *sdev) in hda_dsp_runtime_resume() argument
790 ret = hda_resume(sdev, true); in hda_dsp_runtime_resume()
794 return snd_sof_dsp_set_power_state(sdev, &target_state); in hda_dsp_runtime_resume()
797 int hda_dsp_runtime_idle(struct snd_sof_dev *sdev) in hda_dsp_runtime_idle() argument
799 struct hdac_bus *hbus = sof_to_bus(sdev); in hda_dsp_runtime_idle()
802 dev_dbg(sdev->dev, "some codecs still powered (%08X), not idle\n", in hda_dsp_runtime_idle()
810 int hda_dsp_runtime_suspend(struct snd_sof_dev *sdev) in hda_dsp_runtime_suspend() argument
812 struct sof_intel_hda_dev *hda = sdev->pdata->hw_pdata; in hda_dsp_runtime_suspend()
822 ret = hda_suspend(sdev, true); in hda_dsp_runtime_suspend()
826 return snd_sof_dsp_set_power_state(sdev, &target_state); in hda_dsp_runtime_suspend()
829 int hda_dsp_suspend(struct snd_sof_dev *sdev, u32 target_state) in hda_dsp_suspend() argument
831 struct sof_intel_hda_dev *hda = sdev->pdata->hw_pdata; in hda_dsp_suspend()
832 struct hdac_bus *bus = sof_to_bus(sdev); in hda_dsp_suspend()
833 struct pci_dev *pci = to_pci_dev(sdev->dev); in hda_dsp_suspend()
846 ret = snd_sof_dsp_set_power_state(sdev, &target_dsp_state); in hda_dsp_suspend()
848 dev_err(sdev->dev, "error: setting dsp state %d substate %d\n", in hda_dsp_suspend()
856 snd_sof_dsp_update_bits(sdev, HDA_DSP_HDA_BAR, in hda_dsp_suspend()
869 dev_dbg(sdev->dev, in hda_dsp_suspend()
883 ret = hda_suspend(sdev, false); in hda_dsp_suspend()
889 return snd_sof_dsp_set_power_state(sdev, &target_dsp_state); in hda_dsp_suspend()
892 int hda_dsp_shutdown(struct snd_sof_dev *sdev) in hda_dsp_shutdown() argument
894 sdev->system_suspend_target = SOF_SUSPEND_S3; in hda_dsp_shutdown()
895 return snd_sof_suspend(sdev->dev); in hda_dsp_shutdown()
898 int hda_dsp_set_hw_params_upon_resume(struct snd_sof_dev *sdev) in hda_dsp_set_hw_params_upon_resume() argument
901 struct hdac_bus *bus = sof_to_bus(sdev); in hda_dsp_set_hw_params_upon_resume()
946 struct snd_sof_dev *sdev = dev_get_drvdata(bus->dev); in hda_dsp_d0i3_work() local
954 if (!snd_sof_dsp_only_d0i3_compatible_stream_active(sdev)) in hda_dsp_d0i3_work()
959 ret = snd_sof_dsp_set_power_state(sdev, &target_state); in hda_dsp_d0i3_work()
961 dev_err_ratelimited(sdev->dev, in hda_dsp_d0i3_work()