Source
x
/*
* Analog devices AD5380, AD5381, AD5382, AD5383, AD5390, AD5391, AD5392
* multi-channel Digital to Analog Converters driver
*
* Copyright 2011 Analog Devices Inc.
*
* Licensed under the GPL-2.
*/
/**
* struct ad5380_chip_info - chip specific information
* @channel_template: channel specification template
* @num_channels: number of channels
* @int_vref: internal vref in uV
*/
struct ad5380_chip_info {
struct iio_chan_spec channel_template;
unsigned int num_channels;
unsigned int int_vref;
};
/**
* struct ad5380_state - driver instance specific data
* @regmap: regmap instance used by the device
* @chip_info: chip model specific constants, available modes etc
* @vref_reg: vref supply regulator
* @vref: actual reference voltage used in uA
* @pwr_down: whether the chip is currently in power down mode
*/
struct ad5380_state {
struct regmap *regmap;
const struct ad5380_chip_info *chip_info;
struct regulator *vref_reg;
int vref;
bool pwr_down;
};
enum ad5380_type {
ID_AD5380_3,
ID_AD5380_5,
ID_AD5381_3,
ID_AD5381_5,
ID_AD5382_3,
ID_AD5382_5,
ID_AD5383_3,
ID_AD5383_5,
ID_AD5390_3,
ID_AD5390_5,
ID_AD5391_3,
ID_AD5391_5,
ID_AD5392_3,
ID_AD5392_5,
};
static ssize_t ad5380_read_dac_powerdown(struct iio_dev *indio_dev,
uintptr_t private, const struct iio_chan_spec *chan, char *buf)
{
struct ad5380_state *st = iio_priv(indio_dev);
return sprintf(buf, "%d\n", st->pwr_down);
}
static ssize_t ad5380_write_dac_powerdown(struct iio_dev *indio_dev,
uintptr_t private, const struct iio_chan_spec *chan, const char *buf,
size_t len)