Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

iio: adc: ad7923: support extended range

By default the driver was always setting the RANGE bit which means that
the analog input goes from 0 to VREF. However, we might want to have 0
to 2xVREF. This change adds a new Firmware property to allow for the
extended range while keeping the default behavior if nothing is provided.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
Link: https://lore.kernel.org/r/20220912081223.173584-3-nuno.sa@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

authored by

Nuno Sá and committed by
Jonathan Cameron
096d2dac f4f43f01

+6 -1
+6 -1
drivers/iio/adc/ad7923.c
··· 8 8 9 9 #include <linux/device.h> 10 10 #include <linux/kernel.h> 11 + #include <linux/property.h> 11 12 #include <linux/slab.h> 12 13 #include <linux/sysfs.h> 13 14 #include <linux/spi/spi.h> ··· 301 300 302 301 static int ad7923_probe(struct spi_device *spi) 303 302 { 303 + u32 ad7923_range = AD7923_RANGE; 304 304 struct ad7923_state *st; 305 305 struct iio_dev *indio_dev; 306 306 const struct ad7923_chip_info *info; ··· 313 311 314 312 st = iio_priv(indio_dev); 315 313 314 + if (device_property_read_bool(&spi->dev, "adi,range-double")) 315 + ad7923_range = 0; 316 + 316 317 st->spi = spi; 317 - st->settings = AD7923_CODING | AD7923_RANGE | 318 + st->settings = AD7923_CODING | ad7923_range | 318 319 AD7923_PM_MODE_WRITE(AD7923_PM_MODE_OPS); 319 320 320 321 info = &ad7923_chip_info[spi_get_device_id(spi)->driver_data];