mx27vis-aic32x4.c 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. /*
  2. * mx27vis-aic32x4.c
  3. *
  4. * Copyright 2011 Vista Silicon S.L.
  5. *
  6. * Author: Javier Martin <javier.martin@vista-silicon.com>
  7. *
  8. * This program is free software; you can redistribute it and/or modify it
  9. * under the terms of the GNU General Public License as published by the
  10. * Free Software Foundation; either version 2 of the License, or (at your
  11. * option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
  21. * MA 02110-1301, USA.
  22. */
  23. #include <linux/module.h>
  24. #include <linux/moduleparam.h>
  25. #include <linux/device.h>
  26. #include <linux/i2c.h>
  27. #include <sound/core.h>
  28. #include <sound/pcm.h>
  29. #include <sound/soc.h>
  30. #include <sound/soc-dapm.h>
  31. #include <asm/mach-types.h>
  32. #include <mach/audmux.h>
  33. #include "../codecs/tlv320aic32x4.h"
  34. #include "imx-ssi.h"
  35. static int mx27vis_aic32x4_hw_params(struct snd_pcm_substream *substream,
  36. struct snd_pcm_hw_params *params)
  37. {
  38. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  39. struct snd_soc_dai *codec_dai = rtd->codec_dai;
  40. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  41. int ret;
  42. u32 dai_format;
  43. dai_format = SND_SOC_DAIFMT_DSP_B | SND_SOC_DAIFMT_NB_NF |
  44. SND_SOC_DAIFMT_CBM_CFM;
  45. /* set codec DAI configuration */
  46. snd_soc_dai_set_fmt(codec_dai, dai_format);
  47. /* set cpu DAI configuration */
  48. snd_soc_dai_set_fmt(cpu_dai, dai_format);
  49. ret = snd_soc_dai_set_sysclk(codec_dai, 0,
  50. 25000000, SND_SOC_CLOCK_OUT);
  51. if (ret) {
  52. pr_err("%s: failed setting codec sysclk\n", __func__);
  53. return ret;
  54. }
  55. ret = snd_soc_dai_set_sysclk(cpu_dai, IMX_SSP_SYS_CLK, 0,
  56. SND_SOC_CLOCK_IN);
  57. if (ret) {
  58. pr_err("can't set CPU system clock IMX_SSP_SYS_CLK\n");
  59. return ret;
  60. }
  61. return 0;
  62. }
  63. static struct snd_soc_ops mx27vis_aic32x4_snd_ops = {
  64. .hw_params = mx27vis_aic32x4_hw_params,
  65. };
  66. static struct snd_soc_dai_link mx27vis_aic32x4_dai = {
  67. .name = "tlv320aic32x4",
  68. .stream_name = "TLV320AIC32X4",
  69. .codec_dai_name = "tlv320aic32x4-hifi",
  70. .platform_name = "imx-pcm-audio.0",
  71. .codec_name = "tlv320aic32x4.0-0018",
  72. .cpu_dai_name = "imx-ssi.0",
  73. .ops = &mx27vis_aic32x4_snd_ops,
  74. };
  75. static struct snd_soc_card mx27vis_aic32x4 = {
  76. .name = "visstrim_m10-audio",
  77. .dai_link = &mx27vis_aic32x4_dai,
  78. .num_links = 1,
  79. };
  80. static struct platform_device *mx27vis_aic32x4_snd_device;
  81. static int __init mx27vis_aic32x4_init(void)
  82. {
  83. int ret;
  84. mx27vis_aic32x4_snd_device = platform_device_alloc("soc-audio", -1);
  85. if (!mx27vis_aic32x4_snd_device)
  86. return -ENOMEM;
  87. platform_set_drvdata(mx27vis_aic32x4_snd_device, &mx27vis_aic32x4);
  88. ret = platform_device_add(mx27vis_aic32x4_snd_device);
  89. if (ret) {
  90. printk(KERN_ERR "ASoC: Platform device allocation failed\n");
  91. platform_device_put(mx27vis_aic32x4_snd_device);
  92. }
  93. /* Connect SSI0 as clock slave to SSI1 external pins */
  94. mxc_audmux_v1_configure_port(MX27_AUDMUX_HPCR1_SSI0,
  95. MXC_AUDMUX_V1_PCR_SYN |
  96. MXC_AUDMUX_V1_PCR_TFSDIR |
  97. MXC_AUDMUX_V1_PCR_TCLKDIR |
  98. MXC_AUDMUX_V1_PCR_TFCSEL(MX27_AUDMUX_PPCR1_SSI_PINS_1) |
  99. MXC_AUDMUX_V1_PCR_RXDSEL(MX27_AUDMUX_PPCR1_SSI_PINS_1)
  100. );
  101. mxc_audmux_v1_configure_port(MX27_AUDMUX_PPCR1_SSI_PINS_1,
  102. MXC_AUDMUX_V1_PCR_SYN |
  103. MXC_AUDMUX_V1_PCR_RXDSEL(MX27_AUDMUX_HPCR1_SSI0)
  104. );
  105. return ret;
  106. }
  107. static void __exit mx27vis_aic32x4_exit(void)
  108. {
  109. platform_device_unregister(mx27vis_aic32x4_snd_device);
  110. }
  111. module_init(mx27vis_aic32x4_init);
  112. module_exit(mx27vis_aic32x4_exit);
  113. MODULE_AUTHOR("Javier Martin <javier.martin@vista-silicon.com>");
  114. MODULE_DESCRIPTION("ALSA SoC AIC32X4 mx27 visstrim");
  115. MODULE_LICENSE("GPL");