2 * DB1200/DB1300/DB1550 ASoC audio fabric support code.
4 * (c) 2008-2011 Manuel Lauss <manuel.lauss@googlemail.com>
8 #include <linux/module.h>
9 #include <linux/moduleparam.h>
10 #include <linux/timer.h>
11 #include <linux/interrupt.h>
12 #include <linux/platform_device.h>
13 #include <sound/core.h>
14 #include <sound/pcm.h>
15 #include <sound/soc.h>
16 #include <asm/mach-au1x00/au1000.h>
17 #include <asm/mach-au1x00/au1xxx_psc.h>
18 #include <asm/mach-au1x00/au1xxx_dbdma.h>
19 #include <asm/mach-db1x00/bcsr.h>
21 #include "../codecs/wm8731.h"
24 static struct platform_device_id db1200_pids
[] = {
26 .name
= "db1200-ac97",
32 .name
= "db1300-ac97",
38 .name
= "db1550-ac97",
47 /*------------------------- AC97 PART ---------------------------*/
49 static struct snd_soc_dai_link db1200_ac97_dai
= {
51 .stream_name
= "AC97 HiFi",
52 .codec_dai_name
= "ac97-hifi",
53 .cpu_dai_name
= "au1xpsc_ac97.1",
54 .platform_name
= "au1xpsc-pcm.1",
55 .codec_name
= "ac97-codec.1",
58 static struct snd_soc_card db1200_ac97_machine
= {
59 .name
= "DB1200_AC97",
61 .dai_link
= &db1200_ac97_dai
,
65 static struct snd_soc_dai_link db1300_ac97_dai
= {
67 .stream_name
= "AC97 HiFi",
68 .codec_dai_name
= "wm9712-hifi",
69 .cpu_dai_name
= "au1xpsc_ac97.1",
70 .platform_name
= "au1xpsc-pcm.1",
71 .codec_name
= "wm9712-codec.1",
74 static struct snd_soc_card db1300_ac97_machine
= {
75 .name
= "DB1300_AC97",
77 .dai_link
= &db1300_ac97_dai
,
81 static struct snd_soc_card db1550_ac97_machine
= {
82 .name
= "DB1550_AC97",
84 .dai_link
= &db1200_ac97_dai
,
88 /*------------------------- I2S PART ---------------------------*/
90 static int db1200_i2s_startup(struct snd_pcm_substream
*substream
)
92 struct snd_soc_pcm_runtime
*rtd
= substream
->private_data
;
93 struct snd_soc_dai
*codec_dai
= rtd
->codec_dai
;
94 struct snd_soc_dai
*cpu_dai
= rtd
->cpu_dai
;
97 /* WM8731 has its own 12MHz crystal */
98 snd_soc_dai_set_sysclk(codec_dai
, WM8731_SYSCLK_XTAL
,
99 12000000, SND_SOC_CLOCK_IN
);
101 /* codec is bitclock and lrclk master */
102 ret
= snd_soc_dai_set_fmt(codec_dai
, SND_SOC_DAIFMT_LEFT_J
|
103 SND_SOC_DAIFMT_NB_NF
| SND_SOC_DAIFMT_CBM_CFM
);
107 ret
= snd_soc_dai_set_fmt(cpu_dai
, SND_SOC_DAIFMT_LEFT_J
|
108 SND_SOC_DAIFMT_NB_NF
| SND_SOC_DAIFMT_CBM_CFM
);
117 static struct snd_soc_ops db1200_i2s_wm8731_ops
= {
118 .startup
= db1200_i2s_startup
,
121 static struct snd_soc_dai_link db1200_i2s_dai
= {
123 .stream_name
= "WM8731 PCM",
124 .codec_dai_name
= "wm8731-hifi",
125 .cpu_dai_name
= "au1xpsc_i2s.1",
126 .platform_name
= "au1xpsc-pcm.1",
127 .codec_name
= "wm8731.0-001b",
128 .ops
= &db1200_i2s_wm8731_ops
,
131 static struct snd_soc_card db1200_i2s_machine
= {
132 .name
= "DB1200_I2S",
133 .owner
= THIS_MODULE
,
134 .dai_link
= &db1200_i2s_dai
,
138 static struct snd_soc_dai_link db1300_i2s_dai
= {
140 .stream_name
= "WM8731 PCM",
141 .codec_dai_name
= "wm8731-hifi",
142 .cpu_dai_name
= "au1xpsc_i2s.2",
143 .platform_name
= "au1xpsc-pcm.2",
144 .codec_name
= "wm8731.0-001b",
145 .ops
= &db1200_i2s_wm8731_ops
,
148 static struct snd_soc_card db1300_i2s_machine
= {
149 .name
= "DB1300_I2S",
150 .owner
= THIS_MODULE
,
151 .dai_link
= &db1300_i2s_dai
,
155 static struct snd_soc_dai_link db1550_i2s_dai
= {
157 .stream_name
= "WM8731 PCM",
158 .codec_dai_name
= "wm8731-hifi",
159 .cpu_dai_name
= "au1xpsc_i2s.3",
160 .platform_name
= "au1xpsc-pcm.3",
161 .codec_name
= "wm8731.0-001b",
162 .ops
= &db1200_i2s_wm8731_ops
,
165 static struct snd_soc_card db1550_i2s_machine
= {
166 .name
= "DB1550_I2S",
167 .owner
= THIS_MODULE
,
168 .dai_link
= &db1550_i2s_dai
,
172 /*------------------------- COMMON PART ---------------------------*/
174 static struct snd_soc_card
*db1200_cards
[] = {
175 &db1200_ac97_machine
,
177 &db1300_ac97_machine
,
179 &db1550_ac97_machine
,
183 static int db1200_audio_probe(struct platform_device
*pdev
)
185 const struct platform_device_id
*pid
= platform_get_device_id(pdev
);
186 struct snd_soc_card
*card
;
188 card
= db1200_cards
[pid
->driver_data
];
189 card
->dev
= &pdev
->dev
;
190 return snd_soc_register_card(card
);
193 static int db1200_audio_remove(struct platform_device
*pdev
)
195 struct snd_soc_card
*card
= platform_get_drvdata(pdev
);
196 snd_soc_unregister_card(card
);
200 static struct platform_driver db1200_audio_driver
= {
202 .name
= "db1200-ac97",
203 .owner
= THIS_MODULE
,
204 .pm
= &snd_soc_pm_ops
,
206 .id_table
= db1200_pids
,
207 .probe
= db1200_audio_probe
,
208 .remove
= db1200_audio_remove
,
211 module_platform_driver(db1200_audio_driver
);
213 MODULE_LICENSE("GPL");
214 MODULE_DESCRIPTION("DB1200/DB1300/DB1550 ASoC audio support");
215 MODULE_AUTHOR("Manuel Lauss");