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.c80
1 files changed, 28 insertions, 52 deletions
diff --git a/sound/soc/davinci/davinci-mcasp.c b/sound/soc/davinci/davinci-mcasp.c
index 7a06c0a86665..5d1f98a4c978 100644
--- a/sound/soc/davinci/davinci-mcasp.c
+++ b/sound/soc/davinci/davinci-mcasp.c
@@ -332,14 +332,6 @@ static inline void mcasp_set_ctl_reg(void __iomem *regs, u32 val)
332 printk(KERN_ERR "GBLCTL write error\n"); 332 printk(KERN_ERR "GBLCTL write error\n");
333} 333}
334 334
335static int davinci_mcasp_startup(struct snd_pcm_substream *substream,
336 struct snd_soc_dai *cpu_dai)
337{
338 struct davinci_audio_dev *dev = cpu_dai->private_data;
339 cpu_dai->dma_data = dev->dma_params[substream->stream];
340 return 0;
341}
342
343static void mcasp_start_rx(struct davinci_audio_dev *dev) 335static void mcasp_start_rx(struct davinci_audio_dev *dev)
344{ 336{
345 mcasp_set_ctl_reg(dev->base + DAVINCI_MCASP_GBLCTLR_REG, RXHCLKRST); 337 mcasp_set_ctl_reg(dev->base + DAVINCI_MCASP_GBLCTLR_REG, RXHCLKRST);
@@ -386,17 +378,17 @@ static void mcasp_start_tx(struct davinci_audio_dev *dev)
386 378
387static void davinci_mcasp_start(struct davinci_audio_dev *dev, int stream) 379static void davinci_mcasp_start(struct davinci_audio_dev *dev, int stream)
388{ 380{
389 if (stream == SNDRV_PCM_STREAM_PLAYBACK) 381 if (stream == SNDRV_PCM_STREAM_PLAYBACK) {
382 if (dev->txnumevt) /* enable FIFO */
383 mcasp_set_bits(dev->base + DAVINCI_MCASP_WFIFOCTL,
384 FIFO_ENABLE);
390 mcasp_start_tx(dev); 385 mcasp_start_tx(dev);
391 else 386 } else {
387 if (dev->rxnumevt) /* enable FIFO */
388 mcasp_set_bits(dev->base + DAVINCI_MCASP_RFIFOCTL,
389 FIFO_ENABLE);
392 mcasp_start_rx(dev); 390 mcasp_start_rx(dev);
393 391 }
394 /* enable FIFO */
395 if (dev->txnumevt)
396 mcasp_set_bits(dev->base + DAVINCI_MCASP_WFIFOCTL, FIFO_ENABLE);
397
398 if (dev->rxnumevt)
399 mcasp_set_bits(dev->base + DAVINCI_MCASP_RFIFOCTL, FIFO_ENABLE);
400} 392}
401 393
402static void mcasp_stop_rx(struct davinci_audio_dev *dev) 394static void mcasp_stop_rx(struct davinci_audio_dev *dev)
@@ -413,17 +405,17 @@ static void mcasp_stop_tx(struct davinci_audio_dev *dev)
413 405
414static void davinci_mcasp_stop(struct davinci_audio_dev *dev, int stream) 406static void davinci_mcasp_stop(struct davinci_audio_dev *dev, int stream)
415{ 407{
416 if (stream == SNDRV_PCM_STREAM_PLAYBACK) 408 if (stream == SNDRV_PCM_STREAM_PLAYBACK) {
409 if (dev->txnumevt) /* disable FIFO */
410 mcasp_clr_bits(dev->base + DAVINCI_MCASP_WFIFOCTL,
411 FIFO_ENABLE);
417 mcasp_stop_tx(dev); 412 mcasp_stop_tx(dev);
418 else 413 } else {
414 if (dev->rxnumevt) /* disable FIFO */
415 mcasp_clr_bits(dev->base + DAVINCI_MCASP_RFIFOCTL,
416 FIFO_ENABLE);
419 mcasp_stop_rx(dev); 417 mcasp_stop_rx(dev);
420 418 }
421 /* disable FIFO */
422 if (dev->txnumevt)
423 mcasp_clr_bits(dev->base + DAVINCI_MCASP_WFIFOCTL, FIFO_ENABLE);
424
425 if (dev->rxnumevt)
426 mcasp_clr_bits(dev->base + DAVINCI_MCASP_RFIFOCTL, FIFO_ENABLE);
427} 419}
428 420
429static int davinci_mcasp_set_dai_fmt(struct snd_soc_dai *cpu_dai, 421static int davinci_mcasp_set_dai_fmt(struct snd_soc_dai *cpu_dai,
@@ -720,7 +712,7 @@ static int davinci_mcasp_hw_params(struct snd_pcm_substream *substream,
720{ 712{
721 struct davinci_audio_dev *dev = cpu_dai->private_data; 713 struct davinci_audio_dev *dev = cpu_dai->private_data;
722 struct davinci_pcm_dma_params *dma_params = 714 struct davinci_pcm_dma_params *dma_params =
723 dev->dma_params[substream->stream]; 715 &dev->dma_params[substream->stream];
724 int word_length; 716 int word_length;
725 u8 numevt; 717 u8 numevt;
726 718
@@ -798,7 +790,6 @@ static int davinci_mcasp_trigger(struct snd_pcm_substream *substream,
798} 790}
799 791
800static struct snd_soc_dai_ops davinci_mcasp_dai_ops = { 792static struct snd_soc_dai_ops davinci_mcasp_dai_ops = {
801 .startup = davinci_mcasp_startup,
802 .trigger = davinci_mcasp_trigger, 793 .trigger = davinci_mcasp_trigger,
803 .hw_params = davinci_mcasp_hw_params, 794 .hw_params = davinci_mcasp_hw_params,
804 .set_fmt = davinci_mcasp_set_dai_fmt, 795 .set_fmt = davinci_mcasp_set_dai_fmt,
@@ -849,20 +840,12 @@ static int davinci_mcasp_probe(struct platform_device *pdev)
849 struct resource *mem, *ioarea, *res; 840 struct resource *mem, *ioarea, *res;
850 struct snd_platform_data *pdata; 841 struct snd_platform_data *pdata;
851 struct davinci_audio_dev *dev; 842 struct davinci_audio_dev *dev;
852 int count = 0;
853 int ret = 0; 843 int ret = 0;
854 844
855 dev = kzalloc(sizeof(struct davinci_audio_dev), GFP_KERNEL); 845 dev = kzalloc(sizeof(struct davinci_audio_dev), GFP_KERNEL);
856 if (!dev) 846 if (!dev)
857 return -ENOMEM; 847 return -ENOMEM;
858 848
859 dma_data = kzalloc(sizeof(struct davinci_pcm_dma_params) * 2,
860 GFP_KERNEL);
861 if (!dma_data) {
862 ret = -ENOMEM;
863 goto err_release_dev;
864 }
865
866 mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); 849 mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
867 if (!mem) { 850 if (!mem) {
868 dev_err(&pdev->dev, "no mem resource?\n"); 851 dev_err(&pdev->dev, "no mem resource?\n");
@@ -897,11 +880,10 @@ static int davinci_mcasp_probe(struct platform_device *pdev)
897 dev->txnumevt = pdata->txnumevt; 880 dev->txnumevt = pdata->txnumevt;
898 dev->rxnumevt = pdata->rxnumevt; 881 dev->rxnumevt = pdata->rxnumevt;
899 882
900 dma_data[count].name = "I2S PCM Stereo out"; 883 dma_data = &dev->dma_params[SNDRV_PCM_STREAM_PLAYBACK];
901 dma_data[count].eventq_no = pdata->eventq_no; 884 dma_data->eventq_no = pdata->eventq_no;
902 dma_data[count].dma_addr = (dma_addr_t) (pdata->tx_dma_offset + 885 dma_data->dma_addr = (dma_addr_t) (pdata->tx_dma_offset +
903 io_v2p(dev->base)); 886 io_v2p(dev->base));
904 dev->dma_params[SNDRV_PCM_STREAM_PLAYBACK] = &dma_data[count];
905 887
906 /* first TX, then RX */ 888 /* first TX, then RX */
907 res = platform_get_resource(pdev, IORESOURCE_DMA, 0); 889 res = platform_get_resource(pdev, IORESOURCE_DMA, 0);
@@ -910,13 +892,12 @@ static int davinci_mcasp_probe(struct platform_device *pdev)
910 goto err_release_region; 892 goto err_release_region;
911 } 893 }
912 894
913 dma_data[count].channel = res->start; 895 dma_data->channel = res->start;
914 count++; 896
915 dma_data[count].name = "I2S PCM Stereo in"; 897 dma_data = &dev->dma_params[SNDRV_PCM_STREAM_CAPTURE];
916 dma_data[count].eventq_no = pdata->eventq_no; 898 dma_data->eventq_no = pdata->eventq_no;
917 dma_data[count].dma_addr = (dma_addr_t)(pdata->rx_dma_offset + 899 dma_data->dma_addr = (dma_addr_t)(pdata->rx_dma_offset +
918 io_v2p(dev->base)); 900 io_v2p(dev->base));
919 dev->dma_params[SNDRV_PCM_STREAM_CAPTURE] = &dma_data[count];
920 901
921 res = platform_get_resource(pdev, IORESOURCE_DMA, 1); 902 res = platform_get_resource(pdev, IORESOURCE_DMA, 1);
922 if (!res) { 903 if (!res) {
@@ -924,7 +905,7 @@ static int davinci_mcasp_probe(struct platform_device *pdev)
924 goto err_release_region; 905 goto err_release_region;
925 } 906 }
926 907
927 dma_data[count].channel = res->start; 908 dma_data->channel = res->start;
928 davinci_mcasp_dai[pdata->op_mode].private_data = dev; 909 davinci_mcasp_dai[pdata->op_mode].private_data = dev;
929 davinci_mcasp_dai[pdata->op_mode].dev = &pdev->dev; 910 davinci_mcasp_dai[pdata->op_mode].dev = &pdev->dev;
930 ret = snd_soc_register_dai(&davinci_mcasp_dai[pdata->op_mode]); 911 ret = snd_soc_register_dai(&davinci_mcasp_dai[pdata->op_mode]);
@@ -936,8 +917,6 @@ static int davinci_mcasp_probe(struct platform_device *pdev)
936err_release_region: 917err_release_region:
937 release_mem_region(mem->start, (mem->end - mem->start) + 1); 918 release_mem_region(mem->start, (mem->end - mem->start) + 1);
938err_release_data: 919err_release_data:
939 kfree(dma_data);
940err_release_dev:
941 kfree(dev); 920 kfree(dev);
942 921
943 return ret; 922 return ret;
@@ -946,7 +925,6 @@ err_release_dev:
946static int davinci_mcasp_remove(struct platform_device *pdev) 925static int davinci_mcasp_remove(struct platform_device *pdev)
947{ 926{
948 struct snd_platform_data *pdata = pdev->dev.platform_data; 927 struct snd_platform_data *pdata = pdev->dev.platform_data;
949 struct davinci_pcm_dma_params *dma_data;
950 struct davinci_audio_dev *dev; 928 struct davinci_audio_dev *dev;
951 struct resource *mem; 929 struct resource *mem;
952 930
@@ -959,8 +937,6 @@ static int davinci_mcasp_remove(struct platform_device *pdev)
959 mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); 937 mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
960 release_mem_region(mem->start, (mem->end - mem->start) + 1); 938 release_mem_region(mem->start, (mem->end - mem->start) + 1);
961 939
962 dma_data = dev->dma_params[SNDRV_PCM_STREAM_PLAYBACK];
963 kfree(dma_data);
964 kfree(dev); 940 kfree(dev);
965 941
966 return 0; 942 return 0;