devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tushar Behera <tushar.behera@linaro.org>
To: alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org,
	devicetree@vger.kernel.org
Cc: tiwai@suse.de, perex@perex.cz, broonie@kernel.org,
	dianders@chromium.org, jerry.wong@maximintegrated.com
Subject: [PATCH 1/2] ASoC: max98090: Add master clock handling
Date: Thu, 22 May 2014 14:47:07 +0530	[thread overview]
Message-ID: <1400750228-13750-2-git-send-email-tushar.behera@linaro.org> (raw)
In-Reply-To: <1400750228-13750-1-git-send-email-tushar.behera@linaro.org>

If master clock is provided through device tree, then update
the master clock frequency during set_sysclk.

Documentation has been updated to reflect the change.

Signed-off-by: Tushar Behera <tushar.behera@linaro.org>
---
 .../devicetree/bindings/sound/max98090.txt         |    6 ++++++
 sound/soc/codecs/max98090.c                        |   13 +++++++++++++
 sound/soc/codecs/max98090.h                        |    1 +
 3 files changed, 20 insertions(+)

diff --git a/Documentation/devicetree/bindings/sound/max98090.txt b/Documentation/devicetree/bindings/sound/max98090.txt
index e4c8b36..a5e63fa 100644
--- a/Documentation/devicetree/bindings/sound/max98090.txt
+++ b/Documentation/devicetree/bindings/sound/max98090.txt
@@ -10,6 +10,12 @@ Required properties:
 
 - interrupts : The CODEC's interrupt output.
 
+Optional properties:
+
+- clocks: The phandle of the master clock to the CODEC
+
+- clock-names: Should be "mclk"
+
 Pins on the device (for linking into audio routes):
 
   * MIC1
diff --git a/sound/soc/codecs/max98090.c b/sound/soc/codecs/max98090.c
index 9b76f5a..41c61eb 100644
--- a/sound/soc/codecs/max98090.c
+++ b/sound/soc/codecs/max98090.c
@@ -17,6 +17,7 @@
 #include <linux/regmap.h>
 #include <linux/slab.h>
 #include <linux/acpi.h>
+#include <linux/clk.h>
 #include <sound/jack.h>
 #include <sound/pcm.h>
 #include <sound/pcm_params.h>
@@ -1929,6 +1930,11 @@ static int max98090_dai_set_sysclk(struct snd_soc_dai *dai,
 	if (freq == max98090->sysclk)
 		return 0;
 
+	if (!IS_ERR(max98090->mclk)) {
+		freq = clk_round_rate(max98090->mclk, freq);
+		clk_set_rate(max98090->mclk, freq);
+	}
+
 	/* Setup clocks for slave mode, and using the PLL
 	 * PSCLK = 0x01 (when master clk is 10MHz to 20MHz)
 	 *		 0x02 (when master clk is 20MHz to 40MHz)..
@@ -2213,6 +2219,10 @@ static int max98090_probe(struct snd_soc_codec *codec)
 
 	dev_dbg(codec->dev, "max98090_probe\n");
 
+	max98090->mclk = devm_clk_get(codec->dev, "mclk");
+	if (!IS_ERR(max98090->mclk))
+		clk_prepare_enable(max98090->mclk);
+
 	max98090->codec = codec;
 
 	/* Reset the codec, the DSP core, and disable all interrupts */
@@ -2308,6 +2318,9 @@ static int max98090_remove(struct snd_soc_codec *codec)
 
 	cancel_delayed_work_sync(&max98090->jack_work);
 
+	if (!IS_ERR(max98090->mclk))
+		clk_disable_unprepare(max98090->mclk);
+
 	return 0;
 }
 
diff --git a/sound/soc/codecs/max98090.h b/sound/soc/codecs/max98090.h
index 5a3c8d0..cf1b606 100644
--- a/sound/soc/codecs/max98090.h
+++ b/sound/soc/codecs/max98090.h
@@ -1524,6 +1524,7 @@ struct max98090_priv {
 	struct snd_soc_codec *codec;
 	enum max98090_type devtype;
 	struct max98090_pdata *pdata;
+	struct clk *mclk;
 	unsigned int sysclk;
 	unsigned int bclk;
 	unsigned int lrclk;
-- 
1.7.9.5

  reply	other threads:[~2014-05-22  9:17 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-22  9:17 [PATCH 0/2] ASoC: max98090/max98095: Add master clock handing Tushar Behera
2014-05-22  9:17 ` Tushar Behera [this message]
2014-05-22 10:30   ` [PATCH 1/2] ASoC: max98090: Add master clock handling Mark Brown
     [not found]     ` <20140522103039.GD12304-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2014-05-23  5:35       ` Tushar Behera
     [not found]         ` <CAHbNUh2QHv8n7Y19qfO7BagX5AWe0i17MjDvr7yOpHf6YNGW4A-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-05-23 11:14           ` Mark Brown
     [not found]             ` <20140523111446.GA12304-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2014-05-23 11:36               ` Tushar Behera
     [not found]                 ` <CAHbNUh152xgyVxcCHiv0M6PLw8DE7KZ990WG7uRWWFBc8sPWRQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-05-23 11:41                   ` Mark Brown
     [not found]                     ` <20140523114113.GE12304-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2014-05-23 12:02                       ` Tushar Behera
2014-05-22 15:51   ` Stephen Warren
     [not found]     ` <537E1D0A.6020303-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2014-05-22 17:34       ` Mark Brown
     [not found]         ` <20140522173403.GL12304-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2014-05-22 17:50           ` Stephen Warren
     [not found]             ` <537E38FF.9000407-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2014-05-22 18:19               ` Mark Brown
2014-05-22 22:24                 ` Stephen Warren
2014-05-22 23:36                   ` Mark Brown
2014-05-22  9:17 ` [PATCH 2/2] ASoC: max98095: " Tushar Behera
2014-05-22 10:31   ` Mark Brown

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=1400750228-13750-2-git-send-email-tushar.behera@linaro.org \
    --to=tushar.behera@linaro.org \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dianders@chromium.org \
    --cc=jerry.wong@maximintegrated.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=perex@perex.cz \
    --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).