simone.c 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /*
  2. * simone.c -- ASoC audio for Simplemachines Sim.One board
  3. *
  4. * Copyright (c) 2010 Mika Westerberg
  5. *
  6. * Based on snappercl15 machine driver by Ryan Mallon.
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License version 2 as
  10. * published by the Free Software Foundation.
  11. */
  12. #include <linux/init.h>
  13. #include <linux/module.h>
  14. #include <linux/platform_device.h>
  15. #include <sound/core.h>
  16. #include <sound/pcm.h>
  17. #include <sound/soc.h>
  18. #include <asm/mach-types.h>
  19. #include <mach/hardware.h>
  20. #include "ep93xx-pcm.h"
  21. static struct snd_soc_dai_link simone_dai = {
  22. .name = "AC97",
  23. .stream_name = "AC97 HiFi",
  24. .cpu_dai_name = "ep93xx-ac97",
  25. .codec_dai_name = "ac97-hifi",
  26. .codec_name = "ac97-codec",
  27. .platform_name = "ep93xx-pcm-audio",
  28. };
  29. static struct snd_soc_card snd_soc_simone = {
  30. .name = "Sim.One",
  31. .dai_link = &simone_dai,
  32. .num_links = 1,
  33. };
  34. static struct platform_device *simone_snd_ac97_device;
  35. static struct platform_device *simone_snd_device;
  36. static int __init simone_init(void)
  37. {
  38. int ret;
  39. if (!machine_is_sim_one())
  40. return -ENODEV;
  41. simone_snd_ac97_device = platform_device_alloc("ac97-codec", -1);
  42. if (!simone_snd_ac97_device)
  43. return -ENOMEM;
  44. ret = platform_device_add(simone_snd_ac97_device);
  45. if (ret)
  46. goto fail1;
  47. simone_snd_device = platform_device_alloc("soc-audio", -1);
  48. if (!simone_snd_device) {
  49. ret = -ENOMEM;
  50. goto fail2;
  51. }
  52. platform_set_drvdata(simone_snd_device, &snd_soc_simone);
  53. ret = platform_device_add(simone_snd_device);
  54. if (ret)
  55. goto fail3;
  56. return 0;
  57. fail3:
  58. platform_device_put(simone_snd_device);
  59. fail2:
  60. platform_device_del(simone_snd_ac97_device);
  61. fail1:
  62. platform_device_put(simone_snd_ac97_device);
  63. return ret;
  64. }
  65. module_init(simone_init);
  66. static void __exit simone_exit(void)
  67. {
  68. platform_device_unregister(simone_snd_device);
  69. platform_device_unregister(simone_snd_ac97_device);
  70. }
  71. module_exit(simone_exit);
  72. MODULE_DESCRIPTION("ALSA SoC Simplemachines Sim.One");
  73. MODULE_AUTHOR("Mika Westerberg <mika.westerberg@iki.fi>");
  74. MODULE_LICENSE("GPL");