Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input
[linux-btrfs-devel.git] / sound / soc / au1x / db1200.c
blob1d3e258c9ea8ec861cf19c88a9bd7c99e5384940
1 /*
2 * DB1200 ASoC audio fabric support code.
4 * (c) 2008-9 Manuel Lauss <manuel.lauss@gmail.com>
6 */
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"
22 #include "psc.h"
24 /*------------------------- AC97 PART ---------------------------*/
26 static struct snd_soc_dai_link db1200_ac97_dai = {
27 .name = "AC97",
28 .stream_name = "AC97 HiFi",
29 .codec_dai_name = "ac97-hifi",
30 .cpu_dai_name = "au1xpsc_ac97.1",
31 .platform_name = "au1xpsc-pcm.1",
32 .codec_name = "ac97-codec.1",
35 static struct snd_soc_card db1200_ac97_machine = {
36 .name = "DB1200_AC97",
37 .dai_link = &db1200_ac97_dai,
38 .num_links = 1,
41 /*------------------------- I2S PART ---------------------------*/
43 static int db1200_i2s_startup(struct snd_pcm_substream *substream)
45 struct snd_soc_pcm_runtime *rtd = substream->private_data;
46 struct snd_soc_dai *codec_dai = rtd->codec_dai;
47 struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
48 int ret;
50 /* WM8731 has its own 12MHz crystal */
51 snd_soc_dai_set_sysclk(codec_dai, WM8731_SYSCLK_XTAL,
52 12000000, SND_SOC_CLOCK_IN);
54 /* codec is bitclock and lrclk master */
55 ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_LEFT_J |
56 SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM);
57 if (ret < 0)
58 goto out;
60 ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_LEFT_J |
61 SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM);
62 if (ret < 0)
63 goto out;
65 ret = 0;
66 out:
67 return ret;
70 static struct snd_soc_ops db1200_i2s_wm8731_ops = {
71 .startup = db1200_i2s_startup,
74 static struct snd_soc_dai_link db1200_i2s_dai = {
75 .name = "WM8731",
76 .stream_name = "WM8731 PCM",
77 .codec_dai_name = "wm8731-hifi",
78 .cpu_dai_name = "au1xpsc_i2s.1",
79 .platform_name = "au1xpsc-pcm.1",
80 .codec_name = "wm8731.0-001b",
81 .ops = &db1200_i2s_wm8731_ops,
84 static struct snd_soc_card db1200_i2s_machine = {
85 .name = "DB1200_I2S",
86 .dai_link = &db1200_i2s_dai,
87 .num_links = 1,
90 /*------------------------- COMMON PART ---------------------------*/
92 static struct platform_device *db1200_asoc_dev;
94 static int __init db1200_audio_load(void)
96 int ret;
98 ret = -ENOMEM;
99 db1200_asoc_dev = platform_device_alloc("soc-audio", 1); /* PSC1 */
100 if (!db1200_asoc_dev)
101 goto out;
103 /* DB1200 board setup set PSC1MUX to preferred audio device */
104 if (bcsr_read(BCSR_RESETS) & BCSR_RESETS_PSC1MUX)
105 platform_set_drvdata(db1200_asoc_dev, &db1200_i2s_machine);
106 else
107 platform_set_drvdata(db1200_asoc_dev, &db1200_ac97_machine);
109 ret = platform_device_add(db1200_asoc_dev);
111 if (ret) {
112 platform_device_put(db1200_asoc_dev);
113 db1200_asoc_dev = NULL;
115 out:
116 return ret;
119 static void __exit db1200_audio_unload(void)
121 platform_device_unregister(db1200_asoc_dev);
124 module_init(db1200_audio_load);
125 module_exit(db1200_audio_unload);
127 MODULE_LICENSE("GPL");
128 MODULE_DESCRIPTION("DB1200 ASoC audio support");
129 MODULE_AUTHOR("Manuel Lauss");