aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeter Ujfalusi <peter.ujfalusi@ti.com>2015-03-03 09:45:18 -0500
committerMark Brown <broonie@kernel.org>2015-03-04 12:26:28 -0500
commit257ade78b6019cf1570c1239894a7a6a549768e1 (patch)
tree1e32afd1c800c838393991d4e63b03b6c501dedf
parent4c03a5ebc7f75e98b32591d1d2c6758c811dcbef (diff)
ASoC: davinci-i2s: Convert to use edma-pcm
The edma-pcm can replace the old davinci-pcm as platform driver. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com> Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r--sound/soc/davinci/davinci-i2s.c67
1 files changed, 26 insertions, 41 deletions
diff --git a/sound/soc/davinci/davinci-i2s.c b/sound/soc/davinci/davinci-i2s.c
index 15fb28fc8e1b..56cb4d95637d 100644
--- a/sound/soc/davinci/davinci-i2s.c
+++ b/sound/soc/davinci/davinci-i2s.c
@@ -23,8 +23,9 @@
23#include <sound/pcm_params.h> 23#include <sound/pcm_params.h>
24#include <sound/initval.h> 24#include <sound/initval.h>
25#include <sound/soc.h> 25#include <sound/soc.h>
26#include <sound/dmaengine_pcm.h>
26 27
27#include "davinci-pcm.h" 28#include "edma-pcm.h"
28#include "davinci-i2s.h" 29#include "davinci-i2s.h"
29 30
30 31
@@ -122,7 +123,8 @@ static const unsigned char double_fmt[SNDRV_PCM_FORMAT_S32_LE + 1] = {
122 123
123struct davinci_mcbsp_dev { 124struct davinci_mcbsp_dev {
124 struct device *dev; 125 struct device *dev;
125 struct davinci_pcm_dma_params dma_params[2]; 126 struct snd_dmaengine_dai_dma_data dma_data[2];
127 int dma_request[2];
126 void __iomem *base; 128 void __iomem *base;
127#define MOD_DSP_A 0 129#define MOD_DSP_A 0
128#define MOD_DSP_B 1 130#define MOD_DSP_B 1
@@ -419,8 +421,6 @@ static int davinci_i2s_hw_params(struct snd_pcm_substream *substream,
419 struct snd_soc_dai *dai) 421 struct snd_soc_dai *dai)
420{ 422{
421 struct davinci_mcbsp_dev *dev = snd_soc_dai_get_drvdata(dai); 423 struct davinci_mcbsp_dev *dev = snd_soc_dai_get_drvdata(dai);
422 struct davinci_pcm_dma_params *dma_params =
423 &dev->dma_params[substream->stream];
424 struct snd_interval *i = NULL; 424 struct snd_interval *i = NULL;
425 int mcbsp_word_length, master; 425 int mcbsp_word_length, master;
426 unsigned int rcr, xcr, srgr, clk_div, freq, framesize; 426 unsigned int rcr, xcr, srgr, clk_div, freq, framesize;
@@ -532,8 +532,6 @@ static int davinci_i2s_hw_params(struct snd_pcm_substream *substream,
532 return -EINVAL; 532 return -EINVAL;
533 } 533 }
534 } 534 }
535 dma_params->acnt = dma_params->data_type = data_type[fmt];
536 dma_params->fifo_level = 0;
537 mcbsp_word_length = asp_word_length[fmt]; 535 mcbsp_word_length = asp_word_length[fmt];
538 536
539 switch (master) { 537 switch (master) {
@@ -600,15 +598,6 @@ static int davinci_i2s_trigger(struct snd_pcm_substream *substream, int cmd,
600 return ret; 598 return ret;
601} 599}
602 600
603static int davinci_i2s_startup(struct snd_pcm_substream *substream,
604 struct snd_soc_dai *dai)
605{
606 struct davinci_mcbsp_dev *dev = snd_soc_dai_get_drvdata(dai);
607
608 snd_soc_dai_set_dma_data(dai, substream, dev->dma_params);
609 return 0;
610}
611
612static void davinci_i2s_shutdown(struct snd_pcm_substream *substream, 601static void davinci_i2s_shutdown(struct snd_pcm_substream *substream,
613 struct snd_soc_dai *dai) 602 struct snd_soc_dai *dai)
614{ 603{
@@ -620,7 +609,6 @@ static void davinci_i2s_shutdown(struct snd_pcm_substream *substream,
620#define DAVINCI_I2S_RATES SNDRV_PCM_RATE_8000_96000 609#define DAVINCI_I2S_RATES SNDRV_PCM_RATE_8000_96000
621 610
622static const struct snd_soc_dai_ops davinci_i2s_dai_ops = { 611static const struct snd_soc_dai_ops davinci_i2s_dai_ops = {
623 .startup = davinci_i2s_startup,
624 .shutdown = davinci_i2s_shutdown, 612 .shutdown = davinci_i2s_shutdown,
625 .prepare = davinci_i2s_prepare, 613 .prepare = davinci_i2s_prepare,
626 .trigger = davinci_i2s_trigger, 614 .trigger = davinci_i2s_trigger,
@@ -630,7 +618,18 @@ static const struct snd_soc_dai_ops davinci_i2s_dai_ops = {
630 618
631}; 619};
632 620
621static int davinci_i2s_dai_probe(struct snd_soc_dai *dai)
622{
623 struct davinci_mcbsp_dev *dev = snd_soc_dai_get_drvdata(dai);
624
625 dai->playback_dma_data = &dev->dma_data[SNDRV_PCM_STREAM_PLAYBACK];
626 dai->capture_dma_data = &dev->dma_data[SNDRV_PCM_STREAM_CAPTURE];
627
628 return 0;
629}
630
633static struct snd_soc_dai_driver davinci_i2s_dai = { 631static struct snd_soc_dai_driver davinci_i2s_dai = {
632 .probe = davinci_i2s_dai_probe,
634 .playback = { 633 .playback = {
635 .channels_min = 2, 634 .channels_min = 2,
636 .channels_max = 2, 635 .channels_max = 2,
@@ -651,11 +650,9 @@ static const struct snd_soc_component_driver davinci_i2s_component = {
651 650
652static int davinci_i2s_probe(struct platform_device *pdev) 651static int davinci_i2s_probe(struct platform_device *pdev)
653{ 652{
654 struct snd_platform_data *pdata = pdev->dev.platform_data;
655 struct davinci_mcbsp_dev *dev; 653 struct davinci_mcbsp_dev *dev;
656 struct resource *mem, *ioarea, *res; 654 struct resource *mem, *ioarea, *res;
657 enum dma_event_q asp_chan_q = EVENTQ_0; 655 int *dma;
658 enum dma_event_q ram_chan_q = EVENTQ_1;
659 int ret; 656 int ret;
660 657
661 mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); 658 mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
@@ -676,22 +673,6 @@ static int davinci_i2s_probe(struct platform_device *pdev)
676 GFP_KERNEL); 673 GFP_KERNEL);
677 if (!dev) 674 if (!dev)
678 return -ENOMEM; 675 return -ENOMEM;
679 if (pdata) {
680 dev->enable_channel_combine = pdata->enable_channel_combine;
681 dev->dma_params[SNDRV_PCM_STREAM_PLAYBACK].sram_size =
682 pdata->sram_size_playback;
683 dev->dma_params[SNDRV_PCM_STREAM_CAPTURE].sram_size =
684 pdata->sram_size_capture;
685 dev->clk_input_pin = pdata->clk_input_pin;
686 dev->i2s_accurate_sck = pdata->i2s_accurate_sck;
687 asp_chan_q = pdata->asp_chan_q;
688 ram_chan_q = pdata->ram_chan_q;
689 }
690
691 dev->dma_params[SNDRV_PCM_STREAM_PLAYBACK].asp_chan_q = asp_chan_q;
692 dev->dma_params[SNDRV_PCM_STREAM_PLAYBACK].ram_chan_q = ram_chan_q;
693 dev->dma_params[SNDRV_PCM_STREAM_CAPTURE].asp_chan_q = asp_chan_q;
694 dev->dma_params[SNDRV_PCM_STREAM_CAPTURE].ram_chan_q = ram_chan_q;
695 676
696 dev->clk = clk_get(&pdev->dev, NULL); 677 dev->clk = clk_get(&pdev->dev, NULL);
697 if (IS_ERR(dev->clk)) 678 if (IS_ERR(dev->clk))
@@ -705,10 +686,10 @@ static int davinci_i2s_probe(struct platform_device *pdev)
705 goto err_release_clk; 686 goto err_release_clk;
706 } 687 }
707 688
708 dev->dma_params[SNDRV_PCM_STREAM_PLAYBACK].dma_addr = 689 dev->dma_data[SNDRV_PCM_STREAM_PLAYBACK].addr =
709 (dma_addr_t)(mem->start + DAVINCI_MCBSP_DXR_REG); 690 (dma_addr_t)(mem->start + DAVINCI_MCBSP_DXR_REG);
710 691
711 dev->dma_params[SNDRV_PCM_STREAM_CAPTURE].dma_addr = 692 dev->dma_data[SNDRV_PCM_STREAM_CAPTURE].addr =
712 (dma_addr_t)(mem->start + DAVINCI_MCBSP_DRR_REG); 693 (dma_addr_t)(mem->start + DAVINCI_MCBSP_DRR_REG);
713 694
714 /* first TX, then RX */ 695 /* first TX, then RX */
@@ -718,7 +699,9 @@ static int davinci_i2s_probe(struct platform_device *pdev)
718 ret = -ENXIO; 699 ret = -ENXIO;
719 goto err_release_clk; 700 goto err_release_clk;
720 } 701 }
721 dev->dma_params[SNDRV_PCM_STREAM_PLAYBACK].channel = res->start; 702 dma = &dev->dma_request[SNDRV_PCM_STREAM_PLAYBACK];
703 *dma = res->start;
704 dev->dma_data[SNDRV_PCM_STREAM_PLAYBACK].filter_data = dma;
722 705
723 res = platform_get_resource(pdev, IORESOURCE_DMA, 1); 706 res = platform_get_resource(pdev, IORESOURCE_DMA, 1);
724 if (!res) { 707 if (!res) {
@@ -726,9 +709,11 @@ static int davinci_i2s_probe(struct platform_device *pdev)
726 ret = -ENXIO; 709 ret = -ENXIO;
727 goto err_release_clk; 710 goto err_release_clk;
728 } 711 }
729 dev->dma_params[SNDRV_PCM_STREAM_CAPTURE].channel = res->start; 712 dma = &dev->dma_request[SNDRV_PCM_STREAM_CAPTURE];
730 dev->dev = &pdev->dev; 713 *dma = res->start;
714 dev->dma_data[SNDRV_PCM_STREAM_CAPTURE].filter_data = dma;
731 715
716 dev->dev = &pdev->dev;
732 dev_set_drvdata(&pdev->dev, dev); 717 dev_set_drvdata(&pdev->dev, dev);
733 718
734 ret = snd_soc_register_component(&pdev->dev, &davinci_i2s_component, 719 ret = snd_soc_register_component(&pdev->dev, &davinci_i2s_component,
@@ -736,7 +721,7 @@ static int davinci_i2s_probe(struct platform_device *pdev)
736 if (ret != 0) 721 if (ret != 0)
737 goto err_release_clk; 722 goto err_release_clk;
738 723
739 ret = davinci_soc_platform_register(&pdev->dev); 724 ret = edma_pcm_platform_register(&pdev->dev);
740 if (ret) { 725 if (ret) {
741 dev_err(&pdev->dev, "register PCM failed: %d\n", ret); 726 dev_err(&pdev->dev, "register PCM failed: %d\n", ret);
742 goto err_unregister_component; 727 goto err_unregister_component;