ad193x-spi.c 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /*
  2. * AD1938/AD1939 audio driver
  3. *
  4. * Copyright 2014 Analog Devices Inc.
  5. *
  6. * Licensed under the GPL-2.
  7. */
  8. #include <linux/module.h>
  9. #include <linux/spi/spi.h>
  10. #include <linux/regmap.h>
  11. #include <sound/soc.h>
  12. #include "ad193x.h"
  13. static int ad193x_spi_probe(struct spi_device *spi)
  14. {
  15. const struct spi_device_id *id = spi_get_device_id(spi);
  16. struct regmap_config config;
  17. config = ad193x_regmap_config;
  18. config.val_bits = 8;
  19. config.reg_bits = 16;
  20. config.read_flag_mask = 0x09;
  21. config.write_flag_mask = 0x08;
  22. return ad193x_probe(&spi->dev, devm_regmap_init_spi(spi, &config),
  23. (enum ad193x_type)id->driver_data);
  24. }
  25. static int ad193x_spi_remove(struct spi_device *spi)
  26. {
  27. snd_soc_unregister_codec(&spi->dev);
  28. return 0;
  29. }
  30. static const struct spi_device_id ad193x_spi_id[] = {
  31. { "ad193x", AD193X },
  32. { "ad1933", AD1933 },
  33. { "ad1934", AD1934 },
  34. { "ad1938", AD193X },
  35. { "ad1939", AD193X },
  36. { "adau1328", AD193X },
  37. { }
  38. };
  39. MODULE_DEVICE_TABLE(spi, ad193x_spi_id);
  40. static struct spi_driver ad193x_spi_driver = {
  41. .driver = {
  42. .name = "ad193x",
  43. },
  44. .probe = ad193x_spi_probe,
  45. .remove = ad193x_spi_remove,
  46. .id_table = ad193x_spi_id,
  47. };
  48. module_spi_driver(ad193x_spi_driver);
  49. MODULE_DESCRIPTION("ASoC AD1938/AD1939 audio CODEC driver");
  50. MODULE_AUTHOR("Barry Song <21cnbao@gmail.com>");
  51. MODULE_LICENSE("GPL");