linux/drivers/hwmon/ltc2947-i2c.c
Nuno Sá 9f90fd652b hwmon: Add support for ltc2947
The ltc2947 is a high precision power and energy monitor with an
internal sense resistor supporting up to +/- 30A. Three internal no
Latency ADCs ensure accurate measurement of voltage and current, while
high-bandwidth analog multiplication of voltage and current provides
accurate power measurement in a wide range of applications. Internal or
external clocking options enable precise charge and energy measurements.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
Link: https://lore.kernel.org/r/20191021154115.319073-1-nuno.sa@analog.com
[groeck: Removed unnecessary checks when reading temperature and energy;
	 PAGE{0,1} -> LTC2947_PAGE_{0,1}]
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2019-11-06 14:37:19 -08:00

50 lines
1.1 KiB
C

// SPDX-License-Identifier: GPL-2.0
/*
* Analog Devices LTC2947 high precision power and energy monitor over I2C
*
* Copyright 2019 Analog Devices Inc.
*/
#include <linux/i2c.h>
#include <linux/module.h>
#include <linux/regmap.h>
#include "ltc2947.h"
static const struct regmap_config ltc2947_regmap_config = {
.reg_bits = 8,
.val_bits = 8,
};
static int ltc2947_probe(struct i2c_client *i2c,
const struct i2c_device_id *id)
{
struct regmap *map;
map = devm_regmap_init_i2c(i2c, &ltc2947_regmap_config);
if (IS_ERR(map))
return PTR_ERR(map);
return ltc2947_core_probe(map, i2c->name);
}
static const struct i2c_device_id ltc2947_id[] = {
{"ltc2947", 0},
{}
};
MODULE_DEVICE_TABLE(i2c, ltc2947_id);
static struct i2c_driver ltc2947_driver = {
.driver = {
.name = "ltc2947",
.of_match_table = ltc2947_of_match,
.pm = &ltc2947_pm_ops,
},
.probe = ltc2947_probe,
.id_table = ltc2947_id,
};
module_i2c_driver(ltc2947_driver);
MODULE_AUTHOR("Nuno Sa <nuno.sa@analog.com>");
MODULE_DESCRIPTION("LTC2947 I2C power and energy monitor driver");
MODULE_LICENSE("GPL");