phycore-ac97.c 2.5 KB

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