Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions drivers/iio/dac/ad5686-spi.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/*
* AD5672R, AD5676, AD5676R, AD5684, AD5684R, AD5684R, AD5685R, AD5686, AD5686R
* AD5672R, AD5676, AD5676R, AD5681R, AD5682R, AD5683, AD5683R,
* AD5684, AD5684R, AD5685R, AD5686, AD5686R
* Digital to analog converters driver
*
* Copyright 2018 Analog Devices Inc.
Expand Down Expand Up @@ -38,9 +39,15 @@ static int ad5686_spi_read(struct ad5686_state *st, u8 addr)
},
};
struct spi_device *spi = to_spi_device(st->dev);
u8 cmd;
int ret;

st->data[0].d32 = cpu_to_be32(AD5686_CMD(AD5686_CMD_READBACK_ENABLE) |
if (st->chip_info->regmap_type == AD5686_REGMAP)
cmd = AD5686_CMD_READBACK_ENABLE;
else if (st->chip_info->regmap_type == AD5683_REGMAP)
cmd = AD5686_CMD_READBACK_ENABLE_V2;

st->data[0].d32 = cpu_to_be32(AD5686_CMD(cmd) |
AD5686_ADDR(addr));
st->data[1].d32 = cpu_to_be32(AD5686_CMD(AD5686_CMD_NOOP));

Expand Down Expand Up @@ -68,6 +75,10 @@ static const struct spi_device_id ad5686_spi_id[] = {
{"ad5672r", ID_AD5672R},
{"ad5676", ID_AD5676},
{"ad5676r", ID_AD5676R},
{"ad5681r", ID_AD5681R},
{"ad5682r", ID_AD5682R},
{"ad5683", ID_AD5683},
{"ad5683r", ID_AD5683R},
{"ad5684", ID_AD5684},
{"ad5684r", ID_AD5684R},
{"ad5685r", ID_AD5685R},
Expand Down
32 changes: 32 additions & 0 deletions drivers/iio/dac/ad5686.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,10 @@ static ssize_t ad5686_write_dac_powerdown(struct iio_dev *indio_dev,
st->pwr_down_mask &= ~(0x3 << (chan->channel * 2));

switch (st->chip_info->regmap_type) {
case AD5683_REGMAP:
shift = 17;
ref_bit_msk = AD5683_REF_BIT_MSK;
break;
case AD5686_REGMAP:
shift = 0;
ref_bit_msk = 0;
Expand Down Expand Up @@ -268,6 +272,29 @@ static const struct ad5686_chip_info ad5686_chip_info_tbl[] = {
.num_channels = 8,
.regmap_type = AD5686_REGMAP,
},
[ID_AD5681R] = {
.channels = ad5691r_channels,
.int_vref_mv = 2500,
.num_channels = 1,
.regmap_type = AD5683_REGMAP,
},
[ID_AD5682R] = {
.channels = ad5692r_channels,
.int_vref_mv = 2500,
.num_channels = 1,
.regmap_type = AD5683_REGMAP,
},
[ID_AD5683] = {
.channels = ad5693_channels,
.num_channels = 1,
.regmap_type = AD5683_REGMAP,
},
[ID_AD5683R] = {
.channels = ad5693_channels,
.int_vref_mv = 2500,
.num_channels = 1,
.regmap_type = AD5683_REGMAP,
},
[ID_AD5684] = {
.channels = ad5684_channels,
.num_channels = 4,
Expand Down Expand Up @@ -395,6 +422,11 @@ int ad5686_probe(struct device *dev, enum ad5686_supported_device_ids chip_type,
indio_dev->num_channels = st->chip_info->num_channels;

switch (st->chip_info->regmap_type) {
case AD5683_REGMAP:
cmd = AD5686_CMD_CONTROL_REG;
ref_bit_msk = AD5683_REF_BIT_MSK;
st->use_internal_vref = !voltage_uv;
break;
case AD5686_REGMAP:
cmd = AD5686_CMD_INTERNAL_REFER_SETUP;
ref_bit_msk = 0;
Expand Down
9 changes: 8 additions & 1 deletion drivers/iio/dac/ad5686.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
#define AD5686_LDAC_PWRDN_3STATE 0x3

#define AD5686_CMD_CONTROL_REG 0x4
#define AD5686_CMD_READBACK_ENABLE_V2 0x5
#define AD5683_REF_BIT_MSK BIT(16)
#define AD5693_REF_BIT_MSK BIT(12)

/**
Expand All @@ -40,6 +42,10 @@ enum ad5686_supported_device_ids {
ID_AD5675R,
ID_AD5676,
ID_AD5676R,
ID_AD5681R,
ID_AD5682R,
ID_AD5683,
ID_AD5683R,
ID_AD5684,
ID_AD5684R,
ID_AD5685R,
Expand All @@ -57,8 +63,9 @@ enum ad5686_supported_device_ids {
};

enum ad5686_regmap_type {
AD5683_REGMAP,
AD5686_REGMAP,
AD5693_REGMAP
AD5693_REGMAP,
};

struct ad5686_state;
Expand Down