Title: [8652] trunk/sound/soc: ad193x: add set_pll entry in codec driver
Revision
8652
Author
bhsong
Date
2010-04-19 04:46:49 -0400 (Mon, 19 Apr 2010)

Log Message

ad193x: add set_pll entry in codec driver

Modified Paths


Diff

Modified: trunk/sound/soc/blackfin/bf5xx-ad193x.c (8651 => 8652)


--- trunk/sound/soc/blackfin/bf5xx-ad193x.c	2010-04-16 13:53:23 UTC (rev 8651)
+++ trunk/sound/soc/blackfin/bf5xx-ad193x.c	2010-04-19 08:46:49 UTC (rev 8652)
@@ -77,6 +77,13 @@
 	if (ret < 0)
 		return ret;
 
+#if 0
+	/* if input frequency is not 12288000, we need set pll */
+	ret = snd_soc_dai_set_pll(codec_dai, 0, 0,
+			24576000, 12288000);
+	if (ret < 0)
+		return ret;
+#endif
 	return 0;
 }
 

Modified: trunk/sound/soc/codecs/ad193x.c (8651 => 8652)


--- trunk/sound/soc/codecs/ad193x.c	2010-04-16 13:53:23 UTC (rev 8651)
+++ trunk/sound/soc/codecs/ad193x.c	2010-04-19 08:46:49 UTC (rev 8652)
@@ -248,6 +248,36 @@
 	return 0;
 }
 
+static int ad193x_set_dai_pll(struct snd_soc_dai *codec_dai,
+		int pll_id, int source, unsigned int freq_in, unsigned int freq_out)
+{
+	struct snd_soc_codec *codec = codec_dai->codec;
+	int reg;
+
+	reg = snd_soc_read(codec, AD193X_PLL_CLK_CTRL0);
+
+	switch (freq_in) {
+	case 12288000:
+		reg = (reg & AD193X_PLL_INPUT_MASK) | AD193X_PLL_INPUT_256;
+		break;
+	case 18432000:
+		reg = (reg & AD193X_PLL_INPUT_MASK) | AD193X_PLL_INPUT_384;
+		break;
+	case 24576000:
+		reg = (reg & AD193X_PLL_INPUT_MASK) | AD193X_PLL_INPUT_512;
+		break;
+	case 36864000:
+		reg = (reg & AD193X_PLL_INPUT_MASK) | AD193X_PLL_INPUT_768;
+		break;
+	default:
+		dev_err(codec->dev, "ad193x_set_dai_pll: unsupported pll input freq:%d", freq_in);
+		return -EINVAL;
+	}
+
+	snd_soc_write(codec, AD193X_PLL_CLK_CTRL0, reg);
+	return 0;
+}
+
 static int ad193x_hw_params(struct snd_pcm_substream *substream,
 		struct snd_pcm_hw_params *params,
 		struct snd_soc_dai *dai)
@@ -381,6 +411,7 @@
 	.digital_mute = ad193x_mute,
 	.set_tdm_slot = ad193x_set_tdm_slot,
 	.set_fmt = ad193x_set_dai_fmt,
+	.set_pll = ad193x_set_dai_pll,
 };
 
 /* codec DAI instance */

Modified: trunk/sound/soc/codecs/ad193x.h (8651 => 8652)


--- trunk/sound/soc/codecs/ad193x.h	2010-04-16 13:53:23 UTC (rev 8651)
+++ trunk/sound/soc/codecs/ad193x.h	2010-04-19 08:46:49 UTC (rev 8652)
@@ -11,6 +11,11 @@
 
 #define AD193X_PLL_CLK_CTRL0    0x800
 #define AD193X_PLL_POWERDOWN           0x01
+#define AD193X_PLL_INPUT_MASK   (~0x6)
+#define AD193X_PLL_INPUT_256    (0 << 1)
+#define AD193X_PLL_INPUT_384    (1 << 1)
+#define AD193X_PLL_INPUT_512    (2 << 1)
+#define AD193X_PLL_INPUT_768    (3 << 1)
 #define AD193X_PLL_CLK_CTRL1    0x801
 #define AD193X_DAC_CTRL0        0x802
 #define AD193X_DAC_POWERDOWN           0x01
_______________________________________________
Linux-kernel-commits mailing list
[email protected]
https://blackfin.uclinux.org/mailman/listinfo/linux-kernel-commits

Reply via email to