ltc2947-spi.c (1131B)
1// SPDX-License-Identifier: GPL-2.0 2/* 3 * Analog Devices LTC2947 high precision power and energy monitor over SPI 4 * 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> 11 12#include "ltc2947.h" 13 14static const struct regmap_config ltc2947_regmap_config = { 15 .reg_bits = 16, 16 .val_bits = 8, 17 .read_flag_mask = BIT(0), 18}; 19 20static int ltc2947_probe(struct spi_device *spi) 21{ 22 struct regmap *map; 23 24 map = devm_regmap_init_spi(spi, <c2947_regmap_config); 25 if (IS_ERR(map)) 26 return PTR_ERR(map); 27 28 return ltc2947_core_probe(map, spi_get_device_id(spi)->name); 29} 30 31static const struct spi_device_id ltc2947_id[] = { 32 {"ltc2947", 0}, 33 {} 34}; 35MODULE_DEVICE_TABLE(spi, ltc2947_id); 36 37static struct spi_driver ltc2947_driver = { 38 .driver = { 39 .name = "ltc2947", 40 .of_match_table = ltc2947_of_match, 41 .pm = <c2947_pm_ops, 42 }, 43 .probe = ltc2947_probe, 44 .id_table = ltc2947_id, 45}; 46module_spi_driver(ltc2947_driver); 47 48MODULE_AUTHOR("Nuno Sa <nuno.sa@analog.com>"); 49MODULE_DESCRIPTION("LTC2947 SPI power and energy monitor driver"); 50MODULE_LICENSE("GPL");