From patchwork Fri Mar 20 21:22:43 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Howard Mitchell X-Patchwork-Id: 6061081 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 28462BF90F for ; Fri, 20 Mar 2015 21:23:47 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5B94620394 for ; Fri, 20 Mar 2015 21:23:46 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id F05B720395 for ; Fri, 20 Mar 2015 21:23:44 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 019132657DC; Fri, 20 Mar 2015 22:23:43 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id 6C30B2650BC; Fri, 20 Mar 2015 22:23:35 +0100 (CET) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id 1ABE32650DB; Fri, 20 Mar 2015 22:23:34 +0100 (CET) Received: from avasout02.plus.net (avasout02.plus.net [212.159.14.17]) by alsa0.perex.cz (Postfix) with ESMTP id E9D1B265071 for ; Fri, 20 Mar 2015 22:23:26 +0100 (CET) Received: from howard-VirtualBox.lan ([212.159.100.40]) by avasout02 with smtp id 5xPG1q0080sHRKG01xPPaX; Fri, 20 Mar 2015 21:23:26 +0000 X-CM-Score: 0.00 X-CNFS-Analysis: v=2.1 cv=IsmQcdPg c=1 sm=1 tr=0 a=VGUxJGZ/H8UixBFj6Q9CRg==:117 a=VGUxJGZ/H8UixBFj6Q9CRg==:17 a=0Bzu9jTXAAAA:8 a=eIRpCU4CAAAA:8 a=OK3IcRVFw2eLW-BG4usA:9 X-AUTH: oscars+hm@:2500 From: Howard Mitchell To: broonie@kernel.org, peda@axentia.se Date: Fri, 20 Mar 2015 21:22:43 +0000 Message-Id: <1426886563-10936-1-git-send-email-hm@hmbedded.co.uk> X-Mailer: git-send-email 1.7.9.5 Cc: mark.rutland@arm.com, devicetree@vger.kernel.org, alsa-devel@alsa-project.org, pawel.moll@arm.com, ijc+devicetree@hellion.org.uk, tiwai@suse.de, linux-kernel@vger.kernel.org, lgirdwood@gmail.com, robh+dt@kernel.org, galak@codeaurora.org, Howard Mitchell Subject: [alsa-devel] [PATCH] ASoC:pcm512x: Make PLL lock output selectable via device tree. X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP Currently the PLL Lock output signal is hardcoded to GPIO4. This makes it seletable in the same way as pll-in and pll-out. Signed-off-by: Howard Mitchell --- .../devicetree/bindings/sound/pcm512x.txt | 3 ++ sound/soc/codecs/pcm512x.c | 47 +++++++++++++------- 2 files changed, 33 insertions(+), 17 deletions(-) diff --git a/Documentation/devicetree/bindings/sound/pcm512x.txt b/Documentation/devicetree/bindings/sound/pcm512x.txt index 3aae3b4..432f186 100644 --- a/Documentation/devicetree/bindings/sound/pcm512x.txt +++ b/Documentation/devicetree/bindings/sound/pcm512x.txt @@ -26,6 +26,8 @@ Optional properties: given pll-in pin and PLL output on the given pll-out pin. An external connection from the pll-out pin to the SCLK pin is assumed. + - pll-lock : gpio pin used to output the PLL lock flag. + Examples: pcm5122: pcm5122@4c { @@ -49,4 +51,5 @@ Examples: clocks = <&sck>; pll-in = <3>; pll-out = <6>; + pll-lock = <4>; }; diff --git a/sound/soc/codecs/pcm512x.c b/sound/soc/codecs/pcm512x.c index 8472099..a4217d7 100644 --- a/sound/soc/codecs/pcm512x.c +++ b/sound/soc/codecs/pcm512x.c @@ -49,6 +49,7 @@ struct pcm512x_priv { int fmt; int pll_in; int pll_out; + int pll_lock; int pll_r; int pll_j; int pll_d; @@ -1296,24 +1297,26 @@ static int pcm512x_hw_params(struct snd_pcm_substream *substream, ret, pcm512x->pll_out); return ret; } + } - gpio = PCM512x_G1OE << (4 - 1); - ret = regmap_update_bits(pcm512x->regmap, PCM512x_GPIO_EN, - gpio, gpio); - if (ret != 0) { - dev_err(codec->dev, "Failed to enable gpio %d: %d\n", - 4, ret); - return ret; - } - - gpio = PCM512x_GPIO_OUTPUT_1 + 4 - 1; - ret = regmap_update_bits(pcm512x->regmap, gpio, - PCM512x_GxSL, PCM512x_GxSL_PLLLK); - if (ret != 0) { - dev_err(codec->dev, - "Failed to output pll lock on %d: %d\n", - ret, 4); - return ret; + if (pcm512x->pll_lock) { + gpio = PCM512x_G1OE << (pcm512x->pll_lock - 1); + ret = regmap_update_bits(pcm512x->regmap, PCM512x_GPIO_EN, + gpio, gpio); + if (ret != 0) { + dev_err(codec->dev, "Failed to enable gpio %d: %d\n", + pcm512x->pll_lock, ret); + return ret; + } + + gpio = PCM512x_GPIO_OUTPUT_1 + pcm512x->pll_lock - 1; + ret = regmap_update_bits(pcm512x->regmap, gpio, + PCM512x_GxSL, PCM512x_GxSL_PLLLK); + if (ret != 0) { + dev_err(codec->dev, + "Failed to output pll lock on %d: %d\n", + ret, pcm512x->pll_lock); + return ret; } } @@ -1518,6 +1521,16 @@ int pcm512x_probe(struct device *dev, struct regmap *regmap) ret = -EINVAL; goto err_clk; } + + if (of_property_read_u32(np, "pll-lock", &val) >= 0) { + if (val > 6) { + dev_err(dev, "Invalid pll-lock\n"); + ret = -EINVAL; + goto err_clk; + } + pcm512x->pll_lock = val; + } + } #endif