gtm601.c 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * This is a simple driver for the GTM601 Voice PCM interface
  4. *
  5. * Copyright (C) 2015 Goldelico GmbH
  6. *
  7. * Author: Marek Belisko <marek@goldelico.com>
  8. *
  9. * Based on wm8727.c driver
  10. */
  11. #include <linux/init.h>
  12. #include <linux/slab.h>
  13. #include <linux/module.h>
  14. #include <linux/kernel.h>
  15. #include <linux/of_device.h>
  16. #include <sound/core.h>
  17. #include <sound/pcm.h>
  18. #include <sound/initval.h>
  19. #include <sound/soc.h>
  20. static const struct snd_soc_dapm_widget gtm601_dapm_widgets[] = {
  21. SND_SOC_DAPM_OUTPUT("AOUT"),
  22. SND_SOC_DAPM_INPUT("AIN"),
  23. };
  24. static const struct snd_soc_dapm_route gtm601_dapm_routes[] = {
  25. { "AOUT", NULL, "Playback" },
  26. { "Capture", NULL, "AIN" },
  27. };
  28. static struct snd_soc_dai_driver gtm601_dai = {
  29. .name = "gtm601",
  30. .playback = {
  31. .stream_name = "Playback",
  32. .channels_min = 1,
  33. .channels_max = 1,
  34. .rates = SNDRV_PCM_RATE_8000,
  35. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  36. },
  37. .capture = {
  38. .stream_name = "Capture",
  39. .channels_min = 1,
  40. .channels_max = 1,
  41. .rates = SNDRV_PCM_RATE_8000,
  42. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  43. },
  44. };
  45. static struct snd_soc_dai_driver bm818_dai = {
  46. .name = "bm818",
  47. .playback = {
  48. .stream_name = "Playback",
  49. .channels_min = 2,
  50. .channels_max = 2,
  51. .rates = SNDRV_PCM_RATE_48000,
  52. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  53. },
  54. .capture = {
  55. .stream_name = "Capture",
  56. .channels_min = 2,
  57. .channels_max = 2,
  58. .rates = SNDRV_PCM_RATE_48000,
  59. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  60. },
  61. };
  62. static const struct snd_soc_component_driver soc_component_dev_gtm601 = {
  63. .dapm_widgets = gtm601_dapm_widgets,
  64. .num_dapm_widgets = ARRAY_SIZE(gtm601_dapm_widgets),
  65. .dapm_routes = gtm601_dapm_routes,
  66. .num_dapm_routes = ARRAY_SIZE(gtm601_dapm_routes),
  67. .idle_bias_on = 1,
  68. .use_pmdown_time = 1,
  69. .endianness = 1,
  70. .non_legacy_dai_naming = 1,
  71. };
  72. static int gtm601_platform_probe(struct platform_device *pdev)
  73. {
  74. const struct snd_soc_dai_driver *dai_driver;
  75. dai_driver = of_device_get_match_data(&pdev->dev);
  76. return devm_snd_soc_register_component(&pdev->dev,
  77. &soc_component_dev_gtm601,
  78. (struct snd_soc_dai_driver *)dai_driver, 1);
  79. }
  80. static const struct of_device_id gtm601_codec_of_match[] = {
  81. { .compatible = "option,gtm601", .data = (void *)&gtm601_dai },
  82. { .compatible = "broadmobi,bm818", .data = (void *)&bm818_dai },
  83. {},
  84. };
  85. MODULE_DEVICE_TABLE(of, gtm601_codec_of_match);
  86. static struct platform_driver gtm601_codec_driver = {
  87. .driver = {
  88. .name = "gtm601",
  89. .of_match_table = of_match_ptr(gtm601_codec_of_match),
  90. },
  91. .probe = gtm601_platform_probe,
  92. };
  93. module_platform_driver(gtm601_codec_driver);
  94. MODULE_DESCRIPTION("ASoC gtm601 driver");
  95. MODULE_AUTHOR("Marek Belisko <marek@goldelico.com>");
  96. MODULE_LICENSE("GPL");
  97. MODULE_ALIAS("platform:gtm601");