am3517evm.c 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. /*
  2. * am3517evm.c -- ALSA SoC support for OMAP3517 / AM3517 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) 2009 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 <linux/platform_data/asoc-ti-mcbsp.h>
  27. #include "omap-mcbsp.h"
  28. #include "omap-pcm.h"
  29. #include "../codecs/tlv320aic23.h"
  30. #define CODEC_CLOCK 12000000
  31. static int am3517evm_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,
  39. CODEC_CLOCK, SND_SOC_CLOCK_IN);
  40. if (ret < 0)
  41. printk(KERN_ERR "can't set codec system clock\n");
  42. return ret;
  43. }
  44. static struct snd_soc_ops am3517evm_ops = {
  45. .hw_params = am3517evm_hw_params,
  46. };
  47. /* am3517evm machine dapm widgets */
  48. static const struct snd_soc_dapm_widget tlv320aic23_dapm_widgets[] = {
  49. SND_SOC_DAPM_HP("Line Out", NULL),
  50. SND_SOC_DAPM_LINE("Line In", NULL),
  51. SND_SOC_DAPM_MIC("Mic In", NULL),
  52. };
  53. static const struct snd_soc_dapm_route audio_map[] = {
  54. /* Line Out connected to LLOUT, RLOUT */
  55. {"Line Out", NULL, "LOUT"},
  56. {"Line Out", NULL, "ROUT"},
  57. {"LLINEIN", NULL, "Line In"},
  58. {"RLINEIN", NULL, "Line In"},
  59. {"MICIN", NULL, "Mic In"},
  60. };
  61. /* Digital audio interface glue - connects codec <--> CPU */
  62. static struct snd_soc_dai_link am3517evm_dai = {
  63. .name = "TLV320AIC23",
  64. .stream_name = "AIC23",
  65. .cpu_dai_name = "omap-mcbsp.1",
  66. .codec_dai_name = "tlv320aic23-hifi",
  67. .platform_name = "omap-pcm-audio",
  68. .codec_name = "tlv320aic23-codec.2-001a",
  69. .dai_fmt = SND_SOC_DAIFMT_DSP_B | SND_SOC_DAIFMT_NB_NF |
  70. SND_SOC_DAIFMT_CBM_CFM,
  71. .ops = &am3517evm_ops,
  72. };
  73. /* Audio machine driver */
  74. static struct snd_soc_card snd_soc_am3517evm = {
  75. .name = "am3517evm",
  76. .owner = THIS_MODULE,
  77. .dai_link = &am3517evm_dai,
  78. .num_links = 1,
  79. .dapm_widgets = tlv320aic23_dapm_widgets,
  80. .num_dapm_widgets = ARRAY_SIZE(tlv320aic23_dapm_widgets),
  81. .dapm_routes = audio_map,
  82. .num_dapm_routes = ARRAY_SIZE(audio_map),
  83. };
  84. static struct platform_device *am3517evm_snd_device;
  85. static int __init am3517evm_soc_init(void)
  86. {
  87. int ret;
  88. if (!machine_is_omap3517evm())
  89. return -ENODEV;
  90. pr_info("OMAP3517 / AM3517 EVM SoC init\n");
  91. am3517evm_snd_device = platform_device_alloc("soc-audio", -1);
  92. if (!am3517evm_snd_device) {
  93. printk(KERN_ERR "Platform device allocation failed\n");
  94. return -ENOMEM;
  95. }
  96. platform_set_drvdata(am3517evm_snd_device, &snd_soc_am3517evm);
  97. ret = platform_device_add(am3517evm_snd_device);
  98. if (ret)
  99. goto err1;
  100. return 0;
  101. err1:
  102. printk(KERN_ERR "Unable to add platform device\n");
  103. platform_device_put(am3517evm_snd_device);
  104. return ret;
  105. }
  106. static void __exit am3517evm_soc_exit(void)
  107. {
  108. platform_device_unregister(am3517evm_snd_device);
  109. }
  110. module_init(am3517evm_soc_init);
  111. module_exit(am3517evm_soc_exit);
  112. MODULE_AUTHOR("Anuj Aggarwal <anuj.aggarwal@ti.com>");
  113. MODULE_DESCRIPTION("ALSA SoC OMAP3517 / AM3517 EVM");
  114. MODULE_LICENSE("GPL v2");