Commit d4d7e297 authored by Julien Stephan's avatar Julien Stephan Committed by Jonathan Cameron

iio: adc: ad7380: prepare driver for single-ended parts support

ad738x family contains single-ended parts that have a 2:1 mux in front
of ADC, so the number of IIO channels is different from the number of
simultaneous channels that can be sampled.

To prepare the support for single-ended parts, introduce a new
num_simultaneous_channels variable. For currently supported parts,
num_simultaneous_channels is equal to num_channels minus 1 (the
timestamps channel)
Signed-off-by: default avatarJulien Stephan <jstephan@baylibre.com>
Reviewed-by: default avatarDavid Lechner <dlechner@baylibre.com>
Link: https://patch.msgid.link/20240731-ad7380-add-single-ended-chips-v2-4-cd63bf05744c@baylibre.comSigned-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
parent 65c89a5a
...@@ -80,6 +80,7 @@ struct ad7380_chip_info { ...@@ -80,6 +80,7 @@ struct ad7380_chip_info {
const char *name; const char *name;
const struct iio_chan_spec *channels; const struct iio_chan_spec *channels;
unsigned int num_channels; unsigned int num_channels;
unsigned int num_simult_channels;
const char * const *vcm_supplies; const char * const *vcm_supplies;
unsigned int num_vcm_supplies; unsigned int num_vcm_supplies;
const unsigned long *available_scan_masks; const unsigned long *available_scan_masks;
...@@ -208,6 +209,7 @@ static const struct ad7380_chip_info ad7380_chip_info = { ...@@ -208,6 +209,7 @@ static const struct ad7380_chip_info ad7380_chip_info = {
.name = "ad7380", .name = "ad7380",
.channels = ad7380_channels, .channels = ad7380_channels,
.num_channels = ARRAY_SIZE(ad7380_channels), .num_channels = ARRAY_SIZE(ad7380_channels),
.num_simult_channels = 2,
.available_scan_masks = ad7380_2_channel_scan_masks, .available_scan_masks = ad7380_2_channel_scan_masks,
.timing_specs = &ad7380_timing, .timing_specs = &ad7380_timing,
}; };
...@@ -216,6 +218,7 @@ static const struct ad7380_chip_info ad7381_chip_info = { ...@@ -216,6 +218,7 @@ static const struct ad7380_chip_info ad7381_chip_info = {
.name = "ad7381", .name = "ad7381",
.channels = ad7381_channels, .channels = ad7381_channels,
.num_channels = ARRAY_SIZE(ad7381_channels), .num_channels = ARRAY_SIZE(ad7381_channels),
.num_simult_channels = 2,
.available_scan_masks = ad7380_2_channel_scan_masks, .available_scan_masks = ad7380_2_channel_scan_masks,
.timing_specs = &ad7380_timing, .timing_specs = &ad7380_timing,
}; };
...@@ -224,6 +227,7 @@ static const struct ad7380_chip_info ad7383_chip_info = { ...@@ -224,6 +227,7 @@ static const struct ad7380_chip_info ad7383_chip_info = {
.name = "ad7383", .name = "ad7383",
.channels = ad7383_channels, .channels = ad7383_channels,
.num_channels = ARRAY_SIZE(ad7383_channels), .num_channels = ARRAY_SIZE(ad7383_channels),
.num_simult_channels = 2,
.vcm_supplies = ad7380_2_channel_vcm_supplies, .vcm_supplies = ad7380_2_channel_vcm_supplies,
.num_vcm_supplies = ARRAY_SIZE(ad7380_2_channel_vcm_supplies), .num_vcm_supplies = ARRAY_SIZE(ad7380_2_channel_vcm_supplies),
.available_scan_masks = ad7380_2_channel_scan_masks, .available_scan_masks = ad7380_2_channel_scan_masks,
...@@ -234,6 +238,7 @@ static const struct ad7380_chip_info ad7384_chip_info = { ...@@ -234,6 +238,7 @@ static const struct ad7380_chip_info ad7384_chip_info = {
.name = "ad7384", .name = "ad7384",
.channels = ad7384_channels, .channels = ad7384_channels,
.num_channels = ARRAY_SIZE(ad7384_channels), .num_channels = ARRAY_SIZE(ad7384_channels),
.num_simult_channels = 2,
.vcm_supplies = ad7380_2_channel_vcm_supplies, .vcm_supplies = ad7380_2_channel_vcm_supplies,
.num_vcm_supplies = ARRAY_SIZE(ad7380_2_channel_vcm_supplies), .num_vcm_supplies = ARRAY_SIZE(ad7380_2_channel_vcm_supplies),
.available_scan_masks = ad7380_2_channel_scan_masks, .available_scan_masks = ad7380_2_channel_scan_masks,
...@@ -244,6 +249,7 @@ static const struct ad7380_chip_info ad7380_4_chip_info = { ...@@ -244,6 +249,7 @@ static const struct ad7380_chip_info ad7380_4_chip_info = {
.name = "ad7380-4", .name = "ad7380-4",
.channels = ad7380_4_channels, .channels = ad7380_4_channels,
.num_channels = ARRAY_SIZE(ad7380_4_channels), .num_channels = ARRAY_SIZE(ad7380_4_channels),
.num_simult_channels = 4,
.available_scan_masks = ad7380_4_channel_scan_masks, .available_scan_masks = ad7380_4_channel_scan_masks,
.timing_specs = &ad7380_4_timing, .timing_specs = &ad7380_4_timing,
}; };
...@@ -252,6 +258,7 @@ static const struct ad7380_chip_info ad7381_4_chip_info = { ...@@ -252,6 +258,7 @@ static const struct ad7380_chip_info ad7381_4_chip_info = {
.name = "ad7381-4", .name = "ad7381-4",
.channels = ad7381_4_channels, .channels = ad7381_4_channels,
.num_channels = ARRAY_SIZE(ad7381_4_channels), .num_channels = ARRAY_SIZE(ad7381_4_channels),
.num_simult_channels = 4,
.available_scan_masks = ad7380_4_channel_scan_masks, .available_scan_masks = ad7380_4_channel_scan_masks,
.timing_specs = &ad7380_4_timing, .timing_specs = &ad7380_4_timing,
}; };
...@@ -260,6 +267,7 @@ static const struct ad7380_chip_info ad7383_4_chip_info = { ...@@ -260,6 +267,7 @@ static const struct ad7380_chip_info ad7383_4_chip_info = {
.name = "ad7383-4", .name = "ad7383-4",
.channels = ad7383_4_channels, .channels = ad7383_4_channels,
.num_channels = ARRAY_SIZE(ad7383_4_channels), .num_channels = ARRAY_SIZE(ad7383_4_channels),
.num_simult_channels = 4,
.vcm_supplies = ad7380_4_channel_vcm_supplies, .vcm_supplies = ad7380_4_channel_vcm_supplies,
.num_vcm_supplies = ARRAY_SIZE(ad7380_4_channel_vcm_supplies), .num_vcm_supplies = ARRAY_SIZE(ad7380_4_channel_vcm_supplies),
.available_scan_masks = ad7380_4_channel_scan_masks, .available_scan_masks = ad7380_4_channel_scan_masks,
...@@ -270,6 +278,7 @@ static const struct ad7380_chip_info ad7384_4_chip_info = { ...@@ -270,6 +278,7 @@ static const struct ad7380_chip_info ad7384_4_chip_info = {
.name = "ad7384-4", .name = "ad7384-4",
.channels = ad7384_4_channels, .channels = ad7384_4_channels,
.num_channels = ARRAY_SIZE(ad7384_4_channels), .num_channels = ARRAY_SIZE(ad7384_4_channels),
.num_simult_channels = 4,
.vcm_supplies = ad7380_4_channel_vcm_supplies, .vcm_supplies = ad7380_4_channel_vcm_supplies,
.num_vcm_supplies = ARRAY_SIZE(ad7380_4_channel_vcm_supplies), .num_vcm_supplies = ARRAY_SIZE(ad7380_4_channel_vcm_supplies),
.available_scan_masks = ad7380_4_channel_scan_masks, .available_scan_masks = ad7380_4_channel_scan_masks,
...@@ -407,7 +416,7 @@ static void ad7380_update_xfers(struct ad7380_state *st, ...@@ -407,7 +416,7 @@ static void ad7380_update_xfers(struct ad7380_state *st,
*/ */
st->xfer[1].bits_per_word = scan_type->realbits; st->xfer[1].bits_per_word = scan_type->realbits;
st->xfer[1].len = BITS_TO_BYTES(scan_type->storagebits) * st->xfer[1].len = BITS_TO_BYTES(scan_type->storagebits) *
(st->chip_info->num_channels - 1); st->chip_info->num_simult_channels;
} }
static int ad7380_triggered_buffer_preenable(struct iio_dev *indio_dev) static int ad7380_triggered_buffer_preenable(struct iio_dev *indio_dev)
......
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