linux/drivers/hwmon/ltc4260.c

// SPDX-License-Identifier: GPL-2.0-or-later
/*
 * Driver for Linear Technology LTC4260 I2C Positive Voltage Hot Swap Controller
 *
 * Copyright (c) 2014 Guenter Roeck
 */

#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/err.h>
#include <linux/slab.h>
#include <linux/i2c.h>
#include <linux/hwmon.h>
#include <linux/hwmon-sysfs.h>
#include <linux/jiffies.h>
#include <linux/regmap.h>

/* chip registers */
#define LTC4260_CONTROL
#define LTC4260_ALERT
#define LTC4260_STATUS
#define LTC4260_FAULT
#define LTC4260_SENSE
#define LTC4260_SOURCE
#define LTC4260_ADIN

/*
 * Fault register bits
 */
#define FAULT_OV
#define FAULT_UV
#define FAULT_OC
#define FAULT_POWER_BAD
#define FAULT_FET_SHORT

/* Return the voltage from the given register in mV or mA */
static int ltc4260_get_value(struct device *dev, u8 reg)
{}

static ssize_t ltc4260_value_show(struct device *dev,
				  struct device_attribute *da, char *buf)
{}

static ssize_t ltc4260_bool_show(struct device *dev,
				 struct device_attribute *da, char *buf)
{}

/* Voltages */
static SENSOR_DEVICE_ATTR_RO(in1_input, ltc4260_value, LTC4260_SOURCE);
static SENSOR_DEVICE_ATTR_RO(in2_input, ltc4260_value, LTC4260_ADIN);

/*
 * Voltage alarms
 * UV/OV faults are associated with the input voltage, and the POWER BAD and
 * FET SHORT faults are associated with the output voltage.
 */
static SENSOR_DEVICE_ATTR_RO(in1_min_alarm, ltc4260_bool, FAULT_UV);
static SENSOR_DEVICE_ATTR_RO(in1_max_alarm, ltc4260_bool, FAULT_OV);
static SENSOR_DEVICE_ATTR_RO(in2_alarm, ltc4260_bool,
			     FAULT_POWER_BAD | FAULT_FET_SHORT);

/* Current (via sense resistor) */
static SENSOR_DEVICE_ATTR_RO(curr1_input, ltc4260_value, LTC4260_SENSE);

/* Overcurrent alarm */
static SENSOR_DEVICE_ATTR_RO(curr1_max_alarm, ltc4260_bool, FAULT_OC);

static struct attribute *ltc4260_attrs[] =;
ATTRIBUTE_GROUPS();

static const struct regmap_config ltc4260_regmap_config =;

static int ltc4260_probe(struct i2c_client *client)
{}

static const struct i2c_device_id ltc4260_id[] =;

MODULE_DEVICE_TABLE(i2c, ltc4260_id);

static struct i2c_driver ltc4260_driver =;

module_i2c_driver();

MODULE_AUTHOR();
MODULE_DESCRIPTION();
MODULE_LICENSE();