From patchwork Fri Jan 8 23:22:10 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Deucher X-Patchwork-Id: 7991221 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 35F91BEEE5 for ; Fri, 8 Jan 2016 23:26:13 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4EE58201E4 for ; Fri, 8 Jan 2016 23:26:12 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 28A36201C7 for ; Fri, 8 Jan 2016 23:26:11 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 3A48B266581; Sat, 9 Jan 2016 00:26:10 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, NO_DNS_FOR_FROM, RCVD_IN_DNSWL_NONE, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=no version=3.3.1 Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 9BE91265DC7; Sat, 9 Jan 2016 00:22:47 +0100 (CET) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id D9CB3265DF5; Sat, 9 Jan 2016 00:22:45 +0100 (CET) Received: from mail-qg0-f68.google.com (mail-qg0-f68.google.com [209.85.192.68]) by alsa0.perex.cz (Postfix) with ESMTP id 9385E260523 for ; Sat, 9 Jan 2016 00:22:27 +0100 (CET) Received: by mail-qg0-f68.google.com with SMTP id o11so32615224qge.0 for ; Fri, 08 Jan 2016 15:22:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=5kQJGAQVWj2KEdI/O1SezYFOJpa/STYCc9lH6OgY5lk=; b=Qh0tIaJKLQu6RfrewxWA1VE0I2PZ121d2U47UjR7qZjbIYO5h6Dpe2iJ1Xx6xj7ZEE 1cA6OLpLhzTlH8TPOn8WXEs6fFRaqVJiCxneu811v5N3jsrEEgktFXKOEzJme2Ydxuh4 J5/9TMojP6+42IxEl8Fi77aP2DOuz1HDt4T1OdQA5EDv5C1dsWpDe9+pGLEHOW0+HQ9T uDTj8jArJboyoYFZN3R+1nyZJV3e3AK1VaiGIj8B5ZfM2nDDiluC3tbxmoFAZ4R3mGh2 s5wAmiIoI3QE5H+MBYO2QbFNhu4WmYNxeZL1sF8x9dYHGh0PS3f8o6SPqLnSL6j4JfJH dqkw== X-Received: by 10.140.216.20 with SMTP id m20mr134286318qhb.90.1452295347137; Fri, 08 Jan 2016 15:22:27 -0800 (PST) Received: from cm.localdomain (static-74-96-105-49.washdc.fios.verizon.net. [74.96.105.49]) by smtp.gmail.com with ESMTPSA id f83sm43834730qkb.25.2016.01.08.15.22.26 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 08 Jan 2016 15:22:26 -0800 (PST) From: Alex Deucher X-Google-Original-From: Alex Deucher To: airlied@gmail.com, dri-devel@lists.freedesktop.org, broonie@kernel.org, alsa-devel@alsa-project.org, maruthi.bayyavarapu@amd.com, rajeevkumar.linux@gmail.com Date: Fri, 8 Jan 2016 18:22:10 -0500 Message-Id: <1452295331-28476-9-git-send-email-alexander.deucher@amd.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1452295331-28476-1-git-send-email-alexander.deucher@amd.com> References: <1452295331-28476-1-git-send-email-alexander.deucher@amd.com> Cc: tiwai@suse.de, Alex Deucher , Maruthi Srinivas Bayyavarapu , lgirdwood@gmail.com Subject: [alsa-devel] [PATCH 8/9] ASoC: AMD: add pm ops X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP From: Maruthi Srinivas Bayyavarapu genpd will power off/on ACP to manage runtime ACP PM. ACP runtime PM hooks are added to get it deinitialized and initialized respectively, after it is powered off/on. When system goes to suspend when audio usecase is active, ACP will be powered off through genpd. When it resumes, ACP needs to be initialized and reconfigured. Signed-off-by: Maruthi Bayyavarapu Reviewed-by: Alex Deucher Signed-off-by: Alex Deucher --- v2: replace ternery operator usage sound/soc/amd/acp-pcm-dma.c | 48 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/sound/soc/amd/acp-pcm-dma.c b/sound/soc/amd/acp-pcm-dma.c index 0724d78..c0819b5 100644 --- a/sound/soc/amd/acp-pcm-dma.c +++ b/sound/soc/amd/acp-pcm-dma.c @@ -16,6 +16,7 @@ #include #include #include +#include #include @@ -885,6 +886,10 @@ static int acp_audio_probe(struct platform_device *pdev) return status; } + pm_runtime_set_autosuspend_delay(&pdev->dev, 10000); + pm_runtime_use_autosuspend(&pdev->dev); + pm_runtime_enable(&pdev->dev); + return status; } @@ -894,15 +899,58 @@ static int acp_audio_remove(struct platform_device *pdev) acp_deinit(adata->acp_mmio); snd_soc_unregister_platform(&pdev->dev); + pm_runtime_disable(&pdev->dev); return 0; } +static int acp_pcm_resume(struct device *dev) +{ + struct audio_drv_data *adata = dev_get_drvdata(dev); + + acp_init(adata->acp_mmio); + + if (adata->play_stream && adata->play_stream->runtime) + config_acp_dma(adata->acp_mmio, + adata->play_stream->runtime->private_data); + if (adata->capture_stream && adata->capture_stream->runtime) + config_acp_dma(adata->acp_mmio, + adata->capture_stream->runtime->private_data); + + acp_reg_write(1, adata->acp_mmio, mmACP_EXTERNAL_INTR_ENB); + return 0; +} + +static int acp_pcm_runtime_suspend(struct device *dev) +{ + struct audio_drv_data *adata = dev_get_drvdata(dev); + + acp_deinit(adata->acp_mmio); + acp_reg_write(0, adata->acp_mmio, mmACP_EXTERNAL_INTR_ENB); + return 0; +} + +static int acp_pcm_runtime_resume(struct device *dev) +{ + struct audio_drv_data *adata = dev_get_drvdata(dev); + + acp_init(adata->acp_mmio); + acp_reg_write(1, adata->acp_mmio, mmACP_EXTERNAL_INTR_ENB); + return 0; +} + +static const struct dev_pm_ops acp_pm_ops = { + .resume = acp_pcm_resume, + .runtime_suspend = acp_pcm_runtime_suspend, + .runtime_resume = acp_pcm_runtime_resume, +}; + static struct platform_driver acp_dma_driver = { .probe = acp_audio_probe, .remove = acp_audio_remove, .driver = { .name = "acp_audio_dma", + .pm = &acp_pm_ops, }, };