ad7923 fixes and full range support
Subsystems (3)
Nuno Sá
maintainerv2 cover ad7923 fixes and full range support
This patchset adds important fixes for some of the variants supported by the driver with respect with raw and buffered reads. On top of this way, adds a new firmware property to be able to support all the scales supported by the hardware.
v2:
[1/3]
* Calculate shift using 12 - realbits.
[2/3]
* Use a boolean property and change the code accordingly.
[3/3]
* Use a boolean property (adi,range-double).
Nuno Sá (3):
iio: adc: ad7923: fix channel readings for some variants
iio: adc: ad7923: support extended range
dt-bindings: iio: adi,ad7923: add adi,range-double property
.../devicetree/bindings/iio/adc/adi,ad7923.yaml | 4 ++++ drivers/iio/adc/ad7923.c | 11 +++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-)
Signature · 1 line
2.37.3
Nuno Sá
maintainerPATCH v2 1/3 iio: adc: ad7923: fix channel readings for some variants
Some of the supported devices have 4 or 2 LSB trailing bits that should not be taken into account. Hence we need to shift these bits out which fits perfectly on the scan type shift property. This change fixes both raw and buffered reads.
--- drivers/iio/adc/ad7923.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/iio/adc/ad7923.c +3 -1
@@ -93,6 +93,7 @@ enum ad7923_id { .sign = 'u', \ .realbits = (bits), \ .storagebits = 16, \ + .shift = 12 - (bits), \ .endianness = IIO_BE, \ }, \ }
@@ -268,7 +269,8 @@ static int ad7923_read_raw(struct iio_dev *indio_dev,return ret;if (chan->address ==EXTRACT (ret,12 ,4 )) - *val =EXTRACT (ret,0 ,12 ); + *val =EXTRACT (ret, chan->scan_type.shift, + chan->scan_type.realbits);else return -EIO ;
Signature · 1 line
2.37.3
Nuno Sá
maintainerPATCH v2 2/3 iio: adc: ad7923: support extended range
In reply to Nuno Sá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.
--- drivers/iio/adc/ad7923.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/iio/adc/ad7923.c +6 -1
@@ -8,6 +8,7 @@#include <linux/device.h> #include <linux/kernel.h> +#include <linux/property.h> #include <linux/slab.h> #include <linux/sysfs.h> #include <linux/spi/spi.h>
@@ -300,6 +301,7 @@ static void ad7923_regulator_disable(void *data)static int ad7923_probe (struct spi_device *spi) { +u32 ad7923_range =AD7923_RANGE ;struct ad7923_state *st;struct iio_dev *indio_dev;const struct ad7923_chip_info *info;
@@ -311,8 +313,11 @@ static int ad7923_probe(struct spi_device *spi) st =iio_priv (indio_dev); +if (device_property_read_bool (&spi->dev,"adi,range-double" )) + ad7923_range =0 ; + st->spi = spi; - st->settings =AD7923_CODING |AD7923_RANGE | + st->settings =AD7923_CODING | ad7923_range |AD7923_PM_MODE_WRITE (AD7923_PM_MODE_OPS ); info = &ad7923_chip_info[spi_get_device_id (spi)->driver_data];
Signature · 1 line
2.37.3
Nuno Sá
maintainerPATCH v2 3/3 dt-bindings: iio: adi,ad7923: add adi,range-double property
In reply to Nuno SáDocument the new property to enable doubling the analog input range.
--- Documentation/devicetree/bindings/iio/adc/adi,ad7923.yaml | 4 ++++ 1 file changed, 4 insertions(+)
Documentation/devicetree/bindings/iio/adc/adi,ad7923.yaml +4 -0
@@ -36,6 +36,10 @@ properties: description: | The regulator supply for ADC reference voltage. + adi,range-double: + description: Sets the analog input range from 0 to 2xVREF. + type: boolean + '#address-cells': const: 1
Signature · 1 line
2.37.3
Re: [PATCH v2 3/3] dt-bindings: iio: adi,ad7923: add adi,range-double property
Quoted 4 lines · Nuno Sá
Document the new property to enable doubling the analog input range.
Signed-off-by Nuno Sá <[email protected]>---
Best regards,
Krzysztof
Quoted 4 lines · On Mon, 12 Sep 2022 10:12:20 +0200 Nuno Sá <[email protected]> wrote:
This patchset adds important fixes for some of the variants supported by the driver with respect with raw and buffered reads. On top of this way, adds a new firmware property to be able to support all the scales supported by the hardware.
Applied.
Thanks,
Jonathan
Quoted 21 lines
v2:
[1/3]
* Calculate shift using 12 - realbits.[2/3]
* Use a boolean property and change the code accordingly.[3/3]
* Use a boolean property (adi,range-double).Nuno Sá (3):
iio: adc: ad7923: fix channel readings for some variants
iio: adc: ad7923: support extended range
dt-bindings: iio: adi,ad7923: add adi,range-double property.../devicetree/bindings/iio/adc/adi,ad7923.yaml | 4 ++++ drivers/iio/adc/ad7923.c | 11 +++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-)