From patchwork Mon Oct 9 08:49:48 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Brown X-Patchwork-Id: 115188 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp2309652qgn; Mon, 9 Oct 2017 01:50:42 -0700 (PDT) X-Google-Smtp-Source: AOwi7QCVwSAzYFNlJqQ3yj+w/ziyl01mVwvAPjnaXep06PJ2Nab/q8zXlrJdK28JAdixCYUL+bbr X-Received: by 10.223.197.13 with SMTP id q13mr9792229wrf.272.1507539042780; Mon, 09 Oct 2017 01:50:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507539042; cv=none; d=google.com; s=arc-20160816; b=CiaU2biLQiKF7yCwY3AL50B196oY6w5Zh/43Z4tTVlKb8JnzhM/cv6OtkS/5HlWaHC ml2z3y9+b3MwY+6mle4jeh4dVv9mnxOc34wSsNqxj5/ctrBEQfCg68Ni29tT39++SHat ahGzOKTFOQSWvY93I5KoGg4KQQdpuojLhtKaTfXDRKAXPUkNZERMoh5GXgtruto44QfA nD0Jwp4METZL6ubllGcLLOiPRSyPmZbS8vd5EKdnFZD2/HXifTHiX5VxMsD79d1yllm9 swlTL6ZgD4XefFp02B5oBvkFS42vYnw1HBNwm+uaZAum/vQXsKN47Xwx/ITur3scztZd oe7g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:cc:date:message-id:in-reply-to:to:from :dkim-signature:delivered-to:arc-authentication-results; bh=ig3h6y09J0iISPUHWBt7ASV69V6NzSt2UY9djis38Ys=; b=vWIJHMQrZyuIXLXvmxTL8PS26wqloHLQkP7KMbLmXPnxVNFmGHJ6aWDKO4w5kvgL29 GvOM2JbzaX+SOjwxFp/Mh8x2ZfFtZZRAQLFYd8l77OhyvbmMqggSfrJ3ZpFIlHdN1oed FUOLaBysg/roE6K//X/+m/UGg8lWICoFdceuYm9RtRd8dwwvwYPx9FfYetPWE691pC+z ZezaethYSFJo2Eo93iJ+USxbSFuy9xupiy8Wxfoo8U6+C0eJHcboixlgWmOc7l50QLEy 0HVfdrectr0/RVI0DQht85CKgxX+No9r+npyd0VCEkPnW1zHW898KEEphPFHXPIvIOLt inzQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@sirena.org.uk header.s=20170815-heliosphere header.b=DsVAAbD1; spf=pass (google.com: domain of alsa-devel-bounces@alsa-project.org designates 77.48.224.243 as permitted sender) smtp.mailfrom=alsa-devel-bounces@alsa-project.org Return-Path: Received: from alsa0.perex.cz (alsa0.perex.cz. [77.48.224.243]) by mx.google.com with ESMTP id k128si4335341wmb.181.2017.10.09.01.50.42; Mon, 09 Oct 2017 01:50:42 -0700 (PDT) Received-SPF: pass (google.com: domain of alsa-devel-bounces@alsa-project.org designates 77.48.224.243 as permitted sender) client-ip=77.48.224.243; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@sirena.org.uk header.s=20170815-heliosphere header.b=DsVAAbD1; spf=pass (google.com: domain of alsa-devel-bounces@alsa-project.org designates 77.48.224.243 as permitted sender) smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 6E3EA267193; Mon, 9 Oct 2017 10:49:54 +0200 (CEST) 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 20856267193; Mon, 9 Oct 2017 10:49:53 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mail1.perex.cz X-Spam-Level: X-Spam-Status: No, score=0.7 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, SPF_NEUTRAL autolearn=disabled version=3.4.0 Received: from heliosphere.sirena.org.uk (heliosphere.sirena.org.uk [172.104.155.198]) by alsa0.perex.cz (Postfix) with ESMTP id A6BCA267121 for ; Mon, 9 Oct 2017 10:49:50 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sirena.org.uk; s=20170815-heliosphere; h=Date:Message-Id:In-Reply-To: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:References: List-Id:List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner: List-Archive; bh=v2fPbs7bshw01RmFqRuE8ps+8p+ramW5CCKe/Lczv0w=; b=DsVAAbD1DyOT xSCzNxmbP6IQ5/+sCO8sktLAMn3L8hg4zf2Pz2n2zdlynh4aKEYXLNOjwFSAP3mAkX+6wSEP1IgS2 hbk78w2A7Q9RpmnuMpRjsuvW80ZeNfOLgLHDNJ75S3oTp2H9sR41TdAGTnLhwCz3N4qeX2tZjIiJN YGPkw=; Received: from debutante.sirena.org.uk ([2001:470:1f1d:6b5::3] helo=debutante) by heliosphere.sirena.org.uk with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1e1Tkz-0000dU-6F; Mon, 09 Oct 2017 08:49:49 +0000 Received: from broonie by debutante with local (Exim 4.89) (envelope-from ) id 1e1Tky-0006MC-Q5; Mon, 09 Oct 2017 09:49:48 +0100 From: Mark Brown To: Ed Blake In-Reply-To: <20171006145355.13616-3-ed.blake@sondrel.com> Message-Id: Date: Mon, 09 Oct 2017 09:49:48 +0100 Cc: alsa-devel@alsa-project.org, broonie@kernel.org, lgirdwood@gmail.com Subject: [alsa-devel] Applied "ASoC: img-spdif-in: Add runtime PM" to the asoc tree 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 The patch ASoC: img-spdif-in: Add runtime PM has been applied to the asoc tree at git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted. You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed. If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced. Please add any relevant lists and maintainers to the CCs when replying to this mail. Thanks, Mark >From 1fac824f0c4fe05924243830fa3b44a5ad0869c7 Mon Sep 17 00:00:00 2001 From: Ed Blake Date: Fri, 6 Oct 2017 15:53:55 +0100 Subject: [PATCH] ASoC: img-spdif-in: Add runtime PM Add runtime PM to disable the clock when the device is not in use. The ASoC core takes care of the pm_runtime_get_sync / put calls so we just need to provide runtime_suspend / runtime_resume functions and enable runtime PM. Signed-off-by: Ed Blake Signed-off-by: Mark Brown --- sound/soc/img/img-spdif-in.c | 79 ++++++++++++++++++++++++++++++++++++-------- 1 file changed, 65 insertions(+), 14 deletions(-) -- 2.14.1 _______________________________________________ Alsa-devel mailing list Alsa-devel@alsa-project.org http://mailman.alsa-project.org/mailman/listinfo/alsa-devel diff --git a/sound/soc/img/img-spdif-in.c b/sound/soc/img/img-spdif-in.c index be5a64a44252..cedd40c8d1f3 100644 --- a/sound/soc/img/img-spdif-in.c +++ b/sound/soc/img/img-spdif-in.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include @@ -89,6 +90,29 @@ struct img_spdif_in { unsigned int aclkgen_regs[IMG_SPDIF_IN_NUM_ACLKGEN]; }; +static int img_spdif_in_runtime_suspend(struct device *dev) +{ + struct img_spdif_in *spdif = dev_get_drvdata(dev); + + clk_disable_unprepare(spdif->clk_sys); + + return 0; +} + +static int img_spdif_in_runtime_resume(struct device *dev) +{ + struct img_spdif_in *spdif = dev_get_drvdata(dev); + int ret; + + ret = clk_prepare_enable(spdif->clk_sys); + if (ret) { + dev_err(dev, "Unable to enable sys clock\n"); + return ret; + } + + return 0; +} + static inline void img_spdif_in_writel(struct img_spdif_in *spdif, u32 val, u32 reg) { @@ -725,15 +749,21 @@ static int img_spdif_in_probe(struct platform_device *pdev) return PTR_ERR(spdif->clk_sys); } - ret = clk_prepare_enable(spdif->clk_sys); - if (ret) - return ret; + pm_runtime_enable(&pdev->dev); + if (!pm_runtime_enabled(&pdev->dev)) { + ret = img_spdif_in_runtime_resume(&pdev->dev); + if (ret) + goto err_pm_disable; + } + ret = pm_runtime_get_sync(&pdev->dev); + if (ret < 0) + goto err_suspend; rst = devm_reset_control_get_exclusive(&pdev->dev, "rst"); if (IS_ERR(rst)) { if (PTR_ERR(rst) == -EPROBE_DEFER) { ret = -EPROBE_DEFER; - goto err_clk_disable; + goto err_pm_put; } dev_dbg(dev, "No top level reset found\n"); img_spdif_in_writel(spdif, IMG_SPDIF_IN_SOFT_RESET_MASK, @@ -761,28 +791,35 @@ static int img_spdif_in_probe(struct platform_device *pdev) IMG_SPDIF_IN_CTL_TRK_MASK; img_spdif_in_writel(spdif, reg, IMG_SPDIF_IN_CTL); + pm_runtime_put(&pdev->dev); + ret = devm_snd_soc_register_component(&pdev->dev, &img_spdif_in_component, &img_spdif_in_dai, 1); if (ret) - goto err_clk_disable; + goto err_suspend; ret = devm_snd_dmaengine_pcm_register(&pdev->dev, NULL, 0); if (ret) - goto err_clk_disable; + goto err_suspend; return 0; -err_clk_disable: - clk_disable_unprepare(spdif->clk_sys); +err_pm_put: + pm_runtime_put(&pdev->dev); +err_suspend: + if (!pm_runtime_enabled(&pdev->dev)) + img_spdif_in_runtime_suspend(&pdev->dev); +err_pm_disable: + pm_runtime_disable(&pdev->dev); return ret; } static int img_spdif_in_dev_remove(struct platform_device *pdev) { - struct img_spdif_in *spdif = platform_get_drvdata(pdev); - - clk_disable_unprepare(spdif->clk_sys); + pm_runtime_disable(&pdev->dev); + if (!pm_runtime_status_suspended(&pdev->dev)) + img_spdif_in_runtime_suspend(&pdev->dev); return 0; } @@ -791,11 +828,18 @@ static int img_spdif_in_dev_remove(struct platform_device *pdev) static int img_spdif_in_suspend(struct device *dev) { struct img_spdif_in *spdif = dev_get_drvdata(dev); + int ret; + + if (pm_runtime_status_suspended(dev)) { + ret = img_spdif_in_runtime_resume(dev); + if (ret) + return ret; + } spdif->suspend_clkgen = img_spdif_in_readl(spdif, IMG_SPDIF_IN_CLKGEN); spdif->suspend_ctl = img_spdif_in_readl(spdif, IMG_SPDIF_IN_CTL); - clk_disable_unprepare(spdif->clk_sys); + img_spdif_in_runtime_suspend(dev); return 0; } @@ -803,9 +847,11 @@ static int img_spdif_in_suspend(struct device *dev) static int img_spdif_in_resume(struct device *dev) { struct img_spdif_in *spdif = dev_get_drvdata(dev); - int i; + int i, ret; - clk_prepare_enable(spdif->clk_sys); + ret = img_spdif_in_runtime_resume(dev); + if (ret) + return ret; for (i = 0; i < IMG_SPDIF_IN_NUM_ACLKGEN; i++) img_spdif_in_aclkgen_writel(spdif, i); @@ -813,6 +859,9 @@ static int img_spdif_in_resume(struct device *dev) img_spdif_in_writel(spdif, spdif->suspend_clkgen, IMG_SPDIF_IN_CLKGEN); img_spdif_in_writel(spdif, spdif->suspend_ctl, IMG_SPDIF_IN_CTL); + if (pm_runtime_status_suspended(dev)) + img_spdif_in_runtime_suspend(dev); + return 0; } #endif @@ -824,6 +873,8 @@ static const struct of_device_id img_spdif_in_of_match[] = { MODULE_DEVICE_TABLE(of, img_spdif_in_of_match); static const struct dev_pm_ops img_spdif_in_pm_ops = { + SET_RUNTIME_PM_OPS(img_spdif_in_runtime_suspend, + img_spdif_in_runtime_resume, NULL) SET_SYSTEM_SLEEP_PM_OPS(img_spdif_in_suspend, img_spdif_in_resume) };