From patchwork Tue Feb 7 03:02:51 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoyou Xie X-Patchwork-Id: 9559127 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 5F7E8604DC for ; Tue, 7 Feb 2017 03:03:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 51FFC205FD for ; Tue, 7 Feb 2017 03:03:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 44B3427FC0; Tue, 7 Feb 2017 03:03: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.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, HK_RANDOM_FROM,RCVD_IN_DNSWL_HI,RCVD_IN_SORBS_SPAM,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 DEB70205FD for ; Tue, 7 Feb 2017 03:03:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752866AbdBGDD5 (ORCPT ); Mon, 6 Feb 2017 22:03:57 -0500 Received: from mail-pf0-f182.google.com ([209.85.192.182]:32791 "EHLO mail-pf0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752838AbdBGDDu (ORCPT ); Mon, 6 Feb 2017 22:03:50 -0500 Received: by mail-pf0-f182.google.com with SMTP id y143so28976085pfb.0 for ; Mon, 06 Feb 2017 19:03:50 -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=3FNjxO+bJhRO4M77bl4TnnJMWdzr2D8rV6YifrS7Ysc=; b=hyn+TiLSi7weynItpwqwRBW75EF4zflhFZ34yDotWpDs8znYWOMukNKNFJCdBgV3PL 6j8MhJwKErm5MuDctSy8Yhp2B77CqDrPBpAkfDWWaqIC6VgB2smeCCrT00GltwiRkwd+ CiYU1Om824jlXK8MD+qo7aUpaoGPeLrpa3b70= 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=3FNjxO+bJhRO4M77bl4TnnJMWdzr2D8rV6YifrS7Ysc=; b=NU7fICKQQhmoWvuo1QRRscz5VVgQ81z8LAOKBMFoqzo3CGmnEJGNSNOHx6QSCmGSJb DJAQdfFb7tSMMyBartXMlkNEAHN6llu1flMxyQNGMugwQYpFBz8IPiDdxkBdadm7YUh+ cAM+LSJILxItqZBHvITSDgQ8MVqjircitVB7faP/SjzIQ4izd1osQVpusuGLeDBjuRNb aEnxg630/uWHLApuN1kMeX5/TTQWq8ubCaIbi9r0a520BEVuTxwdk4h1JIPDVz5G8Sx9 373iTNsB0mVH/zEMD/w/CftbkIYWKCBDoOZF7N+dBRRCbB5n9zFlb0MSuccqQGyI7Y6x vmyg== X-Gm-Message-State: AIkVDXJaw4eEu3emkM8whJQYqw9kpQCcwQwPxyZTJkdrvt2WNyHnlc4mKierS93RjqxRNWWE X-Received: by 10.84.225.20 with SMTP id t20mr22663551plj.154.1486436629426; Mon, 06 Feb 2017 19:03:49 -0800 (PST) Received: from localhost.localdomain ([45.56.152.31]) by smtp.gmail.com with ESMTPSA id k76sm5898563pfg.42.2017.02.06.19.03.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 06 Feb 2017 19:03:48 -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, xie.baoyou@zte.com.cn, chen.chaokai@zte.com.cn, wang.qiang01@zte.com.cn Subject: [PATCH v2 3/3] ASoC: zx-i2s: support zx296718 SoC for ZTE's i2s controller driver Date: Tue, 7 Feb 2017 11:02:51 +0800 Message-Id: <1486436571-8682-3-git-send-email-baoyou.xie@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1486436571-8682-1-git-send-email-baoyou.xie@linaro.org> References: <1486436571-8682-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 This patch adds zx296718 SoC support for ZTE's i2s controller driver. Signed-off-by: Baoyou Xie --- sound/soc/zte/zx-i2s.c | 45 +++++++++++++++++++++++++++++++++++---------- 1 file changed, 35 insertions(+), 10 deletions(-) diff --git a/sound/soc/zte/zx-i2s.c b/sound/soc/zte/zx-i2s.c index ed7a56d..2afac69 100644 --- a/sound/soc/zte/zx-i2s.c +++ b/sound/soc/zte/zx-i2s.c @@ -95,12 +95,13 @@ 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, *dai_pclk; void __iomem *reg_base; int master; resource_size_t mapbase; }; + static void zx_i2s_tx_en(void __iomem *base, bool on) { unsigned long val; @@ -274,9 +275,14 @@ static int zx_i2s_hw_params(struct snd_pcm_substream *substream, val |= ZX_I2S_TIMING_CHN(ch_num); 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); + if (i2s->master) { + unsigned long rate = params_rate(params) * ch_num * CLK_RAT; + + ret = clk_set_rate(i2s->dai_wclk, rate); + if (!ret && i2s->dai_pclk) + ret = clk_set_rate(i2s->dai_pclk, rate); + } + return ret; } @@ -328,8 +334,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; - return clk_prepare_enable(zx_i2s->dai_clk); + ret = clk_prepare_enable(zx_i2s->dai_pclk); + if (ret) { + clk_disable_unprepare(zx_i2s->dai_wclk); + return ret; + } + + return ret; } static void zx_i2s_shutdown(struct snd_pcm_substream *substream, @@ -337,7 +354,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 +399,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, "tx"); + 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_info(&pdev->dev, "have no pclk\n"); + zx_i2s->dai_pclk = NULL; } res = platform_get_resource(pdev, IORESOURCE_MEM, 0); @@ -414,6 +438,7 @@ static int zx_i2s_probe(struct platform_device *pdev) static const struct of_device_id zx_i2s_dt_ids[] = { { .compatible = "zte,zx296702-i2s", }, + { .compatible = "zte,zx296718-i2s", }, {} }; MODULE_DEVICE_TABLE(of, zx_i2s_dt_ids);