#include <linux/array_size.h>
#include <linux/bitfield.h>
#include <linux/bitmap.h>
#include <linux/container_of.h>
#include <linux/clk.h>
#include <linux/clk-provider.h>
#include <linux/delay.h>
#include <linux/device.h>
#include <linux/err.h>
#include <linux/gpio/driver.h>
#include <linux/gpio/regmap.h>
#include <linux/idr.h>
#include <linux/interrupt.h>
#include <linux/math64.h>
#include <linux/module.h>
#include <linux/mod_devicetable.h>
#include <linux/property.h>
#include <linux/regmap.h>
#include <linux/regulator/consumer.h>
#include <linux/slab.h>
#include <linux/spi/spi.h>
#include <linux/types.h>
#include <linux/units.h>
#include <linux/iio/buffer.h>
#include <linux/iio/iio.h>
#include <linux/iio/trigger_consumer.h>
#include <linux/iio/triggered_buffer.h>
#include <linux/iio/adc/ad_sigma_delta.h>
#define AD7173_REG_COMMS …
#define AD7173_REG_ADC_MODE …
#define AD7173_REG_INTERFACE_MODE …
#define AD7173_REG_CRC …
#define AD7173_REG_DATA …
#define AD7173_REG_GPIO …
#define AD7173_REG_ID …
#define AD7173_REG_CH(x) …
#define AD7173_REG_SETUP(x) …
#define AD7173_REG_FILTER(x) …
#define AD7173_REG_OFFSET(x) …
#define AD7173_REG_GAIN(x) …
#define AD7173_RESET_LENGTH …
#define AD7173_CH_ENABLE …
#define AD7173_CH_SETUP_SEL_MASK …
#define AD7173_CH_SETUP_AINPOS_MASK …
#define AD7173_CH_SETUP_AINNEG_MASK …
#define AD7173_NO_AINS_PER_CHANNEL …
#define AD7173_CH_ADDRESS(pos, neg) …
#define AD7173_AIN_TEMP_POS …
#define AD7173_AIN_TEMP_NEG …
#define AD7173_AIN_POW_MON_POS …
#define AD7173_AIN_POW_MON_NEG …
#define AD7173_AIN_REF_POS …
#define AD7173_AIN_REF_NEG …
#define AD7173_IS_REF_INPUT(x) …
#define AD7172_2_ID …
#define AD7175_ID …
#define AD7176_ID …
#define AD7175_2_ID …
#define AD7172_4_ID …
#define AD7173_ID …
#define AD4111_ID …
#define AD4112_ID …
#define AD4114_ID …
#define AD4116_ID …
#define AD4115_ID …
#define AD7175_8_ID …
#define AD7177_ID …
#define AD7173_ID_MASK …
#define AD7173_ADC_MODE_REF_EN …
#define AD7173_ADC_MODE_SING_CYC …
#define AD7173_ADC_MODE_MODE_MASK …
#define AD7173_ADC_MODE_CLOCKSEL_MASK …
#define AD7173_ADC_MODE_CLOCKSEL_INT …
#define AD7173_ADC_MODE_CLOCKSEL_INT_OUTPUT …
#define AD7173_ADC_MODE_CLOCKSEL_EXT …
#define AD7173_ADC_MODE_CLOCKSEL_XTAL …
#define AD7173_GPIO_PDSW …
#define AD7173_GPIO_OP_EN2_3 …
#define AD7173_GPIO_MUX_IO …
#define AD7173_GPIO_SYNC_EN …
#define AD7173_GPIO_ERR_EN …
#define AD7173_GPIO_ERR_DAT …
#define AD7173_GPIO_GP_DATA3 …
#define AD7173_GPIO_GP_DATA2 …
#define AD7173_GPIO_IP_EN1 …
#define AD7173_GPIO_IP_EN0 …
#define AD7173_GPIO_OP_EN1 …
#define AD7173_GPIO_OP_EN0 …
#define AD7173_GPIO_GP_DATA1 …
#define AD7173_GPIO_GP_DATA0 …
#define AD7173_GPO12_DATA(x) …
#define AD7173_GPO23_DATA(x) …
#define AD4111_GPO01_DATA(x) …
#define AD7173_GPO_DATA(x) …
#define AD7173_INTERFACE_DATA_STAT …
#define AD7173_INTERFACE_DATA_STAT_EN(x) …
#define AD7173_SETUP_BIPOLAR …
#define AD7173_SETUP_AREF_BUF_MASK …
#define AD7173_SETUP_AIN_BUF_MASK …
#define AD7173_SETUP_REF_SEL_MASK …
#define AD7173_SETUP_REF_SEL_AVDD1_AVSS …
#define AD7173_SETUP_REF_SEL_INT_REF …
#define AD7173_SETUP_REF_SEL_EXT_REF2 …
#define AD7173_SETUP_REF_SEL_EXT_REF …
#define AD7173_VOLTAGE_INT_REF_uV …
#define AD7173_TEMP_SENSIIVITY_uV_per_C …
#define AD7177_ODR_START_VALUE …
#define AD4111_SHUNT_RESISTOR_OHM …
#define AD4111_DIVIDER_RATIO …
#define AD4111_CURRENT_CHAN_CUTOFF …
#define AD4111_VINCOM_INPUT …
#define AD4111_IS_VINCOM_MISMATCH(pin1, pin2) …
#define AD7173_FILTER_ODR0_MASK …
#define AD7173_MAX_CONFIGS …
struct ad7173_device_info { … };
struct ad7173_channel_config { … };
struct ad7173_channel { … };
struct ad7173_state { … };
static unsigned int ad4115_sinc5_data_rates[] = …;
static unsigned int ad4116_sinc5_data_rates[] = …;
static const unsigned int ad7173_sinc5_data_rates[] = …;
static const unsigned int ad7175_sinc5_data_rates[] = …;
static unsigned int ad4111_current_channel_config[] = …;
static const struct ad7173_device_info ad4111_device_info = …;
static const struct ad7173_device_info ad4112_device_info = …;
static const struct ad7173_device_info ad4114_device_info = …;
static const struct ad7173_device_info ad4115_device_info = …;
static const struct ad7173_device_info ad4116_device_info = …;
static const struct ad7173_device_info ad7172_2_device_info = …;
static const struct ad7173_device_info ad7172_4_device_info = …;
static const struct ad7173_device_info ad7173_8_device_info = …;
static const struct ad7173_device_info ad7175_2_device_info = …;
static const struct ad7173_device_info ad7175_8_device_info = …;
static const struct ad7173_device_info ad7176_2_device_info = …;
static const struct ad7173_device_info ad7177_2_device_info = …;
static const char *const ad7173_ref_sel_str[] = …;
static const char *const ad7173_clk_sel[] = …;
#if IS_ENABLED(CONFIG_GPIOLIB)
static const struct regmap_range ad7173_range_gpio[] = …;
static const struct regmap_access_table ad7173_access_table = …;
static const struct regmap_config ad7173_regmap_config = …;
static int ad7173_mask_xlate(struct gpio_regmap *gpio, unsigned int base,
unsigned int offset, unsigned int *reg,
unsigned int *mask)
{ … }
static int ad4111_mask_xlate(struct gpio_regmap *gpio, unsigned int base,
unsigned int offset, unsigned int *reg,
unsigned int *mask)
{ … }
static void ad7173_gpio_disable(void *data)
{ … }
static int ad7173_gpio_init(struct ad7173_state *st)
{ … }
#else
static int ad7173_gpio_init(struct ad7173_state *st)
{
return 0;
}
#endif
static struct ad7173_state *ad_sigma_delta_to_ad7173(struct ad_sigma_delta *sd)
{ … }
static struct ad7173_state *clk_hw_to_ad7173(struct clk_hw *hw)
{ … }
static void ad7173_ida_destroy(void *data)
{ … }
static void ad7173_reset_usage_cnts(struct ad7173_state *st)
{ … }
static struct ad7173_channel_config *
ad7173_find_live_config(struct ad7173_state *st, struct ad7173_channel_config *cfg)
{ … }
static int ad7173_free_config_slot_lru(struct ad7173_state *st)
{ … }
static int ad7173_load_config(struct ad7173_state *st,
struct ad7173_channel_config *cfg)
{ … }
static int ad7173_config_channel(struct ad7173_state *st, int addr)
{ … }
static int ad7173_set_channel(struct ad_sigma_delta *sd, unsigned int channel)
{ … }
static int ad7173_set_mode(struct ad_sigma_delta *sd,
enum ad_sigma_delta_mode mode)
{ … }
static int ad7173_append_status(struct ad_sigma_delta *sd, bool append)
{ … }
static int ad7173_disable_all(struct ad_sigma_delta *sd)
{ … }
static int ad7173_disable_one(struct ad_sigma_delta *sd, unsigned int chan)
{ … }
static struct ad_sigma_delta_info ad7173_sigma_delta_info = …;
static int ad7173_setup(struct iio_dev *indio_dev)
{ … }
static unsigned int ad7173_get_ref_voltage_milli(struct ad7173_state *st,
u8 reference_select)
{ … }
static int ad7173_read_raw(struct iio_dev *indio_dev,
struct iio_chan_spec const *chan,
int *val, int *val2, long info)
{ … }
static int ad7173_write_raw(struct iio_dev *indio_dev,
struct iio_chan_spec const *chan,
int val, int val2, long info)
{ … }
static int ad7173_update_scan_mode(struct iio_dev *indio_dev,
const unsigned long *scan_mask)
{ … }
static int ad7173_debug_reg_access(struct iio_dev *indio_dev, unsigned int reg,
unsigned int writeval, unsigned int *readval)
{ … }
static const struct iio_info ad7173_info = …;
static const struct iio_chan_spec ad7173_channel_template = …;
static const struct iio_chan_spec ad7173_temp_iio_channel_template = …;
static void ad7173_disable_regulators(void *data)
{ … }
static void ad7173_clk_disable_unprepare(void *clk)
{ … }
static unsigned long ad7173_sel_clk(struct ad7173_state *st,
unsigned int clk_sel)
{ … }
static unsigned long ad7173_clk_recalc_rate(struct clk_hw *hw,
unsigned long parent_rate)
{ … }
static int ad7173_clk_output_is_enabled(struct clk_hw *hw)
{ … }
static int ad7173_clk_output_prepare(struct clk_hw *hw)
{ … }
static void ad7173_clk_output_unprepare(struct clk_hw *hw)
{ … }
static const struct clk_ops ad7173_int_clk_ops = …;
static int ad7173_register_clk_provider(struct iio_dev *indio_dev)
{ … }
static int ad4111_validate_current_ain(struct ad7173_state *st,
const unsigned int ain[AD7173_NO_AINS_PER_CHANNEL])
{ … }
static int ad7173_validate_voltage_ain_inputs(struct ad7173_state *st,
unsigned int ain0, unsigned int ain1)
{ … }
static int ad7173_validate_reference(struct ad7173_state *st, int ref_sel)
{ … }
static int ad7173_fw_parse_channel_config(struct iio_dev *indio_dev)
{ … }
static int ad7173_fw_parse_device_config(struct iio_dev *indio_dev)
{ … }
static int ad7173_probe(struct spi_device *spi)
{ … }
static const struct of_device_id ad7173_of_match[] = …;
MODULE_DEVICE_TABLE(of, ad7173_of_match);
static const struct spi_device_id ad7173_id_table[] = …;
MODULE_DEVICE_TABLE(spi, ad7173_id_table);
static struct spi_driver ad7173_driver = …;
module_spi_driver(…) …;
MODULE_IMPORT_NS(…);
MODULE_AUTHOR(…) …;
MODULE_AUTHOR(…) …;
MODULE_DESCRIPTION(…) …;
MODULE_LICENSE(…) …;