linux/drivers/iio/dac/ad5758.c

// SPDX-License-Identifier: GPL-2.0
/*
 * AD5758 Digital to analog converters driver
 *
 * Copyright 2018 Analog Devices Inc.
 *
 * TODO: Currently CRC is not supported in this driver
 */
#include <linux/bsearch.h>
#include <linux/delay.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/mod_devicetable.h>
#include <linux/property.h>
#include <linux/spi/spi.h>
#include <linux/gpio/consumer.h>

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

/* AD5758 registers definition */
#define AD5758_NOP
#define AD5758_DAC_INPUT
#define AD5758_DAC_OUTPUT
#define AD5758_CLEAR_CODE
#define AD5758_USER_GAIN
#define AD5758_USER_OFFSET
#define AD5758_DAC_CONFIG
#define AD5758_SW_LDAC
#define AD5758_KEY
#define AD5758_GP_CONFIG1
#define AD5758_GP_CONFIG2
#define AD5758_DCDC_CONFIG1
#define AD5758_DCDC_CONFIG2
#define AD5758_WDT_CONFIG
#define AD5758_DIGITAL_DIAG_CONFIG
#define AD5758_ADC_CONFIG
#define AD5758_FAULT_PIN_CONFIG
#define AD5758_TWO_STAGE_READBACK_SELECT
#define AD5758_DIGITAL_DIAG_RESULTS
#define AD5758_ANALOG_DIAG_RESULTS
#define AD5758_STATUS
#define AD5758_CHIP_ID
#define AD5758_FREQ_MONITOR
#define AD5758_DEVICE_ID_0
#define AD5758_DEVICE_ID_1
#define AD5758_DEVICE_ID_2
#define AD5758_DEVICE_ID_3

/* AD5758_DAC_CONFIG */
#define AD5758_DAC_CONFIG_RANGE_MSK
#define AD5758_DAC_CONFIG_RANGE_MODE(x)
#define AD5758_DAC_CONFIG_INT_EN_MSK
#define AD5758_DAC_CONFIG_INT_EN_MODE(x)
#define AD5758_DAC_CONFIG_OUT_EN_MSK
#define AD5758_DAC_CONFIG_OUT_EN_MODE(x)
#define AD5758_DAC_CONFIG_SR_EN_MSK
#define AD5758_DAC_CONFIG_SR_EN_MODE(x)
#define AD5758_DAC_CONFIG_SR_CLOCK_MSK
#define AD5758_DAC_CONFIG_SR_CLOCK_MODE(x)
#define AD5758_DAC_CONFIG_SR_STEP_MSK
#define AD5758_DAC_CONFIG_SR_STEP_MODE(x)

/* AD5758_KEY */
#define AD5758_KEY_CODE_RESET_1
#define AD5758_KEY_CODE_RESET_2
#define AD5758_KEY_CODE_SINGLE_ADC_CONV
#define AD5758_KEY_CODE_RESET_WDT
#define AD5758_KEY_CODE_CALIB_MEM_REFRESH

/* AD5758_DCDC_CONFIG1 */
#define AD5758_DCDC_CONFIG1_DCDC_VPROG_MSK
#define AD5758_DCDC_CONFIG1_DCDC_VPROG_MODE(x)
#define AD5758_DCDC_CONFIG1_DCDC_MODE_MSK
#define AD5758_DCDC_CONFIG1_DCDC_MODE_MODE(x)

/* AD5758_DCDC_CONFIG2 */
#define AD5758_DCDC_CONFIG2_ILIMIT_MSK
#define AD5758_DCDC_CONFIG2_ILIMIT_MODE(x)
#define AD5758_DCDC_CONFIG2_INTR_SAT_3WI_MSK
#define AD5758_DCDC_CONFIG2_BUSY_3WI_MSK

/* AD5758_DIGITAL_DIAG_RESULTS */
#define AD5758_CAL_MEM_UNREFRESHED_MSK

/* AD5758_ADC_CONFIG */
#define AD5758_ADC_CONFIG_PPC_BUF_EN(x)
#define AD5758_ADC_CONFIG_PPC_BUF_MSK

#define AD5758_WR_FLAG_MSK(x)

#define AD5758_FULL_SCALE_MICRO

struct ad5758_range {};

/**
 * struct ad5758_state - driver instance specific data
 * @spi:	spi_device
 * @lock:	mutex lock
 * @gpio_reset:	gpio descriptor for the reset line
 * @out_range:	struct which stores the output range
 * @dc_dc_mode:	variable which stores the mode of operation
 * @dc_dc_ilim:	variable which stores the dc-to-dc converter current limit
 * @slew_time:	variable which stores the target slew time
 * @pwr_down:	variable which contains whether a channel is powered down or not
 * @d32:	spi transfer buffers
 */
struct ad5758_state {};

/*
 * Output ranges corresponding to bits [3:0] from DAC_CONFIG register
 * 0000: 0 V to 5 V voltage range
 * 0001: 0 V to 10 V voltage range
 * 0010: ±5 V voltage range
 * 0011: ±10 V voltage range
 * 1000: 0 mA to 20 mA current range
 * 1001: 0 mA to 24 mA current range
 * 1010: 4 mA to 20 mA current range
 * 1011: ±20 mA current range
 * 1100: ±24 mA current range
 * 1101: -1 mA to +22 mA current range
 */
enum ad5758_output_range {};

enum ad5758_dc_dc_mode {};

static const struct ad5758_range ad5758_voltage_range[] =;

static const struct ad5758_range ad5758_current_range[] =;

static const int ad5758_sr_clk[16] =;

static const int ad5758_sr_step[8] =;

static const int ad5758_dc_dc_ilim[6] =;

static int ad5758_spi_reg_read(struct ad5758_state *st, unsigned int addr)
{}

static int ad5758_spi_reg_write(struct ad5758_state *st,
				unsigned int addr,
				unsigned int val)
{}

static int ad5758_spi_write_mask(struct ad5758_state *st,
				 unsigned int addr,
				 unsigned long int mask,
				 unsigned int val)
{}

static int cmpfunc(const void *a, const void *b)
{}

static int ad5758_find_closest_match(const int *array,
				     unsigned int size, int val)
{}

static int ad5758_wait_for_task_complete(struct ad5758_state *st,
					 unsigned int reg,
					 unsigned int mask)
{}

static int ad5758_calib_mem_refresh(struct ad5758_state *st)
{}

static int ad5758_soft_reset(struct ad5758_state *st)
{}

static int ad5758_set_dc_dc_conv_mode(struct ad5758_state *st,
				      enum ad5758_dc_dc_mode mode)
{}

static int ad5758_set_dc_dc_ilim(struct ad5758_state *st, unsigned int ilim)
{}

static int ad5758_slew_rate_set(struct ad5758_state *st,
				unsigned int sr_clk_idx,
				unsigned int sr_step_idx)
{}

static int ad5758_slew_rate_config(struct ad5758_state *st)
{}

static int ad5758_set_out_range(struct ad5758_state *st, int range)
{}

static int ad5758_internal_buffers_en(struct ad5758_state *st, bool enable)
{}

static int ad5758_reset(struct ad5758_state *st)
{}

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

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

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

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

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

static const struct iio_info ad5758_info =;

static const struct iio_chan_spec_ext_info ad5758_ext_info[] =;

#define AD5758_DAC_CHAN(_chan_type)

static const struct iio_chan_spec ad5758_voltage_ch[] =;

static const struct iio_chan_spec ad5758_current_ch[] =;

static bool ad5758_is_valid_mode(enum ad5758_dc_dc_mode mode)
{}

static int ad5758_crc_disable(struct ad5758_state *st)
{}

static int ad5758_find_out_range(struct ad5758_state *st,
				 const struct ad5758_range *range,
				 unsigned int size,
				 int min, int max)
{}

static int ad5758_parse_dt(struct ad5758_state *st)
{}

static int ad5758_init(struct ad5758_state *st)
{}

static int ad5758_probe(struct spi_device *spi)
{}

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

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

static struct spi_driver ad5758_driver =;

module_spi_driver();

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