blob: ad0dfd3efbf89c51405169be8f9de62478c20fec [file] [log] [blame]
Nuno Sá9f90fd62019-10-21 17:41:14 +02001// 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
11#include "ltc2947.h"
12
13static const struct regmap_config ltc2947_regmap_config = {
14 .reg_bits = 8,
15 .val_bits = 8,
16};
17
Stephen Kittc1e60c0d2020-08-13 18:28:51 +020018static int ltc2947_probe(struct i2c_client *i2c)
Nuno Sá9f90fd62019-10-21 17:41:14 +020019{
20 struct regmap *map;
21
22 map = devm_regmap_init_i2c(i2c, &ltc2947_regmap_config);
23 if (IS_ERR(map))
24 return PTR_ERR(map);
25
26 return ltc2947_core_probe(map, i2c->name);
27}
28
29static const struct i2c_device_id ltc2947_id[] = {
30 {"ltc2947", 0},
31 {}
32};
33MODULE_DEVICE_TABLE(i2c, ltc2947_id);
34
35static struct i2c_driver ltc2947_driver = {
36 .driver = {
37 .name = "ltc2947",
38 .of_match_table = ltc2947_of_match,
39 .pm = &ltc2947_pm_ops,
40 },
Stephen Kittc1e60c0d2020-08-13 18:28:51 +020041 .probe_new = ltc2947_probe,
Nuno Sá9f90fd62019-10-21 17:41:14 +020042 .id_table = ltc2947_id,
43};
44module_i2c_driver(ltc2947_driver);
45
46MODULE_AUTHOR("Nuno Sa <nuno.sa@analog.com>");
47MODULE_DESCRIPTION("LTC2947 I2C power and energy monitor driver");
48MODULE_LICENSE("GPL");