Skip to content

Commit

Permalink
staging:iio: Differential channel handling - use explicit flag rather…
Browse files Browse the repository at this point in the history
… than types.

Straight forward change in the core, but required some drivers to not use
the IIO_CHAN macro as that doesn't allow setting this bit (and is
going away anyway). Hence the churn.

Tested on max1363 with a couple of supported parts.

V2: differential bit in code got 7 bits and direction 1. Reversed that.
Issue spotted by Michael - thanks!

Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk>
Acked-by: Michael Hennerich <Michael.Hennerich@analog.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
  • Loading branch information
Jonathan Cameron authored and Greg Kroah-Hartman committed Sep 6, 2011
1 parent 8ce7375 commit ade7ef7
Show file tree
Hide file tree
Showing 7 changed files with 323 additions and 244 deletions.
8 changes: 4 additions & 4 deletions drivers/staging/iio/adc/ad7192.c
Original file line number Diff line number Diff line change
Expand Up @@ -886,8 +886,7 @@ static int ad7192_read_raw(struct iio_dev *indio_dev,
((1 << (chan->scan_type.realbits)) - 1);

switch (chan->type) {
case IIO_IN:
case IIO_IN_DIFF:
case IIO_VOLTAGE:
if (!unipolar)
*val -= (1 << (chan->scan_type.realbits - 1));
break;
Expand Down Expand Up @@ -986,7 +985,8 @@ static const struct iio_info ad7192_info = {
};

#define AD7192_CHAN_DIFF(_chan, _chan2, _name, _address, _si) \
{ .type = IIO_IN_DIFF, \
{ .type = IIO_VOLTAGE, \
.differential = 1, \
.indexed = 1, \
.extend_name = _name, \
.channel = _chan, \
Expand All @@ -997,7 +997,7 @@ static const struct iio_info ad7192_info = {
.scan_type = IIO_ST('s', 24, 32, 0)}

#define AD7192_CHAN(_chan, _address, _si) \
{ .type = IIO_IN, \
{ .type = IIO_VOLTAGE, \
.indexed = 1, \
.channel = _chan, \
.info_mask = (1 << IIO_CHAN_INFO_SCALE_SHARED), \
Expand Down
26 changes: 16 additions & 10 deletions drivers/staging/iio/adc/ad7280a.c
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,8 @@ static int ad7280_channel_init(struct ad7280_state *st)
for (ch = AD7280A_CELL_VOLTAGE_1; ch <= AD7280A_AUX_ADC_6; ch++,
cnt++) {
if (ch < AD7280A_AUX_ADC_1) {
st->channels[cnt].type = IIO_IN_DIFF;
st->channels[cnt].type = IIO_VOLTAGE;
st->channels[cnt].differential = 1;
st->channels[cnt].channel = (dev * 6) + ch;
st->channels[cnt].channel2 =
st->channels[cnt].channel + 1;
Expand All @@ -515,7 +516,8 @@ static int ad7280_channel_init(struct ad7280_state *st)
st->channels[cnt].scan_type.shift = 0;
}

st->channels[cnt].type = IIO_IN_DIFF;
st->channels[cnt].type = IIO_VOLTAGE;
st->channels[cnt].differential = 1;
st->channels[cnt].channel = 0;
st->channels[cnt].channel2 = dev * 6;
st->channels[cnt].address = AD7280A_ALL_CELLS;
Expand Down Expand Up @@ -692,18 +694,22 @@ static irqreturn_t ad7280_event_handler(int irq, void *private)
if (((channels[i] >> 11) & 0xFFF) >=
st->cell_threshhigh)
iio_push_event(dev_info,
IIO_UNMOD_EVENT_CODE(IIO_IN_DIFF,
0,
IIO_EV_TYPE_THRESH,
IIO_EV_DIR_RISING),
IIO_EVENT_CODE(IIO_VOLTAGE,
1,
0,
IIO_EV_DIR_RISING,
IIO_EV_TYPE_THRESH,
0, 0, 0),
iio_get_time_ns());
else if (((channels[i] >> 11) & 0xFFF) <=
st->cell_threshlow)
iio_push_event(dev_info,
IIO_UNMOD_EVENT_CODE(IIO_IN_DIFF,
0,
IIO_EV_TYPE_THRESH,
IIO_EV_DIR_FALLING),
IIO_EVENT_CODE(IIO_VOLTAGE,
1,
0,
IIO_EV_DIR_FALLING,
IIO_EV_TYPE_THRESH,
0, 0, 0),
iio_get_time_ns());
} else {
if (((channels[i] >> 11) & 0xFFF) >= st->aux_threshhigh)
Expand Down
176 changes: 128 additions & 48 deletions drivers/staging/iio/adc/ad7793.c
Original file line number Diff line number Diff line change
Expand Up @@ -767,57 +767,137 @@ static const struct iio_info ad7793_info = {

static const struct ad7793_chip_info ad7793_chip_info_tbl[] = {
[ID_AD7793] = {
.channel[0] = IIO_CHAN(IIO_IN_DIFF, 0, 1, 0, NULL, 0, 0,
(1 << IIO_CHAN_INFO_SCALE_SHARED),
AD7793_CH_AIN1P_AIN1M,
0, IIO_ST('s', 24, 32, 0), 0),
.channel[1] = IIO_CHAN(IIO_IN_DIFF, 0, 1, 0, NULL, 1, 1,
(1 << IIO_CHAN_INFO_SCALE_SHARED),
AD7793_CH_AIN2P_AIN2M,
1, IIO_ST('s', 24, 32, 0), 0),
.channel[2] = IIO_CHAN(IIO_IN_DIFF, 0, 1, 0, NULL, 2, 2,
(1 << IIO_CHAN_INFO_SCALE_SHARED),
AD7793_CH_AIN3P_AIN3M,
2, IIO_ST('s', 24, 32, 0), 0),
.channel[3] = IIO_CHAN(IIO_IN_DIFF, 0, 1, 0, "shorted", 0, 0,
(1 << IIO_CHAN_INFO_SCALE_SHARED),
AD7793_CH_AIN1M_AIN1M,
3, IIO_ST('s', 24, 32, 0), 0),
.channel[4] = IIO_CHAN(IIO_TEMP, 0, 1, 0, NULL, 0, 0,
(1 << IIO_CHAN_INFO_SCALE_SEPARATE),
AD7793_CH_TEMP,
4, IIO_ST('s', 24, 32, 0), 0),
.channel[5] = IIO_CHAN(IIO_IN, 0, 1, 0, "supply", 4, 0,
(1 << IIO_CHAN_INFO_SCALE_SEPARATE),
AD7793_CH_AVDD_MONITOR,
5, IIO_ST('s', 24, 32, 0), 0),
.channel[0] = {
.type = IIO_VOLTAGE,
.differential = 1,
.indexed = 1,
.channel = 0,
.channel2 = 0,
.address = AD7793_CH_AIN1P_AIN1M,
.info_mask = (1 << IIO_CHAN_INFO_SCALE_SHARED),
.scan_index = 0,
.scan_type = IIO_ST('s', 24, 32, 0)
},
.channel[1] = {
.type = IIO_VOLTAGE,
.differential = 1,
.indexed = 1,
.channel = 1,
.channel2 = 1,
.address = AD7793_CH_AIN2P_AIN2M,
.info_mask = (1 << IIO_CHAN_INFO_SCALE_SHARED),
.scan_index = 1,
.scan_type = IIO_ST('s', 24, 32, 0)
},
.channel[2] = {
.type = IIO_VOLTAGE,
.differential = 1,
.indexed = 1,
.channel = 2,
.channel2 = 2,
.address = AD7793_CH_AIN3P_AIN3M,
.info_mask = (1 << IIO_CHAN_INFO_SCALE_SHARED),
.scan_index = 2,
.scan_type = IIO_ST('s', 24, 32, 0)
},
.channel[3] = {
.type = IIO_VOLTAGE,
.differential = 1,
.extend_name = "shorted",
.indexed = 1,
.channel = 2,
.channel2 = 2,
.address = AD7793_CH_AIN1M_AIN1M,
.info_mask = (1 << IIO_CHAN_INFO_SCALE_SHARED),
.scan_index = 2,
.scan_type = IIO_ST('s', 24, 32, 0)
},
.channel[4] = {
.type = IIO_TEMP,
.indexed = 1,
.channel = 0,
.address = AD7793_CH_TEMP,
.info_mask = (1 << IIO_CHAN_INFO_SCALE_SEPARATE),
.scan_index = 4,
.scan_type = IIO_ST('s', 24, 32, 0),
},
.channel[5] = {
.type = IIO_VOLTAGE,
.extend_name = "supply",
.indexed = 1,
.channel = 4,
.address = AD7793_CH_AVDD_MONITOR,
.info_mask = (1 << IIO_CHAN_INFO_SCALE_SEPARATE),
.scan_index = 5,
.scan_type = IIO_ST('s', 24, 32, 0),
},
.channel[6] = IIO_CHAN_SOFT_TIMESTAMP(6),
},
[ID_AD7792] = {
.channel[0] = IIO_CHAN(IIO_IN_DIFF, 0, 1, 0, NULL, 0, 0,
(1 << IIO_CHAN_INFO_SCALE_SHARED),
AD7793_CH_AIN1P_AIN1M,
0, IIO_ST('s', 16, 32, 0), 0),
.channel[1] = IIO_CHAN(IIO_IN_DIFF, 0, 1, 0, NULL, 1, 1,
(1 << IIO_CHAN_INFO_SCALE_SHARED),
AD7793_CH_AIN2P_AIN2M,
1, IIO_ST('s', 16, 32, 0), 0),
.channel[2] = IIO_CHAN(IIO_IN_DIFF, 0, 1, 0, NULL, 2, 2,
(1 << IIO_CHAN_INFO_SCALE_SHARED),
AD7793_CH_AIN3P_AIN3M,
2, IIO_ST('s', 16, 32, 0), 0),
.channel[3] = IIO_CHAN(IIO_IN_DIFF, 0, 1, 0, "shorted", 0, 0,
(1 << IIO_CHAN_INFO_SCALE_SHARED),
AD7793_CH_AIN1M_AIN1M,
3, IIO_ST('s', 16, 32, 0), 0),
.channel[4] = IIO_CHAN(IIO_TEMP, 0, 1, 0, NULL, 0, 0,
(1 << IIO_CHAN_INFO_SCALE_SEPARATE),
AD7793_CH_TEMP,
4, IIO_ST('s', 16, 32, 0), 0),
.channel[5] = IIO_CHAN(IIO_IN, 0, 1, 0, "supply", 4, 0,
(1 << IIO_CHAN_INFO_SCALE_SEPARATE),
AD7793_CH_AVDD_MONITOR,
5, IIO_ST('s', 16, 32, 0), 0),
.channel[0] = {
.type = IIO_VOLTAGE,
.differential = 1,
.indexed = 1,
.channel = 0,
.channel2 = 0,
.address = AD7793_CH_AIN1P_AIN1M,
.info_mask = (1 << IIO_CHAN_INFO_SCALE_SHARED),
.scan_index = 0,
.scan_type = IIO_ST('s', 16, 32, 0)
},
.channel[1] = {
.type = IIO_VOLTAGE,
.differential = 1,
.indexed = 1,
.channel = 1,
.channel2 = 1,
.address = AD7793_CH_AIN2P_AIN2M,
.info_mask = (1 << IIO_CHAN_INFO_SCALE_SHARED),
.scan_index = 1,
.scan_type = IIO_ST('s', 16, 32, 0)
},
.channel[2] = {
.type = IIO_VOLTAGE,
.differential = 1,
.indexed = 1,
.channel = 2,
.channel2 = 2,
.address = AD7793_CH_AIN3P_AIN3M,
.info_mask = (1 << IIO_CHAN_INFO_SCALE_SHARED),
.scan_index = 2,
.scan_type = IIO_ST('s', 16, 32, 0)
},
.channel[3] = {
.type = IIO_VOLTAGE,
.differential = 1,
.extend_name = "shorted",
.indexed = 1,
.channel = 2,
.channel2 = 2,
.address = AD7793_CH_AIN1M_AIN1M,
.info_mask = (1 << IIO_CHAN_INFO_SCALE_SHARED),
.scan_index = 2,
.scan_type = IIO_ST('s', 16, 32, 0)
},
.channel[4] = {
.type = IIO_TEMP,
.indexed = 1,
.channel = 0,
.address = AD7793_CH_TEMP,
.info_mask = (1 << IIO_CHAN_INFO_SCALE_SEPARATE),
.scan_index = 4,
.scan_type = IIO_ST('s', 16, 32, 0),
},
.channel[5] = {
.type = IIO_VOLTAGE,
.extend_name = "supply",
.indexed = 1,
.channel = 4,
.address = AD7793_CH_AVDD_MONITOR,
.info_mask = (1 << IIO_CHAN_INFO_SCALE_SEPARATE),
.scan_index = 5,
.scan_type = IIO_ST('s', 16, 32, 0),
},
.channel[6] = IIO_CHAN_SOFT_TIMESTAMP(6),
},
};
Expand Down
Loading

0 comments on commit ade7ef7

Please sign in to comment.