db1200.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. /*
  2. * DB1200 ASoC audio fabric support code.
  3. *
  4. * (c) 2008-9 Manuel Lauss <manuel.lauss@gmail.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. /*------------------------- AC97 PART ---------------------------*/
  22. static struct snd_soc_dai_link db1200_ac97_dai = {
  23. .name = "AC97",
  24. .stream_name = "AC97 HiFi",
  25. .codec_dai_name = "ac97-hifi",
  26. .cpu_dai_name = "au1xpsc_ac97.1",
  27. .platform_name = "au1xpsc-pcm.1",
  28. .codec_name = "ac97-codec.1",
  29. };
  30. static struct snd_soc_card db1200_ac97_machine = {
  31. .name = "DB1200_AC97",
  32. .dai_link = &db1200_ac97_dai,
  33. .num_links = 1,
  34. };
  35. /*------------------------- I2S PART ---------------------------*/
  36. static int db1200_i2s_startup(struct snd_pcm_substream *substream)
  37. {
  38. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  39. struct snd_soc_dai *codec_dai = rtd->codec_dai;
  40. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  41. int ret;
  42. /* WM8731 has its own 12MHz crystal */
  43. snd_soc_dai_set_sysclk(codec_dai, WM8731_SYSCLK_XTAL,
  44. 12000000, SND_SOC_CLOCK_IN);
  45. /* codec is bitclock and lrclk master */
  46. ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_LEFT_J |
  47. SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM);
  48. if (ret < 0)
  49. goto out;
  50. ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_LEFT_J |
  51. SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM);
  52. if (ret < 0)
  53. goto out;
  54. ret = 0;
  55. out:
  56. return ret;
  57. }
  58. static struct snd_soc_ops db1200_i2s_wm8731_ops = {
  59. .startup = db1200_i2s_startup,
  60. };
  61. static struct snd_soc_dai_link db1200_i2s_dai = {
  62. .name = "WM8731",
  63. .stream_name = "WM8731 PCM",
  64. .codec_dai_name = "wm8731-hifi",
  65. .cpu_dai_name = "au1xpsc_i2s.1",
  66. .platform_name = "au1xpsc-pcm.1",
  67. .codec_name = "wm8731.0-001b",
  68. .ops = &db1200_i2s_wm8731_ops,
  69. };
  70. static struct snd_soc_card db1200_i2s_machine = {
  71. .name = "DB1200_I2S",
  72. .dai_link = &db1200_i2s_dai,
  73. .num_links = 1,
  74. };
  75. /*------------------------- COMMON PART ---------------------------*/
  76. static struct platform_device *db1200_asoc_dev;
  77. static int __init db1200_audio_load(void)
  78. {
  79. int ret;
  80. ret = -ENOMEM;
  81. db1200_asoc_dev = platform_device_alloc("soc-audio", 1); /* PSC1 */
  82. if (!db1200_asoc_dev)
  83. goto out;
  84. /* DB1200 board setup set PSC1MUX to preferred audio device */
  85. if (bcsr_read(BCSR_RESETS) & BCSR_RESETS_PSC1MUX)
  86. platform_set_drvdata(db1200_asoc_dev, &db1200_i2s_machine);
  87. else
  88. platform_set_drvdata(db1200_asoc_dev, &db1200_ac97_machine);
  89. ret = platform_device_add(db1200_asoc_dev);
  90. if (ret) {
  91. platform_device_put(db1200_asoc_dev);
  92. db1200_asoc_dev = NULL;
  93. }
  94. out:
  95. return ret;
  96. }
  97. static void __exit db1200_audio_unload(void)
  98. {
  99. platform_device_unregister(db1200_asoc_dev);
  100. }
  101. module_init(db1200_audio_load);
  102. module_exit(db1200_audio_unload);
  103. MODULE_LICENSE("GPL");
  104. MODULE_DESCRIPTION("DB1200 ASoC audio support");
  105. MODULE_AUTHOR("Manuel Lauss");