aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/davinci/davinci-mcasp.c
diff options
context:
space:
mode:
authorPeter Ujfalusi <peter.ujfalusi@ti.com>2014-04-04 07:31:44 -0400
committerMark Brown <broonie@linaro.org>2014-04-14 12:24:24 -0400
commit83f12503bd1fb18d3fd460871660b34faf671918 (patch)
tree7689085b75c13180b42fcffc353b301ad80ed26f /sound/soc/davinci/davinci-mcasp.c
parent188edc59c297fcd971d6a4ae5f5f5dacff7b315b (diff)
ASoC: davinci-mcasp: Move the FS polarity change out from the switch case
FS polarity can be either rising or falling edge in McASP. Instead of accessing the registers in every switch/case set a flag and write the registers after the switch for the invert configuration. This change will help when adding support for more formats also. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com> Signed-off-by: Mark Brown <broonie@linaro.org>
Diffstat (limited to 'sound/soc/davinci/davinci-mcasp.c')
-rw-r--r--sound/soc/davinci/davinci-mcasp.c27
1 files changed, 14 insertions, 13 deletions
diff --git a/sound/soc/davinci/davinci-mcasp.c b/sound/soc/davinci/davinci-mcasp.c
index 58b6d47cc8f8..113e74c9479f 100644
--- a/sound/soc/davinci/davinci-mcasp.c
+++ b/sound/soc/davinci/davinci-mcasp.c
@@ -272,6 +272,7 @@ static int davinci_mcasp_set_dai_fmt(struct snd_soc_dai *cpu_dai,
272 struct davinci_mcasp *mcasp = snd_soc_dai_get_drvdata(cpu_dai); 272 struct davinci_mcasp *mcasp = snd_soc_dai_get_drvdata(cpu_dai);
273 int ret = 0; 273 int ret = 0;
274 u32 data_delay; 274 u32 data_delay;
275 bool fs_pol_rising;
275 276
276 pm_runtime_get_sync(mcasp->dev); 277 pm_runtime_get_sync(mcasp->dev);
277 switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { 278 switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
@@ -351,39 +352,39 @@ static int davinci_mcasp_set_dai_fmt(struct snd_soc_dai *cpu_dai,
351 switch (fmt & SND_SOC_DAIFMT_INV_MASK) { 352 switch (fmt & SND_SOC_DAIFMT_INV_MASK) {
352 case SND_SOC_DAIFMT_IB_NF: 353 case SND_SOC_DAIFMT_IB_NF:
353 mcasp_clr_bits(mcasp, DAVINCI_MCASP_ACLKXCTL_REG, ACLKXPOL); 354 mcasp_clr_bits(mcasp, DAVINCI_MCASP_ACLKXCTL_REG, ACLKXPOL);
354 mcasp_clr_bits(mcasp, DAVINCI_MCASP_TXFMCTL_REG, FSXPOL);
355
356 mcasp_clr_bits(mcasp, DAVINCI_MCASP_ACLKRCTL_REG, ACLKRPOL); 355 mcasp_clr_bits(mcasp, DAVINCI_MCASP_ACLKRCTL_REG, ACLKRPOL);
357 mcasp_clr_bits(mcasp, DAVINCI_MCASP_RXFMCTL_REG, FSRPOL); 356 fs_pol_rising = true;
358 break; 357 break;
359 358
360 case SND_SOC_DAIFMT_NB_IF: 359 case SND_SOC_DAIFMT_NB_IF:
361 mcasp_set_bits(mcasp, DAVINCI_MCASP_ACLKXCTL_REG, ACLKXPOL); 360 mcasp_set_bits(mcasp, DAVINCI_MCASP_ACLKXCTL_REG, ACLKXPOL);
362 mcasp_set_bits(mcasp, DAVINCI_MCASP_TXFMCTL_REG, FSXPOL);
363
364 mcasp_set_bits(mcasp, DAVINCI_MCASP_ACLKRCTL_REG, ACLKRPOL); 361 mcasp_set_bits(mcasp, DAVINCI_MCASP_ACLKRCTL_REG, ACLKRPOL);
365 mcasp_set_bits(mcasp, DAVINCI_MCASP_RXFMCTL_REG, FSRPOL); 362 fs_pol_rising = false;
366 break; 363 break;
367 364
368 case SND_SOC_DAIFMT_IB_IF: 365 case SND_SOC_DAIFMT_IB_IF:
369 mcasp_clr_bits(mcasp, DAVINCI_MCASP_ACLKXCTL_REG, ACLKXPOL); 366 mcasp_clr_bits(mcasp, DAVINCI_MCASP_ACLKXCTL_REG, ACLKXPOL);
370 mcasp_set_bits(mcasp, DAVINCI_MCASP_TXFMCTL_REG, FSXPOL);
371
372 mcasp_clr_bits(mcasp, DAVINCI_MCASP_ACLKRCTL_REG, ACLKRPOL); 367 mcasp_clr_bits(mcasp, DAVINCI_MCASP_ACLKRCTL_REG, ACLKRPOL);
373 mcasp_set_bits(mcasp, DAVINCI_MCASP_RXFMCTL_REG, FSRPOL); 368 fs_pol_rising = false;
374 break; 369 break;
375 370
376 case SND_SOC_DAIFMT_NB_NF: 371 case SND_SOC_DAIFMT_NB_NF:
377 mcasp_set_bits(mcasp, DAVINCI_MCASP_ACLKXCTL_REG, ACLKXPOL); 372 mcasp_set_bits(mcasp, DAVINCI_MCASP_ACLKXCTL_REG, ACLKXPOL);
378 mcasp_clr_bits(mcasp, DAVINCI_MCASP_TXFMCTL_REG, FSXPOL);
379
380 mcasp_set_bits(mcasp, DAVINCI_MCASP_ACLKRCTL_REG, ACLKRPOL); 373 mcasp_set_bits(mcasp, DAVINCI_MCASP_ACLKRCTL_REG, ACLKRPOL);
381 mcasp_clr_bits(mcasp, DAVINCI_MCASP_RXFMCTL_REG, FSRPOL); 374 fs_pol_rising = true;
382 break; 375 break;
383 376
384 default: 377 default:
385 ret = -EINVAL; 378 ret = -EINVAL;
386 break; 379 goto out;
380 }
381
382 if (fs_pol_rising) {
383 mcasp_clr_bits(mcasp, DAVINCI_MCASP_TXFMCTL_REG, FSXPOL);
384 mcasp_clr_bits(mcasp, DAVINCI_MCASP_RXFMCTL_REG, FSRPOL);
385 } else {
386 mcasp_set_bits(mcasp, DAVINCI_MCASP_TXFMCTL_REG, FSXPOL);
387 mcasp_set_bits(mcasp, DAVINCI_MCASP_RXFMCTL_REG, FSRPOL);
387 } 388 }
388out: 389out:
389 pm_runtime_put_sync(mcasp->dev); 390 pm_runtime_put_sync(mcasp->dev);