linux/drivers/iio/adc/ad7949.c

// SPDX-License-Identifier: GPL-2.0
/* ad7949.c - Analog Devices ADC driver 14/16 bits 4/8 channels
 *
 * Copyright (C) 2018 CMC NV
 *
 * https://www.analog.com/media/en/technical-documentation/data-sheets/AD7949.pdf
 */

#include <linux/delay.h>
#include <linux/iio/iio.h>
#include <linux/module.h>
#include <linux/regulator/consumer.h>
#include <linux/spi/spi.h>
#include <linux/bitfield.h>

#define AD7949_CFG_MASK_TOTAL

/* CFG: Configuration Update */
#define AD7949_CFG_MASK_OVERWRITE

/* INCC: Input Channel Configuration */
#define AD7949_CFG_MASK_INCC
#define AD7949_CFG_VAL_INCC_UNIPOLAR_GND
#define AD7949_CFG_VAL_INCC_UNIPOLAR_COMM
#define AD7949_CFG_VAL_INCC_UNIPOLAR_DIFF
#define AD7949_CFG_VAL_INCC_TEMP
#define AD7949_CFG_VAL_INCC_BIPOLAR
#define AD7949_CFG_VAL_INCC_BIPOLAR_DIFF

/* INX: Input channel Selection in a binary fashion */
#define AD7949_CFG_MASK_INX

/* BW: select bandwidth for low-pass filter. Full or Quarter */
#define AD7949_CFG_MASK_BW_FULL

/* REF: reference/buffer selection */
#define AD7949_CFG_MASK_REF
#define AD7949_CFG_VAL_REF_EXT_TEMP_BUF
#define AD7949_CFG_VAL_REF_EXT_TEMP
#define AD7949_CFG_VAL_REF_INT_4096
#define AD7949_CFG_VAL_REF_INT_2500
#define AD7949_CFG_VAL_REF_EXTERNAL

/* SEQ: channel sequencer. Allows for scanning channels */
#define AD7949_CFG_MASK_SEQ

/* RB: Read back the CFG register */
#define AD7949_CFG_MASK_RBN

enum {};

struct ad7949_adc_spec {};

static const struct ad7949_adc_spec ad7949_adc_spec[] =;

/**
 * struct ad7949_adc_chip - AD ADC chip
 * @lock: protects write sequences
 * @vref: regulator generating Vref
 * @indio_dev: reference to iio structure
 * @spi: reference to spi structure
 * @refsel: reference selection
 * @resolution: resolution of the chip
 * @cfg: copy of the configuration register
 * @current_channel: current channel in use
 * @buffer: buffer to send / receive data to / from device
 * @buf8b: be16 buffer to exchange data with the device in 8-bit transfers
 */
struct ad7949_adc_chip {};

static int ad7949_spi_write_cfg(struct ad7949_adc_chip *ad7949_adc, u16 val,
				u16 mask)
{}

static int ad7949_spi_read_channel(struct ad7949_adc_chip *ad7949_adc, int *val,
				   unsigned int channel)
{}

#define AD7949_ADC_CHANNEL(chan)

static const struct iio_chan_spec ad7949_adc_channels[] =;

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

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

static const struct iio_info ad7949_spi_info =;

static int ad7949_spi_init(struct ad7949_adc_chip *ad7949_adc)
{}

static void ad7949_disable_reg(void *reg)
{}

static int ad7949_spi_probe(struct spi_device *spi)
{}

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

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

static struct spi_driver ad7949_spi_driver =;
module_spi_driver();

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