ads117x.c 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. // SPDX-License-Identifier: GPL-2.0-or-later
  2. /*
  3. * ads117x.c -- Driver for ads1174/8 ADC chips
  4. *
  5. * Copyright 2009 ShotSpotter Inc.
  6. * Author: Graeme Gregory <gg@slimlogic.co.uk>
  7. */
  8. #include <linux/kernel.h>
  9. #include <linux/slab.h>
  10. #include <linux/init.h>
  11. #include <linux/device.h>
  12. #include <linux/module.h>
  13. #include <sound/core.h>
  14. #include <sound/pcm.h>
  15. #include <sound/initval.h>
  16. #include <sound/soc.h>
  17. #include <linux/of.h>
  18. #define ADS117X_RATES (SNDRV_PCM_RATE_8000_48000)
  19. #define ADS117X_FORMATS (SNDRV_PCM_FMTBIT_S16_LE)
  20. static const struct snd_soc_dapm_widget ads117x_dapm_widgets[] = {
  21. SND_SOC_DAPM_INPUT("Input1"),
  22. SND_SOC_DAPM_INPUT("Input2"),
  23. SND_SOC_DAPM_INPUT("Input3"),
  24. SND_SOC_DAPM_INPUT("Input4"),
  25. SND_SOC_DAPM_INPUT("Input5"),
  26. SND_SOC_DAPM_INPUT("Input6"),
  27. SND_SOC_DAPM_INPUT("Input7"),
  28. SND_SOC_DAPM_INPUT("Input8"),
  29. };
  30. static const struct snd_soc_dapm_route ads117x_dapm_routes[] = {
  31. { "Capture", NULL, "Input1" },
  32. { "Capture", NULL, "Input2" },
  33. { "Capture", NULL, "Input3" },
  34. { "Capture", NULL, "Input4" },
  35. { "Capture", NULL, "Input5" },
  36. { "Capture", NULL, "Input6" },
  37. { "Capture", NULL, "Input7" },
  38. { "Capture", NULL, "Input8" },
  39. };
  40. static struct snd_soc_dai_driver ads117x_dai = {
  41. /* ADC */
  42. .name = "ads117x-hifi",
  43. .capture = {
  44. .stream_name = "Capture",
  45. .channels_min = 1,
  46. .channels_max = 32,
  47. .rates = ADS117X_RATES,
  48. .formats = ADS117X_FORMATS,},
  49. };
  50. static const struct snd_soc_component_driver soc_component_dev_ads117x = {
  51. .dapm_widgets = ads117x_dapm_widgets,
  52. .num_dapm_widgets = ARRAY_SIZE(ads117x_dapm_widgets),
  53. .dapm_routes = ads117x_dapm_routes,
  54. .num_dapm_routes = ARRAY_SIZE(ads117x_dapm_routes),
  55. .idle_bias_on = 1,
  56. .use_pmdown_time = 1,
  57. .endianness = 1,
  58. .non_legacy_dai_naming = 1,
  59. };
  60. static int ads117x_probe(struct platform_device *pdev)
  61. {
  62. return devm_snd_soc_register_component(&pdev->dev,
  63. &soc_component_dev_ads117x, &ads117x_dai, 1);
  64. }
  65. #if defined(CONFIG_OF)
  66. static const struct of_device_id ads117x_dt_ids[] = {
  67. { .compatible = "ti,ads1174" },
  68. { .compatible = "ti,ads1178" },
  69. { },
  70. };
  71. MODULE_DEVICE_TABLE(of, ads117x_dt_ids);
  72. #endif
  73. static struct platform_driver ads117x_codec_driver = {
  74. .driver = {
  75. .name = "ads117x-codec",
  76. .of_match_table = of_match_ptr(ads117x_dt_ids),
  77. },
  78. .probe = ads117x_probe,
  79. };
  80. module_platform_driver(ads117x_codec_driver);
  81. MODULE_DESCRIPTION("ASoC ads117x driver");
  82. MODULE_AUTHOR("Graeme Gregory");
  83. MODULE_LICENSE("GPL");