#include <linux/bitfield.h>
#include <linux/clk.h>
#include <linux/delay.h>
#include <linux/device.h>
#include <linux/err.h>
#include <linux/gpio/consumer.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/regulator/consumer.h>
#include <linux/sysfs.h>
#include <linux/spi/spi.h>
#include <linux/iio/buffer.h>
#include <linux/iio/iio.h>
#include <linux/iio/sysfs.h>
#include <linux/iio/trigger.h>
#include <linux/iio/triggered_buffer.h>
#include <linux/iio/trigger_consumer.h>
#define AD7768_REG_CHIP_TYPE …
#define AD7768_REG_PROD_ID_L …
#define AD7768_REG_PROD_ID_H …
#define AD7768_REG_CHIP_GRADE …
#define AD7768_REG_SCRATCH_PAD …
#define AD7768_REG_VENDOR_L …
#define AD7768_REG_VENDOR_H …
#define AD7768_REG_INTERFACE_FORMAT …
#define AD7768_REG_POWER_CLOCK …
#define AD7768_REG_ANALOG …
#define AD7768_REG_ANALOG2 …
#define AD7768_REG_CONVERSION …
#define AD7768_REG_DIGITAL_FILTER …
#define AD7768_REG_SINC3_DEC_RATE_MSB …
#define AD7768_REG_SINC3_DEC_RATE_LSB …
#define AD7768_REG_DUTY_CYCLE_RATIO …
#define AD7768_REG_SYNC_RESET …
#define AD7768_REG_GPIO_CONTROL …
#define AD7768_REG_GPIO_WRITE …
#define AD7768_REG_GPIO_READ …
#define AD7768_REG_OFFSET_HI …
#define AD7768_REG_OFFSET_MID …
#define AD7768_REG_OFFSET_LO …
#define AD7768_REG_GAIN_HI …
#define AD7768_REG_GAIN_MID …
#define AD7768_REG_GAIN_LO …
#define AD7768_REG_SPI_DIAG_ENABLE …
#define AD7768_REG_ADC_DIAG_ENABLE …
#define AD7768_REG_DIG_DIAG_ENABLE …
#define AD7768_REG_ADC_DATA …
#define AD7768_REG_MASTER_STATUS …
#define AD7768_REG_SPI_DIAG_STATUS …
#define AD7768_REG_ADC_DIAG_STATUS …
#define AD7768_REG_DIG_DIAG_STATUS …
#define AD7768_REG_MCLK_COUNTER …
#define AD7768_PWR_MCLK_DIV_MSK …
#define AD7768_PWR_MCLK_DIV(x) …
#define AD7768_PWR_PWRMODE_MSK …
#define AD7768_PWR_PWRMODE(x) …
#define AD7768_DIG_FIL_FIL_MSK …
#define AD7768_DIG_FIL_FIL(x) …
#define AD7768_DIG_FIL_DEC_MSK …
#define AD7768_DIG_FIL_DEC_RATE(x) …
#define AD7768_CONV_MODE_MSK …
#define AD7768_CONV_MODE(x) …
#define AD7768_RD_FLAG_MSK(x) …
#define AD7768_WR_FLAG_MSK(x) …
enum ad7768_conv_mode { … };
enum ad7768_pwrmode { … };
enum ad7768_mclk_div { … };
enum ad7768_dec_rate { … };
struct ad7768_clk_configuration { … };
static const struct ad7768_clk_configuration ad7768_clk_config[] = …;
static const struct iio_chan_spec ad7768_channels[] = …;
struct ad7768_state { … };
static int ad7768_spi_reg_read(struct ad7768_state *st, unsigned int addr,
unsigned int len)
{ … }
static int ad7768_spi_reg_write(struct ad7768_state *st,
unsigned int addr,
unsigned int val)
{ … }
static int ad7768_set_mode(struct ad7768_state *st,
enum ad7768_conv_mode mode)
{ … }
static int ad7768_scan_direct(struct iio_dev *indio_dev)
{ … }
static int ad7768_reg_access(struct iio_dev *indio_dev,
unsigned int reg,
unsigned int writeval,
unsigned int *readval)
{ … }
static int ad7768_set_dig_fil(struct ad7768_state *st,
enum ad7768_dec_rate dec_rate)
{ … }
static int ad7768_set_freq(struct ad7768_state *st,
unsigned int freq)
{ … }
static ssize_t ad7768_sampling_freq_avail(struct device *dev,
struct device_attribute *attr,
char *buf)
{ … }
static IIO_DEV_ATTR_SAMP_FREQ_AVAIL(ad7768_sampling_freq_avail);
static int ad7768_read_raw(struct iio_dev *indio_dev,
struct iio_chan_spec const *chan,
int *val, int *val2, long info)
{ … }
static int ad7768_write_raw(struct iio_dev *indio_dev,
struct iio_chan_spec const *chan,
int val, int val2, long info)
{ … }
static int ad7768_read_label(struct iio_dev *indio_dev,
const struct iio_chan_spec *chan, char *label)
{ … }
static struct attribute *ad7768_attributes[] = …;
static const struct attribute_group ad7768_group = …;
static const struct iio_info ad7768_info = …;
static int ad7768_setup(struct ad7768_state *st)
{ … }
static irqreturn_t ad7768_trigger_handler(int irq, void *p)
{ … }
static irqreturn_t ad7768_interrupt(int irq, void *dev_id)
{
struct iio_dev *indio_dev = dev_id;
struct ad7768_state *st = iio_priv(indio_dev);
if (iio_buffer_enabled(indio_dev))
iio_trigger_poll(st->trig);
else
complete(&st->completion);
return IRQ_HANDLED;
};
static int ad7768_buffer_postenable(struct iio_dev *indio_dev)
{ … }
static int ad7768_buffer_predisable(struct iio_dev *indio_dev)
{ … }
static const struct iio_buffer_setup_ops ad7768_buffer_ops = …;
static const struct iio_trigger_ops ad7768_trigger_ops = …;
static void ad7768_regulator_disable(void *data)
{ … }
static int ad7768_set_channel_label(struct iio_dev *indio_dev,
int num_channels)
{ … }
static int ad7768_probe(struct spi_device *spi)
{ … }
static const struct spi_device_id ad7768_id_table[] = …;
MODULE_DEVICE_TABLE(spi, ad7768_id_table);
static const struct of_device_id ad7768_of_match[] = …;
MODULE_DEVICE_TABLE(of, ad7768_of_match);
static struct spi_driver ad7768_driver = …;
module_spi_driver(…) …;
MODULE_AUTHOR(…) …;
MODULE_DESCRIPTION(…) …;
MODULE_LICENSE(…) …;