No functionality change, just move the code in hda-mlink. Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@xxxxxxxxxxxxxxx> Reviewed-by: Rander Wang <rander.wang@xxxxxxxxx> Reviewed-by: Bard Liao <yung-chuan.liao@xxxxxxxxxxxxxxx> Reviewed-by: Péter Ujfalusi <peter.ujfalusi@xxxxxxxxxxxxxxx> Reviewed-by: Ranjani Sridharan <ranjani.sridharan@xxxxxxxxxxxxxxx> --- sound/soc/sof/intel/hda-dsp.c | 36 +++++++++------------------------ sound/soc/sof/intel/hda-mlink.c | 21 +++++++++++++++++++ sound/soc/sof/intel/hda.h | 4 ++++ 3 files changed, 35 insertions(+), 26 deletions(-) diff --git a/sound/soc/sof/intel/hda-dsp.c b/sound/soc/sof/intel/hda-dsp.c index 2596de5e24d6..c61bab1a5719 100644 --- a/sound/soc/sof/intel/hda-dsp.c +++ b/sound/soc/sof/intel/hda-dsp.c @@ -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); - if (ret < 0) { - dev_err(sdev->dev, - "error %d in %s: failed to power up links", - ret, __func__); - return ret; - } - } + 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); diff --git a/sound/soc/sof/intel/hda-mlink.c b/sound/soc/sof/intel/hda-mlink.c index b5f922603187..2cdee03e4a47 100644 --- a/sound/soc/sof/intel/hda-mlink.c +++ b/sound/soc/sof/intel/hda-mlink.c @@ -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 diff --git a/sound/soc/sof/intel/hda.h b/sound/soc/sof/intel/hda.h index 0214097389d3..f0c9bb6d567d 100644 --- a/sound/soc/sof/intel/hda.h +++ b/sound/soc/sof/intel/hda.h @@ -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 */ -- 2.34.1