linux/drivers/hwmon/ina3221.c

// SPDX-License-Identifier: GPL-2.0-only
/*
 * INA3221 Triple Current/Voltage Monitor
 *
 * Copyright (C) 2016 Texas Instruments Incorporated - https://www.ti.com/
 *	Andrew F. Davis <[email protected]>
 */

#include <linux/debugfs.h>
#include <linux/hwmon.h>
#include <linux/hwmon-sysfs.h>
#include <linux/i2c.h>
#include <linux/module.h>
#include <linux/mutex.h>
#include <linux/of.h>
#include <linux/pm_runtime.h>
#include <linux/regmap.h>
#include <linux/util_macros.h>

#define INA3221_DRIVER_NAME

#define INA3221_CONFIG
#define INA3221_SHUNT1
#define INA3221_BUS1
#define INA3221_SHUNT2
#define INA3221_BUS2
#define INA3221_SHUNT3
#define INA3221_BUS3
#define INA3221_CRIT1
#define INA3221_WARN1
#define INA3221_CRIT2
#define INA3221_WARN2
#define INA3221_CRIT3
#define INA3221_WARN3
#define INA3221_SHUNT_SUM
#define INA3221_CRIT_SUM
#define INA3221_MASK_ENABLE

#define INA3221_CONFIG_MODE_MASK
#define INA3221_CONFIG_MODE_POWERDOWN
#define INA3221_CONFIG_MODE_SHUNT
#define INA3221_CONFIG_MODE_BUS
#define INA3221_CONFIG_MODE_CONTINUOUS
#define INA3221_CONFIG_VSH_CT_SHIFT
#define INA3221_CONFIG_VSH_CT_MASK
#define INA3221_CONFIG_VSH_CT(x)
#define INA3221_CONFIG_VBUS_CT_SHIFT
#define INA3221_CONFIG_VBUS_CT_MASK
#define INA3221_CONFIG_VBUS_CT(x)
#define INA3221_CONFIG_AVG_SHIFT
#define INA3221_CONFIG_AVG_MASK
#define INA3221_CONFIG_AVG(x)
#define INA3221_CONFIG_CHs_EN_MASK
#define INA3221_CONFIG_CHx_EN(x)

#define INA3221_MASK_ENABLE_SCC_MASK

#define INA3221_CONFIG_DEFAULT
#define INA3221_RSHUNT_DEFAULT

enum ina3221_fields {};

static const struct reg_field ina3221_reg_fields[] =;

enum ina3221_channels {};

/**
 * struct ina3221_input - channel input source specific information
 * @label: label of channel input source
 * @shunt_resistor: shunt resistor value of channel input source
 * @disconnected: connection status of channel input source
 * @summation_disable: channel summation status of input source
 */
struct ina3221_input {};

/**
 * struct ina3221_data - device specific information
 * @pm_dev: Device pointer for pm runtime
 * @regmap: Register map of the device
 * @fields: Register fields of the device
 * @inputs: Array of channel input source specific structures
 * @lock: mutex lock to serialize sysfs attribute accesses
 * @debugfs: Pointer to debugfs entry for device
 * @reg_config: Register value of INA3221_CONFIG
 * @summation_shunt_resistor: equivalent shunt resistor value for summation
 * @summation_channel_control: Value written to SCC field in INA3221_MASK_ENABLE
 * @single_shot: running in single-shot operating mode
 */
struct ina3221_data {};

static inline bool ina3221_is_enabled(struct ina3221_data *ina, int channel)
{}

/*
 * Helper function to return the resistor value for current summation.
 *
 * There is a condition to calculate current summation -- all the shunt
 * resistor values should be the same, so as to simply fit the formula:
 *     current summation = shunt voltage summation / shunt resistor
 *
 * Returns the equivalent shunt resistor value on success or 0 on failure
 */
static inline int ina3221_summation_shunt_resistor(struct ina3221_data *ina)
{}

/* Lookup table for Bus and Shunt conversion times in usec */
static const u16 ina3221_conv_time[] =;

/* Lookup table for number of samples using in averaging mode */
static const int ina3221_avg_samples[] =;

/* Converting update_interval in msec to conversion time in usec */
static inline u32 ina3221_interval_ms_to_conv_time(u16 config, int interval)
{}

/* Converting CONFIG register value to update_interval in usec */
static inline u32 ina3221_reg_to_interval_us(u16 config)
{}

static inline int ina3221_wait_for_data(struct ina3221_data *ina)
{}

static int ina3221_read_value(struct ina3221_data *ina, unsigned int reg,
			      int *val)
{}

static const u8 ina3221_in_reg[] =;

static int ina3221_read_chip(struct device *dev, u32 attr, long *val)
{}

static int ina3221_read_in(struct device *dev, u32 attr, int channel, long *val)
{}

static const u8 ina3221_curr_reg[][INA3221_NUM_CHANNELS + 1] =;

static int ina3221_read_curr(struct device *dev, u32 attr,
			     int channel, long *val)
{}

static int ina3221_write_chip(struct device *dev, u32 attr, long val)
{}

static int ina3221_write_curr(struct device *dev, u32 attr,
			      int channel, long val)
{}

static int ina3221_write_enable(struct device *dev, int channel, bool enable)
{}

static int ina3221_read(struct device *dev, enum hwmon_sensor_types type,
			u32 attr, int channel, long *val)
{}

static int ina3221_write(struct device *dev, enum hwmon_sensor_types type,
			 u32 attr, int channel, long val)
{}

static int ina3221_read_string(struct device *dev, enum hwmon_sensor_types type,
			       u32 attr, int channel, const char **str)
{}

static umode_t ina3221_is_visible(const void *drvdata,
				  enum hwmon_sensor_types type,
				  u32 attr, int channel)
{}

#define INA3221_HWMON_CURR_CONFIG

static const struct hwmon_channel_info * const ina3221_info[] =;

static const struct hwmon_ops ina3221_hwmon_ops =;

static const struct hwmon_chip_info ina3221_chip_info =;

/* Extra attribute groups */
static ssize_t ina3221_shunt_show(struct device *dev,
				  struct device_attribute *attr, char *buf)
{}

static ssize_t ina3221_shunt_store(struct device *dev,
				   struct device_attribute *attr,
				   const char *buf, size_t count)
{}

/* shunt resistance */
static SENSOR_DEVICE_ATTR_RW(shunt1_resistor, ina3221_shunt, INA3221_CHANNEL1);
static SENSOR_DEVICE_ATTR_RW(shunt2_resistor, ina3221_shunt, INA3221_CHANNEL2);
static SENSOR_DEVICE_ATTR_RW(shunt3_resistor, ina3221_shunt, INA3221_CHANNEL3);

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

static const struct regmap_range ina3221_yes_ranges[] =;

static const struct regmap_access_table ina3221_volatile_table =;

static const struct regmap_config ina3221_regmap_config =;

static int ina3221_probe_child_from_dt(struct device *dev,
				       struct device_node *child,
				       struct ina3221_data *ina)
{}

static int ina3221_probe_from_dt(struct device *dev, struct ina3221_data *ina)
{}

static int ina3221_probe(struct i2c_client *client)
{}

static void ina3221_remove(struct i2c_client *client)
{}

static int ina3221_suspend(struct device *dev)
{}

static int ina3221_resume(struct device *dev)
{}

static DEFINE_RUNTIME_DEV_PM_OPS(ina3221_pm, ina3221_suspend, ina3221_resume,
				 NULL);

static const struct of_device_id ina3221_of_match_table[] =;
MODULE_DEVICE_TABLE(of, ina3221_of_match_table);

static const struct i2c_device_id ina3221_ids[] =;
MODULE_DEVICE_TABLE(i2c, ina3221_ids);

static struct i2c_driver ina3221_i2c_driver =;
module_i2c_driver();

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