18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * Analog Devices LTC2947 high precision power and energy monitor over I2C
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci * Copyright 2019 Analog Devices Inc.
68c2ecf20Sopenharmony_ci */
78c2ecf20Sopenharmony_ci#include <linux/i2c.h>
88c2ecf20Sopenharmony_ci#include <linux/module.h>
98c2ecf20Sopenharmony_ci#include <linux/regmap.h>
108c2ecf20Sopenharmony_ci
118c2ecf20Sopenharmony_ci#include "ltc2947.h"
128c2ecf20Sopenharmony_ci
138c2ecf20Sopenharmony_cistatic const struct regmap_config ltc2947_regmap_config = {
148c2ecf20Sopenharmony_ci	.reg_bits = 8,
158c2ecf20Sopenharmony_ci	.val_bits = 8,
168c2ecf20Sopenharmony_ci};
178c2ecf20Sopenharmony_ci
188c2ecf20Sopenharmony_cistatic int ltc2947_probe(struct i2c_client *i2c)
198c2ecf20Sopenharmony_ci{
208c2ecf20Sopenharmony_ci	struct regmap *map;
218c2ecf20Sopenharmony_ci
228c2ecf20Sopenharmony_ci	map = devm_regmap_init_i2c(i2c, &ltc2947_regmap_config);
238c2ecf20Sopenharmony_ci	if (IS_ERR(map))
248c2ecf20Sopenharmony_ci		return PTR_ERR(map);
258c2ecf20Sopenharmony_ci
268c2ecf20Sopenharmony_ci	return ltc2947_core_probe(map, i2c->name);
278c2ecf20Sopenharmony_ci}
288c2ecf20Sopenharmony_ci
298c2ecf20Sopenharmony_cistatic const struct i2c_device_id ltc2947_id[] = {
308c2ecf20Sopenharmony_ci	{"ltc2947", 0},
318c2ecf20Sopenharmony_ci	{}
328c2ecf20Sopenharmony_ci};
338c2ecf20Sopenharmony_ciMODULE_DEVICE_TABLE(i2c, ltc2947_id);
348c2ecf20Sopenharmony_ci
358c2ecf20Sopenharmony_cistatic struct i2c_driver ltc2947_driver = {
368c2ecf20Sopenharmony_ci	.driver = {
378c2ecf20Sopenharmony_ci		.name = "ltc2947",
388c2ecf20Sopenharmony_ci		.of_match_table = ltc2947_of_match,
398c2ecf20Sopenharmony_ci		.pm = &ltc2947_pm_ops,
408c2ecf20Sopenharmony_ci	},
418c2ecf20Sopenharmony_ci	.probe_new = ltc2947_probe,
428c2ecf20Sopenharmony_ci	.id_table = ltc2947_id,
438c2ecf20Sopenharmony_ci};
448c2ecf20Sopenharmony_cimodule_i2c_driver(ltc2947_driver);
458c2ecf20Sopenharmony_ci
468c2ecf20Sopenharmony_ciMODULE_AUTHOR("Nuno Sa <nuno.sa@analog.com>");
478c2ecf20Sopenharmony_ciMODULE_DESCRIPTION("LTC2947 I2C power and energy monitor driver");
488c2ecf20Sopenharmony_ciMODULE_LICENSE("GPL");
49