phycore-ac97.c 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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 <sound/soc-dapm.h>
  20. #include <asm/mach-types.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-fiq-pcm-audio.0",
  32. .ops = &imx_phycore_hifi_ops,
  33. },
  34. };
  35. static struct snd_soc_card imx_phycore = {
  36. .name = "PhyCORE-ac97-audio",
  37. .dai_link = imx_phycore_dai_ac97,
  38. .num_links = ARRAY_SIZE(imx_phycore_dai_ac97),
  39. };
  40. static struct platform_device *imx_phycore_snd_ac97_device;
  41. static struct platform_device *imx_phycore_snd_device;
  42. static int __init imx_phycore_init(void)
  43. {
  44. int ret;
  45. if (!machine_is_pcm043() && !machine_is_pca100())
  46. /* return happy. We might run on a totally different machine */
  47. return 0;
  48. imx_phycore_snd_ac97_device = platform_device_alloc("soc-audio", -1);
  49. if (!imx_phycore_snd_ac97_device)
  50. return -ENOMEM;
  51. platform_set_drvdata(imx_phycore_snd_ac97_device, &imx_phycore);
  52. ret = platform_device_add(imx_phycore_snd_ac97_device);
  53. if (ret)
  54. goto fail1;
  55. imx_phycore_snd_device = platform_device_alloc("wm9712-codec", -1);
  56. if (!imx_phycore_snd_device) {
  57. ret = -ENOMEM;
  58. goto fail2;
  59. }
  60. ret = platform_device_add(imx_phycore_snd_device);
  61. if (ret) {
  62. printk(KERN_ERR "ASoC: Platform device allocation failed\n");
  63. goto fail3;
  64. }
  65. return 0;
  66. fail3:
  67. platform_device_put(imx_phycore_snd_device);
  68. fail2:
  69. platform_device_del(imx_phycore_snd_ac97_device);
  70. fail1:
  71. platform_device_put(imx_phycore_snd_ac97_device);
  72. return ret;
  73. }
  74. static void __exit imx_phycore_exit(void)
  75. {
  76. platform_device_unregister(imx_phycore_snd_device);
  77. platform_device_unregister(imx_phycore_snd_ac97_device);
  78. }
  79. late_initcall(imx_phycore_init);
  80. module_exit(imx_phycore_exit);
  81. MODULE_AUTHOR("Sascha Hauer <s.hauer@pengutronix.de>");
  82. MODULE_DESCRIPTION("PhyCORE ALSA SoC driver");
  83. MODULE_LICENSE("GPL");