ad193x-i2c.c 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /*
  2. * AD1936/AD1937 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/i2c.h>
  10. #include <linux/regmap.h>
  11. #include <sound/soc.h>
  12. #include "ad193x.h"
  13. static const struct i2c_device_id ad193x_id[] = {
  14. { "ad1936", AD193X },
  15. { "ad1937", AD193X },
  16. { }
  17. };
  18. MODULE_DEVICE_TABLE(i2c, ad193x_id);
  19. static int ad193x_i2c_probe(struct i2c_client *client,
  20. const struct i2c_device_id *id)
  21. {
  22. struct regmap_config config;
  23. config = ad193x_regmap_config;
  24. config.val_bits = 8;
  25. config.reg_bits = 8;
  26. return ad193x_probe(&client->dev,
  27. devm_regmap_init_i2c(client, &config),
  28. (enum ad193x_type)id->driver_data);
  29. }
  30. static int ad193x_i2c_remove(struct i2c_client *client)
  31. {
  32. snd_soc_unregister_codec(&client->dev);
  33. return 0;
  34. }
  35. static struct i2c_driver ad193x_i2c_driver = {
  36. .driver = {
  37. .name = "ad193x",
  38. },
  39. .probe = ad193x_i2c_probe,
  40. .remove = ad193x_i2c_remove,
  41. .id_table = ad193x_id,
  42. };
  43. module_i2c_driver(ad193x_i2c_driver);
  44. MODULE_DESCRIPTION("ASoC AD1936/AD1937 audio CODEC driver");
  45. MODULE_AUTHOR("Barry Song <21cnbao@gmail.com>");
  46. MODULE_LICENSE("GPL");