diff options
author | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2009-07-07 14:18:46 -0400 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2009-07-07 14:18:46 -0400 |
commit | 3f405b46a91c0c4cdfa6077b4e1853f35a94e8ef (patch) | |
tree | 46d8032c9f224d28f258c44727a7165c9ba47c85 /sound/soc/davinci/davinci-i2s.c | |
parent | 4ec5c9693b46ab34976511cd43bf75c3a0fc704d (diff) | |
parent | efd13be09e2db4ac4efa2c6101c4f50ee1ead4b0 (diff) |
Merge branch 'davinci' into for-2.6.32
Conflicts:
sound/soc/davinci/davinci-i2s.c
Diffstat (limited to 'sound/soc/davinci/davinci-i2s.c')
-rw-r--r-- | sound/soc/davinci/davinci-i2s.c | 121 |
1 files changed, 70 insertions, 51 deletions
diff --git a/sound/soc/davinci/davinci-i2s.c b/sound/soc/davinci/davinci-i2s.c index 88ccef79a5eb..7c4839994e2f 100644 --- a/sound/soc/davinci/davinci-i2s.c +++ b/sound/soc/davinci/davinci-i2s.c | |||
@@ -470,15 +470,41 @@ static void davinci_i2s_shutdown(struct snd_pcm_substream *substream, | |||
470 | davinci_mcbsp_stop(dev, playback); | 470 | davinci_mcbsp_stop(dev, playback); |
471 | } | 471 | } |
472 | 472 | ||
473 | static int davinci_i2s_probe(struct platform_device *pdev, | 473 | #define DAVINCI_I2S_RATES SNDRV_PCM_RATE_8000_96000 |
474 | struct snd_soc_dai *dai) | 474 | |
475 | static struct snd_soc_dai_ops davinci_i2s_dai_ops = { | ||
476 | .startup = davinci_i2s_startup, | ||
477 | .shutdown = davinci_i2s_shutdown, | ||
478 | .prepare = davinci_i2s_prepare, | ||
479 | .trigger = davinci_i2s_trigger, | ||
480 | .hw_params = davinci_i2s_hw_params, | ||
481 | .set_fmt = davinci_i2s_set_dai_fmt, | ||
482 | |||
483 | }; | ||
484 | |||
485 | struct snd_soc_dai davinci_i2s_dai = { | ||
486 | .name = "davinci-i2s", | ||
487 | .id = 0, | ||
488 | .playback = { | ||
489 | .channels_min = 2, | ||
490 | .channels_max = 2, | ||
491 | .rates = DAVINCI_I2S_RATES, | ||
492 | .formats = SNDRV_PCM_FMTBIT_S16_LE,}, | ||
493 | .capture = { | ||
494 | .channels_min = 2, | ||
495 | .channels_max = 2, | ||
496 | .rates = DAVINCI_I2S_RATES, | ||
497 | .formats = SNDRV_PCM_FMTBIT_S16_LE,}, | ||
498 | .ops = &davinci_i2s_dai_ops, | ||
499 | |||
500 | }; | ||
501 | EXPORT_SYMBOL_GPL(davinci_i2s_dai); | ||
502 | |||
503 | static int davinci_i2s_probe(struct platform_device *pdev) | ||
475 | { | 504 | { |
476 | struct snd_soc_device *socdev = platform_get_drvdata(pdev); | 505 | struct snd_platform_data *pdata = pdev->dev.platform_data; |
477 | struct snd_soc_card *card = socdev->card; | ||
478 | struct snd_soc_dai *cpu_dai = card->dai_link->cpu_dai; | ||
479 | struct davinci_mcbsp_dev *dev; | 506 | struct davinci_mcbsp_dev *dev; |
480 | struct resource *mem, *ioarea; | 507 | struct resource *mem, *ioarea, *res; |
481 | struct evm_snd_platform_data *pdata; | ||
482 | int ret; | 508 | int ret; |
483 | 509 | ||
484 | mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 510 | mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
@@ -500,9 +526,7 @@ static int davinci_i2s_probe(struct platform_device *pdev, | |||
500 | goto err_release_region; | 526 | goto err_release_region; |
501 | } | 527 | } |
502 | 528 | ||
503 | cpu_dai->private_data = dev; | 529 | dev->clk = clk_get(&pdev->dev, pdata->clk_name); |
504 | |||
505 | dev->clk = clk_get(&pdev->dev, NULL); | ||
506 | if (IS_ERR(dev->clk)) { | 530 | if (IS_ERR(dev->clk)) { |
507 | ret = -ENODEV; | 531 | ret = -ENODEV; |
508 | goto err_free_mem; | 532 | goto err_free_mem; |
@@ -510,18 +534,37 @@ static int davinci_i2s_probe(struct platform_device *pdev, | |||
510 | clk_enable(dev->clk); | 534 | clk_enable(dev->clk); |
511 | 535 | ||
512 | dev->base = (void __iomem *)IO_ADDRESS(mem->start); | 536 | dev->base = (void __iomem *)IO_ADDRESS(mem->start); |
513 | pdata = pdev->dev.platform_data; | ||
514 | 537 | ||
515 | dev->dma_params[SNDRV_PCM_STREAM_PLAYBACK] = &davinci_i2s_pcm_out; | 538 | dev->dma_params[SNDRV_PCM_STREAM_PLAYBACK] = &davinci_i2s_pcm_out; |
516 | dev->dma_params[SNDRV_PCM_STREAM_PLAYBACK]->channel = pdata->tx_dma_ch; | ||
517 | dev->dma_params[SNDRV_PCM_STREAM_PLAYBACK]->dma_addr = | 539 | dev->dma_params[SNDRV_PCM_STREAM_PLAYBACK]->dma_addr = |
518 | (dma_addr_t)(io_v2p(dev->base) + DAVINCI_MCBSP_DXR_REG); | 540 | (dma_addr_t)(io_v2p(dev->base) + DAVINCI_MCBSP_DXR_REG); |
519 | 541 | ||
520 | dev->dma_params[SNDRV_PCM_STREAM_CAPTURE] = &davinci_i2s_pcm_in; | 542 | dev->dma_params[SNDRV_PCM_STREAM_CAPTURE] = &davinci_i2s_pcm_in; |
521 | dev->dma_params[SNDRV_PCM_STREAM_CAPTURE]->channel = pdata->rx_dma_ch; | ||
522 | dev->dma_params[SNDRV_PCM_STREAM_CAPTURE]->dma_addr = | 543 | dev->dma_params[SNDRV_PCM_STREAM_CAPTURE]->dma_addr = |
523 | (dma_addr_t)(io_v2p(dev->base) + DAVINCI_MCBSP_DRR_REG); | 544 | (dma_addr_t)(io_v2p(dev->base) + DAVINCI_MCBSP_DRR_REG); |
524 | 545 | ||
546 | /* first TX, then RX */ | ||
547 | res = platform_get_resource(pdev, IORESOURCE_DMA, 0); | ||
548 | if (!res) { | ||
549 | dev_err(&pdev->dev, "no DMA resource\n"); | ||
550 | ret = -ENXIO; | ||
551 | goto err_free_mem; | ||
552 | } | ||
553 | dev->dma_params[SNDRV_PCM_STREAM_PLAYBACK]->channel = res->start; | ||
554 | |||
555 | res = platform_get_resource(pdev, IORESOURCE_DMA, 1); | ||
556 | if (!res) { | ||
557 | dev_err(&pdev->dev, "no DMA resource\n"); | ||
558 | ret = -ENXIO; | ||
559 | goto err_free_mem; | ||
560 | } | ||
561 | dev->dma_params[SNDRV_PCM_STREAM_CAPTURE]->channel = res->start; | ||
562 | |||
563 | davinci_i2s_dai.private_data = dev; | ||
564 | ret = snd_soc_register_dai(&davinci_i2s_dai); | ||
565 | if (ret != 0) | ||
566 | goto err_free_mem; | ||
567 | |||
525 | return 0; | 568 | return 0; |
526 | 569 | ||
527 | err_free_mem: | 570 | err_free_mem: |
@@ -532,64 +575,40 @@ err_release_region: | |||
532 | return ret; | 575 | return ret; |
533 | } | 576 | } |
534 | 577 | ||
535 | static void davinci_i2s_remove(struct platform_device *pdev, | 578 | static int davinci_i2s_remove(struct platform_device *pdev) |
536 | struct snd_soc_dai *dai) | ||
537 | { | 579 | { |
538 | struct snd_soc_device *socdev = platform_get_drvdata(pdev); | 580 | struct davinci_mcbsp_dev *dev = davinci_i2s_dai.private_data; |
539 | struct snd_soc_card *card = socdev->card; | ||
540 | struct snd_soc_dai *cpu_dai = card->dai_link->cpu_dai; | ||
541 | struct davinci_mcbsp_dev *dev = cpu_dai->private_data; | ||
542 | struct resource *mem; | 581 | struct resource *mem; |
543 | 582 | ||
583 | snd_soc_unregister_dai(&davinci_i2s_dai); | ||
544 | clk_disable(dev->clk); | 584 | clk_disable(dev->clk); |
545 | clk_put(dev->clk); | 585 | clk_put(dev->clk); |
546 | dev->clk = NULL; | 586 | dev->clk = NULL; |
547 | |||
548 | kfree(dev); | 587 | kfree(dev); |
549 | |||
550 | mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 588 | mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
551 | release_mem_region(mem->start, (mem->end - mem->start) + 1); | 589 | release_mem_region(mem->start, (mem->end - mem->start) + 1); |
552 | } | ||
553 | |||
554 | #define DAVINCI_I2S_RATES SNDRV_PCM_RATE_8000_96000 | ||
555 | 590 | ||
556 | static struct snd_soc_dai_ops davinci_i2s_dai_ops = { | 591 | return 0; |
557 | .startup = davinci_i2s_startup, | 592 | } |
558 | .shutdown = davinci_i2s_shutdown, | ||
559 | .prepare = davinci_i2s_prepare, | ||
560 | .trigger = davinci_i2s_trigger, | ||
561 | .hw_params = davinci_i2s_hw_params, | ||
562 | .set_fmt = davinci_i2s_set_dai_fmt, | ||
563 | }; | ||
564 | 593 | ||
565 | struct snd_soc_dai davinci_i2s_dai = { | 594 | static struct platform_driver davinci_mcbsp_driver = { |
566 | .name = "davinci-i2s", | 595 | .probe = davinci_i2s_probe, |
567 | .id = 0, | 596 | .remove = davinci_i2s_remove, |
568 | .probe = davinci_i2s_probe, | 597 | .driver = { |
569 | .remove = davinci_i2s_remove, | 598 | .name = "davinci-asp", |
570 | .playback = { | 599 | .owner = THIS_MODULE, |
571 | .channels_min = 2, | 600 | }, |
572 | .channels_max = 2, | ||
573 | .rates = DAVINCI_I2S_RATES, | ||
574 | .formats = SNDRV_PCM_FMTBIT_S16_LE,}, | ||
575 | .capture = { | ||
576 | .channels_min = 2, | ||
577 | .channels_max = 2, | ||
578 | .rates = DAVINCI_I2S_RATES, | ||
579 | .formats = SNDRV_PCM_FMTBIT_S16_LE,}, | ||
580 | .ops = &davinci_i2s_dai_ops, | ||
581 | }; | 601 | }; |
582 | EXPORT_SYMBOL_GPL(davinci_i2s_dai); | ||
583 | 602 | ||
584 | static int __init davinci_i2s_init(void) | 603 | static int __init davinci_i2s_init(void) |
585 | { | 604 | { |
586 | return snd_soc_register_dai(&davinci_i2s_dai); | 605 | return platform_driver_register(&davinci_mcbsp_driver); |
587 | } | 606 | } |
588 | module_init(davinci_i2s_init); | 607 | module_init(davinci_i2s_init); |
589 | 608 | ||
590 | static void __exit davinci_i2s_exit(void) | 609 | static void __exit davinci_i2s_exit(void) |
591 | { | 610 | { |
592 | snd_soc_unregister_dai(&davinci_i2s_dai); | 611 | platform_driver_unregister(&davinci_mcbsp_driver); |
593 | } | 612 | } |
594 | module_exit(davinci_i2s_exit); | 613 | module_exit(davinci_i2s_exit); |
595 | 614 | ||