gtm601.c 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /*
  2. * This is a simple driver for the GTM601 Voice PCM interface
  3. *
  4. * Copyright (C) 2015 Goldelico GmbH
  5. *
  6. * Author: Marek Belisko <marek@goldelico.com>
  7. *
  8. * Based on wm8727.c driver
  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 version 2 as
  12. * published by the Free Software Foundation.
  13. */
  14. #include <linux/init.h>
  15. #include <linux/slab.h>
  16. #include <linux/module.h>
  17. #include <linux/kernel.h>
  18. #include <linux/device.h>
  19. #include <sound/core.h>
  20. #include <sound/pcm.h>
  21. #include <sound/ac97_codec.h>
  22. #include <sound/initval.h>
  23. #include <sound/soc.h>
  24. static const struct snd_soc_dapm_widget gtm601_dapm_widgets[] = {
  25. SND_SOC_DAPM_OUTPUT("AOUT"),
  26. SND_SOC_DAPM_INPUT("AIN"),
  27. };
  28. static const struct snd_soc_dapm_route gtm601_dapm_routes[] = {
  29. { "AOUT", NULL, "Playback" },
  30. { "Capture", NULL, "AIN" },
  31. };
  32. static struct snd_soc_dai_driver gtm601_dai = {
  33. .name = "gtm601",
  34. .playback = {
  35. .stream_name = "Playback",
  36. .channels_min = 1,
  37. .channels_max = 1,
  38. .rates = SNDRV_PCM_RATE_8000,
  39. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  40. },
  41. .capture = {
  42. .stream_name = "Capture",
  43. .channels_min = 1,
  44. .channels_max = 1,
  45. .rates = SNDRV_PCM_RATE_8000,
  46. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  47. },
  48. };
  49. static const struct snd_soc_codec_driver soc_codec_dev_gtm601 = {
  50. .component_driver = {
  51. .dapm_widgets = gtm601_dapm_widgets,
  52. .num_dapm_widgets = ARRAY_SIZE(gtm601_dapm_widgets),
  53. .dapm_routes = gtm601_dapm_routes,
  54. .num_dapm_routes = ARRAY_SIZE(gtm601_dapm_routes),
  55. },
  56. };
  57. static int gtm601_platform_probe(struct platform_device *pdev)
  58. {
  59. return snd_soc_register_codec(&pdev->dev,
  60. &soc_codec_dev_gtm601, &gtm601_dai, 1);
  61. }
  62. static int gtm601_platform_remove(struct platform_device *pdev)
  63. {
  64. snd_soc_unregister_codec(&pdev->dev);
  65. return 0;
  66. }
  67. #if defined(CONFIG_OF)
  68. static const struct of_device_id gtm601_codec_of_match[] = {
  69. { .compatible = "option,gtm601", },
  70. {},
  71. };
  72. MODULE_DEVICE_TABLE(of, gtm601_codec_of_match);
  73. #endif
  74. static struct platform_driver gtm601_codec_driver = {
  75. .driver = {
  76. .name = "gtm601",
  77. .of_match_table = of_match_ptr(gtm601_codec_of_match),
  78. },
  79. .probe = gtm601_platform_probe,
  80. .remove = gtm601_platform_remove,
  81. };
  82. module_platform_driver(gtm601_codec_driver);
  83. MODULE_DESCRIPTION("ASoC gtm601 driver");
  84. MODULE_AUTHOR("Marek Belisko <marek@goldelico.com>");
  85. MODULE_LICENSE("GPL");
  86. MODULE_ALIAS("platform:gtm601");