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

// SPDX-License-Identifier: GPL-2.0-only
/*
 * ADS1015 - Texas Instruments Analog-to-Digital Converter
 *
 * Copyright (c) 2016, Intel Corporation.
 *
 * IIO driver for ADS1015 ADC 7-bit I2C slave address:
 *	* 0x48 - ADDR connected to Ground
 *	* 0x49 - ADDR connected to Vdd
 *	* 0x4A - ADDR connected to SDA
 *	* 0x4B - ADDR connected to SCL
 */

#include <linux/module.h>
#include <linux/init.h>
#include <linux/irq.h>
#include <linux/i2c.h>
#include <linux/property.h>
#include <linux/regmap.h>
#include <linux/pm_runtime.h>
#include <linux/mutex.h>
#include <linux/delay.h>

#include <linux/iio/iio.h>
#include <linux/iio/types.h>
#include <linux/iio/sysfs.h>
#include <linux/iio/events.h>
#include <linux/iio/buffer.h>
#include <linux/iio/triggered_buffer.h>
#include <linux/iio/trigger_consumer.h>

#define ADS1015_DRV_NAME

#define ADS1015_CHANNELS

#define ADS1015_CONV_REG
#define ADS1015_CFG_REG
#define ADS1015_LO_THRESH_REG
#define ADS1015_HI_THRESH_REG

#define ADS1015_CFG_COMP_QUE_SHIFT
#define ADS1015_CFG_COMP_LAT_SHIFT
#define ADS1015_CFG_COMP_POL_SHIFT
#define ADS1015_CFG_COMP_MODE_SHIFT
#define ADS1015_CFG_DR_SHIFT
#define ADS1015_CFG_MOD_SHIFT
#define ADS1015_CFG_PGA_SHIFT
#define ADS1015_CFG_MUX_SHIFT

#define ADS1015_CFG_COMP_QUE_MASK
#define ADS1015_CFG_COMP_LAT_MASK
#define ADS1015_CFG_COMP_POL_MASK
#define ADS1015_CFG_COMP_MODE_MASK
#define ADS1015_CFG_DR_MASK
#define ADS1015_CFG_MOD_MASK
#define ADS1015_CFG_PGA_MASK
#define ADS1015_CFG_MUX_MASK

/* Comparator queue and disable field */
#define ADS1015_CFG_COMP_DISABLE

/* Comparator polarity field */
#define ADS1015_CFG_COMP_POL_LOW
#define ADS1015_CFG_COMP_POL_HIGH

/* Comparator mode field */
#define ADS1015_CFG_COMP_MODE_TRAD
#define ADS1015_CFG_COMP_MODE_WINDOW

/* device operating modes */
#define ADS1015_CONTINUOUS
#define ADS1015_SINGLESHOT

#define ADS1015_SLEEP_DELAY_MS
#define ADS1015_DEFAULT_PGA
#define ADS1015_DEFAULT_DATA_RATE
#define ADS1015_DEFAULT_CHAN

struct ads1015_chip_data {};

enum ads1015_channels {};

static const int ads1015_data_rate[] =;

static const int ads1115_data_rate[] =;

/*
 * Translation from PGA bits to full-scale positive and negative input voltage
 * range in mV
 */
static const int ads1015_fullscale_range[] =;

static const int ads1015_scale[] =;

static const int ads1115_scale[] =;

/*
 * Translation from COMP_QUE field value to the number of successive readings
 * exceed the threshold values before an interrupt is generated
 */
static const int ads1015_comp_queue[] =;

static const struct iio_event_spec ads1015_events[] =;

/*
 * Compile-time check whether _fitbits can accommodate up to _testbits
 * bits. Returns _fitbits on success, fails to compile otherwise.
 *
 * The test works such that it multiplies constant _fitbits by constant
 * double-negation of size of a non-empty structure, i.e. it multiplies
 * constant _fitbits by constant 1 in each successful compilation case.
 * The non-empty structure may contain C11 _Static_assert(), make use of
 * this and place the kernel variant of static assert in there, so that
 * it performs the compile-time check for _testbits <= _fitbits. Note
 * that it is not possible to directly use static_assert in compound
 * statements, hence this convoluted construct.
 */
#define FIT_CHECK(_testbits, _fitbits)

#define ADS1015_V_CHAN(_chan, _addr, _realbits, _shift, _event_spec, _num_event_specs)

#define ADS1015_V_DIFF_CHAN(_chan, _chan2, _addr, _realbits, _shift, _event_spec, _num_event_specs)

struct ads1015_channel_data {};

struct ads1015_thresh_data {};

struct ads1015_data {};

static bool ads1015_event_channel_enabled(struct ads1015_data *data)
{}

static void ads1015_event_channel_enable(struct ads1015_data *data, int chan,
					 int comp_mode)
{}

static void ads1015_event_channel_disable(struct ads1015_data *data, int chan)
{}

static const struct regmap_range ads1015_writeable_ranges[] =;

static const struct regmap_access_table ads1015_writeable_table =;

static const struct regmap_config ads1015_regmap_config =;

static const struct regmap_range tla2024_writeable_ranges[] =;

static const struct regmap_access_table tla2024_writeable_table =;

static const struct regmap_config tla2024_regmap_config =;

static const struct iio_chan_spec ads1015_channels[] =;

static const struct iio_chan_spec ads1115_channels[] =;

static const struct iio_chan_spec tla2024_channels[] =;


#ifdef CONFIG_PM
static int ads1015_set_power_state(struct ads1015_data *data, bool on)
{}

#else /* !CONFIG_PM */

static int ads1015_set_power_state(struct ads1015_data *data, bool on)
{
	return 0;
}

#endif /* !CONFIG_PM */

static
int ads1015_get_adc_result(struct ads1015_data *data, int chan, int *val)
{}

static irqreturn_t ads1015_trigger_handler(int irq, void *p)
{}

static int ads1015_set_scale(struct ads1015_data *data,
			     struct iio_chan_spec const *chan,
			     int scale, int uscale)
{}

static int ads1015_set_data_rate(struct ads1015_data *data, int chan, int rate)
{}

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

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

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

static int ads1015_read_event(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 ads1015_write_event(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 ads1015_read_event_config(struct iio_dev *indio_dev,
	const struct iio_chan_spec *chan, enum iio_event_type type,
	enum iio_event_direction dir)
{}

static int ads1015_enable_event_config(struct ads1015_data *data,
	const struct iio_chan_spec *chan, int comp_mode)
{}

static int ads1015_disable_event_config(struct ads1015_data *data,
	const struct iio_chan_spec *chan, int comp_mode)
{}

static int ads1015_write_event_config(struct iio_dev *indio_dev,
	const struct iio_chan_spec *chan, enum iio_event_type type,
	enum iio_event_direction dir, int state)
{}

static irqreturn_t ads1015_event_handler(int irq, void *priv)
{}

static int ads1015_buffer_preenable(struct iio_dev *indio_dev)
{}

static int ads1015_buffer_postdisable(struct iio_dev *indio_dev)
{}

static const struct iio_buffer_setup_ops ads1015_buffer_setup_ops =;

static const struct iio_info ads1015_info =;

static const struct iio_info tla2024_info =;

static int ads1015_client_get_channels_config(struct i2c_client *client)
{}

static void ads1015_get_channels_config(struct i2c_client *client)
{}

static int ads1015_set_conv_mode(struct ads1015_data *data, int mode)
{}

static int ads1015_probe(struct i2c_client *client)
{}

static void ads1015_remove(struct i2c_client *client)
{}

#ifdef CONFIG_PM
static int ads1015_runtime_suspend(struct device *dev)
{}

static int ads1015_runtime_resume(struct device *dev)
{}
#endif

static const struct dev_pm_ops ads1015_pm_ops =;

static const struct ads1015_chip_data ads1015_data =;

static const struct ads1015_chip_data ads1115_data =;

static const struct ads1015_chip_data tla2024_data =;

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

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

static struct i2c_driver ads1015_driver =;

module_i2c_driver();

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