#include <linux/interrupt.h>
#include <linux/device.h>
#include <linux/kernel.h>
#include <linux/slab.h>
#include <linux/sysfs.h>
#include <linux/spi/spi.h>
#include <linux/regulator/consumer.h>
#include <linux/err.h>
#include <linux/sched.h>
#include <linux/delay.h>
#include <linux/module.h>
#include <linux/iio/iio.h>
#include <linux/iio/sysfs.h>
#include <linux/iio/buffer.h>
#include <linux/iio/trigger.h>
#include <linux/iio/trigger_consumer.h>
#include <linux/iio/triggered_buffer.h>
#include <linux/iio/adc/ad_sigma_delta.h>
#include <linux/platform_data/ad7793.h>
#define AD7793_REG_COMM …
#define AD7793_REG_STAT …
#define AD7793_REG_MODE …
#define AD7793_REG_CONF …
#define AD7793_REG_DATA …
#define AD7793_REG_ID …
#define AD7793_REG_IO …
#define AD7793_REG_OFFSET …
#define AD7793_REG_FULLSALE …
#define AD7793_COMM_WEN …
#define AD7793_COMM_WRITE …
#define AD7793_COMM_READ …
#define AD7793_COMM_ADDR(x) …
#define AD7793_COMM_CREAD …
#define AD7793_STAT_RDY …
#define AD7793_STAT_ERR …
#define AD7793_STAT_CH3 …
#define AD7793_STAT_CH2 …
#define AD7793_STAT_CH1 …
#define AD7793_MODE_SEL(x) …
#define AD7793_MODE_SEL_MASK …
#define AD7793_MODE_CLKSRC(x) …
#define AD7793_MODE_RATE(x) …
#define AD7793_MODE_CONT …
#define AD7793_MODE_SINGLE …
#define AD7793_MODE_IDLE …
#define AD7793_MODE_PWRDN …
#define AD7793_MODE_CAL_INT_ZERO …
#define AD7793_MODE_CAL_INT_FULL …
#define AD7793_MODE_CAL_SYS_ZERO …
#define AD7793_MODE_CAL_SYS_FULL …
#define AD7793_CLK_INT …
#define AD7793_CLK_INT_CO …
#define AD7793_CLK_EXT …
#define AD7793_CLK_EXT_DIV2 …
#define AD7793_CONF_VBIAS(x) …
#define AD7793_CONF_BO_EN …
#define AD7793_CONF_UNIPOLAR …
#define AD7793_CONF_BOOST …
#define AD7793_CONF_GAIN(x) …
#define AD7793_CONF_REFSEL(x) …
#define AD7793_CONF_BUF …
#define AD7793_CONF_CHAN(x) …
#define AD7793_CONF_CHAN_MASK …
#define AD7793_CH_AIN1P_AIN1M …
#define AD7793_CH_AIN2P_AIN2M …
#define AD7793_CH_AIN3P_AIN3M …
#define AD7793_CH_AIN1M_AIN1M …
#define AD7793_CH_TEMP …
#define AD7793_CH_AVDD_MONITOR …
#define AD7795_CH_AIN4P_AIN4M …
#define AD7795_CH_AIN5P_AIN5M …
#define AD7795_CH_AIN6P_AIN6M …
#define AD7795_CH_AIN1M_AIN1M …
#define AD7785_ID …
#define AD7792_ID …
#define AD7793_ID …
#define AD7794_ID …
#define AD7795_ID …
#define AD7796_ID …
#define AD7797_ID …
#define AD7798_ID …
#define AD7799_ID …
#define AD7793_ID_MASK …
#define AD7793_IO_IEXC1_IOUT1_IEXC2_IOUT2 …
#define AD7793_IO_IEXC1_IOUT2_IEXC2_IOUT1 …
#define AD7793_IO_IEXC1_IEXC2_IOUT1 …
#define AD7793_IO_IEXC1_IEXC2_IOUT2 …
#define AD7793_IO_IXCEN_10uA …
#define AD7793_IO_IXCEN_210uA …
#define AD7793_IO_IXCEN_1mA …
#define AD7793_FLAG_HAS_CLKSEL …
#define AD7793_FLAG_HAS_REFSEL …
#define AD7793_FLAG_HAS_VBIAS …
#define AD7793_HAS_EXITATION_CURRENT …
#define AD7793_FLAG_HAS_GAIN …
#define AD7793_FLAG_HAS_BUFFER …
struct ad7793_chip_info { … };
struct ad7793_state { … };
enum ad7793_supported_device_ids { … };
static struct ad7793_state *ad_sigma_delta_to_ad7793(struct ad_sigma_delta *sd)
{ … }
static int ad7793_set_channel(struct ad_sigma_delta *sd, unsigned int channel)
{ … }
static int ad7793_set_mode(struct ad_sigma_delta *sd,
enum ad_sigma_delta_mode mode)
{ … }
static const struct ad_sigma_delta_info ad7793_sigma_delta_info = …;
static const struct ad_sd_calib_data ad7793_calib_arr[6] = …;
static int ad7793_calibrate_all(struct ad7793_state *st)
{ … }
static int ad7793_check_platform_data(struct ad7793_state *st,
const struct ad7793_platform_data *pdata)
{ … }
static int ad7793_setup(struct iio_dev *indio_dev,
const struct ad7793_platform_data *pdata,
unsigned int vref_mv)
{ … }
static const u16 ad7793_sample_freq_avail[16] = …;
static const u16 ad7797_sample_freq_avail[16] = …;
static IIO_CONST_ATTR_SAMP_FREQ_AVAIL(
"470 242 123 62 50 39 33 19 17 16 12 10 8 6 4");
static IIO_CONST_ATTR_NAMED(sampling_frequency_available_ad7797,
sampling_frequency_available, "123 62 50 33 17 16 12 10 8 6 4");
static int ad7793_read_avail(struct iio_dev *indio_dev,
struct iio_chan_spec const *chan,
const int **vals, int *type, int *length,
long mask)
{ … }
static struct attribute *ad7793_attributes[] = …;
static const struct attribute_group ad7793_attribute_group = …;
static struct attribute *ad7797_attributes[] = …;
static const struct attribute_group ad7797_attribute_group = …;
static int ad7793_read_raw(struct iio_dev *indio_dev,
struct iio_chan_spec const *chan,
int *val,
int *val2,
long m)
{ … }
static int ad7793_write_raw(struct iio_dev *indio_dev,
struct iio_chan_spec const *chan,
int val,
int val2,
long mask)
{ … }
static int ad7793_write_raw_get_fmt(struct iio_dev *indio_dev,
struct iio_chan_spec const *chan,
long mask)
{ … }
static const struct iio_info ad7793_info = …;
static const struct iio_info ad7797_info = …;
#define __AD7793_CHANNEL(_si, _channel1, _channel2, _address, _bits, \
_storagebits, _shift, _extend_name, _type, _mask_type_av, _mask_all) …
#define AD7793_DIFF_CHANNEL(_si, _channel1, _channel2, _address, _bits, \
_storagebits, _shift) …
#define AD7793_SHORTED_CHANNEL(_si, _channel, _address, _bits, \
_storagebits, _shift) …
#define AD7793_TEMP_CHANNEL(_si, _address, _bits, _storagebits, _shift) …
#define AD7793_SUPPLY_CHANNEL(_si, _channel, _address, _bits, _storagebits, \
_shift) …
#define AD7797_DIFF_CHANNEL(_si, _channel1, _channel2, _address, _bits, \
_storagebits, _shift) …
#define AD7797_SHORTED_CHANNEL(_si, _channel, _address, _bits, \
_storagebits, _shift) …
#define DECLARE_AD7793_CHANNELS(_name, _b, _sb, _s) …
#define DECLARE_AD7795_CHANNELS(_name, _b, _sb) …
#define DECLARE_AD7797_CHANNELS(_name, _b, _sb) …
#define DECLARE_AD7799_CHANNELS(_name, _b, _sb) …
static DECLARE_AD7793_CHANNELS(ad7785, 20, 32, 4);
static DECLARE_AD7793_CHANNELS(ad7792, 16, 32, 0);
static DECLARE_AD7793_CHANNELS(ad7793, 24, 32, 0);
static DECLARE_AD7795_CHANNELS(ad7794, 16, 32);
static DECLARE_AD7795_CHANNELS(ad7795, 24, 32);
static DECLARE_AD7797_CHANNELS(ad7796, 16, 16);
static DECLARE_AD7797_CHANNELS(ad7797, 24, 32);
static DECLARE_AD7799_CHANNELS(ad7798, 16, 16);
static DECLARE_AD7799_CHANNELS(ad7799, 24, 32);
static const struct ad7793_chip_info ad7793_chip_info_tbl[] = …;
static int ad7793_probe(struct spi_device *spi)
{ … }
static const struct spi_device_id ad7793_id[] = …;
MODULE_DEVICE_TABLE(spi, ad7793_id);
static struct spi_driver ad7793_driver = …;
module_spi_driver(…) …;
MODULE_AUTHOR(…) …;
MODULE_DESCRIPTION(…) …;
MODULE_LICENSE(…) …;
MODULE_IMPORT_NS(…);