0001
0002
0003
0004
0005
0006
0007 #include <linux/module.h>
0008 #include <linux/of.h>
0009 #include <linux/regmap.h>
0010 #include <linux/spi/spi.h>
0011
0012 #include "ltc2947.h"
0013
0014 static const struct regmap_config ltc2947_regmap_config = {
0015 .reg_bits = 16,
0016 .val_bits = 8,
0017 .read_flag_mask = BIT(0),
0018 };
0019
0020 static int ltc2947_probe(struct spi_device *spi)
0021 {
0022 struct regmap *map;
0023
0024 map = devm_regmap_init_spi(spi, <c2947_regmap_config);
0025 if (IS_ERR(map))
0026 return PTR_ERR(map);
0027
0028 return ltc2947_core_probe(map, spi_get_device_id(spi)->name);
0029 }
0030
0031 static const struct spi_device_id ltc2947_id[] = {
0032 {"ltc2947", 0},
0033 {}
0034 };
0035 MODULE_DEVICE_TABLE(spi, ltc2947_id);
0036
0037 static struct spi_driver ltc2947_driver = {
0038 .driver = {
0039 .name = "ltc2947",
0040 .of_match_table = ltc2947_of_match,
0041 .pm = <c2947_pm_ops,
0042 },
0043 .probe = ltc2947_probe,
0044 .id_table = ltc2947_id,
0045 };
0046 module_spi_driver(ltc2947_driver);
0047
0048 MODULE_AUTHOR("Nuno Sa <nuno.sa@analog.com>");
0049 MODULE_DESCRIPTION("LTC2947 SPI power and energy monitor driver");
0050 MODULE_LICENSE("GPL");