Commit f402a974 authored by Pierre-Louis Bossart's avatar Pierre-Louis Bossart Committed by Mark Brown

ASoC: SOF: Intel: hda-mlink: add helpers to suspend/resume links

No functionality change, just move the code in hda-mlink.
Signed-off-by: default avatarPierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: default avatarRander Wang <rander.wang@intel.com>
Reviewed-by: default avatarBard Liao <yung-chuan.liao@linux.intel.com>
Reviewed-by: default avatarPéter Ujfalusi <peter.ujfalusi@linux.intel.com>
Reviewed-by: default avatarRanjani Sridharan <ranjani.sridharan@linux.intel.com>
Link: https://lore.kernel.org/r/20221027193540.259520-18-pierre-louis.bossart@linux.intel.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent afae0942
......@@ -614,9 +614,7 @@ static int hda_suspend(struct snd_sof_dev *sdev, bool runtime_suspend)
{
struct sof_intel_hda_dev *hda = sdev->pdata->hw_pdata;
const struct sof_intel_dsp_desc *chip = hda->desc;
#if IS_ENABLED(CONFIG_SND_SOC_SOF_HDA)
struct hdac_bus *bus = sof_to_bus(sdev);
#endif
int ret, j;
/*
......@@ -637,10 +635,8 @@ static int hda_suspend(struct snd_sof_dev *sdev, bool runtime_suspend)
hda_codec_jack_wake_enable(sdev, runtime_suspend);
#if IS_ENABLED(CONFIG_SND_SOC_SOF_HDA)
/* power down all hda link */
snd_hdac_ext_bus_link_power_down_all(bus);
#endif
/* power down all hda links */
hda_bus_ml_suspend(bus);
ret = chip->power_down_dsp(sdev);
if (ret < 0) {
......@@ -719,33 +715,23 @@ static int hda_resume(struct snd_sof_dev *sdev, bool runtime_resume)
int hda_dsp_resume(struct snd_sof_dev *sdev)
{
struct sof_intel_hda_dev *hda = sdev->pdata->hw_pdata;
struct hdac_bus *bus = sof_to_bus(sdev);
struct pci_dev *pci = to_pci_dev(sdev->dev);
const struct sof_dsp_power_state target_state = {
.state = SOF_DSP_PM_D0,
.substate = SOF_HDA_DSP_PM_D0I0,
};
#if IS_ENABLED(CONFIG_SND_SOC_SOF_HDA)
struct hdac_bus *bus = sof_to_bus(sdev);
struct hdac_ext_link *hlink = NULL;
#endif
int ret;
/* resume from D0I3 */
if (sdev->dsp_power_state.state == SOF_DSP_PM_D0) {
#if IS_ENABLED(CONFIG_SND_SOC_SOF_HDA)
/* power up links that were active before suspend */
list_for_each_entry(hlink, &bus->hlink_list, list) {
if (hlink->ref_count) {
ret = snd_hdac_ext_bus_link_power_up(hlink);
ret = hda_bus_ml_resume(bus);
if (ret < 0) {
dev_err(sdev->dev,
"error %d in %s: failed to power up links",
ret, __func__);
return ret;
}
}
}
#endif
/* set up CORB/RIRB buffers if was on before suspend */
hda_codec_resume_cmd_io(sdev);
......@@ -860,16 +846,14 @@ int hda_dsp_suspend(struct snd_sof_dev *sdev, u32 target_state)
/* stop the CORB/RIRB DMA if it is On */
hda_codec_suspend_cmd_io(sdev);
#if IS_ENABLED(CONFIG_SND_SOC_SOF_HDA)
/* no link can be powered in s0ix state */
ret = snd_hdac_ext_bus_link_power_down_all(bus);
ret = hda_bus_ml_suspend(bus);
if (ret < 0) {
dev_err(sdev->dev,
"error %d in %s: failed to power down links",
ret, __func__);
return ret;
}
#endif
/* enable the system waking up via IPC IRQ */
enable_irq_wake(pci->irq);
......
......@@ -51,4 +51,25 @@ void hda_bus_ml_reset_losidv(struct hdac_bus *bus)
writel(0, hlink->ml_addr + AZX_REG_ML_LOSIDV);
}
int hda_bus_ml_resume(struct hdac_bus *bus)
{
struct hdac_ext_link *hlink;
int ret;
/* power up links that were active before suspend */
list_for_each_entry(hlink, &bus->hlink_list, list) {
if (hlink->ref_count) {
ret = snd_hdac_ext_bus_link_power_up(hlink);
if (ret < 0)
return ret;
}
}
return 0;
}
int hda_bus_ml_suspend(struct hdac_bus *bus)
{
return snd_hdac_ext_bus_link_power_down_all(bus);
}
#endif
......@@ -766,12 +766,16 @@ static inline int hda_codec_i915_exit(struct snd_sof_dev *sdev) { return 0; }
void hda_bus_ml_get_capabilities(struct hdac_bus *bus);
void hda_bus_ml_put_all(struct hdac_bus *bus);
void hda_bus_ml_reset_losidv(struct hdac_bus *bus);
int hda_bus_ml_resume(struct hdac_bus *bus);
int hda_bus_ml_suspend(struct hdac_bus *bus);
#else
static inline void hda_bus_ml_get_capabilities(struct hdac_bus *bus) { }
static inline void hda_bus_ml_put_all(struct hdac_bus *bus) { }
static inline void hda_bus_ml_reset_losidv(struct hdac_bus *bus) { }
static inline int hda_bus_ml_resume(struct hdac_bus *bus) { return 0; }
static inline int hda_bus_ml_suspend(struct hdac_bus *bus) { return 0; }
#endif /* CONFIG_SND_SOC_SOF_HDA */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment