db1200.c 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  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 const 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. .owner = THIS_MODULE,
  69. .dai_link = &db1300_ac97_dai,
  70. .num_links = 1,
  71. };
  72. static struct snd_soc_card db1550_ac97_machine = {
  73. .name = "DB1550_AC97",
  74. .owner = THIS_MODULE,
  75. .dai_link = &db1200_ac97_dai,
  76. .num_links = 1,
  77. };
  78. /*------------------------- I2S PART ---------------------------*/
  79. static int db1200_i2s_startup(struct snd_pcm_substream *substream)
  80. {
  81. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  82. struct snd_soc_dai *codec_dai = rtd->codec_dai;
  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. return 0;
  87. }
  88. static struct snd_soc_ops db1200_i2s_wm8731_ops = {
  89. .startup = db1200_i2s_startup,
  90. };
  91. static struct snd_soc_dai_link db1200_i2s_dai = {
  92. .name = "WM8731",
  93. .stream_name = "WM8731 PCM",
  94. .codec_dai_name = "wm8731-hifi",
  95. .cpu_dai_name = "au1xpsc_i2s.1",
  96. .platform_name = "au1xpsc-pcm.1",
  97. .codec_name = "wm8731.0-001b",
  98. .dai_fmt = SND_SOC_DAIFMT_LEFT_J | SND_SOC_DAIFMT_NB_NF |
  99. SND_SOC_DAIFMT_CBM_CFM,
  100. .ops = &db1200_i2s_wm8731_ops,
  101. };
  102. static struct snd_soc_card db1200_i2s_machine = {
  103. .name = "DB1200_I2S",
  104. .owner = THIS_MODULE,
  105. .dai_link = &db1200_i2s_dai,
  106. .num_links = 1,
  107. };
  108. static struct snd_soc_dai_link db1300_i2s_dai = {
  109. .name = "WM8731",
  110. .stream_name = "WM8731 PCM",
  111. .codec_dai_name = "wm8731-hifi",
  112. .cpu_dai_name = "au1xpsc_i2s.2",
  113. .platform_name = "au1xpsc-pcm.2",
  114. .codec_name = "wm8731.0-001b",
  115. .dai_fmt = SND_SOC_DAIFMT_LEFT_J | SND_SOC_DAIFMT_NB_NF |
  116. SND_SOC_DAIFMT_CBM_CFM,
  117. .ops = &db1200_i2s_wm8731_ops,
  118. };
  119. static struct snd_soc_card db1300_i2s_machine = {
  120. .name = "DB1300_I2S",
  121. .owner = THIS_MODULE,
  122. .dai_link = &db1300_i2s_dai,
  123. .num_links = 1,
  124. };
  125. static struct snd_soc_dai_link db1550_i2s_dai = {
  126. .name = "WM8731",
  127. .stream_name = "WM8731 PCM",
  128. .codec_dai_name = "wm8731-hifi",
  129. .cpu_dai_name = "au1xpsc_i2s.3",
  130. .platform_name = "au1xpsc-pcm.3",
  131. .codec_name = "wm8731.0-001b",
  132. .dai_fmt = SND_SOC_DAIFMT_LEFT_J | SND_SOC_DAIFMT_NB_NF |
  133. SND_SOC_DAIFMT_CBM_CFM,
  134. .ops = &db1200_i2s_wm8731_ops,
  135. };
  136. static struct snd_soc_card db1550_i2s_machine = {
  137. .name = "DB1550_I2S",
  138. .owner = THIS_MODULE,
  139. .dai_link = &db1550_i2s_dai,
  140. .num_links = 1,
  141. };
  142. /*------------------------- COMMON PART ---------------------------*/
  143. static struct snd_soc_card *db1200_cards[] = {
  144. &db1200_ac97_machine,
  145. &db1200_i2s_machine,
  146. &db1300_ac97_machine,
  147. &db1300_i2s_machine,
  148. &db1550_ac97_machine,
  149. &db1550_i2s_machine,
  150. };
  151. static int db1200_audio_probe(struct platform_device *pdev)
  152. {
  153. const struct platform_device_id *pid = platform_get_device_id(pdev);
  154. struct snd_soc_card *card;
  155. card = db1200_cards[pid->driver_data];
  156. card->dev = &pdev->dev;
  157. return devm_snd_soc_register_card(&pdev->dev, card);
  158. }
  159. static struct platform_driver db1200_audio_driver = {
  160. .driver = {
  161. .name = "db1200-ac97",
  162. .pm = &snd_soc_pm_ops,
  163. },
  164. .id_table = db1200_pids,
  165. .probe = db1200_audio_probe,
  166. };
  167. module_platform_driver(db1200_audio_driver);
  168. MODULE_LICENSE("GPL");
  169. MODULE_DESCRIPTION("DB1200/DB1300/DB1550 ASoC audio support");
  170. MODULE_AUTHOR("Manuel Lauss");