ltc2947-i2c.c 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * Analog Devices LTC2947 high precision power and energy monitor over I2C
  4. *
  5. * Copyright 2019 Analog Devices Inc.
  6. */
  7. #include <linux/i2c.h>
  8. #include <linux/module.h>
  9. #include <linux/regmap.h>
  10. #include "ltc2947.h"
  11. static const struct regmap_config ltc2947_regmap_config = {
  12. .reg_bits = 8,
  13. .val_bits = 8,
  14. };
  15. static int ltc2947_probe(struct i2c_client *i2c)
  16. {
  17. struct regmap *map;
  18. map = devm_regmap_init_i2c(i2c, &ltc2947_regmap_config);
  19. if (IS_ERR(map))
  20. return PTR_ERR(map);
  21. return ltc2947_core_probe(map, i2c->name);
  22. }
  23. static const struct i2c_device_id ltc2947_id[] = {
  24. {"ltc2947", 0},
  25. {}
  26. };
  27. MODULE_DEVICE_TABLE(i2c, ltc2947_id);
  28. static struct i2c_driver ltc2947_driver = {
  29. .driver = {
  30. .name = "ltc2947",
  31. .of_match_table = ltc2947_of_match,
  32. .pm = &ltc2947_pm_ops,
  33. },
  34. .probe_new = ltc2947_probe,
  35. .id_table = ltc2947_id,
  36. };
  37. module_i2c_driver(ltc2947_driver);
  38. MODULE_AUTHOR("Nuno Sa <nuno.sa@analog.com>");
  39. MODULE_DESCRIPTION("LTC2947 I2C power and energy monitor driver");
  40. MODULE_LICENSE("GPL");