ics43432.c 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /*
  2. * I2S MEMS microphone driver for InvenSense ICS-43432
  3. *
  4. * - Non configurable.
  5. * - I2S interface, 64 BCLs per frame, 32 bits per channel, 24 bit data
  6. *
  7. * Copyright (c) 2015 Axis Communications AB
  8. *
  9. * Licensed under GPL v2.
  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 struct snd_soc_codec_driver ics43432_codec_driver = {
  36. };
  37. static int ics43432_probe(struct platform_device *pdev)
  38. {
  39. return snd_soc_register_codec(&pdev->dev, &ics43432_codec_driver,
  40. &ics43432_dai, 1);
  41. }
  42. static int ics43432_remove(struct platform_device *pdev)
  43. {
  44. snd_soc_unregister_codec(&pdev->dev);
  45. return 0;
  46. }
  47. #ifdef CONFIG_OF
  48. static const struct of_device_id ics43432_ids[] = {
  49. { .compatible = "invensense,ics43432", },
  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. .remove = ics43432_remove,
  61. };
  62. module_platform_driver(ics43432_driver);
  63. MODULE_DESCRIPTION("ASoC ICS43432 driver");
  64. MODULE_AUTHOR("Ricard Wanderlof <ricardw@axis.com>");
  65. MODULE_LICENSE("GPL v2");