forked from luck/tmp_suning_uos_patched
iio: adc: ad7791: define/use own IIO channel macros
This driver seems to use most of the AD_SD_*_CHANNEL. This change will move them in the driver. The intent is that if a new part comes along which would require tweaks per IIO channel, these should be doable in the driver. Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
This commit is contained in:
parent
5924dab241
commit
ab3449943b
|
@ -64,25 +64,73 @@
|
|||
#define AD7791_MODE_SEL_MASK (0x3 << 6)
|
||||
#define AD7791_MODE_SEL(x) ((x) << 6)
|
||||
|
||||
#define __AD7991_CHANNEL(_si, _channel1, _channel2, _address, _bits, \
|
||||
_storagebits, _shift, _extend_name, _type, _mask_all) \
|
||||
{ \
|
||||
.type = (_type), \
|
||||
.differential = (_channel2 == -1 ? 0 : 1), \
|
||||
.indexed = 1, \
|
||||
.channel = (_channel1), \
|
||||
.channel2 = (_channel2), \
|
||||
.address = (_address), \
|
||||
.extend_name = (_extend_name), \
|
||||
.info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | \
|
||||
BIT(IIO_CHAN_INFO_OFFSET), \
|
||||
.info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), \
|
||||
.info_mask_shared_by_all = _mask_all, \
|
||||
.scan_index = (_si), \
|
||||
.scan_type = { \
|
||||
.sign = 'u', \
|
||||
.realbits = (_bits), \
|
||||
.storagebits = (_storagebits), \
|
||||
.shift = (_shift), \
|
||||
.endianness = IIO_BE, \
|
||||
}, \
|
||||
}
|
||||
|
||||
#define AD7991_SHORTED_CHANNEL(_si, _channel, _address, _bits, \
|
||||
_storagebits, _shift) \
|
||||
__AD7991_CHANNEL(_si, _channel, _channel, _address, _bits, \
|
||||
_storagebits, _shift, "shorted", IIO_VOLTAGE, \
|
||||
BIT(IIO_CHAN_INFO_SAMP_FREQ))
|
||||
|
||||
#define AD7991_CHANNEL(_si, _channel, _address, _bits, \
|
||||
_storagebits, _shift) \
|
||||
__AD7991_CHANNEL(_si, _channel, -1, _address, _bits, \
|
||||
_storagebits, _shift, NULL, IIO_VOLTAGE, \
|
||||
BIT(IIO_CHAN_INFO_SAMP_FREQ))
|
||||
|
||||
#define AD7991_DIFF_CHANNEL(_si, _channel1, _channel2, _address, _bits, \
|
||||
_storagebits, _shift) \
|
||||
__AD7991_CHANNEL(_si, _channel1, _channel2, _address, _bits, \
|
||||
_storagebits, _shift, NULL, IIO_VOLTAGE, \
|
||||
BIT(IIO_CHAN_INFO_SAMP_FREQ))
|
||||
|
||||
#define AD7991_SUPPLY_CHANNEL(_si, _channel, _address, _bits, _storagebits, \
|
||||
_shift) \
|
||||
__AD7991_CHANNEL(_si, _channel, -1, _address, _bits, \
|
||||
_storagebits, _shift, "supply", IIO_VOLTAGE, \
|
||||
BIT(IIO_CHAN_INFO_SAMP_FREQ))
|
||||
|
||||
#define DECLARE_AD7787_CHANNELS(name, bits, storagebits) \
|
||||
const struct iio_chan_spec name[] = { \
|
||||
AD_SD_DIFF_CHANNEL(0, 0, 0, AD7791_CH_AIN1P_AIN1N, \
|
||||
AD7991_DIFF_CHANNEL(0, 0, 0, AD7791_CH_AIN1P_AIN1N, \
|
||||
(bits), (storagebits), 0), \
|
||||
AD_SD_CHANNEL(1, 1, AD7791_CH_AIN2, (bits), (storagebits), 0), \
|
||||
AD_SD_SHORTED_CHANNEL(2, 0, AD7791_CH_AIN1N_AIN1N, \
|
||||
AD7991_CHANNEL(1, 1, AD7791_CH_AIN2, (bits), (storagebits), 0), \
|
||||
AD7991_SHORTED_CHANNEL(2, 0, AD7791_CH_AIN1N_AIN1N, \
|
||||
(bits), (storagebits), 0), \
|
||||
AD_SD_SUPPLY_CHANNEL(3, 2, AD7791_CH_AVDD_MONITOR, \
|
||||
AD7991_SUPPLY_CHANNEL(3, 2, AD7791_CH_AVDD_MONITOR, \
|
||||
(bits), (storagebits), 0), \
|
||||
IIO_CHAN_SOFT_TIMESTAMP(4), \
|
||||
}
|
||||
|
||||
#define DECLARE_AD7791_CHANNELS(name, bits, storagebits) \
|
||||
const struct iio_chan_spec name[] = { \
|
||||
AD_SD_DIFF_CHANNEL(0, 0, 0, AD7791_CH_AIN1P_AIN1N, \
|
||||
AD7991_DIFF_CHANNEL(0, 0, 0, AD7791_CH_AIN1P_AIN1N, \
|
||||
(bits), (storagebits), 0), \
|
||||
AD_SD_SHORTED_CHANNEL(1, 0, AD7791_CH_AIN1N_AIN1N, \
|
||||
AD7991_SHORTED_CHANNEL(1, 0, AD7791_CH_AIN1N_AIN1N, \
|
||||
(bits), (storagebits), 0), \
|
||||
AD_SD_SUPPLY_CHANNEL(2, 1, AD7791_CH_AVDD_MONITOR, \
|
||||
AD7991_SUPPLY_CHANNEL(2, 1, AD7791_CH_AVDD_MONITOR, \
|
||||
(bits), (storagebits), 0), \
|
||||
IIO_CHAN_SOFT_TIMESTAMP(3), \
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user