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