#include <linux/bitfield.h>
#include <linux/delay.h>
#include <linux/i2c.h>
#include <linux/interrupt.h>
#include <linux/kernel.h>
#include <linux/log2.h>
#include <linux/mod_devicetable.h>
#include <linux/module.h>
#include <linux/pm.h>
#include <linux/property.h>
#include <linux/regmap.h>
#include <linux/iio/iio.h>
#include "sx_common.h"
#define SX9310_REG_IRQ_SRC …
#define SX9310_REG_STAT0 …
#define SX9310_REG_STAT1 …
#define SX9310_REG_STAT1_COMPSTAT_MASK …
#define SX9310_REG_IRQ_MSK …
#define SX9310_CONVDONE_IRQ …
#define SX9310_FAR_IRQ …
#define SX9310_CLOSE_IRQ …
#define SX9310_REG_IRQ_FUNC …
#define SX9310_REG_PROX_CTRL0 …
#define SX9310_REG_PROX_CTRL0_SENSOREN_MASK …
#define SX9310_REG_PROX_CTRL0_SCANPERIOD_MASK …
#define SX9310_REG_PROX_CTRL0_SCANPERIOD_15MS …
#define SX9310_REG_PROX_CTRL1 …
#define SX9310_REG_PROX_CTRL2 …
#define SX9310_REG_PROX_CTRL2_COMBMODE_MASK …
#define SX9310_REG_PROX_CTRL2_COMBMODE_CS0_CS1_CS2_CS3 …
#define SX9310_REG_PROX_CTRL2_COMBMODE_CS1_CS2 …
#define SX9310_REG_PROX_CTRL2_COMBMODE_CS0_CS1 …
#define SX9310_REG_PROX_CTRL2_COMBMODE_CS3 …
#define SX9310_REG_PROX_CTRL2_SHIELDEN_MASK …
#define SX9310_REG_PROX_CTRL2_SHIELDEN_DYNAMIC …
#define SX9310_REG_PROX_CTRL2_SHIELDEN_GROUND …
#define SX9310_REG_PROX_CTRL3 …
#define SX9310_REG_PROX_CTRL3_GAIN0_MASK …
#define SX9310_REG_PROX_CTRL3_GAIN0_X8 …
#define SX9310_REG_PROX_CTRL3_GAIN12_MASK …
#define SX9310_REG_PROX_CTRL3_GAIN12_X4 …
#define SX9310_REG_PROX_CTRL4 …
#define SX9310_REG_PROX_CTRL4_RESOLUTION_MASK …
#define SX9310_REG_PROX_CTRL4_RESOLUTION_FINEST …
#define SX9310_REG_PROX_CTRL4_RESOLUTION_VERY_FINE …
#define SX9310_REG_PROX_CTRL4_RESOLUTION_FINE …
#define SX9310_REG_PROX_CTRL4_RESOLUTION_MEDIUM …
#define SX9310_REG_PROX_CTRL4_RESOLUTION_MEDIUM_COARSE …
#define SX9310_REG_PROX_CTRL4_RESOLUTION_COARSE …
#define SX9310_REG_PROX_CTRL4_RESOLUTION_VERY_COARSE …
#define SX9310_REG_PROX_CTRL4_RESOLUTION_COARSEST …
#define SX9310_REG_PROX_CTRL5 …
#define SX9310_REG_PROX_CTRL5_RANGE_SMALL …
#define SX9310_REG_PROX_CTRL5_STARTUPSENS_MASK …
#define SX9310_REG_PROX_CTRL5_STARTUPSENS_CS1 …
#define SX9310_REG_PROX_CTRL5_RAWFILT_MASK …
#define SX9310_REG_PROX_CTRL5_RAWFILT_SHIFT …
#define SX9310_REG_PROX_CTRL5_RAWFILT_1P25 …
#define SX9310_REG_PROX_CTRL6 …
#define SX9310_REG_PROX_CTRL6_AVGTHRESH_DEFAULT …
#define SX9310_REG_PROX_CTRL7 …
#define SX9310_REG_PROX_CTRL7_AVGNEGFILT_2 …
#define SX9310_REG_PROX_CTRL7_AVGPOSFILT_MASK …
#define SX9310_REG_PROX_CTRL7_AVGPOSFILT_SHIFT …
#define SX9310_REG_PROX_CTRL7_AVGPOSFILT_512 …
#define SX9310_REG_PROX_CTRL8 …
#define SX9310_REG_PROX_CTRL8_9_PTHRESH_MASK …
#define SX9310_REG_PROX_CTRL9 …
#define SX9310_REG_PROX_CTRL8_9_PTHRESH_28 …
#define SX9310_REG_PROX_CTRL8_9_PTHRESH_96 …
#define SX9310_REG_PROX_CTRL8_9_BODYTHRESH_900 …
#define SX9310_REG_PROX_CTRL8_9_BODYTHRESH_1500 …
#define SX9310_REG_PROX_CTRL10 …
#define SX9310_REG_PROX_CTRL10_HYST_MASK …
#define SX9310_REG_PROX_CTRL10_HYST_6PCT …
#define SX9310_REG_PROX_CTRL10_CLOSE_DEBOUNCE_MASK …
#define SX9310_REG_PROX_CTRL10_FAR_DEBOUNCE_MASK …
#define SX9310_REG_PROX_CTRL10_FAR_DEBOUNCE_2 …
#define SX9310_REG_PROX_CTRL11 …
#define SX9310_REG_PROX_CTRL12 …
#define SX9310_REG_PROX_CTRL13 …
#define SX9310_REG_PROX_CTRL14 …
#define SX9310_REG_PROX_CTRL15 …
#define SX9310_REG_PROX_CTRL16 …
#define SX9310_REG_PROX_CTRL17 …
#define SX9310_REG_PROX_CTRL18 …
#define SX9310_REG_PROX_CTRL19 …
#define SX9310_REG_SAR_CTRL0 …
#define SX9310_REG_SAR_CTRL0_SARDEB_4_SAMPLES …
#define SX9310_REG_SAR_CTRL0_SARHYST_8 …
#define SX9310_REG_SAR_CTRL1 …
#define SX9310_REG_SAR_CTRL1_SLOPE(_hnslope) …
#define SX9310_REG_SAR_CTRL2 …
#define SX9310_REG_SAR_CTRL2_SAROFFSET_DEFAULT …
#define SX9310_REG_SENSOR_SEL …
#define SX9310_REG_USE_MSB …
#define SX9310_REG_USE_LSB …
#define SX9310_REG_AVG_MSB …
#define SX9310_REG_AVG_LSB …
#define SX9310_REG_DIFF_MSB …
#define SX9310_REG_DIFF_LSB …
#define SX9310_REG_OFFSET_MSB …
#define SX9310_REG_OFFSET_LSB …
#define SX9310_REG_SAR_MSB …
#define SX9310_REG_SAR_LSB …
#define SX9310_REG_I2C_ADDR …
#define SX9310_REG_PAUSE …
#define SX9310_REG_WHOAMI …
#define SX9310_WHOAMI_VALUE …
#define SX9311_WHOAMI_VALUE …
#define SX9310_REG_RESET …
#define SX9310_NUM_CHANNELS …
static_assert(…);
#define SX9310_NAMED_CHANNEL(idx, name) …
#define SX9310_CHANNEL(idx) …
struct sx931x_info { … };
static const struct iio_chan_spec sx9310_channels[] = …;
static const struct { … } sx9310_samp_freq_table[] = …;
static const unsigned int sx9310_scan_period_table[] = …;
static const struct regmap_range sx9310_writable_reg_ranges[] = …;
static const struct regmap_access_table sx9310_writeable_regs = …;
static const struct regmap_range sx9310_readable_reg_ranges[] = …;
static const struct regmap_access_table sx9310_readable_regs = …;
static const struct regmap_range sx9310_volatile_reg_ranges[] = …;
static const struct regmap_access_table sx9310_volatile_regs = …;
static const struct regmap_config sx9310_regmap_config = …;
static int sx9310_read_prox_data(struct sx_common_data *data,
const struct iio_chan_spec *chan, __be16 *val)
{ … }
static int sx9310_wait_for_sample(struct sx_common_data *data)
{ … }
static int sx9310_read_gain(struct sx_common_data *data,
const struct iio_chan_spec *chan, int *val)
{ … }
static int sx9310_read_samp_freq(struct sx_common_data *data, int *val, int *val2)
{ … }
static int sx9310_read_raw(struct iio_dev *indio_dev,
const struct iio_chan_spec *chan, int *val,
int *val2, long mask)
{ … }
static const int sx9310_gain_vals[] = …;
static int sx9310_read_avail(struct iio_dev *indio_dev,
struct iio_chan_spec const *chan,
const int **vals, int *type, int *length,
long mask)
{ … }
static const unsigned int sx9310_pthresh_codes[] = …;
static int sx9310_get_thresh_reg(unsigned int channel)
{ … }
static int sx9310_read_thresh(struct sx_common_data *data,
const struct iio_chan_spec *chan, int *val)
{ … }
static int sx9310_read_hysteresis(struct sx_common_data *data,
const struct iio_chan_spec *chan, int *val)
{ … }
static int sx9310_read_far_debounce(struct sx_common_data *data, int *val)
{ … }
static int sx9310_read_close_debounce(struct sx_common_data *data, int *val)
{ … }
static int sx9310_read_event_val(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 int sx9310_write_thresh(struct sx_common_data *data,
const struct iio_chan_spec *chan, int val)
{ … }
static int sx9310_write_hysteresis(struct sx_common_data *data,
const struct iio_chan_spec *chan, int _val)
{ … }
static int sx9310_write_far_debounce(struct sx_common_data *data, int val)
{ … }
static int sx9310_write_close_debounce(struct sx_common_data *data, int val)
{ … }
static int sx9310_write_event_val(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 int sx9310_set_samp_freq(struct sx_common_data *data, int val, int val2)
{ … }
static int sx9310_write_gain(struct sx_common_data *data,
const struct iio_chan_spec *chan, int val)
{ … }
static int sx9310_write_raw(struct iio_dev *indio_dev,
const struct iio_chan_spec *chan, int val, int val2,
long mask)
{ … }
static const struct sx_common_reg_default sx9310_default_regs[] = …;
static int sx9310_init_compensation(struct iio_dev *indio_dev)
{ … }
static const struct sx_common_reg_default *
sx9310_get_default_reg(struct device *dev, int idx,
struct sx_common_reg_default *reg_def)
{ … }
static int sx9310_check_whoami(struct device *dev,
struct iio_dev *indio_dev)
{ … }
static const struct sx_common_chip_info sx9310_chip_info = …;
static int sx9310_probe(struct i2c_client *client)
{ … }
static int sx9310_suspend(struct device *dev)
{ … }
static int sx9310_resume(struct device *dev)
{ … }
static DEFINE_SIMPLE_DEV_PM_OPS(sx9310_pm_ops, sx9310_suspend, sx9310_resume);
static const struct sx931x_info sx9310_info = …;
static const struct sx931x_info sx9311_info = …;
static const struct acpi_device_id sx9310_acpi_match[] = …;
MODULE_DEVICE_TABLE(acpi, sx9310_acpi_match);
static const struct of_device_id sx9310_of_match[] = …;
MODULE_DEVICE_TABLE(of, sx9310_of_match);
static const struct i2c_device_id sx9310_id[] = …;
MODULE_DEVICE_TABLE(i2c, sx9310_id);
static struct i2c_driver sx9310_driver = …;
module_i2c_driver(…) …;
MODULE_AUTHOR(…) …;
MODULE_AUTHOR(…) …;
MODULE_DESCRIPTION(…) …;
MODULE_LICENSE(…) …;
MODULE_IMPORT_NS(…);