db1200.c 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. /*
  2. * DB1200/DB1300/DB1550 ASoC audio fabric support code.
  3. *
  4. * (c) 2008-2011 Manuel Lauss <manuel.lauss@googlemail.com>
  5. *
  6. */
  7. #include <linux/module.h>
  8. #include <linux/moduleparam.h>
  9. #include <linux/timer.h>
  10. #include <linux/interrupt.h>
  11. #include <linux/platform_device.h>
  12. #include <sound/core.h>
  13. #include <sound/pcm.h>
  14. #include <sound/soc.h>
  15. #include <asm/mach-au1x00/au1000.h>
  16. #include <asm/mach-au1x00/au1xxx_psc.h>
  17. #include <asm/mach-au1x00/au1xxx_dbdma.h>
  18. #include <asm/mach-db1x00/bcsr.h>
  19. #include "../codecs/wm8731.h"
  20. #include "psc.h"
  21. static struct platform_device_id db1200_pids[] = {
  22. {
  23. .name = "db1200-ac97",
  24. .driver_data = 0,
  25. }, {
  26. .name = "db1200-i2s",
  27. .driver_data = 1,
  28. }, {
  29. .name = "db1300-ac97",
  30. .driver_data = 2,
  31. }, {
  32. .name = "db1300-i2s",
  33. .driver_data = 3,
  34. }, {
  35. .name = "db1550-ac97",
  36. .driver_data = 4,
  37. }, {
  38. .name = "db1550-i2s",
  39. .driver_data = 5,
  40. },
  41. {},
  42. };
  43. /*------------------------- AC97 PART ---------------------------*/
  44. static struct snd_soc_dai_link db1200_ac97_dai = {
  45. .name = "AC97",
  46. .stream_name = "AC97 HiFi",
  47. .codec_dai_name = "ac97-hifi",
  48. .cpu_dai_name = "au1xpsc_ac97.1",
  49. .platform_name = "au1xpsc-pcm.1",
  50. .codec_name = "ac97-codec.1",
  51. };
  52. static struct snd_soc_card db1200_ac97_machine = {
  53. .name = "DB1200_AC97",
  54. .owner = THIS_MODULE,
  55. .dai_link = &db1200_ac97_dai,
  56. .num_links = 1,
  57. };
  58. static struct snd_soc_dai_link db1300_ac97_dai = {
  59. .name = "AC97",
  60. .stream_name = "AC97 HiFi",
  61. .codec_dai_name = "wm9712-hifi",
  62. .cpu_dai_name = "au1xpsc_ac97.1",
  63. .platform_name = "au1xpsc-pcm.1",
  64. .codec_name = "wm9712-codec.1",
  65. };
  66. static struct snd_soc_card db1300_ac97_machine = {
  67. .name = "DB1300_AC97",
  68. .dai_link = &db1300_ac97_dai,
  69. .num_links = 1,
  70. };
  71. static struct snd_soc_card db1550_ac97_machine = {
  72. .name = "DB1550_AC97",
  73. .dai_link = &db1200_ac97_dai,
  74. .num_links = 1,
  75. };
  76. /*------------------------- I2S PART ---------------------------*/
  77. static int db1200_i2s_startup(struct snd_pcm_substream *substream)
  78. {
  79. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  80. struct snd_soc_dai *codec_dai = rtd->codec_dai;
  81. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  82. int ret;
  83. /* WM8731 has its own 12MHz crystal */
  84. snd_soc_dai_set_sysclk(codec_dai, WM8731_SYSCLK_XTAL,
  85. 12000000, SND_SOC_CLOCK_IN);
  86. /* codec is bitclock and lrclk master */
  87. ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_LEFT_J |
  88. SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM);
  89. if (ret < 0)
  90. goto out;
  91. ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_LEFT_J |
  92. SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM);
  93. if (ret < 0)
  94. goto out;
  95. ret = 0;
  96. out:
  97. return ret;
  98. }
  99. static struct snd_soc_ops db1200_i2s_wm8731_ops = {
  100. .startup = db1200_i2s_startup,
  101. };
  102. static struct snd_soc_dai_link db1200_i2s_dai = {
  103. .name = "WM8731",
  104. .stream_name = "WM8731 PCM",
  105. .codec_dai_name = "wm8731-hifi",
  106. .cpu_dai_name = "au1xpsc_i2s.1",
  107. .platform_name = "au1xpsc-pcm.1",
  108. .codec_name = "wm8731.0-001b",
  109. .ops = &db1200_i2s_wm8731_ops,
  110. };
  111. static struct snd_soc_card db1200_i2s_machine = {
  112. .name = "DB1200_I2S",
  113. .owner = THIS_MODULE,
  114. .dai_link = &db1200_i2s_dai,
  115. .num_links = 1,
  116. };
  117. static struct snd_soc_dai_link db1300_i2s_dai = {
  118. .name = "WM8731",
  119. .stream_name = "WM8731 PCM",
  120. .codec_dai_name = "wm8731-hifi",
  121. .cpu_dai_name = "au1xpsc_i2s.2",
  122. .platform_name = "au1xpsc-pcm.2",
  123. .codec_name = "wm8731.0-001b",
  124. .ops = &db1200_i2s_wm8731_ops,
  125. };
  126. static struct snd_soc_card db1300_i2s_machine = {
  127. .name = "DB1300_I2S",
  128. .dai_link = &db1300_i2s_dai,
  129. .num_links = 1,
  130. };
  131. static struct snd_soc_dai_link db1550_i2s_dai = {
  132. .name = "WM8731",
  133. .stream_name = "WM8731 PCM",
  134. .codec_dai_name = "wm8731-hifi",
  135. .cpu_dai_name = "au1xpsc_i2s.3",
  136. .platform_name = "au1xpsc-pcm.3",
  137. .codec_name = "wm8731.0-001b",
  138. .ops = &db1200_i2s_wm8731_ops,
  139. };
  140. static struct snd_soc_card db1550_i2s_machine = {
  141. .name = "DB1550_I2S",
  142. .dai_link = &db1550_i2s_dai,
  143. .num_links = 1,
  144. };
  145. /*------------------------- COMMON PART ---------------------------*/
  146. static struct snd_soc_card *db1200_cards[] __devinitdata = {
  147. &db1200_ac97_machine,
  148. &db1200_i2s_machine,
  149. &db1300_ac97_machine,
  150. &db1300_i2s_machine,
  151. &db1550_ac97_machine,
  152. &db1550_i2s_machine,
  153. };
  154. static int __devinit db1200_audio_probe(struct platform_device *pdev)
  155. {
  156. const struct platform_device_id *pid = platform_get_device_id(pdev);
  157. struct snd_soc_card *card;
  158. card = db1200_cards[pid->driver_data];
  159. card->dev = &pdev->dev;
  160. return snd_soc_register_card(card);
  161. }
  162. static int __devexit db1200_audio_remove(struct platform_device *pdev)
  163. {
  164. struct snd_soc_card *card = platform_get_drvdata(pdev);
  165. snd_soc_unregister_card(card);
  166. return 0;
  167. }
  168. static struct platform_driver db1200_audio_driver = {
  169. .driver = {
  170. .name = "db1200-ac97",
  171. .owner = THIS_MODULE,
  172. .pm = &snd_soc_pm_ops,
  173. },
  174. .id_table = db1200_pids,
  175. .probe = db1200_audio_probe,
  176. .remove = __devexit_p(db1200_audio_remove),
  177. };
  178. module_platform_driver(db1200_audio_driver);
  179. MODULE_LICENSE("GPL");
  180. MODULE_DESCRIPTION("DB1200/DB1300/DB1550 ASoC audio support");
  181. MODULE_AUTHOR("Manuel Lauss");