All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kuninori Morimoto <morimoto.kuninori@renesas.com>
To: Mark Brown <broonie@opensource.wolfsonmicro.com>
Cc: Linux-ALSA <alsa-devel@alsa-project.org>
Subject: [PATCH 1/3] ASoC: ak4642: Add pll select support
Date: Tue, 23 Mar 2010 16:27:28 +0900	[thread overview]
Message-ID: <utys74hwf.wl%morimoto.kuninori@renesas.com> (raw)
In-Reply-To: <uvdcn4hx0.wl%morimoto.kuninori@renesas.com>

Current ak4642 was not able to select pll.
This patch add support it.
It still expect PLL base input pin is MCKI.
see Table 5 "setting of PLL Mode" of datasheet

Signed-off-by: Kuninori Morimoto <morimoto.kuninori@renesas.com>
---
 sound/soc/codecs/ak4642.c |   40 +++++++++++++++++++++++++++++++++-------
 sound/soc/sh/fsi-ak4642.c |   10 ++++++++++
 2 files changed, 43 insertions(+), 7 deletions(-)

diff --git a/sound/soc/codecs/ak4642.c b/sound/soc/codecs/ak4642.c
index 3ef16bb..d5bd4ca 100644
--- a/sound/soc/codecs/ak4642.c
+++ b/sound/soc/codecs/ak4642.c
@@ -80,12 +80,18 @@
 
 #define AK4642_CACHEREGNUM 	0x25
 
+/* MD_CTL1 */
+#define PLL3		(1 << 7)
+#define PLL2		(1 << 6)
+#define PLL1		(1 << 5)
+#define PLL0		(1 << 4)
+#define PLL_MASK	(PLL3 | PLL2 | PLL1 | PLL0)
+
 struct snd_soc_codec_device soc_codec_dev_ak4642;
 
 /* codec private data */
 struct ak4642_priv {
 	struct snd_soc_codec codec;
-	unsigned int sysclk;
 };
 
 static struct snd_soc_codec *ak4642_codec;
@@ -249,9 +255,32 @@ static int ak4642_dai_set_sysclk(struct snd_soc_dai *codec_dai,
 	int clk_id, unsigned int freq, int dir)
 {
 	struct snd_soc_codec *codec = codec_dai->codec;
-	struct ak4642_priv *ak4642 = codec->private_data;
+	u8 pll;
+
+	switch (freq) {
+	case 11289600:
+		pll = PLL2;
+		break;
+	case 12288000:
+		pll = PLL2 | PLL0;
+		break;
+	case 12000000:
+		pll = PLL2 | PLL1;
+		break;
+	case 24000000:
+		pll = PLL2 | PLL1 | PLL0;
+		break;
+	case 13500000:
+		pll = PLL3 | PLL2;
+		break;
+	case 27000000:
+		pll = PLL3 | PLL2 | PLL0;
+		break;
+	default:
+		return -EINVAL;
+	}
+	snd_soc_update_bits(codec, MD_CTL1, PLL_MASK, pll);
 
-	ak4642->sysclk = freq;
 	return 0;
 }
 
@@ -342,7 +371,6 @@ static int ak4642_init(struct ak4642_priv *ak4642)
 	 *
 	 * Audio I/F Format: MSB justified (ADC & DAC)
 	 * BICK frequency at Master Mode: 64fs
-	 * Input Master Clock Select at PLL Mode: 11.2896MHz
 	 * MCKO: Enable
 	 * Sampling Frequency: 44.1kHz
 	 *
@@ -352,10 +380,8 @@ static int ak4642_init(struct ak4642_priv *ak4642)
 	 * please fix-me
 	 */
 	ak4642_write(codec, 0x01, 0x08);
-	ak4642_write(codec, 0x04, 0x4a);
 	ak4642_write(codec, 0x05, 0x27);
-	ak4642_write(codec, 0x00, 0x40);
-	ak4642_write(codec, 0x01, 0x0b);
+	ak4642_write(codec, 0x04, 0x0a);
 
 	return ret;
 
diff --git a/sound/soc/sh/fsi-ak4642.c b/sound/soc/sh/fsi-ak4642.c
index 5263ab1..c0207dc 100644
--- a/sound/soc/sh/fsi-ak4642.c
+++ b/sound/soc/sh/fsi-ak4642.c
@@ -22,11 +22,21 @@
 #include <sound/sh_fsi.h>
 #include <../sound/soc/codecs/ak4642.h>
 
+static int fsi_ak4642_dai_init(struct snd_soc_codec *codec)
+{
+	int ret;
+
+	ret = snd_soc_dai_set_sysclk(&ak4642_dai, 0, 11289600, 0);
+
+	return ret;
+}
+
 static struct snd_soc_dai_link fsi_dai_link = {
 	.name		= "AK4642",
 	.stream_name	= "AK4642",
 	.cpu_dai	= &fsi_soc_dai[0], /* fsi */
 	.codec_dai	= &ak4642_dai,
+	.init		= fsi_ak4642_dai_init,
 	.ops		= NULL,
 };
 
-- 
1.6.3.3

  parent reply	other threads:[~2010-03-23  7:27 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-23  7:27 [PATCH 0/3] ASoC: ak4642: sampling rate update Kuninori Morimoto
2010-03-15  9:10 ` [PATCH 2/3] ASoC: ak4642: Add set_fmt function for snd_soc_dai_ops Kuninori Morimoto
2010-03-23 15:36   ` Liam Girdwood
2010-03-23  7:27 ` Kuninori Morimoto [this message]
2010-03-23 10:10   ` [PATCH 1/3] ASoC: ak4642: Add pll select support Liam Girdwood
2010-03-23  7:27 ` [PATCH 3/3] ASoC: ak4642: Add enhanced sampling rate Kuninori Morimoto
2010-03-23 10:10   ` Liam Girdwood
2010-03-23 15:38 ` [PATCH 0/3] ASoC: ak4642: sampling rate update 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=utys74hwf.wl%morimoto.kuninori@renesas.com \
    --to=morimoto.kuninori@renesas.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@opensource.wolfsonmicro.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.