iio: adc: ad7091r: Enable internal vref if external vref is not supplied
authorMarcelo Schmitt <marcelo.schmitt@analog.com>
Tue, 19 Dec 2023 20:26:27 +0000 (17:26 -0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 1 Feb 2024 00:18:47 +0000 (16:18 -0800)
commite4e845c8ddd2a810eaafb2690e2bdf7fd3e1efe4
treee9829bc057b8f6bc895ca5c86731272793de053a
parent89c4e63324e208a23098f7fb15c00487cecbfed2
iio: adc: ad7091r: Enable internal vref if external vref is not supplied

[ Upstream commit e71c5c89bcb165a02df35325aa13d1ee40112401 ]

The ADC needs a voltage reference to work correctly.
Users can provide an external voltage reference or use the chip internal
reference to operate the ADC.
The availability of an in chip reference for the ADC saves the user from
having to supply an external voltage reference, which makes the external
reference an optional property as described in the device tree
documentation.
Though, to use the internal reference, it must be enabled by writing to
the configuration register.
Enable AD7091R internal voltage reference if no external vref is supplied.

Fixes: 260442cc5be4 ("iio: adc: ad7091r5: Add scale and external VREF support")
Signed-off-by: Marcelo Schmitt <marcelo.schmitt@analog.com>
Link: https://lore.kernel.org/r/b865033fa6a4fc4bf2b4a98ec51a6144e0f64f77.1703013352.git.marcelo.schmitt1@gmail.com
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/iio/adc/ad7091r-base.c
drivers/iio/adc/ad7091r-base.h