Lines Matching +full:primary +full:- +full:dai +full:- +full:link

1 // SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause)
21 #include <sound/hda-mlink.h>
23 #include "../sof-audio.h"
26 #include "hda-ipc.h"
58 dev_err(sdev->dev, in hda_dsp_core_reset_enter()
69 dev_err(sdev->dev, in hda_dsp_core_reset_enter()
72 ret = -EIO; in hda_dsp_core_reset_enter()
99 dev_err(sdev->dev, in hda_dsp_core_reset_leave()
109 dev_err(sdev->dev, in hda_dsp_core_reset_leave()
112 ret = -EIO; in hda_dsp_core_reset_leave()
149 dev_dbg(sdev->dev, "DSP core(s) enabled? %d : core_mask %x\n", in hda_dsp_core_is_enabled()
165 dev_dbg(sdev->dev, "unstall/run core: core_mask = %x\n", core_mask); in hda_dsp_core_run()
174 dev_err(sdev->dev, "error: DSP start core failed: core_mask %x\n", in hda_dsp_core_run()
176 ret = -EIO; in hda_dsp_core_run()
188 struct sof_intel_hda_dev *hda = sdev->pdata->hw_pdata; in hda_dsp_core_power_up()
189 const struct sof_intel_dsp_desc *chip = hda->desc; in hda_dsp_core_power_up()
195 core_mask &= chip->host_managed_cores_mask; in hda_dsp_core_power_up()
213 dev_err(sdev->dev, in hda_dsp_core_power_up()
224 dev_err(sdev->dev, in hda_dsp_core_power_up()
227 ret = -EIO; in hda_dsp_core_power_up()
249 dev_err(sdev->dev, in hda_dsp_core_power_down()
258 struct sof_intel_hda_dev *hda = sdev->pdata->hw_pdata; in hda_dsp_enable_core()
259 const struct sof_intel_dsp_desc *chip = hda->desc; in hda_dsp_enable_core()
263 core_mask &= chip->host_managed_cores_mask; in hda_dsp_enable_core()
272 dev_err(sdev->dev, "error: dsp core power up failed: core_mask %x\n", in hda_dsp_enable_core()
283 struct sof_intel_hda_dev *hda = sdev->pdata->hw_pdata; in hda_dsp_core_reset_power_down()
284 const struct sof_intel_dsp_desc *chip = hda->desc; in hda_dsp_core_reset_power_down()
288 core_mask &= chip->host_managed_cores_mask; in hda_dsp_core_reset_power_down()
297 dev_err(sdev->dev, "error: dsp core reset failed: core_mask %x\n", in hda_dsp_core_reset_power_down()
305 dev_err(sdev->dev, "error: dsp core power down fail mask %x: %d\n", in hda_dsp_core_reset_power_down()
312 dev_err(sdev->dev, "error: dsp core disable fail mask %x: %d\n", in hda_dsp_core_reset_power_down()
314 ret = -EIO; in hda_dsp_core_reset_power_down()
322 struct sof_intel_hda_dev *hda = sdev->pdata->hw_pdata; in hda_dsp_ipc_int_enable()
323 const struct sof_intel_dsp_desc *chip = hda->desc; in hda_dsp_ipc_int_enable()
325 if (sdev->dspless_mode_selected) in hda_dsp_ipc_int_enable()
329 snd_sof_dsp_update_bits(sdev, HDA_DSP_BAR, chip->ipc_ctl, in hda_dsp_ipc_int_enable()
340 struct sof_intel_hda_dev *hda = sdev->pdata->hw_pdata; in hda_dsp_ipc_int_disable()
341 const struct sof_intel_dsp_desc *chip = hda->desc; in hda_dsp_ipc_int_disable()
343 if (sdev->dspless_mode_selected) in hda_dsp_ipc_int_disable()
351 snd_sof_dsp_update_bits(sdev, HDA_DSP_BAR, chip->ipc_ctl, in hda_dsp_ipc_int_disable()
358 struct snd_sof_pdata *pdata = sdev->pdata; in hda_dsp_wait_d0i3c_done()
362 while (snd_sof_dsp_read8(sdev, HDA_DSP_HDA_BAR, chip->d0i3_offset) & in hda_dsp_wait_d0i3c_done()
364 if (!retry--) in hda_dsp_wait_d0i3c_done()
365 return -ETIMEDOUT; in hda_dsp_wait_d0i3c_done()
376 if (pm_ops && pm_ops->set_pm_gate) in hda_dsp_send_pm_gate_ipc()
377 return pm_ops->set_pm_gate(sdev, flags); in hda_dsp_send_pm_gate_ipc()
384 struct snd_sof_pdata *pdata = sdev->pdata; in hda_dsp_update_d0i3c_register()
391 /* Write to D0I3C after Command-In-Progress bit is cleared */ in hda_dsp_update_d0i3c_register()
394 dev_err(sdev->dev, "CIP timeout before D0I3C update!\n"); in hda_dsp_update_d0i3c_register()
399 snd_sof_dsp_update8(sdev, HDA_DSP_HDA_BAR, chip->d0i3_offset, in hda_dsp_update_d0i3c_register()
411 dev_err(sdev->dev, "CIP timeout after D0I3C update!\n"); in hda_dsp_update_d0i3c_register()
415 reg = snd_sof_dsp_read8(sdev, HDA_DSP_HDA_BAR, chip->d0i3_offset); in hda_dsp_update_d0i3c_register()
418 dev_err(sdev->dev, "failed to update D0I3C!\n"); in hda_dsp_update_d0i3c_register()
419 return -EIO; in hda_dsp_update_d0i3c_register()
438 list_for_each_entry(spcm, &sdev->pcm_list, list) { in hda_dsp_d0i3_streaming_applicable()
440 substream = spcm->stream[dir].substream; in hda_dsp_d0i3_streaming_applicable()
441 if (!substream || !substream->runtime) in hda_dsp_d0i3_streaming_applicable()
444 if (!spcm->stream[dir].d0i3_compatible) in hda_dsp_d0i3_streaming_applicable()
465 * 1. D3 -> D0I0 in hda_dsp_set_D0_state()
466 * 2. D0I0 -> D0I3 in hda_dsp_set_D0_state()
467 * 3. D0I3 -> D0I0 in hda_dsp_set_D0_state()
469 switch (sdev->dsp_power_state.state) { in hda_dsp_set_D0_state()
474 /* Follow regular flow for D3 -> D0 transition */ in hda_dsp_set_D0_state()
477 dev_err(sdev->dev, "error: transition from %d to %d not allowed\n", in hda_dsp_set_D0_state()
478 sdev->dsp_power_state.state, target_state->state); in hda_dsp_set_D0_state()
479 return -EINVAL; in hda_dsp_set_D0_state()
483 if (target_state->substate == SOF_HDA_DSP_PM_D0I3) { in hda_dsp_set_D0_state()
492 if (!sdev->fw_trace_is_supported || in hda_dsp_set_D0_state()
494 sdev->system_suspend_target != SOF_SUSPEND_NONE) in hda_dsp_set_D0_state()
516 dev_err(sdev->dev, in hda_dsp_set_D0_state()
539 switch (sdev->dsp_power_state.state) { in hda_dsp_state_log()
541 switch (sdev->dsp_power_state.substate) { in hda_dsp_state_log()
543 dev_dbg(sdev->dev, "Current DSP power state: D0I0\n"); in hda_dsp_state_log()
546 dev_dbg(sdev->dev, "Current DSP power state: D0I3\n"); in hda_dsp_state_log()
549 dev_dbg(sdev->dev, "Unknown DSP D0 substate: %d\n", in hda_dsp_state_log()
550 sdev->dsp_power_state.substate); in hda_dsp_state_log()
555 dev_dbg(sdev->dev, "Current DSP power state: D1\n"); in hda_dsp_state_log()
558 dev_dbg(sdev->dev, "Current DSP power state: D2\n"); in hda_dsp_state_log()
561 dev_dbg(sdev->dev, "Current DSP power state: D3\n"); in hda_dsp_state_log()
564 dev_dbg(sdev->dev, "Unknown DSP power state: %d\n", in hda_dsp_state_log()
565 sdev->dsp_power_state.state); in hda_dsp_state_log()
582 switch (target_state->state) { in hda_dsp_set_power_state()
587 /* The only allowed transition is: D0I0 -> D3 */ in hda_dsp_set_power_state()
588 if (sdev->dsp_power_state.state == SOF_DSP_PM_D0 && in hda_dsp_set_power_state()
589 sdev->dsp_power_state.substate == SOF_HDA_DSP_PM_D0I0) in hda_dsp_set_power_state()
592 dev_err(sdev->dev, in hda_dsp_set_power_state()
594 sdev->dsp_power_state.state, target_state->state); in hda_dsp_set_power_state()
595 return -EINVAL; in hda_dsp_set_power_state()
597 dev_err(sdev->dev, "error: target state unsupported %d\n", in hda_dsp_set_power_state()
598 target_state->state); in hda_dsp_set_power_state()
599 return -EINVAL; in hda_dsp_set_power_state()
602 dev_err(sdev->dev, in hda_dsp_set_power_state()
604 target_state->state, target_state->substate); in hda_dsp_set_power_state()
608 sdev->dsp_power_state = *target_state; in hda_dsp_set_power_state()
623 if (target_state->substate == SOF_HDA_DSP_PM_D0I3 && in hda_dsp_set_power_state_ipc3()
624 sdev->system_suspend_target == SOF_SUSPEND_S0IX) in hda_dsp_set_power_state_ipc3()
631 if (target_state->state == sdev->dsp_power_state.state && in hda_dsp_set_power_state_ipc3()
632 target_state->substate == sdev->dsp_power_state.substate) in hda_dsp_set_power_state_ipc3()
642 if (target_state->state == sdev->dsp_power_state.state && in hda_dsp_set_power_state_ipc4()
643 target_state->substate == sdev->dsp_power_state.substate) in hda_dsp_set_power_state_ipc4()
650 * Audio DSP states may transform as below:-
653 * Runtime +---------------------+ Delayed D0i3 work timeout
654 * suspend | +--------------------+
655 * +------------+ D0I0(active) | |
656 * | | <---------------+ |
657 * | +--------> | New IPC | |
658 * | |Runtime +--^--+---------^--+--+ (via mailbox) | |
667 * +-v---+-----------+--v-------+ | | +------+----v----+
668 * | | | +-----------> |
670 * | | +--------------+ |
672 * +----------------------------+ +----------------+
674 * S0IX suspend: The DSP is in D0I3 if any D0I3-compatible streams
681 struct sof_intel_hda_dev *hda = sdev->pdata->hw_pdata; in hda_suspend()
682 const struct sof_intel_dsp_desc *chip = hda->desc; in hda_suspend()
695 if (sdev->system_suspend_target > SOF_SUSPEND_S3 || in hda_suspend()
696 (chip->hw_ip_version >= SOF_INTEL_ACE_1_0 && in hda_suspend()
697 sdev->system_suspend_target == SOF_SUSPEND_S3)) in hda_suspend()
702 * as well in order to try to re-load the firmware to do a 'cold' boot. in hda_suspend()
704 if (imr_lost || sdev->fw_state == SOF_FW_CRASHED || in hda_suspend()
705 sdev->fw_state == SOF_FW_BOOT_FAILED) in hda_suspend()
706 hda->skip_imr_boot = true; in hda_suspend()
708 ret = chip->disable_interrupts(sdev); in hda_suspend()
713 synchronize_irq(sdev->ipc_irq); in hda_suspend()
720 if (sdev->dspless_mode_selected) in hda_suspend()
723 ret = chip->power_down_dsp(sdev); in hda_suspend()
725 dev_err(sdev->dev, "failed to power down DSP during suspend\n"); in hda_suspend()
730 for (j = 0; j < chip->cores_num; j++) in hda_suspend()
731 sdev->dsp_core_ref_count[j] = 0; in hda_suspend()
748 dev_err(sdev->dev, in hda_suspend()
753 /* display codec can powered off after link reset */ in hda_suspend()
763 /* display codec must be powered before link reset */ in hda_resume()
775 dev_err(sdev->dev, in hda_resume()
783 if (sdev->system_suspend_target == SOF_SUSPEND_NONE) in hda_resume()
787 if (!sdev->dspless_mode_selected) { in hda_resume()
802 struct sof_intel_hda_dev *hda = sdev->pdata->hw_pdata; in hda_dsp_resume()
804 struct pci_dev *pci = to_pci_dev(sdev->dev); in hda_dsp_resume()
812 if (sdev->dsp_power_state.state == SOF_DSP_PM_D0) { in hda_dsp_resume()
815 dev_err(sdev->dev, in hda_dsp_resume()
827 dev_err(sdev->dev, "error: setting dsp state %d substate %d\n", in hda_dsp_resume()
833 if (hda->l1_disabled) in hda_dsp_resume()
840 disable_irq_wake(pci->irq); in hda_dsp_resume()
871 if (hbus->codec_powered) { in hda_dsp_runtime_idle()
872 dev_dbg(sdev->dev, "some codecs still powered (%08X), not idle\n", in hda_dsp_runtime_idle()
873 (unsigned int)hbus->codec_powered); in hda_dsp_runtime_idle()
874 return -EBUSY; in hda_dsp_runtime_idle()
882 struct sof_intel_hda_dev *hda = sdev->pdata->hw_pdata; in hda_dsp_runtime_suspend()
888 if (!sdev->dspless_mode_selected) { in hda_dsp_runtime_suspend()
890 cancel_delayed_work_sync(&hda->d0i3_work); in hda_dsp_runtime_suspend()
903 struct sof_intel_hda_dev *hda = sdev->pdata->hw_pdata; in hda_dsp_suspend()
905 struct pci_dev *pci = to_pci_dev(sdev->dev); in hda_dsp_suspend()
913 if (!sdev->dspless_mode_selected) { in hda_dsp_suspend()
915 cancel_delayed_work_sync(&hda->d0i3_work); in hda_dsp_suspend()
922 dev_err(sdev->dev, "error: setting dsp state %d substate %d\n", in hda_dsp_suspend()
929 if (hda->l1_disabled) in hda_dsp_suspend()
936 /* no link can be powered in s0ix state */ in hda_dsp_suspend()
939 dev_err(sdev->dev, in hda_dsp_suspend()
946 enable_irq_wake(pci->irq); in hda_dsp_suspend()
954 dev_err(bus->dev, "error: suspending dsp\n"); in hda_dsp_suspend()
969 list_for_each_entry(s, &bus->stream_list, list) { in hda_dsp_check_for_dma_streams()
974 active_streams |= BIT(s->index); in hda_dsp_check_for_dma_streams()
1018 sdev->system_suspend_target = SOF_SUSPEND_S3; in hda_dsp_shutdown_dma_flush()
1019 ret = snd_sof_suspend(sdev->dev); in hda_dsp_shutdown_dma_flush()
1022 dev_warn(sdev->dev, in hda_dsp_shutdown_dma_flush()
1027 dev_err(sdev->dev, "shutdown recovery failed (%d)\n", ret2); in hda_dsp_shutdown_dma_flush()
1035 sdev->system_suspend_target = SOF_SUSPEND_S3; in hda_dsp_shutdown()
1036 return snd_sof_suspend(sdev->dev); in hda_dsp_shutdown()
1043 /* make sure all DAI resources are freed */ in hda_dsp_set_hw_params_upon_resume()
1046 dev_warn(sdev->dev, "%s: failure in hda_dsp_dais_suspend\n", __func__); in hda_dsp_set_hw_params_upon_resume()
1056 struct hdac_bus *bus = &hdev->hbus.core; in hda_dsp_d0i3_work()
1057 struct snd_sof_dev *sdev = dev_get_drvdata(bus->dev); in hda_dsp_d0i3_work()
1064 /* DSP can enter D0I3 iff only D0I3-compatible streams are active */ in hda_dsp_d0i3_work()
1072 dev_err_ratelimited(sdev->dev, in hda_dsp_d0i3_work()
1079 const struct sof_ipc_pm_ops *pm_ops = sdev->ipc->ops->pm; in hda_dsp_core_get()
1085 dev_err(sdev->dev, "failed to power up core %d with err: %d\n", in hda_dsp_core_get()
1090 /* No need to send IPC for primary core or if FW boot is not complete */ in hda_dsp_core_get()
1091 if (sdev->fw_state != SOF_FW_BOOT_COMPLETE || core == SOF_DSP_PRIMARY_CORE) in hda_dsp_core_get()
1095 if (!pm_ops->set_core_state) in hda_dsp_core_get()
1099 ret = pm_ops->set_core_state(sdev, core, true); in hda_dsp_core_get()
1101 dev_err(sdev->dev, "failed to enable secondary core '%d' failed with %d\n", in hda_dsp_core_get()
1112 dev_err(sdev->dev, "failed to power down core: %d with err: %d\n", core, ret1); in hda_dsp_core_get()