8766f7a3893d92aac0797d40652cadc77216af23
[pandora-kernel.git] / sound / soc / fsl / pcm030-audio-fabric.c
1 /*
2  * Phytec pcm030 driver for the PSC of the Freescale MPC52xx
3  * configured as AC97 interface
4  *
5  * Copyright 2008 Jon Smirl, Digispeaker
6  * Author: Jon Smirl <jonsmirl@gmail.com>
7  *
8  * This file is licensed under the terms of the GNU General Public License
9  * version 2. This program is licensed "as is" without any warranty of any
10  * kind, whether express or implied.
11  */
12
13 #include <linux/init.h>
14 #include <linux/module.h>
15 #include <linux/interrupt.h>
16 #include <linux/device.h>
17 #include <linux/delay.h>
18 #include <linux/of_device.h>
19 #include <linux/of_platform.h>
20 #include <linux/dma-mapping.h>
21
22 #include <sound/core.h>
23 #include <sound/pcm.h>
24 #include <sound/pcm_params.h>
25 #include <sound/initval.h>
26 #include <sound/soc.h>
27 #include <sound/soc-of-simple.h>
28
29 #include "mpc5200_dma.h"
30 #include "mpc5200_psc_ac97.h"
31 #include "../codecs/wm9712.h"
32
33 static struct snd_soc_device device;
34 static struct snd_soc_card card;
35
36 static struct snd_soc_dai_link pcm030_fabric_dai[] = {
37 {
38         .name = "AC97",
39         .stream_name = "AC97 Analog",
40         .codec_dai = &wm9712_dai[WM9712_DAI_AC97_HIFI],
41         .cpu_dai = &psc_ac97_dai[MPC5200_AC97_NORMAL],
42 },
43 {
44         .name = "AC97",
45         .stream_name = "AC97 IEC958",
46         .codec_dai = &wm9712_dai[WM9712_DAI_AC97_AUX],
47         .cpu_dai = &psc_ac97_dai[MPC5200_AC97_SPDIF],
48 },
49 };
50
51 static __init int pcm030_fabric_init(void)
52 {
53         struct platform_device *pdev;
54         int rc;
55
56         if (!machine_is_compatible("phytec,pcm030"))
57                 return -ENODEV;
58
59         card.platform = &mpc5200_audio_dma_platform;
60         card.name = "pcm030";
61         card.dai_link = pcm030_fabric_dai;
62         card.num_links = ARRAY_SIZE(pcm030_fabric_dai);
63
64         device.card = &card;
65         device.codec_dev = &soc_codec_dev_wm9712;
66
67         pdev = platform_device_alloc("soc-audio", 1);
68         if (!pdev) {
69                 pr_err("pcm030_fabric_init: platform_device_alloc() failed\n");
70                 return -ENODEV;
71         }
72
73         platform_set_drvdata(pdev, &device);
74         device.dev = &pdev->dev;
75
76         rc = platform_device_add(pdev);
77         if (rc) {
78                 pr_err("pcm030_fabric_init: platform_device_add() failed\n");
79                 return -ENODEV;
80         }
81         return 0;
82 }
83
84 module_init(pcm030_fabric_init);
85
86
87 MODULE_AUTHOR("Jon Smirl <jonsmirl@gmail.com>");
88 MODULE_DESCRIPTION(DRV_NAME ": mpc5200 pcm030 fabric driver");
89 MODULE_LICENSE("GPL");
90