bfin-eval-adau1701.c 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. /*
  2. * Machine driver for EVAL-ADAU1701MINIZ on Analog Devices bfin
  3. * evaluation boards.
  4. *
  5. * Copyright 2011 Analog Devices Inc.
  6. * Author: Lars-Peter Clausen <lars@metafoo.de>
  7. *
  8. * Licensed under the GPL-2 or later.
  9. */
  10. #include <linux/module.h>
  11. #include <linux/device.h>
  12. #include <sound/core.h>
  13. #include <sound/pcm.h>
  14. #include <sound/soc.h>
  15. #include <sound/pcm_params.h>
  16. #include "../codecs/adau1701.h"
  17. static const struct snd_soc_dapm_widget bfin_eval_adau1701_dapm_widgets[] = {
  18. SND_SOC_DAPM_SPK("Speaker", NULL),
  19. SND_SOC_DAPM_LINE("Line Out", NULL),
  20. SND_SOC_DAPM_LINE("Line In", NULL),
  21. };
  22. static const struct snd_soc_dapm_route bfin_eval_adau1701_dapm_routes[] = {
  23. { "Speaker", NULL, "OUT0" },
  24. { "Speaker", NULL, "OUT1" },
  25. { "Line Out", NULL, "OUT2" },
  26. { "Line Out", NULL, "OUT3" },
  27. { "IN0", NULL, "Line In" },
  28. { "IN1", NULL, "Line In" },
  29. };
  30. static int bfin_eval_adau1701_hw_params(struct snd_pcm_substream *substream,
  31. struct snd_pcm_hw_params *params)
  32. {
  33. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  34. struct snd_soc_dai *codec_dai = rtd->codec_dai;
  35. int ret;
  36. ret = snd_soc_dai_set_sysclk(codec_dai, ADAU1701_CLK_SRC_OSC, 12288000,
  37. SND_SOC_CLOCK_IN);
  38. return ret;
  39. }
  40. static struct snd_soc_ops bfin_eval_adau1701_ops = {
  41. .hw_params = bfin_eval_adau1701_hw_params,
  42. };
  43. #define BFIN_EVAL_ADAU1701_DAI_FMT (SND_SOC_DAIFMT_I2S | \
  44. SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM)
  45. static struct snd_soc_dai_link bfin_eval_adau1701_dai[] = {
  46. {
  47. .name = "adau1701",
  48. .stream_name = "adau1701",
  49. .cpu_dai_name = "bfin-i2s.0",
  50. .codec_dai_name = "adau1701",
  51. .platform_name = "bfin-i2s-pcm-audio",
  52. .codec_name = "adau1701.0-0034",
  53. .ops = &bfin_eval_adau1701_ops,
  54. .dai_fmt = BFIN_EVAL_ADAU1701_DAI_FMT,
  55. },
  56. {
  57. .name = "adau1701",
  58. .stream_name = "adau1701",
  59. .cpu_dai_name = "bfin-i2s.1",
  60. .codec_dai_name = "adau1701",
  61. .platform_name = "bfin-i2s-pcm-audio",
  62. .codec_name = "adau1701.0-0034",
  63. .ops = &bfin_eval_adau1701_ops,
  64. .dai_fmt = BFIN_EVAL_ADAU1701_DAI_FMT,
  65. },
  66. };
  67. static struct snd_soc_card bfin_eval_adau1701 = {
  68. .name = "bfin-eval-adau1701",
  69. .owner = THIS_MODULE,
  70. .dai_link = &bfin_eval_adau1701_dai[CONFIG_SND_BF5XX_SPORT_NUM],
  71. .num_links = 1,
  72. .dapm_widgets = bfin_eval_adau1701_dapm_widgets,
  73. .num_dapm_widgets = ARRAY_SIZE(bfin_eval_adau1701_dapm_widgets),
  74. .dapm_routes = bfin_eval_adau1701_dapm_routes,
  75. .num_dapm_routes = ARRAY_SIZE(bfin_eval_adau1701_dapm_routes),
  76. };
  77. static int bfin_eval_adau1701_probe(struct platform_device *pdev)
  78. {
  79. struct snd_soc_card *card = &bfin_eval_adau1701;
  80. card->dev = &pdev->dev;
  81. return devm_snd_soc_register_card(&pdev->dev, &bfin_eval_adau1701);
  82. }
  83. static struct platform_driver bfin_eval_adau1701_driver = {
  84. .driver = {
  85. .name = "bfin-eval-adau1701",
  86. .pm = &snd_soc_pm_ops,
  87. },
  88. .probe = bfin_eval_adau1701_probe,
  89. };
  90. module_platform_driver(bfin_eval_adau1701_driver);
  91. MODULE_AUTHOR("Lars-Peter Clausen <lars@metafoo.de>");
  92. MODULE_DESCRIPTION("ALSA SoC bfin ADAU1701 driver");
  93. MODULE_LICENSE("GPL");
  94. MODULE_ALIAS("platform:bfin-eval-adau1701");