ics43432.c 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * I2S MEMS microphone driver for InvenSense ICS-43432
  4. *
  5. * - Non configurable.
  6. * - I2S interface, 64 BCLs per frame, 32 bits per channel, 24 bit data
  7. *
  8. * Copyright (c) 2015 Axis Communications AB
  9. */
  10. #include <linux/module.h>
  11. #include <linux/init.h>
  12. #include <linux/slab.h>
  13. #include <sound/core.h>
  14. #include <sound/pcm.h>
  15. #include <sound/pcm_params.h>
  16. #include <sound/soc.h>
  17. #include <sound/initval.h>
  18. #include <sound/tlv.h>
  19. #define ICS43432_RATE_MIN 7190 /* Hz, from data sheet */
  20. #define ICS43432_RATE_MAX 52800 /* Hz, from data sheet */
  21. #define ICS43432_FORMATS (SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32)
  22. static struct snd_soc_dai_driver ics43432_dai = {
  23. .name = "ics43432-hifi",
  24. .capture = {
  25. .stream_name = "Capture",
  26. .channels_min = 1,
  27. .channels_max = 2,
  28. .rate_min = ICS43432_RATE_MIN,
  29. .rate_max = ICS43432_RATE_MAX,
  30. .rates = SNDRV_PCM_RATE_CONTINUOUS,
  31. .formats = ICS43432_FORMATS,
  32. },
  33. };
  34. static const struct snd_soc_component_driver ics43432_component_driver = {
  35. .idle_bias_on = 1,
  36. .use_pmdown_time = 1,
  37. .endianness = 1,
  38. .non_legacy_dai_naming = 1,
  39. };
  40. static int ics43432_probe(struct platform_device *pdev)
  41. {
  42. return devm_snd_soc_register_component(&pdev->dev,
  43. &ics43432_component_driver,
  44. &ics43432_dai, 1);
  45. }
  46. #ifdef CONFIG_OF
  47. static const struct of_device_id ics43432_ids[] = {
  48. { .compatible = "invensense,ics43432", },
  49. { }
  50. };
  51. MODULE_DEVICE_TABLE(of, ics43432_ids);
  52. #endif
  53. static struct platform_driver ics43432_driver = {
  54. .driver = {
  55. .name = "ics43432",
  56. .of_match_table = of_match_ptr(ics43432_ids),
  57. },
  58. .probe = ics43432_probe,
  59. };
  60. module_platform_driver(ics43432_driver);
  61. MODULE_DESCRIPTION("ASoC ICS43432 driver");
  62. MODULE_AUTHOR("Ricard Wanderlof <ricardw@axis.com>");
  63. MODULE_LICENSE("GPL v2");