phycore-ac97.c 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. /*
  2. * phycore-ac97.c -- SoC audio for imx_phycore in AC97 mode
  3. *
  4. * Copyright 2009 Sascha Hauer, Pengutronix <s.hauer@pengutronix.de>
  5. *
  6. * This program is free software; you can redistribute it and/or modify it
  7. * under the terms of the GNU General Public License as published by the
  8. * Free Software Foundation; either version 2 of the License, or (at your
  9. * option) any later version.
  10. *
  11. */
  12. #include <linux/module.h>
  13. #include <linux/moduleparam.h>
  14. #include <linux/device.h>
  15. #include <linux/i2c.h>
  16. #include <sound/core.h>
  17. #include <sound/pcm.h>
  18. #include <sound/soc.h>
  19. #include <asm/mach-types.h>
  20. #include "imx-audmux.h"
  21. static struct snd_soc_card imx_phycore;
  22. static struct snd_soc_ops imx_phycore_hifi_ops = {
  23. };
  24. static struct snd_soc_dai_link imx_phycore_dai_ac97[] = {
  25. {
  26. .name = "HiFi",
  27. .stream_name = "HiFi",
  28. .codec_dai_name = "wm9712-hifi",
  29. .codec_name = "wm9712-codec",
  30. .cpu_dai_name = "imx-ssi.0",
  31. .platform_name = "imx-ssi.0",
  32. .ops = &imx_phycore_hifi_ops,
  33. },
  34. };
  35. static struct snd_soc_card imx_phycore = {
  36. .name = "PhyCORE-ac97-audio",
  37. .owner = THIS_MODULE,
  38. .dai_link = imx_phycore_dai_ac97,
  39. .num_links = ARRAY_SIZE(imx_phycore_dai_ac97),
  40. };
  41. static struct platform_device *imx_phycore_snd_ac97_device;
  42. static struct platform_device *imx_phycore_snd_device;
  43. static int __init imx_phycore_init(void)
  44. {
  45. int ret;
  46. if (machine_is_pca100()) {
  47. imx_audmux_v1_configure_port(MX27_AUDMUX_HPCR1_SSI0,
  48. IMX_AUDMUX_V1_PCR_SYN | /* 4wire mode */
  49. IMX_AUDMUX_V1_PCR_TFCSEL(3) |
  50. IMX_AUDMUX_V1_PCR_TCLKDIR | /* clock is output */
  51. IMX_AUDMUX_V1_PCR_RXDSEL(3));
  52. imx_audmux_v1_configure_port(3,
  53. IMX_AUDMUX_V1_PCR_SYN | /* 4wire mode */
  54. IMX_AUDMUX_V1_PCR_TFCSEL(0) |
  55. IMX_AUDMUX_V1_PCR_TFSDIR |
  56. IMX_AUDMUX_V1_PCR_RXDSEL(0));
  57. } else if (machine_is_pcm043()) {
  58. imx_audmux_v2_configure_port(3,
  59. IMX_AUDMUX_V2_PTCR_SYN | /* 4wire mode */
  60. IMX_AUDMUX_V2_PTCR_TFSEL(0) |
  61. IMX_AUDMUX_V2_PTCR_TFSDIR,
  62. IMX_AUDMUX_V2_PDCR_RXDSEL(0));
  63. imx_audmux_v2_configure_port(0,
  64. IMX_AUDMUX_V2_PTCR_SYN | /* 4wire mode */
  65. IMX_AUDMUX_V2_PTCR_TCSEL(3) |
  66. IMX_AUDMUX_V2_PTCR_TCLKDIR, /* clock is output */
  67. IMX_AUDMUX_V2_PDCR_RXDSEL(3));
  68. } else {
  69. /* return happy. We might run on a totally different machine */
  70. return 0;
  71. }
  72. imx_phycore_snd_ac97_device = platform_device_alloc("soc-audio", -1);
  73. if (!imx_phycore_snd_ac97_device)
  74. return -ENOMEM;
  75. platform_set_drvdata(imx_phycore_snd_ac97_device, &imx_phycore);
  76. ret = platform_device_add(imx_phycore_snd_ac97_device);
  77. if (ret)
  78. goto fail1;
  79. imx_phycore_snd_device = platform_device_alloc("wm9712-codec", -1);
  80. if (!imx_phycore_snd_device) {
  81. ret = -ENOMEM;
  82. goto fail2;
  83. }
  84. ret = platform_device_add(imx_phycore_snd_device);
  85. if (ret) {
  86. printk(KERN_ERR "ASoC: Platform device allocation failed\n");
  87. goto fail3;
  88. }
  89. return 0;
  90. fail3:
  91. platform_device_put(imx_phycore_snd_device);
  92. fail2:
  93. platform_device_del(imx_phycore_snd_ac97_device);
  94. fail1:
  95. platform_device_put(imx_phycore_snd_ac97_device);
  96. return ret;
  97. }
  98. static void __exit imx_phycore_exit(void)
  99. {
  100. platform_device_unregister(imx_phycore_snd_device);
  101. platform_device_unregister(imx_phycore_snd_ac97_device);
  102. }
  103. late_initcall(imx_phycore_init);
  104. module_exit(imx_phycore_exit);
  105. MODULE_AUTHOR("Sascha Hauer <s.hauer@pengutronix.de>");
  106. MODULE_DESCRIPTION("PhyCORE ALSA SoC driver");
  107. MODULE_LICENSE("GPL");