omap3evm.c 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. /*
  2. * omap3evm.c -- ALSA SoC support for OMAP3 EVM
  3. *
  4. * Author: Anuj Aggarwal <anuj.aggarwal@ti.com>
  5. *
  6. * Based on sound/soc/omap/beagle.c by Steve Sakoman
  7. *
  8. * Copyright (C) 2008 Texas Instruments, Incorporated
  9. *
  10. * This program is free software; you can redistribute it and/or modify it
  11. * under the terms of the GNU General Public License as published by the
  12. * Free Software Foundation version 2.
  13. *
  14. * This program is distributed "as is" WITHOUT ANY WARRANTY of any kind,
  15. * whether express or implied; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  17. * General Public License for more details.
  18. */
  19. #include <linux/clk.h>
  20. #include <linux/platform_device.h>
  21. #include <linux/module.h>
  22. #include <sound/core.h>
  23. #include <sound/pcm.h>
  24. #include <sound/soc.h>
  25. #include <asm/mach-types.h>
  26. #include <mach/hardware.h>
  27. #include <mach/gpio.h>
  28. #include <plat/mcbsp.h>
  29. #include "omap-mcbsp.h"
  30. #include "omap-pcm.h"
  31. static int omap3evm_hw_params(struct snd_pcm_substream *substream,
  32. struct snd_pcm_hw_params *params)
  33. {
  34. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  35. struct snd_soc_dai *codec_dai = rtd->codec_dai;
  36. int ret;
  37. /* Set the codec system clock for DAC and ADC */
  38. ret = snd_soc_dai_set_sysclk(codec_dai, 0, 26000000,
  39. SND_SOC_CLOCK_IN);
  40. if (ret < 0) {
  41. printk(KERN_ERR "Can't set codec system clock\n");
  42. return ret;
  43. }
  44. return 0;
  45. }
  46. static struct snd_soc_ops omap3evm_ops = {
  47. .hw_params = omap3evm_hw_params,
  48. };
  49. /* Digital audio interface glue - connects codec <--> CPU */
  50. static struct snd_soc_dai_link omap3evm_dai = {
  51. .name = "TWL4030",
  52. .stream_name = "TWL4030",
  53. .cpu_dai_name = "omap-mcbsp.2",
  54. .codec_dai_name = "twl4030-hifi",
  55. .platform_name = "omap-pcm-audio",
  56. .codec_name = "twl4030-codec",
  57. .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
  58. SND_SOC_DAIFMT_CBM_CFM,
  59. .ops = &omap3evm_ops,
  60. };
  61. /* Audio machine driver */
  62. static struct snd_soc_card snd_soc_omap3evm = {
  63. .name = "omap3evm",
  64. .owner = THIS_MODULE,
  65. .dai_link = &omap3evm_dai,
  66. .num_links = 1,
  67. };
  68. static struct platform_device *omap3evm_snd_device;
  69. static int __init omap3evm_soc_init(void)
  70. {
  71. int ret;
  72. if (!machine_is_omap3evm())
  73. return -ENODEV;
  74. pr_info("OMAP3 EVM SoC init\n");
  75. omap3evm_snd_device = platform_device_alloc("soc-audio", -1);
  76. if (!omap3evm_snd_device) {
  77. printk(KERN_ERR "Platform device allocation failed\n");
  78. return -ENOMEM;
  79. }
  80. platform_set_drvdata(omap3evm_snd_device, &snd_soc_omap3evm);
  81. ret = platform_device_add(omap3evm_snd_device);
  82. if (ret)
  83. goto err1;
  84. return 0;
  85. err1:
  86. printk(KERN_ERR "Unable to add platform device\n");
  87. platform_device_put(omap3evm_snd_device);
  88. return ret;
  89. }
  90. static void __exit omap3evm_soc_exit(void)
  91. {
  92. platform_device_unregister(omap3evm_snd_device);
  93. }
  94. module_init(omap3evm_soc_init);
  95. module_exit(omap3evm_soc_exit);
  96. MODULE_AUTHOR("Anuj Aggarwal <anuj.aggarwal@ti.com>");
  97. MODULE_DESCRIPTION("ALSA SoC OMAP3 EVM");
  98. MODULE_LICENSE("GPL v2");