Commit 6a954b96 authored by Marek Vasut's avatar Marek Vasut Committed by Jonathan Cameron

iio: adc: ti-ads1015: Make channel event_spec optional

Pass event_spec and num_event_specs to ADS1015_V_CHAN and ADS1015_V_DIFF_CHAN
macros, to make it possible to pass no event_spec at all for chips which have
no comparator and thus no events. No functional change.
Signed-off-by: default avatarMarek Vasut <marex@denx.de>
Reviewed-by: default avatarAndy Shevchenko <andy@kernel.org>
Cc: Daniel Baluta <daniel.baluta@nxp.com>
Link: https://lore.kernel.org/r/20220328194725.149150-5-marex@denx.deSigned-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
parent fba6ca2a
...@@ -134,7 +134,7 @@ static const struct iio_event_spec ads1015_events[] = { ...@@ -134,7 +134,7 @@ static const struct iio_event_spec ads1015_events[] = {
}, },
}; };
#define ADS1015_V_CHAN(_chan, _addr, _realbits, _shift) { \ #define ADS1015_V_CHAN(_chan, _addr, _realbits, _shift, _event_spec, _num_event_specs) { \
.type = IIO_VOLTAGE, \ .type = IIO_VOLTAGE, \
.indexed = 1, \ .indexed = 1, \
.address = _addr, \ .address = _addr, \
...@@ -150,12 +150,12 @@ static const struct iio_event_spec ads1015_events[] = { ...@@ -150,12 +150,12 @@ static const struct iio_event_spec ads1015_events[] = {
.shift = (_shift), \ .shift = (_shift), \
.endianness = IIO_CPU, \ .endianness = IIO_CPU, \
}, \ }, \
.event_spec = ads1015_events, \ .event_spec = (_event_spec), \
.num_event_specs = ARRAY_SIZE(ads1015_events), \ .num_event_specs = (_num_event_specs), \
.datasheet_name = "AIN"#_chan, \ .datasheet_name = "AIN"#_chan, \
} }
#define ADS1015_V_DIFF_CHAN(_chan, _chan2, _addr, _realbits, _shift) { \ #define ADS1015_V_DIFF_CHAN(_chan, _chan2, _addr, _realbits, _shift, _event_spec, _num_event_specs) { \
.type = IIO_VOLTAGE, \ .type = IIO_VOLTAGE, \
.differential = 1, \ .differential = 1, \
.indexed = 1, \ .indexed = 1, \
...@@ -173,8 +173,8 @@ static const struct iio_event_spec ads1015_events[] = { ...@@ -173,8 +173,8 @@ static const struct iio_event_spec ads1015_events[] = {
.shift = (_shift), \ .shift = (_shift), \
.endianness = IIO_CPU, \ .endianness = IIO_CPU, \
}, \ }, \
.event_spec = ads1015_events, \ .event_spec = (_event_spec), \
.num_event_specs = ARRAY_SIZE(ads1015_events), \ .num_event_specs = (_num_event_specs), \
.datasheet_name = "AIN"#_chan"-AIN"#_chan2, \ .datasheet_name = "AIN"#_chan"-AIN"#_chan2, \
} }
...@@ -248,26 +248,42 @@ static const struct regmap_config ads1015_regmap_config = { ...@@ -248,26 +248,42 @@ static const struct regmap_config ads1015_regmap_config = {
}; };
static const struct iio_chan_spec ads1015_channels[] = { static const struct iio_chan_spec ads1015_channels[] = {
ADS1015_V_DIFF_CHAN(0, 1, ADS1015_AIN0_AIN1, 12, 4), ADS1015_V_DIFF_CHAN(0, 1, ADS1015_AIN0_AIN1, 12, 4,
ADS1015_V_DIFF_CHAN(0, 3, ADS1015_AIN0_AIN3, 12, 4), ads1015_events, ARRAY_SIZE(ads1015_events)),
ADS1015_V_DIFF_CHAN(1, 3, ADS1015_AIN1_AIN3, 12, 4), ADS1015_V_DIFF_CHAN(0, 3, ADS1015_AIN0_AIN3, 12, 4,
ADS1015_V_DIFF_CHAN(2, 3, ADS1015_AIN2_AIN3, 12, 4), ads1015_events, ARRAY_SIZE(ads1015_events)),
ADS1015_V_CHAN(0, ADS1015_AIN0, 12, 4), ADS1015_V_DIFF_CHAN(1, 3, ADS1015_AIN1_AIN3, 12, 4,
ADS1015_V_CHAN(1, ADS1015_AIN1, 12, 4), ads1015_events, ARRAY_SIZE(ads1015_events)),
ADS1015_V_CHAN(2, ADS1015_AIN2, 12, 4), ADS1015_V_DIFF_CHAN(2, 3, ADS1015_AIN2_AIN3, 12, 4,
ADS1015_V_CHAN(3, ADS1015_AIN3, 12, 4), ads1015_events, ARRAY_SIZE(ads1015_events)),
ADS1015_V_CHAN(0, ADS1015_AIN0, 12, 4,
ads1015_events, ARRAY_SIZE(ads1015_events)),
ADS1015_V_CHAN(1, ADS1015_AIN1, 12, 4,
ads1015_events, ARRAY_SIZE(ads1015_events)),
ADS1015_V_CHAN(2, ADS1015_AIN2, 12, 4,
ads1015_events, ARRAY_SIZE(ads1015_events)),
ADS1015_V_CHAN(3, ADS1015_AIN3, 12, 4,
ads1015_events, ARRAY_SIZE(ads1015_events)),
IIO_CHAN_SOFT_TIMESTAMP(ADS1015_TIMESTAMP), IIO_CHAN_SOFT_TIMESTAMP(ADS1015_TIMESTAMP),
}; };
static const struct iio_chan_spec ads1115_channels[] = { static const struct iio_chan_spec ads1115_channels[] = {
ADS1015_V_DIFF_CHAN(0, 1, ADS1015_AIN0_AIN1, 16, 0), ADS1015_V_DIFF_CHAN(0, 1, ADS1015_AIN0_AIN1, 16, 0,
ADS1015_V_DIFF_CHAN(0, 3, ADS1015_AIN0_AIN3, 16, 0), ads1015_events, ARRAY_SIZE(ads1015_events)),
ADS1015_V_DIFF_CHAN(1, 3, ADS1015_AIN1_AIN3, 16, 0), ADS1015_V_DIFF_CHAN(0, 3, ADS1015_AIN0_AIN3, 16, 0,
ADS1015_V_DIFF_CHAN(2, 3, ADS1015_AIN2_AIN3, 16, 0), ads1015_events, ARRAY_SIZE(ads1015_events)),
ADS1015_V_CHAN(0, ADS1015_AIN0, 16, 0), ADS1015_V_DIFF_CHAN(1, 3, ADS1015_AIN1_AIN3, 16, 0,
ADS1015_V_CHAN(1, ADS1015_AIN1, 16, 0), ads1015_events, ARRAY_SIZE(ads1015_events)),
ADS1015_V_CHAN(2, ADS1015_AIN2, 16, 0), ADS1015_V_DIFF_CHAN(2, 3, ADS1015_AIN2_AIN3, 16, 0,
ADS1015_V_CHAN(3, ADS1015_AIN3, 16, 0), ads1015_events, ARRAY_SIZE(ads1015_events)),
ADS1015_V_CHAN(0, ADS1015_AIN0, 16, 0,
ads1015_events, ARRAY_SIZE(ads1015_events)),
ADS1015_V_CHAN(1, ADS1015_AIN1, 16, 0,
ads1015_events, ARRAY_SIZE(ads1015_events)),
ADS1015_V_CHAN(2, ADS1015_AIN2, 16, 0,
ads1015_events, ARRAY_SIZE(ads1015_events)),
ADS1015_V_CHAN(3, ADS1015_AIN3, 16, 0,
ads1015_events, ARRAY_SIZE(ads1015_events)),
IIO_CHAN_SOFT_TIMESTAMP(ADS1015_TIMESTAMP), IIO_CHAN_SOFT_TIMESTAMP(ADS1015_TIMESTAMP),
}; };
......
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