]> Git Repo - linux.git/blame - sound/soc/au1x/db1200.c
Merge branch 'pnfs-submit' of git://git.open-osd.org/linux-open-osd
[linux.git] / sound / soc / au1x / db1200.c
CommitLineData
05ae3231
ML
1/*
2 * DB1200 ASoC audio fabric support code.
3 *
4 * (c) 2008-9 Manuel Lauss <[email protected]>
5 *
6 */
7
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>
05ae3231
ML
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>
20
05ae3231
ML
21#include "../codecs/wm8731.h"
22#include "psc.h"
23
24/*------------------------- AC97 PART ---------------------------*/
25
26static struct snd_soc_dai_link db1200_ac97_dai = {
27 .name = "AC97",
28 .stream_name = "AC97 HiFi",
f0fba2ad 29 .codec_dai_name = "ac97-hifi",
ffc4fdbb
ML
30 .cpu_dai_name = "au1xpsc_ac97.1",
31 .platform_name = "au1xpsc-pcm.1",
32 .codec_name = "ac97-codec.1",
05ae3231
ML
33};
34
35static struct snd_soc_card db1200_ac97_machine = {
36 .name = "DB1200_AC97",
37 .dai_link = &db1200_ac97_dai,
38 .num_links = 1,
05ae3231
ML
39};
40
41/*------------------------- I2S PART ---------------------------*/
42
43static int db1200_i2s_startup(struct snd_pcm_substream *substream)
44{
45 struct snd_soc_pcm_runtime *rtd = substream->private_data;
f0fba2ad
LG
46 struct snd_soc_dai *codec_dai = rtd->codec_dai;
47 struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
05ae3231
ML
48 int ret;
49
50 /* WM8731 has its own 12MHz crystal */
9745e824 51 snd_soc_dai_set_sysclk(codec_dai, WM8731_SYSCLK_XTAL,
05ae3231
ML
52 12000000, SND_SOC_CLOCK_IN);
53
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;
59
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;
64
65 ret = 0;
66out:
67 return ret;
68}
69
70static struct snd_soc_ops db1200_i2s_wm8731_ops = {
71 .startup = db1200_i2s_startup,
72};
73
74static struct snd_soc_dai_link db1200_i2s_dai = {
75 .name = "WM8731",
76 .stream_name = "WM8731 PCM",
ffc4fdbb
ML
77 .codec_dai_name = "wm8731-hifi",
78 .cpu_dai_name = "au1xpsc_i2s.1",
79 .platform_name = "au1xpsc-pcm.1",
99b59f3c 80 .codec_name = "wm8731.0-001b",
05ae3231
ML
81 .ops = &db1200_i2s_wm8731_ops,
82};
83
84static struct snd_soc_card db1200_i2s_machine = {
85 .name = "DB1200_I2S",
86 .dai_link = &db1200_i2s_dai,
87 .num_links = 1,
05ae3231
ML
88};
89
90/*------------------------- COMMON PART ---------------------------*/
91
92static struct platform_device *db1200_asoc_dev;
93
94static int __init db1200_audio_load(void)
95{
96 int ret;
97
98 ret = -ENOMEM;
ffc4fdbb 99 db1200_asoc_dev = platform_device_alloc("soc-audio", 1); /* PSC1 */
05ae3231
ML
100 if (!db1200_asoc_dev)
101 goto out;
102
103 /* DB1200 board setup set PSC1MUX to preferred audio device */
104 if (bcsr_read(BCSR_RESETS) & BCSR_RESETS_PSC1MUX)
f0fba2ad 105 platform_set_drvdata(db1200_asoc_dev, &db1200_i2s_machine);
05ae3231 106 else
f0fba2ad 107 platform_set_drvdata(db1200_asoc_dev, &db1200_ac97_machine);
05ae3231 108
05ae3231
ML
109 ret = platform_device_add(db1200_asoc_dev);
110
111 if (ret) {
112 platform_device_put(db1200_asoc_dev);
113 db1200_asoc_dev = NULL;
114 }
115out:
116 return ret;
117}
118
119static void __exit db1200_audio_unload(void)
120{
121 platform_device_unregister(db1200_asoc_dev);
122}
123
124module_init(db1200_audio_load);
125module_exit(db1200_audio_unload);
126
127MODULE_LICENSE("GPL");
128MODULE_DESCRIPTION("DB1200 ASoC audio support");
129MODULE_AUTHOR("Manuel Lauss");
This page took 0.1489 seconds and 4 git commands to generate.