From patchwork Thu Feb 9 03:12:58 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoyou Xie X-Patchwork-Id: 9563953 X-Patchwork-Delegate: sboyd@codeaurora.org Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 14A7A60234 for ; Thu, 9 Feb 2017 03:13:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 54AF628522 for ; Thu, 9 Feb 2017 03:13:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 48E052853A; Thu, 9 Feb 2017 03:13:58 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, HK_RANDOM_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 173D728522 for ; Thu, 9 Feb 2017 03:13:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751599AbdBIDNz (ORCPT ); Wed, 8 Feb 2017 22:13:55 -0500 Received: from mail-pf0-f171.google.com ([209.85.192.171]:34859 "EHLO mail-pf0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751600AbdBIDNx (ORCPT ); Wed, 8 Feb 2017 22:13:53 -0500 Received: by mail-pf0-f171.google.com with SMTP id f144so46463444pfa.2 for ; Wed, 08 Feb 2017 19:13:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=3kykv4ZJ0eTmGj31OAndn2ptFgeQ0jsTLvYkb6C68Fo=; b=SSRvYL9mugj2dbcV3bWkCbWjx+2OSgMRCZIW6fUvmwVjr7XBezEShBdGhYdlgnBSWd klqG6c//Q1QWYZwjxXjl14UmKHgAmHfYMKFCTmIcjTXU6tIflpYvOswVGVWgKItPL1Fb uCHGdPs8FbVKMhr2njWY8pWE+sC/yf1JCsGx0= 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; bh=3kykv4ZJ0eTmGj31OAndn2ptFgeQ0jsTLvYkb6C68Fo=; b=k9Uyqe17SQm40FYdart4duc4VRsRa8YBWaD+sgsiKOYlZnrlf5WbzNSEfgpKFUypUi ejiJZOG6+EqlGDh0HkhODTybbz655Qv34MljcOHIJ6qBuR4m/vJnd6oDjVmWsbugk8oV e4MfhZZnNIa3gnWL76GkwndfAh/J/qppZnkkjUQXFLDBUbDJIpqmBvvPWFso1AOCsaeq 5UFK4xM6EmFnmGWaFbWkraPEwMutB/DysNukMlg5NePYI/dpEPYzTssdzW2YO0jpQn9U IkYwqw/5jwHwvaE38i1P4C/ISksirx0hQ3F/vaDGhnODKJ7c9wUKV7KIO1l1FExJd6MD RFNw== X-Gm-Message-State: AMke39m9vk78x13fsonT92TSLYfu1dBd7kZwp4lP8hrt6o7cJC79/IWTx1rUg5m9zLEETQQA X-Received: by 10.98.34.82 with SMTP id i79mr1115954pfi.120.1486610032913; Wed, 08 Feb 2017 19:13:52 -0800 (PST) Received: from localhost.localdomain ([104.237.91.118]) by smtp.gmail.com with ESMTPSA id c74sm23767201pfc.1.2017.02.08.19.13.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 08 Feb 2017 19:13:52 -0800 (PST) From: Baoyou Xie To: lgirdwood@gmail.com, broonie@kernel.org, robh+dt@kernel.org, mark.rutland@arm.com, jun.nie@linaro.org, baoyou.xie@linaro.org, mturquette@baylibre.com, sboyd@codeaurora.org, perex@perex.cz, tiwai@suse.com, shawn.guo@linaro.org, vinod.koul@intel.com Cc: alsa-devel@alsa-project.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-clk@vger.kernel.org, shawnguo@kernel.org, mathieu.poirier@linaro.org, xie.baoyou@zte.com.cn, chen.chaokai@zte.com.cn, wang.qiang01@zte.com.cn Subject: [PATCH v4 3/3] ASoC: zx-i2s: introduce pclk for zx2967 family Date: Thu, 9 Feb 2017 11:12:58 +0800 Message-Id: <1486609978-18482-3-git-send-email-baoyou.xie@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1486609978-18482-1-git-send-email-baoyou.xie@linaro.org> References: <1486609978-18482-1-git-send-email-baoyou.xie@linaro.org> Sender: linux-clk-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-clk@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The pclk is necessary for zx2967 I2S controller. the driver currently doesn't handle it. This is something we need to fix. In turn, the driver supports zx296718's I2S controller. By the way, this patch also change the clock name from tx to wclk to make it clear. Signed-off-by: Baoyou Xie Reviewed-by: Shawn Guo Reviewed-by: Jun Nie --- sound/soc/zte/zx-i2s.c | 38 +++++++++++++++++++++++++++++--------- 1 file changed, 29 insertions(+), 9 deletions(-) diff --git a/sound/soc/zte/zx-i2s.c b/sound/soc/zte/zx-i2s.c index ed7a56d..a865f37 100644 --- a/sound/soc/zte/zx-i2s.c +++ b/sound/soc/zte/zx-i2s.c @@ -95,7 +95,8 @@ struct zx_i2s_info { struct snd_dmaengine_dai_dma_data dma_playback; struct snd_dmaengine_dai_dma_data dma_capture; - struct clk *dai_clk; + struct clk *dai_wclk; + struct clk *dai_pclk; void __iomem *reg_base; int master; resource_size_t mapbase; @@ -275,8 +276,9 @@ static int zx_i2s_hw_params(struct snd_pcm_substream *substream, writel_relaxed(val, i2s->reg_base + ZX_I2S_TIMING_CTRL); if (i2s->master) - ret = clk_set_rate(i2s->dai_clk, - params_rate(params) * ch_num * CLK_RAT); + ret = clk_set_rate(i2s->dai_wclk, + params_rate(params) * ch_num * CLK_RAT); + return ret; } @@ -328,8 +330,19 @@ static int zx_i2s_startup(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { struct zx_i2s_info *zx_i2s = dev_get_drvdata(dai->dev); + int ret; + + ret = clk_prepare_enable(zx_i2s->dai_wclk); + if (ret) + return ret; + + ret = clk_prepare_enable(zx_i2s->dai_pclk); + if (ret) { + clk_disable_unprepare(zx_i2s->dai_wclk); + return ret; + } - return clk_prepare_enable(zx_i2s->dai_clk); + return ret; } static void zx_i2s_shutdown(struct snd_pcm_substream *substream, @@ -337,7 +350,8 @@ static void zx_i2s_shutdown(struct snd_pcm_substream *substream, { struct zx_i2s_info *zx_i2s = dev_get_drvdata(dai->dev); - clk_disable_unprepare(zx_i2s->dai_clk); + clk_disable_unprepare(zx_i2s->dai_wclk); + clk_disable_unprepare(zx_i2s->dai_pclk); } static struct snd_soc_dai_ops zx_i2s_dai_ops = { @@ -381,10 +395,16 @@ static int zx_i2s_probe(struct platform_device *pdev) if (!zx_i2s) return -ENOMEM; - zx_i2s->dai_clk = devm_clk_get(&pdev->dev, "tx"); - if (IS_ERR(zx_i2s->dai_clk)) { - dev_err(&pdev->dev, "Fail to get clk\n"); - return PTR_ERR(zx_i2s->dai_clk); + zx_i2s->dai_wclk = devm_clk_get(&pdev->dev, "wclk"); + if (IS_ERR(zx_i2s->dai_wclk)) { + dev_err(&pdev->dev, "Fail to get wclk\n"); + return PTR_ERR(zx_i2s->dai_wclk); + } + + zx_i2s->dai_pclk = devm_clk_get(&pdev->dev, "pclk"); + if (IS_ERR(zx_i2s->dai_pclk)) { + dev_err(&pdev->dev, "Fail to get pclk\n"); + return PTR_ERR(zx_i2s->dai_pclk); } res = platform_get_resource(pdev, IORESOURCE_MEM, 0);