bf5xx-ad1836.c 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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. static struct snd_soc_card bf5xx_ad1836;
  30. static int bf5xx_ad1836_init(struct snd_soc_pcm_runtime *rtd)
  31. {
  32. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  33. unsigned int channel_map[] = {0, 4, 1, 5, 2, 6, 3, 7};
  34. int ret = 0;
  35. /* set cpu DAI channel mapping */
  36. ret = snd_soc_dai_set_channel_map(cpu_dai, ARRAY_SIZE(channel_map),
  37. channel_map, ARRAY_SIZE(channel_map), channel_map);
  38. if (ret < 0)
  39. return ret;
  40. ret = snd_soc_dai_set_tdm_slot(cpu_dai, 0xFF, 0xFF, 8, 32);
  41. if (ret < 0)
  42. return ret;
  43. return 0;
  44. }
  45. #define BF5XX_AD1836_DAIFMT (SND_SOC_DAIFMT_DSP_A | SND_SOC_DAIFMT_IB_IF | \
  46. SND_SOC_DAIFMT_CBM_CFM)
  47. static struct snd_soc_dai_link bf5xx_ad1836_dai = {
  48. .name = "ad1836",
  49. .stream_name = "AD1836",
  50. .codec_dai_name = "ad1836-hifi",
  51. .platform_name = "bfin-i2s-pcm-audio",
  52. .dai_fmt = BF5XX_AD1836_DAIFMT,
  53. .init = bf5xx_ad1836_init,
  54. };
  55. static struct snd_soc_card bf5xx_ad1836 = {
  56. .name = "bfin-ad1836",
  57. .owner = THIS_MODULE,
  58. .dai_link = &bf5xx_ad1836_dai,
  59. .num_links = 1,
  60. };
  61. static int bf5xx_ad1836_driver_probe(struct platform_device *pdev)
  62. {
  63. struct snd_soc_card *card = &bf5xx_ad1836;
  64. const char **link_name;
  65. int ret;
  66. link_name = pdev->dev.platform_data;
  67. if (!link_name) {
  68. dev_err(&pdev->dev, "No platform data supplied\n");
  69. return -EINVAL;
  70. }
  71. bf5xx_ad1836_dai.cpu_dai_name = link_name[0];
  72. bf5xx_ad1836_dai.codec_name = link_name[1];
  73. card->dev = &pdev->dev;
  74. platform_set_drvdata(pdev, card);
  75. ret = devm_snd_soc_register_card(&pdev->dev, card);
  76. if (ret)
  77. dev_err(&pdev->dev, "Failed to register card\n");
  78. return ret;
  79. }
  80. static struct platform_driver bf5xx_ad1836_driver = {
  81. .driver = {
  82. .name = "bfin-snd-ad1836",
  83. .pm = &snd_soc_pm_ops,
  84. },
  85. .probe = bf5xx_ad1836_driver_probe,
  86. };
  87. module_platform_driver(bf5xx_ad1836_driver);
  88. /* Module information */
  89. MODULE_AUTHOR("Barry Song");
  90. MODULE_DESCRIPTION("ALSA SoC AD1836 board driver");
  91. MODULE_LICENSE("GPL");