iio: adc: ad7476: Add IIO_CHAN_INFO_RAW for AD7091R
When CONVST signal is generated internally, IIO_CHAN_INFO_RAW can be made available for AD7091R for single reads. This patch enables it and makes supporting more devices by this driver easier. Signed-off-by: Dragos Bogdan <dragos.bogdan@analog.com> Signed-off-by: Beniamin Bia <beniamin.bia@analog.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
This commit is contained in:
parent
af37e4703d
commit
3a6af93dd6
@ -29,6 +29,8 @@ struct ad7476_state;
|
|||||||
struct ad7476_chip_info {
|
struct ad7476_chip_info {
|
||||||
unsigned int int_vref_uv;
|
unsigned int int_vref_uv;
|
||||||
struct iio_chan_spec channel[2];
|
struct iio_chan_spec channel[2];
|
||||||
|
/* channels used when convst gpio is defined */
|
||||||
|
struct iio_chan_spec convst_channel[2];
|
||||||
void (*reset)(struct ad7476_state *);
|
void (*reset)(struct ad7476_state *);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -109,6 +111,8 @@ static int ad7476_scan_direct(struct ad7476_state *st)
|
|||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
ad7091_convst(st);
|
||||||
|
|
||||||
ret = spi_sync(st->spi, &st->msg);
|
ret = spi_sync(st->spi, &st->msg);
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
@ -176,6 +180,8 @@ static int ad7476_read_raw(struct iio_dev *indio_dev,
|
|||||||
#define AD7940_CHAN(bits) _AD7476_CHAN((bits), 15 - (bits), \
|
#define AD7940_CHAN(bits) _AD7476_CHAN((bits), 15 - (bits), \
|
||||||
BIT(IIO_CHAN_INFO_RAW))
|
BIT(IIO_CHAN_INFO_RAW))
|
||||||
#define AD7091R_CHAN(bits) _AD7476_CHAN((bits), 16 - (bits), 0)
|
#define AD7091R_CHAN(bits) _AD7476_CHAN((bits), 16 - (bits), 0)
|
||||||
|
#define AD7091R_CONVST_CHAN(bits) _AD7476_CHAN((bits), 16 - (bits), \
|
||||||
|
BIT(IIO_CHAN_INFO_RAW))
|
||||||
#define ADS786X_CHAN(bits) _AD7476_CHAN((bits), 12 - (bits), \
|
#define ADS786X_CHAN(bits) _AD7476_CHAN((bits), 12 - (bits), \
|
||||||
BIT(IIO_CHAN_INFO_RAW))
|
BIT(IIO_CHAN_INFO_RAW))
|
||||||
|
|
||||||
@ -183,6 +189,8 @@ static const struct ad7476_chip_info ad7476_chip_info_tbl[] = {
|
|||||||
[ID_AD7091R] = {
|
[ID_AD7091R] = {
|
||||||
.channel[0] = AD7091R_CHAN(12),
|
.channel[0] = AD7091R_CHAN(12),
|
||||||
.channel[1] = IIO_CHAN_SOFT_TIMESTAMP(1),
|
.channel[1] = IIO_CHAN_SOFT_TIMESTAMP(1),
|
||||||
|
.convst_channel[0] = AD7091R_CONVST_CHAN(12),
|
||||||
|
.convst_channel[1] = IIO_CHAN_SOFT_TIMESTAMP(1),
|
||||||
.reset = ad7091_reset,
|
.reset = ad7091_reset,
|
||||||
},
|
},
|
||||||
[ID_AD7276] = {
|
[ID_AD7276] = {
|
||||||
@ -288,6 +296,9 @@ static int ad7476_probe(struct spi_device *spi)
|
|||||||
indio_dev->channels = st->chip_info->channel;
|
indio_dev->channels = st->chip_info->channel;
|
||||||
indio_dev->num_channels = 2;
|
indio_dev->num_channels = 2;
|
||||||
indio_dev->info = &ad7476_info;
|
indio_dev->info = &ad7476_info;
|
||||||
|
|
||||||
|
if (st->convst_gpio && st->chip_info->convst_channel)
|
||||||
|
indio_dev->channels = st->chip_info->convst_channel;
|
||||||
/* Setup default message */
|
/* Setup default message */
|
||||||
|
|
||||||
st->xfer.rx_buf = &st->data;
|
st->xfer.rx_buf = &st->data;
|
||||||
|
Loading…
Reference in New Issue
Block a user