aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/codecs/tlv320dac33.c
diff options
context:
space:
mode:
authorPeter Ujfalusi <peter.ujfalusi@nokia.com>2010-04-30 07:59:33 -0400
committerLiam Girdwood <lrg@slimlogic.co.uk>2010-05-03 07:55:48 -0400
commitef909d67299498010f07889bd0980c829ae78990 (patch)
tree58c83b124d0c1dd2c9b70b2740866cb21770c776 /sound/soc/codecs/tlv320dac33.c
parent1b7c9afbfbfde93d4da89dcebfd2314f7d79c064 (diff)
ASoC: tlv320dac33: Optimize power up, and restore
On power up we only need to initialize the codec, and restore only registers, which are not in either in DAPM nor in the playback start sequence. These are mostly gain related registers. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@nokia.com> Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Signed-off-by: Liam Girdwood <lrg@slimlogic.co.uk>
Diffstat (limited to 'sound/soc/codecs/tlv320dac33.c')
-rw-r--r--sound/soc/codecs/tlv320dac33.c106
1 files changed, 39 insertions, 67 deletions
diff --git a/sound/soc/codecs/tlv320dac33.c b/sound/soc/codecs/tlv320dac33.c
index 54b2a0508a11..329a97f6e0f8 100644
--- a/sound/soc/codecs/tlv320dac33.c
+++ b/sound/soc/codecs/tlv320dac33.c
@@ -284,45 +284,49 @@ static int dac33_write16(struct snd_soc_codec *codec, unsigned int reg,
284 return ret; 284 return ret;
285} 285}
286 286
287static void dac33_restore_regs(struct snd_soc_codec *codec) 287static void dac33_init_chip(struct snd_soc_codec *codec)
288{ 288{
289 struct tlv320dac33_priv *dac33 = snd_soc_codec_get_drvdata(codec); 289 struct tlv320dac33_priv *dac33 = snd_soc_codec_get_drvdata(codec);
290 u8 *cache = codec->reg_cache;
291 u8 data[2];
292 int i, ret;
293 290
294 if (!dac33->chip_power) 291 if (unlikely(!dac33->chip_power))
295 return; 292 return;
296 293
297 for (i = DAC33_PWR_CTRL; i <= DAC33_INTP_CTRL_B; i++) { 294 /* 44-46: DAC Control Registers */
298 data[0] = i; 295 /* A : DAC sample rate Fsref/1.5 */
299 data[1] = cache[i]; 296 dac33_write(codec, DAC33_DAC_CTRL_A, DAC33_DACRATE(0));
300 /* Skip the read only registers */ 297 /* B : DAC src=normal, not muted */
301 if ((i >= DAC33_INT_OSC_STATUS && 298 dac33_write(codec, DAC33_DAC_CTRL_B, DAC33_DACSRCR_RIGHT |
302 i <= DAC33_INT_OSC_FREQ_RAT_READ_B) || 299 DAC33_DACSRCL_LEFT);
303 (i >= DAC33_FIFO_WPTR_MSB && i <= DAC33_FIFO_IRQ_FLAG) || 300 /* C : (defaults) */
304 i == DAC33_DAC_STATUS_FLAGS || 301 dac33_write(codec, DAC33_DAC_CTRL_C, 0x00);
305 i == DAC33_SRC_EST_REF_CLK_RATIO_A || 302
306 i == DAC33_SRC_EST_REF_CLK_RATIO_B) 303 /* 64-65 : L&R DAC power control
307 continue; 304 Line In -> OUT 1V/V Gain, DAC -> OUT 4V/V Gain*/
308 ret = codec->hw_write(codec->control_data, data, 2); 305 dac33_write(codec, DAC33_LDAC_PWR_CTRL, DAC33_LROUT_GAIN(2));
309 if (ret != 2) 306 dac33_write(codec, DAC33_RDAC_PWR_CTRL, DAC33_LROUT_GAIN(2));
310 dev_err(codec->dev, "Write failed (%d)\n", ret); 307
311 } 308 /* 73 : volume soft stepping control,
312 for (i = DAC33_LDAC_PWR_CTRL; i <= DAC33_LINEL_TO_LLO_VOL; i++) { 309 clock source = internal osc (?) */
313 data[0] = i; 310 dac33_write(codec, DAC33_ANA_VOL_SOFT_STEP_CTRL, DAC33_VOLCLKEN);
314 data[1] = cache[i]; 311
315 ret = codec->hw_write(codec->control_data, data, 2); 312 /* 66 : LOP/LOM Modes */
316 if (ret != 2) 313 dac33_write(codec, DAC33_OUT_AMP_CM_CTRL, 0xff);
317 dev_err(codec->dev, "Write failed (%d)\n", ret); 314
318 } 315 /* 68 : LOM inverted from LOP */
319 for (i = DAC33_LINER_TO_RLO_VOL; i <= DAC33_OSC_TRIM; i++) { 316 dac33_write(codec, DAC33_OUT_AMP_CTRL, (3<<2));
320 data[0] = i; 317
321 data[1] = cache[i]; 318 dac33_write(codec, DAC33_PWR_CTRL, DAC33_PDNALLB);
322 ret = codec->hw_write(codec->control_data, data, 2); 319
323 if (ret != 2) 320 /* Restore only selected registers (gains mostly) */
324 dev_err(codec->dev, "Write failed (%d)\n", ret); 321 dac33_write(codec, DAC33_LDAC_DIG_VOL_CTRL,
325 } 322 dac33_read_reg_cache(codec, DAC33_LDAC_DIG_VOL_CTRL));
323 dac33_write(codec, DAC33_RDAC_DIG_VOL_CTRL,
324 dac33_read_reg_cache(codec, DAC33_RDAC_DIG_VOL_CTRL));
325
326 dac33_write(codec, DAC33_LINEL_TO_LLO_VOL,
327 dac33_read_reg_cache(codec, DAC33_LINEL_TO_LLO_VOL));
328 dac33_write(codec, DAC33_LINER_TO_RLO_VOL,
329 dac33_read_reg_cache(codec, DAC33_LINER_TO_RLO_VOL));
326} 330}
327 331
328static inline void dac33_soft_power(struct snd_soc_codec *codec, int power) 332static inline void dac33_soft_power(struct snd_soc_codec *codec, int power)
@@ -358,8 +362,7 @@ static int dac33_hard_power(struct snd_soc_codec *codec, int power)
358 362
359 dac33->chip_power = 1; 363 dac33->chip_power = 1;
360 364
361 /* Restore registers */ 365 dac33_init_chip(codec);
362 dac33_restore_regs(codec);
363 366
364 dac33_soft_power(codec, 1); 367 dac33_soft_power(codec, 1);
365 } else { 368 } else {
@@ -1269,35 +1272,6 @@ static int dac33_set_dai_fmt(struct snd_soc_dai *codec_dai,
1269 return 0; 1272 return 0;
1270} 1273}
1271 1274
1272static void dac33_init_chip(struct snd_soc_codec *codec)
1273{
1274 /* 44-46: DAC Control Registers */
1275 /* A : DAC sample rate Fsref/1.5 */
1276 dac33_write(codec, DAC33_DAC_CTRL_A, DAC33_DACRATE(0));
1277 /* B : DAC src=normal, not muted */
1278 dac33_write(codec, DAC33_DAC_CTRL_B, DAC33_DACSRCR_RIGHT |
1279 DAC33_DACSRCL_LEFT);
1280 /* C : (defaults) */
1281 dac33_write(codec, DAC33_DAC_CTRL_C, 0x00);
1282
1283 /* 64-65 : L&R DAC power control
1284 Line In -> OUT 1V/V Gain, DAC -> OUT 4V/V Gain*/
1285 dac33_write(codec, DAC33_LDAC_PWR_CTRL, DAC33_LROUT_GAIN(2));
1286 dac33_write(codec, DAC33_RDAC_PWR_CTRL, DAC33_LROUT_GAIN(2));
1287
1288 /* 73 : volume soft stepping control,
1289 clock source = internal osc (?) */
1290 dac33_write(codec, DAC33_ANA_VOL_SOFT_STEP_CTRL, DAC33_VOLCLKEN);
1291
1292 /* 66 : LOP/LOM Modes */
1293 dac33_write(codec, DAC33_OUT_AMP_CM_CTRL, 0xff);
1294
1295 /* 68 : LOM inverted from LOP */
1296 dac33_write(codec, DAC33_OUT_AMP_CTRL, (3<<2));
1297
1298 dac33_write(codec, DAC33_PWR_CTRL, DAC33_PDNALLB);
1299}
1300
1301static int dac33_soc_probe(struct platform_device *pdev) 1275static int dac33_soc_probe(struct platform_device *pdev)
1302{ 1276{
1303 struct snd_soc_device *socdev = platform_get_drvdata(pdev); 1277 struct snd_soc_device *socdev = platform_get_drvdata(pdev);
@@ -1313,8 +1287,6 @@ static int dac33_soc_probe(struct platform_device *pdev)
1313 1287
1314 /* Power up the codec */ 1288 /* Power up the codec */
1315 dac33_hard_power(codec, 1); 1289 dac33_hard_power(codec, 1);
1316 /* Set default configuration */
1317 dac33_init_chip(codec);
1318 1290
1319 /* register pcms */ 1291 /* register pcms */
1320 ret = snd_soc_new_pcms(socdev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1); 1292 ret = snd_soc_new_pcms(socdev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1);