linux/drivers/iio/dac/ad5064.c

// SPDX-License-Identifier: GPL-2.0-only
/*
 * AD5024, AD5025, AD5044, AD5045, AD5064, AD5064-1, AD5065, AD5625, AD5625R,
 * AD5627, AD5627R, AD5628, AD5629R, AD5645R, AD5647R, AD5648, AD5665, AD5665R,
 * AD5666, AD5667, AD5667R, AD5668, AD5669R, LTC2606, LTC2607, LTC2609, LTC2616,
 * LTC2617, LTC2619, LTC2626, LTC2627, LTC2629, LTC2631, LTC2633, LTC2635
 * Digital to analog converters driver
 *
 * Copyright 2011 Analog Devices Inc.
 */

#include <linux/device.h>
#include <linux/err.h>
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/spi/spi.h>
#include <linux/i2c.h>
#include <linux/slab.h>
#include <linux/sysfs.h>
#include <linux/regulator/consumer.h>
#include <asm/unaligned.h>

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

#define AD5064_MAX_DAC_CHANNELS
#define AD5064_MAX_VREFS

#define AD5064_ADDR(x)
#define AD5064_CMD(x)

#define AD5064_ADDR_ALL_DAC

#define AD5064_CMD_WRITE_INPUT_N
#define AD5064_CMD_UPDATE_DAC_N
#define AD5064_CMD_WRITE_INPUT_N_UPDATE_ALL
#define AD5064_CMD_WRITE_INPUT_N_UPDATE_N
#define AD5064_CMD_POWERDOWN_DAC
#define AD5064_CMD_CLEAR
#define AD5064_CMD_LDAC_MASK
#define AD5064_CMD_RESET
#define AD5064_CMD_CONFIG

#define AD5064_CMD_RESET_V2
#define AD5064_CMD_CONFIG_V2

#define AD5064_CONFIG_DAISY_CHAIN_ENABLE
#define AD5064_CONFIG_INT_VREF_ENABLE

#define AD5064_LDAC_PWRDN_NONE
#define AD5064_LDAC_PWRDN_1K
#define AD5064_LDAC_PWRDN_100K
#define AD5064_LDAC_PWRDN_3STATE

/**
 * enum ad5064_regmap_type - Register layout variant
 * @AD5064_REGMAP_ADI: Old Analog Devices register map layout
 * @AD5064_REGMAP_ADI2: New Analog Devices register map layout
 * @AD5064_REGMAP_LTC: LTC register map layout
 */
enum ad5064_regmap_type {};

/**
 * struct ad5064_chip_info - chip specific information
 * @shared_vref:	whether the vref supply is shared between channels
 * @internal_vref:	internal reference voltage. 0 if the chip has no
 *			internal vref.
 * @channels:		channel specification
 * @num_channels:	number of channels
 * @regmap_type:	register map layout variant
 */

struct ad5064_chip_info {};

struct ad5064_state;

ad5064_write_func;

/**
 * struct ad5064_state - driver instance specific data
 * @dev:		the device for this driver instance
 * @chip_info:		chip model specific constants, available modes etc
 * @vref_reg:		vref supply regulators
 * @pwr_down:		whether channel is powered down
 * @pwr_down_mode:	channel's current power down mode
 * @dac_cache:		current DAC raw value (chip does not support readback)
 * @use_internal_vref:	set to true if the internal reference voltage should be
 *			used.
 * @write:		register write callback
 * @lock:		maintain consistency between cached and dev state
 * @data:		i2c/spi transfer buffers
 */

struct ad5064_state {};

enum ad5064_type {};

static int ad5064_write(struct ad5064_state *st, unsigned int cmd,
	unsigned int addr, unsigned int val, unsigned int shift)
{}

static int ad5064_sync_powerdown_mode(struct ad5064_state *st,
	const struct iio_chan_spec *chan)
{}

static const char * const ad5064_powerdown_modes[] =;

static const char * const ltc2617_powerdown_modes[] =;

static int ad5064_get_powerdown_mode(struct iio_dev *indio_dev,
	const struct iio_chan_spec *chan)
{}

static int ad5064_set_powerdown_mode(struct iio_dev *indio_dev,
	const struct iio_chan_spec *chan, unsigned int mode)
{}

static const struct iio_enum ad5064_powerdown_mode_enum =;

static const struct iio_enum ltc2617_powerdown_mode_enum =;

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

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

static int ad5064_get_vref(struct ad5064_state *st,
	struct iio_chan_spec const *chan)
{}

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

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

static const struct iio_info ad5064_info =;

static const struct iio_chan_spec_ext_info ad5064_ext_info[] =;

static const struct iio_chan_spec_ext_info ltc2617_ext_info[] =;

#define AD5064_CHANNEL(chan, addr, bits, _shift, _ext_info)

#define DECLARE_AD5064_CHANNELS(name, bits, shift, ext_info)

#define DECLARE_AD5065_CHANNELS(name, bits, shift, ext_info)

static DECLARE_AD5064_CHANNELS(ad5024_channels, 12, 8, ad5064_ext_info);
static DECLARE_AD5064_CHANNELS(ad5044_channels, 14, 6, ad5064_ext_info);
static DECLARE_AD5064_CHANNELS(ad5064_channels, 16, 4, ad5064_ext_info);

static DECLARE_AD5065_CHANNELS(ad5025_channels, 12, 8, ad5064_ext_info);
static DECLARE_AD5065_CHANNELS(ad5045_channels, 14, 6, ad5064_ext_info);
static DECLARE_AD5065_CHANNELS(ad5065_channels, 16, 4, ad5064_ext_info);

static DECLARE_AD5064_CHANNELS(ad5629_channels, 12, 4, ad5064_ext_info);
static DECLARE_AD5064_CHANNELS(ad5645_channels, 14, 2, ad5064_ext_info);
static DECLARE_AD5064_CHANNELS(ad5669_channels, 16, 0, ad5064_ext_info);

static DECLARE_AD5064_CHANNELS(ltc2607_channels, 16, 0, ltc2617_ext_info);
static DECLARE_AD5064_CHANNELS(ltc2617_channels, 14, 2, ltc2617_ext_info);
static DECLARE_AD5064_CHANNELS(ltc2627_channels, 12, 4, ltc2617_ext_info);
#define ltc2631_12_channels
static DECLARE_AD5064_CHANNELS(ltc2631_10_channels, 10, 6, ltc2617_ext_info);
static DECLARE_AD5064_CHANNELS(ltc2631_8_channels, 8, 8, ltc2617_ext_info);

#define LTC2631_INFO(vref, pchannels, nchannels)


static const struct ad5064_chip_info ad5064_chip_info_tbl[] =;

static inline unsigned int ad5064_num_vref(struct ad5064_state *st)
{}

static const char * const ad5064_vref_names[] =;

static const char *ad5064_vref_name(struct ad5064_state *st,
	unsigned int vref)
{}

static int ad5064_set_config(struct ad5064_state *st, unsigned int val)
{}

static int ad5064_request_vref(struct ad5064_state *st, struct device *dev)
{}

static void ad5064_bulk_reg_disable(void *data)
{}

static int ad5064_probe(struct device *dev, enum ad5064_type type,
			const char *name, ad5064_write_func write)
{}

#if IS_ENABLED(CONFIG_SPI_MASTER)

static int ad5064_spi_write(struct ad5064_state *st, unsigned int cmd,
	unsigned int addr, unsigned int val)
{}

static int ad5064_spi_probe(struct spi_device *spi)
{}

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

static struct spi_driver ad5064_spi_driver =;

static int __init ad5064_spi_register_driver(void)
{}

static void ad5064_spi_unregister_driver(void)
{}

#else

static inline int ad5064_spi_register_driver(void) { return 0; }
static inline void ad5064_spi_unregister_driver(void) { }

#endif

#if IS_ENABLED(CONFIG_I2C)

static int ad5064_i2c_write(struct ad5064_state *st, unsigned int cmd,
	unsigned int addr, unsigned int val)
{}

static int ad5064_i2c_probe(struct i2c_client *i2c)
{}

static const struct i2c_device_id ad5064_i2c_ids[] =;
MODULE_DEVICE_TABLE(i2c, ad5064_i2c_ids);

static struct i2c_driver ad5064_i2c_driver =;

static int __init ad5064_i2c_register_driver(void)
{}

static void __exit ad5064_i2c_unregister_driver(void)
{}

#else

static inline int ad5064_i2c_register_driver(void) { return 0; }
static inline void ad5064_i2c_unregister_driver(void) { }

#endif

static int __init ad5064_init(void)
{}
module_init();

static void __exit ad5064_exit(void)
{}
module_exit(ad5064_exit);

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