From patchwork Fri Aug 4 10:58:17 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Sylwester Nawrocki/Kernel \\(PLT\\) /SRPOL/Staff Engineer/Samsung Electronics" X-Patchwork-Id: 9880991 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 D5991603B4 for ; Fri, 4 Aug 2017 10:59:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CDBBD289BC for ; Fri, 4 Aug 2017 10:59:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C2646289D3; Fri, 4 Aug 2017 10:59:42 +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=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI 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 AB631289C6 for ; Fri, 4 Aug 2017 10:59:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752213AbdHDK66 (ORCPT ); Fri, 4 Aug 2017 06:58:58 -0400 Received: from mailout1.samsung.com ([203.254.224.24]:24964 "EHLO mailout1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752211AbdHDK64 (ORCPT ); Fri, 4 Aug 2017 06:58:56 -0400 Received: from epcas2p4.samsung.com (unknown [182.195.41.56]) by mailout1.samsung.com (KnoxPortal) with ESMTP id 20170804105855epoutp01e3aa7f84d770b56cfb068612b30ca2cc~Xn3cxKYP90166301663epoutp01P; Fri, 4 Aug 2017 10:58:55 +0000 (GMT) Received: from epsmges2p3.samsung.com (unknown [182.195.42.71]) by epcas2p3.samsung.com (KnoxPortal) with ESMTP id 20170804105854epcas2p34acc041949302e84e61ec03d05dc0b3a~Xn3cp4SAt2154521545epcas2p3Z; Fri, 4 Aug 2017 10:58:54 +0000 (GMT) Received: from epcas2p1.samsung.com ( [182.195.41.53]) by epsmges2p3.samsung.com (Symantec Messaging Gateway) with SMTP id 15.75.14130.E6354895; Fri, 4 Aug 2017 19:58:54 +0900 (KST) Received: from epsmgms2p2.samsung.com (unknown [182.195.42.80]) by epcas2p3.samsung.com (KnoxPortal) with ESMTP id 20170804105854epcas2p30ed120bc4bcb51979a880f44ffe3aca6~Xn3cDAZ262154921549epcas2p3Z; Fri, 4 Aug 2017 10:58:54 +0000 (GMT) X-AuditID: b6c32a47-f79db6d000003732-ce-5984536e0d1a Received: from epmmp1.local.host ( [203.254.227.16]) by epsmgms2p2.samsung.com (Symantec Messaging Gateway) with SMTP id 41.E1.09541.E6354895; Fri, 4 Aug 2017 19:58:54 +0900 (KST) Received: from AMDC3061.digital.local ([106.116.147.40]) by mmp1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0OU500FJ7QH8K4D0@mmp1.samsung.com>; Fri, 04 Aug 2017 19:58:54 +0900 (KST) From: Sylwester Nawrocki To: broonie@kernel.org, lgirdwood@gmail.com Cc: devicetree@vger.kernel.org, robh+dt@kernel.org, krzk@kernel.org, linux-samsung-soc@vger.kernel.org, b.zolnierkie@samsung.com, alsa-devel@alsa-project.org, Sylwester Nawrocki Subject: [PATCH] ASoC: samsung: odroid: Drop requirement of clocks in the sound node Date: Fri, 04 Aug 2017 12:58:17 +0200 Message-id: <1501844297-22842-1-git-send-email-s.nawrocki@samsung.com> X-Mailer: git-send-email 1.9.1 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrFIsWRmVeSWpSXmKPExsWy7bCmqW5ecEukwbp+U4srFw8xWWycsZ7V YurDJ2wW84+cY7U4f34Du8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0LAROLfxTssELaYxIV7 69m6GLk4hAS2MUosOdbIBOH8YpRYfHUiWBWbgKFE79E+RhBbREBbYs7NDrAOZoFzjBJtb1+y giSEBcIkPu+/CdbAIqAqcexoN5jNK+AmsX/iZqh1chInj01mncDIvYCRYRWjWGpBcW56brFR gZFecWJucWleul5yfu4mRmDYbjusFbCDselc9CFGAQ5GJR5egxnNkUKsiWXFlbmHGCU4mJVE eE8FtUQK8aYkVlalFuXHF5XmpBYfYjQFWj+RWUo0OR8YU3kl8YYmlkYmBmZmhkYGxmZK4rwT Ar9ECAmkJ5akZqemFqQWwfQxcXBKNTDu2/T8hP6x3RzhxV0GDMfKfy1zf+q3WUc35+7jfp5a Y8Xrfzt3RJdfOfr9ZUbl5CVfKk5V/7+5fgPrpL5M/7l/73MfO60nyfDE4MnXpdYyW6z4mCbH pc18fn9BsMvnv//LpeI43ZR1yo8lGp9QrndcsG1p0I/j53YuEfhaUfgmVLiL/X6Hq9VLJZbi jERDLeai4kQAfNnhtXECAAA= X-MTR: 20000000000000000@CPGS X-CMS-MailID: 20170804105854epcas2p30ed120bc4bcb51979a880f44ffe3aca6 X-Msg-Generator: CA X-Sender-IP: 182.195.42.80 X-Local-Sender: =?UTF-8?B?U3lsd2VzdGVyIE5hd3JvY2tpG1NSUE9MLUtlcm5lbCAoVFAp?= =?UTF-8?B?G+yCvOyEseyghOyekBtTZW5pb3IgU29mdHdhcmUgRW5naW5lZXI=?= X-Global-Sender: =?UTF-8?B?U3lsd2VzdGVyIE5hd3JvY2tpG1NSUE9MLUtlcm5lbCAoVFAp?= =?UTF-8?B?G1NhbXN1bmcgRWxlY3Ryb25pY3MbU2VuaW9yIFNvZnR3YXJlIEVuZ2luZWVy?= X-Sender-Code: =?UTF-8?B?QzEwG0VIURtDMTBDRDAyQ0QwMjczOTI=?= CMS-TYPE: 102P X-CMS-RootMailID: 20170804105854epcas2p30ed120bc4bcb51979a880f44ffe3aca6 X-RootMTR: 20170804105854epcas2p30ed120bc4bcb51979a880f44ffe3aca6 References: Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP As suggested in reviews the requirement of clocks in the 'sound' node is dropped and instead a leaf clock is used to configure frequency of the audio root clock PLL. This can work now after the clock tree definitions have been updated to allow clock rate setting propagation on the path from the I2S controller up to the EPLL. This patch also lowers the CODEC master clock frequency so as to not exceed the maximum allowed 60 MHz at maximum audio sampling rates. Signed-off-by: Sylwester Nawrocki Acked-by: Krzysztof Kozlowski --- .../devicetree/bindings/sound/samsung,odroid.txt | 6 --- sound/soc/samsung/odroid.c | 44 +++++++++++++++------- 2 files changed, 30 insertions(+), 20 deletions(-) diff --git a/Documentation/devicetree/bindings/sound/samsung,odroid.txt b/Documentation/devicetree/bindings/sound/samsung,odroid.txt index c30934d..625b1b1 100644 --- a/Documentation/devicetree/bindings/sound/samsung,odroid.txt +++ b/Documentation/devicetree/bindings/sound/samsung,odroid.txt @@ -7,9 +7,6 @@ Required properties: - model - the user-visible name of this sound complex - clocks - should contain entries matching clock names in the clock-names property - - clock-names - should contain following entries: - - "epll" - indicating the EPLL output clock - - "i2s_rclk" - indicating the RCLK (root) clock of the I2S0 controller - samsung,audio-widgets - this property specifies off-codec audio elements like headphones or speakers, for details see widgets.txt - samsung,audio-routing - a list of the connections between audio @@ -46,9 +43,6 @@ sound { "IN1", "Mic Jack", "Mic Jack", "MICBIAS"; - clocks = <&clock CLK_FOUT_EPLL>, <&i2s0 CLK_I2S_RCLK_SRC>; - clock-names = "epll", "sclk_i2s"; - cpu { sound-dai = <&i2s0 0>; }; diff --git a/sound/soc/samsung/odroid.c b/sound/soc/samsung/odroid.c index 0834319..44b6de5 100644 --- a/sound/soc/samsung/odroid.c +++ b/sound/soc/samsung/odroid.c @@ -19,8 +19,8 @@ struct odroid_priv { struct snd_soc_card card; struct snd_soc_dai_link dai_link; - struct clk *pll; - struct clk *rclk; + struct clk *clk_i2s_bus; + struct clk *sclk_i2s; }; static int odroid_card_startup(struct snd_pcm_substream *substream) @@ -58,13 +58,18 @@ static int odroid_card_hw_params(struct snd_pcm_substream *substream, return -EINVAL; } - ret = clk_set_rate(priv->pll, pll_freq + 1); + ret = clk_set_rate(priv->clk_i2s_bus, pll_freq / 2 + 1); if (ret < 0) return ret; - rclk_freq = params_rate(params) * 256 * 4; + /* + * We add 1 to the rclk_freq value in order to avoid too low clock + * frequency values due to the EPLL output frequency not being exact + * multiple of the audio sampling rate. + */ + rclk_freq = params_rate(params) * 256 + 1; - ret = clk_set_rate(priv->rclk, rclk_freq); + ret = clk_set_rate(priv->sclk_i2s, rclk_freq); if (ret < 0) return ret; @@ -118,14 +123,6 @@ static int odroid_audio_probe(struct platform_device *pdev) snd_soc_card_set_drvdata(card, priv); - priv->pll = devm_clk_get(dev, "epll"); - if (IS_ERR(priv->pll)) - return PTR_ERR(priv->pll); - - priv->rclk = devm_clk_get(dev, "i2s_rclk"); - if (IS_ERR(priv->rclk)) - return PTR_ERR(priv->rclk); - ret = snd_soc_of_parse_card_name(card, "model"); if (ret < 0) return ret; @@ -171,14 +168,31 @@ static int odroid_audio_probe(struct platform_device *pdev) link->name = "Primary"; link->stream_name = link->name; + + priv->sclk_i2s = of_clk_get_by_name(link->cpu_of_node, "i2s_opclk1"); + if (IS_ERR(priv->sclk_i2s)) { + ret = PTR_ERR(priv->sclk_i2s); + goto err_put_i2s_n; + } + + priv->clk_i2s_bus = of_clk_get_by_name(link->cpu_of_node, "iis"); + if (IS_ERR(priv->clk_i2s_bus)) { + ret = PTR_ERR(priv->clk_i2s_bus); + goto err_put_sclk; + } + ret = devm_snd_soc_register_card(dev, card); if (ret < 0) { dev_err(dev, "snd_soc_register_card() failed: %d\n", ret); - goto err_put_i2s_n; + goto err_put_clk_i2s; } return 0; +err_put_clk_i2s: + clk_put(priv->clk_i2s_bus); +err_put_sclk: + clk_put(priv->sclk_i2s); err_put_i2s_n: of_node_put(link->cpu_of_node); err_put_codec_n: @@ -192,6 +206,8 @@ static int odroid_audio_remove(struct platform_device *pdev) of_node_put(priv->dai_link.cpu_of_node); odroid_put_codec_of_nodes(&priv->dai_link); + clk_put(priv->sclk_i2s); + clk_put(priv->clk_i2s_bus); return 0; }