devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Howard Mitchell <hm@hmbedded.co.uk>
To: broonie@kernel.org, peda@axentia.se
Cc: tiwai@suse.de, lgirdwood@gmail.com, perex@perex.cz,
	robh+dt@kernel.org, pawel.moll@arm.com, mark.rutland@arm.com,
	ijc+devicetree@hellion.org.uk, galak@codeaurora.org,
	devicetree@vger.kernel.org, alsa-devel@alsa-project.org,
	linux-kernel@vger.kernel.org, Howard Mitchell <hm@hmbedded.co.uk>
Subject: [PATCH] ASoC:pcm512x: Make PLL lock output selectable via device tree.
Date: Fri, 20 Mar 2015 21:22:43 +0000	[thread overview]
Message-ID: <1426886563-10936-1-git-send-email-hm@hmbedded.co.uk> (raw)

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 <hm@hmbedded.co.uk>
---
 .../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
 
-- 
1.7.9.5

             reply	other threads:[~2015-03-20 21:22 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-20 21:22 Howard Mitchell [this message]
2015-03-22 16:24 ` [PATCH] ASoC:pcm512x: Make PLL lock output selectable via device tree Mark Brown
     [not found]   ` <20150322162409.GG6643-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2015-03-23  9:43     ` Howard Mitchell
     [not found]       ` <550FE05F.6070204-n6SlHCM0l+K9FHfhHBbuYA@public.gmane.org>
2015-03-23 11:00         ` Peter Rosin
2015-03-23 11:14           ` Howard Mitchell
2015-03-23 16:56           ` Mark Brown
     [not found]             ` <20150323165621.GH14954-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2015-03-23 19:15               ` Howard Mitchell
     [not found] ` <1426886563-10936-1-git-send-email-hm-n6SlHCM0l+K9FHfhHBbuYA@public.gmane.org>
2015-03-22 21:25   ` Peter Rosin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1426886563-10936-1-git-send-email-hm@hmbedded.co.uk \
    --to=hm@hmbedded.co.uk \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=galak@codeaurora.org \
    --cc=ijc+devicetree@hellion.org.uk \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=pawel.moll@arm.com \
    --cc=peda@axentia.se \
    --cc=perex@perex.cz \
    --cc=robh+dt@kernel.org \
    --cc=tiwai@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).