igep0020.c 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. /*
  2. * igep0020.c -- SoC audio for IGEP v2
  3. *
  4. * Based on sound/soc/omap/overo.c by Steve Sakoman
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public License
  8. * version 2 as published by the Free Software Foundation.
  9. *
  10. * This program is distributed in the hope that it will be useful, but
  11. * WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  13. * General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program; if not, write to the Free Software
  17. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  18. * 02110-1301 USA
  19. *
  20. */
  21. #include <linux/clk.h>
  22. #include <linux/platform_device.h>
  23. #include <linux/module.h>
  24. #include <sound/core.h>
  25. #include <sound/pcm.h>
  26. #include <sound/soc.h>
  27. #include <asm/mach-types.h>
  28. #include <mach/hardware.h>
  29. #include <mach/gpio.h>
  30. #include <plat/mcbsp.h>
  31. #include "omap-mcbsp.h"
  32. #include "omap-pcm.h"
  33. static int igep2_hw_params(struct snd_pcm_substream *substream,
  34. struct snd_pcm_hw_params *params)
  35. {
  36. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  37. struct snd_soc_dai *codec_dai = rtd->codec_dai;
  38. int ret;
  39. /* Set the codec system clock for DAC and ADC */
  40. ret = snd_soc_dai_set_sysclk(codec_dai, 0, 26000000,
  41. SND_SOC_CLOCK_IN);
  42. if (ret < 0) {
  43. printk(KERN_ERR "can't set codec system clock\n");
  44. return ret;
  45. }
  46. return 0;
  47. }
  48. static struct snd_soc_ops igep2_ops = {
  49. .hw_params = igep2_hw_params,
  50. };
  51. /* Digital audio interface glue - connects codec <--> CPU */
  52. static struct snd_soc_dai_link igep2_dai = {
  53. .name = "TWL4030",
  54. .stream_name = "TWL4030",
  55. .cpu_dai_name = "omap-mcbsp.2",
  56. .codec_dai_name = "twl4030-hifi",
  57. .platform_name = "omap-pcm-audio",
  58. .codec_name = "twl4030-codec",
  59. .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
  60. SND_SOC_DAIFMT_CBM_CFM,
  61. .ops = &igep2_ops,
  62. };
  63. /* Audio machine driver */
  64. static struct snd_soc_card snd_soc_card_igep2 = {
  65. .name = "igep2",
  66. .owner = THIS_MODULE,
  67. .dai_link = &igep2_dai,
  68. .num_links = 1,
  69. };
  70. static struct platform_device *igep2_snd_device;
  71. static int __init igep2_soc_init(void)
  72. {
  73. int ret;
  74. if (!machine_is_igep0020())
  75. return -ENODEV;
  76. printk(KERN_INFO "IGEP v2 SoC init\n");
  77. igep2_snd_device = platform_device_alloc("soc-audio", -1);
  78. if (!igep2_snd_device) {
  79. printk(KERN_ERR "Platform device allocation failed\n");
  80. return -ENOMEM;
  81. }
  82. platform_set_drvdata(igep2_snd_device, &snd_soc_card_igep2);
  83. ret = platform_device_add(igep2_snd_device);
  84. if (ret)
  85. goto err1;
  86. return 0;
  87. err1:
  88. printk(KERN_ERR "Unable to add platform device\n");
  89. platform_device_put(igep2_snd_device);
  90. return ret;
  91. }
  92. module_init(igep2_soc_init);
  93. static void __exit igep2_soc_exit(void)
  94. {
  95. platform_device_unregister(igep2_snd_device);
  96. }
  97. module_exit(igep2_soc_exit);
  98. MODULE_AUTHOR("Enric Balletbo i Serra <eballetbo@iseebcn.com>");
  99. MODULE_DESCRIPTION("ALSA SoC IGEP v2");
  100. MODULE_LICENSE("GPL");