adau7002.c 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /*
  2. * ADAU7002 Stereo PDM-to-I2S/TDM converter driver
  3. *
  4. * Copyright 2014-2016 Analog Devices
  5. * Author: Lars-Peter Clausen <lars@metafoo.de>
  6. *
  7. * Licensed under the GPL-2.
  8. */
  9. #include <linux/init.h>
  10. #include <linux/module.h>
  11. #include <linux/of.h>
  12. #include <linux/platform_device.h>
  13. #include <sound/soc.h>
  14. static const struct snd_soc_dapm_widget adau7002_widgets[] = {
  15. SND_SOC_DAPM_INPUT("PDM_DAT"),
  16. SND_SOC_DAPM_REGULATOR_SUPPLY("IOVDD", 0, 0),
  17. };
  18. static const struct snd_soc_dapm_route adau7002_routes[] = {
  19. { "Capture", NULL, "PDM_DAT" },
  20. { "Capture", NULL, "IOVDD" },
  21. };
  22. static struct snd_soc_dai_driver adau7002_dai = {
  23. .name = "adau7002-hifi",
  24. .capture = {
  25. .stream_name = "Capture",
  26. .channels_min = 2,
  27. .channels_max = 2,
  28. .rates = SNDRV_PCM_RATE_8000_96000,
  29. .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S18_3LE |
  30. SNDRV_PCM_FMTBIT_S20_3LE | SNDRV_PCM_FMTBIT_S24_LE |
  31. SNDRV_PCM_FMTBIT_S24_3LE | SNDRV_PCM_FMTBIT_S32_LE,
  32. .sig_bits = 20,
  33. },
  34. };
  35. static const struct snd_soc_codec_driver adau7002_codec_driver = {
  36. .component_driver = {
  37. .dapm_widgets = adau7002_widgets,
  38. .num_dapm_widgets = ARRAY_SIZE(adau7002_widgets),
  39. .dapm_routes = adau7002_routes,
  40. .num_dapm_routes = ARRAY_SIZE(adau7002_routes),
  41. },
  42. };
  43. static int adau7002_probe(struct platform_device *pdev)
  44. {
  45. return snd_soc_register_codec(&pdev->dev, &adau7002_codec_driver,
  46. &adau7002_dai, 1);
  47. }
  48. static int adau7002_remove(struct platform_device *pdev)
  49. {
  50. snd_soc_unregister_codec(&pdev->dev);
  51. return 0;
  52. }
  53. #ifdef CONFIG_OF
  54. static const struct of_device_id adau7002_dt_ids[] = {
  55. { .compatible = "adi,adau7002", },
  56. { }
  57. };
  58. MODULE_DEVICE_TABLE(of, adau7002_dt_ids);
  59. #endif
  60. static struct platform_driver adau7002_driver = {
  61. .driver = {
  62. .name = "adau7002",
  63. .of_match_table = of_match_ptr(adau7002_dt_ids),
  64. },
  65. .probe = adau7002_probe,
  66. .remove = adau7002_remove,
  67. };
  68. module_platform_driver(adau7002_driver);
  69. MODULE_AUTHOR("Lars-Peter Clausen <lars@metafoo.de>");
  70. MODULE_DESCRIPTION("ADAU7002 Stereo PDM-to-I2S/TDM Converter driver");
  71. MODULE_LICENSE("GPL v2");