Lines Matching refs:sdev

37 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 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 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 int hda_dsp_core_run(struct snd_sof_dev *sdev, unsigned int core_mask) in hda_dsp_core_run() argument
133 ret = hda_dsp_core_reset_leave(sdev, core_mask); in hda_dsp_core_run()
138 dev_dbg(sdev->dev, "unstall/run core: core_mask = %x\n", core_mask); in hda_dsp_core_run()
139 snd_sof_dsp_update_bits_unlocked(sdev, HDA_DSP_BAR, in hda_dsp_core_run()
145 if (!hda_dsp_core_is_enabled(sdev, core_mask)) { in hda_dsp_core_run()
146 hda_dsp_core_stall_reset(sdev, core_mask); in hda_dsp_core_run()
147 dev_err(sdev->dev, "error: DSP start core failed: core_mask %x\n", in hda_dsp_core_run()
159 int hda_dsp_core_power_up(struct snd_sof_dev *sdev, unsigned int core_mask) in hda_dsp_core_power_up() argument
166 snd_sof_dsp_update_bits(sdev, HDA_DSP_BAR, HDA_DSP_REG_ADSPCS, in hda_dsp_core_power_up()
172 ret = snd_sof_dsp_read_poll_timeout(sdev, HDA_DSP_BAR, in hda_dsp_core_power_up()
178 dev_err(sdev->dev, in hda_dsp_core_power_up()
185 adspcs = snd_sof_dsp_read(sdev, HDA_DSP_BAR, in hda_dsp_core_power_up()
189 dev_err(sdev->dev, in hda_dsp_core_power_up()
198 int hda_dsp_core_power_down(struct snd_sof_dev *sdev, unsigned int core_mask) in hda_dsp_core_power_down() argument
204 snd_sof_dsp_update_bits_unlocked(sdev, HDA_DSP_BAR, in hda_dsp_core_power_down()
208 ret = snd_sof_dsp_read_poll_timeout(sdev, HDA_DSP_BAR, in hda_dsp_core_power_down()
214 dev_err(sdev->dev, in hda_dsp_core_power_down()
221 bool hda_dsp_core_is_enabled(struct snd_sof_dev *sdev, in hda_dsp_core_is_enabled() argument
227 val = snd_sof_dsp_read(sdev, HDA_DSP_BAR, HDA_DSP_REG_ADSPCS); in hda_dsp_core_is_enabled()
234 dev_dbg(sdev->dev, "DSP core(s) enabled? %d : core_mask %x\n", in hda_dsp_core_is_enabled()
240 int hda_dsp_enable_core(struct snd_sof_dev *sdev, unsigned int core_mask) in hda_dsp_enable_core() argument
242 struct sof_intel_hda_dev *hda = sdev->pdata->hw_pdata; in hda_dsp_enable_core()
250 if (!core_mask || hda_dsp_core_is_enabled(sdev, core_mask)) in hda_dsp_enable_core()
254 ret = hda_dsp_core_power_up(sdev, core_mask); in hda_dsp_enable_core()
256 dev_err(sdev->dev, "error: dsp core power up failed: core_mask %x\n", in hda_dsp_enable_core()
261 return hda_dsp_core_run(sdev, core_mask); in hda_dsp_enable_core()
264 int hda_dsp_core_reset_power_down(struct snd_sof_dev *sdev, in hda_dsp_core_reset_power_down() argument
267 struct sof_intel_hda_dev *hda = sdev->pdata->hw_pdata; in hda_dsp_core_reset_power_down()
279 ret = hda_dsp_core_stall_reset(sdev, core_mask); in hda_dsp_core_reset_power_down()
281 dev_err(sdev->dev, "error: dsp core reset failed: core_mask %x\n", in hda_dsp_core_reset_power_down()
287 ret = hda_dsp_core_power_down(sdev, core_mask); in hda_dsp_core_reset_power_down()
289 dev_err(sdev->dev, "error: dsp core power down fail mask %x: %d\n", in hda_dsp_core_reset_power_down()
295 if (hda_dsp_core_is_enabled(sdev, core_mask)) { in hda_dsp_core_reset_power_down()
296 dev_err(sdev->dev, "error: dsp core disable fail mask %x: %d\n", in hda_dsp_core_reset_power_down()
304 void hda_dsp_ipc_int_enable(struct snd_sof_dev *sdev) in hda_dsp_ipc_int_enable() argument
306 struct sof_intel_hda_dev *hda = sdev->pdata->hw_pdata; in hda_dsp_ipc_int_enable()
310 snd_sof_dsp_update_bits(sdev, HDA_DSP_BAR, chip->ipc_ctl, in hda_dsp_ipc_int_enable()
315 snd_sof_dsp_update_bits(sdev, HDA_DSP_BAR, HDA_DSP_REG_ADSPIC, in hda_dsp_ipc_int_enable()
319 void hda_dsp_ipc_int_disable(struct snd_sof_dev *sdev) in hda_dsp_ipc_int_disable() argument
321 struct sof_intel_hda_dev *hda = sdev->pdata->hw_pdata; in hda_dsp_ipc_int_disable()
325 snd_sof_dsp_update_bits(sdev, HDA_DSP_BAR, HDA_DSP_REG_ADSPIC, in hda_dsp_ipc_int_disable()
329 snd_sof_dsp_update_bits(sdev, HDA_DSP_BAR, chip->ipc_ctl, in hda_dsp_ipc_int_disable()
333 static int hda_dsp_wait_d0i3c_done(struct snd_sof_dev *sdev) in hda_dsp_wait_d0i3c_done() argument
335 struct hdac_bus *bus = sof_to_bus(sdev); in hda_dsp_wait_d0i3c_done()
347 static int hda_dsp_send_pm_gate_ipc(struct snd_sof_dev *sdev, u32 flags) in hda_dsp_send_pm_gate_ipc() argument
360 return sof_ipc_tx_message_no_pm(sdev->ipc, pm_gate.hdr.cmd, in hda_dsp_send_pm_gate_ipc()
365 static int hda_dsp_update_d0i3c_register(struct snd_sof_dev *sdev, u8 value) in hda_dsp_update_d0i3c_register() argument
367 struct hdac_bus *bus = sof_to_bus(sdev); in hda_dsp_update_d0i3c_register()
371 ret = hda_dsp_wait_d0i3c_done(sdev); in hda_dsp_update_d0i3c_register()
381 ret = hda_dsp_wait_d0i3c_done(sdev); in hda_dsp_update_d0i3c_register()
393 static int hda_dsp_set_D0_state(struct snd_sof_dev *sdev, in hda_dsp_set_D0_state() argument
407 switch (sdev->dsp_power_state.state) { in hda_dsp_set_D0_state()
415 dev_err(sdev->dev, "error: transition from %d to %d not allowed\n", in hda_dsp_set_D0_state()
416 sdev->dsp_power_state.state, target_state->state); in hda_dsp_set_D0_state()
430 if (!sdev->dtrace_is_supported || in hda_dsp_set_D0_state()
432 sdev->system_suspend_target != SOF_SUSPEND_NONE) in hda_dsp_set_D0_state()
440 ret = hda_dsp_update_d0i3c_register(sdev, value); in hda_dsp_set_D0_state()
449 ret = hda_dsp_send_pm_gate_ipc(sdev, flags); in hda_dsp_set_D0_state()
451 dev_err(sdev->dev, in hda_dsp_set_D0_state()
466 hda_dsp_update_d0i3c_register(sdev, value); in hda_dsp_set_D0_state()
472 static void hda_dsp_state_log(struct snd_sof_dev *sdev) in hda_dsp_state_log() argument
474 switch (sdev->dsp_power_state.state) { in hda_dsp_state_log()
476 switch (sdev->dsp_power_state.substate) { in hda_dsp_state_log()
478 dev_dbg(sdev->dev, "Current DSP power state: D0I0\n"); in hda_dsp_state_log()
481 dev_dbg(sdev->dev, "Current DSP power state: D0I3\n"); in hda_dsp_state_log()
484 dev_dbg(sdev->dev, "Unknown DSP D0 substate: %d\n", in hda_dsp_state_log()
485 sdev->dsp_power_state.substate); in hda_dsp_state_log()
490 dev_dbg(sdev->dev, "Current DSP power state: D1\n"); in hda_dsp_state_log()
493 dev_dbg(sdev->dev, "Current DSP power state: D2\n"); in hda_dsp_state_log()
496 dev_dbg(sdev->dev, "Current DSP power state: D3_HOT\n"); in hda_dsp_state_log()
499 dev_dbg(sdev->dev, "Current DSP power state: D3\n"); in hda_dsp_state_log()
502 dev_dbg(sdev->dev, "Current DSP power state: D3_COLD\n"); in hda_dsp_state_log()
505 dev_dbg(sdev->dev, "Unknown DSP power state: %d\n", in hda_dsp_state_log()
506 sdev->dsp_power_state.state); in hda_dsp_state_log()
518 int hda_dsp_set_power_state(struct snd_sof_dev *sdev, in hda_dsp_set_power_state() argument
531 sdev->system_suspend_target == SOF_SUSPEND_S0IX) in hda_dsp_set_power_state()
538 if (target_state->state == sdev->dsp_power_state.state && in hda_dsp_set_power_state()
539 target_state->substate == sdev->dsp_power_state.substate) in hda_dsp_set_power_state()
545 ret = hda_dsp_set_D0_state(sdev, target_state); in hda_dsp_set_power_state()
549 if (sdev->dsp_power_state.state == SOF_DSP_PM_D0 && in hda_dsp_set_power_state()
550 sdev->dsp_power_state.substate == SOF_HDA_DSP_PM_D0I0) in hda_dsp_set_power_state()
553 dev_err(sdev->dev, in hda_dsp_set_power_state()
555 sdev->dsp_power_state.state, target_state->state); in hda_dsp_set_power_state()
558 dev_err(sdev->dev, "error: target state unsupported %d\n", in hda_dsp_set_power_state()
563 dev_err(sdev->dev, in hda_dsp_set_power_state()
569 sdev->dsp_power_state = *target_state; in hda_dsp_set_power_state()
570 hda_dsp_state_log(sdev); in hda_dsp_set_power_state()
604 static int hda_suspend(struct snd_sof_dev *sdev, bool runtime_suspend) in hda_suspend() argument
606 struct sof_intel_hda_dev *hda = sdev->pdata->hw_pdata; in hda_suspend()
609 struct hdac_bus *bus = sof_to_bus(sdev); in hda_suspend()
613 hda_sdw_int_enable(sdev, false); in hda_suspend()
616 hda_dsp_ipc_int_disable(sdev); in hda_suspend()
620 hda_codec_jack_wake_enable(sdev); in hda_suspend()
627 ret = hda_dsp_core_reset_power_down(sdev, chip->host_managed_cores_mask); in hda_suspend()
629 dev_err(sdev->dev, in hda_suspend()
635 hda_dsp_ctrl_ppcap_enable(sdev, false); in hda_suspend()
636 hda_dsp_ctrl_ppcap_int_enable(sdev, false); in hda_suspend()
639 hda_dsp_ctrl_stop_chip(sdev); in hda_suspend()
642 snd_sof_pci_update_bits(sdev, PCI_PGCTL, in hda_suspend()
646 ret = hda_dsp_ctrl_link_reset(sdev, true); in hda_suspend()
648 dev_err(sdev->dev, in hda_suspend()
654 hda_codec_i915_display_power(sdev, false); in hda_suspend()
659 static int hda_resume(struct snd_sof_dev *sdev, bool runtime_resume) in hda_resume() argument
662 struct hdac_bus *bus = sof_to_bus(sdev); in hda_resume()
668 hda_codec_i915_display_power(sdev, true); in hda_resume()
674 snd_sof_pci_update_bits(sdev, PCI_TCSEL, 0x07, 0); in hda_resume()
677 ret = hda_dsp_ctrl_init_chip(sdev, true); in hda_resume()
679 dev_err(sdev->dev, in hda_resume()
687 hda_codec_jack_check(sdev); in hda_resume()
701 hda_dsp_ctrl_ppcap_enable(sdev, true); in hda_resume()
702 hda_dsp_ctrl_ppcap_int_enable(sdev, true); in hda_resume()
707 int hda_dsp_resume(struct snd_sof_dev *sdev) in hda_dsp_resume() argument
709 struct sof_intel_hda_dev *hda = sdev->pdata->hw_pdata; in hda_dsp_resume()
710 struct pci_dev *pci = to_pci_dev(sdev->dev); in hda_dsp_resume()
716 struct hdac_bus *bus = sof_to_bus(sdev); in hda_dsp_resume()
722 if (sdev->dsp_power_state.state == SOF_DSP_PM_D0) { in hda_dsp_resume()
723 hda_codec_i915_display_power(sdev, true); in hda_dsp_resume()
731 dev_dbg(sdev->dev, in hda_dsp_resume()
745 ret = snd_sof_dsp_set_power_state(sdev, &target_state); in hda_dsp_resume()
747 dev_err(sdev->dev, "error: setting dsp state %d substate %d\n", in hda_dsp_resume()
754 snd_sof_dsp_update_bits(sdev, HDA_DSP_HDA_BAR, in hda_dsp_resume()
765 ret = hda_resume(sdev, false); in hda_dsp_resume()
769 return snd_sof_dsp_set_power_state(sdev, &target_state); in hda_dsp_resume()
772 int hda_dsp_runtime_resume(struct snd_sof_dev *sdev) in hda_dsp_runtime_resume() argument
780 ret = hda_resume(sdev, true); in hda_dsp_runtime_resume()
784 return snd_sof_dsp_set_power_state(sdev, &target_state); in hda_dsp_runtime_resume()
787 int hda_dsp_runtime_idle(struct snd_sof_dev *sdev) in hda_dsp_runtime_idle() argument
789 struct hdac_bus *hbus = sof_to_bus(sdev); in hda_dsp_runtime_idle()
792 dev_dbg(sdev->dev, "some codecs still powered (%08X), not idle\n", in hda_dsp_runtime_idle()
800 int hda_dsp_runtime_suspend(struct snd_sof_dev *sdev) in hda_dsp_runtime_suspend() argument
808 ret = hda_suspend(sdev, true); in hda_dsp_runtime_suspend()
812 return snd_sof_dsp_set_power_state(sdev, &target_state); in hda_dsp_runtime_suspend()
815 int hda_dsp_suspend(struct snd_sof_dev *sdev, u32 target_state) in hda_dsp_suspend() argument
817 struct sof_intel_hda_dev *hda = sdev->pdata->hw_pdata; in hda_dsp_suspend()
818 struct hdac_bus *bus = sof_to_bus(sdev); in hda_dsp_suspend()
819 struct pci_dev *pci = to_pci_dev(sdev->dev); in hda_dsp_suspend()
832 hda_codec_i915_display_power(sdev, false); in hda_dsp_suspend()
835 ret = snd_sof_dsp_set_power_state(sdev, &target_dsp_state); in hda_dsp_suspend()
837 dev_err(sdev->dev, "error: setting dsp state %d substate %d\n", in hda_dsp_suspend()
845 snd_sof_dsp_update_bits(sdev, HDA_DSP_HDA_BAR, in hda_dsp_suspend()
858 dev_dbg(sdev->dev, in hda_dsp_suspend()
872 ret = hda_suspend(sdev, false); in hda_dsp_suspend()
878 return snd_sof_dsp_set_power_state(sdev, &target_dsp_state); in hda_dsp_suspend()
881 int hda_dsp_set_hw_params_upon_resume(struct snd_sof_dev *sdev) in hda_dsp_set_hw_params_upon_resume() argument
884 struct hdac_bus *bus = sof_to_bus(sdev); in hda_dsp_set_hw_params_upon_resume()
929 struct snd_sof_dev *sdev = dev_get_drvdata(bus->dev); in hda_dsp_d0i3_work() local
936 if (snd_sof_dsp_only_d0i3_compatible_stream_active(sdev)) in hda_dsp_d0i3_work()
946 ret = snd_sof_dsp_set_power_state(sdev, &target_state); in hda_dsp_d0i3_work()
948 dev_err_ratelimited(sdev->dev, in hda_dsp_d0i3_work()