From patchwork Wed Sep 14 05:16:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hui Wang X-Patchwork-Id: 1677653 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=canonical.com header.i=@canonical.com header.a=rsa-sha256 header.s=20210705 header.b=j6YzsHqm; dkim-atps=neutral Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4MS7sG38nbz1ync for ; Wed, 14 Sep 2022 15:18:26 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1oYKmt-0002LZ-Hz; Wed, 14 Sep 2022 05:18:15 +0000 Received: from smtp-relay-canonical-0.internal ([10.131.114.83] helo=smtp-relay-canonical-0.canonical.com) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1oYKmD-0000M6-0B for kernel-team@lists.ubuntu.com; Wed, 14 Sep 2022 05:17:33 +0000 Received: from localhost.localdomain (unknown [124.160.154.11]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-canonical-0.canonical.com (Postfix) with ESMTPSA id B9ABD3F10C for ; Wed, 14 Sep 2022 05:17:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1663132650; bh=+cVG5hV7XtQyiMxgz3RR1ZibioozXKnCjqI/EElU33s=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=j6YzsHqmxTeOnIN5maUMtPxb/BJWDXhEwSK0/kWy+z70dU8tOpvHgV5RzpD3Luyqi GSCxFyBwWRy/lrNHuXdJyJ6k6fEEzVV8tRPnkgPyK2AIGLUwLYkKSdN2a/Tarl+B7m fEVgqTOXZ+gRChMqKZGAX9WB+qMicaIX0zl/Ewh6PS5eJwYC4VHfKakdlAZVaXMm+3 gbszhxsZ3b8TReviqftA0yGv0Qxn4uT1cTEkJOpBuDJn69XaFgxYQ2gIrnOY/sKHUa QWBhA2qsvDCoKSck4tACzCUVcJMW4xC2V0OQW64bk43xRGwCZjLBKfvQGIq6LB8Mqf P/WWe3C69S5xg== From: Hui Wang To: kernel-team@lists.ubuntu.com Subject: [SRU][Kinetic][PATCH 09/14] ASoC: amd: add acp6.2 pdm driver pm ops Date: Wed, 14 Sep 2022 13:16:28 +0800 Message-Id: <20220914051633.20418-24-hui.wang@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220914051633.20418-1-hui.wang@canonical.com> References: <20220914051633.20418-1-hui.wang@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Syed Saba Kareem BugLink: https://bugs.launchpad.net/bugs/1989518 Add acp6.2 pdm driver pm ops. Signed-off-by: Syed Saba Kareem Reviewed-by: Vijendar Mukunda Link: https://lore.kernel.org/r/20220827165657.2343818-10-Syed.SabaKareem@amd.com Signed-off-by: Mark Brown (cherry picked from commit 28023a78790c33f5df0147fd00ab3cf333edd24f linux-next) Signed-off-by: Hui Wang --- sound/soc/amd/ps/ps-pdm-dma.c | 57 +++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/sound/soc/amd/ps/ps-pdm-dma.c b/sound/soc/amd/ps/ps-pdm-dma.c index f0ec1a4f3b9d..b207b726cd82 100644 --- a/sound/soc/amd/ps/ps-pdm-dma.c +++ b/sound/soc/amd/ps/ps-pdm-dma.c @@ -12,6 +12,7 @@ #include #include #include +#include #include "acp62.h" @@ -377,13 +378,69 @@ static int acp62_pdm_audio_probe(struct platform_device *pdev) return -ENODEV; } + pm_runtime_set_autosuspend_delay(&pdev->dev, ACP_SUSPEND_DELAY_MS); + pm_runtime_use_autosuspend(&pdev->dev); + pm_runtime_enable(&pdev->dev); + pm_runtime_allow(&pdev->dev); return 0; } +static int acp62_pdm_audio_remove(struct platform_device *pdev) +{ + pm_runtime_disable(&pdev->dev); + return 0; +} + +static int __maybe_unused acp62_pdm_resume(struct device *dev) +{ + struct pdm_dev_data *adata; + struct snd_pcm_runtime *runtime; + struct pdm_stream_instance *rtd; + u32 period_bytes, buffer_len; + + adata = dev_get_drvdata(dev); + if (adata->capture_stream && adata->capture_stream->runtime) { + runtime = adata->capture_stream->runtime; + rtd = runtime->private_data; + period_bytes = frames_to_bytes(runtime, runtime->period_size); + buffer_len = frames_to_bytes(runtime, runtime->buffer_size); + acp62_config_dma(rtd, SNDRV_PCM_STREAM_CAPTURE); + acp62_init_pdm_ring_buffer(PDM_MEM_WINDOW_START, buffer_len, + period_bytes, adata->acp62_base); + } + acp62_enable_pdm_interrupts(adata->acp62_base); + return 0; +} + +static int __maybe_unused acp62_pdm_suspend(struct device *dev) +{ + struct pdm_dev_data *adata; + + adata = dev_get_drvdata(dev); + acp62_disable_pdm_interrupts(adata->acp62_base); + return 0; +} + +static int __maybe_unused acp62_pdm_runtime_resume(struct device *dev) +{ + struct pdm_dev_data *adata; + + adata = dev_get_drvdata(dev); + acp62_enable_pdm_interrupts(adata->acp62_base); + return 0; +} + +static const struct dev_pm_ops acp62_pdm_pm_ops = { + SET_RUNTIME_PM_OPS(acp62_pdm_suspend, acp62_pdm_runtime_resume, NULL) + SET_SYSTEM_SLEEP_PM_OPS(acp62_pdm_suspend, acp62_pdm_resume) +}; + static struct platform_driver acp62_pdm_dma_driver = { .probe = acp62_pdm_audio_probe, + .remove = acp62_pdm_audio_remove, .driver = { .name = "acp_ps_pdm_dma", + .pm = &acp62_pdm_pm_ops, }, };