aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/davinci/davinci-mcasp.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/soc/davinci/davinci-mcasp.c')
-rw-r--r--sound/soc/davinci/davinci-mcasp.c260
1 files changed, 161 insertions, 99 deletions
diff --git a/sound/soc/davinci/davinci-mcasp.c b/sound/soc/davinci/davinci-mcasp.c
index 4f75cac462d1..14058dc6eaf8 100644
--- a/sound/soc/davinci/davinci-mcasp.c
+++ b/sound/soc/davinci/davinci-mcasp.c
@@ -36,6 +36,9 @@
36 36
37#include "davinci-pcm.h" 37#include "davinci-pcm.h"
38#include "davinci-mcasp.h" 38#include "davinci-mcasp.h"
39#include "../omap/omap-pcm.h"
40
41#define MCASP_MAX_AFIFO_DEPTH 64
39 42
40struct davinci_mcasp_context { 43struct davinci_mcasp_context {
41 u32 txfmtctl; 44 u32 txfmtctl;
@@ -269,25 +272,51 @@ static int davinci_mcasp_set_dai_fmt(struct snd_soc_dai *cpu_dai,
269{ 272{
270 struct davinci_mcasp *mcasp = snd_soc_dai_get_drvdata(cpu_dai); 273 struct davinci_mcasp *mcasp = snd_soc_dai_get_drvdata(cpu_dai);
271 int ret = 0; 274 int ret = 0;
275 u32 data_delay;
276 bool fs_pol_rising;
277 bool inv_fs = false;
272 278
273 pm_runtime_get_sync(mcasp->dev); 279 pm_runtime_get_sync(mcasp->dev);
274 switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { 280 switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
281 case SND_SOC_DAIFMT_DSP_A:
282 mcasp_clr_bits(mcasp, DAVINCI_MCASP_TXFMCTL_REG, FSXDUR);
283 mcasp_clr_bits(mcasp, DAVINCI_MCASP_RXFMCTL_REG, FSRDUR);
284 /* 1st data bit occur one ACLK cycle after the frame sync */
285 data_delay = 1;
286 break;
275 case SND_SOC_DAIFMT_DSP_B: 287 case SND_SOC_DAIFMT_DSP_B:
276 case SND_SOC_DAIFMT_AC97: 288 case SND_SOC_DAIFMT_AC97:
277 mcasp_clr_bits(mcasp, DAVINCI_MCASP_TXFMCTL_REG, FSXDUR); 289 mcasp_clr_bits(mcasp, DAVINCI_MCASP_TXFMCTL_REG, FSXDUR);
278 mcasp_clr_bits(mcasp, DAVINCI_MCASP_RXFMCTL_REG, FSRDUR); 290 mcasp_clr_bits(mcasp, DAVINCI_MCASP_RXFMCTL_REG, FSRDUR);
291 /* No delay after FS */
292 data_delay = 0;
279 break; 293 break;
280 default: 294 case SND_SOC_DAIFMT_I2S:
281 /* configure a full-word SYNC pulse (LRCLK) */ 295 /* configure a full-word SYNC pulse (LRCLK) */
282 mcasp_set_bits(mcasp, DAVINCI_MCASP_TXFMCTL_REG, FSXDUR); 296 mcasp_set_bits(mcasp, DAVINCI_MCASP_TXFMCTL_REG, FSXDUR);
283 mcasp_set_bits(mcasp, DAVINCI_MCASP_RXFMCTL_REG, FSRDUR); 297 mcasp_set_bits(mcasp, DAVINCI_MCASP_RXFMCTL_REG, FSRDUR);
284 298 /* 1st data bit occur one ACLK cycle after the frame sync */
285 /* make 1st data bit occur one ACLK cycle after the frame sync */ 299 data_delay = 1;
286 mcasp_set_bits(mcasp, DAVINCI_MCASP_TXFMT_REG, FSXDLY(1)); 300 /* FS need to be inverted */
287 mcasp_set_bits(mcasp, DAVINCI_MCASP_RXFMT_REG, FSRDLY(1)); 301 inv_fs = true;
288 break; 302 break;
303 case SND_SOC_DAIFMT_LEFT_J:
304 /* configure a full-word SYNC pulse (LRCLK) */
305 mcasp_set_bits(mcasp, DAVINCI_MCASP_TXFMCTL_REG, FSXDUR);
306 mcasp_set_bits(mcasp, DAVINCI_MCASP_RXFMCTL_REG, FSRDUR);
307 /* No delay after FS */
308 data_delay = 0;
309 break;
310 default:
311 ret = -EINVAL;
312 goto out;
289 } 313 }
290 314
315 mcasp_mod_bits(mcasp, DAVINCI_MCASP_TXFMT_REG, FSXDLY(data_delay),
316 FSXDLY(3));
317 mcasp_mod_bits(mcasp, DAVINCI_MCASP_RXFMT_REG, FSRDLY(data_delay),
318 FSRDLY(3));
319
291 switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { 320 switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
292 case SND_SOC_DAIFMT_CBS_CFS: 321 case SND_SOC_DAIFMT_CBS_CFS:
293 /* codec is clock and frame slave */ 322 /* codec is clock and frame slave */
@@ -325,7 +354,6 @@ static int davinci_mcasp_set_dai_fmt(struct snd_soc_dai *cpu_dai,
325 ACLKX | AHCLKX | AFSX | ACLKR | AHCLKR | AFSR); 354 ACLKX | AHCLKX | AFSX | ACLKR | AHCLKR | AFSR);
326 mcasp->bclk_master = 0; 355 mcasp->bclk_master = 0;
327 break; 356 break;
328
329 default: 357 default:
330 ret = -EINVAL; 358 ret = -EINVAL;
331 goto out; 359 goto out;
@@ -334,39 +362,38 @@ static int davinci_mcasp_set_dai_fmt(struct snd_soc_dai *cpu_dai,
334 switch (fmt & SND_SOC_DAIFMT_INV_MASK) { 362 switch (fmt & SND_SOC_DAIFMT_INV_MASK) {
335 case SND_SOC_DAIFMT_IB_NF: 363 case SND_SOC_DAIFMT_IB_NF:
336 mcasp_clr_bits(mcasp, DAVINCI_MCASP_ACLKXCTL_REG, ACLKXPOL); 364 mcasp_clr_bits(mcasp, DAVINCI_MCASP_ACLKXCTL_REG, ACLKXPOL);
337 mcasp_clr_bits(mcasp, DAVINCI_MCASP_TXFMCTL_REG, FSXPOL);
338
339 mcasp_clr_bits(mcasp, DAVINCI_MCASP_ACLKRCTL_REG, ACLKRPOL); 365 mcasp_clr_bits(mcasp, DAVINCI_MCASP_ACLKRCTL_REG, ACLKRPOL);
340 mcasp_clr_bits(mcasp, DAVINCI_MCASP_RXFMCTL_REG, FSRPOL); 366 fs_pol_rising = true;
341 break; 367 break;
342
343 case SND_SOC_DAIFMT_NB_IF: 368 case SND_SOC_DAIFMT_NB_IF:
344 mcasp_set_bits(mcasp, DAVINCI_MCASP_ACLKXCTL_REG, ACLKXPOL); 369 mcasp_set_bits(mcasp, DAVINCI_MCASP_ACLKXCTL_REG, ACLKXPOL);
345 mcasp_set_bits(mcasp, DAVINCI_MCASP_TXFMCTL_REG, FSXPOL);
346
347 mcasp_set_bits(mcasp, DAVINCI_MCASP_ACLKRCTL_REG, ACLKRPOL); 370 mcasp_set_bits(mcasp, DAVINCI_MCASP_ACLKRCTL_REG, ACLKRPOL);
348 mcasp_set_bits(mcasp, DAVINCI_MCASP_RXFMCTL_REG, FSRPOL); 371 fs_pol_rising = false;
349 break; 372 break;
350
351 case SND_SOC_DAIFMT_IB_IF: 373 case SND_SOC_DAIFMT_IB_IF:
352 mcasp_clr_bits(mcasp, DAVINCI_MCASP_ACLKXCTL_REG, ACLKXPOL); 374 mcasp_clr_bits(mcasp, DAVINCI_MCASP_ACLKXCTL_REG, ACLKXPOL);
353 mcasp_set_bits(mcasp, DAVINCI_MCASP_TXFMCTL_REG, FSXPOL);
354
355 mcasp_clr_bits(mcasp, DAVINCI_MCASP_ACLKRCTL_REG, ACLKRPOL); 375 mcasp_clr_bits(mcasp, DAVINCI_MCASP_ACLKRCTL_REG, ACLKRPOL);
356 mcasp_set_bits(mcasp, DAVINCI_MCASP_RXFMCTL_REG, FSRPOL); 376 fs_pol_rising = false;
357 break; 377 break;
358
359 case SND_SOC_DAIFMT_NB_NF: 378 case SND_SOC_DAIFMT_NB_NF:
360 mcasp_set_bits(mcasp, DAVINCI_MCASP_ACLKXCTL_REG, ACLKXPOL); 379 mcasp_set_bits(mcasp, DAVINCI_MCASP_ACLKXCTL_REG, ACLKXPOL);
361 mcasp_clr_bits(mcasp, DAVINCI_MCASP_TXFMCTL_REG, FSXPOL);
362
363 mcasp_set_bits(mcasp, DAVINCI_MCASP_ACLKRCTL_REG, ACLKRPOL); 380 mcasp_set_bits(mcasp, DAVINCI_MCASP_ACLKRCTL_REG, ACLKRPOL);
364 mcasp_clr_bits(mcasp, DAVINCI_MCASP_RXFMCTL_REG, FSRPOL); 381 fs_pol_rising = true;
365 break; 382 break;
366
367 default: 383 default:
368 ret = -EINVAL; 384 ret = -EINVAL;
369 break; 385 goto out;
386 }
387
388 if (inv_fs)
389 fs_pol_rising = !fs_pol_rising;
390
391 if (fs_pol_rising) {
392 mcasp_clr_bits(mcasp, DAVINCI_MCASP_TXFMCTL_REG, FSXPOL);
393 mcasp_clr_bits(mcasp, DAVINCI_MCASP_RXFMCTL_REG, FSRPOL);
394 } else {
395 mcasp_set_bits(mcasp, DAVINCI_MCASP_TXFMCTL_REG, FSXPOL);
396 mcasp_set_bits(mcasp, DAVINCI_MCASP_RXFMCTL_REG, FSRPOL);
370 } 397 }
371out: 398out:
372 pm_runtime_put_sync(mcasp->dev); 399 pm_runtime_put_sync(mcasp->dev);
@@ -464,17 +491,19 @@ static int davinci_config_channel_size(struct davinci_mcasp *mcasp,
464} 491}
465 492
466static int mcasp_common_hw_param(struct davinci_mcasp *mcasp, int stream, 493static int mcasp_common_hw_param(struct davinci_mcasp *mcasp, int stream,
467 int channels) 494 int period_words, int channels)
468{ 495{
496 struct davinci_pcm_dma_params *dma_params = &mcasp->dma_params[stream];
497 struct snd_dmaengine_dai_dma_data *dma_data = &mcasp->dma_data[stream];
469 int i; 498 int i;
470 u8 tx_ser = 0; 499 u8 tx_ser = 0;
471 u8 rx_ser = 0; 500 u8 rx_ser = 0;
472 u8 ser;
473 u8 slots = mcasp->tdm_slots; 501 u8 slots = mcasp->tdm_slots;
474 u8 max_active_serializers = (channels + slots - 1) / slots; 502 u8 max_active_serializers = (channels + slots - 1) / slots;
503 int active_serializers, numevt, n;
475 u32 reg; 504 u32 reg;
476 /* Default configuration */ 505 /* Default configuration */
477 if (mcasp->version != MCASP_VERSION_4) 506 if (mcasp->version < MCASP_VERSION_3)
478 mcasp_set_bits(mcasp, DAVINCI_MCASP_PWREMUMGT_REG, MCASP_SOFT); 507 mcasp_set_bits(mcasp, DAVINCI_MCASP_PWREMUMGT_REG, MCASP_SOFT);
479 508
480 /* All PINS as McASP */ 509 /* All PINS as McASP */
@@ -505,37 +534,71 @@ static int mcasp_common_hw_param(struct davinci_mcasp *mcasp, int stream,
505 } 534 }
506 } 535 }
507 536
508 if (stream == SNDRV_PCM_STREAM_PLAYBACK) 537 if (stream == SNDRV_PCM_STREAM_PLAYBACK) {
509 ser = tx_ser; 538 active_serializers = tx_ser;
510 else 539 numevt = mcasp->txnumevt;
511 ser = rx_ser; 540 reg = mcasp->fifo_base + MCASP_WFIFOCTL_OFFSET;
541 } else {
542 active_serializers = rx_ser;
543 numevt = mcasp->rxnumevt;
544 reg = mcasp->fifo_base + MCASP_RFIFOCTL_OFFSET;
545 }
512 546
513 if (ser < max_active_serializers) { 547 if (active_serializers < max_active_serializers) {
514 dev_warn(mcasp->dev, "stream has more channels (%d) than are " 548 dev_warn(mcasp->dev, "stream has more channels (%d) than are "
515 "enabled in mcasp (%d)\n", channels, ser * slots); 549 "enabled in mcasp (%d)\n", channels,
550 active_serializers * slots);
516 return -EINVAL; 551 return -EINVAL;
517 } 552 }
518 553
519 if (mcasp->txnumevt && stream == SNDRV_PCM_STREAM_PLAYBACK) { 554 /* AFIFO is not in use */
520 if (mcasp->txnumevt * tx_ser > 64) 555 if (!numevt) {
521 mcasp->txnumevt = 1; 556 /* Configure the burst size for platform drivers */
522 557 if (active_serializers > 1) {
523 reg = mcasp->fifo_base + MCASP_WFIFOCTL_OFFSET; 558 /*
524 mcasp_mod_bits(mcasp, reg, tx_ser, NUMDMA_MASK); 559 * If more than one serializers are in use we have one
525 mcasp_mod_bits(mcasp, reg, ((mcasp->txnumevt * tx_ser) << 8), 560 * DMA request to provide data for all serializers.
526 NUMEVT_MASK); 561 * For example if three serializers are enabled the DMA
562 * need to transfer three words per DMA request.
563 */
564 dma_params->fifo_level = active_serializers;
565 dma_data->maxburst = active_serializers;
566 } else {
567 dma_params->fifo_level = 0;
568 dma_data->maxburst = 0;
569 }
570 return 0;
527 } 571 }
528 572
529 if (mcasp->rxnumevt && stream == SNDRV_PCM_STREAM_CAPTURE) { 573 if (period_words % active_serializers) {
530 if (mcasp->rxnumevt * rx_ser > 64) 574 dev_err(mcasp->dev, "Invalid combination of period words and "
531 mcasp->rxnumevt = 1; 575 "active serializers: %d, %d\n", period_words,
532 576 active_serializers);
533 reg = mcasp->fifo_base + MCASP_RFIFOCTL_OFFSET; 577 return -EINVAL;
534 mcasp_mod_bits(mcasp, reg, rx_ser, NUMDMA_MASK);
535 mcasp_mod_bits(mcasp, reg, ((mcasp->rxnumevt * rx_ser) << 8),
536 NUMEVT_MASK);
537 } 578 }
538 579
580 /*
581 * Calculate the optimal AFIFO depth for platform side:
582 * The number of words for numevt need to be in steps of active
583 * serializers.
584 */
585 n = numevt % active_serializers;
586 if (n)
587 numevt += (active_serializers - n);
588 while (period_words % numevt && numevt > 0)
589 numevt -= active_serializers;
590 if (numevt <= 0)
591 numevt = active_serializers;
592
593 mcasp_mod_bits(mcasp, reg, active_serializers, NUMDMA_MASK);
594 mcasp_mod_bits(mcasp, reg, NUMEVT(numevt), NUMEVT_MASK);
595
596 /* Configure the burst size for platform drivers */
597 if (numevt == 1)
598 numevt = 0;
599 dma_params->fifo_level = numevt;
600 dma_data->maxburst = numevt;
601
539 return 0; 602 return 0;
540} 603}
541 604
@@ -607,27 +670,24 @@ static int davinci_mcasp_hw_params(struct snd_pcm_substream *substream,
607 struct davinci_mcasp *mcasp = snd_soc_dai_get_drvdata(cpu_dai); 670 struct davinci_mcasp *mcasp = snd_soc_dai_get_drvdata(cpu_dai);
608 struct davinci_pcm_dma_params *dma_params = 671 struct davinci_pcm_dma_params *dma_params =
609 &mcasp->dma_params[substream->stream]; 672 &mcasp->dma_params[substream->stream];
610 struct snd_dmaengine_dai_dma_data *dma_data =
611 &mcasp->dma_data[substream->stream];
612 int word_length; 673 int word_length;
613 u8 fifo_level;
614 u8 slots = mcasp->tdm_slots;
615 u8 active_serializers;
616 int channels = params_channels(params); 674 int channels = params_channels(params);
675 int period_size = params_period_size(params);
617 int ret; 676 int ret;
618 677
619 /* If mcasp is BCLK master we need to set BCLK divider */ 678 /* If mcasp is BCLK master we need to set BCLK divider */
620 if (mcasp->bclk_master) { 679 if (mcasp->bclk_master) {
621 unsigned int bclk_freq = snd_soc_params_to_bclk(params); 680 unsigned int bclk_freq = snd_soc_params_to_bclk(params);
622 if (mcasp->sysclk_freq % bclk_freq != 0) { 681 if (mcasp->sysclk_freq % bclk_freq != 0) {
623 dev_err(mcasp->dev, "Can't produce requred BCLK\n"); 682 dev_err(mcasp->dev, "Can't produce required BCLK\n");
624 return -EINVAL; 683 return -EINVAL;
625 } 684 }
626 davinci_mcasp_set_clkdiv( 685 davinci_mcasp_set_clkdiv(
627 cpu_dai, 1, mcasp->sysclk_freq / bclk_freq); 686 cpu_dai, 1, mcasp->sysclk_freq / bclk_freq);
628 } 687 }
629 688
630 ret = mcasp_common_hw_param(mcasp, substream->stream, channels); 689 ret = mcasp_common_hw_param(mcasp, substream->stream,
690 period_size * channels, channels);
631 if (ret) 691 if (ret)
632 return ret; 692 return ret;
633 693
@@ -671,21 +731,11 @@ static int davinci_mcasp_hw_params(struct snd_pcm_substream *substream,
671 return -EINVAL; 731 return -EINVAL;
672 } 732 }
673 733
674 /* Calculate FIFO level */ 734 if (mcasp->version == MCASP_VERSION_2 && !dma_params->fifo_level)
675 active_serializers = (channels + slots - 1) / slots;
676 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
677 fifo_level = mcasp->txnumevt * active_serializers;
678 else
679 fifo_level = mcasp->rxnumevt * active_serializers;
680
681 if (mcasp->version == MCASP_VERSION_2 && !fifo_level)
682 dma_params->acnt = 4; 735 dma_params->acnt = 4;
683 else 736 else
684 dma_params->acnt = dma_params->data_type; 737 dma_params->acnt = dma_params->data_type;
685 738
686 dma_params->fifo_level = fifo_level;
687 dma_data->maxburst = fifo_level;
688
689 davinci_config_channel_size(mcasp, word_length); 739 davinci_config_channel_size(mcasp, word_length);
690 740
691 return 0; 741 return 0;
@@ -716,22 +766,7 @@ static int davinci_mcasp_trigger(struct snd_pcm_substream *substream,
716 return ret; 766 return ret;
717} 767}
718 768
719static int davinci_mcasp_startup(struct snd_pcm_substream *substream,
720 struct snd_soc_dai *dai)
721{
722 struct davinci_mcasp *mcasp = snd_soc_dai_get_drvdata(dai);
723
724 if (mcasp->version == MCASP_VERSION_4)
725 snd_soc_dai_set_dma_data(dai, substream,
726 &mcasp->dma_data[substream->stream]);
727 else
728 snd_soc_dai_set_dma_data(dai, substream, mcasp->dma_params);
729
730 return 0;
731}
732
733static const struct snd_soc_dai_ops davinci_mcasp_dai_ops = { 769static const struct snd_soc_dai_ops davinci_mcasp_dai_ops = {
734 .startup = davinci_mcasp_startup,
735 .trigger = davinci_mcasp_trigger, 770 .trigger = davinci_mcasp_trigger,
736 .hw_params = davinci_mcasp_hw_params, 771 .hw_params = davinci_mcasp_hw_params,
737 .set_fmt = davinci_mcasp_set_dai_fmt, 772 .set_fmt = davinci_mcasp_set_dai_fmt,
@@ -739,6 +774,25 @@ static const struct snd_soc_dai_ops davinci_mcasp_dai_ops = {
739 .set_sysclk = davinci_mcasp_set_sysclk, 774 .set_sysclk = davinci_mcasp_set_sysclk,
740}; 775};
741 776
777static int davinci_mcasp_dai_probe(struct snd_soc_dai *dai)
778{
779 struct davinci_mcasp *mcasp = snd_soc_dai_get_drvdata(dai);
780
781 if (mcasp->version == MCASP_VERSION_4) {
782 /* Using dmaengine PCM */
783 dai->playback_dma_data =
784 &mcasp->dma_data[SNDRV_PCM_STREAM_PLAYBACK];
785 dai->capture_dma_data =
786 &mcasp->dma_data[SNDRV_PCM_STREAM_CAPTURE];
787 } else {
788 /* Using davinci-pcm */
789 dai->playback_dma_data = mcasp->dma_params;
790 dai->capture_dma_data = mcasp->dma_params;
791 }
792
793 return 0;
794}
795
742#ifdef CONFIG_PM_SLEEP 796#ifdef CONFIG_PM_SLEEP
743static int davinci_mcasp_suspend(struct snd_soc_dai *dai) 797static int davinci_mcasp_suspend(struct snd_soc_dai *dai)
744{ 798{
@@ -792,6 +846,7 @@ static int davinci_mcasp_resume(struct snd_soc_dai *dai)
792static struct snd_soc_dai_driver davinci_mcasp_dai[] = { 846static struct snd_soc_dai_driver davinci_mcasp_dai[] = {
793 { 847 {
794 .name = "davinci-mcasp.0", 848 .name = "davinci-mcasp.0",
849 .probe = davinci_mcasp_dai_probe,
795 .suspend = davinci_mcasp_suspend, 850 .suspend = davinci_mcasp_suspend,
796 .resume = davinci_mcasp_resume, 851 .resume = davinci_mcasp_resume,
797 .playback = { 852 .playback = {
@@ -811,6 +866,7 @@ static struct snd_soc_dai_driver davinci_mcasp_dai[] = {
811 }, 866 },
812 { 867 {
813 .name = "davinci-mcasp.1", 868 .name = "davinci-mcasp.1",
869 .probe = davinci_mcasp_dai_probe,
814 .playback = { 870 .playback = {
815 .channels_min = 1, 871 .channels_min = 1,
816 .channels_max = 384, 872 .channels_max = 384,
@@ -1078,7 +1134,7 @@ static int davinci_mcasp_probe(struct platform_device *pdev)
1078 if (!mcasp->base) { 1134 if (!mcasp->base) {
1079 dev_err(&pdev->dev, "ioremap failed\n"); 1135 dev_err(&pdev->dev, "ioremap failed\n");
1080 ret = -ENOMEM; 1136 ret = -ENOMEM;
1081 goto err_release_clk; 1137 goto err;
1082 } 1138 }
1083 1139
1084 mcasp->op_mode = pdata->op_mode; 1140 mcasp->op_mode = pdata->op_mode;
@@ -1159,25 +1215,37 @@ static int davinci_mcasp_probe(struct platform_device *pdev)
1159 1215
1160 mcasp_reparent_fck(pdev); 1216 mcasp_reparent_fck(pdev);
1161 1217
1162 ret = snd_soc_register_component(&pdev->dev, &davinci_mcasp_component, 1218 ret = devm_snd_soc_register_component(&pdev->dev,
1163 &davinci_mcasp_dai[pdata->op_mode], 1); 1219 &davinci_mcasp_component,
1220 &davinci_mcasp_dai[pdata->op_mode], 1);
1164 1221
1165 if (ret != 0) 1222 if (ret != 0)
1166 goto err_release_clk; 1223 goto err;
1167 1224
1168 if (mcasp->version != MCASP_VERSION_4) { 1225 switch (mcasp->version) {
1226 case MCASP_VERSION_1:
1227 case MCASP_VERSION_2:
1228 case MCASP_VERSION_3:
1169 ret = davinci_soc_platform_register(&pdev->dev); 1229 ret = davinci_soc_platform_register(&pdev->dev);
1170 if (ret) { 1230 break;
1171 dev_err(&pdev->dev, "register PCM failed: %d\n", ret); 1231 case MCASP_VERSION_4:
1172 goto err_unregister_component; 1232 ret = omap_pcm_platform_register(&pdev->dev);
1173 } 1233 break;
1234 default:
1235 dev_err(&pdev->dev, "Invalid McASP version: %d\n",
1236 mcasp->version);
1237 ret = -EINVAL;
1238 break;
1239 }
1240
1241 if (ret) {
1242 dev_err(&pdev->dev, "register PCM failed: %d\n", ret);
1243 goto err;
1174 } 1244 }
1175 1245
1176 return 0; 1246 return 0;
1177 1247
1178err_unregister_component: 1248err:
1179 snd_soc_unregister_component(&pdev->dev);
1180err_release_clk:
1181 pm_runtime_put_sync(&pdev->dev); 1249 pm_runtime_put_sync(&pdev->dev);
1182 pm_runtime_disable(&pdev->dev); 1250 pm_runtime_disable(&pdev->dev);
1183 return ret; 1251 return ret;
@@ -1185,12 +1253,6 @@ err_release_clk:
1185 1253
1186static int davinci_mcasp_remove(struct platform_device *pdev) 1254static int davinci_mcasp_remove(struct platform_device *pdev)
1187{ 1255{
1188 struct davinci_mcasp *mcasp = dev_get_drvdata(&pdev->dev);
1189
1190 snd_soc_unregister_component(&pdev->dev);
1191 if (mcasp->version != MCASP_VERSION_4)
1192 davinci_soc_platform_unregister(&pdev->dev);
1193
1194 pm_runtime_put_sync(&pdev->dev); 1256 pm_runtime_put_sync(&pdev->dev);
1195 pm_runtime_disable(&pdev->dev); 1257 pm_runtime_disable(&pdev->dev);
1196 1258