ASoC: SOF: mediatek: Add DSP system PM callback for mt8186
authorTinghan Shen <tinghan.shen@mediatek.com>
Fri, 22 Apr 2022 05:56:59 +0000 (13:56 +0800)
committerMark Brown <broonie@kernel.org>
Mon, 25 Apr 2022 13:04:46 +0000 (14:04 +0100)
Add DSP system PM callback for suspend and resume

Signed-off-by: Allen-KH Cheng <allen-kh.cheng@mediatek.com>
Signed-off-by: Tinghan Shen <tinghan.shen@mediatek.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Reviewed-by: Yaochun Hung <yc.hung@mediatek.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20220422055659.8738-5-tinghan.shen@mediatek.com
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/sof/mediatek/mt8186/mt8186.c

index a04cea77bd4d75f858a2d16bab9cbdf0a838d95a..c8faa63497c662df4bf68f2eb68818c60c2f01bc 100644 (file)
@@ -304,6 +304,30 @@ static int mt8186_dsp_remove(struct snd_sof_dev *sdev)
        return 0;
 }
 
+static int mt8186_dsp_suspend(struct snd_sof_dev *sdev, u32 target_state)
+{
+       sof_hifixdsp_shutdown(sdev);
+       adsp_sram_power_off(sdev);
+       adsp_clock_off(sdev);
+
+       return 0;
+}
+
+static int mt8186_dsp_resume(struct snd_sof_dev *sdev)
+{
+       int ret;
+
+       ret = adsp_clock_on(sdev);
+       if (ret) {
+               dev_err(sdev->dev, "adsp_clock_on fail!\n");
+               return ret;
+       }
+
+       adsp_sram_power_on(sdev);
+
+       return ret;
+}
+
 /* on mt8186 there is 1 to 1 match between type and BAR idx */
 static int mt8186_get_bar_index(struct snd_sof_dev *sdev, u32 type)
 {
@@ -338,6 +362,10 @@ static struct snd_sof_dsp_ops sof_mt8186_ops = {
        /* Firmware ops */
        .dsp_arch_ops = &sof_xtensa_arch_ops,
 
+       /* PM */
+       .suspend        = mt8186_dsp_suspend,
+       .resume         = mt8186_dsp_resume,
+
        /* ALSA HW info flags */
        .hw_info =      SNDRV_PCM_INFO_MMAP |
                        SNDRV_PCM_INFO_MMAP_VALID |