ASoC: davinci-mcasp: Remove last reference to num-serializer in DT doc
[deliverable/linux.git] / sound / soc / davinci / davinci-evm.c
CommitLineData
310355c1
VB
1/*
2 * ASoC driver for TI DAVINCI EVM platform
3 *
d6b52039 4 * Author: Vladimir Barinov, <vbarinov@embeddedalley.com>
310355c1
VB
5 * Copyright: (C) 2007 MontaVista Software, Inc., <source@mvista.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 */
11
12#include <linux/module.h>
13#include <linux/moduleparam.h>
14#include <linux/timer.h>
15#include <linux/interrupt.h>
16#include <linux/platform_device.h>
3ad7a42d 17#include <linux/platform_data/edma.h>
aa6b904e 18#include <linux/i2c.h>
310355c1
VB
19#include <sound/core.h>
20#include <sound/pcm.h>
21#include <sound/soc.h>
310355c1 22
310355c1 23#include <asm/dma.h>
f492ec9f
DB
24#include <asm/mach-types.h>
25
310355c1
VB
26#include "davinci-pcm.h"
27#include "davinci-i2s.h"
04f80f5c 28#include "davinci-mcasp.h"
310355c1 29
bcf25567
JS
30struct snd_soc_card_drvdata_davinci {
31 unsigned sysclk;
32};
33
d6f83396
TK
34#define AUDIO_FORMAT (SND_SOC_DAIFMT_DSP_B | \
35 SND_SOC_DAIFMT_CBM_CFM | SND_SOC_DAIFMT_IB_NF)
310355c1
VB
36static int evm_hw_params(struct snd_pcm_substream *substream,
37 struct snd_pcm_hw_params *params)
38{
39 struct snd_soc_pcm_runtime *rtd = substream->private_data;
f0fba2ad
LG
40 struct snd_soc_dai *codec_dai = rtd->codec_dai;
41 struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
bcf25567
JS
42 struct snd_soc_codec *codec = rtd->codec;
43 struct snd_soc_card *soc_card = codec->card;
310355c1 44 int ret = 0;
bcf25567
JS
45 unsigned sysclk = ((struct snd_soc_card_drvdata_davinci *)
46 snd_soc_card_get_drvdata(soc_card))->sysclk;
310355c1
VB
47
48 /* set codec DAI configuration */
9e031624 49 ret = snd_soc_dai_set_fmt(codec_dai, AUDIO_FORMAT);
310355c1
VB
50 if (ret < 0)
51 return ret;
52
53 /* set cpu DAI configuration */
9e031624 54 ret = snd_soc_dai_set_fmt(cpu_dai, AUDIO_FORMAT);
310355c1
VB
55 if (ret < 0)
56 return ret;
57
58 /* set the codec system clock */
05d5e991 59 ret = snd_soc_dai_set_sysclk(codec_dai, 0, sysclk, SND_SOC_CLOCK_OUT);
310355c1
VB
60 if (ret < 0)
61 return ret;
62
5b66aa2d
DM
63 /* set the CPU system clock */
64 ret = snd_soc_dai_set_sysclk(cpu_dai, 0, sysclk, SND_SOC_CLOCK_OUT);
65 if (ret < 0)
66 return ret;
67
310355c1
VB
68 return 0;
69}
70
8d43d1bc
C
71static int evm_spdif_hw_params(struct snd_pcm_substream *substream,
72 struct snd_pcm_hw_params *params)
73{
74 struct snd_soc_pcm_runtime *rtd = substream->private_data;
f0fba2ad 75 struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
8d43d1bc
C
76
77 /* set cpu DAI configuration */
78 return snd_soc_dai_set_fmt(cpu_dai, AUDIO_FORMAT);
79}
80
310355c1
VB
81static struct snd_soc_ops evm_ops = {
82 .hw_params = evm_hw_params,
83};
84
8d43d1bc
C
85static struct snd_soc_ops evm_spdif_ops = {
86 .hw_params = evm_spdif_hw_params,
87};
88
310355c1
VB
89/* davinci-evm machine dapm widgets */
90static const struct snd_soc_dapm_widget aic3x_dapm_widgets[] = {
91 SND_SOC_DAPM_HP("Headphone Jack", NULL),
92 SND_SOC_DAPM_LINE("Line Out", NULL),
93 SND_SOC_DAPM_MIC("Mic Jack", NULL),
94 SND_SOC_DAPM_LINE("Line In", NULL),
95};
96
97/* davinci-evm machine audio_mapnections to the codec pins */
acf497f9 98static const struct snd_soc_dapm_route audio_map[] = {
310355c1
VB
99 /* Headphone connected to HPLOUT, HPROUT */
100 {"Headphone Jack", NULL, "HPLOUT"},
101 {"Headphone Jack", NULL, "HPROUT"},
102
103 /* Line Out connected to LLOUT, RLOUT */
104 {"Line Out", NULL, "LLOUT"},
105 {"Line Out", NULL, "RLOUT"},
106
107 /* Mic connected to (MIC3L | MIC3R) */
e2e8bfdf
HG
108 {"MIC3L", NULL, "Mic Bias"},
109 {"MIC3R", NULL, "Mic Bias"},
110 {"Mic Bias", NULL, "Mic Jack"},
310355c1
VB
111
112 /* Line In connected to (LINE1L | LINE2L), (LINE1R | LINE2R) */
113 {"LINE1L", NULL, "Line In"},
114 {"LINE2L", NULL, "Line In"},
115 {"LINE1R", NULL, "Line In"},
116 {"LINE2R", NULL, "Line In"},
310355c1
VB
117};
118
119/* Logic for a aic3x as connected on a davinci-evm */
f0fba2ad 120static int evm_aic3x_init(struct snd_soc_pcm_runtime *rtd)
310355c1 121{
f0fba2ad 122 struct snd_soc_codec *codec = rtd->codec;
ce6120cc 123 struct snd_soc_dapm_context *dapm = &codec->dapm;
f0fba2ad 124
310355c1 125 /* Add davinci-evm specific widgets */
ce6120cc 126 snd_soc_dapm_new_controls(dapm, aic3x_dapm_widgets,
acf497f9 127 ARRAY_SIZE(aic3x_dapm_widgets));
310355c1
VB
128
129 /* Set up davinci-evm specific audio path audio_map */
ce6120cc 130 snd_soc_dapm_add_routes(dapm, audio_map, ARRAY_SIZE(audio_map));
310355c1
VB
131
132 /* not connected */
ce6120cc
LG
133 snd_soc_dapm_disable_pin(dapm, "MONO_LOUT");
134 snd_soc_dapm_disable_pin(dapm, "HPLCOM");
135 snd_soc_dapm_disable_pin(dapm, "HPRCOM");
310355c1
VB
136
137 /* always connected */
ce6120cc
LG
138 snd_soc_dapm_enable_pin(dapm, "Headphone Jack");
139 snd_soc_dapm_enable_pin(dapm, "Line Out");
140 snd_soc_dapm_enable_pin(dapm, "Mic Jack");
141 snd_soc_dapm_enable_pin(dapm, "Line In");
310355c1 142
310355c1
VB
143 return 0;
144}
145
146/* davinci-evm digital audio interface glue - connects codec <--> CPU */
bedad0ca 147static struct snd_soc_dai_link dm6446_evm_dai = {
310355c1
VB
148 .name = "TLV320AIC3X",
149 .stream_name = "AIC3X",
bedad0ca 150 .cpu_dai_name = "davinci-mcbsp",
f0fba2ad 151 .codec_dai_name = "tlv320aic3x-hifi",
bedad0ca 152 .codec_name = "tlv320aic3x-codec.1-001b",
f08095a4 153 .platform_name = "davinci-mcbsp",
bedad0ca
CPE
154 .init = evm_aic3x_init,
155 .ops = &evm_ops,
156};
157
158static struct snd_soc_dai_link dm355_evm_dai = {
159 .name = "TLV320AIC3X",
160 .stream_name = "AIC3X",
161 .cpu_dai_name = "davinci-mcbsp.1",
162 .codec_dai_name = "tlv320aic3x-hifi",
163 .codec_name = "tlv320aic3x-codec.1-001b",
f08095a4 164 .platform_name = "davinci-mcbsp.1",
310355c1
VB
165 .init = evm_aic3x_init,
166 .ops = &evm_ops,
167};
168
aa9b88ee
MA
169static struct snd_soc_dai_link dm365_evm_dai = {
170#ifdef CONFIG_SND_DM365_AIC3X_CODEC
171 .name = "TLV320AIC3X",
172 .stream_name = "AIC3X",
bedad0ca 173 .cpu_dai_name = "davinci-mcbsp",
f0fba2ad 174 .codec_dai_name = "tlv320aic3x-hifi",
aa9b88ee 175 .init = evm_aic3x_init,
bedad0ca 176 .codec_name = "tlv320aic3x-codec.1-0018",
aa9b88ee 177 .ops = &evm_ops,
f08095a4 178 .platform_name = "davinci-mcbsp",
aa9b88ee
MA
179#elif defined(CONFIG_SND_DM365_VOICE_CODEC)
180 .name = "Voice Codec - CQ93VC",
181 .stream_name = "CQ93",
f0fba2ad
LG
182 .cpu_dai_name = "davinci-vcif",
183 .codec_dai_name = "cq93vc-hifi",
184 .codec_name = "cq93vc-codec",
ffb690d5 185 .platform_name = "davinci-vcif",
aa9b88ee
MA
186#endif
187};
188
04f80f5c
C
189static struct snd_soc_dai_link dm6467_evm_dai[] = {
190 {
191 .name = "TLV320AIC3X",
192 .stream_name = "AIC3X",
f0fba2ad
LG
193 .cpu_dai_name= "davinci-mcasp.0",
194 .codec_dai_name = "tlv320aic3x-hifi",
f08095a4 195 .platform_name = "davinci-mcasp.0",
f0fba2ad 196 .codec_name = "tlv320aic3x-codec.0-001a",
04f80f5c
C
197 .init = evm_aic3x_init,
198 .ops = &evm_ops,
199 },
200 {
201 .name = "McASP",
202 .stream_name = "spdif",
f0fba2ad
LG
203 .cpu_dai_name= "davinci-mcasp.1",
204 .codec_dai_name = "dit-hifi",
205 .codec_name = "spdif_dit",
f08095a4 206 .platform_name = "davinci-mcasp.1",
8d43d1bc 207 .ops = &evm_spdif_ops,
04f80f5c
C
208 },
209};
f9eb9dd1
VB
210
211static struct snd_soc_dai_link da830_evm_dai = {
212 .name = "TLV320AIC3X",
213 .stream_name = "AIC3X",
214 .cpu_dai_name = "davinci-mcasp.1",
215 .codec_dai_name = "tlv320aic3x-hifi",
216 .codec_name = "tlv320aic3x-codec.1-0018",
f08095a4 217 .platform_name = "davinci-mcasp.1",
f9eb9dd1
VB
218 .init = evm_aic3x_init,
219 .ops = &evm_ops,
220};
221
222static struct snd_soc_dai_link da850_evm_dai = {
7ae5945f
C
223 .name = "TLV320AIC3X",
224 .stream_name = "AIC3X",
f0fba2ad
LG
225 .cpu_dai_name= "davinci-mcasp.0",
226 .codec_dai_name = "tlv320aic3x-hifi",
dc5a460a 227 .codec_name = "tlv320aic3x-codec.1-0018",
f08095a4 228 .platform_name = "davinci-mcasp.0",
7ae5945f
C
229 .init = evm_aic3x_init,
230 .ops = &evm_ops,
231};
04f80f5c 232
bedad0ca 233/* davinci dm6446 evm audio machine driver */
bcf25567
JS
234/*
235 * ASP0 in DM6446 EVM is clocked by U55, as configured by
236 * board-dm644x-evm.c using GPIOs from U18. There are six
237 * options; here we "know" we use a 48 KHz sample rate.
238 */
239static struct snd_soc_card_drvdata_davinci dm6446_snd_soc_card_drvdata = {
240 .sysclk = 12288000,
241};
242
bedad0ca
CPE
243static struct snd_soc_card dm6446_snd_soc_card_evm = {
244 .name = "DaVinci DM6446 EVM",
36a16d1a 245 .owner = THIS_MODULE,
bedad0ca
CPE
246 .dai_link = &dm6446_evm_dai,
247 .num_links = 1,
bcf25567 248 .drvdata = &dm6446_snd_soc_card_drvdata,
bedad0ca
CPE
249};
250
251/* davinci dm355 evm audio machine driver */
bcf25567
JS
252/* ASP1 on DM355 EVM is clocked by an external oscillator */
253static struct snd_soc_card_drvdata_davinci dm355_snd_soc_card_drvdata = {
254 .sysclk = 27000000,
255};
256
bedad0ca
CPE
257static struct snd_soc_card dm355_snd_soc_card_evm = {
258 .name = "DaVinci DM355 EVM",
36a16d1a 259 .owner = THIS_MODULE,
bedad0ca 260 .dai_link = &dm355_evm_dai,
310355c1 261 .num_links = 1,
bcf25567 262 .drvdata = &dm355_snd_soc_card_drvdata,
310355c1
VB
263};
264
aa9b88ee 265/* davinci dm365 evm audio machine driver */
bcf25567
JS
266static struct snd_soc_card_drvdata_davinci dm365_snd_soc_card_drvdata = {
267 .sysclk = 27000000,
268};
269
aa9b88ee
MA
270static struct snd_soc_card dm365_snd_soc_card_evm = {
271 .name = "DaVinci DM365 EVM",
36a16d1a 272 .owner = THIS_MODULE,
aa9b88ee
MA
273 .dai_link = &dm365_evm_dai,
274 .num_links = 1,
bcf25567 275 .drvdata = &dm365_snd_soc_card_drvdata,
aa9b88ee
MA
276};
277
04f80f5c 278/* davinci dm6467 evm audio machine driver */
bcf25567
JS
279static struct snd_soc_card_drvdata_davinci dm6467_snd_soc_card_drvdata = {
280 .sysclk = 27000000,
281};
282
04f80f5c
C
283static struct snd_soc_card dm6467_snd_soc_card_evm = {
284 .name = "DaVinci DM6467 EVM",
36a16d1a 285 .owner = THIS_MODULE,
04f80f5c
C
286 .dai_link = dm6467_evm_dai,
287 .num_links = ARRAY_SIZE(dm6467_evm_dai),
bcf25567
JS
288 .drvdata = &dm6467_snd_soc_card_drvdata,
289};
290
291static struct snd_soc_card_drvdata_davinci da830_snd_soc_card_drvdata = {
292 .sysclk = 24576000,
04f80f5c
C
293};
294
7ae5945f 295static struct snd_soc_card da830_snd_soc_card = {
30230f4c 296 .name = "DA830/OMAP-L137 EVM",
36a16d1a 297 .owner = THIS_MODULE,
f9eb9dd1 298 .dai_link = &da830_evm_dai,
30230f4c 299 .num_links = 1,
bcf25567
JS
300 .drvdata = &da830_snd_soc_card_drvdata,
301};
302
303static struct snd_soc_card_drvdata_davinci da850_snd_soc_card_drvdata = {
304 .sysclk = 24576000,
30230f4c
C
305};
306
307static struct snd_soc_card da850_snd_soc_card = {
308 .name = "DA850/OMAP-L138 EVM",
36a16d1a 309 .owner = THIS_MODULE,
f9eb9dd1 310 .dai_link = &da850_evm_dai,
7ae5945f 311 .num_links = 1,
bcf25567 312 .drvdata = &da850_snd_soc_card_drvdata,
7ae5945f
C
313};
314
310355c1
VB
315static struct platform_device *evm_snd_device;
316
317static int __init evm_init(void)
318{
f0fba2ad 319 struct snd_soc_card *evm_snd_dev_data;
f492ec9f 320 int index;
310355c1
VB
321 int ret;
322
aa9b88ee 323 if (machine_is_davinci_evm()) {
bedad0ca 324 evm_snd_dev_data = &dm6446_snd_soc_card_evm;
f492ec9f
DB
325 index = 0;
326 } else if (machine_is_davinci_dm355_evm()) {
bedad0ca 327 evm_snd_dev_data = &dm355_snd_soc_card_evm;
f492ec9f 328 index = 1;
aa9b88ee 329 } else if (machine_is_davinci_dm365_evm()) {
f0fba2ad 330 evm_snd_dev_data = &dm365_snd_soc_card_evm;
aa9b88ee 331 index = 0;
04f80f5c 332 } else if (machine_is_davinci_dm6467_evm()) {
f0fba2ad 333 evm_snd_dev_data = &dm6467_snd_soc_card_evm;
04f80f5c 334 index = 0;
7ae5945f 335 } else if (machine_is_davinci_da830_evm()) {
f0fba2ad 336 evm_snd_dev_data = &da830_snd_soc_card;
7ae5945f 337 index = 1;
30230f4c 338 } else if (machine_is_davinci_da850_evm()) {
f0fba2ad 339 evm_snd_dev_data = &da850_snd_soc_card;
30230f4c 340 index = 0;
f492ec9f
DB
341 } else
342 return -EINVAL;
343
344 evm_snd_device = platform_device_alloc("soc-audio", index);
310355c1
VB
345 if (!evm_snd_device)
346 return -ENOMEM;
347
04f80f5c 348 platform_set_drvdata(evm_snd_device, evm_snd_dev_data);
310355c1
VB
349 ret = platform_device_add(evm_snd_device);
350 if (ret)
351 platform_device_put(evm_snd_device);
352
353 return ret;
354}
355
356static void __exit evm_exit(void)
357{
358 platform_device_unregister(evm_snd_device);
359}
360
361module_init(evm_init);
362module_exit(evm_exit);
363
364MODULE_AUTHOR("Vladimir Barinov");
365MODULE_DESCRIPTION("TI DAVINCI EVM ASoC driver");
366MODULE_LICENSE("GPL");
This page took 0.230648 seconds and 5 git commands to generate.