blob: c75995f2779cf57604de8d1ef37c4aa42c31d2a5 [file] [log] [blame]
Manuel Lauss05ae3232009-11-02 21:21:44 +01001/*
Manuel Laussf869d422011-11-10 12:06:16 +00002 * DB1200/DB1300/DB1550 ASoC audio fabric support code.
Manuel Lauss05ae3232009-11-02 21:21:44 +01003 *
Manuel Laussadbc7a52011-07-25 13:45:03 +02004 * (c) 2008-2011 Manuel Lauss <manuel.lauss@googlemail.com>
Manuel Lauss05ae3232009-11-02 21:21:44 +01005 *
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>
Manuel Lauss05ae3232009-11-02 21:21:44 +010016#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
Manuel Lauss05ae3232009-11-02 21:21:44 +010021#include "../codecs/wm8731.h"
22#include "psc.h"
23
Manuel Laussadbc7a52011-07-25 13:45:03 +020024static struct platform_device_id db1200_pids[] = {
25 {
26 .name = "db1200-ac97",
27 .driver_data = 0,
28 }, {
29 .name = "db1200-i2s",
30 .driver_data = 1,
Manuel Lauss64cd04d2011-11-10 12:03:26 +000031 }, {
32 .name = "db1300-ac97",
33 .driver_data = 2,
34 }, {
35 .name = "db1300-i2s",
36 .driver_data = 3,
Manuel Laussf869d422011-11-10 12:06:16 +000037 }, {
38 .name = "db1550-ac97",
39 .driver_data = 4,
40 }, {
41 .name = "db1550-i2s",
42 .driver_data = 5,
Manuel Laussadbc7a52011-07-25 13:45:03 +020043 },
44 {},
45};
46
Manuel Lauss05ae3232009-11-02 21:21:44 +010047/*------------------------- AC97 PART ---------------------------*/
48
49static struct snd_soc_dai_link db1200_ac97_dai = {
50 .name = "AC97",
51 .stream_name = "AC97 HiFi",
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +000052 .codec_dai_name = "ac97-hifi",
Manuel Laussffc4fdb2010-08-26 14:53:51 +020053 .cpu_dai_name = "au1xpsc_ac97.1",
54 .platform_name = "au1xpsc-pcm.1",
55 .codec_name = "ac97-codec.1",
Manuel Lauss05ae3232009-11-02 21:21:44 +010056};
57
58static struct snd_soc_card db1200_ac97_machine = {
59 .name = "DB1200_AC97",
Axel Lin662d4e5c2011-12-23 09:53:55 +080060 .owner = THIS_MODULE,
Manuel Lauss05ae3232009-11-02 21:21:44 +010061 .dai_link = &db1200_ac97_dai,
62 .num_links = 1,
Manuel Lauss05ae3232009-11-02 21:21:44 +010063};
64
Manuel Lauss64cd04d2011-11-10 12:03:26 +000065static struct snd_soc_dai_link db1300_ac97_dai = {
66 .name = "AC97",
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",
72};
73
74static struct snd_soc_card db1300_ac97_machine = {
75 .name = "DB1300_AC97",
Wei Yongjun35261ed2013-07-02 17:19:25 +080076 .owner = THIS_MODULE,
Manuel Lauss64cd04d2011-11-10 12:03:26 +000077 .dai_link = &db1300_ac97_dai,
78 .num_links = 1,
79};
80
Manuel Laussf869d422011-11-10 12:06:16 +000081static struct snd_soc_card db1550_ac97_machine = {
82 .name = "DB1550_AC97",
Wei Yongjun35261ed2013-07-02 17:19:25 +080083 .owner = THIS_MODULE,
Manuel Laussf869d422011-11-10 12:06:16 +000084 .dai_link = &db1200_ac97_dai,
85 .num_links = 1,
86};
87
Manuel Lauss05ae3232009-11-02 21:21:44 +010088/*------------------------- I2S PART ---------------------------*/
89
90static int db1200_i2s_startup(struct snd_pcm_substream *substream)
91{
92 struct snd_soc_pcm_runtime *rtd = substream->private_data;
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +000093 struct snd_soc_dai *codec_dai = rtd->codec_dai;
Manuel Lauss05ae3232009-11-02 21:21:44 +010094
95 /* WM8731 has its own 12MHz crystal */
Mark Brown9745e822010-08-17 23:40:24 +010096 snd_soc_dai_set_sysclk(codec_dai, WM8731_SYSCLK_XTAL,
Manuel Lauss05ae3232009-11-02 21:21:44 +010097 12000000, SND_SOC_CLOCK_IN);
98
Lars-Peter Clausenb4508d02015-01-01 17:16:11 +010099 return 0;
Manuel Lauss05ae3232009-11-02 21:21:44 +0100100}
101
102static struct snd_soc_ops db1200_i2s_wm8731_ops = {
103 .startup = db1200_i2s_startup,
104};
105
106static struct snd_soc_dai_link db1200_i2s_dai = {
107 .name = "WM8731",
108 .stream_name = "WM8731 PCM",
Manuel Laussffc4fdb2010-08-26 14:53:51 +0200109 .codec_dai_name = "wm8731-hifi",
110 .cpu_dai_name = "au1xpsc_i2s.1",
111 .platform_name = "au1xpsc-pcm.1",
Mark Brown99b59f32011-03-27 14:35:15 +0100112 .codec_name = "wm8731.0-001b",
Lars-Peter Clausenb4508d02015-01-01 17:16:11 +0100113 .dai_fmt = SND_SOC_DAIFMT_LEFT_J | SND_SOC_DAIFMT_NB_NF |
114 SND_SOC_DAIFMT_CBM_CFM,
Manuel Lauss05ae3232009-11-02 21:21:44 +0100115 .ops = &db1200_i2s_wm8731_ops,
116};
117
118static struct snd_soc_card db1200_i2s_machine = {
119 .name = "DB1200_I2S",
Axel Lin662d4e5c2011-12-23 09:53:55 +0800120 .owner = THIS_MODULE,
Manuel Lauss05ae3232009-11-02 21:21:44 +0100121 .dai_link = &db1200_i2s_dai,
122 .num_links = 1,
Manuel Lauss05ae3232009-11-02 21:21:44 +0100123};
124
Manuel Lauss64cd04d2011-11-10 12:03:26 +0000125static struct snd_soc_dai_link db1300_i2s_dai = {
126 .name = "WM8731",
127 .stream_name = "WM8731 PCM",
128 .codec_dai_name = "wm8731-hifi",
129 .cpu_dai_name = "au1xpsc_i2s.2",
130 .platform_name = "au1xpsc-pcm.2",
131 .codec_name = "wm8731.0-001b",
132 .ops = &db1200_i2s_wm8731_ops,
133};
134
135static struct snd_soc_card db1300_i2s_machine = {
136 .name = "DB1300_I2S",
Wei Yongjun35261ed2013-07-02 17:19:25 +0800137 .owner = THIS_MODULE,
Manuel Lauss64cd04d2011-11-10 12:03:26 +0000138 .dai_link = &db1300_i2s_dai,
139 .num_links = 1,
140};
141
Manuel Laussf869d422011-11-10 12:06:16 +0000142static struct snd_soc_dai_link db1550_i2s_dai = {
143 .name = "WM8731",
144 .stream_name = "WM8731 PCM",
145 .codec_dai_name = "wm8731-hifi",
146 .cpu_dai_name = "au1xpsc_i2s.3",
147 .platform_name = "au1xpsc-pcm.3",
148 .codec_name = "wm8731.0-001b",
149 .ops = &db1200_i2s_wm8731_ops,
150};
151
152static struct snd_soc_card db1550_i2s_machine = {
153 .name = "DB1550_I2S",
Wei Yongjun35261ed2013-07-02 17:19:25 +0800154 .owner = THIS_MODULE,
Manuel Laussf869d422011-11-10 12:06:16 +0000155 .dai_link = &db1550_i2s_dai,
156 .num_links = 1,
157};
158
Manuel Lauss05ae3232009-11-02 21:21:44 +0100159/*------------------------- COMMON PART ---------------------------*/
160
Bill Pemberton5c658be2012-12-07 09:26:22 -0500161static struct snd_soc_card *db1200_cards[] = {
Manuel Laussadbc7a52011-07-25 13:45:03 +0200162 &db1200_ac97_machine,
163 &db1200_i2s_machine,
Manuel Lauss64cd04d2011-11-10 12:03:26 +0000164 &db1300_ac97_machine,
165 &db1300_i2s_machine,
Manuel Laussf869d422011-11-10 12:06:16 +0000166 &db1550_ac97_machine,
167 &db1550_i2s_machine,
Manuel Laussadbc7a52011-07-25 13:45:03 +0200168};
169
Bill Pemberton5c658be2012-12-07 09:26:22 -0500170static int db1200_audio_probe(struct platform_device *pdev)
Manuel Laussadbc7a52011-07-25 13:45:03 +0200171{
172 const struct platform_device_id *pid = platform_get_device_id(pdev);
173 struct snd_soc_card *card;
174
175 card = db1200_cards[pid->driver_data];
176 card->dev = &pdev->dev;
177 return snd_soc_register_card(card);
178}
179
Bill Pemberton5c658be2012-12-07 09:26:22 -0500180static int db1200_audio_remove(struct platform_device *pdev)
Manuel Laussadbc7a52011-07-25 13:45:03 +0200181{
182 struct snd_soc_card *card = platform_get_drvdata(pdev);
183 snd_soc_unregister_card(card);
184 return 0;
185}
186
187static struct platform_driver db1200_audio_driver = {
188 .driver = {
189 .name = "db1200-ac97",
Manuel Laussadbc7a52011-07-25 13:45:03 +0200190 .pm = &snd_soc_pm_ops,
191 },
192 .id_table = db1200_pids,
193 .probe = db1200_audio_probe,
Bill Pemberton5c658be2012-12-07 09:26:22 -0500194 .remove = db1200_audio_remove,
Manuel Laussadbc7a52011-07-25 13:45:03 +0200195};
Manuel Lauss05ae3232009-11-02 21:21:44 +0100196
Axel Lin8a124f92011-11-25 10:06:59 +0800197module_platform_driver(db1200_audio_driver);
Manuel Lauss05ae3232009-11-02 21:21:44 +0100198
199MODULE_LICENSE("GPL");
Manuel Laussf869d422011-11-10 12:06:16 +0000200MODULE_DESCRIPTION("DB1200/DB1300/DB1550 ASoC audio support");
Manuel Lauss05ae3232009-11-02 21:21:44 +0100201MODULE_AUTHOR("Manuel Lauss");