1 // SPDX-License-Identifier: GPL-2.0-only
3 * DB1200/DB1300/DB1550 ASoC audio fabric support code.
5 * (c) 2008-2011 Manuel Lauss <manuel.lauss@googlemail.com>
9 #include <linux/module.h>
10 #include <linux/moduleparam.h>
11 #include <linux/timer.h>
12 #include <linux/interrupt.h>
13 #include <linux/platform_device.h>
14 #include <sound/core.h>
15 #include <sound/pcm.h>
16 #include <sound/soc.h>
17 #include <asm/mach-au1x00/au1000.h>
18 #include <asm/mach-au1x00/au1xxx_psc.h>
19 #include <asm/mach-au1x00/au1xxx_dbdma.h>
20 #include <asm/mach-db1x00/bcsr.h>
22 #include "../codecs/wm8731.h"
25 static const struct platform_device_id db1200_pids
[] = {
27 .name
= "db1200-ac97",
33 .name
= "db1300-ac97",
39 .name
= "db1550-ac97",
48 /*------------------------- AC97 PART ---------------------------*/
50 SND_SOC_DAILINK_DEFS(db1200_ac97
,
51 DAILINK_COMP_ARRAY(COMP_CPU("au1xpsc_ac97.1")),
52 DAILINK_COMP_ARRAY(COMP_CODEC("ac97-codec.1", "ac97-hifi")),
53 DAILINK_COMP_ARRAY(COMP_PLATFORM("au1xpsc-pcm.1")));
55 static struct snd_soc_dai_link db1200_ac97_dai
= {
57 .stream_name
= "AC97 HiFi",
58 SND_SOC_DAILINK_REG(db1200_ac97
),
61 static struct snd_soc_card db1200_ac97_machine
= {
62 .name
= "DB1200_AC97",
64 .dai_link
= &db1200_ac97_dai
,
68 SND_SOC_DAILINK_DEFS(db1300_ac97
,
69 DAILINK_COMP_ARRAY(COMP_CPU("au1xpsc_ac97.1")),
70 DAILINK_COMP_ARRAY(COMP_CODEC("wm9712-codec.1", "wm9712-hifi")),
71 DAILINK_COMP_ARRAY(COMP_PLATFORM("au1xpsc-pcm.1")));
73 static struct snd_soc_dai_link db1300_ac97_dai
= {
75 .stream_name
= "AC97 HiFi",
76 SND_SOC_DAILINK_REG(db1300_ac97
),
79 static struct snd_soc_card db1300_ac97_machine
= {
80 .name
= "DB1300_AC97",
82 .dai_link
= &db1300_ac97_dai
,
86 static struct snd_soc_card db1550_ac97_machine
= {
87 .name
= "DB1550_AC97",
89 .dai_link
= &db1200_ac97_dai
,
93 /*------------------------- I2S PART ---------------------------*/
95 static int db1200_i2s_startup(struct snd_pcm_substream
*substream
)
97 struct snd_soc_pcm_runtime
*rtd
= substream
->private_data
;
98 struct snd_soc_dai
*codec_dai
= rtd
->codec_dai
;
100 /* WM8731 has its own 12MHz crystal */
101 snd_soc_dai_set_sysclk(codec_dai
, WM8731_SYSCLK_XTAL
,
102 12000000, SND_SOC_CLOCK_IN
);
107 static const struct snd_soc_ops db1200_i2s_wm8731_ops
= {
108 .startup
= db1200_i2s_startup
,
111 SND_SOC_DAILINK_DEFS(db1200_i2s
,
112 DAILINK_COMP_ARRAY(COMP_CPU("au1xpsc_i2s.1")),
113 DAILINK_COMP_ARRAY(COMP_CODEC("wm8731.0-001b", "wm8731-hifi")),
114 DAILINK_COMP_ARRAY(COMP_PLATFORM("au1xpsc-pcm.1")));
116 static struct snd_soc_dai_link db1200_i2s_dai
= {
118 .stream_name
= "WM8731 PCM",
119 .dai_fmt
= SND_SOC_DAIFMT_LEFT_J
| SND_SOC_DAIFMT_NB_NF
|
120 SND_SOC_DAIFMT_CBM_CFM
,
121 .ops
= &db1200_i2s_wm8731_ops
,
122 SND_SOC_DAILINK_REG(db1200_i2s
),
125 static struct snd_soc_card db1200_i2s_machine
= {
126 .name
= "DB1200_I2S",
127 .owner
= THIS_MODULE
,
128 .dai_link
= &db1200_i2s_dai
,
132 SND_SOC_DAILINK_DEFS(db1300_i2s
,
133 DAILINK_COMP_ARRAY(COMP_CPU("au1xpsc_i2s.2")),
134 DAILINK_COMP_ARRAY(COMP_CODEC("wm8731.0-001b", "wm8731-hifi")),
135 DAILINK_COMP_ARRAY(COMP_PLATFORM("au1xpsc-pcm.2")));
137 static struct snd_soc_dai_link db1300_i2s_dai
= {
139 .stream_name
= "WM8731 PCM",
140 .dai_fmt
= SND_SOC_DAIFMT_LEFT_J
| SND_SOC_DAIFMT_NB_NF
|
141 SND_SOC_DAIFMT_CBM_CFM
,
142 .ops
= &db1200_i2s_wm8731_ops
,
143 SND_SOC_DAILINK_REG(db1300_i2s
),
146 static struct snd_soc_card db1300_i2s_machine
= {
147 .name
= "DB1300_I2S",
148 .owner
= THIS_MODULE
,
149 .dai_link
= &db1300_i2s_dai
,
153 SND_SOC_DAILINK_DEFS(db1550_i2s
,
154 DAILINK_COMP_ARRAY(COMP_CPU("au1xpsc_i2s.3")),
155 DAILINK_COMP_ARRAY(COMP_CODEC("wm8731.0-001b", "wm8731-hifi")),
156 DAILINK_COMP_ARRAY(COMP_PLATFORM("au1xpsc-pcm.3")));
158 static struct snd_soc_dai_link db1550_i2s_dai
= {
160 .stream_name
= "WM8731 PCM",
161 .dai_fmt
= SND_SOC_DAIFMT_LEFT_J
| SND_SOC_DAIFMT_NB_NF
|
162 SND_SOC_DAIFMT_CBM_CFM
,
163 .ops
= &db1200_i2s_wm8731_ops
,
164 SND_SOC_DAILINK_REG(db1550_i2s
),
167 static struct snd_soc_card db1550_i2s_machine
= {
168 .name
= "DB1550_I2S",
169 .owner
= THIS_MODULE
,
170 .dai_link
= &db1550_i2s_dai
,
174 /*------------------------- COMMON PART ---------------------------*/
176 static struct snd_soc_card
*db1200_cards
[] = {
177 &db1200_ac97_machine
,
179 &db1300_ac97_machine
,
181 &db1550_ac97_machine
,
185 static int db1200_audio_probe(struct platform_device
*pdev
)
187 const struct platform_device_id
*pid
= platform_get_device_id(pdev
);
188 struct snd_soc_card
*card
;
190 card
= db1200_cards
[pid
->driver_data
];
191 card
->dev
= &pdev
->dev
;
192 return devm_snd_soc_register_card(&pdev
->dev
, card
);
195 static struct platform_driver db1200_audio_driver
= {
197 .name
= "db1200-ac97",
198 .pm
= &snd_soc_pm_ops
,
200 .id_table
= db1200_pids
,
201 .probe
= db1200_audio_probe
,
204 module_platform_driver(db1200_audio_driver
);
206 MODULE_LICENSE("GPL");
207 MODULE_DESCRIPTION("DB1200/DB1300/DB1550 ASoC audio support");
208 MODULE_AUTHOR("Manuel Lauss");