linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Daniel Baluta <daniel.baluta@oss.nxp.com>
To: broonie@kernel.org, alsa-devel@alsa-project.org
Cc: pierre-louis.bossart@linux.intel.com, lgirdwood@gmail.com,
	daniel.baluta@nxp.com, daniel.baluta@gmail.com,
	linux-kernel@vger.kernel.org, yc.hung@mediatek.com,
	linux-mediatek@lists.infradead.org
Subject: [PATCH v2 8/8] ASoC: SOF: mediatek: Add DSP system PM callback for mt8195
Date: Thu, 18 Nov 2021 12:07:49 +0200	[thread overview]
Message-ID: <20211118100749.54628-9-daniel.baluta@oss.nxp.com> (raw)
In-Reply-To: <20211118100749.54628-1-daniel.baluta@oss.nxp.com>

From: YC Hung <yc.hung@mediatek.com>

Add DSP system PM callback for suspend and resume

Signed-off-by: YC Hung <yc.hung@mediatek.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Daniel Baluta <daniel.baluta@nxp.com>
Signed-off-by: Daniel Baluta <daniel.baluta@nxp.com>
---
 sound/soc/sof/mediatek/mt8195/mt8195.c | 42 ++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)

diff --git a/sound/soc/sof/mediatek/mt8195/mt8195.c b/sound/soc/sof/mediatek/mt8195/mt8195.c
index 5bfae9379ac8..40e5a25875a6 100644
--- a/sound/soc/sof/mediatek/mt8195/mt8195.c
+++ b/sound/soc/sof/mediatek/mt8195/mt8195.c
@@ -311,6 +311,44 @@ static int mt8195_dsp_remove(struct snd_sof_dev *sdev)
 	return 0;
 }
 
+static int mt8195_dsp_suspend(struct snd_sof_dev *sdev, u32 target_state)
+{
+	struct platform_device *pdev = container_of(sdev->dev, struct platform_device, dev);
+	int ret;
+
+	/* stall and reset dsp */
+	sof_hifixdsp_shutdown(sdev);
+
+	/* power down adsp sram */
+	ret = adsp_sram_power_on(&pdev->dev, false);
+	if (ret) {
+		dev_err(sdev->dev, "adsp_sram_power_off fail!\n");
+		return ret;
+	}
+
+	/* turn off adsp clock */
+	return adsp_clock_off(sdev);
+}
+
+static int mt8195_dsp_resume(struct snd_sof_dev *sdev)
+{
+	int ret;
+
+	/* turn on adsp clock */
+	ret = adsp_clock_on(sdev);
+	if (ret) {
+		dev_err(sdev->dev, "adsp_clock_on fail!\n");
+		return ret;
+	}
+
+	/* power on adsp sram */
+	ret = adsp_sram_power_on(sdev->dev, true);
+	if (ret)
+		dev_err(sdev->dev, "adsp_sram_power_on fail!\n");
+
+	return ret;
+}
+
 /* on mt8195 there is 1 to 1 match between type and BAR idx */
 static int mt8195_get_bar_index(struct snd_sof_dev *sdev, u32 type)
 {
@@ -382,6 +420,10 @@ const struct snd_sof_dsp_ops sof_mt8195_ops = {
 	.drv = mt8195_dai,
 	.num_drv = ARRAY_SIZE(mt8195_dai),
 
+	/* PM */
+	.suspend	= mt8195_dsp_suspend,
+	.resume		= mt8195_dsp_resume,
+
 	/* ALSA HW info flags */
 	.hw_info =	SNDRV_PCM_INFO_MMAP |
 			SNDRV_PCM_INFO_MMAP_VALID |
-- 
2.27.0


  parent reply	other threads:[~2021-11-18 10:12 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-18 10:07 [PATCH v2 0/8] ASoC: SOF: Add support for Mediatek MT8195 Daniel Baluta
2021-11-18 10:07 ` [PATCH v2 1/8] ASoC: SOF: mediatek: Add mt8195 hardware support Daniel Baluta
2021-11-26 12:06   ` AngeloGioacchino Del Regno
2021-11-18 10:07 ` [PATCH v2 2/8] ASoC: SOF: tokens: add token for Mediatek AFE Daniel Baluta
2021-11-26 12:06   ` AngeloGioacchino Del Regno
2021-11-18 10:07 ` [PATCH v2 3/8] ASoC: SOF: topology: Add support for Mediatek AFE DAI Daniel Baluta
2021-11-26 12:05   ` AngeloGioacchino Del Regno
2021-11-18 10:07 ` [PATCH v2 4/8] ASoC: SOF: mediatek: Add fw loader and mt8195 dsp ops to load firmware Daniel Baluta
2021-11-26 12:05   ` AngeloGioacchino Del Regno
2021-11-18 10:07 ` [PATCH v2 5/8] ASoC: SOF: Add mt8195 device descriptor Daniel Baluta
2021-11-26 12:06   ` AngeloGioacchino Del Regno
2021-11-18 10:07 ` [PATCH v2 6/8] ASoC: SOF: mediatek: Add dai driver dsp ops callback for mt8195 Daniel Baluta
2021-11-26 12:06   ` AngeloGioacchino Del Regno
2021-11-18 10:07 ` [PATCH v2 7/8] ASoC: SOF: mediatek: Add mt8195 dsp clock support Daniel Baluta
2021-11-26 12:07   ` AngeloGioacchino Del Regno
2021-11-18 10:07 ` Daniel Baluta [this message]
2021-11-26 12:07   ` [PATCH v2 8/8] ASoC: SOF: mediatek: Add DSP system PM callback for mt8195 AngeloGioacchino Del Regno
2021-11-18 19:06 ` [PATCH v2 0/8] ASoC: SOF: Add support for Mediatek MT8195 Mark Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211118100749.54628-9-daniel.baluta@oss.nxp.com \
    --to=daniel.baluta@oss.nxp.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=daniel.baluta@gmail.com \
    --cc=daniel.baluta@nxp.com \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=pierre-louis.bossart@linux.intel.com \
    --cc=yc.hung@mediatek.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).