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()
241 dev_dbg(sdev->dev, "DSP core(s) enabled? %d : core_mask %x\n", in hda_dsp_core_is_enabled()
247 int hda_dsp_enable_core(struct snd_sof_dev *sdev, unsigned int core_mask) in hda_dsp_enable_core() argument
249 struct sof_intel_hda_dev *hda = sdev->pdata->hw_pdata; in hda_dsp_enable_core()
257 if (!core_mask || hda_dsp_core_is_enabled(sdev, core_mask)) in hda_dsp_enable_core()
261 ret = hda_dsp_core_power_up(sdev, core_mask); in hda_dsp_enable_core()
263 dev_err(sdev->dev, "error: dsp core power up failed: core_mask %x\n", in hda_dsp_enable_core()
268 return hda_dsp_core_run(sdev, core_mask); in hda_dsp_enable_core()
271 int hda_dsp_core_reset_power_down(struct snd_sof_dev *sdev, in hda_dsp_core_reset_power_down() argument
274 struct sof_intel_hda_dev *hda = sdev->pdata->hw_pdata; in hda_dsp_core_reset_power_down()
286 ret = hda_dsp_core_stall_reset(sdev, core_mask); in hda_dsp_core_reset_power_down()
288 dev_err(sdev->dev, "error: dsp core reset failed: core_mask %x\n", in hda_dsp_core_reset_power_down()
294 ret = hda_dsp_core_power_down(sdev, core_mask); in hda_dsp_core_reset_power_down()
296 dev_err(sdev->dev, "error: dsp core power down fail mask %x: %d\n", in hda_dsp_core_reset_power_down()
302 if (hda_dsp_core_is_enabled(sdev, core_mask)) { in hda_dsp_core_reset_power_down()
303 dev_err(sdev->dev, "error: dsp core disable fail mask %x: %d\n", in hda_dsp_core_reset_power_down()
311 void hda_dsp_ipc_int_enable(struct snd_sof_dev *sdev) in hda_dsp_ipc_int_enable() argument
313 struct sof_intel_hda_dev *hda = sdev->pdata->hw_pdata; in hda_dsp_ipc_int_enable()
317 snd_sof_dsp_update_bits(sdev, HDA_DSP_BAR, chip->ipc_ctl, in hda_dsp_ipc_int_enable()
322 snd_sof_dsp_update_bits(sdev, HDA_DSP_BAR, HDA_DSP_REG_ADSPIC, in hda_dsp_ipc_int_enable()
326 void hda_dsp_ipc_int_disable(struct snd_sof_dev *sdev) in hda_dsp_ipc_int_disable() argument
328 struct sof_intel_hda_dev *hda = sdev->pdata->hw_pdata; in hda_dsp_ipc_int_disable()
332 snd_sof_dsp_update_bits(sdev, HDA_DSP_BAR, HDA_DSP_REG_ADSPIC, in hda_dsp_ipc_int_disable()
336 snd_sof_dsp_update_bits(sdev, HDA_DSP_BAR, chip->ipc_ctl, in hda_dsp_ipc_int_disable()
340 static int hda_dsp_wait_d0i3c_done(struct snd_sof_dev *sdev) in hda_dsp_wait_d0i3c_done() argument
342 struct hdac_bus *bus = sof_to_bus(sdev); in hda_dsp_wait_d0i3c_done()
354 static int hda_dsp_send_pm_gate_ipc(struct snd_sof_dev *sdev, u32 flags) in hda_dsp_send_pm_gate_ipc() argument
367 return sof_ipc_tx_message_no_pm(sdev->ipc, pm_gate.hdr.cmd, in hda_dsp_send_pm_gate_ipc()
372 static int hda_dsp_update_d0i3c_register(struct snd_sof_dev *sdev, u8 value) in hda_dsp_update_d0i3c_register() argument
374 struct hdac_bus *bus = sof_to_bus(sdev); in hda_dsp_update_d0i3c_register()
378 ret = hda_dsp_wait_d0i3c_done(sdev); in hda_dsp_update_d0i3c_register()
388 ret = hda_dsp_wait_d0i3c_done(sdev); in hda_dsp_update_d0i3c_register()
400 static int hda_dsp_set_D0_state(struct snd_sof_dev *sdev, in hda_dsp_set_D0_state() argument
414 switch (sdev->dsp_power_state.state) { in hda_dsp_set_D0_state()
422 dev_err(sdev->dev, "error: transition from %d to %d not allowed\n", in hda_dsp_set_D0_state()
423 sdev->dsp_power_state.state, target_state->state); in hda_dsp_set_D0_state()
437 if (!sdev->dtrace_is_supported || in hda_dsp_set_D0_state()
439 sdev->system_suspend_target != SOF_SUSPEND_NONE) in hda_dsp_set_D0_state()
447 ret = hda_dsp_update_d0i3c_register(sdev, value); in hda_dsp_set_D0_state()
456 ret = hda_dsp_send_pm_gate_ipc(sdev, flags); in hda_dsp_set_D0_state()
458 dev_err(sdev->dev, in hda_dsp_set_D0_state()
473 hda_dsp_update_d0i3c_register(sdev, value); in hda_dsp_set_D0_state()
479 static void hda_dsp_state_log(struct snd_sof_dev *sdev) in hda_dsp_state_log() argument
481 switch (sdev->dsp_power_state.state) { in hda_dsp_state_log()
483 switch (sdev->dsp_power_state.substate) { in hda_dsp_state_log()
485 dev_dbg(sdev->dev, "Current DSP power state: D0I0\n"); in hda_dsp_state_log()
488 dev_dbg(sdev->dev, "Current DSP power state: D0I3\n"); in hda_dsp_state_log()
491 dev_dbg(sdev->dev, "Unknown DSP D0 substate: %d\n", in hda_dsp_state_log()
492 sdev->dsp_power_state.substate); in hda_dsp_state_log()
497 dev_dbg(sdev->dev, "Current DSP power state: D1\n"); in hda_dsp_state_log()
500 dev_dbg(sdev->dev, "Current DSP power state: D2\n"); in hda_dsp_state_log()
503 dev_dbg(sdev->dev, "Current DSP power state: D3_HOT\n"); in hda_dsp_state_log()
506 dev_dbg(sdev->dev, "Current DSP power state: D3\n"); in hda_dsp_state_log()
509 dev_dbg(sdev->dev, "Current DSP power state: D3_COLD\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()
620 hda_sdw_int_enable(sdev, false); in hda_suspend()
623 hda_dsp_ipc_int_disable(sdev); in hda_suspend()
627 hda_codec_jack_wake_enable(sdev); in hda_suspend()
634 ret = hda_dsp_core_reset_power_down(sdev, chip->host_managed_cores_mask); in hda_suspend()
636 dev_err(sdev->dev, in hda_suspend()
642 hda_dsp_ctrl_ppcap_enable(sdev, false); in hda_suspend()
643 hda_dsp_ctrl_ppcap_int_enable(sdev, false); in hda_suspend()
646 hda_dsp_ctrl_stop_chip(sdev); in hda_suspend()
649 snd_sof_pci_update_bits(sdev, PCI_PGCTL, in hda_suspend()
653 ret = hda_dsp_ctrl_link_reset(sdev, true); in hda_suspend()
655 dev_err(sdev->dev, in hda_suspend()
661 hda_codec_i915_display_power(sdev, false); in hda_suspend()
666 static int hda_resume(struct snd_sof_dev *sdev, bool runtime_resume) in hda_resume() argument
669 struct hdac_bus *bus = sof_to_bus(sdev); in hda_resume()
675 hda_codec_i915_display_power(sdev, true); in hda_resume()
681 snd_sof_pci_update_bits(sdev, PCI_TCSEL, 0x07, 0); in hda_resume()
684 ret = hda_dsp_ctrl_init_chip(sdev, true); in hda_resume()
686 dev_err(sdev->dev, in hda_resume()
694 if (sdev->system_suspend_target == SOF_SUSPEND_NONE) in hda_resume()
695 hda_codec_jack_check(sdev); in hda_resume()
710 hda_dsp_ctrl_ppcap_enable(sdev, true); in hda_resume()
711 hda_dsp_ctrl_ppcap_int_enable(sdev, true); in hda_resume()
716 int hda_dsp_resume(struct snd_sof_dev *sdev) in hda_dsp_resume() argument
718 struct sof_intel_hda_dev *hda = sdev->pdata->hw_pdata; in hda_dsp_resume()
719 struct pci_dev *pci = to_pci_dev(sdev->dev); in hda_dsp_resume()
725 struct hdac_bus *bus = sof_to_bus(sdev); in hda_dsp_resume()
731 if (sdev->dsp_power_state.state == SOF_DSP_PM_D0) { in hda_dsp_resume()
732 hda_codec_i915_display_power(sdev, true); in hda_dsp_resume()
740 dev_dbg(sdev->dev, in hda_dsp_resume()
754 ret = snd_sof_dsp_set_power_state(sdev, &target_state); in hda_dsp_resume()
756 dev_err(sdev->dev, "error: setting dsp state %d substate %d\n", in hda_dsp_resume()
763 snd_sof_dsp_update_bits(sdev, HDA_DSP_HDA_BAR, in hda_dsp_resume()
774 ret = hda_resume(sdev, false); in hda_dsp_resume()
778 return snd_sof_dsp_set_power_state(sdev, &target_state); in hda_dsp_resume()
781 int hda_dsp_runtime_resume(struct snd_sof_dev *sdev) in hda_dsp_runtime_resume() argument
789 ret = hda_resume(sdev, true); in hda_dsp_runtime_resume()
793 return snd_sof_dsp_set_power_state(sdev, &target_state); in hda_dsp_runtime_resume()
796 int hda_dsp_runtime_idle(struct snd_sof_dev *sdev) in hda_dsp_runtime_idle() argument
798 struct hdac_bus *hbus = sof_to_bus(sdev); in hda_dsp_runtime_idle()
801 dev_dbg(sdev->dev, "some codecs still powered (%08X), not idle\n", in hda_dsp_runtime_idle()
809 int hda_dsp_runtime_suspend(struct snd_sof_dev *sdev) in hda_dsp_runtime_suspend() argument
811 struct sof_intel_hda_dev *hda = sdev->pdata->hw_pdata; in hda_dsp_runtime_suspend()
821 ret = hda_suspend(sdev, true); in hda_dsp_runtime_suspend()
825 return snd_sof_dsp_set_power_state(sdev, &target_state); in hda_dsp_runtime_suspend()
828 int hda_dsp_suspend(struct snd_sof_dev *sdev, u32 target_state) in hda_dsp_suspend() argument
830 struct sof_intel_hda_dev *hda = sdev->pdata->hw_pdata; in hda_dsp_suspend()
831 struct hdac_bus *bus = sof_to_bus(sdev); in hda_dsp_suspend()
832 struct pci_dev *pci = to_pci_dev(sdev->dev); in hda_dsp_suspend()
845 hda_codec_i915_display_power(sdev, false); in hda_dsp_suspend()
848 ret = snd_sof_dsp_set_power_state(sdev, &target_dsp_state); in hda_dsp_suspend()
850 dev_err(sdev->dev, "error: setting dsp state %d substate %d\n", in hda_dsp_suspend()
858 snd_sof_dsp_update_bits(sdev, HDA_DSP_HDA_BAR, in hda_dsp_suspend()
871 dev_dbg(sdev->dev, in hda_dsp_suspend()
885 ret = hda_suspend(sdev, false); in hda_dsp_suspend()
891 return snd_sof_dsp_set_power_state(sdev, &target_dsp_state); in hda_dsp_suspend()
894 int hda_dsp_set_hw_params_upon_resume(struct snd_sof_dev *sdev) in hda_dsp_set_hw_params_upon_resume() argument
897 struct hdac_bus *bus = sof_to_bus(sdev); in hda_dsp_set_hw_params_upon_resume()
942 struct snd_sof_dev *sdev = dev_get_drvdata(bus->dev); in hda_dsp_d0i3_work() local
949 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()