ASoC: SOF: Intel: hda-mlink: add helpers to suspend/resume links
authorPierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Thu, 27 Oct 2022 19:35:36 +0000 (15:35 -0400)
committerMark Brown <broonie@kernel.org>
Fri, 28 Oct 2022 12:04:57 +0000 (13:04 +0100)
No functionality change, just move the code in hda-mlink.

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Rander Wang <rander.wang@intel.com>
Reviewed-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Reviewed-by: Péter Ujfalusi <peter.ujfalusi@linux.intel.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Link: https://lore.kernel.org/r/20221027193540.259520-18-pierre-louis.bossart@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/sof/intel/hda-dsp.c
sound/soc/sof/intel/hda-mlink.c
sound/soc/sof/intel/hda.h

index 2596de5..c61bab1 100644 (file)
@@ -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 @@ cleanup:
 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);
index b5f9226..2cdee03 100644 (file)
@@ -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
index 0214097..f0c9bb6 100644 (file)
@@ -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 */