~ubuntu-branches/ubuntu/precise/linux-ti-omap4/precise

« back to all changes in this revision

Viewing changes to sound/soc/davinci/davinci-mcasp.c

  • Committer: Bazaar Package Importer
  • Author(s): Paolo Pisati
  • Date: 2011-06-29 15:23:51 UTC
  • mfrom: (26.1.1 natty-proposed)
  • Revision ID: james.westby@ubuntu.com-20110629152351-xs96tm303d95rpbk
Tags: 3.0.0-1200.2
* Rebased against 3.0.0-6.7
* BSP from TI based on 3.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
434
434
                mcasp_set_bits(base + DAVINCI_MCASP_ACLKRCTL_REG, ACLKRE);
435
435
                mcasp_set_bits(base + DAVINCI_MCASP_RXFMCTL_REG, AFSRE);
436
436
 
437
 
                mcasp_set_bits(base + DAVINCI_MCASP_PDIR_REG, (0x7 << 26));
 
437
                mcasp_set_bits(base + DAVINCI_MCASP_PDIR_REG,
 
438
                                ACLKX | AHCLKX | AFSX);
438
439
                break;
439
440
        case SND_SOC_DAIFMT_CBM_CFS:
440
441
                /* codec is clock master and frame slave */
441
 
                mcasp_set_bits(base + DAVINCI_MCASP_ACLKXCTL_REG, ACLKXE);
 
442
                mcasp_clr_bits(base + DAVINCI_MCASP_ACLKXCTL_REG, ACLKXE);
442
443
                mcasp_set_bits(base + DAVINCI_MCASP_TXFMCTL_REG, AFSXE);
443
444
 
444
 
                mcasp_set_bits(base + DAVINCI_MCASP_ACLKRCTL_REG, ACLKRE);
 
445
                mcasp_clr_bits(base + DAVINCI_MCASP_ACLKRCTL_REG, ACLKRE);
445
446
                mcasp_set_bits(base + DAVINCI_MCASP_RXFMCTL_REG, AFSRE);
446
447
 
447
 
                mcasp_set_bits(base + DAVINCI_MCASP_PDIR_REG, (0x2d << 26));
 
448
                mcasp_clr_bits(base + DAVINCI_MCASP_PDIR_REG,
 
449
                                ACLKX | ACLKR);
 
450
                mcasp_set_bits(base + DAVINCI_MCASP_PDIR_REG,
 
451
                                AFSX | AFSR);
448
452
                break;
449
453
        case SND_SOC_DAIFMT_CBM_CFM:
450
454
                /* codec is clock and frame master */
454
458
                mcasp_clr_bits(base + DAVINCI_MCASP_ACLKRCTL_REG, ACLKRE);
455
459
                mcasp_clr_bits(base + DAVINCI_MCASP_RXFMCTL_REG, AFSRE);
456
460
 
457
 
                mcasp_clr_bits(base + DAVINCI_MCASP_PDIR_REG, (0x3f << 26));
 
461
                mcasp_clr_bits(base + DAVINCI_MCASP_PDIR_REG,
 
462
                                ACLKX | AHCLKX | AFSX | ACLKR | AHCLKR | AFSR);
458
463
                break;
459
464
 
460
465
        default:
644
649
                mcasp_set_reg(dev->base + DAVINCI_MCASP_TXTDM_REG, mask);
645
650
                mcasp_set_bits(dev->base + DAVINCI_MCASP_TXFMT_REG, TXORD);
646
651
 
647
 
                if ((dev->tdm_slots >= 2) || (dev->tdm_slots <= 32))
 
652
                if ((dev->tdm_slots >= 2) && (dev->tdm_slots <= 32))
648
653
                        mcasp_mod_bits(dev->base + DAVINCI_MCASP_TXFMCTL_REG,
649
654
                                        FSXMOD(dev->tdm_slots), FSXMOD(0x1FF));
650
655
                else
660
665
                                AHCLKRE);
661
666
                mcasp_set_reg(dev->base + DAVINCI_MCASP_RXTDM_REG, mask);
662
667
 
663
 
                if ((dev->tdm_slots >= 2) || (dev->tdm_slots <= 32))
 
668
                if ((dev->tdm_slots >= 2) && (dev->tdm_slots <= 32))
664
669
                        mcasp_mod_bits(dev->base + DAVINCI_MCASP_RXFMCTL_REG,
665
670
                                        FSRMOD(dev->tdm_slots), FSRMOD(0x1FF));
666
671
                else
868
873
        }
869
874
 
870
875
        ioarea = request_mem_region(mem->start,
871
 
                        (mem->end - mem->start) + 1, pdev->name);
 
876
                        resource_size(mem), pdev->name);
872
877
        if (!ioarea) {
873
878
                dev_err(&pdev->dev, "Audio region already claimed\n");
874
879
                ret = -EBUSY;
885
890
        clk_enable(dev->clk);
886
891
        dev->clk_active = 1;
887
892
 
888
 
        dev->base = (void __iomem *)IO_ADDRESS(mem->start);
 
893
        dev->base = ioremap(mem->start, resource_size(mem));
 
894
        if (!dev->base) {
 
895
                dev_err(&pdev->dev, "ioremap failed\n");
 
896
                ret = -ENOMEM;
 
897
                goto err_release_clk;
 
898
        }
 
899
 
889
900
        dev->op_mode = pdata->op_mode;
890
901
        dev->tdm_slots = pdata->tdm_slots;
891
902
        dev->num_serializer = pdata->num_serializer;
898
909
        dma_data = &dev->dma_params[SNDRV_PCM_STREAM_PLAYBACK];
899
910
        dma_data->asp_chan_q = pdata->asp_chan_q;
900
911
        dma_data->ram_chan_q = pdata->ram_chan_q;
 
912
        dma_data->sram_size = pdata->sram_size_playback;
901
913
        dma_data->dma_addr = (dma_addr_t) (pdata->tx_dma_offset +
902
 
                                                        io_v2p(dev->base));
 
914
                                                        mem->start);
903
915
 
904
916
        /* first TX, then RX */
905
917
        res = platform_get_resource(pdev, IORESOURCE_DMA, 0);
906
918
        if (!res) {
907
919
                dev_err(&pdev->dev, "no DMA resource\n");
908
920
                ret = -ENODEV;
909
 
                goto err_release_region;
 
921
                goto err_iounmap;
910
922
        }
911
923
 
912
924
        dma_data->channel = res->start;
914
926
        dma_data = &dev->dma_params[SNDRV_PCM_STREAM_CAPTURE];
915
927
        dma_data->asp_chan_q = pdata->asp_chan_q;
916
928
        dma_data->ram_chan_q = pdata->ram_chan_q;
 
929
        dma_data->sram_size = pdata->sram_size_capture;
917
930
        dma_data->dma_addr = (dma_addr_t)(pdata->rx_dma_offset +
918
 
                                                        io_v2p(dev->base));
 
931
                                                        mem->start);
919
932
 
920
933
        res = platform_get_resource(pdev, IORESOURCE_DMA, 1);
921
934
        if (!res) {
922
935
                dev_err(&pdev->dev, "no DMA resource\n");
923
936
                ret = -ENODEV;
924
 
                goto err_release_region;
 
937
                goto err_iounmap;
925
938
        }
926
939
 
927
940
        dma_data->channel = res->start;
929
942
        ret = snd_soc_register_dai(&pdev->dev, &davinci_mcasp_dai[pdata->op_mode]);
930
943
 
931
944
        if (ret != 0)
932
 
                goto err_release_region;
 
945
                goto err_iounmap;
933
946
        return 0;
934
947
 
 
948
err_iounmap:
 
949
        iounmap(dev->base);
 
950
err_release_clk:
 
951
        clk_disable(dev->clk);
 
952
        clk_put(dev->clk);
935
953
err_release_region:
936
 
        release_mem_region(mem->start, (mem->end - mem->start) + 1);
 
954
        release_mem_region(mem->start, resource_size(mem));
937
955
err_release_data:
938
956
        kfree(dev);
939
957
 
951
969
        dev->clk = NULL;
952
970
 
953
971
        mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
954
 
        release_mem_region(mem->start, (mem->end - mem->start) + 1);
 
972
        release_mem_region(mem->start, resource_size(mem));
955
973
 
956
974
        kfree(dev);
957
975