bf5xx-ad1836.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. /*
  2. * File: sound/soc/blackfin/bf5xx-ad1836.c
  3. * Author: Barry Song <Barry.Song@analog.com>
  4. *
  5. * Created: Aug 4 2009
  6. * Description: Board driver for ad1836 sound chip
  7. *
  8. * Bugs: Enter bugs at http://blackfin.uclinux.org/
  9. *
  10. * This program is free software; you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License as published by
  12. * the Free Software Foundation; either version 2 of the License, or
  13. * (at your option) any later version.
  14. *
  15. */
  16. #include <linux/module.h>
  17. #include <linux/moduleparam.h>
  18. #include <linux/device.h>
  19. #include <sound/core.h>
  20. #include <sound/pcm.h>
  21. #include <sound/soc.h>
  22. #include <sound/pcm_params.h>
  23. #include <asm/blackfin.h>
  24. #include <asm/cacheflush.h>
  25. #include <asm/irq.h>
  26. #include <asm/dma.h>
  27. #include <asm/portmux.h>
  28. #include "../codecs/ad1836.h"
  29. #include "bf5xx-tdm-pcm.h"
  30. #include "bf5xx-tdm.h"
  31. static struct snd_soc_card bf5xx_ad1836;
  32. static int bf5xx_ad1836_hw_params(struct snd_pcm_substream *substream,
  33. struct snd_pcm_hw_params *params)
  34. {
  35. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  36. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  37. unsigned int channel_map[] = {0, 4, 1, 5, 2, 6, 3, 7};
  38. int ret = 0;
  39. /* set cpu DAI channel mapping */
  40. ret = snd_soc_dai_set_channel_map(cpu_dai, ARRAY_SIZE(channel_map),
  41. channel_map, ARRAY_SIZE(channel_map), channel_map);
  42. if (ret < 0)
  43. return ret;
  44. return 0;
  45. }
  46. static struct snd_soc_ops bf5xx_ad1836_ops = {
  47. .hw_params = bf5xx_ad1836_hw_params,
  48. };
  49. #define BF5XX_AD1836_DAIFMT (SND_SOC_DAIFMT_DSP_A | SND_SOC_DAIFMT_IB_IF | \
  50. SND_SOC_DAIFMT_CBM_CFM)
  51. static struct snd_soc_dai_link bf5xx_ad1836_dai = {
  52. .name = "ad1836",
  53. .stream_name = "AD1836",
  54. .codec_dai_name = "ad1836-hifi",
  55. .platform_name = "bfin-tdm-pcm-audio",
  56. .ops = &bf5xx_ad1836_ops,
  57. .dai_fmt = BF5XX_AD1836_DAIFMT,
  58. };
  59. static struct snd_soc_card bf5xx_ad1836 = {
  60. .name = "bfin-ad1836",
  61. .owner = THIS_MODULE,
  62. .dai_link = &bf5xx_ad1836_dai,
  63. .num_links = 1,
  64. };
  65. static int bf5xx_ad1836_driver_probe(struct platform_device *pdev)
  66. {
  67. struct snd_soc_card *card = &bf5xx_ad1836;
  68. const char **link_name;
  69. int ret;
  70. link_name = pdev->dev.platform_data;
  71. if (!link_name) {
  72. dev_err(&pdev->dev, "No platform data supplied\n");
  73. return -EINVAL;
  74. }
  75. bf5xx_ad1836_dai.cpu_dai_name = link_name[0];
  76. bf5xx_ad1836_dai.codec_name = link_name[1];
  77. card->dev = &pdev->dev;
  78. platform_set_drvdata(pdev, card);
  79. ret = snd_soc_register_card(card);
  80. if (ret)
  81. dev_err(&pdev->dev, "Failed to register card\n");
  82. return ret;
  83. }
  84. static int bf5xx_ad1836_driver_remove(struct platform_device *pdev)
  85. {
  86. struct snd_soc_card *card = platform_get_drvdata(pdev);
  87. snd_soc_unregister_card(card);
  88. return 0;
  89. }
  90. static struct platform_driver bf5xx_ad1836_driver = {
  91. .driver = {
  92. .name = "bfin-snd-ad1836",
  93. .owner = THIS_MODULE,
  94. .pm = &snd_soc_pm_ops,
  95. },
  96. .probe = bf5xx_ad1836_driver_probe,
  97. .remove = bf5xx_ad1836_driver_remove,
  98. };
  99. module_platform_driver(bf5xx_ad1836_driver);
  100. /* Module information */
  101. MODULE_AUTHOR("Barry Song");
  102. MODULE_DESCRIPTION("ALSA SoC AD1836 board driver");
  103. MODULE_LICENSE("GPL");