From patchwork Fri Jan 15 13:49:50 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Caesar Wang X-Patchwork-Id: 8041001 Return-Path: X-Original-To: patchwork-linux-rockchip@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 099F79F859 for ; Fri, 15 Jan 2016 13:51:29 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 296BE203A4 for ; Fri, 15 Jan 2016 13:51:28 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 020E820444 for ; Fri, 15 Jan 2016 13:51:27 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1aK4mk-00055l-Jt; Fri, 15 Jan 2016 13:51:26 +0000 Received: from mail-pf0-f195.google.com ([209.85.192.195]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1aK4mT-0004sz-Dr; Fri, 15 Jan 2016 13:51:12 +0000 Received: by mail-pf0-f195.google.com with SMTP id 65so8573358pfd.1; Fri, 15 Jan 2016 05:50:49 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=FmBKUr505RXd0lCYmx/KyIrNVUgTmArra0INUs9avJM=; b=YrMy50TQHG9jxps68stYdlFYtSdGoLrUHjIzrLI0wn8l+CtJlf2rqVtcXYxSeuw9VE U0tVPg5gbGEbpF8f/Ge45nRUmmxQUOYVVKdjbRekM0ClQGaemjpijHhK0pat+g9fVJC+ iMILtM90Bm02bH6/EIUhnXkUVPH93z5qI5+r+bHICi5BbWowzBwZw1/ZY5GxOsIfNSov qSAai1lZMa8YGNq1xfkzTo1R9ZgN/zx0V6WbwG7V2XpvQAm4QiRB5mENP8RI30J3pJeP auw7K9g3vp6ebOIW8zXrDG8mAKJ40JT7dh5AevaN+GAq9iPtgBE5CqrAeNntbaVkPkpd sNsw== X-Gm-Message-State: ALoCoQkgkmATQxcfRrWV4QIGhAzO8nCfXZS/wMtLlBK2blE7zH75kf8DwFmOc53K4D7kBU3S3RiPIBxW0m71QTGRg5ZTm7eUXw== X-Received: by 10.98.31.210 with SMTP id l79mr15039580pfj.144.1452865848766; Fri, 15 Jan 2016 05:50:48 -0800 (PST) Received: from localhost.localdomain ([103.29.142.67]) by smtp.gmail.com with ESMTPSA id 16sm15811805pfh.48.2016.01.15.05.50.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 15 Jan 2016 05:50:47 -0800 (PST) From: Caesar Wang To: Heiko Stuebner , linux-rockchip@lists.infradead.org Subject: [PATCH v3 3/9] ASoC: rockchip: i2s: add support for grabbing output clock to codec Date: Fri, 15 Jan 2016 21:49:50 +0800 Message-Id: <1452865796-23527-4-git-send-email-wxt@rock-chips.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1452865796-23527-1-git-send-email-wxt@rock-chips.com> References: <1452865796-23527-1-git-send-email-wxt@rock-chips.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160115_055109_714070_6C00B8A8 X-CRM114-Status: GOOD ( 14.13 ) X-Spam-Score: -2.4 (--) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jianqun Xu , linux-kernel@vger.kernel.org, Mark Brown , leozwang@google.com, keescook@google.com, Sonny Rao , linux-arm-kernel@lists.infradead.org, Caesar Wang MIME-Version: 1.0 Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Sonny Rao We need to claim the clock which is driving the codec so that when we enable clock gating, we continue to clock the codec when needed. I make this an optional clock since there might be some applications where we don't need it but can still use the I2S block. Signed-off-by: Sonny Rao Signed-off-by: Jianqun Xu Signed-off-by: Caesar Wang --- Changes in v3: - As the perious discuss on https://patchwork.kernel.org/patch/5427131/, I think Mark likes do it in codec driver, I have to say I agree this patch in here since that's the i2s block output. I don't know if the Mark has changed his mind. - Add the suspend/resume handle the clock. sound/soc/rockchip/rockchip_i2s.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/sound/soc/rockchip/rockchip_i2s.c b/sound/soc/rockchip/rockchip_i2s.c index 58ee645..5889bba 100644 --- a/sound/soc/rockchip/rockchip_i2s.c +++ b/sound/soc/rockchip/rockchip_i2s.c @@ -28,6 +28,7 @@ struct rk_i2s_dev { struct clk *hclk; struct clk *mclk; + struct clk *oclk; struct snd_dmaengine_dai_dma_data capture_dma_data; struct snd_dmaengine_dai_dma_data playback_dma_data; @@ -47,6 +48,9 @@ static int i2s_runtime_suspend(struct device *dev) { struct rk_i2s_dev *i2s = dev_get_drvdata(dev); + if (i2s->oclk) + clk_disable_unprepare(i2s->oclk); + clk_disable_unprepare(i2s->mclk); return 0; @@ -63,6 +67,14 @@ static int i2s_runtime_resume(struct device *dev) return ret; } + if (i2s->oclk) { + ret = clk_prepare_enable(i2s->oclk); + if (ret) { + dev_err(i2s->dev, "oclk enable failed %d\n", ret); + return ret; + } + } + return 0; } @@ -480,6 +492,15 @@ static int rockchip_i2s_probe(struct platform_device *pdev) return PTR_ERR(i2s->mclk); } + i2s->oclk = devm_clk_get(&pdev->dev, "i2s_clk_out"); + if (IS_ERR(i2s->oclk)) { + dev_dbg(&pdev->dev, "Didn't find output clock\n"); + i2s->oclk = NULL; + } + + if (i2s->oclk) + ret = clk_prepare_enable(i2s->oclk); + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); regs = devm_ioremap_resource(&pdev->dev, res); if (IS_ERR(regs)) @@ -552,6 +573,9 @@ static int rockchip_i2s_remove(struct platform_device *pdev) if (!pm_runtime_status_suspended(&pdev->dev)) i2s_runtime_suspend(&pdev->dev); + if (i2s->oclk) + clk_disable_unprepare(i2s->oclk); + clk_disable_unprepare(i2s->mclk); clk_disable_unprepare(i2s->hclk);