Commit 192778fb authored by Mircea Caprioru's avatar Mircea Caprioru Committed by Jonathan Cameron

iio: dac: ad5686: Add support for AD5674R/AD5679R

The AD5674R/AD5679R are low power, 16-channel, 12-/16-bit buffered voltage
output digital-to-analog converters (DACs). They include a 2.5 V internal
reference (enabled by default).

These devices are very similar to AD5684R/AD5686R, except that they have 16
channels.
Signed-off-by: default avatarMircea Caprioru <mircea.caprioru@analog.com>
Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
parent e717f8c6
...@@ -148,9 +148,9 @@ config AD5686_SPI ...@@ -148,9 +148,9 @@ config AD5686_SPI
depends on SPI depends on SPI
select AD5686 select AD5686
help help
Say yes here to build support for Analog Devices AD5672R, AD5676, Say yes here to build support for Analog Devices AD5672R, AD5674R,
AD5676R, AD5684, AD5684R, AD5684R, AD5685R, AD5686, AD5686R. AD5676, AD5676R, AD5679R, AD5684, AD5684R, AD5684R, AD5685R, AD5686,
Voltage Output Digital to Analog Converter. AD5686R Voltage Output Digital to Analog Converter.
To compile this driver as a module, choose M here: the To compile this driver as a module, choose M here: the
module will be called ad5686. module will be called ad5686.
......
// SPDX-License-Identifier: GPL-2.0+ // SPDX-License-Identifier: GPL-2.0+
/* /*
* AD5672R, AD5676, AD5676R, AD5681R, AD5682R, AD5683, AD5683R, * AD5672R, AD5674R, AD5676, AD5676R, AD5679R,
* AD5684, AD5684R, AD5685R, AD5686, AD5686R * AD5681R, AD5682R, AD5683, AD5683R, AD5684,
* AD5684R, AD5685R, AD5686, AD5686R
* Digital to analog converters driver * Digital to analog converters driver
* *
* Copyright 2018 Analog Devices Inc. * Copyright 2018 Analog Devices Inc.
...@@ -102,8 +103,10 @@ static int ad5686_spi_remove(struct spi_device *spi) ...@@ -102,8 +103,10 @@ static int ad5686_spi_remove(struct spi_device *spi)
static const struct spi_device_id ad5686_spi_id[] = { static const struct spi_device_id ad5686_spi_id[] = {
{"ad5310r", ID_AD5310R}, {"ad5310r", ID_AD5310R},
{"ad5672r", ID_AD5672R}, {"ad5672r", ID_AD5672R},
{"ad5674r", ID_AD5674R},
{"ad5676", ID_AD5676}, {"ad5676", ID_AD5676},
{"ad5676r", ID_AD5676R}, {"ad5676r", ID_AD5676R},
{"ad5679r", ID_AD5679R},
{"ad5681r", ID_AD5681R}, {"ad5681r", ID_AD5681R},
{"ad5682r", ID_AD5682R}, {"ad5682r", ID_AD5682R},
{"ad5683", ID_AD5683}, {"ad5683", ID_AD5683},
......
...@@ -71,7 +71,7 @@ static ssize_t ad5686_write_dac_powerdown(struct iio_dev *indio_dev, ...@@ -71,7 +71,7 @@ static ssize_t ad5686_write_dac_powerdown(struct iio_dev *indio_dev,
int ret; int ret;
struct ad5686_state *st = iio_priv(indio_dev); struct ad5686_state *st = iio_priv(indio_dev);
unsigned int val, ref_bit_msk; unsigned int val, ref_bit_msk;
u8 shift; u8 shift, address = 0;
ret = strtobool(buf, &readin); ret = strtobool(buf, &readin);
if (ret) if (ret)
...@@ -94,6 +94,9 @@ static ssize_t ad5686_write_dac_powerdown(struct iio_dev *indio_dev, ...@@ -94,6 +94,9 @@ static ssize_t ad5686_write_dac_powerdown(struct iio_dev *indio_dev,
case AD5686_REGMAP: case AD5686_REGMAP:
shift = 0; shift = 0;
ref_bit_msk = 0; ref_bit_msk = 0;
/* AD5674R/AD5679R have 16 channels and 2 powerdown registers */
if (chan->channel > 0x7)
address = 0x8;
break; break;
case AD5693_REGMAP: case AD5693_REGMAP:
shift = 13; shift = 13;
...@@ -107,7 +110,8 @@ static ssize_t ad5686_write_dac_powerdown(struct iio_dev *indio_dev, ...@@ -107,7 +110,8 @@ static ssize_t ad5686_write_dac_powerdown(struct iio_dev *indio_dev,
if (!st->use_internal_vref) if (!st->use_internal_vref)
val |= ref_bit_msk; val |= ref_bit_msk;
ret = st->write(st, AD5686_CMD_POWERDOWN_DAC, 0, val); ret = st->write(st, AD5686_CMD_POWERDOWN_DAC,
address, val >> (address * 2));
return ret ? ret : len; return ret ? ret : len;
} }
...@@ -226,10 +230,32 @@ static struct iio_chan_spec name[] = { \ ...@@ -226,10 +230,32 @@ static struct iio_chan_spec name[] = { \
AD5868_CHANNEL(7, 7, bits, _shift), \ AD5868_CHANNEL(7, 7, bits, _shift), \
} }
#define DECLARE_AD5679_CHANNELS(name, bits, _shift) \
static struct iio_chan_spec name[] = { \
AD5868_CHANNEL(0, 0, bits, _shift), \
AD5868_CHANNEL(1, 1, bits, _shift), \
AD5868_CHANNEL(2, 2, bits, _shift), \
AD5868_CHANNEL(3, 3, bits, _shift), \
AD5868_CHANNEL(4, 4, bits, _shift), \
AD5868_CHANNEL(5, 5, bits, _shift), \
AD5868_CHANNEL(6, 6, bits, _shift), \
AD5868_CHANNEL(7, 7, bits, _shift), \
AD5868_CHANNEL(8, 8, bits, _shift), \
AD5868_CHANNEL(9, 9, bits, _shift), \
AD5868_CHANNEL(10, 10, bits, _shift), \
AD5868_CHANNEL(11, 11, bits, _shift), \
AD5868_CHANNEL(12, 12, bits, _shift), \
AD5868_CHANNEL(13, 13, bits, _shift), \
AD5868_CHANNEL(14, 14, bits, _shift), \
AD5868_CHANNEL(15, 15, bits, _shift), \
}
DECLARE_AD5693_CHANNELS(ad5310r_channels, 10, 2); DECLARE_AD5693_CHANNELS(ad5310r_channels, 10, 2);
DECLARE_AD5693_CHANNELS(ad5311r_channels, 10, 6); DECLARE_AD5693_CHANNELS(ad5311r_channels, 10, 6);
DECLARE_AD5676_CHANNELS(ad5672_channels, 12, 4); DECLARE_AD5676_CHANNELS(ad5672_channels, 12, 4);
DECLARE_AD5679_CHANNELS(ad5674r_channels, 12, 4);
DECLARE_AD5676_CHANNELS(ad5676_channels, 16, 0); DECLARE_AD5676_CHANNELS(ad5676_channels, 16, 0);
DECLARE_AD5679_CHANNELS(ad5679r_channels, 16, 0);
DECLARE_AD5686_CHANNELS(ad5684_channels, 12, 4); DECLARE_AD5686_CHANNELS(ad5684_channels, 12, 4);
DECLARE_AD5686_CHANNELS(ad5685r_channels, 14, 2); DECLARE_AD5686_CHANNELS(ad5685r_channels, 14, 2);
DECLARE_AD5686_CHANNELS(ad5686_channels, 16, 0); DECLARE_AD5686_CHANNELS(ad5686_channels, 16, 0);
...@@ -262,6 +288,12 @@ static const struct ad5686_chip_info ad5686_chip_info_tbl[] = { ...@@ -262,6 +288,12 @@ static const struct ad5686_chip_info ad5686_chip_info_tbl[] = {
.num_channels = 8, .num_channels = 8,
.regmap_type = AD5686_REGMAP, .regmap_type = AD5686_REGMAP,
}, },
[ID_AD5674R] = {
.channels = ad5674r_channels,
.int_vref_mv = 2500,
.num_channels = 16,
.regmap_type = AD5686_REGMAP,
},
[ID_AD5675R] = { [ID_AD5675R] = {
.channels = ad5676_channels, .channels = ad5676_channels,
.int_vref_mv = 2500, .int_vref_mv = 2500,
...@@ -279,6 +311,12 @@ static const struct ad5686_chip_info ad5686_chip_info_tbl[] = { ...@@ -279,6 +311,12 @@ static const struct ad5686_chip_info ad5686_chip_info_tbl[] = {
.num_channels = 8, .num_channels = 8,
.regmap_type = AD5686_REGMAP, .regmap_type = AD5686_REGMAP,
}, },
[ID_AD5679R] = {
.channels = ad5679r_channels,
.int_vref_mv = 2500,
.num_channels = 16,
.regmap_type = AD5686_REGMAP,
},
[ID_AD5681R] = { [ID_AD5681R] = {
.channels = ad5691r_channels, .channels = ad5691r_channels,
.int_vref_mv = 2500, .int_vref_mv = 2500,
......
...@@ -54,9 +54,11 @@ enum ad5686_supported_device_ids { ...@@ -54,9 +54,11 @@ enum ad5686_supported_device_ids {
ID_AD5311R, ID_AD5311R,
ID_AD5671R, ID_AD5671R,
ID_AD5672R, ID_AD5672R,
ID_AD5674R,
ID_AD5675R, ID_AD5675R,
ID_AD5676, ID_AD5676,
ID_AD5676R, ID_AD5676R,
ID_AD5679R,
ID_AD5681R, ID_AD5681R,
ID_AD5682R, ID_AD5682R,
ID_AD5683, ID_AD5683,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment