WIP FPC-III support
[linux/fpc-iii.git] / drivers / hwmon / ltc2947-spi.c
blobc24ca569db1b2c12e19d62ec7bcc243db6982206
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3 * Analog Devices LTC2947 high precision power and energy monitor over SPI
5 * Copyright 2019 Analog Devices Inc.
6 */
7 #include <linux/module.h>
8 #include <linux/of.h>
9 #include <linux/regmap.h>
10 #include <linux/spi/spi.h>
12 #include "ltc2947.h"
14 static const struct regmap_config ltc2947_regmap_config = {
15 .reg_bits = 16,
16 .val_bits = 8,
17 .read_flag_mask = BIT(0),
20 static int ltc2947_probe(struct spi_device *spi)
22 struct regmap *map;
24 map = devm_regmap_init_spi(spi, &ltc2947_regmap_config);
25 if (IS_ERR(map))
26 return PTR_ERR(map);
28 return ltc2947_core_probe(map, spi_get_device_id(spi)->name);
31 static const struct spi_device_id ltc2947_id[] = {
32 {"ltc2947", 0},
35 MODULE_DEVICE_TABLE(spi, ltc2947_id);
37 static struct spi_driver ltc2947_driver = {
38 .driver = {
39 .name = "ltc2947",
40 .of_match_table = ltc2947_of_match,
41 .pm = &ltc2947_pm_ops,
43 .probe = ltc2947_probe,
44 .id_table = ltc2947_id,
46 module_spi_driver(ltc2947_driver);
48 MODULE_AUTHOR("Nuno Sa <nuno.sa@analog.com>");
49 MODULE_DESCRIPTION("LTC2947 SPI power and energy monitor driver");
50 MODULE_LICENSE("GPL");