ID_AD5685,
ID_AD5686,
};
-
+#define AD5868_CHANNEL(chan, bits, shift) { \
+ .type = IIO_VOLTAGE, \
+ .indexed = 1, \
+ .output = 1, \
+ .channel = chan, \
+ .info_mask = (1 << IIO_CHAN_INFO_SCALE_SHARED), \
+ .address = AD5686_ADDR_DAC0, \
+ .scan_type = IIO_ST('u', bits, 16, shift) \
+}
static const struct ad5686_chip_info ad5686_chip_info_tbl[] = {
[ID_AD5684] = {
- .channel[0] = IIO_CHAN(IIO_OUT, 0, 1, 0, NULL, 0, 0,
- (1 << IIO_CHAN_INFO_SCALE_SHARED),
- AD5686_ADDR_DAC0,
- 0, IIO_ST('u', 12, 16, 4), 0),
- .channel[1] = IIO_CHAN(IIO_OUT, 0, 1, 0, NULL, 1, 0,
- (1 << IIO_CHAN_INFO_SCALE_SHARED),
- AD5686_ADDR_DAC1,
- 1, IIO_ST('u', 12, 16, 4), 0),
- .channel[2] = IIO_CHAN(IIO_OUT, 0, 1, 0, NULL, 2, 0,
- (1 << IIO_CHAN_INFO_SCALE_SHARED),
- AD5686_ADDR_DAC2,
- 2, IIO_ST('u', 12, 16, 4), 0),
- .channel[3] = IIO_CHAN(IIO_OUT, 0, 1, 0, NULL, 3, 0,
- (1 << IIO_CHAN_INFO_SCALE_SHARED),
- AD5686_ADDR_DAC3,
- 3, IIO_ST('u', 12, 16, 4), 0),
+ .channel[0] = AD5868_CHANNEL(0, 12, 4),
+ .channel[1] = AD5868_CHANNEL(1, 12, 4),
+ .channel[2] = AD5868_CHANNEL(2, 12, 4),
+ .channel[3] = AD5868_CHANNEL(3, 12, 4),
.int_vref_mv = 2500,
},
[ID_AD5685] = {
- .channel[0] = IIO_CHAN(IIO_OUT, 0, 1, 0, NULL, 0, 0,
- (1 << IIO_CHAN_INFO_SCALE_SHARED),
- AD5686_ADDR_DAC0,
- 0, IIO_ST('u', 14, 16, 2), 0),
- .channel[1] = IIO_CHAN(IIO_OUT, 0, 1, 0, NULL, 1, 0,
- (1 << IIO_CHAN_INFO_SCALE_SHARED),
- AD5686_ADDR_DAC1,
- 1, IIO_ST('u', 14, 16, 2), 0),
- .channel[2] = IIO_CHAN(IIO_OUT, 0, 1, 0, NULL, 2, 0,
- (1 << IIO_CHAN_INFO_SCALE_SHARED),
- AD5686_ADDR_DAC2,
- 2, IIO_ST('u', 14, 16, 2), 0),
- .channel[3] = IIO_CHAN(IIO_OUT, 0, 1, 0, NULL, 3, 0,
- (1 << IIO_CHAN_INFO_SCALE_SHARED),
- AD5686_ADDR_DAC3,
- 3, IIO_ST('u', 14, 16, 2), 0),
+ .channel[0] = AD5868_CHANNEL(0, 14, 2),
+ .channel[1] = AD5868_CHANNEL(1, 14, 2),
+ .channel[2] = AD5868_CHANNEL(2, 14, 2),
+ .channel[3] = AD5868_CHANNEL(3, 14, 2),
.int_vref_mv = 2500,
},
[ID_AD5686] = {
- .channel[0] = IIO_CHAN(IIO_OUT, 0, 1, 0, NULL, 0, 0,
- (1 << IIO_CHAN_INFO_SCALE_SHARED),
- AD5686_ADDR_DAC0,
- 0, IIO_ST('u', 16, 16, 0), 0),
- .channel[1] = IIO_CHAN(IIO_OUT, 0, 1, 0, NULL, 1, 0,
- (1 << IIO_CHAN_INFO_SCALE_SHARED),
- AD5686_ADDR_DAC1,
- 1, IIO_ST('u', 16, 16, 0), 0),
- .channel[2] = IIO_CHAN(IIO_OUT, 0, 1, 0, NULL, 2, 0,
- (1 << IIO_CHAN_INFO_SCALE_SHARED),
- AD5686_ADDR_DAC2,
- 2, IIO_ST('u', 16, 16, 0), 0),
- .channel[3] = IIO_CHAN(IIO_OUT, 0, 1, 0, NULL, 3, 0,
- (1 << IIO_CHAN_INFO_SCALE_SHARED),
- AD5686_ADDR_DAC3,
- 3, IIO_ST('u', 16, 16, 0), 0),
+ .channel[0] = AD5868_CHANNEL(0, 16, 0),
+ .channel[1] = AD5868_CHANNEL(1, 16, 0),
+ .channel[2] = AD5868_CHANNEL(2, 16, 0),
+ .channel[3] = AD5868_CHANNEL(3, 16, 0),
.int_vref_mv = 2500,
},
};
[IIO_PROCESSED] = "input",
};
+static const char * const iio_direction[] = {
+ [0] = "in",
+ [1] = "out",
+};
+
static const char * const iio_chan_type_name_spec_shared[] = {
- [IIO_IN] = "in",
- [IIO_OUT] = "out",
+ [IIO_VOLTAGE] = "voltage",
[IIO_CURRENT] = "current",
[IIO_POWER] = "power",
[IIO_ACCEL] = "accel",
- [IIO_IN_DIFF] = "in-in",
+ [IIO_VOLTAGE_DIFF] = "voltage-voltage",
[IIO_GYRO] = "gyro",
[IIO_MAGN] = "magn",
[IIO_LIGHT] = "illuminance",
};
static const char * const iio_chan_type_name_spec_complex[] = {
- [IIO_IN_DIFF] = "in%d-in%d",
+ [IIO_VOLTAGE_DIFF] = "voltage%d-voltage%d",
};
static const char * const iio_modifier_names_light[] = {
goto error_ret;
/* Special case for types that uses both channel numbers in naming */
- if (chan->type == IIO_IN_DIFF && !generic)
+ if (chan->type == IIO_VOLTAGE_DIFF && !generic)
name_format
- = kasprintf(GFP_KERNEL, "%s_%s",
+ = kasprintf(GFP_KERNEL, "%s_%s_%s",
+ iio_direction[chan->output],
iio_chan_type_name_spec_complex[chan->type],
full_postfix);
else if (generic || !chan->indexed)
name_format
- = kasprintf(GFP_KERNEL, "%s_%s",
+ = kasprintf(GFP_KERNEL, "%s_%s_%s",
+ iio_direction[chan->output],
iio_chan_type_name_spec_shared[chan->type],
full_postfix);
else
name_format
- = kasprintf(GFP_KERNEL, "%s%d_%s",
+ = kasprintf(GFP_KERNEL, "%s_%s%d_%s",
+ iio_direction[chan->output],
iio_chan_type_name_spec_shared[chan->type],
chan->channel,
full_postfix);
ret = __iio_add_chan_devattr(iio_data_type_name[chan->processed_val],
NULL, chan,
&iio_read_channel_info,
- (chan->type == IIO_OUT ?
+ (chan->output ?
&iio_write_channel_info : NULL),
0,
0,
}
switch (chan->type) {
/* Switch this to a table at some point */
- case IIO_IN:
+ case IIO_VOLTAGE:
mask = IIO_UNMOD_EVENT_CODE(chan->type, chan->channel,
i/IIO_EV_TYPE_MAX,
i%IIO_EV_TYPE_MAX);
i/IIO_EV_TYPE_MAX,
i%IIO_EV_TYPE_MAX);
break;
- case IIO_IN_DIFF:
+ case IIO_VOLTAGE_DIFF:
mask = IIO_MOD_EVENT_CODE(chan->type, chan->channel,
chan->channel2,
i/IIO_EV_TYPE_MAX,