Commit | Line | Data |
---|---|---|
6c742509 SG |
1 | /* |
2 | * atmel-pcm.c -- ALSA PCM interface for the Atmel atmel SoC. | |
9aaca968 | 3 | * |
6c742509 SG |
4 | * Copyright (C) 2005 SAN People |
5 | * Copyright (C) 2008 Atmel | |
6 | * | |
7 | * Authors: Sedji Gaouaou <sedji.gaouaou@atmel.com> | |
8 | * | |
9 | * Based on at91-pcm. by: | |
10 | * Frank Mandarino <fmandarino@endrelia.com> | |
11 | * Copyright 2006 Endrelia Technologies Inc. | |
12 | * | |
13 | * Based on pxa2xx-pcm.c by: | |
14 | * | |
15 | * Author: Nicolas Pitre | |
16 | * Created: Nov 30, 2004 | |
17 | * Copyright: (C) 2004 MontaVista Software, Inc. | |
9aaca968 GW |
18 | * |
19 | * This program is free software; you can redistribute it and/or modify | |
6c742509 SG |
20 | * it under the terms of the GNU General Public License as published by |
21 | * the Free Software Foundation; either version 2 of the License, or | |
22 | * (at your option) any later version. | |
9aaca968 | 23 | * |
6c742509 SG |
24 | * This program is distributed in the hope that it will be useful, |
25 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
26 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
27 | * GNU General Public License for more details. | |
28 | * | |
29 | * You should have received a copy of the GNU General Public License | |
30 | * along with this program; if not, write to the Free Software | |
31 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
9aaca968 GW |
32 | */ |
33 | ||
34 | #include <linux/module.h> | |
35 | #include <linux/init.h> | |
36 | #include <linux/platform_device.h> | |
37 | #include <linux/slab.h> | |
38 | #include <linux/dma-mapping.h> | |
39 | #include <linux/atmel_pdc.h> | |
6c742509 | 40 | #include <linux/atmel-ssc.h> |
9aaca968 GW |
41 | |
42 | #include <sound/core.h> | |
43 | #include <sound/pcm.h> | |
44 | #include <sound/pcm_params.h> | |
45 | #include <sound/soc.h> | |
46 | ||
6c742509 | 47 | #include "atmel-pcm.h" |
9aaca968 GW |
48 | |
49 | ||
50 | /*--------------------------------------------------------------------------*\ | |
51 | * Hardware definition | |
52 | \*--------------------------------------------------------------------------*/ | |
53 | /* TODO: These values were taken from the AT91 platform driver, check | |
54 | * them against real values for AT32 | |
55 | */ | |
6c742509 SG |
56 | static const struct snd_pcm_hardware atmel_pcm_hardware = { |
57 | .info = SNDRV_PCM_INFO_MMAP | | |
58 | SNDRV_PCM_INFO_MMAP_VALID | | |
59 | SNDRV_PCM_INFO_INTERLEAVED | | |
60 | SNDRV_PCM_INFO_PAUSE, | |
61 | .formats = SNDRV_PCM_FMTBIT_S16_LE, | |
62 | .period_bytes_min = 32, | |
63 | .period_bytes_max = 8192, | |
64 | .periods_min = 2, | |
65 | .periods_max = 1024, | |
66 | .buffer_bytes_max = 32 * 1024, | |
9aaca968 GW |
67 | }; |
68 | ||
69 | ||
9aaca968 GW |
70 | /*--------------------------------------------------------------------------*\ |
71 | * Data types | |
72 | \*--------------------------------------------------------------------------*/ | |
6c742509 SG |
73 | struct atmel_runtime_data { |
74 | struct atmel_pcm_dma_params *params; | |
75 | dma_addr_t dma_buffer; /* physical address of dma buffer */ | |
76 | dma_addr_t dma_buffer_end; /* first address beyond DMA buffer */ | |
9aaca968 GW |
77 | size_t period_size; |
78 | ||
6c742509 | 79 | dma_addr_t period_ptr; /* physical address of next period */ |
9aaca968 | 80 | |
6c742509 | 81 | /* PDC register save */ |
9aaca968 GW |
82 | u32 pdc_xpr_save; |
83 | u32 pdc_xcr_save; | |
84 | u32 pdc_xnpr_save; | |
85 | u32 pdc_xncr_save; | |
86 | }; | |
87 | ||
88 | ||
9aaca968 GW |
89 | /*--------------------------------------------------------------------------*\ |
90 | * Helper functions | |
91 | \*--------------------------------------------------------------------------*/ | |
6c742509 SG |
92 | static int atmel_pcm_preallocate_dma_buffer(struct snd_pcm *pcm, |
93 | int stream) | |
9aaca968 GW |
94 | { |
95 | struct snd_pcm_substream *substream = pcm->streams[stream].substream; | |
6c742509 SG |
96 | struct snd_dma_buffer *buf = &substream->dma_buffer; |
97 | size_t size = atmel_pcm_hardware.buffer_bytes_max; | |
98 | ||
99 | buf->dev.type = SNDRV_DMA_TYPE_DEV; | |
100 | buf->dev.dev = pcm->card->dev; | |
101 | buf->private_data = NULL; | |
102 | buf->area = dma_alloc_coherent(pcm->card->dev, size, | |
103 | &buf->addr, GFP_KERNEL); | |
104 | pr_debug("atmel-pcm:" | |
105 | "preallocate_dma_buffer: area=%p, addr=%p, size=%d\n", | |
106 | (void *) buf->area, | |
107 | (void *) buf->addr, | |
108 | size); | |
109 | ||
110 | if (!buf->area) | |
9aaca968 GW |
111 | return -ENOMEM; |
112 | ||
6c742509 | 113 | buf->bytes = size; |
9aaca968 GW |
114 | return 0; |
115 | } | |
9aaca968 GW |
116 | /*--------------------------------------------------------------------------*\ |
117 | * ISR | |
118 | \*--------------------------------------------------------------------------*/ | |
6c742509 SG |
119 | static void atmel_pcm_dma_irq(u32 ssc_sr, |
120 | struct snd_pcm_substream *substream) | |
9aaca968 | 121 | { |
6c742509 SG |
122 | struct atmel_runtime_data *prtd = substream->runtime->private_data; |
123 | struct atmel_pcm_dma_params *params = prtd->params; | |
9aaca968 GW |
124 | static int count; |
125 | ||
126 | count++; | |
6c742509 | 127 | |
9aaca968 | 128 | if (ssc_sr & params->mask->ssc_endbuf) { |
6c742509 SG |
129 | pr_warning("atmel-pcm: buffer %s on %s" |
130 | " (SSC_SR=%#x, count=%d)\n", | |
131 | substream->stream == SNDRV_PCM_STREAM_PLAYBACK | |
132 | ? "underrun" : "overrun", | |
133 | params->name, ssc_sr, count); | |
9aaca968 GW |
134 | |
135 | /* re-start the PDC */ | |
136 | ssc_writex(params->ssc->regs, ATMEL_PDC_PTCR, | |
137 | params->mask->pdc_disable); | |
138 | prtd->period_ptr += prtd->period_size; | |
139 | if (prtd->period_ptr >= prtd->dma_buffer_end) | |
140 | prtd->period_ptr = prtd->dma_buffer; | |
141 | ||
9aaca968 GW |
142 | ssc_writex(params->ssc->regs, params->pdc->xpr, |
143 | prtd->period_ptr); | |
144 | ssc_writex(params->ssc->regs, params->pdc->xcr, | |
145 | prtd->period_size / params->pdc_xfer_size); | |
146 | ssc_writex(params->ssc->regs, ATMEL_PDC_PTCR, | |
147 | params->mask->pdc_enable); | |
148 | } | |
149 | ||
9aaca968 GW |
150 | if (ssc_sr & params->mask->ssc_endx) { |
151 | /* Load the PDC next pointer and counter registers */ | |
152 | prtd->period_ptr += prtd->period_size; | |
153 | if (prtd->period_ptr >= prtd->dma_buffer_end) | |
154 | prtd->period_ptr = prtd->dma_buffer; | |
6c742509 | 155 | |
9aaca968 GW |
156 | ssc_writex(params->ssc->regs, params->pdc->xnpr, |
157 | prtd->period_ptr); | |
158 | ssc_writex(params->ssc->regs, params->pdc->xncr, | |
159 | prtd->period_size / params->pdc_xfer_size); | |
160 | } | |
161 | ||
9aaca968 GW |
162 | snd_pcm_period_elapsed(substream); |
163 | } | |
164 | ||
165 | ||
9aaca968 GW |
166 | /*--------------------------------------------------------------------------*\ |
167 | * PCM operations | |
168 | \*--------------------------------------------------------------------------*/ | |
6c742509 SG |
169 | static int atmel_pcm_hw_params(struct snd_pcm_substream *substream, |
170 | struct snd_pcm_hw_params *params) | |
9aaca968 GW |
171 | { |
172 | struct snd_pcm_runtime *runtime = substream->runtime; | |
6c742509 | 173 | struct atmel_runtime_data *prtd = runtime->private_data; |
9aaca968 GW |
174 | struct snd_soc_pcm_runtime *rtd = substream->private_data; |
175 | ||
176 | /* this may get called several times by oss emulation | |
6c742509 SG |
177 | * with different params */ |
178 | ||
9aaca968 GW |
179 | snd_pcm_set_runtime_buffer(substream, &substream->dma_buffer); |
180 | runtime->dma_bytes = params_buffer_bytes(params); | |
181 | ||
f0fba2ad | 182 | prtd->params = snd_soc_dai_get_dma_data(rtd->cpu_dai, substream); |
6c742509 | 183 | prtd->params->dma_intr_handler = atmel_pcm_dma_irq; |
9aaca968 GW |
184 | |
185 | prtd->dma_buffer = runtime->dma_addr; | |
186 | prtd->dma_buffer_end = runtime->dma_addr + runtime->dma_bytes; | |
187 | prtd->period_size = params_period_bytes(params); | |
188 | ||
6c742509 SG |
189 | pr_debug("atmel-pcm: " |
190 | "hw_params: DMA for %s initialized " | |
191 | "(dma_bytes=%u, period_size=%u)\n", | |
192 | prtd->params->name, | |
193 | runtime->dma_bytes, | |
194 | prtd->period_size); | |
9aaca968 GW |
195 | return 0; |
196 | } | |
197 | ||
6c742509 | 198 | static int atmel_pcm_hw_free(struct snd_pcm_substream *substream) |
9aaca968 | 199 | { |
6c742509 SG |
200 | struct atmel_runtime_data *prtd = substream->runtime->private_data; |
201 | struct atmel_pcm_dma_params *params = prtd->params; | |
9aaca968 GW |
202 | |
203 | if (params != NULL) { | |
204 | ssc_writex(params->ssc->regs, SSC_PDC_PTCR, | |
205 | params->mask->pdc_disable); | |
206 | prtd->params->dma_intr_handler = NULL; | |
207 | } | |
208 | ||
209 | return 0; | |
210 | } | |
211 | ||
6c742509 | 212 | static int atmel_pcm_prepare(struct snd_pcm_substream *substream) |
9aaca968 | 213 | { |
6c742509 SG |
214 | struct atmel_runtime_data *prtd = substream->runtime->private_data; |
215 | struct atmel_pcm_dma_params *params = prtd->params; | |
9aaca968 GW |
216 | |
217 | ssc_writex(params->ssc->regs, SSC_IDR, | |
218 | params->mask->ssc_endx | params->mask->ssc_endbuf); | |
219 | ssc_writex(params->ssc->regs, ATMEL_PDC_PTCR, | |
220 | params->mask->pdc_disable); | |
9aaca968 GW |
221 | return 0; |
222 | } | |
223 | ||
6c742509 SG |
224 | static int atmel_pcm_trigger(struct snd_pcm_substream *substream, |
225 | int cmd) | |
9aaca968 GW |
226 | { |
227 | struct snd_pcm_runtime *rtd = substream->runtime; | |
6c742509 SG |
228 | struct atmel_runtime_data *prtd = rtd->private_data; |
229 | struct atmel_pcm_dma_params *params = prtd->params; | |
9aaca968 GW |
230 | int ret = 0; |
231 | ||
6c742509 SG |
232 | pr_debug("atmel-pcm:buffer_size = %ld," |
233 | "dma_area = %p, dma_bytes = %u\n", | |
234 | rtd->buffer_size, rtd->dma_area, rtd->dma_bytes); | |
9aaca968 GW |
235 | |
236 | switch (cmd) { | |
237 | case SNDRV_PCM_TRIGGER_START: | |
238 | prtd->period_ptr = prtd->dma_buffer; | |
239 | ||
240 | ssc_writex(params->ssc->regs, params->pdc->xpr, | |
241 | prtd->period_ptr); | |
242 | ssc_writex(params->ssc->regs, params->pdc->xcr, | |
243 | prtd->period_size / params->pdc_xfer_size); | |
244 | ||
245 | prtd->period_ptr += prtd->period_size; | |
246 | ssc_writex(params->ssc->regs, params->pdc->xnpr, | |
247 | prtd->period_ptr); | |
248 | ssc_writex(params->ssc->regs, params->pdc->xncr, | |
249 | prtd->period_size / params->pdc_xfer_size); | |
250 | ||
6c742509 SG |
251 | pr_debug("atmel-pcm: trigger: " |
252 | "period_ptr=%lx, xpr=%u, " | |
253 | "xcr=%u, xnpr=%u, xncr=%u\n", | |
254 | (unsigned long)prtd->period_ptr, | |
255 | ssc_readx(params->ssc->regs, params->pdc->xpr), | |
256 | ssc_readx(params->ssc->regs, params->pdc->xcr), | |
257 | ssc_readx(params->ssc->regs, params->pdc->xnpr), | |
258 | ssc_readx(params->ssc->regs, params->pdc->xncr)); | |
9aaca968 GW |
259 | |
260 | ssc_writex(params->ssc->regs, SSC_IER, | |
261 | params->mask->ssc_endx | params->mask->ssc_endbuf); | |
262 | ssc_writex(params->ssc->regs, SSC_PDC_PTCR, | |
263 | params->mask->pdc_enable); | |
264 | ||
6c742509 SG |
265 | pr_debug("sr=%u imr=%u\n", |
266 | ssc_readx(params->ssc->regs, SSC_SR), | |
267 | ssc_readx(params->ssc->regs, SSC_IER)); | |
9aaca968 GW |
268 | break; /* SNDRV_PCM_TRIGGER_START */ |
269 | ||
9aaca968 GW |
270 | case SNDRV_PCM_TRIGGER_STOP: |
271 | case SNDRV_PCM_TRIGGER_SUSPEND: | |
272 | case SNDRV_PCM_TRIGGER_PAUSE_PUSH: | |
273 | ssc_writex(params->ssc->regs, ATMEL_PDC_PTCR, | |
274 | params->mask->pdc_disable); | |
275 | break; | |
276 | ||
9aaca968 GW |
277 | case SNDRV_PCM_TRIGGER_RESUME: |
278 | case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: | |
279 | ssc_writex(params->ssc->regs, ATMEL_PDC_PTCR, | |
280 | params->mask->pdc_enable); | |
281 | break; | |
282 | ||
283 | default: | |
284 | ret = -EINVAL; | |
285 | } | |
286 | ||
287 | return ret; | |
288 | } | |
289 | ||
6c742509 SG |
290 | static snd_pcm_uframes_t atmel_pcm_pointer( |
291 | struct snd_pcm_substream *substream) | |
9aaca968 GW |
292 | { |
293 | struct snd_pcm_runtime *runtime = substream->runtime; | |
6c742509 SG |
294 | struct atmel_runtime_data *prtd = runtime->private_data; |
295 | struct atmel_pcm_dma_params *params = prtd->params; | |
9aaca968 GW |
296 | dma_addr_t ptr; |
297 | snd_pcm_uframes_t x; | |
298 | ||
299 | ptr = (dma_addr_t) ssc_readx(params->ssc->regs, params->pdc->xpr); | |
300 | x = bytes_to_frames(runtime, ptr - prtd->dma_buffer); | |
301 | ||
302 | if (x == runtime->buffer_size) | |
303 | x = 0; | |
304 | ||
305 | return x; | |
306 | } | |
307 | ||
6c742509 | 308 | static int atmel_pcm_open(struct snd_pcm_substream *substream) |
9aaca968 GW |
309 | { |
310 | struct snd_pcm_runtime *runtime = substream->runtime; | |
6c742509 | 311 | struct atmel_runtime_data *prtd; |
9aaca968 GW |
312 | int ret = 0; |
313 | ||
6c742509 | 314 | snd_soc_set_runtime_hwparams(substream, &atmel_pcm_hardware); |
9aaca968 GW |
315 | |
316 | /* ensure that buffer size is a multiple of period size */ | |
317 | ret = snd_pcm_hw_constraint_integer(runtime, | |
6c742509 | 318 | SNDRV_PCM_HW_PARAM_PERIODS); |
9aaca968 GW |
319 | if (ret < 0) |
320 | goto out; | |
321 | ||
6c742509 | 322 | prtd = kzalloc(sizeof(struct atmel_runtime_data), GFP_KERNEL); |
9aaca968 GW |
323 | if (prtd == NULL) { |
324 | ret = -ENOMEM; | |
325 | goto out; | |
326 | } | |
327 | runtime->private_data = prtd; | |
328 | ||
6c742509 | 329 | out: |
9aaca968 GW |
330 | return ret; |
331 | } | |
332 | ||
6c742509 | 333 | static int atmel_pcm_close(struct snd_pcm_substream *substream) |
9aaca968 | 334 | { |
6c742509 | 335 | struct atmel_runtime_data *prtd = substream->runtime->private_data; |
9aaca968 GW |
336 | |
337 | kfree(prtd); | |
338 | return 0; | |
339 | } | |
340 | ||
6c742509 SG |
341 | static int atmel_pcm_mmap(struct snd_pcm_substream *substream, |
342 | struct vm_area_struct *vma) | |
9aaca968 GW |
343 | { |
344 | return remap_pfn_range(vma, vma->vm_start, | |
6c742509 SG |
345 | substream->dma_buffer.addr >> PAGE_SHIFT, |
346 | vma->vm_end - vma->vm_start, vma->vm_page_prot); | |
9aaca968 GW |
347 | } |
348 | ||
b2a19d02 | 349 | static struct snd_pcm_ops atmel_pcm_ops = { |
6c742509 SG |
350 | .open = atmel_pcm_open, |
351 | .close = atmel_pcm_close, | |
352 | .ioctl = snd_pcm_lib_ioctl, | |
353 | .hw_params = atmel_pcm_hw_params, | |
354 | .hw_free = atmel_pcm_hw_free, | |
355 | .prepare = atmel_pcm_prepare, | |
356 | .trigger = atmel_pcm_trigger, | |
357 | .pointer = atmel_pcm_pointer, | |
358 | .mmap = atmel_pcm_mmap, | |
9aaca968 GW |
359 | }; |
360 | ||
361 | ||
9aaca968 GW |
362 | /*--------------------------------------------------------------------------*\ |
363 | * ASoC platform driver | |
364 | \*--------------------------------------------------------------------------*/ | |
6c742509 | 365 | static u64 atmel_pcm_dmamask = 0xffffffff; |
9aaca968 | 366 | |
6c742509 SG |
367 | static int atmel_pcm_new(struct snd_card *card, |
368 | struct snd_soc_dai *dai, struct snd_pcm *pcm) | |
9aaca968 GW |
369 | { |
370 | int ret = 0; | |
371 | ||
372 | if (!card->dev->dma_mask) | |
6c742509 | 373 | card->dev->dma_mask = &atmel_pcm_dmamask; |
9aaca968 GW |
374 | if (!card->dev->coherent_dma_mask) |
375 | card->dev->coherent_dma_mask = 0xffffffff; | |
376 | ||
f0fba2ad | 377 | if (dai->driver->playback.channels_min) { |
6c742509 SG |
378 | ret = atmel_pcm_preallocate_dma_buffer(pcm, |
379 | SNDRV_PCM_STREAM_PLAYBACK); | |
9aaca968 GW |
380 | if (ret) |
381 | goto out; | |
382 | } | |
383 | ||
f0fba2ad | 384 | if (dai->driver->capture.channels_min) { |
6c742509 SG |
385 | pr_debug("at32-pcm:" |
386 | "Allocating PCM capture DMA buffer\n"); | |
387 | ret = atmel_pcm_preallocate_dma_buffer(pcm, | |
388 | SNDRV_PCM_STREAM_CAPTURE); | |
9aaca968 GW |
389 | if (ret) |
390 | goto out; | |
391 | } | |
6c742509 | 392 | out: |
9aaca968 GW |
393 | return ret; |
394 | } | |
395 | ||
6c742509 | 396 | static void atmel_pcm_free_dma_buffers(struct snd_pcm *pcm) |
9aaca968 GW |
397 | { |
398 | struct snd_pcm_substream *substream; | |
399 | struct snd_dma_buffer *buf; | |
400 | int stream; | |
401 | ||
402 | for (stream = 0; stream < 2; stream++) { | |
403 | substream = pcm->streams[stream].substream; | |
6c742509 | 404 | if (!substream) |
9aaca968 GW |
405 | continue; |
406 | ||
407 | buf = &substream->dma_buffer; | |
408 | if (!buf->area) | |
409 | continue; | |
410 | dma_free_coherent(pcm->card->dev, buf->bytes, | |
411 | buf->area, buf->addr); | |
412 | buf->area = NULL; | |
413 | } | |
414 | } | |
415 | ||
9aaca968 | 416 | #ifdef CONFIG_PM |
f0fba2ad | 417 | static int atmel_pcm_suspend(struct snd_soc_dai *dai) |
9aaca968 | 418 | { |
f0fba2ad | 419 | struct snd_pcm_runtime *runtime = dai->runtime; |
6c742509 SG |
420 | struct atmel_runtime_data *prtd; |
421 | struct atmel_pcm_dma_params *params; | |
9aaca968 | 422 | |
6c742509 | 423 | if (!runtime) |
9aaca968 | 424 | return 0; |
6c742509 | 425 | |
9aaca968 GW |
426 | prtd = runtime->private_data; |
427 | params = prtd->params; | |
428 | ||
6c742509 SG |
429 | /* disable the PDC and save the PDC registers */ |
430 | ||
431 | ssc_writel(params->ssc->regs, PDC_PTCR, params->mask->pdc_disable); | |
9aaca968 GW |
432 | |
433 | prtd->pdc_xpr_save = ssc_readx(params->ssc->regs, params->pdc->xpr); | |
434 | prtd->pdc_xcr_save = ssc_readx(params->ssc->regs, params->pdc->xcr); | |
435 | prtd->pdc_xnpr_save = ssc_readx(params->ssc->regs, params->pdc->xnpr); | |
436 | prtd->pdc_xncr_save = ssc_readx(params->ssc->regs, params->pdc->xncr); | |
437 | ||
438 | return 0; | |
439 | } | |
440 | ||
f0fba2ad | 441 | static int atmel_pcm_resume(struct snd_soc_dai *dai) |
9aaca968 | 442 | { |
f0fba2ad | 443 | struct snd_pcm_runtime *runtime = dai->runtime; |
6c742509 SG |
444 | struct atmel_runtime_data *prtd; |
445 | struct atmel_pcm_dma_params *params; | |
9aaca968 | 446 | |
6c742509 | 447 | if (!runtime) |
9aaca968 | 448 | return 0; |
6c742509 | 449 | |
9aaca968 GW |
450 | prtd = runtime->private_data; |
451 | params = prtd->params; | |
452 | ||
6c742509 | 453 | /* restore the PDC registers and enable the PDC */ |
9aaca968 GW |
454 | ssc_writex(params->ssc->regs, params->pdc->xpr, prtd->pdc_xpr_save); |
455 | ssc_writex(params->ssc->regs, params->pdc->xcr, prtd->pdc_xcr_save); | |
456 | ssc_writex(params->ssc->regs, params->pdc->xnpr, prtd->pdc_xnpr_save); | |
457 | ssc_writex(params->ssc->regs, params->pdc->xncr, prtd->pdc_xncr_save); | |
458 | ||
6c742509 | 459 | ssc_writel(params->ssc->regs, PDC_PTCR, params->mask->pdc_enable); |
9aaca968 GW |
460 | return 0; |
461 | } | |
6c742509 SG |
462 | #else |
463 | #define atmel_pcm_suspend NULL | |
464 | #define atmel_pcm_resume NULL | |
465 | #endif | |
466 | ||
f0fba2ad LG |
467 | static struct snd_soc_platform_driver atmel_soc_platform = { |
468 | .ops = &atmel_pcm_ops, | |
6c742509 SG |
469 | .pcm_new = atmel_pcm_new, |
470 | .pcm_free = atmel_pcm_free_dma_buffers, | |
471 | .suspend = atmel_pcm_suspend, | |
472 | .resume = atmel_pcm_resume, | |
9aaca968 | 473 | }; |
9aaca968 | 474 | |
f0fba2ad LG |
475 | static int __devinit atmel_soc_platform_probe(struct platform_device *pdev) |
476 | { | |
477 | return snd_soc_register_platform(&pdev->dev, &atmel_soc_platform); | |
478 | } | |
479 | ||
480 | static int __devexit atmel_soc_platform_remove(struct platform_device *pdev) | |
481 | { | |
482 | snd_soc_unregister_platform(&pdev->dev); | |
483 | return 0; | |
484 | } | |
485 | ||
486 | static struct platform_driver atmel_pcm_driver = { | |
487 | .driver = { | |
488 | .name = "atmel-pcm-audio", | |
489 | .owner = THIS_MODULE, | |
490 | }, | |
491 | ||
492 | .probe = atmel_soc_platform_probe, | |
493 | .remove = __devexit_p(atmel_soc_platform_remove), | |
494 | }; | |
495 | ||
496 | static int __init snd_atmel_pcm_init(void) | |
958e792c | 497 | { |
f0fba2ad | 498 | return platform_driver_register(&atmel_pcm_driver); |
958e792c | 499 | } |
f0fba2ad | 500 | module_init(snd_atmel_pcm_init); |
958e792c | 501 | |
f0fba2ad | 502 | static void __exit snd_atmel_pcm_exit(void) |
958e792c | 503 | { |
f0fba2ad | 504 | platform_driver_unregister(&atmel_pcm_driver); |
958e792c | 505 | } |
f0fba2ad | 506 | module_exit(snd_atmel_pcm_exit); |
958e792c | 507 | |
6c742509 SG |
508 | MODULE_AUTHOR("Sedji Gaouaou <sedji.gaouaou@atmel.com>"); |
509 | MODULE_DESCRIPTION("Atmel PCM module"); | |
9aaca968 | 510 | MODULE_LICENSE("GPL"); |