overo.c 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. /*
  2. * overo.c -- SoC audio for Gumstix Overo
  3. *
  4. * Author: Steve Sakoman <steve@sakoman.com>
  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 overo_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 overo_ops = {
  49. .hw_params = overo_hw_params,
  50. };
  51. /* Digital audio interface glue - connects codec <--> CPU */
  52. static struct snd_soc_dai_link overo_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 = &overo_ops,
  62. };
  63. /* Audio machine driver */
  64. static struct snd_soc_card snd_soc_card_overo = {
  65. .name = "overo",
  66. .owner = THIS_MODULE,
  67. .dai_link = &overo_dai,
  68. .num_links = 1,
  69. };
  70. static struct platform_device *overo_snd_device;
  71. static int __init overo_soc_init(void)
  72. {
  73. int ret;
  74. if (!(machine_is_overo() || machine_is_cm_t35())) {
  75. pr_debug("Incomatible machine!\n");
  76. return -ENODEV;
  77. }
  78. printk(KERN_INFO "overo SoC init\n");
  79. overo_snd_device = platform_device_alloc("soc-audio", -1);
  80. if (!overo_snd_device) {
  81. printk(KERN_ERR "Platform device allocation failed\n");
  82. return -ENOMEM;
  83. }
  84. platform_set_drvdata(overo_snd_device, &snd_soc_card_overo);
  85. ret = platform_device_add(overo_snd_device);
  86. if (ret)
  87. goto err1;
  88. return 0;
  89. err1:
  90. printk(KERN_ERR "Unable to add platform device\n");
  91. platform_device_put(overo_snd_device);
  92. return ret;
  93. }
  94. module_init(overo_soc_init);
  95. static void __exit overo_soc_exit(void)
  96. {
  97. platform_device_unregister(overo_snd_device);
  98. }
  99. module_exit(overo_soc_exit);
  100. MODULE_AUTHOR("Steve Sakoman <steve@sakoman.com>");
  101. MODULE_DESCRIPTION("ALSA SoC overo");
  102. MODULE_LICENSE("GPL");