Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0
0002 /*
0003  * Analog Devices LTC2947 high precision power and energy monitor over I2C
0004  *
0005  * Copyright 2019 Analog Devices Inc.
0006  */
0007 #include <linux/i2c.h>
0008 #include <linux/module.h>
0009 #include <linux/regmap.h>
0010 
0011 #include "ltc2947.h"
0012 
0013 static const struct regmap_config ltc2947_regmap_config = {
0014     .reg_bits = 8,
0015     .val_bits = 8,
0016 };
0017 
0018 static int ltc2947_probe(struct i2c_client *i2c)
0019 {
0020     struct regmap *map;
0021 
0022     map = devm_regmap_init_i2c(i2c, &ltc2947_regmap_config);
0023     if (IS_ERR(map))
0024         return PTR_ERR(map);
0025 
0026     return ltc2947_core_probe(map, i2c->name);
0027 }
0028 
0029 static const struct i2c_device_id ltc2947_id[] = {
0030     {"ltc2947", 0},
0031     {}
0032 };
0033 MODULE_DEVICE_TABLE(i2c, ltc2947_id);
0034 
0035 static struct i2c_driver ltc2947_driver = {
0036     .driver = {
0037         .name = "ltc2947",
0038         .of_match_table = ltc2947_of_match,
0039         .pm = &ltc2947_pm_ops,
0040     },
0041     .probe_new = ltc2947_probe,
0042     .id_table = ltc2947_id,
0043 };
0044 module_i2c_driver(ltc2947_driver);
0045 
0046 MODULE_AUTHOR("Nuno Sa <nuno.sa@analog.com>");
0047 MODULE_DESCRIPTION("LTC2947 I2C power and energy monitor driver");
0048 MODULE_LICENSE("GPL");