diff options
author | Kuninori Morimoto <morimoto.kuninori@renesas.com> | 2010-03-23 03:27:28 -0400 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2010-03-23 06:59:11 -0400 |
commit | 4b6316b4b16c7fb5d51df43f0371416e054e7102 (patch) | |
tree | 72571695549ff0a1b55ad8e55bf122e21dce90aa /sound/soc | |
parent | 778a76e2dbdb896d005849e9e74518d6aba85671 (diff) |
ASoC: ak4642: Add pll select support
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>
Acked-by: Liam Girdwood <lrg@slimlogic.co.uk>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound/soc')
-rw-r--r-- | sound/soc/codecs/ak4642.c | 40 | ||||
-rw-r--r-- | 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 3ef16bbc8c83..d5bd4cae73a1 100644 --- a/sound/soc/codecs/ak4642.c +++ b/sound/soc/codecs/ak4642.c | |||
@@ -80,12 +80,18 @@ | |||
80 | 80 | ||
81 | #define AK4642_CACHEREGNUM 0x25 | 81 | #define AK4642_CACHEREGNUM 0x25 |
82 | 82 | ||
83 | /* MD_CTL1 */ | ||
84 | #define PLL3 (1 << 7) | ||
85 | #define PLL2 (1 << 6) | ||
86 | #define PLL1 (1 << 5) | ||
87 | #define PLL0 (1 << 4) | ||
88 | #define PLL_MASK (PLL3 | PLL2 | PLL1 | PLL0) | ||
89 | |||
83 | struct snd_soc_codec_device soc_codec_dev_ak4642; | 90 | struct snd_soc_codec_device soc_codec_dev_ak4642; |
84 | 91 | ||
85 | /* codec private data */ | 92 | /* codec private data */ |
86 | struct ak4642_priv { | 93 | struct ak4642_priv { |
87 | struct snd_soc_codec codec; | 94 | struct snd_soc_codec codec; |
88 | unsigned int sysclk; | ||
89 | }; | 95 | }; |
90 | 96 | ||
91 | static struct snd_soc_codec *ak4642_codec; | 97 | static struct snd_soc_codec *ak4642_codec; |
@@ -249,9 +255,32 @@ static int ak4642_dai_set_sysclk(struct snd_soc_dai *codec_dai, | |||
249 | int clk_id, unsigned int freq, int dir) | 255 | int clk_id, unsigned int freq, int dir) |
250 | { | 256 | { |
251 | struct snd_soc_codec *codec = codec_dai->codec; | 257 | struct snd_soc_codec *codec = codec_dai->codec; |
252 | struct ak4642_priv *ak4642 = codec->private_data; | 258 | u8 pll; |
259 | |||
260 | switch (freq) { | ||
261 | case 11289600: | ||
262 | pll = PLL2; | ||
263 | break; | ||
264 | case 12288000: | ||
265 | pll = PLL2 | PLL0; | ||
266 | break; | ||
267 | case 12000000: | ||
268 | pll = PLL2 | PLL1; | ||
269 | break; | ||
270 | case 24000000: | ||
271 | pll = PLL2 | PLL1 | PLL0; | ||
272 | break; | ||
273 | case 13500000: | ||
274 | pll = PLL3 | PLL2; | ||
275 | break; | ||
276 | case 27000000: | ||
277 | pll = PLL3 | PLL2 | PLL0; | ||
278 | break; | ||
279 | default: | ||
280 | return -EINVAL; | ||
281 | } | ||
282 | snd_soc_update_bits(codec, MD_CTL1, PLL_MASK, pll); | ||
253 | 283 | ||
254 | ak4642->sysclk = freq; | ||
255 | return 0; | 284 | return 0; |
256 | } | 285 | } |
257 | 286 | ||
@@ -342,7 +371,6 @@ static int ak4642_init(struct ak4642_priv *ak4642) | |||
342 | * | 371 | * |
343 | * Audio I/F Format: MSB justified (ADC & DAC) | 372 | * Audio I/F Format: MSB justified (ADC & DAC) |
344 | * BICK frequency at Master Mode: 64fs | 373 | * BICK frequency at Master Mode: 64fs |
345 | * Input Master Clock Select at PLL Mode: 11.2896MHz | ||
346 | * MCKO: Enable | 374 | * MCKO: Enable |
347 | * Sampling Frequency: 44.1kHz | 375 | * Sampling Frequency: 44.1kHz |
348 | * | 376 | * |
@@ -352,10 +380,8 @@ static int ak4642_init(struct ak4642_priv *ak4642) | |||
352 | * please fix-me | 380 | * please fix-me |
353 | */ | 381 | */ |
354 | ak4642_write(codec, 0x01, 0x08); | 382 | ak4642_write(codec, 0x01, 0x08); |
355 | ak4642_write(codec, 0x04, 0x4a); | ||
356 | ak4642_write(codec, 0x05, 0x27); | 383 | ak4642_write(codec, 0x05, 0x27); |
357 | ak4642_write(codec, 0x00, 0x40); | 384 | ak4642_write(codec, 0x04, 0x0a); |
358 | ak4642_write(codec, 0x01, 0x0b); | ||
359 | 385 | ||
360 | return ret; | 386 | return ret; |
361 | 387 | ||
diff --git a/sound/soc/sh/fsi-ak4642.c b/sound/soc/sh/fsi-ak4642.c index 5263ab18f827..c0207dc524b8 100644 --- a/sound/soc/sh/fsi-ak4642.c +++ b/sound/soc/sh/fsi-ak4642.c | |||
@@ -22,11 +22,21 @@ | |||
22 | #include <sound/sh_fsi.h> | 22 | #include <sound/sh_fsi.h> |
23 | #include <../sound/soc/codecs/ak4642.h> | 23 | #include <../sound/soc/codecs/ak4642.h> |
24 | 24 | ||
25 | static int fsi_ak4642_dai_init(struct snd_soc_codec *codec) | ||
26 | { | ||
27 | int ret; | ||
28 | |||
29 | ret = snd_soc_dai_set_sysclk(&ak4642_dai, 0, 11289600, 0); | ||
30 | |||
31 | return ret; | ||
32 | } | ||
33 | |||
25 | static struct snd_soc_dai_link fsi_dai_link = { | 34 | static struct snd_soc_dai_link fsi_dai_link = { |
26 | .name = "AK4642", | 35 | .name = "AK4642", |
27 | .stream_name = "AK4642", | 36 | .stream_name = "AK4642", |
28 | .cpu_dai = &fsi_soc_dai[0], /* fsi */ | 37 | .cpu_dai = &fsi_soc_dai[0], /* fsi */ |
29 | .codec_dai = &ak4642_dai, | 38 | .codec_dai = &ak4642_dai, |
39 | .init = fsi_ak4642_dai_init, | ||
30 | .ops = NULL, | 40 | .ops = NULL, |
31 | }; | 41 | }; |
32 | 42 | ||