aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/davinci/davinci-i2s.c
diff options
context:
space:
mode:
authorChaithrika U S <chaithrika@ti.com>2009-06-05 06:28:23 -0400
committerMark Brown <broonie@opensource.wolfsonmicro.com>2009-06-07 15:08:40 -0400
commit5204d49676dae3ae1f9dff5b60bf567d24680872 (patch)
treef7af4b28aed538e406e155912d7acf17f3db8945 /sound/soc/davinci/davinci-i2s.c
parent74b8f955a73d20b1e22403fd1ef85834fbf38d98 (diff)
ASoC: Introduce platform driver model for dm644x, dm355
Introduce the platform driver model to get platform data for dm355 and dm644x. Register platform driver and acquire the resources in the probe function Since the platform specific code had been moved from machine driver to dm<soc>.c Signed-off-by: Naresh Medisetty <naresh@ti.com> Signed-off-by: Chaithrika U S <chaithrika@ti.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound/soc/davinci/davinci-i2s.c')
-rw-r--r--sound/soc/davinci/davinci-i2s.c117
1 files changed, 67 insertions, 50 deletions
diff --git a/sound/soc/davinci/davinci-i2s.c b/sound/soc/davinci/davinci-i2s.c
index b1ea52fc83c7..500d2f574186 100644
--- a/sound/soc/davinci/davinci-i2s.c
+++ b/sound/soc/davinci/davinci-i2s.c
@@ -436,16 +436,40 @@ static int davinci_i2s_trigger(struct snd_pcm_substream *substream, int cmd,
436 return ret; 436 return ret;
437} 437}
438 438
439static int davinci_i2s_probe(struct platform_device *pdev, 439#define DAVINCI_I2S_RATES SNDRV_PCM_RATE_8000_96000
440 struct snd_soc_dai *dai) 440
441static struct snd_soc_dai_ops davinci_i2s_dai_ops = {
442 .startup = davinci_i2s_startup,
443 .trigger = davinci_i2s_trigger,
444 .hw_params = davinci_i2s_hw_params,
445 .set_fmt = davinci_i2s_set_dai_fmt,
446
447};
448
449struct snd_soc_dai davinci_i2s_dai = {
450 .name = "davinci-i2s",
451 .id = 0,
452 .playback = {
453 .channels_min = 2,
454 .channels_max = 2,
455 .rates = DAVINCI_I2S_RATES,
456 .formats = SNDRV_PCM_FMTBIT_S16_LE,},
457 .capture = {
458 .channels_min = 2,
459 .channels_max = 2,
460 .rates = DAVINCI_I2S_RATES,
461 .formats = SNDRV_PCM_FMTBIT_S16_LE,},
462 .ops = &davinci_i2s_dai_ops,
463
464};
465EXPORT_SYMBOL_GPL(davinci_i2s_dai);
466
467static int davinci_i2s_probe(struct platform_device *pdev)
441{ 468{
442 struct snd_soc_device *socdev = platform_get_drvdata(pdev); 469 struct snd_platform_data *pdata = pdev->dev.platform_data;
443 struct snd_soc_card *card = socdev->card;
444 struct snd_soc_dai *cpu_dai = card->dai_link->cpu_dai;
445 struct davinci_mcbsp_dev *dev; 470 struct davinci_mcbsp_dev *dev;
446 struct resource *mem, *ioarea; 471 struct resource *mem, *ioarea, *res;
447 struct evm_snd_platform_data *pdata; 472 int ret = 0;
448 int ret;
449 473
450 mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); 474 mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
451 if (!mem) { 475 if (!mem) {
@@ -466,9 +490,7 @@ static int davinci_i2s_probe(struct platform_device *pdev,
466 goto err_release_region; 490 goto err_release_region;
467 } 491 }
468 492
469 cpu_dai->private_data = dev; 493 dev->clk = clk_get(&pdev->dev, pdata->clk_name);
470
471 dev->clk = clk_get(&pdev->dev, NULL);
472 if (IS_ERR(dev->clk)) { 494 if (IS_ERR(dev->clk)) {
473 ret = -ENODEV; 495 ret = -ENODEV;
474 goto err_free_mem; 496 goto err_free_mem;
@@ -476,18 +498,35 @@ static int davinci_i2s_probe(struct platform_device *pdev,
476 clk_enable(dev->clk); 498 clk_enable(dev->clk);
477 499
478 dev->base = (void __iomem *)IO_ADDRESS(mem->start); 500 dev->base = (void __iomem *)IO_ADDRESS(mem->start);
479 pdata = pdev->dev.platform_data;
480 501
481 dev->dma_params[SNDRV_PCM_STREAM_PLAYBACK] = &davinci_i2s_pcm_out; 502 dev->dma_params[SNDRV_PCM_STREAM_PLAYBACK] = &davinci_i2s_pcm_out;
482 dev->dma_params[SNDRV_PCM_STREAM_PLAYBACK]->channel = pdata->tx_dma_ch;
483 dev->dma_params[SNDRV_PCM_STREAM_PLAYBACK]->dma_addr = 503 dev->dma_params[SNDRV_PCM_STREAM_PLAYBACK]->dma_addr =
484 (dma_addr_t)(io_v2p(dev->base) + DAVINCI_MCBSP_DXR_REG); 504 (dma_addr_t)(io_v2p(dev->base) + DAVINCI_MCBSP_DXR_REG);
485 505
486 dev->dma_params[SNDRV_PCM_STREAM_CAPTURE] = &davinci_i2s_pcm_in; 506 dev->dma_params[SNDRV_PCM_STREAM_CAPTURE] = &davinci_i2s_pcm_in;
487 dev->dma_params[SNDRV_PCM_STREAM_CAPTURE]->channel = pdata->rx_dma_ch;
488 dev->dma_params[SNDRV_PCM_STREAM_CAPTURE]->dma_addr = 507 dev->dma_params[SNDRV_PCM_STREAM_CAPTURE]->dma_addr =
489 (dma_addr_t)(io_v2p(dev->base) + DAVINCI_MCBSP_DRR_REG); 508 (dma_addr_t)(io_v2p(dev->base) + DAVINCI_MCBSP_DRR_REG);
490 509
510 /* first TX, then RX */
511 res = platform_get_resource(pdev, IORESOURCE_DMA, 0);
512 if (!res) {
513 dev_err(&pdev->dev, "no DMA resource\n");
514 goto err_free_mem;
515 }
516 dev->dma_params[SNDRV_PCM_STREAM_PLAYBACK]->channel = res->start;
517
518 res = platform_get_resource(pdev, IORESOURCE_DMA, 1);
519 if (!res) {
520 dev_err(&pdev->dev, "no DMA resource\n");
521 goto err_free_mem;
522 }
523 dev->dma_params[SNDRV_PCM_STREAM_CAPTURE]->channel = res->start;
524
525 davinci_i2s_dai.private_data = dev;
526 ret = snd_soc_register_dai(&davinci_i2s_dai);
527 if (ret != 0)
528 goto err_free_mem;
529
491 return 0; 530 return 0;
492 531
493err_free_mem: 532err_free_mem:
@@ -498,62 +537,40 @@ err_release_region:
498 return ret; 537 return ret;
499} 538}
500 539
501static void davinci_i2s_remove(struct platform_device *pdev, 540static int davinci_i2s_remove(struct platform_device *pdev)
502 struct snd_soc_dai *dai)
503{ 541{
504 struct snd_soc_device *socdev = platform_get_drvdata(pdev); 542 struct davinci_mcbsp_dev *dev = davinci_i2s_dai.private_data;
505 struct snd_soc_card *card = socdev->card;
506 struct snd_soc_dai *cpu_dai = card->dai_link->cpu_dai;
507 struct davinci_mcbsp_dev *dev = cpu_dai->private_data;
508 struct resource *mem; 543 struct resource *mem;
509 544
545 snd_soc_unregister_dai(&davinci_i2s_dai);
510 clk_disable(dev->clk); 546 clk_disable(dev->clk);
511 clk_put(dev->clk); 547 clk_put(dev->clk);
512 dev->clk = NULL; 548 dev->clk = NULL;
513
514 kfree(dev); 549 kfree(dev);
515
516 mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); 550 mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
517 release_mem_region(mem->start, (mem->end - mem->start) + 1); 551 release_mem_region(mem->start, (mem->end - mem->start) + 1);
518}
519 552
520#define DAVINCI_I2S_RATES SNDRV_PCM_RATE_8000_96000 553 return 0;
521 554}
522static struct snd_soc_dai_ops davinci_i2s_dai_ops = {
523 .startup = davinci_i2s_startup,
524 .trigger = davinci_i2s_trigger,
525 .hw_params = davinci_i2s_hw_params,
526 .set_fmt = davinci_i2s_set_dai_fmt,
527};
528 555
529struct snd_soc_dai davinci_i2s_dai = { 556static struct platform_driver davinci_mcbsp_driver = {
530 .name = "davinci-i2s", 557 .probe = davinci_i2s_probe,
531 .id = 0, 558 .remove = davinci_i2s_remove,
532 .probe = davinci_i2s_probe, 559 .driver = {
533 .remove = davinci_i2s_remove, 560 .name = "davinci-asp",
534 .playback = { 561 .owner = THIS_MODULE,
535 .channels_min = 2, 562 },
536 .channels_max = 2,
537 .rates = DAVINCI_I2S_RATES,
538 .formats = SNDRV_PCM_FMTBIT_S16_LE,},
539 .capture = {
540 .channels_min = 2,
541 .channels_max = 2,
542 .rates = DAVINCI_I2S_RATES,
543 .formats = SNDRV_PCM_FMTBIT_S16_LE,},
544 .ops = &davinci_i2s_dai_ops,
545}; 563};
546EXPORT_SYMBOL_GPL(davinci_i2s_dai);
547 564
548static int __init davinci_i2s_init(void) 565static int __init davinci_i2s_init(void)
549{ 566{
550 return snd_soc_register_dai(&davinci_i2s_dai); 567 return platform_driver_register(&davinci_mcbsp_driver);
551} 568}
552module_init(davinci_i2s_init); 569module_init(davinci_i2s_init);
553 570
554static void __exit davinci_i2s_exit(void) 571static void __exit davinci_i2s_exit(void)
555{ 572{
556 snd_soc_unregister_dai(&davinci_i2s_dai); 573 platform_driver_unregister(&davinci_mcbsp_driver);
557} 574}
558module_exit(davinci_i2s_exit); 575module_exit(davinci_i2s_exit);
559 576