#include <linux/err.h>
#include <linux/delay.h>
#include <linux/device.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/mod_devicetable.h>
#include <linux/slab.h>
#include <linux/sysfs.h>
#include <linux/gpio/consumer.h>
#include <linux/spi/spi.h>
#include <linux/iio/iio.h>
#include <linux/iio/buffer.h>
#include <linux/iio/trigger_consumer.h>
#include <linux/iio/triggered_buffer.h>
#include <linux/iio/sysfs.h>
#include <asm/unaligned.h>
#define ADS124S08_CMD_NOP …
#define ADS124S08_CMD_WAKEUP …
#define ADS124S08_CMD_PWRDWN …
#define ADS124S08_CMD_RESET …
#define ADS124S08_CMD_START …
#define ADS124S08_CMD_STOP …
#define ADS124S08_CMD_SYOCAL …
#define ADS124S08_CMD_SYGCAL …
#define ADS124S08_CMD_SFOCAL …
#define ADS124S08_CMD_RDATA …
#define ADS124S08_CMD_RREG …
#define ADS124S08_CMD_WREG …
#define ADS124S08_ID_REG …
#define ADS124S08_STATUS …
#define ADS124S08_INPUT_MUX …
#define ADS124S08_PGA …
#define ADS124S08_DATA_RATE …
#define ADS124S08_REF …
#define ADS124S08_IDACMAG …
#define ADS124S08_IDACMUX …
#define ADS124S08_VBIAS …
#define ADS124S08_SYS …
#define ADS124S08_OFCAL0 …
#define ADS124S08_OFCAL1 …
#define ADS124S08_OFCAL2 …
#define ADS124S08_FSCAL0 …
#define ADS124S08_FSCAL1 …
#define ADS124S08_FSCAL2 …
#define ADS124S08_GPIODAT …
#define ADS124S08_GPIOCON …
#define ADS124S08_AIN0 …
#define ADS124S08_AIN1 …
#define ADS124S08_AIN2 …
#define ADS124S08_AIN3 …
#define ADS124S08_AIN4 …
#define ADS124S08_AIN5 …
#define ADS124S08_AINCOM …
#define ADS124S08_AIN6 …
#define ADS124S08_AIN7 …
#define ADS124S08_AIN8 …
#define ADS124S08_AIN9 …
#define ADS124S08_AIN10 …
#define ADS124S08_AIN11 …
#define ADS124S08_MAX_CHANNELS …
#define ADS124S08_POS_MUX_SHIFT …
#define ADS124S08_INT_REF …
#define ADS124S08_START_REG_MASK …
#define ADS124S08_NUM_BYTES_MASK …
#define ADS124S08_START_CONV …
#define ADS124S08_STOP_CONV …
enum ads124s_id { … };
struct ads124s_chip_info { … };
struct ads124s_private { … };
#define ADS124S08_CHAN(index) …
static const struct iio_chan_spec ads124s06_channels[] = …;
static const struct iio_chan_spec ads124s08_channels[] = …;
static const struct ads124s_chip_info ads124s_chip_info_tbl[] = …;
static int ads124s_write_cmd(struct iio_dev *indio_dev, u8 command)
{ … }
static int ads124s_write_reg(struct iio_dev *indio_dev, u8 reg, u8 data)
{ … }
static int ads124s_reset(struct iio_dev *indio_dev)
{
struct ads124s_private *priv = iio_priv(indio_dev);
if (priv->reset_gpio) {
gpiod_set_value(priv->reset_gpio, 0);
udelay(200);
gpiod_set_value(priv->reset_gpio, 1);
} else {
return ads124s_write_cmd(indio_dev, ADS124S08_CMD_RESET);
}
return 0;
};
static int ads124s_read(struct iio_dev *indio_dev)
{ … }
static int ads124s_read_raw(struct iio_dev *indio_dev,
struct iio_chan_spec const *chan,
int *val, int *val2, long m)
{ … }
static const struct iio_info ads124s_info = …;
static irqreturn_t ads124s_trigger_handler(int irq, void *p)
{ … }
static int ads124s_probe(struct spi_device *spi)
{ … }
static const struct spi_device_id ads124s_id[] = …;
MODULE_DEVICE_TABLE(spi, ads124s_id);
static const struct of_device_id ads124s_of_table[] = …;
MODULE_DEVICE_TABLE(of, ads124s_of_table);
static struct spi_driver ads124s_driver = …;
module_spi_driver(…) …;
MODULE_AUTHOR(…) …;
MODULE_DESCRIPTION(…) …;
MODULE_LICENSE(…) …;