Commit 1082e2703a2d91790f9349a6155913a8aa0d0b66
Committed by
Mark Brown
1 parent
b6f4bb383d
Exists in
master
and in
7 other branches
ASoC: NUC900/audio: add nuc900 audio driver support
Add support for NUC900 AC97 Signed-off-by: Wan ZongShun <mcuos.com@gmail.com> Acked-by: Liam Girdwood <lrg@slimlogic.co.uk> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Showing 8 changed files with 1036 additions and 0 deletions Side-by-side Diff
sound/soc/Kconfig
sound/soc/Makefile
sound/soc/nuc900/Kconfig
1 | +## | |
2 | +## NUC900 series AC97 API | |
3 | +## | |
4 | +config SND_SOC_NUC900 | |
5 | + tristate "SoC Audio for NUC900 series" | |
6 | + depends on ARCH_W90X900 | |
7 | + help | |
8 | + This option enables support for AC97 mode on the NUC900 SoC. | |
9 | + | |
10 | +config SND_SOC_NUC900_AC97 | |
11 | + tristate | |
12 | + select AC97_BUS | |
13 | + select SND_AC97_CODEC | |
14 | + select SND_SOC_AC97_BUS | |
15 | + | |
16 | + | |
17 | +## | |
18 | +## Boards | |
19 | +## | |
20 | +config SND_SOC_NUC900EVB | |
21 | + tristate "NUC900 AC97 support for demo board" | |
22 | + depends on SND_SOC_NUC900 | |
23 | + select SND_SOC_NUC900_AC97 | |
24 | + select SND_SOC_AC97_CODEC | |
25 | + help | |
26 | + Select this option to enable audio (AC97) on the | |
27 | + NUC900 demoboard. |
sound/soc/nuc900/Makefile
1 | +# NUC900 series audio | |
2 | +snd-soc-nuc900-pcm-objs := nuc900-pcm.o | |
3 | +snd-soc-nuc900-ac97-objs := nuc900-ac97.o | |
4 | + | |
5 | +obj-$(CONFIG_SND_SOC_NUC900) += snd-soc-nuc900-pcm.o | |
6 | +obj-$(CONFIG_SND_SOC_NUC900_AC97) += snd-soc-nuc900-ac97.o | |
7 | + | |
8 | +# Boards | |
9 | +snd-soc-nuc900-audio-objs := nuc900-audio.o | |
10 | + | |
11 | +obj-$(CONFIG_SND_SOC_NUC900EVB) += snd-soc-nuc900-audio.o |
sound/soc/nuc900/nuc900-ac97.c
1 | +/* | |
2 | + * Copyright (c) 2009-2010 Nuvoton technology corporation. | |
3 | + * | |
4 | + * Wan ZongShun <mcuos.com@gmail.com> | |
5 | + * | |
6 | + * This program is free software; you can redistribute it and/or modify | |
7 | + * it under the terms of the GNU General Public License as published by | |
8 | + * the Free Software Foundation;version 2 of the License. | |
9 | + * | |
10 | + */ | |
11 | + | |
12 | +#include <linux/init.h> | |
13 | +#include <linux/module.h> | |
14 | +#include <linux/slab.h> | |
15 | +#include <linux/device.h> | |
16 | +#include <linux/delay.h> | |
17 | +#include <linux/mutex.h> | |
18 | +#include <linux/suspend.h> | |
19 | +#include <sound/core.h> | |
20 | +#include <sound/pcm.h> | |
21 | +#include <sound/initval.h> | |
22 | +#include <sound/soc.h> | |
23 | +#include <linux/device.h> | |
24 | +#include <linux/clk.h> | |
25 | + | |
26 | +#include <mach/mfp.h> | |
27 | + | |
28 | +#include "nuc900-auido.h" | |
29 | + | |
30 | +static DEFINE_MUTEX(ac97_mutex); | |
31 | +struct nuc900_audio *nuc900_ac97_data; | |
32 | + | |
33 | +static int nuc900_checkready(void) | |
34 | +{ | |
35 | + struct nuc900_audio *nuc900_audio = nuc900_ac97_data; | |
36 | + | |
37 | + if (!(AUDIO_READ(nuc900_audio->mmio + ACTL_ACIS0) & CODEC_READY)) | |
38 | + return -EPERM; | |
39 | + | |
40 | + return 0; | |
41 | +} | |
42 | + | |
43 | +/* AC97 controller reads codec register */ | |
44 | +static unsigned short nuc900_ac97_read(struct snd_ac97 *ac97, | |
45 | + unsigned short reg) | |
46 | +{ | |
47 | + struct nuc900_audio *nuc900_audio = nuc900_ac97_data; | |
48 | + unsigned long timeout = 0x10000, val; | |
49 | + | |
50 | + mutex_lock(&ac97_mutex); | |
51 | + | |
52 | + val = nuc900_checkready(); | |
53 | + if (!!val) { | |
54 | + dev_err(nuc900_audio->dev, "AC97 codec is not ready\n"); | |
55 | + goto out; | |
56 | + } | |
57 | + | |
58 | + /* set the R_WB bit and write register index */ | |
59 | + AUDIO_WRITE(nuc900_audio->mmio + ACTL_ACOS1, R_WB | reg); | |
60 | + | |
61 | + /* set the valid frame bit and valid slots */ | |
62 | + val = AUDIO_READ(nuc900_audio->mmio + ACTL_ACOS0); | |
63 | + val |= (VALID_FRAME | SLOT1_VALID); | |
64 | + AUDIO_WRITE(nuc900_audio->mmio + ACTL_ACOS0, val); | |
65 | + | |
66 | + udelay(100); | |
67 | + | |
68 | + /* polling the AC_R_FINISH */ | |
69 | + val = AUDIO_READ(nuc900_audio->mmio + ACTL_ACCON); | |
70 | + val &= AC_R_FINISH; | |
71 | + while (!val && timeout--) | |
72 | + mdelay(1); | |
73 | + | |
74 | + if (!timeout) { | |
75 | + dev_err(nuc900_audio->dev, "AC97 read register time out !\n"); | |
76 | + val = -EPERM; | |
77 | + goto out; | |
78 | + } | |
79 | + | |
80 | + val = AUDIO_READ(nuc900_audio->mmio + ACTL_ACOS0) ; | |
81 | + val &= ~SLOT1_VALID; | |
82 | + AUDIO_WRITE(nuc900_audio->mmio + ACTL_ACOS0, val); | |
83 | + | |
84 | + if (AUDIO_READ(nuc900_audio->mmio + ACTL_ACIS1) >> 2 != reg) { | |
85 | + dev_err(nuc900_audio->dev, | |
86 | + "R_INDEX of REG_ACTL_ACIS1 not match!\n"); | |
87 | + } | |
88 | + | |
89 | + udelay(100); | |
90 | + val = (AUDIO_READ(nuc900_audio->mmio + ACTL_ACIS2) & 0xFFFF); | |
91 | + | |
92 | +out: | |
93 | + mutex_unlock(&ac97_mutex); | |
94 | + return val; | |
95 | +} | |
96 | + | |
97 | +/* AC97 controller writes to codec register */ | |
98 | +static void nuc900_ac97_write(struct snd_ac97 *ac97, unsigned short reg, | |
99 | + unsigned short val) | |
100 | +{ | |
101 | + struct nuc900_audio *nuc900_audio = nuc900_ac97_data; | |
102 | + unsigned long tmp, timeout = 0x10000; | |
103 | + | |
104 | + mutex_lock(&ac97_mutex); | |
105 | + | |
106 | + tmp = nuc900_checkready(); | |
107 | + if (!!tmp) | |
108 | + dev_err(nuc900_audio->dev, "AC97 codec is not ready\n"); | |
109 | + | |
110 | + /* clear the R_WB bit and write register index */ | |
111 | + AUDIO_WRITE(nuc900_audio->mmio + ACTL_ACOS1, reg); | |
112 | + | |
113 | + /* write register value */ | |
114 | + AUDIO_WRITE(nuc900_audio->mmio + ACTL_ACOS2, val); | |
115 | + | |
116 | + /* set the valid frame bit and valid slots */ | |
117 | + tmp = AUDIO_READ(nuc900_audio->mmio + ACTL_ACOS0); | |
118 | + tmp |= SLOT1_VALID | SLOT2_VALID | VALID_FRAME; | |
119 | + AUDIO_WRITE(nuc900_audio->mmio + ACTL_ACOS0, tmp); | |
120 | + | |
121 | + udelay(100); | |
122 | + | |
123 | + /* polling the AC_W_FINISH */ | |
124 | + tmp = AUDIO_READ(nuc900_audio->mmio + ACTL_ACCON); | |
125 | + tmp &= AC_W_FINISH; | |
126 | + while (tmp && timeout--) | |
127 | + mdelay(1); | |
128 | + | |
129 | + if (!timeout) | |
130 | + dev_err(nuc900_audio->dev, "AC97 write register time out !\n"); | |
131 | + | |
132 | + tmp = AUDIO_READ(nuc900_audio->mmio + ACTL_ACOS0); | |
133 | + tmp &= ~(SLOT1_VALID | SLOT2_VALID); | |
134 | + AUDIO_WRITE(nuc900_audio->mmio + ACTL_ACOS0, tmp); | |
135 | + | |
136 | + mutex_unlock(&ac97_mutex); | |
137 | + | |
138 | +} | |
139 | + | |
140 | +static void nuc900_ac97_warm_reset(struct snd_ac97 *ac97) | |
141 | +{ | |
142 | + struct nuc900_audio *nuc900_audio = nuc900_ac97_data; | |
143 | + unsigned long val; | |
144 | + | |
145 | + mutex_lock(&ac97_mutex); | |
146 | + | |
147 | + /* warm reset AC 97 */ | |
148 | + val = AUDIO_READ(nuc900_audio->mmio + ACTL_ACCON); | |
149 | + val |= AC_W_RES; | |
150 | + AUDIO_WRITE(nuc900_audio->mmio + ACTL_ACCON, val); | |
151 | + | |
152 | + udelay(1000); | |
153 | + | |
154 | + val = nuc900_checkready(); | |
155 | + if (!!val) | |
156 | + dev_err(nuc900_audio->dev, "AC97 codec is not ready\n"); | |
157 | + | |
158 | + mutex_unlock(&ac97_mutex); | |
159 | +} | |
160 | + | |
161 | +static void nuc900_ac97_cold_reset(struct snd_ac97 *ac97) | |
162 | +{ | |
163 | + struct nuc900_audio *nuc900_audio = nuc900_ac97_data; | |
164 | + unsigned long val; | |
165 | + | |
166 | + mutex_lock(&ac97_mutex); | |
167 | + | |
168 | + /* reset Audio Controller */ | |
169 | + val = AUDIO_READ(nuc900_audio->mmio + ACTL_RESET); | |
170 | + val |= ACTL_RESET_BIT; | |
171 | + AUDIO_WRITE(nuc900_audio->mmio + ACTL_RESET, val); | |
172 | + | |
173 | + udelay(1000); | |
174 | + | |
175 | + val = AUDIO_READ(nuc900_audio->mmio + ACTL_RESET); | |
176 | + val &= (~ACTL_RESET_BIT); | |
177 | + AUDIO_WRITE(nuc900_audio->mmio + ACTL_RESET, val); | |
178 | + | |
179 | + udelay(1000); | |
180 | + | |
181 | + /* reset AC-link interface */ | |
182 | + | |
183 | + val = AUDIO_READ(nuc900_audio->mmio + ACTL_RESET); | |
184 | + val |= AC_RESET; | |
185 | + AUDIO_WRITE(nuc900_audio->mmio + ACTL_RESET, val); | |
186 | + | |
187 | + udelay(1000); | |
188 | + | |
189 | + val = AUDIO_READ(nuc900_audio->mmio + ACTL_RESET); | |
190 | + val &= ~AC_RESET; | |
191 | + AUDIO_WRITE(nuc900_audio->mmio + ACTL_RESET, val); | |
192 | + | |
193 | + udelay(1000); | |
194 | + | |
195 | + /* cold reset AC 97 */ | |
196 | + val = AUDIO_READ(nuc900_audio->mmio + ACTL_ACCON); | |
197 | + val |= AC_C_RES; | |
198 | + AUDIO_WRITE(nuc900_audio->mmio + ACTL_ACCON, val); | |
199 | + | |
200 | + udelay(1000); | |
201 | + | |
202 | + val = AUDIO_READ(nuc900_audio->mmio + ACTL_ACCON); | |
203 | + val &= (~AC_C_RES); | |
204 | + AUDIO_WRITE(nuc900_audio->mmio + ACTL_ACCON, val); | |
205 | + | |
206 | + udelay(1000); | |
207 | + | |
208 | + mutex_unlock(&ac97_mutex); | |
209 | + | |
210 | +} | |
211 | + | |
212 | +/* AC97 controller operations */ | |
213 | +struct snd_ac97_bus_ops soc_ac97_ops = { | |
214 | + .read = nuc900_ac97_read, | |
215 | + .write = nuc900_ac97_write, | |
216 | + .reset = nuc900_ac97_cold_reset, | |
217 | + .warm_reset = nuc900_ac97_warm_reset, | |
218 | +} | |
219 | +EXPORT_SYMBOL_GPL(soc_ac97_ops); | |
220 | + | |
221 | +static int nuc900_ac97_trigger(struct snd_pcm_substream *substream, | |
222 | + int cmd, struct snd_soc_dai *dai) | |
223 | +{ | |
224 | + struct nuc900_audio *nuc900_audio = nuc900_ac97_data; | |
225 | + int ret, stype = SUBSTREAM_TYPE(substream); | |
226 | + unsigned long val, tmp; | |
227 | + | |
228 | + ret = 0; | |
229 | + | |
230 | + switch (cmd) { | |
231 | + case SNDRV_PCM_TRIGGER_START: | |
232 | + case SNDRV_PCM_TRIGGER_RESUME: | |
233 | + val = AUDIO_READ(nuc900_audio->mmio + ACTL_RESET); | |
234 | + if (PCM_TX == stype) { | |
235 | + tmp = AUDIO_READ(nuc900_audio->mmio + ACTL_ACOS0); | |
236 | + tmp |= (SLOT3_VALID | SLOT4_VALID | VALID_FRAME); | |
237 | + AUDIO_WRITE(nuc900_audio->mmio + ACTL_ACOS0, tmp); | |
238 | + | |
239 | + tmp = AUDIO_READ(nuc900_audio->mmio + ACTL_PSR); | |
240 | + tmp |= (P_DMA_END_IRQ | P_DMA_MIDDLE_IRQ); | |
241 | + AUDIO_WRITE(nuc900_audio->mmio + ACTL_PSR, tmp); | |
242 | + val |= AC_PLAY; | |
243 | + } else { | |
244 | + tmp = AUDIO_READ(nuc900_audio->mmio + ACTL_RSR); | |
245 | + tmp |= (R_DMA_END_IRQ | R_DMA_MIDDLE_IRQ); | |
246 | + | |
247 | + AUDIO_WRITE(nuc900_audio->mmio + ACTL_RSR, tmp); | |
248 | + val |= AC_RECORD; | |
249 | + } | |
250 | + | |
251 | + AUDIO_WRITE(nuc900_audio->mmio + ACTL_RESET, val); | |
252 | + | |
253 | + break; | |
254 | + case SNDRV_PCM_TRIGGER_STOP: | |
255 | + case SNDRV_PCM_TRIGGER_SUSPEND: | |
256 | + val = AUDIO_READ(nuc900_audio->mmio + ACTL_RESET); | |
257 | + if (PCM_TX == stype) { | |
258 | + tmp = AUDIO_READ(nuc900_audio->mmio + ACTL_ACOS0); | |
259 | + tmp &= ~(SLOT3_VALID | SLOT4_VALID); | |
260 | + AUDIO_WRITE(nuc900_audio->mmio + ACTL_ACOS0, tmp); | |
261 | + | |
262 | + AUDIO_WRITE(nuc900_audio->mmio + ACTL_PSR, RESET_PRSR); | |
263 | + val &= ~AC_PLAY; | |
264 | + } else { | |
265 | + AUDIO_WRITE(nuc900_audio->mmio + ACTL_RSR, RESET_PRSR); | |
266 | + val &= ~AC_RECORD; | |
267 | + } | |
268 | + | |
269 | + AUDIO_WRITE(nuc900_audio->mmio + ACTL_RESET, val); | |
270 | + | |
271 | + break; | |
272 | + default: | |
273 | + ret = -EINVAL; | |
274 | + } | |
275 | + | |
276 | + return ret; | |
277 | +} | |
278 | + | |
279 | +static int nuc900_ac97_probe(struct platform_device *pdev, | |
280 | + struct snd_soc_dai *dai) | |
281 | +{ | |
282 | + struct nuc900_audio *nuc900_audio = nuc900_ac97_data; | |
283 | + unsigned long val; | |
284 | + | |
285 | + mutex_lock(&ac97_mutex); | |
286 | + | |
287 | + /* enable unit clock */ | |
288 | + clk_enable(nuc900_audio->clk); | |
289 | + | |
290 | + /* enable audio controller and AC-link interface */ | |
291 | + val = AUDIO_READ(nuc900_audio->mmio + ACTL_CON); | |
292 | + val |= (IIS_AC_PIN_SEL | ACLINK_EN); | |
293 | + AUDIO_WRITE(nuc900_audio->mmio + ACTL_CON, val); | |
294 | + | |
295 | + mutex_unlock(&ac97_mutex); | |
296 | + | |
297 | + return 0; | |
298 | +} | |
299 | + | |
300 | +static void nuc900_ac97_remove(struct platform_device *pdev, | |
301 | + struct snd_soc_dai *dai) | |
302 | +{ | |
303 | + struct nuc900_audio *nuc900_audio = nuc900_ac97_data; | |
304 | + | |
305 | + clk_disable(nuc900_audio->clk); | |
306 | +} | |
307 | + | |
308 | +static struct snd_soc_dai_ops nuc900_ac97_dai_ops = { | |
309 | + .trigger = nuc900_ac97_trigger, | |
310 | +}; | |
311 | + | |
312 | +struct snd_soc_dai nuc900_ac97_dai = { | |
313 | + .name = "nuc900-ac97", | |
314 | + .probe = nuc900_ac97_probe, | |
315 | + .remove = nuc900_ac97_remove, | |
316 | + .ac97_control = 1, | |
317 | + .playback = { | |
318 | + .rates = SNDRV_PCM_RATE_8000_48000, | |
319 | + .formats = SNDRV_PCM_FMTBIT_S16_LE, | |
320 | + .channels_min = 1, | |
321 | + .channels_max = 2, | |
322 | + }, | |
323 | + .capture = { | |
324 | + .rates = SNDRV_PCM_RATE_8000_48000, | |
325 | + .formats = SNDRV_PCM_FMTBIT_S16_LE, | |
326 | + .channels_min = 1, | |
327 | + .channels_max = 2, | |
328 | + }, | |
329 | + .ops = &nuc900_ac97_dai_ops, | |
330 | +} | |
331 | +EXPORT_SYMBOL_GPL(nuc900_ac97_dai); | |
332 | + | |
333 | +static int __devinit nuc900_ac97_drvprobe(struct platform_device *pdev) | |
334 | +{ | |
335 | + struct nuc900_audio *nuc900_audio; | |
336 | + int ret; | |
337 | + | |
338 | + if (nuc900_ac97_data) | |
339 | + return -EBUSY; | |
340 | + | |
341 | + nuc900_audio = kzalloc(sizeof(struct nuc900_audio), GFP_KERNEL); | |
342 | + if (!nuc900_audio) | |
343 | + return -ENOMEM; | |
344 | + | |
345 | + spin_lock_init(&nuc900_audio->lock); | |
346 | + | |
347 | + nuc900_audio->res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | |
348 | + if (!nuc900_audio->res) { | |
349 | + ret = -ENODEV; | |
350 | + goto out0; | |
351 | + } | |
352 | + | |
353 | + if (!request_mem_region(nuc900_audio->res->start, | |
354 | + resource_size(nuc900_audio->res), pdev->name)) { | |
355 | + ret = -EBUSY; | |
356 | + goto out0; | |
357 | + } | |
358 | + | |
359 | + nuc900_audio->mmio = ioremap(nuc900_audio->res->start, | |
360 | + resource_size(nuc900_audio->res)); | |
361 | + if (!nuc900_audio->mmio) { | |
362 | + ret = -ENOMEM; | |
363 | + goto out1; | |
364 | + } | |
365 | + | |
366 | + nuc900_audio->clk = clk_get(&pdev->dev, NULL); | |
367 | + if (IS_ERR(nuc900_audio->clk)) { | |
368 | + ret = PTR_ERR(nuc900_audio->clk); | |
369 | + goto out2; | |
370 | + } | |
371 | + | |
372 | + nuc900_audio->irq_num = platform_get_irq(pdev, 0); | |
373 | + if (!nuc900_audio->irq_num) { | |
374 | + ret = -EBUSY; | |
375 | + goto out2; | |
376 | + } | |
377 | + | |
378 | + nuc900_ac97_data = nuc900_audio; | |
379 | + | |
380 | + nuc900_audio->dev = nuc900_ac97_dai.dev = &pdev->dev; | |
381 | + | |
382 | + ret = snd_soc_register_dai(&nuc900_ac97_dai); | |
383 | + if (ret) | |
384 | + goto out3; | |
385 | + | |
386 | + mfp_set_groupg(nuc900_audio->dev); /* enbale ac97 multifunction pin*/ | |
387 | + | |
388 | + return 0; | |
389 | + | |
390 | +out3: | |
391 | + clk_put(nuc900_audio->clk); | |
392 | +out2: | |
393 | + iounmap(nuc900_audio->mmio); | |
394 | +out1: | |
395 | + release_mem_region(nuc900_audio->res->start, | |
396 | + resource_size(nuc900_audio->res)); | |
397 | +out0: | |
398 | + kfree(nuc900_audio); | |
399 | + return ret; | |
400 | +} | |
401 | + | |
402 | +static int __devexit nuc900_ac97_drvremove(struct platform_device *pdev) | |
403 | +{ | |
404 | + | |
405 | + snd_soc_unregister_dai(&nuc900_ac97_dai); | |
406 | + | |
407 | + clk_put(nuc900_ac97_data->clk); | |
408 | + iounmap(nuc900_ac97_data->mmio); | |
409 | + release_mem_region(nuc900_ac97_data->res->start, | |
410 | + resource_size(nuc900_ac97_data->res)); | |
411 | + | |
412 | + nuc900_ac97_data = NULL; | |
413 | + | |
414 | + return 0; | |
415 | +} | |
416 | + | |
417 | +static struct platform_driver nuc900_ac97_driver = { | |
418 | + .driver = { | |
419 | + .name = "nuc900-audio", | |
420 | + .owner = THIS_MODULE, | |
421 | + }, | |
422 | + .probe = nuc900_ac97_drvprobe, | |
423 | + .remove = __devexit_p(nuc900_ac97_drvremove), | |
424 | +}; | |
425 | + | |
426 | +static int __init nuc900_ac97_init(void) | |
427 | +{ | |
428 | + return platform_driver_register(&nuc900_ac97_driver); | |
429 | +} | |
430 | + | |
431 | +static void __exit nuc900_ac97_exit(void) | |
432 | +{ | |
433 | + platform_driver_unregister(&nuc900_ac97_driver); | |
434 | +} | |
435 | + | |
436 | +module_init(nuc900_ac97_init); | |
437 | +module_exit(nuc900_ac97_exit); | |
438 | + | |
439 | +MODULE_AUTHOR("Wan ZongShun <mcuos.com@gmail.com>"); | |
440 | +MODULE_DESCRIPTION("NUC900 AC97 SoC driver!"); | |
441 | +MODULE_LICENSE("GPL"); | |
442 | +MODULE_ALIAS("platform:nuc900-ac97"); |
sound/soc/nuc900/nuc900-audio.c
1 | +/* | |
2 | + * Copyright (c) 2010 Nuvoton technology corporation. | |
3 | + * | |
4 | + * Wan ZongShun <mcuos.com@gmail.com> | |
5 | + * | |
6 | + * This program is free software; you can redistribute it and/or modify | |
7 | + * it under the terms of the GNU General Public License as published by | |
8 | + * the Free Software Foundation;version 2 of the License. | |
9 | + * | |
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> | |
17 | + | |
18 | +#include <sound/core.h> | |
19 | +#include <sound/pcm.h> | |
20 | +#include <sound/soc.h> | |
21 | +#include <sound/soc-dapm.h> | |
22 | + | |
23 | +#include "../codecs/ac97.h" | |
24 | +#include "nuc900-auido.h" | |
25 | + | |
26 | +static struct snd_soc_dai_link nuc900evb_ac97_dai = { | |
27 | + .name = "AC97", | |
28 | + .stream_name = "AC97 HiFi", | |
29 | + .cpu_dai = &nuc900_ac97_dai, | |
30 | + .codec_dai = &ac97_dai, | |
31 | +}; | |
32 | + | |
33 | +static struct snd_soc_card nuc900evb_audio_machine = { | |
34 | + .name = "NUC900EVB_AC97", | |
35 | + .dai_link = &nuc900evb_ac97_dai, | |
36 | + .num_links = 1, | |
37 | + .platform = &nuc900_soc_platform, | |
38 | +}; | |
39 | + | |
40 | +static struct snd_soc_device nuc900evb_ac97_devdata = { | |
41 | + .card = &nuc900evb_audio_machine, | |
42 | + .codec_dev = &soc_codec_dev_ac97, | |
43 | +}; | |
44 | + | |
45 | +static struct platform_device *nuc900evb_asoc_dev; | |
46 | + | |
47 | +static int __init nuc900evb_audio_init(void) | |
48 | +{ | |
49 | + int ret; | |
50 | + | |
51 | + ret = -ENOMEM; | |
52 | + nuc900evb_asoc_dev = platform_device_alloc("soc-audio", -1); | |
53 | + if (!nuc900evb_asoc_dev) | |
54 | + goto out; | |
55 | + | |
56 | + /* nuc900 board audio device */ | |
57 | + platform_set_drvdata(nuc900evb_asoc_dev, &nuc900evb_ac97_devdata); | |
58 | + | |
59 | + nuc900evb_ac97_devdata.dev = &nuc900evb_asoc_dev->dev; | |
60 | + ret = platform_device_add(nuc900evb_asoc_dev); | |
61 | + | |
62 | + if (ret) { | |
63 | + platform_device_put(nuc900evb_asoc_dev); | |
64 | + nuc900evb_asoc_dev = NULL; | |
65 | + } | |
66 | + | |
67 | +out: | |
68 | + return ret; | |
69 | +} | |
70 | + | |
71 | +static void __exit nuc900evb_audio_exit(void) | |
72 | +{ | |
73 | + platform_device_unregister(nuc900evb_asoc_dev); | |
74 | +} | |
75 | + | |
76 | +module_init(nuc900evb_audio_init); | |
77 | +module_exit(nuc900evb_audio_exit); | |
78 | + | |
79 | +MODULE_LICENSE("GPL"); | |
80 | +MODULE_DESCRIPTION("NUC900 Series ASoC audio support"); | |
81 | +MODULE_AUTHOR("Wan ZongShun"); |
sound/soc/nuc900/nuc900-auido.h
1 | +/* | |
2 | + * Copyright (c) 2010 Nuvoton technology corporation. | |
3 | + * | |
4 | + * Wan ZongShun <mcuos.com@gmail.com> | |
5 | + * | |
6 | + * This program is free software; you can redistribute it and/or modify | |
7 | + * it under the terms of the GNU General Public License as published by | |
8 | + * the Free Software Foundation;version 2 of the License. | |
9 | + * | |
10 | + */ | |
11 | + | |
12 | +#ifndef _NUC900_AUDIO_H | |
13 | +#define _NUC900_AUDIO_H | |
14 | + | |
15 | +#include <linux/io.h> | |
16 | + | |
17 | +/* Audio Control Registers */ | |
18 | +#define ACTL_CON 0x00 | |
19 | +#define ACTL_RESET 0x04 | |
20 | +#define ACTL_RDSTB 0x08 | |
21 | +#define ACTL_RDST_LENGTH 0x0C | |
22 | +#define ACTL_RDSTC 0x10 | |
23 | +#define ACTL_RSR 0x14 | |
24 | +#define ACTL_PDSTB 0x18 | |
25 | +#define ACTL_PDST_LENGTH 0x1C | |
26 | +#define ACTL_PDSTC 0x20 | |
27 | +#define ACTL_PSR 0x24 | |
28 | +#define ACTL_IISCON 0x28 | |
29 | +#define ACTL_ACCON 0x2C | |
30 | +#define ACTL_ACOS0 0x30 | |
31 | +#define ACTL_ACOS1 0x34 | |
32 | +#define ACTL_ACOS2 0x38 | |
33 | +#define ACTL_ACIS0 0x3C | |
34 | +#define ACTL_ACIS1 0x40 | |
35 | +#define ACTL_ACIS2 0x44 | |
36 | +#define ACTL_COUNTER 0x48 | |
37 | + | |
38 | +/* bit definition of REG_ACTL_CON register */ | |
39 | +#define R_DMA_IRQ 0x1000 | |
40 | +#define T_DMA_IRQ 0x0800 | |
41 | +#define IIS_AC_PIN_SEL 0x0100 | |
42 | +#define FIFO_TH 0x0080 | |
43 | +#define ADC_EN 0x0010 | |
44 | +#define M80_EN 0x0008 | |
45 | +#define ACLINK_EN 0x0004 | |
46 | +#define IIS_EN 0x0002 | |
47 | + | |
48 | +/* bit definition of REG_ACTL_RESET register */ | |
49 | +#define W5691_PLAY 0x20000 | |
50 | +#define ACTL_RESET_BIT 0x10000 | |
51 | +#define RECORD_RIGHT_CHNNEL 0x08000 | |
52 | +#define RECORD_LEFT_CHNNEL 0x04000 | |
53 | +#define PLAY_RIGHT_CHNNEL 0x02000 | |
54 | +#define PLAY_LEFT_CHNNEL 0x01000 | |
55 | +#define DAC_PLAY 0x00800 | |
56 | +#define ADC_RECORD 0x00400 | |
57 | +#define M80_PLAY 0x00200 | |
58 | +#define AC_RECORD 0x00100 | |
59 | +#define AC_PLAY 0x00080 | |
60 | +#define IIS_RECORD 0x00040 | |
61 | +#define IIS_PLAY 0x00020 | |
62 | +#define DAC_RESET 0x00010 | |
63 | +#define ADC_RESET 0x00008 | |
64 | +#define M80_RESET 0x00004 | |
65 | +#define AC_RESET 0x00002 | |
66 | +#define IIS_RESET 0x00001 | |
67 | + | |
68 | +/* bit definition of REG_ACTL_ACCON register */ | |
69 | +#define AC_BCLK_PU_EN 0x20 | |
70 | +#define AC_R_FINISH 0x10 | |
71 | +#define AC_W_FINISH 0x08 | |
72 | +#define AC_W_RES 0x04 | |
73 | +#define AC_C_RES 0x02 | |
74 | + | |
75 | +/* bit definition of ACTL_RSR register */ | |
76 | +#define R_FIFO_EMPTY 0x04 | |
77 | +#define R_DMA_END_IRQ 0x02 | |
78 | +#define R_DMA_MIDDLE_IRQ 0x01 | |
79 | + | |
80 | +/* bit definition of ACTL_PSR register */ | |
81 | +#define P_FIFO_EMPTY 0x04 | |
82 | +#define P_DMA_END_IRQ 0x02 | |
83 | +#define P_DMA_MIDDLE_IRQ 0x01 | |
84 | + | |
85 | +/* bit definition of ACTL_ACOS0 register */ | |
86 | +#define SLOT1_VALID 0x01 | |
87 | +#define SLOT2_VALID 0x02 | |
88 | +#define SLOT3_VALID 0x04 | |
89 | +#define SLOT4_VALID 0x08 | |
90 | +#define VALID_FRAME 0x10 | |
91 | + | |
92 | +/* bit definition of ACTL_ACOS1 register */ | |
93 | +#define R_WB 0x80 | |
94 | + | |
95 | +#define CODEC_READY 0x10 | |
96 | +#define RESET_PRSR 0x00 | |
97 | +#define AUDIO_WRITE(addr, val) __raw_writel(val, addr) | |
98 | +#define AUDIO_READ(addr) __raw_readl(addr) | |
99 | +#define PCM_TX 0 | |
100 | +#define PCM_RX 1 | |
101 | +#define SUBSTREAM_TYPE(substream) \ | |
102 | + ((substream)->stream == SNDRV_PCM_STREAM_PLAYBACK ? PCM_TX : PCM_RX) | |
103 | + | |
104 | +struct nuc900_audio { | |
105 | + void __iomem *mmio; | |
106 | + spinlock_t lock; | |
107 | + dma_addr_t dma_addr[2]; | |
108 | + unsigned long buffersize[2]; | |
109 | + unsigned long irq_num; | |
110 | + struct snd_pcm_substream *substream; | |
111 | + struct resource *res; | |
112 | + struct clk *clk; | |
113 | + struct device *dev; | |
114 | + | |
115 | +}; | |
116 | + | |
117 | +extern struct nuc900_audio *nuc900_ac97_data; | |
118 | +extern struct snd_soc_dai nuc900_ac97_dai; | |
119 | +extern struct snd_soc_platform nuc900_soc_platform; | |
120 | + | |
121 | +#endif /*end _NUC900_AUDIO_H */ |
sound/soc/nuc900/nuc900-pcm.c
1 | +/* | |
2 | + * Copyright (c) 2010 Nuvoton technology corporation. | |
3 | + * | |
4 | + * Wan ZongShun <mcuos.com@gmail.com> | |
5 | + * | |
6 | + * This program is free software; you can redistribute it and/or modify | |
7 | + * it under the terms of the GNU General Public License as published by | |
8 | + * the Free Software Foundation;version 2 of the License. | |
9 | + * | |
10 | + */ | |
11 | + | |
12 | +#include <linux/module.h> | |
13 | +#include <linux/init.h> | |
14 | +#include <linux/io.h> | |
15 | +#include <linux/platform_device.h> | |
16 | +#include <linux/slab.h> | |
17 | +#include <linux/dma-mapping.h> | |
18 | + | |
19 | +#include <sound/core.h> | |
20 | +#include <sound/pcm.h> | |
21 | +#include <sound/pcm_params.h> | |
22 | +#include <sound/soc.h> | |
23 | + | |
24 | +#include <mach/hardware.h> | |
25 | + | |
26 | +#include "nuc900-auido.h" | |
27 | + | |
28 | +static const struct snd_pcm_hardware nuc900_pcm_hardware = { | |
29 | + .info = SNDRV_PCM_INFO_INTERLEAVED | | |
30 | + SNDRV_PCM_INFO_BLOCK_TRANSFER | | |
31 | + SNDRV_PCM_INFO_MMAP | | |
32 | + SNDRV_PCM_INFO_MMAP_VALID | | |
33 | + SNDRV_PCM_INFO_PAUSE | | |
34 | + SNDRV_PCM_INFO_RESUME, | |
35 | + .formats = SNDRV_PCM_FMTBIT_S16_LE, | |
36 | + .channels_min = 1, | |
37 | + .channels_max = 2, | |
38 | + .buffer_bytes_max = 4*1024, | |
39 | + .period_bytes_min = 1*1024, | |
40 | + .period_bytes_max = 4*1024, | |
41 | + .periods_min = 1, | |
42 | + .periods_max = 1024, | |
43 | +}; | |
44 | + | |
45 | +static int nuc900_dma_hw_params(struct snd_pcm_substream *substream, | |
46 | + struct snd_pcm_hw_params *params) | |
47 | +{ | |
48 | + struct snd_pcm_runtime *runtime = substream->runtime; | |
49 | + struct nuc900_audio *nuc900_audio = runtime->private_data; | |
50 | + unsigned long flags, stype = SUBSTREAM_TYPE(substream); | |
51 | + int ret = 0; | |
52 | + | |
53 | + spin_lock_irqsave(&nuc900_audio->lock, flags); | |
54 | + | |
55 | + ret = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(params)); | |
56 | + if (ret < 0) | |
57 | + return ret; | |
58 | + | |
59 | + nuc900_audio->substream = substream; | |
60 | + nuc900_audio->dma_addr[stype] = runtime->dma_addr; | |
61 | + nuc900_audio->buffersize[stype] = params_buffer_bytes(params); | |
62 | + | |
63 | + spin_unlock_irqrestore(&nuc900_audio->lock, flags); | |
64 | + | |
65 | + return ret; | |
66 | +} | |
67 | + | |
68 | +static void nuc900_update_dma_register(struct snd_pcm_substream *substream, | |
69 | + dma_addr_t dma_addr, size_t count) | |
70 | +{ | |
71 | + struct snd_pcm_runtime *runtime = substream->runtime; | |
72 | + struct nuc900_audio *nuc900_audio = runtime->private_data; | |
73 | + void __iomem *mmio_addr, *mmio_len; | |
74 | + | |
75 | + if (SUBSTREAM_TYPE(substream) == PCM_TX) { | |
76 | + mmio_addr = nuc900_audio->mmio + ACTL_PDSTB; | |
77 | + mmio_len = nuc900_audio->mmio + ACTL_PDST_LENGTH; | |
78 | + } else { | |
79 | + mmio_addr = nuc900_audio->mmio + ACTL_RDSTB; | |
80 | + mmio_len = nuc900_audio->mmio + ACTL_RDST_LENGTH; | |
81 | + } | |
82 | + | |
83 | + AUDIO_WRITE(mmio_addr, dma_addr); | |
84 | + AUDIO_WRITE(mmio_len, count); | |
85 | +} | |
86 | + | |
87 | +static void nuc900_dma_start(struct snd_pcm_substream *substream) | |
88 | +{ | |
89 | + struct snd_pcm_runtime *runtime = substream->runtime; | |
90 | + struct nuc900_audio *nuc900_audio = runtime->private_data; | |
91 | + unsigned long val; | |
92 | + | |
93 | + val = AUDIO_READ(nuc900_audio->mmio + ACTL_CON); | |
94 | + val |= (T_DMA_IRQ | R_DMA_IRQ); | |
95 | + AUDIO_WRITE(nuc900_audio->mmio + ACTL_CON, val); | |
96 | +} | |
97 | + | |
98 | +static void nuc900_dma_stop(struct snd_pcm_substream *substream) | |
99 | +{ | |
100 | + struct snd_pcm_runtime *runtime = substream->runtime; | |
101 | + struct nuc900_audio *nuc900_audio = runtime->private_data; | |
102 | + unsigned long val; | |
103 | + | |
104 | + val = AUDIO_READ(nuc900_audio->mmio + ACTL_CON); | |
105 | + val &= ~(T_DMA_IRQ | R_DMA_IRQ); | |
106 | + AUDIO_WRITE(nuc900_audio->mmio + ACTL_CON, val); | |
107 | +} | |
108 | + | |
109 | +static irqreturn_t nuc900_dma_interrupt(int irq, void *dev_id) | |
110 | +{ | |
111 | + struct snd_pcm_substream *substream = dev_id; | |
112 | + struct nuc900_audio *nuc900_audio = substream->runtime->private_data; | |
113 | + unsigned long val; | |
114 | + | |
115 | + spin_lock(&nuc900_audio->lock); | |
116 | + | |
117 | + val = AUDIO_READ(nuc900_audio->mmio + ACTL_CON); | |
118 | + | |
119 | + if (val & R_DMA_IRQ) { | |
120 | + AUDIO_WRITE(nuc900_audio->mmio + ACTL_CON, val | R_DMA_IRQ); | |
121 | + | |
122 | + val = AUDIO_READ(nuc900_audio->mmio + ACTL_RSR); | |
123 | + | |
124 | + if (val & R_DMA_MIDDLE_IRQ) { | |
125 | + val |= R_DMA_MIDDLE_IRQ; | |
126 | + AUDIO_WRITE(nuc900_audio->mmio + ACTL_RSR, val); | |
127 | + } | |
128 | + | |
129 | + if (val & R_DMA_END_IRQ) { | |
130 | + val |= R_DMA_END_IRQ; | |
131 | + AUDIO_WRITE(nuc900_audio->mmio + ACTL_RSR, val); | |
132 | + } | |
133 | + } else if (val & T_DMA_IRQ) { | |
134 | + AUDIO_WRITE(nuc900_audio->mmio + ACTL_CON, val | T_DMA_IRQ); | |
135 | + | |
136 | + val = AUDIO_READ(nuc900_audio->mmio + ACTL_PSR); | |
137 | + | |
138 | + if (val & P_DMA_MIDDLE_IRQ) { | |
139 | + val |= P_DMA_MIDDLE_IRQ; | |
140 | + AUDIO_WRITE(nuc900_audio->mmio + ACTL_PSR, val); | |
141 | + } | |
142 | + | |
143 | + if (val & P_DMA_END_IRQ) { | |
144 | + val |= P_DMA_END_IRQ; | |
145 | + AUDIO_WRITE(nuc900_audio->mmio + ACTL_PSR, val); | |
146 | + } | |
147 | + } else { | |
148 | + dev_err(nuc900_audio->dev, "Wrong DMA interrupt status!\n"); | |
149 | + spin_unlock(&nuc900_audio->lock); | |
150 | + return IRQ_HANDLED; | |
151 | + } | |
152 | + | |
153 | + spin_unlock(&nuc900_audio->lock); | |
154 | + | |
155 | + snd_pcm_period_elapsed(substream); | |
156 | + | |
157 | + return IRQ_HANDLED; | |
158 | +} | |
159 | + | |
160 | +static int nuc900_dma_hw_free(struct snd_pcm_substream *substream) | |
161 | +{ | |
162 | + snd_pcm_lib_free_pages(substream); | |
163 | + return 0; | |
164 | +} | |
165 | + | |
166 | +static int nuc900_dma_prepare(struct snd_pcm_substream *substream) | |
167 | +{ | |
168 | + struct snd_pcm_runtime *runtime = substream->runtime; | |
169 | + struct nuc900_audio *nuc900_audio = runtime->private_data; | |
170 | + unsigned long flags, val, stype = SUBSTREAM_TYPE(substream);; | |
171 | + | |
172 | + spin_lock_irqsave(&nuc900_audio->lock, flags); | |
173 | + | |
174 | + nuc900_update_dma_register(substream, | |
175 | + nuc900_audio->dma_addr[stype], nuc900_audio->buffersize[stype]); | |
176 | + | |
177 | + val = AUDIO_READ(nuc900_audio->mmio + ACTL_RESET); | |
178 | + | |
179 | + switch (runtime->channels) { | |
180 | + case 1: | |
181 | + if (PCM_TX == stype) { | |
182 | + val &= ~(PLAY_LEFT_CHNNEL | PLAY_RIGHT_CHNNEL); | |
183 | + val |= PLAY_RIGHT_CHNNEL; | |
184 | + } else { | |
185 | + val &= ~(RECORD_LEFT_CHNNEL | RECORD_RIGHT_CHNNEL); | |
186 | + val |= RECORD_RIGHT_CHNNEL; | |
187 | + } | |
188 | + AUDIO_WRITE(nuc900_audio->mmio + ACTL_RESET, val); | |
189 | + break; | |
190 | + case 2: | |
191 | + if (PCM_TX == stype) | |
192 | + val |= (PLAY_LEFT_CHNNEL | PLAY_RIGHT_CHNNEL); | |
193 | + else | |
194 | + val |= (RECORD_LEFT_CHNNEL | RECORD_RIGHT_CHNNEL); | |
195 | + AUDIO_WRITE(nuc900_audio->mmio + ACTL_RESET, val); | |
196 | + break; | |
197 | + default: | |
198 | + return -EINVAL; | |
199 | + } | |
200 | + spin_unlock_irqrestore(&nuc900_audio->lock, flags); | |
201 | + return 0; | |
202 | +} | |
203 | + | |
204 | +static int nuc900_dma_trigger(struct snd_pcm_substream *substream, int cmd) | |
205 | +{ | |
206 | + int ret = 0; | |
207 | + | |
208 | + switch (cmd) { | |
209 | + case SNDRV_PCM_TRIGGER_START: | |
210 | + case SNDRV_PCM_TRIGGER_RESUME: | |
211 | + nuc900_dma_start(substream); | |
212 | + break; | |
213 | + | |
214 | + case SNDRV_PCM_TRIGGER_STOP: | |
215 | + case SNDRV_PCM_TRIGGER_SUSPEND: | |
216 | + nuc900_dma_stop(substream); | |
217 | + break; | |
218 | + | |
219 | + default: | |
220 | + ret = -EINVAL; | |
221 | + break; | |
222 | + } | |
223 | + | |
224 | + return ret; | |
225 | +} | |
226 | + | |
227 | +int nuc900_dma_getposition(struct snd_pcm_substream *substream, | |
228 | + dma_addr_t *src, dma_addr_t *dst) | |
229 | +{ | |
230 | + struct snd_pcm_runtime *runtime = substream->runtime; | |
231 | + struct nuc900_audio *nuc900_audio = runtime->private_data; | |
232 | + | |
233 | + if (src != NULL) | |
234 | + *src = AUDIO_READ(nuc900_audio->mmio + ACTL_PDSTC); | |
235 | + | |
236 | + if (dst != NULL) | |
237 | + *dst = AUDIO_READ(nuc900_audio->mmio + ACTL_RDSTC); | |
238 | + | |
239 | + return 0; | |
240 | +} | |
241 | + | |
242 | +static snd_pcm_uframes_t nuc900_dma_pointer(struct snd_pcm_substream *substream) | |
243 | +{ | |
244 | + struct snd_pcm_runtime *runtime = substream->runtime; | |
245 | + dma_addr_t src, dst; | |
246 | + unsigned long res; | |
247 | + | |
248 | + nuc900_dma_getposition(substream, &src, &dst); | |
249 | + | |
250 | + if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) | |
251 | + res = dst - runtime->dma_addr; | |
252 | + else | |
253 | + res = src - runtime->dma_addr; | |
254 | + | |
255 | + return bytes_to_frames(substream->runtime, res); | |
256 | +} | |
257 | + | |
258 | +static int nuc900_dma_open(struct snd_pcm_substream *substream) | |
259 | +{ | |
260 | + struct snd_pcm_runtime *runtime = substream->runtime; | |
261 | + struct nuc900_audio *nuc900_audio; | |
262 | + | |
263 | + snd_soc_set_runtime_hwparams(substream, &nuc900_pcm_hardware); | |
264 | + | |
265 | + nuc900_audio = nuc900_ac97_data; | |
266 | + | |
267 | + if (request_irq(nuc900_audio->irq_num, nuc900_dma_interrupt, | |
268 | + IRQF_DISABLED, "nuc900-dma", substream)) | |
269 | + return -EBUSY; | |
270 | + | |
271 | + runtime->private_data = nuc900_audio; | |
272 | + | |
273 | + return 0; | |
274 | +} | |
275 | + | |
276 | +static int nuc900_dma_close(struct snd_pcm_substream *substream) | |
277 | +{ | |
278 | + struct snd_pcm_runtime *runtime = substream->runtime; | |
279 | + struct nuc900_audio *nuc900_audio = runtime->private_data; | |
280 | + | |
281 | + free_irq(nuc900_audio->irq_num, substream); | |
282 | + | |
283 | + return 0; | |
284 | +} | |
285 | + | |
286 | +static int nuc900_dma_mmap(struct snd_pcm_substream *substream, | |
287 | + struct vm_area_struct *vma) | |
288 | +{ | |
289 | + struct snd_pcm_runtime *runtime = substream->runtime; | |
290 | + | |
291 | + return dma_mmap_writecombine(substream->pcm->card->dev, vma, | |
292 | + runtime->dma_area, | |
293 | + runtime->dma_addr, | |
294 | + runtime->dma_bytes); | |
295 | +} | |
296 | + | |
297 | +static struct snd_pcm_ops nuc900_dma_ops = { | |
298 | + .open = nuc900_dma_open, | |
299 | + .close = nuc900_dma_close, | |
300 | + .ioctl = snd_pcm_lib_ioctl, | |
301 | + .hw_params = nuc900_dma_hw_params, | |
302 | + .hw_free = nuc900_dma_hw_free, | |
303 | + .prepare = nuc900_dma_prepare, | |
304 | + .trigger = nuc900_dma_trigger, | |
305 | + .pointer = nuc900_dma_pointer, | |
306 | + .mmap = nuc900_dma_mmap, | |
307 | +}; | |
308 | + | |
309 | +static void nuc900_dma_free_dma_buffers(struct snd_pcm *pcm) | |
310 | +{ | |
311 | + snd_pcm_lib_preallocate_free_for_all(pcm); | |
312 | +} | |
313 | + | |
314 | +static u64 nuc900_pcm_dmamask = DMA_BIT_MASK(32); | |
315 | +static int nuc900_dma_new(struct snd_card *card, | |
316 | + struct snd_soc_dai *dai, struct snd_pcm *pcm) | |
317 | +{ | |
318 | + if (!card->dev->dma_mask) | |
319 | + card->dev->dma_mask = &nuc900_pcm_dmamask; | |
320 | + if (!card->dev->coherent_dma_mask) | |
321 | + card->dev->coherent_dma_mask = DMA_BIT_MASK(32); | |
322 | + | |
323 | + snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, | |
324 | + card->dev, 4 * 1024, (4 * 1024) - 1); | |
325 | + | |
326 | + return 0; | |
327 | +} | |
328 | + | |
329 | +struct snd_soc_platform nuc900_soc_platform = { | |
330 | + .name = "nuc900-dma", | |
331 | + .pcm_ops = &nuc900_dma_ops, | |
332 | + .pcm_new = nuc900_dma_new, | |
333 | + .pcm_free = nuc900_dma_free_dma_buffers, | |
334 | +} | |
335 | +EXPORT_SYMBOL_GPL(nuc900_soc_platform); | |
336 | + | |
337 | +static int __init nuc900_soc_platform_init(void) | |
338 | +{ | |
339 | + return snd_soc_register_platform(&nuc900_soc_platform); | |
340 | +} | |
341 | + | |
342 | +static void __exit nuc900_soc_platform_exit(void) | |
343 | +{ | |
344 | + snd_soc_unregister_platform(&nuc900_soc_platform); | |
345 | +} | |
346 | + | |
347 | +module_init(nuc900_soc_platform_init); | |
348 | +module_exit(nuc900_soc_platform_exit); | |
349 | + | |
350 | +MODULE_AUTHOR("Wan ZongShun, <mcuos.com@gmail.com>"); | |
351 | +MODULE_DESCRIPTION("nuc900 Audio DMA module"); | |
352 | +MODULE_LICENSE("GPL"); |