diff options
author | Beniamin Bia <beniamin.bia@analog.com> | 2019-07-18 09:27:34 +0300 |
---|---|---|
committer | Jonathan Cameron <Jonathan.Cameron@huawei.com> | 2019-07-28 08:56:45 +0100 |
commit | a444fa597e2a130d2c56f1bfbe131c62625d7b55 (patch) | |
tree | 44625b4193801deb90b2ee68719dc3dfee6f3659 | |
parent | f2a22e1e172f7dc486325216ec0890f301cb09e2 (diff) | |
download | linux-stable-a444fa597e2a130d2c56f1bfbe131c62625d7b55.tar.gz linux-stable-a444fa597e2a130d2c56f1bfbe131c62625d7b55.tar.bz2 linux-stable-a444fa597e2a130d2c56f1bfbe131c62625d7b55.zip |
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>
-rw-r--r-- | drivers/iio/adc/ad7606.c | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/drivers/iio/adc/ad7606.c b/drivers/iio/adc/ad7606.c index be2330c8b277..ed2d08437e5d 100644 --- a/drivers/iio/adc/ad7606.c +++ b/drivers/iio/adc/ad7606.c @@ -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) |