tlv320aic32x4-i2c.c 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /* SPDX-License-Identifier: GPL-2.0
  2. *
  3. * Copyright 2011-2019 NW Digital Radio
  4. *
  5. * Author: Annaliese McDermond <nh6z@nh6z.net>
  6. *
  7. * Based on sound/soc/codecs/wm8974 and TI driver for kernel 2.6.27.
  8. *
  9. */
  10. #include <linux/i2c.h>
  11. #include <linux/module.h>
  12. #include <linux/of.h>
  13. #include <linux/regmap.h>
  14. #include <sound/soc.h>
  15. #include "tlv320aic32x4.h"
  16. static int aic32x4_i2c_probe(struct i2c_client *i2c,
  17. const struct i2c_device_id *id)
  18. {
  19. struct regmap *regmap;
  20. struct regmap_config config;
  21. config = aic32x4_regmap_config;
  22. config.reg_bits = 8;
  23. config.val_bits = 8;
  24. regmap = devm_regmap_init_i2c(i2c, &config);
  25. return aic32x4_probe(&i2c->dev, regmap);
  26. }
  27. static int aic32x4_i2c_remove(struct i2c_client *i2c)
  28. {
  29. return aic32x4_remove(&i2c->dev);
  30. }
  31. static const struct i2c_device_id aic32x4_i2c_id[] = {
  32. { "tlv320aic32x4", 0 },
  33. { "tlv320aic32x6", 1 },
  34. { /* sentinel */ }
  35. };
  36. MODULE_DEVICE_TABLE(i2c, aic32x4_i2c_id);
  37. static const struct of_device_id aic32x4_of_id[] = {
  38. { .compatible = "ti,tlv320aic32x4", },
  39. { .compatible = "ti,tlv320aic32x6", },
  40. { /* senitel */ }
  41. };
  42. MODULE_DEVICE_TABLE(of, aic32x4_of_id);
  43. static struct i2c_driver aic32x4_i2c_driver = {
  44. .driver = {
  45. .name = "tlv320aic32x4",
  46. .of_match_table = aic32x4_of_id,
  47. },
  48. .probe = aic32x4_i2c_probe,
  49. .remove = aic32x4_i2c_remove,
  50. .id_table = aic32x4_i2c_id,
  51. };
  52. module_i2c_driver(aic32x4_i2c_driver);
  53. MODULE_DESCRIPTION("ASoC TLV320AIC32x4 codec driver I2C");
  54. MODULE_AUTHOR("Annaliese McDermond <nh6z@nh6z.net>");
  55. MODULE_LICENSE("GPL");