aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/codecs/da7210.c
diff options
context:
space:
mode:
authorKuninori Morimoto <morimoto.kuninori@renesas.com>2010-03-10 21:37:44 -0500
committerMark Brown <broonie@opensource.wolfsonmicro.com>2010-03-11 05:58:33 -0500
commit960b3b4b4cb6d22d55ad0ebb280dac9876937fa0 (patch)
treeb3b320be623413e77861ba8ab4f478a5b0c71a73 /sound/soc/codecs/da7210.c
parent9c9b125736db934b98aa7e16b675767ed4fcf5ce (diff)
ASoC: da7210: Add 11025/22050/44100/88200 rate support
This driver USE PLL for 11025/22050/44100/88200 rate. To enable switching to bypass mode, PLL is always turned on. Special thanks to Phil Signed-off-by: Phil Edworthy <Phil.Edworthy@renesas.com> 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/codecs/da7210.c')
-rw-r--r--sound/soc/codecs/da7210.c90
1 files changed, 86 insertions, 4 deletions
diff --git a/sound/soc/codecs/da7210.c b/sound/soc/codecs/da7210.c
index 3bd867de597b..35b881638658 100644
--- a/sound/soc/codecs/da7210.c
+++ b/sound/soc/codecs/da7210.c
@@ -55,8 +55,14 @@
55#define DA7210_DAI_SRC_SEL 0x25 55#define DA7210_DAI_SRC_SEL 0x25
56#define DA7210_DAI_CFG1 0x26 56#define DA7210_DAI_CFG1 0x26
57#define DA7210_DAI_CFG3 0x28 57#define DA7210_DAI_CFG3 0x28
58#define DA7210_PLL_DIV1 0x29
59#define DA7210_PLL_DIV2 0x2A
58#define DA7210_PLL_DIV3 0x2B 60#define DA7210_PLL_DIV3 0x2B
59#define DA7210_PLL 0x2C 61#define DA7210_PLL 0x2C
62#define DA7210_A_HID_UNLOCK 0x8A
63#define DA7210_A_TEST_UNLOCK 0x8B
64#define DA7210_A_PLL1 0x90
65#define DA7210_A_CP_MODE 0xA7
60 66
61/* STARTUP1 bit fields */ 67/* STARTUP1 bit fields */
62#define DA7210_SC_MST_EN (1 << 0) 68#define DA7210_SC_MST_EN (1 << 0)
@@ -124,13 +130,17 @@
124/* PLL bit fields */ 130/* PLL bit fields */
125#define DA7210_PLL_FS_MASK (0xF << 0) 131#define DA7210_PLL_FS_MASK (0xF << 0)
126#define DA7210_PLL_FS_8000 (0x1 << 0) 132#define DA7210_PLL_FS_8000 (0x1 << 0)
133#define DA7210_PLL_FS_11025 (0x2 << 0)
127#define DA7210_PLL_FS_12000 (0x3 << 0) 134#define DA7210_PLL_FS_12000 (0x3 << 0)
128#define DA7210_PLL_FS_16000 (0x5 << 0) 135#define DA7210_PLL_FS_16000 (0x5 << 0)
136#define DA7210_PLL_FS_22050 (0x6 << 0)
129#define DA7210_PLL_FS_24000 (0x7 << 0) 137#define DA7210_PLL_FS_24000 (0x7 << 0)
130#define DA7210_PLL_FS_32000 (0x9 << 0) 138#define DA7210_PLL_FS_32000 (0x9 << 0)
139#define DA7210_PLL_FS_44100 (0xA << 0)
131#define DA7210_PLL_FS_48000 (0xB << 0) 140#define DA7210_PLL_FS_48000 (0xB << 0)
141#define DA7210_PLL_FS_88200 (0xE << 0)
132#define DA7210_PLL_FS_96000 (0xF << 0) 142#define DA7210_PLL_FS_96000 (0xF << 0)
133 143#define DA7210_PLL_EN (0x1 << 7)
134 144
135#define DA7210_VERSION "0.0.1" 145#define DA7210_VERSION "0.0.1"
136 146
@@ -249,7 +259,7 @@ static int da7210_hw_params(struct snd_pcm_substream *substream,
249 struct snd_soc_codec *codec = socdev->card->codec; 259 struct snd_soc_codec *codec = socdev->card->codec;
250 u32 dai_cfg1; 260 u32 dai_cfg1;
251 u32 hpf_reg, hpf_mask, hpf_value; 261 u32 hpf_reg, hpf_mask, hpf_value;
252 u32 fs; 262 u32 fs, bypass;
253 263
254 /* set DAI source to Left and Right ADC */ 264 /* set DAI source to Left and Right ADC */
255 da7210_write(codec, DA7210_DAI_SRC_SEL, 265 da7210_write(codec, DA7210_DAI_SRC_SEL,
@@ -281,38 +291,76 @@ static int da7210_hw_params(struct snd_pcm_substream *substream,
281 fs = DA7210_PLL_FS_8000; 291 fs = DA7210_PLL_FS_8000;
282 hpf_mask = DA7210_VOICE_F0_MASK | DA7210_VOICE_EN; 292 hpf_mask = DA7210_VOICE_F0_MASK | DA7210_VOICE_EN;
283 hpf_value = DA7210_VOICE_F0_25 | DA7210_VOICE_EN; 293 hpf_value = DA7210_VOICE_F0_25 | DA7210_VOICE_EN;
294 bypass = DA7210_PLL_BYP;
295 break;
296 case 11025:
297 fs = DA7210_PLL_FS_11025;
298 hpf_mask = DA7210_VOICE_F0_MASK | DA7210_VOICE_EN;
299 hpf_value = DA7210_VOICE_F0_25 | DA7210_VOICE_EN;
300 bypass = 0;
284 break; 301 break;
285 case 12000: 302 case 12000:
286 fs = DA7210_PLL_FS_12000; 303 fs = DA7210_PLL_FS_12000;
287 hpf_mask = DA7210_VOICE_F0_MASK | DA7210_VOICE_EN; 304 hpf_mask = DA7210_VOICE_F0_MASK | DA7210_VOICE_EN;
288 hpf_value = DA7210_VOICE_F0_25 | DA7210_VOICE_EN; 305 hpf_value = DA7210_VOICE_F0_25 | DA7210_VOICE_EN;
306 bypass = DA7210_PLL_BYP;
289 break; 307 break;
290 case 16000: 308 case 16000:
291 fs = DA7210_PLL_FS_16000; 309 fs = DA7210_PLL_FS_16000;
292 hpf_mask = DA7210_VOICE_F0_MASK | DA7210_VOICE_EN; 310 hpf_mask = DA7210_VOICE_F0_MASK | DA7210_VOICE_EN;
293 hpf_value = DA7210_VOICE_F0_25 | DA7210_VOICE_EN; 311 hpf_value = DA7210_VOICE_F0_25 | DA7210_VOICE_EN;
312 bypass = DA7210_PLL_BYP;
313 break;
314 case 22050:
315 fs = DA7210_PLL_FS_22050;
316 hpf_mask = DA7210_VOICE_EN;
317 hpf_value = 0;
318 bypass = 0;
294 break; 319 break;
295 case 32000: 320 case 32000:
296 fs = DA7210_PLL_FS_32000; 321 fs = DA7210_PLL_FS_32000;
297 hpf_mask = DA7210_VOICE_EN; 322 hpf_mask = DA7210_VOICE_EN;
298 hpf_value = 0; 323 hpf_value = 0;
324 bypass = DA7210_PLL_BYP;
325 break;
326 case 44100:
327 fs = DA7210_PLL_FS_44100;
328 hpf_mask = DA7210_VOICE_EN;
329 hpf_value = 0;
330 bypass = 0;
299 break; 331 break;
300 case 48000: 332 case 48000:
301 fs = DA7210_PLL_FS_48000; 333 fs = DA7210_PLL_FS_48000;
302 hpf_mask = DA7210_VOICE_EN; 334 hpf_mask = DA7210_VOICE_EN;
303 hpf_value = 0; 335 hpf_value = 0;
336 bypass = DA7210_PLL_BYP;
337 break;
338 case 88200:
339 fs = DA7210_PLL_FS_88200;
340 hpf_mask = DA7210_VOICE_EN;
341 hpf_value = 0;
342 bypass = 0;
304 break; 343 break;
305 case 96000: 344 case 96000:
306 fs = DA7210_PLL_FS_96000; 345 fs = DA7210_PLL_FS_96000;
307 hpf_mask = DA7210_VOICE_EN; 346 hpf_mask = DA7210_VOICE_EN;
308 hpf_value = 0; 347 hpf_value = 0;
348 bypass = DA7210_PLL_BYP;
309 break; 349 break;
310 default: 350 default:
311 return -EINVAL; 351 return -EINVAL;
312 } 352 }
313 353
354 /* Disable active mode */
355 snd_soc_update_bits(codec, DA7210_STARTUP1, DA7210_SC_MST_EN, 0);
356
314 snd_soc_update_bits(codec, hpf_reg, hpf_mask, hpf_value); 357 snd_soc_update_bits(codec, hpf_reg, hpf_mask, hpf_value);
315 snd_soc_update_bits(codec, DA7210_PLL, DA7210_PLL_FS_MASK, fs); 358 snd_soc_update_bits(codec, DA7210_PLL, DA7210_PLL_FS_MASK, fs);
359 snd_soc_update_bits(codec, DA7210_PLL_DIV3, DA7210_PLL_BYP, bypass);
360
361 /* Enable active mode */
362 snd_soc_update_bits(codec, DA7210_STARTUP1,
363 DA7210_SC_MST_EN, DA7210_SC_MST_EN);
316 364
317 return 0; 365 return 0;
318} 366}
@@ -390,6 +438,7 @@ struct snd_soc_dai da7210_dai = {
390 .formats = DA7210_FORMATS, 438 .formats = DA7210_FORMATS,
391 }, 439 },
392 .ops = &da7210_dai_ops, 440 .ops = &da7210_dai_ops,
441 .symmetric_rates = 1,
393}; 442};
394EXPORT_SYMBOL_GPL(da7210_dai); 443EXPORT_SYMBOL_GPL(da7210_dai);
395 444
@@ -444,7 +493,21 @@ static int da7210_init(struct da7210_priv *da7210)
444 /* FIXME 493 /* FIXME
445 * 494 *
446 * This driver use fixed value here 495 * This driver use fixed value here
496 * And below settings expects MCLK = 12.288MHz
497 *
498 * When you select different MCLK, please check...
499 * DA7210_PLL_DIV1 val
500 * DA7210_PLL_DIV2 val
501 * DA7210_PLL_DIV3 val
502 * DA7210_PLL_DIV3 :: DA7210_MCLK_RANGExxx
503 */
504
505 /*
506 * make sure that DA7210 use bypass mode before start up
447 */ 507 */
508 da7210_write(codec, DA7210_STARTUP1, 0);
509 da7210_write(codec, DA7210_PLL_DIV3,
510 DA7210_MCLK_RANGE_10_20_MHZ | DA7210_PLL_BYP);
448 511
449 /* 512 /*
450 * ADC settings 513 * ADC settings
@@ -482,9 +545,28 @@ static int da7210_init(struct da7210_priv *da7210)
482 /* Diable PLL and bypass it */ 545 /* Diable PLL and bypass it */
483 da7210_write(codec, DA7210_PLL, DA7210_PLL_FS_48000); 546 da7210_write(codec, DA7210_PLL, DA7210_PLL_FS_48000);
484 547
485 /* Bypass PLL and set MCLK freq rang to 10-20MHz */ 548 /*
486 da7210_write(codec, DA7210_PLL_DIV3, 549 * If 48kHz sound came, it use bypass mode,
550 * and when it is 44.1kHz, it use PLL.
551 *
552 * This time, this driver sets PLL always ON
553 * and controls bypass/PLL mode by switching
554 * DA7210_PLL_DIV3 :: DA7210_PLL_BYP bit.
555 * see da7210_hw_params
556 */
557 da7210_write(codec, DA7210_PLL_DIV1, 0xE5); /* MCLK = 12.288MHz */
558 da7210_write(codec, DA7210_PLL_DIV2, 0x99);
559 da7210_write(codec, DA7210_PLL_DIV3, 0x0A |
487 DA7210_MCLK_RANGE_10_20_MHZ | DA7210_PLL_BYP); 560 DA7210_MCLK_RANGE_10_20_MHZ | DA7210_PLL_BYP);
561 snd_soc_update_bits(codec, DA7210_PLL, DA7210_PLL_EN, DA7210_PLL_EN);
562
563 /* As suggested by Dialog */
564 da7210_write(codec, DA7210_A_HID_UNLOCK, 0x8B); /* unlock */
565 da7210_write(codec, DA7210_A_TEST_UNLOCK, 0xB4);
566 da7210_write(codec, DA7210_A_PLL1, 0x01);
567 da7210_write(codec, DA7210_A_CP_MODE, 0x7C);
568 da7210_write(codec, DA7210_A_HID_UNLOCK, 0x00); /* re-lock */
569 da7210_write(codec, DA7210_A_TEST_UNLOCK, 0x00);
488 570
489 /* Activate all enabled subsystem */ 571 /* Activate all enabled subsystem */
490 da7210_write(codec, DA7210_STARTUP1, DA7210_SC_MST_EN); 572 da7210_write(codec, DA7210_STARTUP1, DA7210_SC_MST_EN);