linux/drivers/iio/adc/ad9467.c

// SPDX-License-Identifier: GPL-2.0-only
/*
 * Analog Devices AD9467 SPI ADC driver
 *
 * Copyright 2012-2020 Analog Devices Inc.
 */

#include <linux/bitmap.h>
#include <linux/bitops.h>
#include <linux/cleanup.h>
#include <linux/debugfs.h>
#include <linux/module.h>
#include <linux/mutex.h>
#include <linux/device.h>
#include <linux/kernel.h>
#include <linux/slab.h>
#include <linux/spi/spi.h>
#include <linux/seq_file.h>
#include <linux/err.h>
#include <linux/delay.h>
#include <linux/gpio/consumer.h>
#include <linux/of.h>


#include <linux/iio/backend.h>
#include <linux/iio/iio.h>
#include <linux/iio/sysfs.h>

#include <linux/clk.h>

/*
 * ADI High-Speed ADC common spi interface registers
 * See Application-Note AN-877:
 *   https://www.analog.com/media/en/technical-documentation/application-notes/AN-877.pdf
 */

#define AN877_ADC_REG_CHIP_PORT_CONF
#define AN877_ADC_REG_CHIP_ID
#define AN877_ADC_REG_CHIP_GRADE
#define AN877_ADC_REG_CHAN_INDEX
#define AN877_ADC_REG_TRANSFER
#define AN877_ADC_REG_MODES
#define AN877_ADC_REG_TEST_IO
#define AN877_ADC_REG_ADC_INPUT
#define AN877_ADC_REG_OFFSET
#define AN877_ADC_REG_OUTPUT_MODE
#define AN877_ADC_REG_OUTPUT_ADJUST
#define AN877_ADC_REG_OUTPUT_PHASE
#define AN877_ADC_REG_OUTPUT_DELAY
#define AN877_ADC_REG_VREF
#define AN877_ADC_REG_ANALOG_INPUT

/* AN877_ADC_REG_TEST_IO */
#define AN877_ADC_TESTMODE_OFF
#define AN877_ADC_TESTMODE_MIDSCALE_SHORT
#define AN877_ADC_TESTMODE_POS_FULLSCALE
#define AN877_ADC_TESTMODE_NEG_FULLSCALE
#define AN877_ADC_TESTMODE_ALT_CHECKERBOARD
#define AN877_ADC_TESTMODE_PN23_SEQ
#define AN877_ADC_TESTMODE_PN9_SEQ
#define AN877_ADC_TESTMODE_ONE_ZERO_TOGGLE
#define AN877_ADC_TESTMODE_USER
#define AN877_ADC_TESTMODE_BIT_TOGGLE
#define AN877_ADC_TESTMODE_SYNC
#define AN877_ADC_TESTMODE_ONE_BIT_HIGH
#define AN877_ADC_TESTMODE_MIXED_BIT_FREQUENCY
#define AN877_ADC_TESTMODE_RAMP

/* AN877_ADC_REG_TRANSFER */
#define AN877_ADC_TRANSFER_SYNC

/* AN877_ADC_REG_OUTPUT_MODE */
#define AN877_ADC_OUTPUT_MODE_OFFSET_BINARY
#define AN877_ADC_OUTPUT_MODE_TWOS_COMPLEMENT
#define AN877_ADC_OUTPUT_MODE_GRAY_CODE

/* AN877_ADC_REG_OUTPUT_PHASE */
#define AN877_ADC_OUTPUT_EVEN_ODD_MODE_EN
#define AN877_ADC_INVERT_DCO_CLK

/* AN877_ADC_REG_OUTPUT_DELAY */
#define AN877_ADC_DCO_DELAY_ENABLE

/*
 * Analog Devices AD9265 16-Bit, 125/105/80 MSPS ADC
 */

#define CHIPID_AD9265
#define AD9265_DEF_OUTPUT_MODE
#define AD9265_REG_VREF_MASK

/*
 * Analog Devices AD9434 12-Bit, 370/500 MSPS ADC
 */

#define CHIPID_AD9434
#define AD9434_DEF_OUTPUT_MODE
#define AD9434_REG_VREF_MASK

/*
 * Analog Devices AD9467 16-Bit, 200/250 MSPS ADC
 */

#define CHIPID_AD9467
#define AD9467_DEF_OUTPUT_MODE
#define AD9467_REG_VREF_MASK

/*
 * Analog Devices AD9643 14-Bit, 170/210/250 MSPS ADC
 */

#define CHIPID_AD9643
#define AD9643_REG_VREF_MASK

/*
 * Analog Devices AD9652 16-bit 310 MSPS ADC
 */

#define CHIPID_AD9652
#define AD9652_REG_VREF_MASK

/*
 * Analog Devices AD9649 14-bit 20/40/65/80 MSPS ADC
 */

#define CHIPID_AD9649
#define AD9649_TEST_POINTS

#define AD9647_MAX_TEST_POINTS
#define AD9467_CAN_INVERT(st)

struct ad9467_chip_info {};

struct ad9467_chan_test_mode {};

struct ad9467_state {};

static int ad9467_spi_read(struct ad9467_state *st, unsigned int reg)
{}

static int ad9467_spi_write(struct ad9467_state *st, unsigned int reg,
			    unsigned int val)
{}

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

static const unsigned int ad9265_scale_table[][2] =;

static const unsigned int ad9434_scale_table[][2] =;

static const unsigned int ad9467_scale_table[][2] =;

static const unsigned int ad9643_scale_table[][2] =;

static const unsigned int ad9649_scale_table[][2] =;

static const unsigned int ad9652_scale_table[][2] =;

static void __ad9467_get_scale(struct ad9467_state *st, int index,
			       unsigned int *val, unsigned int *val2)
{}

#define AD9467_CHAN(_chan, avai_mask, _si, _bits, _sign)

static const struct iio_chan_spec ad9434_channels[] =;

static const struct iio_chan_spec ad9467_channels[] =;

static const struct iio_chan_spec ad9643_channels[] =;

static const struct iio_chan_spec ad9649_channels[] =;

static const struct iio_chan_spec ad9652_channels[] =;

static const char * const ad9467_test_modes[] =;

static const struct ad9467_chip_info ad9467_chip_tbl =;

static const struct ad9467_chip_info ad9434_chip_tbl =;

static const struct ad9467_chip_info ad9265_chip_tbl =;

static const struct ad9467_chip_info ad9643_chip_tbl =;

static const struct ad9467_chip_info ad9649_chip_tbl =;

static const struct ad9467_chip_info ad9652_chip_tbl =;

static int ad9467_get_scale(struct ad9467_state *st, int *val, int *val2)
{}

static int ad9467_set_scale(struct ad9467_state *st, int val, int val2)
{}

static int ad9467_outputmode_set(struct ad9467_state *st, unsigned int mode)
{}

static int ad9467_testmode_set(struct ad9467_state *st, unsigned int chan,
			       unsigned int test_mode)
{}

static int ad9467_backend_testmode_on(struct ad9467_state *st,
				      unsigned int chan,
				      enum iio_backend_test_pattern pattern)
{}

static int ad9467_backend_testmode_off(struct ad9467_state *st,
				       unsigned int chan)
{}

static int ad9647_calibrate_prepare(struct ad9467_state *st)
{}

static int ad9647_calibrate_polarity_set(struct ad9467_state *st,
					 bool invert)
{}

/*
 * The idea is pretty simple. Find the max number of successful points in a row
 * and get the one in the middle.
 */
static unsigned int ad9467_find_optimal_point(const unsigned long *calib_map,
					      unsigned int start,
					      unsigned int nbits,
					      unsigned int *val)
{}

static int ad9467_calibrate_apply(struct ad9467_state *st, unsigned int val)
{}

static int ad9647_calibrate_stop(struct ad9467_state *st)
{}

static int ad9467_calibrate(struct ad9467_state *st)
{}

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

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

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

static int ad9467_update_scan_mode(struct iio_dev *indio_dev,
				   const unsigned long *scan_mask)
{}

static struct iio_info ad9467_info =;

static int ad9467_scale_fill(struct ad9467_state *st)
{}

static int ad9467_reset(struct device *dev)
{}

static int ad9467_iio_backend_get(struct ad9467_state *st)
{}

static int ad9467_test_mode_available_show(struct seq_file *s, void *ignored)
{}
DEFINE_SHOW_ATTRIBUTE();

static ssize_t ad9467_chan_test_mode_read(struct file *file,
					  char __user *userbuf, size_t count,
					  loff_t *ppos)
{}

static ssize_t ad9467_chan_test_mode_write(struct file *file,
					   const char __user *userbuf,
					   size_t count, loff_t *ppos)
{}

static const struct file_operations ad9467_chan_test_mode_fops =;

static ssize_t ad9467_dump_calib_table(struct file *file,
				       char __user *userbuf,
				       size_t count, loff_t *ppos)
{}

static const struct file_operations ad9467_calib_table_fops =;

static void ad9467_debugfs_init(struct iio_dev *indio_dev)
{}

static int ad9467_probe(struct spi_device *spi)
{}

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

static const struct spi_device_id ad9467_ids[] =;
MODULE_DEVICE_TABLE(spi, ad9467_ids);

static struct spi_driver ad9467_driver =;
module_spi_driver();

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