linux/drivers/iio/dac/ad5766.c

// SPDX-License-Identifier: GPL-2.0-only
/*
 * Analog Devices AD5766, AD5767
 * Digital to Analog Converters driver
 * Copyright 2019-2020 Analog Devices Inc.
 */
#include <linux/bitfield.h>
#include <linux/bitops.h>
#include <linux/delay.h>
#include <linux/device.h>
#include <linux/gpio/consumer.h>
#include <linux/iio/iio.h>
#include <linux/iio/triggered_buffer.h>
#include <linux/iio/trigger_consumer.h>
#include <linux/module.h>
#include <linux/spi/spi.h>
#include <asm/unaligned.h>

#define AD5766_UPPER_WORD_SPI_MASK
#define AD5766_LOWER_WORD_SPI_MASK
#define AD5766_DITHER_SOURCE_MASK(ch)
#define AD5766_DITHER_SOURCE(ch, source)
#define AD5766_DITHER_SCALE_MASK(x)
#define AD5766_DITHER_SCALE(ch, scale)
#define AD5766_DITHER_ENABLE_MASK(ch)
#define AD5766_DITHER_ENABLE(ch, state)
#define AD5766_DITHER_INVERT_MASK(ch)
#define AD5766_DITHER_INVERT(ch, state)

#define AD5766_CMD_NOP_MUX_OUT
#define AD5766_CMD_SDO_CNTRL
#define AD5766_CMD_WR_IN_REG(x)
#define AD5766_CMD_WR_DAC_REG(x)
#define AD5766_CMD_SW_LDAC
#define AD5766_CMD_SPAN_REG
#define AD5766_CMD_WR_PWR_DITHER
#define AD5766_CMD_WR_DAC_REG_ALL
#define AD5766_CMD_SW_FULL_RESET
#define AD5766_CMD_READBACK_REG(x)
#define AD5766_CMD_DITHER_SIG_1
#define AD5766_CMD_DITHER_SIG_2
#define AD5766_CMD_INV_DITHER
#define AD5766_CMD_DITHER_SCALE_1
#define AD5766_CMD_DITHER_SCALE_2

#define AD5766_FULL_RESET_CODE

enum ad5766_type {};

enum ad5766_voltage_range {};

/**
 * struct ad5766_chip_info - chip specific information
 * @num_channels:	number of channels
 * @channels:	        channel specification
 */
struct ad5766_chip_info {};

enum {};

/*
 * Dither signal can also be scaled.
 * Available dither scale strings corresponding to "dither_scale" field in
 * "struct ad5766_state".
 */
static const char * const ad5766_dither_scales[] =;

/**
 * struct ad5766_state - driver instance specific data
 * @spi:		SPI device
 * @lock:		Lock used to restrict concurrent access to SPI device
 * @chip_info:		Chip model specific constants
 * @gpio_reset:		Reset GPIO, used to reset the device
 * @crt_range:		Current selected output range
 * @dither_enable:	Power enable bit for each channel dither block (for
 *			example, D15 = DAC 15,D8 = DAC 8, and D0 = DAC 0)
 *			0 - Normal operation, 1 - Power down
 * @dither_invert:	Inverts the dither signal applied to the selected DAC
 *			outputs
 * @dither_source:	Selects between 2 possible sources:
 *			1: N0, 2: N1
 *			Two bits are used for each channel
 * @dither_scale:	Two bits are used for each of the 16 channels:
 *			0: 1 SCALING, 1: 0.75 SCALING, 2: 0.5 SCALING,
 *			3: 0.25 SCALING.
 * @data:		SPI transfer buffers
 */
struct ad5766_state {};

struct ad5766_span_tbl {};

static const struct ad5766_span_tbl ad5766_span_tbl[] =;

static int __ad5766_spi_read(struct ad5766_state *st, u8 dac, int *val)
{}

static int __ad5766_spi_write(struct ad5766_state *st, u8 command, u16 data)
{}

static int ad5766_read(struct iio_dev *indio_dev, u8 dac, int *val)
{}

static int ad5766_write(struct iio_dev *indio_dev, u8 dac, u16 data)
{}

static int ad5766_reset(struct ad5766_state *st)
{}

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

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

static const struct iio_info ad5766_info =;

static int ad5766_get_dither_source(struct iio_dev *dev,
				    const struct iio_chan_spec *chan)
{}

static int ad5766_set_dither_source(struct iio_dev *dev,
			  const struct iio_chan_spec *chan,
			  unsigned int source)
{}

static int ad5766_get_dither_scale(struct iio_dev *dev,
				   const struct iio_chan_spec *chan)
{}

static int ad5766_set_dither_scale(struct iio_dev *dev,
			  const struct iio_chan_spec *chan,
			  unsigned int scale)
{}

static const struct iio_enum ad5766_dither_scale_enum =;

static ssize_t ad5766_read_ext(struct iio_dev *indio_dev,
			       uintptr_t private,
			       const struct iio_chan_spec *chan,
			       char *buf)
{}

static ssize_t ad5766_write_ext(struct iio_dev *indio_dev,
				 uintptr_t private,
				 const struct iio_chan_spec *chan,
				 const char *buf, size_t len)
{}

#define _AD5766_CHAN_EXT_INFO(_name, _what, _shared)

static const struct iio_chan_spec_ext_info ad5766_ext_info[] =;

#define AD576x_CHANNEL(_chan, _bits)

#define DECLARE_AD576x_CHANNELS(_name, _bits)

static DECLARE_AD576x_CHANNELS(ad5766_channels, 16);
static DECLARE_AD576x_CHANNELS(ad5767_channels, 12);

static const struct ad5766_chip_info ad5766_chip_infos[] =;

static int ad5766_get_output_range(struct ad5766_state *st)
{}

static int ad5766_default_setup(struct ad5766_state *st)
{}

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

static int ad5766_probe(struct spi_device *spi)
{}

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

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

static struct spi_driver ad5766_driver =;
module_spi_driver();

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