xref: /linux/sound/soc/au1x/db1200.c (revision b7019ac550eb3916f34d79db583e9b7ea2524afa)
1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3  * DB1200/DB1300/DB1550 ASoC audio fabric support code.
4  *
5  * (c) 2008-2011 Manuel Lauss <manuel.lauss@googlemail.com>
6  *
7  */
8 
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>
21 
22 #include "../codecs/wm8731.h"
23 #include "psc.h"
24 
25 static const struct platform_device_id db1200_pids[] = {
26 	{
27 		.name		= "db1200-ac97",
28 		.driver_data	= 0,
29 	}, {
30 		.name		= "db1200-i2s",
31 		.driver_data	= 1,
32 	}, {
33 		.name		= "db1300-ac97",
34 		.driver_data	= 2,
35 	}, {
36 		.name		= "db1300-i2s",
37 		.driver_data	= 3,
38 	}, {
39 		.name		= "db1550-ac97",
40 		.driver_data	= 4,
41 	}, {
42 		.name		= "db1550-i2s",
43 		.driver_data	= 5,
44 	},
45 	{},
46 };
47 
48 /*-------------------------  AC97 PART  ---------------------------*/
49 
50 static struct snd_soc_dai_link db1200_ac97_dai = {
51 	.name		= "AC97",
52 	.stream_name	= "AC97 HiFi",
53 	.codec_dai_name	= "ac97-hifi",
54 	.cpu_dai_name	= "au1xpsc_ac97.1",
55 	.platform_name	= "au1xpsc-pcm.1",
56 	.codec_name	= "ac97-codec.1",
57 };
58 
59 static struct snd_soc_card db1200_ac97_machine = {
60 	.name		= "DB1200_AC97",
61 	.owner		= THIS_MODULE,
62 	.dai_link	= &db1200_ac97_dai,
63 	.num_links	= 1,
64 };
65 
66 static struct snd_soc_dai_link db1300_ac97_dai = {
67 	.name		= "AC97",
68 	.stream_name	= "AC97 HiFi",
69 	.codec_dai_name	= "wm9712-hifi",
70 	.cpu_dai_name	= "au1xpsc_ac97.1",
71 	.platform_name	= "au1xpsc-pcm.1",
72 	.codec_name	= "wm9712-codec.1",
73 };
74 
75 static struct snd_soc_card db1300_ac97_machine = {
76 	.name		= "DB1300_AC97",
77 	.owner		= THIS_MODULE,
78 	.dai_link	= &db1300_ac97_dai,
79 	.num_links	= 1,
80 };
81 
82 static struct snd_soc_card db1550_ac97_machine = {
83 	.name		= "DB1550_AC97",
84 	.owner		= THIS_MODULE,
85 	.dai_link	= &db1200_ac97_dai,
86 	.num_links	= 1,
87 };
88 
89 /*-------------------------  I2S PART  ---------------------------*/
90 
91 static int db1200_i2s_startup(struct snd_pcm_substream *substream)
92 {
93 	struct snd_soc_pcm_runtime *rtd = substream->private_data;
94 	struct snd_soc_dai *codec_dai = rtd->codec_dai;
95 
96 	/* WM8731 has its own 12MHz crystal */
97 	snd_soc_dai_set_sysclk(codec_dai, WM8731_SYSCLK_XTAL,
98 				12000000, SND_SOC_CLOCK_IN);
99 
100 	return 0;
101 }
102 
103 static const struct snd_soc_ops db1200_i2s_wm8731_ops = {
104 	.startup	= db1200_i2s_startup,
105 };
106 
107 static struct snd_soc_dai_link db1200_i2s_dai = {
108 	.name		= "WM8731",
109 	.stream_name	= "WM8731 PCM",
110 	.codec_dai_name	= "wm8731-hifi",
111 	.cpu_dai_name	= "au1xpsc_i2s.1",
112 	.platform_name	= "au1xpsc-pcm.1",
113 	.codec_name	= "wm8731.0-001b",
114 	.dai_fmt	= SND_SOC_DAIFMT_LEFT_J | SND_SOC_DAIFMT_NB_NF |
115 			  SND_SOC_DAIFMT_CBM_CFM,
116 	.ops		= &db1200_i2s_wm8731_ops,
117 };
118 
119 static struct snd_soc_card db1200_i2s_machine = {
120 	.name		= "DB1200_I2S",
121 	.owner		= THIS_MODULE,
122 	.dai_link	= &db1200_i2s_dai,
123 	.num_links	= 1,
124 };
125 
126 static struct snd_soc_dai_link db1300_i2s_dai = {
127 	.name		= "WM8731",
128 	.stream_name	= "WM8731 PCM",
129 	.codec_dai_name	= "wm8731-hifi",
130 	.cpu_dai_name	= "au1xpsc_i2s.2",
131 	.platform_name	= "au1xpsc-pcm.2",
132 	.codec_name	= "wm8731.0-001b",
133 	.dai_fmt	= SND_SOC_DAIFMT_LEFT_J | SND_SOC_DAIFMT_NB_NF |
134 			  SND_SOC_DAIFMT_CBM_CFM,
135 	.ops		= &db1200_i2s_wm8731_ops,
136 };
137 
138 static struct snd_soc_card db1300_i2s_machine = {
139 	.name		= "DB1300_I2S",
140 	.owner		= THIS_MODULE,
141 	.dai_link	= &db1300_i2s_dai,
142 	.num_links	= 1,
143 };
144 
145 static struct snd_soc_dai_link db1550_i2s_dai = {
146 	.name		= "WM8731",
147 	.stream_name	= "WM8731 PCM",
148 	.codec_dai_name	= "wm8731-hifi",
149 	.cpu_dai_name	= "au1xpsc_i2s.3",
150 	.platform_name	= "au1xpsc-pcm.3",
151 	.codec_name	= "wm8731.0-001b",
152 	.dai_fmt	= SND_SOC_DAIFMT_LEFT_J | SND_SOC_DAIFMT_NB_NF |
153 			  SND_SOC_DAIFMT_CBM_CFM,
154 	.ops		= &db1200_i2s_wm8731_ops,
155 };
156 
157 static struct snd_soc_card db1550_i2s_machine = {
158 	.name		= "DB1550_I2S",
159 	.owner		= THIS_MODULE,
160 	.dai_link	= &db1550_i2s_dai,
161 	.num_links	= 1,
162 };
163 
164 /*-------------------------  COMMON PART  ---------------------------*/
165 
166 static struct snd_soc_card *db1200_cards[] = {
167 	&db1200_ac97_machine,
168 	&db1200_i2s_machine,
169 	&db1300_ac97_machine,
170 	&db1300_i2s_machine,
171 	&db1550_ac97_machine,
172 	&db1550_i2s_machine,
173 };
174 
175 static int db1200_audio_probe(struct platform_device *pdev)
176 {
177 	const struct platform_device_id *pid = platform_get_device_id(pdev);
178 	struct snd_soc_card *card;
179 
180 	card = db1200_cards[pid->driver_data];
181 	card->dev = &pdev->dev;
182 	return devm_snd_soc_register_card(&pdev->dev, card);
183 }
184 
185 static struct platform_driver db1200_audio_driver = {
186 	.driver	= {
187 		.name	= "db1200-ac97",
188 		.pm	= &snd_soc_pm_ops,
189 	},
190 	.id_table	= db1200_pids,
191 	.probe		= db1200_audio_probe,
192 };
193 
194 module_platform_driver(db1200_audio_driver);
195 
196 MODULE_LICENSE("GPL");
197 MODULE_DESCRIPTION("DB1200/DB1300/DB1550 ASoC audio support");
198 MODULE_AUTHOR("Manuel Lauss");
199