diff options
Diffstat (limited to 'sound/soc/kirkwood/kirkwood-i2s.c')
-rw-r--r-- | sound/soc/kirkwood/kirkwood-i2s.c | 55 |
1 files changed, 31 insertions, 24 deletions
diff --git a/sound/soc/kirkwood/kirkwood-i2s.c b/sound/soc/kirkwood/kirkwood-i2s.c index 981ffc2a13c8..a33fc51f363b 100644 --- a/sound/soc/kirkwood/kirkwood-i2s.c +++ b/sound/soc/kirkwood/kirkwood-i2s.c | |||
@@ -2,6 +2,7 @@ | |||
2 | * kirkwood-i2s.c | 2 | * kirkwood-i2s.c |
3 | * | 3 | * |
4 | * (c) 2010 Arnaud Patard <apatard@mandriva.com> | 4 | * (c) 2010 Arnaud Patard <apatard@mandriva.com> |
5 | * (c) 2010 Arnaud Patard <arnaud.patard@rtp-net.org> | ||
5 | * | 6 | * |
6 | * This program is free software; you can redistribute it and/or modify it | 7 | * This program is free software; you can redistribute it and/or modify it |
7 | * under the terms of the GNU General Public License as published by the | 8 | * under the terms of the GNU General Public License as published by the |
@@ -20,7 +21,6 @@ | |||
20 | #include <sound/pcm_params.h> | 21 | #include <sound/pcm_params.h> |
21 | #include <sound/soc.h> | 22 | #include <sound/soc.h> |
22 | #include <plat/audio.h> | 23 | #include <plat/audio.h> |
23 | #include "kirkwood-i2s.h" | ||
24 | #include "kirkwood.h" | 24 | #include "kirkwood.h" |
25 | 25 | ||
26 | #define DRV_NAME "kirkwood-i2s" | 26 | #define DRV_NAME "kirkwood-i2s" |
@@ -33,13 +33,10 @@ | |||
33 | SNDRV_PCM_FMTBIT_S24_LE | \ | 33 | SNDRV_PCM_FMTBIT_S24_LE | \ |
34 | SNDRV_PCM_FMTBIT_S32_LE) | 34 | SNDRV_PCM_FMTBIT_S32_LE) |
35 | 35 | ||
36 | |||
37 | struct snd_soc_dai kirkwood_i2s_dai; | ||
38 | static struct kirkwood_dma_data *priv; | ||
39 | |||
40 | static int kirkwood_i2s_set_fmt(struct snd_soc_dai *cpu_dai, | 36 | static int kirkwood_i2s_set_fmt(struct snd_soc_dai *cpu_dai, |
41 | unsigned int fmt) | 37 | unsigned int fmt) |
42 | { | 38 | { |
39 | struct kirkwood_dma_data *priv = snd_soc_dai_get_drvdata(cpu_dai); | ||
43 | unsigned long mask; | 40 | unsigned long mask; |
44 | unsigned long value; | 41 | unsigned long value; |
45 | 42 | ||
@@ -101,10 +98,20 @@ static inline void kirkwood_set_dco(void __iomem *io, unsigned long rate) | |||
101 | } while (value == 0); | 98 | } while (value == 0); |
102 | } | 99 | } |
103 | 100 | ||
101 | static int kirkwood_i2s_startup(struct snd_pcm_substream *substream, | ||
102 | struct snd_soc_dai *dai) | ||
103 | { | ||
104 | struct kirkwood_dma_data *priv = snd_soc_dai_get_drvdata(dai); | ||
105 | |||
106 | snd_soc_dai_set_dma_data(dai, substream, priv); | ||
107 | return 0; | ||
108 | } | ||
109 | |||
104 | static int kirkwood_i2s_hw_params(struct snd_pcm_substream *substream, | 110 | static int kirkwood_i2s_hw_params(struct snd_pcm_substream *substream, |
105 | struct snd_pcm_hw_params *params, | 111 | struct snd_pcm_hw_params *params, |
106 | struct snd_soc_dai *dai) | 112 | struct snd_soc_dai *dai) |
107 | { | 113 | { |
114 | struct kirkwood_dma_data *priv = snd_soc_dai_get_drvdata(dai); | ||
108 | unsigned int i2s_reg, reg; | 115 | unsigned int i2s_reg, reg; |
109 | unsigned long i2s_value, value; | 116 | unsigned long i2s_value, value; |
110 | 117 | ||
@@ -171,6 +178,7 @@ static int kirkwood_i2s_hw_params(struct snd_pcm_substream *substream, | |||
171 | static int kirkwood_i2s_play_trigger(struct snd_pcm_substream *substream, | 178 | static int kirkwood_i2s_play_trigger(struct snd_pcm_substream *substream, |
172 | int cmd, struct snd_soc_dai *dai) | 179 | int cmd, struct snd_soc_dai *dai) |
173 | { | 180 | { |
181 | struct kirkwood_dma_data *priv = snd_soc_dai_get_drvdata(dai); | ||
174 | unsigned long value; | 182 | unsigned long value; |
175 | 183 | ||
176 | /* | 184 | /* |
@@ -244,6 +252,7 @@ static int kirkwood_i2s_play_trigger(struct snd_pcm_substream *substream, | |||
244 | static int kirkwood_i2s_rec_trigger(struct snd_pcm_substream *substream, | 252 | static int kirkwood_i2s_rec_trigger(struct snd_pcm_substream *substream, |
245 | int cmd, struct snd_soc_dai *dai) | 253 | int cmd, struct snd_soc_dai *dai) |
246 | { | 254 | { |
255 | struct kirkwood_dma_data *priv = snd_soc_dai_get_drvdata(dai); | ||
247 | unsigned long value; | 256 | unsigned long value; |
248 | 257 | ||
249 | value = readl(priv->io + KIRKWOOD_RECCTL); | 258 | value = readl(priv->io + KIRKWOOD_RECCTL); |
@@ -323,9 +332,9 @@ static int kirkwood_i2s_trigger(struct snd_pcm_substream *substream, int cmd, | |||
323 | return 0; | 332 | return 0; |
324 | } | 333 | } |
325 | 334 | ||
326 | static int kirkwood_i2s_probe(struct platform_device *pdev, | 335 | static int kirkwood_i2s_probe(struct snd_soc_dai *dai) |
327 | struct snd_soc_dai *dai) | ||
328 | { | 336 | { |
337 | struct kirkwood_dma_data *priv = snd_soc_dai_get_drvdata(dai); | ||
329 | unsigned long value; | 338 | unsigned long value; |
330 | unsigned int reg_data; | 339 | unsigned int reg_data; |
331 | 340 | ||
@@ -359,21 +368,20 @@ static int kirkwood_i2s_probe(struct platform_device *pdev, | |||
359 | 368 | ||
360 | } | 369 | } |
361 | 370 | ||
362 | static void kirkwood_i2s_remove(struct platform_device *pdev, | 371 | static int kirkwood_i2s_remove(struct snd_soc_dai *dai) |
363 | struct snd_soc_dai *dai) | ||
364 | { | 372 | { |
373 | return 0; | ||
365 | } | 374 | } |
366 | 375 | ||
367 | static struct snd_soc_dai_ops kirkwood_i2s_dai_ops = { | 376 | static struct snd_soc_dai_ops kirkwood_i2s_dai_ops = { |
377 | .startup = kirkwood_i2s_startup, | ||
368 | .trigger = kirkwood_i2s_trigger, | 378 | .trigger = kirkwood_i2s_trigger, |
369 | .hw_params = kirkwood_i2s_hw_params, | 379 | .hw_params = kirkwood_i2s_hw_params, |
370 | .set_fmt = kirkwood_i2s_set_fmt, | 380 | .set_fmt = kirkwood_i2s_set_fmt, |
371 | }; | 381 | }; |
372 | 382 | ||
373 | 383 | ||
374 | struct snd_soc_dai kirkwood_i2s_dai = { | 384 | static struct snd_soc_dai_driver kirkwood_i2s_dai = { |
375 | .name = DRV_NAME, | ||
376 | .id = 0, | ||
377 | .probe = kirkwood_i2s_probe, | 385 | .probe = kirkwood_i2s_probe, |
378 | .remove = kirkwood_i2s_remove, | 386 | .remove = kirkwood_i2s_remove, |
379 | .playback = { | 387 | .playback = { |
@@ -388,13 +396,13 @@ struct snd_soc_dai kirkwood_i2s_dai = { | |||
388 | .formats = KIRKWOOD_I2S_FORMATS,}, | 396 | .formats = KIRKWOOD_I2S_FORMATS,}, |
389 | .ops = &kirkwood_i2s_dai_ops, | 397 | .ops = &kirkwood_i2s_dai_ops, |
390 | }; | 398 | }; |
391 | EXPORT_SYMBOL_GPL(kirkwood_i2s_dai); | ||
392 | 399 | ||
393 | static __devinit int kirkwood_i2s_dev_probe(struct platform_device *pdev) | 400 | static __devinit int kirkwood_i2s_dev_probe(struct platform_device *pdev) |
394 | { | 401 | { |
395 | struct resource *mem; | 402 | struct resource *mem; |
396 | struct kirkwood_asoc_platform_data *data = | 403 | struct kirkwood_asoc_platform_data *data = |
397 | pdev->dev.platform_data; | 404 | pdev->dev.platform_data; |
405 | struct kirkwood_dma_data *priv; | ||
398 | int err; | 406 | int err; |
399 | 407 | ||
400 | priv = kzalloc(sizeof(struct kirkwood_dma_data), GFP_KERNEL); | 408 | priv = kzalloc(sizeof(struct kirkwood_dma_data), GFP_KERNEL); |
@@ -403,6 +411,7 @@ static __devinit int kirkwood_i2s_dev_probe(struct platform_device *pdev) | |||
403 | err = -ENOMEM; | 411 | err = -ENOMEM; |
404 | goto error; | 412 | goto error; |
405 | } | 413 | } |
414 | dev_set_drvdata(&pdev->dev, priv); | ||
406 | 415 | ||
407 | mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 416 | mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
408 | if (!mem) { | 417 | if (!mem) { |
@@ -441,10 +450,7 @@ static __devinit int kirkwood_i2s_dev_probe(struct platform_device *pdev) | |||
441 | priv->dram = data->dram; | 450 | priv->dram = data->dram; |
442 | priv->burst = data->burst; | 451 | priv->burst = data->burst; |
443 | 452 | ||
444 | kirkwood_i2s_dai.capture.dma_data = priv; | 453 | return snd_soc_register_dai(&pdev->dev, &kirkwood_i2s_dai); |
445 | kirkwood_i2s_dai.playback.dma_data = priv; | ||
446 | |||
447 | return snd_soc_register_dai(&kirkwood_i2s_dai); | ||
448 | 454 | ||
449 | err_ioremap: | 455 | err_ioremap: |
450 | iounmap(priv->io); | 456 | iounmap(priv->io); |
@@ -458,12 +464,13 @@ error: | |||
458 | 464 | ||
459 | static __devexit int kirkwood_i2s_dev_remove(struct platform_device *pdev) | 465 | static __devexit int kirkwood_i2s_dev_remove(struct platform_device *pdev) |
460 | { | 466 | { |
461 | if (priv) { | 467 | struct kirkwood_dma_data *priv = dev_get_drvdata(&pdev->dev); |
462 | iounmap(priv->io); | 468 | |
463 | release_mem_region(priv->mem->start, SZ_16K); | 469 | snd_soc_unregister_dai(&pdev->dev); |
464 | kfree(priv); | 470 | iounmap(priv->io); |
465 | } | 471 | release_mem_region(priv->mem->start, SZ_16K); |
466 | snd_soc_unregister_dai(&kirkwood_i2s_dai); | 472 | kfree(priv); |
473 | |||
467 | return 0; | 474 | return 0; |
468 | } | 475 | } |
469 | 476 | ||
@@ -489,7 +496,7 @@ static void __exit kirkwood_i2s_exit(void) | |||
489 | module_exit(kirkwood_i2s_exit); | 496 | module_exit(kirkwood_i2s_exit); |
490 | 497 | ||
491 | /* Module information */ | 498 | /* Module information */ |
492 | MODULE_AUTHOR("Arnaud Patard, <apatard@mandriva.com>"); | 499 | MODULE_AUTHOR("Arnaud Patard, <arnaud.patard@rtp-net.org>"); |
493 | MODULE_DESCRIPTION("Kirkwood I2S SoC Interface"); | 500 | MODULE_DESCRIPTION("Kirkwood I2S SoC Interface"); |
494 | MODULE_LICENSE("GPL"); | 501 | MODULE_LICENSE("GPL"); |
495 | MODULE_ALIAS("platform:kirkwood-i2s"); | 502 | MODULE_ALIAS("platform:kirkwood-i2s"); |