From patchwork Mon Feb 6 13:50:19 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoyou Xie X-Patchwork-Id: 93432 Delivered-To: patch@linaro.org Received: by 10.182.3.34 with SMTP id 2csp1783082obz; Mon, 6 Feb 2017 05:52:16 -0800 (PST) X-Received: by 10.84.225.148 with SMTP id u20mr17264714plj.93.1486389136245; Mon, 06 Feb 2017 05:52:16 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 96si764337plz.28.2017.02.06.05.52.15; Mon, 06 Feb 2017 05:52:16 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753487AbdBFNwH (ORCPT + 25 others); Mon, 6 Feb 2017 08:52:07 -0500 Received: from mail-pg0-f52.google.com ([74.125.83.52]:36646 "EHLO mail-pg0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752490AbdBFNwD (ORCPT ); Mon, 6 Feb 2017 08:52:03 -0500 Received: by mail-pg0-f52.google.com with SMTP id v184so28925303pgv.3 for ; Mon, 06 Feb 2017 05:52:03 -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=GNi5Sn/HaiUAW0YxukUyQEI9PK0pLQMFUbP+WdCDTG0=; b=QUlyxowlpNcLLSvl16/GKAlJCSlAAvFbvAGmANEkqp6bvx3nSthEKdWUbi8cZkm9li ao0efyafXxH3RiaGsN7BF6b1kqsxVhsIVgvgkZi1Apmkz20GyHUPl//0/GJMyLoDFvwr fZCcStIsPk6ti4UNaxreAHb2sRMtF6Akp7HdM= 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=GNi5Sn/HaiUAW0YxukUyQEI9PK0pLQMFUbP+WdCDTG0=; b=HbITc6nHp2uy3Cy3xLrO1ePlLR8ciQad6oSWOVN9x7xk0MVB7+l97z5AjwzG2dK/kT ic/sj5nuIntQDVY6KbTVeA4C3RZZIvc/IMdcgnuCxeXN8NT8EZVVhRtcSpUFpMrjLKZT CRDZ1i1O2o+1sX3xpVYX8lGBeA8gGO9VMSHQBmgO1zGDJ0H3nfxQgiVDi2VKFtNtY3Or VJo4hHyezlOUQUfWfepWfFHUGZwUHiCtmvePSvXfJzWjra+9uTuLDxdzUPgUw9c+MUq8 hAQoUVjby+a2Tqf/fkWTX4c07MnhMThV5JeuAwYeVbgi+ueGWTeDycQeTnqvRh9/WQ+C DR9Q== X-Gm-Message-State: AIkVDXISw8n+ABpIpquqbC5TYjuiAYOgmf58lE6oG+m1VZkU17kFm4vlHd1hcSxdXj5pq7xU X-Received: by 10.84.143.195 with SMTP id 61mr17623571plz.46.1486389123047; Mon, 06 Feb 2017 05:52:03 -0800 (PST) Received: from localhost.localdomain ([104.237.91.232]) by smtp.gmail.com with ESMTPSA id g28sm3130054pgn.3.2017.02.06.05.51.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 06 Feb 2017 05:52:02 -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 v1 2/3] dt: Document for the ZTE zx296718 I2S controller Date: Mon, 6 Feb 2017 21:50:19 +0800 Message-Id: <1486389020-29432-2-git-send-email-baoyou.xie@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1486389020-29432-1-git-send-email-baoyou.xie@linaro.org> References: <1486389020-29432-1-git-send-email-baoyou.xie@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch documents the devicetree for the ZTE's zx296718 I2S audio controller. Signed-off-by: Baoyou Xie --- Documentation/devicetree/bindings/sound/zte,zx-i2s.txt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) -- 2.7.4 diff --git a/Documentation/devicetree/bindings/sound/zte,zx-i2s.txt b/Documentation/devicetree/bindings/sound/zte,zx-i2s.txt index 7e5aa6f..c405561 100644 --- a/Documentation/devicetree/bindings/sound/zte,zx-i2s.txt +++ b/Documentation/devicetree/bindings/sound/zte,zx-i2s.txt @@ -1,10 +1,12 @@ ZTE ZX296702 I2S controller Required properties: - - compatible : Must be "zte,zx296702-i2s" + - compatible : Should include one of the following strings: + "zte,zx296702-i2s","zte,zx296718-i2s". - reg : Must contain I2S core's registers location and length - clocks : Pairs of phandle and specifier referencing the controller's clocks. - - clock-names: "tx" for the clock to the I2S interface. + - clock-names: "tx" for the wclk, "pclk" for the pclk to the I2S interface. + must contain pclk for zx296718 SoC. - dmas: Pairs of phandle and specifier for the DMA channel that is used by the core. The core expects two dma channels for transmit. - dma-names : Must be "tx" and "rx" From patchwork Mon Feb 6 13:50:20 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoyou Xie X-Patchwork-Id: 93433 Delivered-To: patch@linaro.org Received: by 10.182.3.34 with SMTP id 2csp1783315obz; Mon, 6 Feb 2017 05:52:49 -0800 (PST) X-Received: by 10.99.95.16 with SMTP id t16mr13464686pgb.212.1486389169853; Mon, 06 Feb 2017 05:52:49 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 96si764337plz.28.2017.02.06.05.52.49; Mon, 06 Feb 2017 05:52:49 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753539AbdBFNwr (ORCPT + 25 others); Mon, 6 Feb 2017 08:52:47 -0500 Received: from mail-pf0-f171.google.com ([209.85.192.171]:32796 "EHLO mail-pf0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752333AbdBFNwp (ORCPT ); Mon, 6 Feb 2017 08:52:45 -0500 Received: by mail-pf0-f171.google.com with SMTP id y143so24456883pfb.0 for ; Mon, 06 Feb 2017 05:52:40 -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=WUE9OZfOJMRykY4t2XelD4dXtMR5QXU1pCuBesd/sQA=; b=MTKt4X0Z9nPDrmpk/OG0CmaFY90N1RXoyQwHignP7Joy7SmN2wf3tA+6Q7gwpJXdEa lNlzvGaQn/cwjB2jHOrN9KPeKSRN1Nm8DY3tZych7fSKPCuinBIZlNZ9M5IZvJrgsJBp QhQKFb1J/od8tBWICuGXe4t1hSMwghkEZRSK4= 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=WUE9OZfOJMRykY4t2XelD4dXtMR5QXU1pCuBesd/sQA=; b=H1rpS37Pt1ZmRoiGeiaX1wmeu1wmwOyFaoyc4OxWPTXDqHN6az0jrgDs4I5rUwGTf8 qntT++m0ZsgoOQtHMsrTkolI3iTiA373KLtR8KVnrqZTEL9MbtJKDbYgdlJLUvJun+XW t05VMRrQA1X3pqf/d943KZE0o9Eifwk47gafzgVfv7dEjMCTx1C/UkGE7aH0/Hz9JNuX o/vnG50XvQdgUChc2UzEJvL896yPQUD9duQ0X3ACZpZADpj9+t3hY1ze0eTuxE1qYplG +awA1sG2kdO6bnBeRNJpJIflJ+6+/Ijj6a5f39klBybQ0gpoQHkVSJJLSZHOwPxU/dGY Lxnw== X-Gm-Message-State: AIkVDXKhFWLvEeZKkxc/wituwHI7YYI+2ww+cXtfTsg559LH/Vwb6OroM8vmFcEw7c3e49JB X-Received: by 10.84.151.9 with SMTP id i9mr8859657pli.122.1486389159847; Mon, 06 Feb 2017 05:52:39 -0800 (PST) Received: from localhost.localdomain ([104.237.91.232]) by smtp.gmail.com with ESMTPSA id g28sm3130054pgn.3.2017.02.06.05.52.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 06 Feb 2017 05:52:39 -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 v1 3/3] ASoC: zx-i2s: support zx296718 SoC for ZTE's i2s controller driver Date: Mon, 6 Feb 2017 21:50:20 +0800 Message-Id: <1486389020-29432-3-git-send-email-baoyou.xie@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1486389020-29432-1-git-send-email-baoyou.xie@linaro.org> References: <1486389020-29432-1-git-send-email-baoyou.xie@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch adds zx296718 SoC support for ZTE's i2s controller driver. Signed-off-by: Baoyou Xie --- sound/soc/zte/zx-i2s.c | 49 ++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 40 insertions(+), 9 deletions(-) -- 2.7.4 diff --git a/sound/soc/zte/zx-i2s.c b/sound/soc/zte/zx-i2s.c index ed7a56d..68d590be 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; @@ -218,6 +219,17 @@ static int zx_i2s_set_fmt(struct snd_soc_dai *cpu_dai, unsigned int fmt) return 0; } +static void zx_i2s_set_clk(struct zx_i2s_info *i2s, + unsigned int ch_num, unsigned int sample_rate) +{ + unsigned long val = sample_rate * ch_num * CLK_RAT; + + clk_set_rate(i2s->dai_wclk, val); + + if (i2s->dai_pclk) + clk_set_rate(i2s->dai_pclk, val); +} + static int zx_i2s_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *socdai) @@ -275,8 +287,8 @@ 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); + zx_i2s_set_clk(i2s, ch_num, params_rate(params)); + return ret; } @@ -328,8 +340,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 +360,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 +405,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 +444,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);