diff options
Diffstat (limited to 'sound/soc/fsl/pcm030-audio-fabric.c')
-rw-r--r-- | sound/soc/fsl/pcm030-audio-fabric.c | 100 |
1 files changed, 73 insertions, 27 deletions
diff --git a/sound/soc/fsl/pcm030-audio-fabric.c b/sound/soc/fsl/pcm030-audio-fabric.c index b3af55dcde9d..4b63ec8eb372 100644 --- a/sound/soc/fsl/pcm030-audio-fabric.c +++ b/sound/soc/fsl/pcm030-audio-fabric.c | |||
@@ -12,32 +12,27 @@ | |||
12 | 12 | ||
13 | #include <linux/init.h> | 13 | #include <linux/init.h> |
14 | #include <linux/module.h> | 14 | #include <linux/module.h> |
15 | #include <linux/interrupt.h> | ||
16 | #include <linux/device.h> | 15 | #include <linux/device.h> |
17 | #include <linux/delay.h> | ||
18 | #include <linux/of_device.h> | 16 | #include <linux/of_device.h> |
19 | #include <linux/of_platform.h> | 17 | #include <linux/of_platform.h> |
20 | #include <linux/dma-mapping.h> | ||
21 | 18 | ||
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> | 19 | #include <sound/soc.h> |
27 | 20 | ||
28 | #include "mpc5200_dma.h" | 21 | #include "mpc5200_dma.h" |
29 | #include "mpc5200_psc_ac97.h" | ||
30 | #include "../codecs/wm9712.h" | ||
31 | 22 | ||
32 | #define DRV_NAME "pcm030-audio-fabric" | 23 | #define DRV_NAME "pcm030-audio-fabric" |
33 | 24 | ||
25 | struct pcm030_audio_data { | ||
26 | struct snd_soc_card *card; | ||
27 | struct platform_device *codec_device; | ||
28 | }; | ||
29 | |||
34 | static struct snd_soc_dai_link pcm030_fabric_dai[] = { | 30 | static struct snd_soc_dai_link pcm030_fabric_dai[] = { |
35 | { | 31 | { |
36 | .name = "AC97", | 32 | .name = "AC97", |
37 | .stream_name = "AC97 Analog", | 33 | .stream_name = "AC97 Analog", |
38 | .codec_dai_name = "wm9712-hifi", | 34 | .codec_dai_name = "wm9712-hifi", |
39 | .cpu_dai_name = "mpc5200-psc-ac97.0", | 35 | .cpu_dai_name = "mpc5200-psc-ac97.0", |
40 | .platform_name = "mpc5200-pcm-audio", | ||
41 | .codec_name = "wm9712-codec", | 36 | .codec_name = "wm9712-codec", |
42 | }, | 37 | }, |
43 | { | 38 | { |
@@ -45,44 +40,95 @@ static struct snd_soc_dai_link pcm030_fabric_dai[] = { | |||
45 | .stream_name = "AC97 IEC958", | 40 | .stream_name = "AC97 IEC958", |
46 | .codec_dai_name = "wm9712-aux", | 41 | .codec_dai_name = "wm9712-aux", |
47 | .cpu_dai_name = "mpc5200-psc-ac97.1", | 42 | .cpu_dai_name = "mpc5200-psc-ac97.1", |
48 | .platform_name = "mpc5200-pcm-audio", | ||
49 | .codec_name = "wm9712-codec", | 43 | .codec_name = "wm9712-codec", |
50 | }, | 44 | }, |
51 | }; | 45 | }; |
52 | 46 | ||
53 | static struct snd_soc_card card = { | 47 | static struct snd_soc_card pcm030_card = { |
54 | .name = "pcm030", | 48 | .name = "pcm030", |
55 | .owner = THIS_MODULE, | 49 | .owner = THIS_MODULE, |
56 | .dai_link = pcm030_fabric_dai, | 50 | .dai_link = pcm030_fabric_dai, |
57 | .num_links = ARRAY_SIZE(pcm030_fabric_dai), | 51 | .num_links = ARRAY_SIZE(pcm030_fabric_dai), |
58 | }; | 52 | }; |
59 | 53 | ||
60 | static __init int pcm030_fabric_init(void) | 54 | static int __init pcm030_fabric_probe(struct platform_device *op) |
61 | { | 55 | { |
62 | struct platform_device *pdev; | 56 | struct device_node *np = op->dev.of_node; |
63 | int rc; | 57 | struct device_node *platform_np; |
58 | struct snd_soc_card *card = &pcm030_card; | ||
59 | struct pcm030_audio_data *pdata; | ||
60 | int ret; | ||
61 | int i; | ||
64 | 62 | ||
65 | if (!of_machine_is_compatible("phytec,pcm030")) | 63 | if (!of_machine_is_compatible("phytec,pcm030")) |
66 | return -ENODEV; | 64 | return -ENODEV; |
67 | 65 | ||
68 | pdev = platform_device_alloc("soc-audio", 1); | 66 | pdata = devm_kzalloc(&op->dev, sizeof(struct pcm030_audio_data), |
69 | if (!pdev) { | 67 | GFP_KERNEL); |
70 | pr_err("pcm030_fabric_init: platform_device_alloc() failed\n"); | 68 | if (!pdata) |
71 | return -ENODEV; | 69 | return -ENOMEM; |
72 | } | 70 | |
71 | card->dev = &op->dev; | ||
72 | platform_set_drvdata(op, pdata); | ||
73 | 73 | ||
74 | platform_set_drvdata(pdev, &card); | 74 | pdata->card = card; |
75 | 75 | ||
76 | rc = platform_device_add(pdev); | 76 | platform_np = of_parse_phandle(np, "asoc-platform", 0); |
77 | if (rc) { | 77 | if (!platform_np) { |
78 | pr_err("pcm030_fabric_init: platform_device_add() failed\n"); | 78 | dev_err(&op->dev, "ac97 not registered\n"); |
79 | platform_device_put(pdev); | ||
80 | return -ENODEV; | 79 | return -ENODEV; |
81 | } | 80 | } |
82 | return 0; | 81 | |
82 | for (i = 0; i < card->num_links; i++) | ||
83 | card->dai_link[i].platform_of_node = platform_np; | ||
84 | |||
85 | ret = request_module("snd-soc-wm9712"); | ||
86 | if (ret) | ||
87 | dev_err(&op->dev, "request_module returned: %d\n", ret); | ||
88 | |||
89 | pdata->codec_device = platform_device_alloc("wm9712-codec", -1); | ||
90 | if (!pdata->codec_device) | ||
91 | dev_err(&op->dev, "platform_device_alloc() failed\n"); | ||
92 | |||
93 | ret = platform_device_add(pdata->codec_device); | ||
94 | if (ret) | ||
95 | dev_err(&op->dev, "platform_device_add() failed: %d\n", ret); | ||
96 | |||
97 | ret = snd_soc_register_card(card); | ||
98 | if (ret) | ||
99 | dev_err(&op->dev, "snd_soc_register_card() failed: %d\n", ret); | ||
100 | |||
101 | return ret; | ||
102 | } | ||
103 | |||
104 | static int __devexit pcm030_fabric_remove(struct platform_device *op) | ||
105 | { | ||
106 | struct pcm030_audio_data *pdata = platform_get_drvdata(op); | ||
107 | int ret; | ||
108 | |||
109 | ret = snd_soc_unregister_card(pdata->card); | ||
110 | platform_device_unregister(pdata->codec_device); | ||
111 | |||
112 | return ret; | ||
83 | } | 113 | } |
84 | 114 | ||
85 | module_init(pcm030_fabric_init); | 115 | static struct of_device_id pcm030_audio_match[] = { |
116 | { .compatible = "phytec,pcm030-audio-fabric", }, | ||
117 | {} | ||
118 | }; | ||
119 | MODULE_DEVICE_TABLE(of, pcm030_audio_match); | ||
120 | |||
121 | static struct platform_driver pcm030_fabric_driver = { | ||
122 | .probe = pcm030_fabric_probe, | ||
123 | .remove = __devexit_p(pcm030_fabric_remove), | ||
124 | .driver = { | ||
125 | .name = DRV_NAME, | ||
126 | .owner = THIS_MODULE, | ||
127 | .of_match_table = pcm030_audio_match, | ||
128 | }, | ||
129 | }; | ||
130 | |||
131 | module_platform_driver(pcm030_fabric_driver); | ||
86 | 132 | ||
87 | 133 | ||
88 | MODULE_AUTHOR("Jon Smirl <jonsmirl@gmail.com>"); | 134 | MODULE_AUTHOR("Jon Smirl <jonsmirl@gmail.com>"); |