aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/atmel/atmel_ssc_dai.c
diff options
context:
space:
mode:
authorMark Brown <broonie@opensource.wolfsonmicro.com>2010-08-18 11:29:37 -0400
committerMark Brown <broonie@opensource.wolfsonmicro.com>2010-08-18 11:53:22 -0400
commitabfa4eae0bd2723859931631771ac275f97cada4 (patch)
treee6bb08ccc9e15b18bead4dae83fe139eb409be1a /sound/soc/atmel/atmel_ssc_dai.c
parentdad965f07be946726c6153cf578d089ea991f41e (diff)
ASoC: Add simplfied device registration for Atmel SSC devices
Since the SSC is already being registered as a device under arch and the DMA and SSC hardware are pretty much the same provide a simplified device registration function for the Atmel SSC which will add the ASoC-specific devices within the ASoC code, parenting the SSC device off the actual SSC device. Also use it in the sam9g20-ek driver. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Acked-by: Liam Girdwood <lrg@slimlogic.co.uk>
Diffstat (limited to 'sound/soc/atmel/atmel_ssc_dai.c')
-rw-r--r--sound/soc/atmel/atmel_ssc_dai.c57
1 files changed, 54 insertions, 3 deletions
diff --git a/sound/soc/atmel/atmel_ssc_dai.c b/sound/soc/atmel/atmel_ssc_dai.c
index eabf66af12c..5d230cee3fa 100644
--- a/sound/soc/atmel/atmel_ssc_dai.c
+++ b/sound/soc/atmel/atmel_ssc_dai.c
@@ -789,13 +789,14 @@ static struct snd_soc_dai_driver atmel_ssc_dai[NUM_SSC_DEVICES] = {
789 789
790static __devinit int asoc_ssc_probe(struct platform_device *pdev) 790static __devinit int asoc_ssc_probe(struct platform_device *pdev)
791{ 791{
792 return snd_soc_register_dais(&pdev->dev, atmel_ssc_dai, 792 BUG_ON(pdev->id < 0);
793 ARRAY_SIZE(atmel_ssc_dai)); 793 BUG_ON(pdev->id >= ARRAY_SIZE(atmel_ssc_dai));
794 return snd_soc_register_dai(&pdev->dev, &atmel_ssc_dai[pdev->id]);
794} 795}
795 796
796static int __devexit asoc_ssc_remove(struct platform_device *pdev) 797static int __devexit asoc_ssc_remove(struct platform_device *pdev)
797{ 798{
798 snd_soc_unregister_dais(&pdev->dev, ARRAY_SIZE(atmel_ssc_dai)); 799 snd_soc_unregister_dai(&pdev->dev);
799 return 0; 800 return 0;
800} 801}
801 802
@@ -809,6 +810,56 @@ static struct platform_driver asoc_ssc_driver = {
809 .remove = __devexit_p(asoc_ssc_remove), 810 .remove = __devexit_p(asoc_ssc_remove),
810}; 811};
811 812
813/**
814 * atmel_ssc_set_audio - Allocate the specified SSC for audio use.
815 */
816int atmel_ssc_set_audio(int ssc_id)
817{
818 struct ssc_device *ssc;
819 static struct platform_device *dma_pdev;
820 struct platform_device *ssc_pdev;
821 int ret;
822
823 if (ssc_id < 0 || ssc_id >= ARRAY_SIZE(atmel_ssc_dai))
824 return -EINVAL;
825
826 /* Allocate a dummy device for DMA if we don't have one already */
827 if (!dma_pdev) {
828 dma_pdev = platform_device_alloc("atmel-pcm-audio", -1);
829 if (!dma_pdev)
830 return -ENOMEM;
831
832 ret = platform_device_add(dma_pdev);
833 if (ret < 0) {
834 platform_device_put(dma_pdev);
835 dma_pdev = NULL;
836 return ret;
837 }
838 }
839
840 ssc_pdev = platform_device_alloc("atmel-ssc-dai", ssc_id);
841 if (!ssc_pdev) {
842 ssc_free(ssc);
843 return -ENOMEM;
844 }
845
846 /* If we can grab the SSC briefly to parent the DAI device off it */
847 ssc = ssc_request(ssc_id);
848 if (IS_ERR(ssc))
849 pr_warn("Unable to parent ASoC SSC DAI on SSC: %ld\n",
850 PTR_ERR(ssc));
851 else
852 ssc_pdev->dev.parent = &(ssc->pdev->dev);
853 ssc_free(ssc);
854
855 ret = platform_device_add(ssc_pdev);
856 if (ret < 0)
857 platform_device_put(ssc_pdev);
858
859 return ret;
860}
861EXPORT_SYMBOL_GPL(atmel_ssc_set_audio);
862
812static int __init snd_atmel_ssc_init(void) 863static int __init snd_atmel_ssc_init(void)
813{ 864{
814 return platform_driver_register(&asoc_ssc_driver); 865 return platform_driver_register(&asoc_ssc_driver);