linux/drivers/iio/adc/ti-ads1119.c

// SPDX-License-Identifier: GPL-2.0-only
/*
 * Texas Instruments ADS1119 ADC driver.
 *
 * Copyright 2024 Toradex
 */

#include <linux/bits.h>
#include <linux/bitfield.h>
#include <linux/completion.h>
#include <linux/delay.h>
#include <linux/dev_printk.h>
#include <linux/err.h>
#include <linux/gpio/consumer.h>
#include <linux/interrupt.h>
#include <linux/iopoll.h>
#include <linux/i2c.h>
#include <linux/kernel.h>
#include <linux/math.h>
#include <linux/module.h>
#include <linux/pm_runtime.h>
#include <linux/regulator/consumer.h>
#include <linux/units.h>

#include <linux/iio/iio.h>
#include <linux/iio/buffer.h>
#include <linux/iio/trigger.h>
#include <linux/iio/triggered_buffer.h>
#include <linux/iio/trigger_consumer.h>

#define ADS1119_CMD_RESET
#define ADS1119_CMD_POWERDOWN
#define ADS1119_CMD_START_SYNC
#define ADS1119_CMD_RDATA
#define ADS1119_CMD_RREG_CONFIG
#define ADS1119_CMD_RREG_STATUS
#define ADS1119_CMD_WREG

#define ADS1119_CMD_RREG(reg)

/* Config register */
#define ADS1119_REG_CONFIG
#define ADS1119_CONFIG_VREF_FIELD
#define ADS1119_CONFIG_CM_FIELD
#define ADS1119_CONFIG_DR_FIELD
#define ADS1119_CONFIG_GAIN_FIELD
#define ADS1119_CONFIG_MUX_FIELD

#define ADS1119_VREF_INTERNAL
#define ADS1119_VREF_EXTERNAL
#define ADS1119_VREF_INTERNAL_VAL

#define ADS1119_CM_SINGLE
#define ADS1119_CM_CONTINUOUS

#define ADS1119_DR_20_SPS
#define ADS1119_DR_90_SPS
#define ADS1119_DR_330_SPS
#define ADS1119_DR_1000_SPS

#define ADS1119_GAIN_1
#define ADS1119_GAIN_4

#define ADS1119_MUX_AIN0_AIN1
#define ADS1119_MUX_AIN2_AIN3
#define ADS1119_MUX_AIN1_AIN2
#define ADS1119_MUX_AIN0
#define ADS1119_MUX_AIN1
#define ADS1119_MUX_AIN2
#define ADS1119_MUX_AIN3
#define ADS1119_MUX_SHORTED

/* Status register */
#define ADS1119_REG_STATUS
#define ADS1119_STATUS_DRDY_FIELD

#define ADS1119_DEFAULT_GAIN
#define ADS1119_DEFAULT_DATARATE

#define ADS1119_SUSPEND_DELAY

/* Timeout based on the minimum sample rate of 20 SPS (50000us) */
#define ADS1119_MAX_DRDY_TIMEOUT

#define ADS1119_MAX_CHANNELS
#define ADS1119_MAX_SINGLE_CHANNELS

struct ads1119_channel_config {};

struct ads1119_state {};

static const char * const ads1119_power_supplies[] =;

static const int ads1119_available_datarates[] =;

static const int ads1119_available_gains[] =;

static int ads1119_upd_cfg_reg(struct ads1119_state *st, unsigned int fields,
			       unsigned int val)
{}

static bool ads1119_data_ready(struct ads1119_state *st)
{}

static int ads1119_reset(struct ads1119_state *st)
{}

static int ads1119_set_conv_mode(struct ads1119_state *st, bool continuous)
{}

static int ads1119_get_hw_gain(int gain)
{}

static int ads1119_get_hw_datarate(int datarate)
{}

static int ads1119_configure_channel(struct ads1119_state *st, int mux,
				     int gain, int datarate)
{}

static int ads1119_poll_data_ready(struct ads1119_state *st,
				   struct iio_chan_spec const *chan)
{}

static int ads1119_read_data(struct ads1119_state *st,
			     struct iio_chan_spec const *chan,
			     unsigned int *val)
{}

static int ads1119_single_conversion(struct ads1119_state *st,
				     struct iio_chan_spec const *chan,
				     int *val,
				     bool calib_offset)
{}

static int ads1119_validate_datarate(struct ads1119_state *st, int datarate)
{}

static int ads1119_read_avail(struct iio_dev *indio_dev,
			      struct iio_chan_spec const *chan,
			      const int **vals, int *type, int *length,
			      long mask)
{}

static int ads1119_read_raw(struct iio_dev *indio_dev,
			    struct iio_chan_spec const *chan, int *val,
			    int *val2, long mask)
{}

static int ads1119_write_raw(struct iio_dev *indio_dev,
			     struct iio_chan_spec const *chan, int val,
			     int val2, long mask)
{}

static int ads1119_debugfs_reg_access(struct iio_dev *indio_dev,
				      unsigned int reg, unsigned int writeval,
				      unsigned int *readval)
{}

static const struct iio_info ads1119_info =;

static int ads1119_triggered_buffer_preenable(struct iio_dev *indio_dev)
{}

static int ads1119_triggered_buffer_postdisable(struct iio_dev *indio_dev)
{}

static const struct iio_buffer_setup_ops ads1119_buffer_setup_ops =;

static const struct iio_trigger_ops ads1119_trigger_ops =;

static irqreturn_t ads1119_irq_handler(int irq, void *dev_id)
{}

static irqreturn_t ads1119_trigger_handler(int irq, void *private)
{}

static int ads1119_init(struct ads1119_state *st, bool vref_external)
{}

static int ads1119_map_analog_inputs_mux(int ain_pos, int ain_neg,
					 bool differential)
{}

static int ads1119_alloc_and_config_channels(struct iio_dev *indio_dev)
{}

static void ads1119_powerdown(void *data)
{}

static int ads1119_probe(struct i2c_client *client)
{}

static int ads1119_runtime_suspend(struct device *dev)
{}

/*
 * The ADS1119 does not require a resume function because it automatically
 * powers on after a reset.
 * After a power down command, the ADS1119 can still communicate but turns off
 * its analog parts. To resume from power down, the device will power up again
 * upon receiving a start/sync command.
 */
static DEFINE_RUNTIME_DEV_PM_OPS(ads1119_pm_ops, ads1119_runtime_suspend,
				 NULL, NULL);

static const struct of_device_id __maybe_unused ads1119_of_match[] =;
MODULE_DEVICE_TABLE(of, ads1119_of_match);

static const struct i2c_device_id ads1119_id[] =;
MODULE_DEVICE_TABLE(i2c, ads1119_id);

static struct i2c_driver ads1119_driver =;
module_i2c_driver();

MODULE_AUTHOR();
MODULE_DESCRIPTION();
MODULE_LICENSE();