From patchwork Tue Mar 19 17:03:22 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Fuzzey X-Patchwork-Id: 2302961 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork2.kernel.org (Postfix) with ESMTP id 55FFEDFB79 for ; Tue, 19 Mar 2013 17:06:40 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1UHzwh-0004Uz-9g; Tue, 19 Mar 2013 17:03:31 +0000 Received: from mta1.parkeon.com ([91.121.43.66]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UHzwc-0004TT-Sh for linux-arm-kernel@lists.infradead.org; Tue, 19 Mar 2013 17:03:27 +0000 Received: from [213.152.31.71] (helo=mta2.parkeon.com) by mta1.parkeon.com with esmtp (Exim 4.76) (envelope-from ) id 1UHzwZ-0004N8-2I; Tue, 19 Mar 2013 18:03:23 +0100 Received: from [10.32.16.23] (helo=mail.besancon.parkeon.com) by mta2.parkeon.com with esmtp (Exim 4.77) (envelope-from ) id 1UHzwV-0000Cf-Rq; Tue, 19 Mar 2013 18:03:19 +0100 Received: from [10.32.51.221] (port=59831 helo=[127.0.0.1]) by mail.besancon.parkeon.com with esmtp (Exim 4.71) (envelope-from ) id 1UHzwY-0001uH-Su; Tue, 19 Mar 2013 18:03:22 +0100 Subject: [PATCH] Sound: sgtl5000 Allow codec clock frequency to be set. To: alsa-devel@alsa-project.org, Timur Tabi , linux-arm-kernel@lists.infradead.org From: Martin Fuzzey Date: Tue, 19 Mar 2013 18:03:22 +0100 Message-ID: <20130319170322.27828.7691.stgit@localhost> User-Agent: StGit/0.15 MIME-Version: 1.0 X-Virus-Scanned: by ClamAV at mta2.parkeon.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130319_130327_009185_A0E12B5A X-CRM114-Status: GOOD ( 10.62 ) X-Spam-Score: -4.4 (----) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-4.4 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record -2.5 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org If both clocks and clock-frequency DT properties are given set the clock frequency. This is useful when a programmable clock is used as the codec clock. Signed-off-by: Martin Fuzzey --- .../devicetree/bindings/sound/sgtl5000.txt | 14 ++++++++++++++ sound/soc/fsl/imx-sgtl5000.c | 20 ++++++++++++++++---- 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/Documentation/devicetree/bindings/sound/sgtl5000.txt b/Documentation/devicetree/bindings/sound/sgtl5000.txt index 9cc4444..31e82f0 100644 --- a/Documentation/devicetree/bindings/sound/sgtl5000.txt +++ b/Documentation/devicetree/bindings/sound/sgtl5000.txt @@ -5,9 +5,23 @@ Required properties: - reg : the I2C address of the device +Optional properties: +- clocks: phandle to of codec clock +- clock-frequency: clock frequency to set or use (see below) + +If a clock is provided, clock-frequency is optional + +If no clock is provided clock-frequency is required (this represents the codec +being clocked by an external signal not present in the clock tree) + +If both a clock and clock-frequency are provided the clock's rate will be set. + + Example: codec: sgtl5000@0a { compatible = "fsl,sgtl5000"; reg = <0x0a>; + clock-frequency = <20000000>; + clocks = <&clks 162>; /* cko1 */ }; diff --git a/sound/soc/fsl/imx-sgtl5000.c b/sound/soc/fsl/imx-sgtl5000.c index 424347e..71ce1f6 100644 --- a/sound/soc/fsl/imx-sgtl5000.c +++ b/sound/soc/fsl/imx-sgtl5000.c @@ -128,18 +128,30 @@ static int imx_sgtl5000_probe(struct platform_device *pdev) goto fail; } + ret = of_property_read_u32(codec_np, "clock-frequency", + &data->clk_frequency); data->codec_clk = clk_get(&codec_dev->dev, NULL); + if (IS_ERR(data->codec_clk)) { - /* assuming clock enabled by default */ + /* assuming clock enabled by default (frequency required) */ data->codec_clk = NULL; - ret = of_property_read_u32(codec_np, "clock-frequency", - &data->clk_frequency); - if (ret) { + if (!data->clk_frequency) { dev_err(&codec_dev->dev, "clock-frequency missing or invalid\n"); goto fail; } } else { + if (data->clk_frequency) { + ret = clk_set_rate( + data->codec_clk, data->clk_frequency); + if (ret) { + dev_err(&codec_dev->dev, + "failed to set clock-frequency to %u\n", + data->clk_frequency); + goto fail; + } + } + data->clk_frequency = clk_get_rate(data->codec_clk); clk_prepare_enable(data->codec_clk); }