iio: adc: add new ad7380 driver
David Lechner
reviewerv4 cover iio: adc: add new ad7380 driver
This series is adding a new driver for the Analog Devices Inc. AD7380, AD7381, AD7383, and AD7384 ADCs. These chips are part of a family of simultaneous sampling SAR ADCs.
One quirk of these chips is that since they are simultaneous sampling, they have multiple SPI data output lines that allow transferring two data words (one for each input channel) at the same time. So a new generic devicetree binding is added to describe this sort of SPI bus configuration.
To keep things simple, the initial driver implementation only supports the 2-channel differential chips listed above. There are also 4-channel differential chips and 4-channel single-ended chips in the family that can be added later.
Furthermore, the driver is just implementing basic support for capturing data. Additional features like interrupts, CRC, etc. can be added later.
Also, FYI, this driver will also be used as the base for an upcoming series adding AXI SPI Engine offload support for these chips along with [1].
This work is being done by BayLibre and on behalf of Analog Devices Inc. hence the maintainers are @analog.com.
[1]: https://lore.kernel.org/linux-spi/[email protected]/
---
Changes in v4:
- Dropped SPI bindings patch.
- Removed spi-rx-bus-channels from the adi,ad7380 bindings.
- Link to v3: https://lore.kernel.org/r/[email protected]
Changes in v3:
- dt-bindings:
- Picked up Conor's Reviewed-By on the adi,ad7380 bindings
- driver:
- Removed extra indent in DEFINE_AD7380_DIFFERENTIAL_2_CHANNEL macro
- Removed scan mask that included timestamp channel
- Removed parent device assignment
- Picked up Nuno's Reviewed-by
- Link to v2: https://lore.kernel.org/r/[email protected]
Changes in v2:
- dt-bindings:
- Added new patch with generic spi-rx-bus-channels property
- Added maxItems to reg property
- Replaced adi,sdo-mode property with spi-rx-bus-channels
- Made spi-rx-bus-channels property optional with default value of 1
(this made the if: check more complex)
- Changed example to use gpio for interrupt
- driver:
- Fixed CONFIG_AD7380 in Makefile
- rx_buf = st->scan_data.raw instead of rx_buf = &st->scan_data
- Moved iio_push_to_buffers_with_timestamp() outside of if statement
- Removed extra blank lines
- Renamed regulator disable function
- Dropped checking of adi,sdo-mode property (regardless of the actual wiring, we can always use 1-wire mode)
- Added available_scan_masks
- Added check for missing driver match data
- Link to v1: https://lore.kernel.org/r/[email protected]
---
David Lechner (2):
dt-bindings: iio: adc: Add binding for AD7380 ADCs
iio: adc: ad7380: new driver for AD7380 ADCs
.../devicetree/bindings/iio/adc/adi,ad7380.yaml | 86 ++++ MAINTAINERS | 10 + drivers/iio/adc/Kconfig | 16 + drivers/iio/adc/Makefile | 1 + drivers/iio/adc/ad7380.c | 462 +++++++++++++++++++++ 5 files changed, 575 insertions(+)
---
base-commit: 18f78b5e609b19b56237f0dae47068d44b8b0ecd
change-id: 20231208-ad7380-mainline-e6c4fa7dbedd
Best regards,
Signature · 1 line
David Lechner <[email protected]>
David Lechner
reviewerPATCH v4 1/2 dt-bindings: iio: adc: Add binding for AD7380 ADCs
This adds a binding specification for the Analog Devices Inc. AD7380 family of ADCs.
---
As discussed in [1], the proposed spi-rx-bus-channels property is a complex new SPI core feature, so it was nacked for now on the grounds that it should be accepted without the corresponding SPI core changes. I dropped the Reviewed-by since no DT maintainers responded on that thread.
[1]: https://lore.kernel.org/linux-spi/[email protected]/
Changes in v4:
- Dropped spi-rx-bus-channels property.
Changes in v3:
- Picked up Conor's Reviewed-By on the adi,ad7380 bindings
Changes in v2:
- Added new patch with generic spi-rx-bus-channels property
- Added maxItems to reg property
- Replaced adi,sdo-mode property with spi-rx-bus-channels
- Made spi-rx-bus-channels property optional with default value of 1 (this made the if: check more complex)
- Changed example to use gpio for interrupt
.../devicetree/bindings/iio/adc/adi,ad7380.yaml | 86 ++++++++++++++++++++++ MAINTAINERS | 9 +++ 2 files changed, 95 insertions(+)
Documentation/devicetree/bindings/iio/adc/adi,ad7380.yaml new file +86 -0
@@ -0,0 +1,86 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/adc/adi,ad7380.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Analog Devices Simultaneous Sampling Analog to Digital Converters + +maintainers: + - Michael Hennerich <[email protected]> + - Nuno Sá <[email protected]> + +description: | + * https://www.analog.com/en/products/ad7380.html + * https://www.analog.com/en/products/ad7381.html + * https://www.analog.com/en/products/ad7383.html + * https://www.analog.com/en/products/ad7384.html + +$ref: /schemas/spi/spi-peripheral-props.yaml# + +properties: + compatible: + enum: + - adi,ad7380 + - adi,ad7381 + - adi,ad7383 + - adi,ad7384 + + reg: + maxItems: 1 + + spi-max-frequency: + maximum: 80000000 + spi-cpol: true + spi-cpha: true + + vcc-supply: + description: A 3V to 3.6V supply that powers the chip. + + vlogic-supply: + description: + A 1.65V to 3.6V supply for the logic pins. + + refio-supply: + description: + A 2.5V to 3.3V supply for the external reference voltage. When omitted, + the internal 2.5V reference is used. + + interrupts: + description: + When the device is using 1-wire mode, this property is used to optionally + specify the ALERT interrupt. + maxItems: 1 + +required: + - compatible + - reg + - vcc-supply + - vlogic-supply + +unevaluatedProperties: false + +examples: + - | + #include <dt-bindings/interrupt-controller/irq.h> + + spi { + #address-cells = <1>; + #size-cells = <0>; + + adc@0 { + compatible = "adi,ad7380"; + reg = <0>; + + spi-cpol; + spi-cpha; + spi-max-frequency = <80000000>; + + interrupts = <27 IRQ_TYPE_EDGE_FALLING>; + interrupt-parent = <&gpio0>; + + vcc-supply = <&supply_3_3V>; + vlogic-supply = <&supply_3_3V>; + refio-supply = <&supply_2_5V>; + }; + };
MAINTAINERS +9 -0
@@ -430,6 +430,15 @@ W: http://wiki.analog.com/AD7142 W: https://ez.analog.com/linux-software-drivers F: drivers/input/misc/ad714x.c +AD738X ADC DRIVER (AD7380/1/2/4) +M: Michael Hennerich <[email protected]> +M: Nuno Sá <[email protected]> +R: David Lechner <[email protected]> +S: Supported +W: https://wiki.analog.com/resources/tools-software/linux-drivers/iio-adc/ad738x +W: https://ez.analog.com/linux-software-drivers +F: Documentation/devicetree/bindings/iio/adc/adi,ad7380.yaml + AD7877 TOUCHSCREEN DRIVER M: Michael Hennerich <[email protected]> S: Supported
Signature · 1 line
2.43.0
Re: [PATCH v4 1/2] dt-bindings: iio: adc: Add binding for AD7380 ADCs
Quoted 10 lines · David Lechner
This adds a binding specification for the Analog Devices Inc. AD7380 family of ADCs.
Signed-off-by David Lechner <[email protected]>---
As discussed in [1], the proposed spi-rx-bus-channels property is a complex new SPI core feature, so it was nacked for now on the grounds that it should be accepted without the corresponding SPI core changes. I dropped the Reviewed-by since no DT maintainers responded on that thread.
I think that's reasonable. Better to wait and do something correct when the problme is understood than rush into something. You can re-add
Cheers,
Conor.
David Lechner
reviewerPATCH v4 2/2 iio: adc: ad7380: new driver for AD7380 ADCs
In reply to David LechnerThis adds a new driver for the AD7380 family ADCs.
The driver currently implements basic support for the AD7380, AD7381, AD7383, and AD7384 2-channel differential ADCs. Support for additional single-ended and 4-channel chips that use the same register map as well as additional features of the chip will be added in future patches.
---
Changes in v4: none
Changes in v3:
- Removed extra indent in DEFINE_AD7380_DIFFERENTIAL_2_CHANNEL macro
- Removed scan mask that included timestamp channel
- Removed parent device assignment
- Picked up Nuno's Reviewed-by
Changes in v2:
- Fixed CONFIG_AD7380 in Makefile
- rx_buf = st->scan_data.raw instead of rx_buf = &st->scan_data
- Moved iio_push_to_buffers_with_timestamp() outside of if statement
- Removed extra blank lines
- Renamed regulator disable function
- Dropped checking of adi,sdo-mode property (regardless of the actual wiring, we can always use 1-wire mode)
- Added available_scan_masks
- Added check for missing driver match data
MAINTAINERS | 1 + drivers/iio/adc/Kconfig | 16 ++ drivers/iio/adc/Makefile | 1 + drivers/iio/adc/ad7380.c | 462 +++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 480 insertions(+)
MAINTAINERS +1 -0
@@ -438,6 +438,7 @@ S: Supported W: https://wiki.analog.com/resources/tools-software/linux-drivers/iio-adc/ad738x W: https://ez.analog.com/linux-software-drivers F: Documentation/devicetree/bindings/iio/adc/adi,ad7380.yaml +F: drivers/iio/adc/ad7380.c AD7877 TOUCHSCREEN DRIVER M: Michael Hennerich <[email protected]>
drivers/iio/adc/Kconfig +16 -0
@@ -122,6 +122,22 @@ config AD7298 To compile this driver as a module, choose M here: the module will be called ad7298. +config AD7380 + tristate "Analog Devices AD7380 ADC driver" + depends on SPI_MASTER + select IIO_BUFFER + select IIO_TRIGGER + select IIO_TRIGGERED_BUFFER + help + AD7380 is a family of simultaneous sampling ADCs that share the same + SPI register map and have similar pinouts. + + Say yes here to build support for Analog Devices AD7380 ADC and + similar chips. + + To compile this driver as a module, choose M here: the module will be + called ad7380. + config AD7476 tristate "Analog Devices AD7476 1-channel ADCs driver and other similar devices from AD and TI" depends on SPI
drivers/iio/adc/Makefile +1 -0
@@ -16,6 +16,7 @@ obj-$(CONFIG_AD7291) += ad7291.o obj-$(CONFIG_AD7292) += ad7292.o obj-$(CONFIG_AD7298) += ad7298.o obj-$(CONFIG_AD7923) += ad7923.o +obj-$(CONFIG_AD7380) += ad7380.o obj-$(CONFIG_AD7476) += ad7476.o obj-$(CONFIG_AD7606_IFACE_PARALLEL) += ad7606_par.o obj-$(CONFIG_AD7606_IFACE_SPI) += ad7606_spi.o
drivers/iio/adc/ad7380.c new file +462 -0
462 lines not on this page · raw message
Signature · 1 line
2.43.0
David Lechner
reviewerRe: [PATCH v4 2/2] iio: adc: ad7380: new driver for AD7380 ADCs
Quoted 8 lines · David Lechner
This adds a new driver for the AD7380 family ADCs.
The driver currently implements basic support for the AD7380, AD7381, AD7383, and AD7384 2-channel differential ADCs. Support for additional single-ended and 4-channel chips that use the same register map as well as additional features of the chip will be added in future patches.
Hi Jonathan,
We have some additional features to add to this driver we are working on that look like they might affect userspace. Can we hold off on sending this one to Greg for 6.9? That way we will have more time to sort that out without having to worry about breaking userspace.
Jonathan Cameron
maintainerRe: [PATCH v4 2/2] iio: adc: ad7380: new driver for AD7380 ADCs
Quoted 10 lines · On Fri, 16 Feb 2024 14:34:01 -0600 David Lechner <[email protected]> wrote:
Quoted 8 lines · David Lechner
This adds a new driver for the AD7380 family ADCs.
The driver currently implements basic support for the AD7380, AD7381, AD7383, and AD7384 2-channel differential ADCs. Support for additional single-ended and 4-channel chips that use the same register map as well as additional features of the chip will be added in future patches.
Quoted 6 lines
Hi Jonathan,
We have some additional features to add to this driver we are working on that look like they might affect userspace. Can we hold off on sending this one to Greg for 6.9? That way we will have more time to sort that out without having to worry about breaking userspace.
Ok. Hopefully rebasing my tree won't cause others too many downstream problems. Generally I only do this if there is an invalid tag or similar that must be fixed. There is normally a window of a weekish between me picking it up and pushing out for linux-next to pick up and hopefully issues like this get spotted in that window.
Ah well, sometimes things don't work out how we would like them to.
Dropped the 3 patches (original driver and a fix) from the togreg branch.
Jonathan
David Lechner
reviewerRe: [PATCH v4 2/2] iio: adc: ad7380: new driver for AD7380 ADCs
Quoted 20 lines · Jonathan Cameron
Quoted 10 lines · On Fri, 16 Feb 2024 14:34:01 -0600 David Lechner <[email protected]> wrote:
Quoted 8 lines · David Lechner
This adds a new driver for the AD7380 family ADCs.
The driver currently implements basic support for the AD7380, AD7381, AD7383, and AD7384 2-channel differential ADCs. Support for additional single-ended and 4-channel chips that use the same register map as well as additional features of the chip will be added in future patches.
Quoted 6 lines
Hi Jonathan,
We have some additional features to add to this driver we are working on that look like they might affect userspace. Can we hold off on sending this one to Greg for 6.9? That way we will have more time to sort that out without having to worry about breaking userspace.
Quoted 9 lines
Ok. Hopefully rebasing my tree won't cause others too many downstream problems. Generally I only do this if there is an invalid tag or similar that must be fixed. There is normally a window of a weekish between me picking it up and pushing out for linux-next to pick up and hopefully issues like this get spotted in that window.
Ah well, sometimes things don't work out how we would like them to.Dropped the 3 patches (original driver and a fix) from the togreg branch.
Thanks. I will keep the the one week window in mind if we have similar cases in the future.
David Lechner
reviewerRe: [PATCH v4 2/2] iio: adc: ad7380: new driver for AD7380 ADCs
In reply to David LechnerOn Wed, Jan 10, 2024 at 2:29 PM David Lechner <[email protected]> wrote:
...
drivers/iio/adc/ad7380.c line 100
Quoted 8 lines
drivers/iio/adc/ad7380.c new file +8
-0+ +/* fully differential */ +DEFINE_AD7380_DIFFERENTIAL_2_CHANNEL (ad7380_channels,16 ); +DEFINE_AD7380_DIFFERENTIAL_2_CHANNEL (ad7381_channels,14 ); +/* pseudo differential */ +DEFINE_AD7380_DIFFERENTIAL_2_CHANNEL (ad7383_channels,16 ); +DEFINE_AD7380_DIFFERENTIAL_2_CHANNEL (ad7384_channels,14 ); +
Similar question to [1] in light of [2]: Since AD7383 and AD7384 are pseudo-differential, should we handle them differently? I.e. add aina-supply and ainb-supply DT properties for the negative inputs (typically a V_REF / 2 supply) and remove the differential flag from the channel spec.
[1]: https://lore.kernel.org/linux-iio/CAMknhBH2Pqa9xpPxnTCxJegVTbOG-QDeJA4YrQUPfj+hfSs73A@mail.gmail.com/
[2]: https://lore.kernel.org/linux-iio/CAMknhBF5mAsN1c-194Qwa5oKmqKzef2khXnqA1cSdKpWHKWp0w@mail.gmail.com/
Jonathan Cameron
maintainerRe: [PATCH v4 2/2] iio: adc: ad7380: new driver for AD7380 ADCs
Quoted 19 lines · On Mon, 19 Feb 2024 13:47:03 -0600 David Lechner <[email protected]> wrote:
On Wed, Jan 10, 2024 at 2:29 PM David Lechner <[email protected]> wrote:
...
drivers/iio/adc/ad7380.c line 100
Quoted 8 lines
drivers/iio/adc/ad7380.c new file +8
-0+ +/* fully differential */ +DEFINE_AD7380_DIFFERENTIAL_2_CHANNEL (ad7380_channels,16 ); +DEFINE_AD7380_DIFFERENTIAL_2_CHANNEL (ad7381_channels,14 ); +/* pseudo differential */ +DEFINE_AD7380_DIFFERENTIAL_2_CHANNEL (ad7383_channels,16 ); +DEFINE_AD7380_DIFFERENTIAL_2_CHANNEL (ad7384_channels,14 ); +Similar question to [1] in light of [2]: Since AD7383 and AD7384 are pseudo-differential, should we handle them differently? I.e. add aina-supply and ainb-supply DT properties for the negative inputs (typically a
V_REF/ 2 supply) and remove the differential flag from the channel spec.
Quoted 2 lines
[1]: https://lore.kernel.org/linux-iio/CAMknhBH2Pqa9xpPxnTCxJegVTbOG-QDeJA4YrQUPfj+hfSs73A@mail.gmail.com/
[2]: https://lore.kernel.org/linux-iio/CAMknhBF5mAsN1c-194Qwa5oKmqKzef2khXnqA1cSdKpWHKWp0w@mail.gmail.com/
Yes. I think that gives a more intuitive interface for users. I don't think we need to 'fix' any drivers already upstream as presenting these as differential is not an ABI error as far as I am concerned. It's just less than ideal choices given our views now! (as a result of these discussions on what pseudo differential means in practice)
Jonathan
Jonathan Cameron
maintainerQuoted 18 lines · On Wed, 10 Jan 2024 14:28:39 -0600 David Lechner <[email protected]> wrote:
This series is adding a new driver for the Analog Devices Inc. AD7380, AD7381, AD7383, and AD7384 ADCs. These chips are part of a family of simultaneous sampling SAR ADCs.
One quirk of these chips is that since they are simultaneous sampling, they have multiple SPI data output lines that allow transferring two data words (one for each input channel) at the same time. So a new generic devicetree binding is added to describe this sort of SPI bus configuration.
To keep things simple, the initial driver implementation only supports the 2-channel differential chips listed above. There are also 4-channel differential chips and 4-channel single-ended chips in the family that can be added later.
Furthermore, the driver is just implementing basic support for capturing data. Additional features like interrupts, CRC, etc. can be added later.
Quoted 8 lines
Also, FYI, this driver will also be used as the base for an upcoming series adding AXI SPI Engine offload support for these chips along with [1].
This work is being done by BayLibre and on behalf of Analog Devices Inc. hence the maintainers are @analog.com.
Series applied to the togreg branch of iio.git though that is only pushed out as testing for now as I'll be rebasing it on rc1 once available.
Jonathan