iio: adc: ad7606: Add debug mode for ad7616
Support for register access was added for devices which have software mode. Signed-off-by: Beniamin Bia <beniamin.bia@analog.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
This commit is contained in:
parent
f2a22e1e17
commit
a444fa597e
|
@ -60,6 +60,29 @@ static int ad7606_reset(struct ad7606_state *st)
|
|||
return -ENODEV;
|
||||
}
|
||||
|
||||
static int ad7606_reg_access(struct iio_dev *indio_dev,
|
||||
unsigned int reg,
|
||||
unsigned int writeval,
|
||||
unsigned int *readval)
|
||||
{
|
||||
struct ad7606_state *st = iio_priv(indio_dev);
|
||||
int ret;
|
||||
|
||||
mutex_lock(&st->lock);
|
||||
if (readval) {
|
||||
ret = st->bops->reg_read(st, reg);
|
||||
if (ret < 0)
|
||||
goto err_unlock;
|
||||
*readval = ret;
|
||||
ret = 0;
|
||||
} else {
|
||||
ret = st->bops->reg_write(st, reg, writeval);
|
||||
}
|
||||
err_unlock:
|
||||
mutex_unlock(&st->lock);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int ad7606_read_samples(struct ad7606_state *st)
|
||||
{
|
||||
unsigned int num = st->chip_info->num_channels;
|
||||
|
@ -501,6 +524,14 @@ static const struct iio_info ad7606_info_os_and_range = {
|
|||
.validate_trigger = &ad7606_validate_trigger,
|
||||
};
|
||||
|
||||
static const struct iio_info ad7606_info_os_range_and_debug = {
|
||||
.read_raw = &ad7606_read_raw,
|
||||
.write_raw = &ad7606_write_raw,
|
||||
.debugfs_reg_access = &ad7606_reg_access,
|
||||
.attrs = &ad7606_attribute_group_os_and_range,
|
||||
.validate_trigger = &ad7606_validate_trigger,
|
||||
};
|
||||
|
||||
static const struct iio_info ad7606_info_os = {
|
||||
.read_raw = &ad7606_read_raw,
|
||||
.write_raw = &ad7606_write_raw,
|
||||
|
@ -617,7 +648,7 @@ int ad7606_probe(struct device *dev, int irq, void __iomem *base_address,
|
|||
|
||||
/* After reset, in software mode, ±10 V is set by default */
|
||||
memset32(st->range, 2, ARRAY_SIZE(st->range));
|
||||
indio_dev->info = &ad7606_info_os_and_range;
|
||||
indio_dev->info = &ad7606_info_os_range_and_debug;
|
||||
|
||||
ret = st->bops->sw_mode_config(indio_dev);
|
||||
if (ret < 0)
|
||||
|
|
Loading…
Reference in New Issue