diff options
Diffstat (limited to 'sound/soc/fsl/mpc5200_dma.c')
-rw-r--r-- | sound/soc/fsl/mpc5200_dma.c | 63 |
1 files changed, 44 insertions, 19 deletions
diff --git a/sound/soc/fsl/mpc5200_dma.c b/sound/soc/fsl/mpc5200_dma.c index 3dcd1469f283..fff695ccdd3e 100644 --- a/sound/soc/fsl/mpc5200_dma.c +++ b/sound/soc/fsl/mpc5200_dma.c | |||
@@ -9,6 +9,7 @@ | |||
9 | #include <linux/module.h> | 9 | #include <linux/module.h> |
10 | #include <linux/of_device.h> | 10 | #include <linux/of_device.h> |
11 | #include <linux/slab.h> | 11 | #include <linux/slab.h> |
12 | #include <linux/of_platform.h> | ||
12 | 13 | ||
13 | #include <sound/soc.h> | 14 | #include <sound/soc.h> |
14 | 15 | ||
@@ -107,7 +108,7 @@ static int psc_dma_hw_free(struct snd_pcm_substream *substream) | |||
107 | static int psc_dma_trigger(struct snd_pcm_substream *substream, int cmd) | 108 | static int psc_dma_trigger(struct snd_pcm_substream *substream, int cmd) |
108 | { | 109 | { |
109 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | 110 | struct snd_soc_pcm_runtime *rtd = substream->private_data; |
110 | struct psc_dma *psc_dma = rtd->dai->cpu_dai->private_data; | 111 | struct psc_dma *psc_dma = snd_soc_dai_get_drvdata(rtd->cpu_dai); |
111 | struct snd_pcm_runtime *runtime = substream->runtime; | 112 | struct snd_pcm_runtime *runtime = substream->runtime; |
112 | struct psc_dma_stream *s = to_psc_dma_stream(substream, psc_dma); | 113 | struct psc_dma_stream *s = to_psc_dma_stream(substream, psc_dma); |
113 | struct mpc52xx_psc __iomem *regs = psc_dma->psc_regs; | 114 | struct mpc52xx_psc __iomem *regs = psc_dma->psc_regs; |
@@ -212,7 +213,7 @@ static int psc_dma_open(struct snd_pcm_substream *substream) | |||
212 | { | 213 | { |
213 | struct snd_pcm_runtime *runtime = substream->runtime; | 214 | struct snd_pcm_runtime *runtime = substream->runtime; |
214 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | 215 | struct snd_soc_pcm_runtime *rtd = substream->private_data; |
215 | struct psc_dma *psc_dma = rtd->dai->cpu_dai->private_data; | 216 | struct psc_dma *psc_dma = snd_soc_dai_get_drvdata(rtd->cpu_dai); |
216 | struct psc_dma_stream *s; | 217 | struct psc_dma_stream *s; |
217 | int rc; | 218 | int rc; |
218 | 219 | ||
@@ -239,7 +240,7 @@ static int psc_dma_open(struct snd_pcm_substream *substream) | |||
239 | static int psc_dma_close(struct snd_pcm_substream *substream) | 240 | static int psc_dma_close(struct snd_pcm_substream *substream) |
240 | { | 241 | { |
241 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | 242 | struct snd_soc_pcm_runtime *rtd = substream->private_data; |
242 | struct psc_dma *psc_dma = rtd->dai->cpu_dai->private_data; | 243 | struct psc_dma *psc_dma = snd_soc_dai_get_drvdata(rtd->cpu_dai); |
243 | struct psc_dma_stream *s; | 244 | struct psc_dma_stream *s; |
244 | 245 | ||
245 | dev_dbg(psc_dma->dev, "psc_dma_close(substream=%p)\n", substream); | 246 | dev_dbg(psc_dma->dev, "psc_dma_close(substream=%p)\n", substream); |
@@ -264,7 +265,7 @@ static snd_pcm_uframes_t | |||
264 | psc_dma_pointer(struct snd_pcm_substream *substream) | 265 | psc_dma_pointer(struct snd_pcm_substream *substream) |
265 | { | 266 | { |
266 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | 267 | struct snd_soc_pcm_runtime *rtd = substream->private_data; |
267 | struct psc_dma *psc_dma = rtd->dai->cpu_dai->private_data; | 268 | struct psc_dma *psc_dma = snd_soc_dai_get_drvdata(rtd->cpu_dai); |
268 | struct psc_dma_stream *s; | 269 | struct psc_dma_stream *s; |
269 | dma_addr_t count; | 270 | dma_addr_t count; |
270 | 271 | ||
@@ -302,11 +303,11 @@ static int psc_dma_new(struct snd_card *card, struct snd_soc_dai *dai, | |||
302 | struct snd_pcm *pcm) | 303 | struct snd_pcm *pcm) |
303 | { | 304 | { |
304 | struct snd_soc_pcm_runtime *rtd = pcm->private_data; | 305 | struct snd_soc_pcm_runtime *rtd = pcm->private_data; |
305 | struct psc_dma *psc_dma = rtd->dai->cpu_dai->private_data; | 306 | struct psc_dma *psc_dma = snd_soc_dai_get_drvdata(rtd->cpu_dai); |
306 | size_t size = psc_dma_hardware.buffer_bytes_max; | 307 | size_t size = psc_dma_hardware.buffer_bytes_max; |
307 | int rc = 0; | 308 | int rc = 0; |
308 | 309 | ||
309 | dev_dbg(rtd->socdev->dev, "psc_dma_new(card=%p, dai=%p, pcm=%p)\n", | 310 | dev_dbg(rtd->platform->dev, "psc_dma_new(card=%p, dai=%p, pcm=%p)\n", |
310 | card, dai, pcm); | 311 | card, dai, pcm); |
311 | 312 | ||
312 | if (!card->dev->dma_mask) | 313 | if (!card->dev->dma_mask) |
@@ -328,8 +329,8 @@ static int psc_dma_new(struct snd_card *card, struct snd_soc_dai *dai, | |||
328 | goto capture_alloc_err; | 329 | goto capture_alloc_err; |
329 | } | 330 | } |
330 | 331 | ||
331 | if (rtd->socdev->card->codec->ac97) | 332 | if (rtd->codec->ac97) |
332 | rtd->socdev->card->codec->ac97->private_data = psc_dma; | 333 | rtd->codec->ac97->private_data = psc_dma; |
333 | 334 | ||
334 | return 0; | 335 | return 0; |
335 | 336 | ||
@@ -349,7 +350,7 @@ static void psc_dma_free(struct snd_pcm *pcm) | |||
349 | struct snd_pcm_substream *substream; | 350 | struct snd_pcm_substream *substream; |
350 | int stream; | 351 | int stream; |
351 | 352 | ||
352 | dev_dbg(rtd->socdev->dev, "psc_dma_free(pcm=%p)\n", pcm); | 353 | dev_dbg(rtd->platform->dev, "psc_dma_free(pcm=%p)\n", pcm); |
353 | 354 | ||
354 | for (stream = 0; stream < 2; stream++) { | 355 | for (stream = 0; stream < 2; stream++) { |
355 | substream = pcm->streams[stream].substream; | 356 | substream = pcm->streams[stream].substream; |
@@ -361,15 +362,13 @@ static void psc_dma_free(struct snd_pcm *pcm) | |||
361 | } | 362 | } |
362 | } | 363 | } |
363 | 364 | ||
364 | struct snd_soc_platform mpc5200_audio_dma_platform = { | 365 | static struct snd_soc_platform_driver mpc5200_audio_dma_platform = { |
365 | .name = "mpc5200-psc-audio", | 366 | .ops = &psc_dma_ops, |
366 | .pcm_ops = &psc_dma_ops, | ||
367 | .pcm_new = &psc_dma_new, | 367 | .pcm_new = &psc_dma_new, |
368 | .pcm_free = &psc_dma_free, | 368 | .pcm_free = &psc_dma_free, |
369 | }; | 369 | }; |
370 | EXPORT_SYMBOL_GPL(mpc5200_audio_dma_platform); | ||
371 | 370 | ||
372 | int mpc5200_audio_dma_create(struct platform_device *op) | 371 | static int mpc5200_hpcd_probe(struct of_device *op) |
373 | { | 372 | { |
374 | phys_addr_t fifo; | 373 | phys_addr_t fifo; |
375 | struct psc_dma *psc_dma; | 374 | struct psc_dma *psc_dma; |
@@ -475,7 +474,7 @@ int mpc5200_audio_dma_create(struct platform_device *op) | |||
475 | dev_set_drvdata(&op->dev, psc_dma); | 474 | dev_set_drvdata(&op->dev, psc_dma); |
476 | 475 | ||
477 | /* Tell the ASoC OF helpers about it */ | 476 | /* Tell the ASoC OF helpers about it */ |
478 | return snd_soc_register_platform(&mpc5200_audio_dma_platform); | 477 | return snd_soc_register_platform(&op->dev, &mpc5200_audio_dma_platform); |
479 | out_irq: | 478 | out_irq: |
480 | free_irq(psc_dma->irq, psc_dma); | 479 | free_irq(psc_dma->irq, psc_dma); |
481 | free_irq(psc_dma->capture.irq, &psc_dma->capture); | 480 | free_irq(psc_dma->capture.irq, &psc_dma->capture); |
@@ -486,15 +485,14 @@ out_unmap: | |||
486 | iounmap(regs); | 485 | iounmap(regs); |
487 | return ret; | 486 | return ret; |
488 | } | 487 | } |
489 | EXPORT_SYMBOL_GPL(mpc5200_audio_dma_create); | ||
490 | 488 | ||
491 | int mpc5200_audio_dma_destroy(struct platform_device *op) | 489 | static int mpc5200_hpcd_remove(struct of_device *op) |
492 | { | 490 | { |
493 | struct psc_dma *psc_dma = dev_get_drvdata(&op->dev); | 491 | struct psc_dma *psc_dma = dev_get_drvdata(&op->dev); |
494 | 492 | ||
495 | dev_dbg(&op->dev, "mpc5200_audio_dma_destroy()\n"); | 493 | dev_dbg(&op->dev, "mpc5200_audio_dma_destroy()\n"); |
496 | 494 | ||
497 | snd_soc_unregister_platform(&mpc5200_audio_dma_platform); | 495 | snd_soc_unregister_platform(&op->dev); |
498 | 496 | ||
499 | bcom_gen_bd_rx_release(psc_dma->capture.bcom_task); | 497 | bcom_gen_bd_rx_release(psc_dma->capture.bcom_task); |
500 | bcom_gen_bd_tx_release(psc_dma->playback.bcom_task); | 498 | bcom_gen_bd_tx_release(psc_dma->playback.bcom_task); |
@@ -510,7 +508,34 @@ int mpc5200_audio_dma_destroy(struct platform_device *op) | |||
510 | 508 | ||
511 | return 0; | 509 | return 0; |
512 | } | 510 | } |
513 | EXPORT_SYMBOL_GPL(mpc5200_audio_dma_destroy); | 511 | |
512 | static struct of_device_id mpc5200_hpcd_match[] = { | ||
513 | { .compatible = "fsl,mpc5200-pcm", }, | ||
514 | {} | ||
515 | }; | ||
516 | MODULE_DEVICE_TABLE(of, mpc5200_hpcd_match); | ||
517 | |||
518 | static struct platform_driver mpc5200_hpcd_of_driver = { | ||
519 | .probe = mpc5200_hpcd_probe, | ||
520 | .remove = mpc5200_hpcd_remove, | ||
521 | .dev = { | ||
522 | .owner = THIS_MODULE, | ||
523 | .name = "mpc5200-pcm-audio", | ||
524 | .of_match_table = mpc5200_hpcd_match, | ||
525 | } | ||
526 | }; | ||
527 | |||
528 | static int __init mpc5200_hpcd_init(void) | ||
529 | { | ||
530 | return platform_driver_register(&mpc5200_hpcd_of_driver); | ||
531 | } | ||
532 | module_init(mpc5200_hpcd_init); | ||
533 | |||
534 | static void __exit mpc5200_hpcd_exit(void) | ||
535 | { | ||
536 | platform_driver_unregister(&mpc5200_hpcd_of_driver); | ||
537 | } | ||
538 | module_exit(mpc5200_hpcd_exit); | ||
514 | 539 | ||
515 | MODULE_AUTHOR("Grant Likely <grant.likely@secretlab.ca>"); | 540 | MODULE_AUTHOR("Grant Likely <grant.likely@secretlab.ca>"); |
516 | MODULE_DESCRIPTION("Freescale MPC5200 PSC in DMA mode ASoC Driver"); | 541 | MODULE_DESCRIPTION("Freescale MPC5200 PSC in DMA mode ASoC Driver"); |