linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: olivier.moysan@st.com (Olivier Moysan)
To: linux-arm-kernel@lists.infradead.org
Subject: [RFC PATCH 2/2] ASoC: select sysclk clock from mlck clock provider in wm8994 driver
Date: Thu, 14 Dec 2017 17:53:58 +0100	[thread overview]
Message-ID: <1513270438-18523-3-git-send-email-olivier.moysan@st.com> (raw)
In-Reply-To: <1513270438-18523-1-git-send-email-olivier.moysan@st.com>

When defined in device tree, MCLK1 and MCLK2 are used
as sysclk for aif1 and aif2 interfaces respectively.
If clock rate is let 0, the frequency provided by
wm8994_set_dai_sysclk() is used instead.

Signed-off-by: Olivier Moysan <olivier.moysan@st.com>
---
 sound/soc/codecs/wm8994.c | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/sound/soc/codecs/wm8994.c b/sound/soc/codecs/wm8994.c
index 21ffd64..7a84e37 100644
--- a/sound/soc/codecs/wm8994.c
+++ b/sound/soc/codecs/wm8994.c
@@ -11,6 +11,7 @@
  * published by the Free Software Foundation.
  */
 
+#include <linux/clk.h>
 #include <linux/module.h>
 #include <linux/moduleparam.h>
 #include <linux/init.h>
@@ -2376,18 +2377,35 @@ static int wm8994_set_dai_sysclk(struct snd_soc_dai *dai,
 {
 	struct snd_soc_codec *codec = dai->codec;
 	struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec);
+	struct wm8994 *control = wm8994->wm8994;
+	struct wm8994_pdata *pdata = &control->pdata;
+	unsigned long rate;
 	int i;
 
 	switch (dai->id) {
 	case 1:
+		if (pdata->mclk1) {
+			rate = clk_get_rate(pdata->mclk1);
+			if (rate)
+				freq = (unsigned int)rate;
+			clk_id = WM8994_SYSCLK_MCLK1;
+		}
+		break;
 	case 2:
+		if (pdata->mclk2) {
+			rate = clk_get_rate(pdata->mclk2);
+			if (rate)
+				freq = (unsigned int)rate;
+			clk_id = WM8994_SYSCLK_MCLK2;
+		}
 		break;
-
 	default:
 		/* AIF3 shares clocking with AIF1/2 */
 		return -EINVAL;
 	}
 
+	dev_info(codec->dev, "%s:.clock id %d\n", __func__, clk_id);
+
 	switch (clk_id) {
 	case WM8994_SYSCLK_MCLK1:
 		wm8994->sysclk[dai->id - 1] = WM8994_SYSCLK_MCLK1;
-- 
1.9.1

  parent reply	other threads:[~2017-12-14 16:53 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-14 16:53 [RFC PATCH 0/2] select master clock in wm8994 driver based on DT clocks configuration Olivier Moysan
2017-12-14 16:53 ` [RFC PATCH 1/2] ASoC: add support of mclk clock providers in wm8894 driver Olivier Moysan
     [not found]   ` <20171214173025.GL9788@sirena.org.uk>
2017-12-15 11:51     ` Charles Keepax
2017-12-14 16:53 ` Olivier Moysan [this message]
     [not found]   ` <20171214173624.GM9788@sirena.org.uk>
2017-12-15 11:46     ` [RFC PATCH 2/2] ASoC: select sysclk clock from mlck clock provider in wm8994 driver Charles Keepax
2017-12-15 15:15     ` Olivier MOYSAN
2017-12-19  9:35       ` Mark Brown
2017-12-20 12:42         ` Olivier MOYSAN
     [not found]           ` <20171220155000.GD17890@sirena.org.uk>
2017-12-21 10:51             ` Olivier MOYSAN

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=1513270438-18523-3-git-send-email-olivier.moysan@st.com \
    --to=olivier.moysan@st.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    /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).