From patchwork Tue May 5 20:53:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Deucher X-Patchwork-Id: 11529907 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6381F912 for ; Tue, 5 May 2020 21:02:45 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id EE62B2068E for ; Tue, 5 May 2020 21:02:44 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="SnXc2JgI"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="uPJnt6v+" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EE62B2068E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 3F363175D; Tue, 5 May 2020 23:01:57 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 3F363175D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1588712563; bh=xJxUAGPZt2Uv90HX57w9RNfrxCSkJSUrLJ928RAtssE=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=SnXc2JgI/6oQhCgzsbJ9XZrIibU8Qw0SOT5yV2Jkl0+YxQRwbqhTfHPxECUm+a2l5 P29SzKmVfrjxoley8MVW/mwMImvlXLROLIDmoPC3vFS7hzKud4wCVPRPjJOqWvJ3Dr ZuNr1OpxOPO4av2gu2YN8JRJRWXHmgHpvGG41E38= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 7F8DFF80334; Tue, 5 May 2020 22:54:15 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa1.perex.cz (Postfix, from userid 50401) id 243CAF802EB; Tue, 5 May 2020 22:54:10 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on alsa1.perex.cz X-Spam-Level: * X-Spam-Status: No, score=1.4 required=5.0 tests=DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from mail-qk1-x742.google.com (mail-qk1-x742.google.com [IPv6:2607:f8b0:4864:20::742]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id E9C12F8023E for ; Tue, 5 May 2020 22:53:53 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz E9C12F8023E Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="uPJnt6v+" Received: by mail-qk1-x742.google.com with SMTP id b6so3857318qkh.11 for ; Tue, 05 May 2020 13:53:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=c+eSD6JZC4THB9YwHcMFZmdVU+wdM7Rk0LOykpENBUc=; b=uPJnt6v+OKPG0l3QBnfrm5lEUiiITEBit1IpQsujhU8Ecq3mkqFtdZZSMx2k1JwBdo wZDQ1RiL+Y44f9C+viFRflLFsdpGPL13wrrrsBQDSEgDcSz5vKm6pglLFhshTeVhR3e8 qnFR3iCcj3/PAcXh7jnTVzfnSjYzgAYkcwZxnCe25uskPoePIf2nmZn+GrSPRioZ2L2m gmAACYGCpDnN8Hs0kXOibvLpGL0XlXNXKu1DXNdwesCKAuKqn4N+ZD0qLnDOMy+K5mN2 igDzofdzUriWjueH5JESGw1sY2tLQGtRRVgBT/Gq1hg2oVbZnzeSXLrjQgmV+HZVAwFB /j+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=c+eSD6JZC4THB9YwHcMFZmdVU+wdM7Rk0LOykpENBUc=; b=OsHwKQ/JbT/+lyruiNHy/SBCV6bL88Z4aJpIFrECmkRqxM8oED1BHR/mOpw2mtxK1l fzHOztWFBecEgRokNQj3CQd2Hw+NmS4dQXJamUA/S1u+ZpB3ZNp3c6TqXapY3asO4lme LF8CE7m9LjbFzK5uv2s6qYtM6SYiLhI3GjQp+sFVvJW3Mxhwg4sD8CKZ+N0V/1WvbZTP udCQZF534SN7/5ed7fGPPawxiIo0DnJEzkesvHEfdoaoYgn9zNByW16PqpWON5DBBQ9s cHBkFJLPajOiBa/V4XckQbkWsW2usec5eohRkam9GSh7C9KBg1oaFvQ7kMGJ9ZZYoLvr IWkw== X-Gm-Message-State: AGi0PuYjULwyYKvmCJylH0a3STIDQ/nxvGT6wXr9zM4Xhwl19WR8DeYw BH4AGV8wM48+IhjaU2IsWoptpnMo X-Google-Smtp-Source: APiQypKpkPgkH1M17qPy4bQQ2mR3+p3rDKMQA57Nr+BLm+SvC3RDN9Puwamld/72oFR2I0ao7S9F2A== X-Received: by 2002:a37:ae07:: with SMTP id x7mr4822569qke.13.1588712029628; Tue, 05 May 2020 13:53:49 -0700 (PDT) Received: from tr4.amd.com (atlvpn.amd.com. [165.204.84.11]) by smtp.gmail.com with ESMTPSA id k58sm2972513qtf.40.2020.05.05.13.53.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 May 2020 13:53:49 -0700 (PDT) From: Alex Deucher X-Google-Original-From: Alex Deucher To: alsa-devel@alsa-project.org, broonie@kernel.org, vijendar.mukunda@amd.com, tiwai@suse.de Subject: [PATCH 10/14] ASoC: amd: add ACP PDM DMA driver pm ops Date: Tue, 5 May 2020 16:53:23 -0400 Message-Id: <20200505205327.642282-11-alexander.deucher@amd.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20200505205327.642282-1-alexander.deucher@amd.com> References: <20200505205327.642282-1-alexander.deucher@amd.com> MIME-Version: 1.0 Cc: Alex Deucher , Vijendar Mukunda X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 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: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" From: Vijendar Mukunda Add ACP PDM DMA driver pm ops. Signed-off-by: Vijendar Mukunda Signed-off-by: Alex Deucher --- sound/soc/amd/renoir/acp3x-pdm-dma.c | 53 ++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/sound/soc/amd/renoir/acp3x-pdm-dma.c b/sound/soc/amd/renoir/acp3x-pdm-dma.c index 6e8d5b85bce4..ef256c777873 100644 --- a/sound/soc/amd/renoir/acp3x-pdm-dma.c +++ b/sound/soc/amd/renoir/acp3x-pdm-dma.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -457,19 +458,71 @@ static int acp_pdm_audio_probe(struct platform_device *pdev) dev_err(&pdev->dev, "ACP PDM IRQ request failed\n"); 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 acp_pdm_audio_remove(struct platform_device *pdev) { + pm_runtime_disable(&pdev->dev); return 0; } +static int acp_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); + config_acp_dma(rtd, SNDRV_PCM_STREAM_CAPTURE); + init_pdm_ring_buffer(MEM_WINDOW_START, buffer_len, period_bytes, + adata->acp_base); + } + enable_pdm_interrupts(adata->acp_base); + return 0; +} + +static int acp_pdm_runtime_suspend(struct device *dev) +{ + struct pdm_dev_data *adata; + + adata = dev_get_drvdata(dev); + disable_pdm_interrupts(adata->acp_base); + + return 0; +} + +static int acp_pdm_runtime_resume(struct device *dev) +{ + struct pdm_dev_data *adata; + + adata = dev_get_drvdata(dev); + enable_pdm_interrupts(adata->acp_base); + return 0; +} + +static const struct dev_pm_ops acp_pdm_pm_ops = { + .runtime_suspend = acp_pdm_runtime_suspend, + .runtime_resume = acp_pdm_runtime_resume, + .resume = acp_pdm_resume, +}; + static struct platform_driver acp_pdm_dma_driver = { .probe = acp_pdm_audio_probe, .remove = acp_pdm_audio_remove, .driver = { .name = "acp_rn_pdm_dma", + .pm = &acp_pdm_pm_ops, }, };