ics43432.c 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * I2S MEMS microphone driver for InvenSense ICS-43432 and similar
  4. * MEMS-based microphones.
  5. *
  6. * - Non configurable.
  7. * - I2S interface, 64 BCLs per frame, 32 bits per channel, 24 bit data
  8. *
  9. * Copyright (c) 2015 Axis Communications AB
  10. */
  11. #include <linux/module.h>
  12. #include <linux/init.h>
  13. #include <linux/slab.h>
  14. #include <sound/core.h>
  15. #include <sound/pcm.h>
  16. #include <sound/pcm_params.h>
  17. #include <sound/soc.h>
  18. #include <sound/initval.h>
  19. #include <sound/tlv.h>
  20. #define ICS43432_RATE_MIN 7190 /* Hz, from data sheet */
  21. #define ICS43432_RATE_MAX 52800 /* Hz, from data sheet */
  22. #define ICS43432_FORMATS (SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32)
  23. static struct snd_soc_dai_driver ics43432_dai = {
  24. .name = "ics43432-hifi",
  25. .capture = {
  26. .stream_name = "Capture",
  27. .channels_min = 1,
  28. .channels_max = 2,
  29. .rate_min = ICS43432_RATE_MIN,
  30. .rate_max = ICS43432_RATE_MAX,
  31. .rates = SNDRV_PCM_RATE_CONTINUOUS,
  32. .formats = ICS43432_FORMATS,
  33. },
  34. };
  35. static const struct snd_soc_component_driver ics43432_component_driver = {
  36. .idle_bias_on = 1,
  37. .use_pmdown_time = 1,
  38. .endianness = 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. { .compatible = "cui,cmm-4030d-261", },
  50. { }
  51. };
  52. MODULE_DEVICE_TABLE(of, ics43432_ids);
  53. #endif
  54. static struct platform_driver ics43432_driver = {
  55. .driver = {
  56. .name = "ics43432",
  57. .of_match_table = of_match_ptr(ics43432_ids),
  58. },
  59. .probe = ics43432_probe,
  60. };
  61. module_platform_driver(ics43432_driver);
  62. MODULE_DESCRIPTION("ASoC ICS43432 driver");
  63. MODULE_AUTHOR("Ricard Wanderlof <[email protected]>");
  64. MODULE_LICENSE("GPL v2");