db1200.c 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  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. .dai_link = &db1200_ac97_dai,
  55. .num_links = 1,
  56. };
  57. static struct snd_soc_dai_link db1300_ac97_dai = {
  58. .name = "AC97",
  59. .stream_name = "AC97 HiFi",
  60. .codec_dai_name = "wm9712-hifi",
  61. .cpu_dai_name = "au1xpsc_ac97.1",
  62. .platform_name = "au1xpsc-pcm.1",
  63. .codec_name = "wm9712-codec.1",
  64. };
  65. static struct snd_soc_card db1300_ac97_machine = {
  66. .name = "DB1300_AC97",
  67. .dai_link = &db1300_ac97_dai,
  68. .num_links = 1,
  69. };
  70. static struct snd_soc_card db1550_ac97_machine = {
  71. .name = "DB1550_AC97",
  72. .dai_link = &db1200_ac97_dai,
  73. .num_links = 1,
  74. };
  75. /*------------------------- I2S PART ---------------------------*/
  76. static int db1200_i2s_startup(struct snd_pcm_substream *substream)
  77. {
  78. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  79. struct snd_soc_dai *codec_dai = rtd->codec_dai;
  80. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  81. int ret;
  82. /* WM8731 has its own 12MHz crystal */
  83. snd_soc_dai_set_sysclk(codec_dai, WM8731_SYSCLK_XTAL,
  84. 12000000, SND_SOC_CLOCK_IN);
  85. /* codec is bitclock and lrclk master */
  86. ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_LEFT_J |
  87. SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM);
  88. if (ret < 0)
  89. goto out;
  90. ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_LEFT_J |
  91. SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM);
  92. if (ret < 0)
  93. goto out;
  94. ret = 0;
  95. out:
  96. return ret;
  97. }
  98. static struct snd_soc_ops db1200_i2s_wm8731_ops = {
  99. .startup = db1200_i2s_startup,
  100. };
  101. static struct snd_soc_dai_link db1200_i2s_dai = {
  102. .name = "WM8731",
  103. .stream_name = "WM8731 PCM",
  104. .codec_dai_name = "wm8731-hifi",
  105. .cpu_dai_name = "au1xpsc_i2s.1",
  106. .platform_name = "au1xpsc-pcm.1",
  107. .codec_name = "wm8731.0-001b",
  108. .ops = &db1200_i2s_wm8731_ops,
  109. };
  110. static struct snd_soc_card db1200_i2s_machine = {
  111. .name = "DB1200_I2S",
  112. .dai_link = &db1200_i2s_dai,
  113. .num_links = 1,
  114. };
  115. static struct snd_soc_dai_link db1300_i2s_dai = {
  116. .name = "WM8731",
  117. .stream_name = "WM8731 PCM",
  118. .codec_dai_name = "wm8731-hifi",
  119. .cpu_dai_name = "au1xpsc_i2s.2",
  120. .platform_name = "au1xpsc-pcm.2",
  121. .codec_name = "wm8731.0-001b",
  122. .ops = &db1200_i2s_wm8731_ops,
  123. };
  124. static struct snd_soc_card db1300_i2s_machine = {
  125. .name = "DB1300_I2S",
  126. .dai_link = &db1300_i2s_dai,
  127. .num_links = 1,
  128. };
  129. static struct snd_soc_dai_link db1550_i2s_dai = {
  130. .name = "WM8731",
  131. .stream_name = "WM8731 PCM",
  132. .codec_dai_name = "wm8731-hifi",
  133. .cpu_dai_name = "au1xpsc_i2s.3",
  134. .platform_name = "au1xpsc-pcm.3",
  135. .codec_name = "wm8731.0-001b",
  136. .ops = &db1200_i2s_wm8731_ops,
  137. };
  138. static struct snd_soc_card db1550_i2s_machine = {
  139. .name = "DB1550_I2S",
  140. .dai_link = &db1550_i2s_dai,
  141. .num_links = 1,
  142. };
  143. /*------------------------- COMMON PART ---------------------------*/
  144. static struct snd_soc_card *db1200_cards[] __devinitdata = {
  145. &db1200_ac97_machine,
  146. &db1200_i2s_machine,
  147. &db1300_ac97_machine,
  148. &db1300_i2s_machine,
  149. &db1550_ac97_machine,
  150. &db1550_i2s_machine,
  151. };
  152. static int __devinit db1200_audio_probe(struct platform_device *pdev)
  153. {
  154. const struct platform_device_id *pid = platform_get_device_id(pdev);
  155. struct snd_soc_card *card;
  156. card = db1200_cards[pid->driver_data];
  157. card->dev = &pdev->dev;
  158. return snd_soc_register_card(card);
  159. }
  160. static int __devexit db1200_audio_remove(struct platform_device *pdev)
  161. {
  162. struct snd_soc_card *card = platform_get_drvdata(pdev);
  163. snd_soc_unregister_card(card);
  164. return 0;
  165. }
  166. static struct platform_driver db1200_audio_driver = {
  167. .driver = {
  168. .name = "db1200-ac97",
  169. .owner = THIS_MODULE,
  170. .pm = &snd_soc_pm_ops,
  171. },
  172. .id_table = db1200_pids,
  173. .probe = db1200_audio_probe,
  174. .remove = __devexit_p(db1200_audio_remove),
  175. };
  176. static int __init db1200_audio_load(void)
  177. {
  178. return platform_driver_register(&db1200_audio_driver);
  179. }
  180. static void __exit db1200_audio_unload(void)
  181. {
  182. platform_driver_unregister(&db1200_audio_driver);
  183. }
  184. module_init(db1200_audio_load);
  185. module_exit(db1200_audio_unload);
  186. MODULE_LICENSE("GPL");
  187. MODULE_DESCRIPTION("DB1200/DB1300/DB1550 ASoC audio support");
  188. MODULE_AUTHOR("Manuel Lauss");