db1200.c 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  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. .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. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  84. int ret;
  85. /* WM8731 has its own 12MHz crystal */
  86. snd_soc_dai_set_sysclk(codec_dai, WM8731_SYSCLK_XTAL,
  87. 12000000, SND_SOC_CLOCK_IN);
  88. /* codec is bitclock and lrclk master */
  89. ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_LEFT_J |
  90. SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM);
  91. if (ret < 0)
  92. goto out;
  93. ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_LEFT_J |
  94. SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM);
  95. if (ret < 0)
  96. goto out;
  97. ret = 0;
  98. out:
  99. return ret;
  100. }
  101. static struct snd_soc_ops db1200_i2s_wm8731_ops = {
  102. .startup = db1200_i2s_startup,
  103. };
  104. static struct snd_soc_dai_link db1200_i2s_dai = {
  105. .name = "WM8731",
  106. .stream_name = "WM8731 PCM",
  107. .codec_dai_name = "wm8731-hifi",
  108. .cpu_dai_name = "au1xpsc_i2s.1",
  109. .platform_name = "au1xpsc-pcm.1",
  110. .codec_name = "wm8731.0-001b",
  111. .ops = &db1200_i2s_wm8731_ops,
  112. };
  113. static struct snd_soc_card db1200_i2s_machine = {
  114. .name = "DB1200_I2S",
  115. .owner = THIS_MODULE,
  116. .dai_link = &db1200_i2s_dai,
  117. .num_links = 1,
  118. };
  119. static struct snd_soc_dai_link db1300_i2s_dai = {
  120. .name = "WM8731",
  121. .stream_name = "WM8731 PCM",
  122. .codec_dai_name = "wm8731-hifi",
  123. .cpu_dai_name = "au1xpsc_i2s.2",
  124. .platform_name = "au1xpsc-pcm.2",
  125. .codec_name = "wm8731.0-001b",
  126. .ops = &db1200_i2s_wm8731_ops,
  127. };
  128. static struct snd_soc_card db1300_i2s_machine = {
  129. .name = "DB1300_I2S",
  130. .owner = THIS_MODULE,
  131. .dai_link = &db1300_i2s_dai,
  132. .num_links = 1,
  133. };
  134. static struct snd_soc_dai_link db1550_i2s_dai = {
  135. .name = "WM8731",
  136. .stream_name = "WM8731 PCM",
  137. .codec_dai_name = "wm8731-hifi",
  138. .cpu_dai_name = "au1xpsc_i2s.3",
  139. .platform_name = "au1xpsc-pcm.3",
  140. .codec_name = "wm8731.0-001b",
  141. .ops = &db1200_i2s_wm8731_ops,
  142. };
  143. static struct snd_soc_card db1550_i2s_machine = {
  144. .name = "DB1550_I2S",
  145. .owner = THIS_MODULE,
  146. .dai_link = &db1550_i2s_dai,
  147. .num_links = 1,
  148. };
  149. /*------------------------- COMMON PART ---------------------------*/
  150. static struct snd_soc_card *db1200_cards[] = {
  151. &db1200_ac97_machine,
  152. &db1200_i2s_machine,
  153. &db1300_ac97_machine,
  154. &db1300_i2s_machine,
  155. &db1550_ac97_machine,
  156. &db1550_i2s_machine,
  157. };
  158. static int db1200_audio_probe(struct platform_device *pdev)
  159. {
  160. const struct platform_device_id *pid = platform_get_device_id(pdev);
  161. struct snd_soc_card *card;
  162. card = db1200_cards[pid->driver_data];
  163. card->dev = &pdev->dev;
  164. return snd_soc_register_card(card);
  165. }
  166. static int db1200_audio_remove(struct platform_device *pdev)
  167. {
  168. struct snd_soc_card *card = platform_get_drvdata(pdev);
  169. snd_soc_unregister_card(card);
  170. return 0;
  171. }
  172. static struct platform_driver db1200_audio_driver = {
  173. .driver = {
  174. .name = "db1200-ac97",
  175. .owner = THIS_MODULE,
  176. .pm = &snd_soc_pm_ops,
  177. },
  178. .id_table = db1200_pids,
  179. .probe = db1200_audio_probe,
  180. .remove = db1200_audio_remove,
  181. };
  182. module_platform_driver(db1200_audio_driver);
  183. MODULE_LICENSE("GPL");
  184. MODULE_DESCRIPTION("DB1200/DB1300/DB1550 ASoC audio support");
  185. MODULE_AUTHOR("Manuel Lauss");