Make use of the AD7991_REF_SEL bit and support using the external reference voltage by setting the 'vref-external' property in devicetree. Signed-off-by: Florian Boor <florian.boor@xxxxxxxxxxxxxxxxx> --- drivers/iio/adc/ad799x.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/drivers/iio/adc/ad799x.c b/drivers/iio/adc/ad799x.c index 18bf8386d50a..3ae7ec72caa3 100644 --- a/drivers/iio/adc/ad799x.c +++ b/drivers/iio/adc/ad799x.c @@ -770,6 +770,7 @@ static int ad799x_probe(struct i2c_client *client, const struct i2c_device_id *id) { int ret; + int extra_config = 0; struct ad799x_state *st; struct iio_dev *indio_dev; const struct ad799x_chip_info *chip_info = @@ -806,6 +807,17 @@ static int ad799x_probe(struct i2c_client *client, if (ret) goto error_disable_reg; + + /* allow to use external reference voltage */ + if ((st->id == ad7991) || (st->id == ad7995) || (st->id == ad7999)) { + unsigned int vref_external = 0; + of_property_read_u32(client->dev.of_node, "vref-external", + &vref_external); + + if (vref_external) + extra_config |= AD7991_REF_SEL; + } + st->client = client; indio_dev->name = id->name; @@ -815,7 +827,7 @@ static int ad799x_probe(struct i2c_client *client, indio_dev->channels = st->chip_config->channel; indio_dev->num_channels = chip_info->num_channels; - ret = ad799x_update_config(st, st->chip_config->default_config); + ret = ad799x_update_config(st, st->chip_config->default_config | extra_config); if (ret) goto error_disable_vref; -- 2.20.1