#include <linux/unaligned.h>
#include <linux/bitfield.h>
#include <linux/i2c.h>
#include <linux/iio/events.h>
#include <linux/iio/iio.h>
#include <linux/iio/trigger_consumer.h>
#include <linux/iio/triggered_buffer.h>
#include <linux/regmap.h>
#include <linux/units.h>
#define PAC1921_REG_GAIN_CFG …
#define PAC1921_REG_INT_CFG …
#define PAC1921_REG_CONTROL …
#define PAC1921_REG_VBUS …
#define PAC1921_REG_VSENSE …
#define PAC1921_REG_OVERFLOW_STS …
#define PAC1921_REG_VPOWER …
#define PAC1921_GAIN_DI_GAIN_MASK …
#define PAC1921_GAIN_DV_GAIN_MASK …
#define PAC1921_INT_CFG_SMPL_MASK …
#define PAC1921_INT_CFG_VSFEN …
#define PAC1921_INT_CFG_VBFEN …
#define PAC1921_INT_CFG_RIOV …
#define PAC1921_INT_CFG_INTEN …
#define PAC1921_CONTROL_MXSL_MASK …
enum pac1921_mxsl { … };
#define PAC1921_CONTROL_SLEEP …
#define PAC1921_RES_MASK …
#define PAC1921_RES_RESOLUTION …
#define PAC1921_OVERFLOW_VSOV …
#define PAC1921_OVERFLOW_VBOV …
#define PAC1921_OVERFLOW_VPOV …
#define PAC1921_MAX_VSENSE_MV …
#define PAC1921_MAX_VBUS_V …
#define PAC1921_POWERUP_TIME_MS …
#define PAC1921_SLEEP_TO_INT_TIME_US …
#define PAC1921_DEFAULT_DV_GAIN …
#define PAC1921_DEFAULT_DI_GAIN …
#define PAC1921_DEFAULT_NUM_SAMPLES …
static const int pac1921_vbus_scales[][2] = …;
static const int pac1921_vsense_scales[][2] = …;
static const int pac1921_int_num_samples[] = …;
static const unsigned int pac1921_int_periods_usecs[] = …;
static const struct regmap_range pac1921_regmap_wr_ranges[] = …;
static const struct regmap_access_table pac1921_regmap_wr_table = …;
static const struct regmap_range pac1921_regmap_rd_ranges[] = …;
static const struct regmap_access_table pac1921_regmap_rd_table = …;
static const struct regmap_config pac1921_regmap_config = …;
enum pac1921_channels { … };
#define PAC1921_NUM_MEAS_CHANS …
struct pac1921_priv { … };
static bool pac1921_data_ready(struct pac1921_priv *priv)
{ … }
static inline void pac1921_calc_scale(int dividend, int divisor, int *val,
int *val2)
{ … }
static void pac1921_calc_current_scales(struct pac1921_priv *priv)
{ … }
static int pac1921_check_push_overflow(struct iio_dev *indio_dev, s64 timestamp)
{ … }
static int pac1921_read_res(struct pac1921_priv *priv, unsigned long reg,
u16 *val)
{ … }
static int pac1921_read_raw(struct iio_dev *indio_dev,
struct iio_chan_spec const *chan, int *val,
int *val2, long mask)
{ … }
static int pac1921_read_avail(struct iio_dev *indio_dev,
struct iio_chan_spec const *chan,
const int **vals, int *type, int *length,
long mask)
{ … }
static int pac1921_update_cfg_reg(struct pac1921_priv *priv, unsigned int reg,
unsigned int mask, unsigned int val)
{ … }
static int pac1921_lookup_scale(const int (*const scales_tbl)[2], size_t size,
int scale_val, int scale_val2)
{ … }
static int pac1921_update_gain(struct pac1921_priv *priv, u8 *priv_val, u8 gain,
unsigned int mask)
{ … }
static int pac1921_update_gain_from_scale(struct pac1921_priv *priv,
struct iio_chan_spec const *chan,
int scale_val, int scale_val2)
{ … }
static int pac1921_lookup_int_num_samples(int num_samples)
{ … }
static int pac1921_update_int_num_samples(struct pac1921_priv *priv,
int num_samples)
{ … }
static int pac1921_write_raw_get_fmt(struct iio_dev *indio_dev,
struct iio_chan_spec const *chan,
long info)
{ … }
static int pac1921_write_raw(struct iio_dev *indio_dev,
struct iio_chan_spec const *chan, int val,
int val2, long mask)
{ … }
static int pac1921_read_label(struct iio_dev *indio_dev,
struct iio_chan_spec const *chan, char *label)
{ … }
static int pac1921_read_event_config(struct iio_dev *indio_dev,
const struct iio_chan_spec *chan,
enum iio_event_type type,
enum iio_event_direction dir)
{ … }
static int pac1921_write_event_config(struct iio_dev *indio_dev,
const struct iio_chan_spec *chan,
enum iio_event_type type,
enum iio_event_direction dir, int state)
{ … }
static int pac1921_read_event_value(struct iio_dev *indio_dev,
const struct iio_chan_spec *chan,
enum iio_event_type type,
enum iio_event_direction dir,
enum iio_event_info info, int *val,
int *val2)
{ … }
static const struct iio_info pac1921_iio = …;
static ssize_t pac1921_read_shunt_resistor(struct iio_dev *indio_dev,
uintptr_t private,
const struct iio_chan_spec *chan,
char *buf)
{ … }
static ssize_t pac1921_write_shunt_resistor(struct iio_dev *indio_dev,
uintptr_t private,
const struct iio_chan_spec *chan,
const char *buf, size_t len)
{ … }
static ssize_t pac1921_format_scale_avail(const int (*const scales_tbl)[2],
size_t size, char *buf)
{ … }
static ssize_t pac1921_read_scale_avail(struct iio_dev *indio_dev,
uintptr_t private,
const struct iio_chan_spec *chan,
char *buf)
{ … }
#define PAC1921_EXT_INFO_SCALE_AVAIL …
static const struct iio_chan_spec_ext_info pac1921_ext_info_voltage[] = …;
static const struct iio_chan_spec_ext_info pac1921_ext_info_current[] = …;
static const struct iio_event_spec pac1921_overflow_event[] = …;
static const struct iio_chan_spec pac1921_channels[] = …;
static irqreturn_t pac1921_trigger_handler(int irq, void *p)
{ … }
static int pac1921_init(struct pac1921_priv *priv)
{ … }
static int pac1921_suspend(struct device *dev)
{ … }
static int pac1921_resume(struct device *dev)
{ … }
static DEFINE_SIMPLE_DEV_PM_OPS(pac1921_pm_ops, pac1921_suspend,
pac1921_resume);
static void pac1921_regulator_disable(void *data)
{ … }
static int pac1921_probe(struct i2c_client *client)
{ … }
static const struct i2c_device_id pac1921_id[] = …;
MODULE_DEVICE_TABLE(i2c, pac1921_id);
static const struct of_device_id pac1921_of_match[] = …;
MODULE_DEVICE_TABLE(of, pac1921_of_match);
static struct i2c_driver pac1921_driver = …;
module_i2c_driver(…) …;
MODULE_AUTHOR(…) …;
MODULE_DESCRIPTION(…) …;
MODULE_LICENSE(…) …;