kirkwood-t5325.c 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. /*
  2. * kirkwood-t5325.c
  3. *
  4. * (c) 2010 Arnaud Patard <arnaud.patard@rtp-net.org>
  5. *
  6. * This program is free software; you can redistribute it and/or modify it
  7. * under the terms of the GNU General Public License as published by the
  8. * Free Software Foundation; either version 2 of the License, or (at your
  9. * option) any later version.
  10. */
  11. #include <linux/module.h>
  12. #include <linux/moduleparam.h>
  13. #include <linux/interrupt.h>
  14. #include <linux/platform_device.h>
  15. #include <linux/slab.h>
  16. #include <sound/soc.h>
  17. #include <mach/kirkwood.h>
  18. #include <plat/audio.h>
  19. #include <asm/mach-types.h>
  20. #include "../codecs/alc5623.h"
  21. static int t5325_hw_params(struct snd_pcm_substream *substream,
  22. struct snd_pcm_hw_params *params)
  23. {
  24. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  25. struct snd_soc_dai *codec_dai = rtd->codec_dai;
  26. unsigned int freq;
  27. freq = params_rate(params) * 256;
  28. return snd_soc_dai_set_sysclk(codec_dai, 0, freq, SND_SOC_CLOCK_IN);
  29. }
  30. static struct snd_soc_ops t5325_ops = {
  31. .hw_params = t5325_hw_params,
  32. };
  33. static const struct snd_soc_dapm_widget t5325_dapm_widgets[] = {
  34. SND_SOC_DAPM_HP("Headphone Jack", NULL),
  35. SND_SOC_DAPM_SPK("Speaker", NULL),
  36. SND_SOC_DAPM_MIC("Mic Jack", NULL),
  37. };
  38. static const struct snd_soc_dapm_route t5325_route[] = {
  39. { "Headphone Jack", NULL, "HPL" },
  40. { "Headphone Jack", NULL, "HPR" },
  41. {"Speaker", NULL, "SPKOUT"},
  42. {"Speaker", NULL, "SPKOUTN"},
  43. { "MIC1", NULL, "Mic Jack" },
  44. { "MIC2", NULL, "Mic Jack" },
  45. };
  46. static int t5325_dai_init(struct snd_soc_pcm_runtime *rtd)
  47. {
  48. struct snd_soc_codec *codec = rtd->codec;
  49. struct snd_soc_dapm_context *dapm = &codec->dapm;
  50. snd_soc_dapm_enable_pin(dapm, "Mic Jack");
  51. snd_soc_dapm_enable_pin(dapm, "Headphone Jack");
  52. snd_soc_dapm_enable_pin(dapm, "Speaker");
  53. return 0;
  54. }
  55. static struct snd_soc_dai_link t5325_dai[] = {
  56. {
  57. .name = "ALC5621",
  58. .stream_name = "ALC5621 HiFi",
  59. .cpu_dai_name = "kirkwood-i2s",
  60. .platform_name = "kirkwood-pcm-audio",
  61. .codec_dai_name = "alc5621-hifi",
  62. .codec_name = "alc562x-codec.0-001a",
  63. .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_CBS_CFS,
  64. .ops = &t5325_ops,
  65. .init = t5325_dai_init,
  66. },
  67. };
  68. static struct snd_soc_card t5325 = {
  69. .name = "t5325",
  70. .owner = THIS_MODULE,
  71. .dai_link = t5325_dai,
  72. .num_links = ARRAY_SIZE(t5325_dai),
  73. .dapm_widgets = t5325_dapm_widgets,
  74. .num_dapm_widgets = ARRAY_SIZE(t5325_dapm_widgets),
  75. .dapm_routes = t5325_route,
  76. .num_dapm_routes = ARRAY_SIZE(t5325_route),
  77. };
  78. static int __devinit t5325_probe(struct platform_device *pdev)
  79. {
  80. struct snd_soc_card *card = &t5325;
  81. int ret;
  82. card->dev = &pdev->dev;
  83. ret = snd_soc_register_card(card);
  84. if (ret)
  85. dev_err(&pdev->dev, "snd_soc_register_card() failed: %d\n",
  86. ret);
  87. return ret;
  88. }
  89. static int __devexit t5325_remove(struct platform_device *pdev)
  90. {
  91. struct snd_soc_card *card = platform_get_drvdata(pdev);
  92. snd_soc_unregister_card(card);
  93. return 0;
  94. }
  95. static struct platform_driver t5325_driver = {
  96. .driver = {
  97. .name = "t5325-audio",
  98. .owner = THIS_MODULE,
  99. },
  100. .probe = t5325_probe,
  101. .remove = __devexit_p(t5325_remove),
  102. };
  103. module_platform_driver(t5325_driver);
  104. MODULE_AUTHOR("Arnaud Patard <arnaud.patard@rtp-net.org>");
  105. MODULE_DESCRIPTION("ALSA SoC t5325 audio client");
  106. MODULE_LICENSE("GPL");
  107. MODULE_ALIAS("platform:t5325-audio");