diff options
author | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2012-08-22 15:19:01 -0400 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2012-08-22 15:19:01 -0400 |
commit | 2bbf6078dc948e87564c1a947f23ea4cf2349a13 (patch) | |
tree | 2fc93ee7a26febb4ff9554e40043f8e097726c6d /sound/soc/omap/omap-mcbsp.c | |
parent | 02e79476998ba7e62842d20dca898c403ad55c7e (diff) | |
parent | b8101048f0f3cd281ed4c4901e38ae2bcfb32030 (diff) |
Merge branch 'asoc-omap' into for-3.7
Diffstat (limited to 'sound/soc/omap/omap-mcbsp.c')
-rw-r--r-- | sound/soc/omap/omap-mcbsp.c | 106 |
1 files changed, 73 insertions, 33 deletions
diff --git a/sound/soc/omap/omap-mcbsp.c b/sound/soc/omap/omap-mcbsp.c index acdd3ef14e08..d6de066ad7ea 100644 --- a/sound/soc/omap/omap-mcbsp.c +++ b/sound/soc/omap/omap-mcbsp.c | |||
@@ -26,6 +26,8 @@ | |||
26 | #include <linux/module.h> | 26 | #include <linux/module.h> |
27 | #include <linux/device.h> | 27 | #include <linux/device.h> |
28 | #include <linux/pm_runtime.h> | 28 | #include <linux/pm_runtime.h> |
29 | #include <linux/of.h> | ||
30 | #include <linux/of_device.h> | ||
29 | #include <sound/core.h> | 31 | #include <sound/core.h> |
30 | #include <sound/pcm.h> | 32 | #include <sound/pcm.h> |
31 | #include <sound/pcm_params.h> | 33 | #include <sound/pcm_params.h> |
@@ -398,12 +400,14 @@ static int omap_mcbsp_dai_set_dai_fmt(struct snd_soc_dai *cpu_dai, | |||
398 | /* Generic McBSP register settings */ | 400 | /* Generic McBSP register settings */ |
399 | regs->spcr2 |= XINTM(3) | FREE; | 401 | regs->spcr2 |= XINTM(3) | FREE; |
400 | regs->spcr1 |= RINTM(3); | 402 | regs->spcr1 |= RINTM(3); |
401 | /* RFIG and XFIG are not defined in 34xx */ | 403 | /* RFIG and XFIG are not defined in 2430 and on OMAP3+ */ |
402 | if (!cpu_is_omap34xx() && !cpu_is_omap44xx()) { | 404 | if (!mcbsp->pdata->has_ccr) { |
403 | regs->rcr2 |= RFIG; | 405 | regs->rcr2 |= RFIG; |
404 | regs->xcr2 |= XFIG; | 406 | regs->xcr2 |= XFIG; |
405 | } | 407 | } |
406 | if (cpu_is_omap2430() || cpu_is_omap34xx() || cpu_is_omap44xx()) { | 408 | |
409 | /* Configure XCCR/RCCR only for revisions which have ccr registers */ | ||
410 | if (mcbsp->pdata->has_ccr) { | ||
407 | regs->xccr = DXENDLY(1) | XDMAEN | XDISABLE; | 411 | regs->xccr = DXENDLY(1) | XDMAEN | XDISABLE; |
408 | regs->rccr = RFULL_CYCLE | RDMAEN | RDISABLE; | 412 | regs->rccr = RFULL_CYCLE | RDMAEN | RDISABLE; |
409 | } | 413 | } |
@@ -516,21 +520,9 @@ static int omap_mcbsp_dai_set_dai_sysclk(struct snd_soc_dai *cpu_dai, | |||
516 | return -EBUSY; | 520 | return -EBUSY; |
517 | } | 521 | } |
518 | 522 | ||
519 | if (clk_id == OMAP_MCBSP_SYSCLK_CLK || | 523 | mcbsp->in_freq = freq; |
520 | clk_id == OMAP_MCBSP_SYSCLK_CLKS_FCLK || | 524 | regs->srgr2 &= ~CLKSM; |
521 | clk_id == OMAP_MCBSP_SYSCLK_CLKS_EXT || | 525 | regs->pcr0 &= ~SCLKME; |
522 | clk_id == OMAP_MCBSP_SYSCLK_CLKX_EXT || | ||
523 | clk_id == OMAP_MCBSP_SYSCLK_CLKR_EXT) { | ||
524 | mcbsp->in_freq = freq; | ||
525 | regs->srgr2 &= ~CLKSM; | ||
526 | regs->pcr0 &= ~SCLKME; | ||
527 | } else if (cpu_class_is_omap1()) { | ||
528 | /* | ||
529 | * McBSP CLKR/FSR signal muxing functions are only available on | ||
530 | * OMAP2 or newer versions | ||
531 | */ | ||
532 | return -EINVAL; | ||
533 | } | ||
534 | 526 | ||
535 | switch (clk_id) { | 527 | switch (clk_id) { |
536 | case OMAP_MCBSP_SYSCLK_CLK: | 528 | case OMAP_MCBSP_SYSCLK_CLK: |
@@ -558,20 +550,6 @@ static int omap_mcbsp_dai_set_dai_sysclk(struct snd_soc_dai *cpu_dai, | |||
558 | case OMAP_MCBSP_SYSCLK_CLKR_EXT: | 550 | case OMAP_MCBSP_SYSCLK_CLKR_EXT: |
559 | regs->pcr0 |= SCLKME; | 551 | regs->pcr0 |= SCLKME; |
560 | break; | 552 | break; |
561 | |||
562 | |||
563 | case OMAP_MCBSP_CLKR_SRC_CLKR: | ||
564 | err = omap_mcbsp_6pin_src_mux(mcbsp, CLKR_SRC_CLKR); | ||
565 | break; | ||
566 | case OMAP_MCBSP_CLKR_SRC_CLKX: | ||
567 | err = omap_mcbsp_6pin_src_mux(mcbsp, CLKR_SRC_CLKX); | ||
568 | break; | ||
569 | case OMAP_MCBSP_FSR_SRC_FSR: | ||
570 | err = omap_mcbsp_6pin_src_mux(mcbsp, FSR_SRC_FSR); | ||
571 | break; | ||
572 | case OMAP_MCBSP_FSR_SRC_FSX: | ||
573 | err = omap_mcbsp_6pin_src_mux(mcbsp, FSR_SRC_FSX); | ||
574 | break; | ||
575 | default: | 553 | default: |
576 | err = -ENODEV; | 554 | err = -ENODEV; |
577 | } | 555 | } |
@@ -761,13 +739,74 @@ int omap_mcbsp_st_add_controls(struct snd_soc_pcm_runtime *rtd) | |||
761 | } | 739 | } |
762 | EXPORT_SYMBOL_GPL(omap_mcbsp_st_add_controls); | 740 | EXPORT_SYMBOL_GPL(omap_mcbsp_st_add_controls); |
763 | 741 | ||
742 | static struct omap_mcbsp_platform_data omap2420_pdata = { | ||
743 | .reg_step = 4, | ||
744 | .reg_size = 2, | ||
745 | }; | ||
746 | |||
747 | static struct omap_mcbsp_platform_data omap2430_pdata = { | ||
748 | .reg_step = 4, | ||
749 | .reg_size = 4, | ||
750 | .has_ccr = true, | ||
751 | }; | ||
752 | |||
753 | static struct omap_mcbsp_platform_data omap3_pdata = { | ||
754 | .reg_step = 4, | ||
755 | .reg_size = 4, | ||
756 | .has_ccr = true, | ||
757 | .has_wakeup = true, | ||
758 | }; | ||
759 | |||
760 | static struct omap_mcbsp_platform_data omap4_pdata = { | ||
761 | .reg_step = 4, | ||
762 | .reg_size = 4, | ||
763 | .has_ccr = true, | ||
764 | .has_wakeup = true, | ||
765 | }; | ||
766 | |||
767 | static const struct of_device_id omap_mcbsp_of_match[] = { | ||
768 | { | ||
769 | .compatible = "ti,omap2420-mcbsp", | ||
770 | .data = &omap2420_pdata, | ||
771 | }, | ||
772 | { | ||
773 | .compatible = "ti,omap2430-mcbsp", | ||
774 | .data = &omap2430_pdata, | ||
775 | }, | ||
776 | { | ||
777 | .compatible = "ti,omap3-mcbsp", | ||
778 | .data = &omap3_pdata, | ||
779 | }, | ||
780 | { | ||
781 | .compatible = "ti,omap4-mcbsp", | ||
782 | .data = &omap4_pdata, | ||
783 | }, | ||
784 | { }, | ||
785 | }; | ||
786 | MODULE_DEVICE_TABLE(of, omap_mcbsp_of_match); | ||
787 | |||
764 | static __devinit int asoc_mcbsp_probe(struct platform_device *pdev) | 788 | static __devinit int asoc_mcbsp_probe(struct platform_device *pdev) |
765 | { | 789 | { |
766 | struct omap_mcbsp_platform_data *pdata = dev_get_platdata(&pdev->dev); | 790 | struct omap_mcbsp_platform_data *pdata = dev_get_platdata(&pdev->dev); |
767 | struct omap_mcbsp *mcbsp; | 791 | struct omap_mcbsp *mcbsp; |
792 | const struct of_device_id *match; | ||
768 | int ret; | 793 | int ret; |
769 | 794 | ||
770 | if (!pdata) { | 795 | match = of_match_device(omap_mcbsp_of_match, &pdev->dev); |
796 | if (match) { | ||
797 | struct device_node *node = pdev->dev.of_node; | ||
798 | int buffer_size; | ||
799 | |||
800 | pdata = devm_kzalloc(&pdev->dev, | ||
801 | sizeof(struct omap_mcbsp_platform_data), | ||
802 | GFP_KERNEL); | ||
803 | if (!pdata) | ||
804 | return -ENOMEM; | ||
805 | |||
806 | memcpy(pdata, match->data, sizeof(*pdata)); | ||
807 | if (!of_property_read_u32(node, "ti,buffer-size", &buffer_size)) | ||
808 | pdata->buffer_size = buffer_size; | ||
809 | } else if (!pdata) { | ||
771 | dev_err(&pdev->dev, "missing platform data.\n"); | 810 | dev_err(&pdev->dev, "missing platform data.\n"); |
772 | return -EINVAL; | 811 | return -EINVAL; |
773 | } | 812 | } |
@@ -809,6 +848,7 @@ static struct platform_driver asoc_mcbsp_driver = { | |||
809 | .driver = { | 848 | .driver = { |
810 | .name = "omap-mcbsp", | 849 | .name = "omap-mcbsp", |
811 | .owner = THIS_MODULE, | 850 | .owner = THIS_MODULE, |
851 | .of_match_table = omap_mcbsp_of_match, | ||
812 | }, | 852 | }, |
813 | 853 | ||
814 | .probe = asoc_mcbsp_probe, | 854 | .probe = asoc_mcbsp_probe, |