mbox series

[v2,0/2] iio: adc: ad7944: new driver

Message ID 20240216-ad7944-mainline-v2-0-7eb69651e592@baylibre.com
Headers show
Series iio: adc: ad7944: new driver | expand

Message

David Lechner Feb. 16, 2024, 7:46 p.m. UTC
This is a new driver for the Analog Devices AD7944/AD7985/AD7986 family
of ADCs. These are fairly simple chips (e.g. no configuration registers).
The initial driver is only supporting the 'multi' (4-wire) SPI mode. We
plan to follow up with support for the 'single' (3-wire) SPI mode.

This work is done on behalf of Analog Devices, Inc., hence the
MAINTAINERS are @analog.com folks.

---
Changes in v2:
- Added limit to spi-max-frequency for chain mode in DT bindings
- Added spi-cpol property to DT bindings
- Renamed '3-wire' mode to 'single' mode (to avoid confusion with spi-3wire)
- Renamed '4-wire' mode to 'multi' mode
- Dropped adi,reference property - now using only ref-supply and 
  refin-supply to determine the reference voltage source
- Fixed spelling of TURBO
- Renamed t_cnv to t_conv to match datasheet name and fixed comment
- Fixed wrong timestamp pushed to buffer
- Fixed scaling for chips with signed data
- Make use of sysfs_match_string() function
- Link to v1: https://lore.kernel.org/r/20240206-ad7944-mainline-v1-0-bf115fa9474f@baylibre.com

---
David Lechner (2):
      dt-bindings: iio: adc: add ad7944 ADCs
      iio: adc: ad7944: add driver for AD7944/AD7985/AD7986

 .../devicetree/bindings/iio/adc/adi,ad7944.yaml    | 204 ++++++++++
 MAINTAINERS                                        |   9 +
 drivers/iio/adc/Kconfig                            |  10 +
 drivers/iio/adc/Makefile                           |   1 +
 drivers/iio/adc/ad7944.c                           | 427 +++++++++++++++++++++
 5 files changed, 651 insertions(+)
---
base-commit: bd2f1ed8873d4bbb2798151bbe28c86565251cfb
change-id: 20240206-ad7944-mainline-17c968aa0967

Comments

David Lechner Feb. 19, 2024, 7:13 p.m. UTC | #1
On Fri, Feb 16, 2024 at 1:47 PM David Lechner <dlechner@baylibre.com> wrote:

...

> +
> +#define AD7944_DEFINE_CHIP_INFO(_name, _t, _bits, _sign)               \
> +static const struct ad7944_chip_info _name##_chip_info = {             \
> +       .name = #_name,                                                 \
> +       .t = &_t##_timing_spec,                                         \
> +       .channels = {                                                   \
> +               {                                                       \
> +                       .type = IIO_VOLTAGE,                            \
> +                       .indexed = 1,                                   \
> +                       .differential = 1,                              \
> +                       .channel = 0,                                   \
> +                       .channel2 = 1,                                  \
> +                       .scan_index = 0,                                \
> +                       .scan_type.sign = _sign,                        \
> +                       .scan_type.realbits = _bits,                    \
> +                       .scan_type.storagebits = _bits > 16 ? 32 : 16,  \
> +                       .scan_type.endianness = IIO_CPU,                \
> +                       .info_mask_separate = BIT(IIO_CHAN_INFO_RAW)    \
> +                                       | BIT(IIO_CHAN_INFO_SCALE),     \
> +               },                                                      \
> +               IIO_CHAN_SOFT_TIMESTAMP(1),                             \
> +       },                                                              \
> +}
> +
> +AD7944_DEFINE_CHIP_INFO(ad7944, ad7944, 14, 'u');
> +AD7944_DEFINE_CHIP_INFO(ad7985, ad7944, 16, 'u');
> +AD7944_DEFINE_CHIP_INFO(ad7986, ad7986, 18, 's');

Now that I have been enlightened [1] about pseudo-differntial inputs,
I'm thinking that AD7944 and AD7985 should not have the .differential
= 1 flag set since they are pseudo-differential inputs with a ground
sense on the negative input (and no extra supply needed since it is
always ground). Does that sound right?

AD7986 is true differential though, so should be correct already.

[1]: https://lore.kernel.org/linux-iio/CAMknhBF5mAsN1c-194Qwa5oKmqKzef2khXnqA1cSdKpWHKWp0w@mail.gmail.com/
Jonathan Cameron Feb. 19, 2024, 7:46 p.m. UTC | #2
On Mon, 19 Feb 2024 13:13:35 -0600
David Lechner <dlechner@baylibre.com> wrote:

> On Fri, Feb 16, 2024 at 1:47 PM David Lechner <dlechner@baylibre.com> wrote:
> 
> ...
> 
> > +
> > +#define AD7944_DEFINE_CHIP_INFO(_name, _t, _bits, _sign)               \
> > +static const struct ad7944_chip_info _name##_chip_info = {             \
> > +       .name = #_name,                                                 \
> > +       .t = &_t##_timing_spec,                                         \
> > +       .channels = {                                                   \
> > +               {                                                       \
> > +                       .type = IIO_VOLTAGE,                            \
> > +                       .indexed = 1,                                   \
> > +                       .differential = 1,                              \
> > +                       .channel = 0,                                   \
> > +                       .channel2 = 1,                                  \
> > +                       .scan_index = 0,                                \
> > +                       .scan_type.sign = _sign,                        \
> > +                       .scan_type.realbits = _bits,                    \
> > +                       .scan_type.storagebits = _bits > 16 ? 32 : 16,  \
> > +                       .scan_type.endianness = IIO_CPU,                \
> > +                       .info_mask_separate = BIT(IIO_CHAN_INFO_RAW)    \
> > +                                       | BIT(IIO_CHAN_INFO_SCALE),     \
> > +               },                                                      \
> > +               IIO_CHAN_SOFT_TIMESTAMP(1),                             \
> > +       },                                                              \
> > +}
> > +
> > +AD7944_DEFINE_CHIP_INFO(ad7944, ad7944, 14, 'u');
> > +AD7944_DEFINE_CHIP_INFO(ad7985, ad7944, 16, 'u');
> > +AD7944_DEFINE_CHIP_INFO(ad7986, ad7986, 18, 's');  
> 
> Now that I have been enlightened [1] about pseudo-differntial inputs,
> I'm thinking that AD7944 and AD7985 should not have the .differential
> = 1 flag set since they are pseudo-differential inputs with a ground
> sense on the negative input (and no extra supply needed since it is
> always ground). Does that sound right?

yes

> 
> AD7986 is true differential though, so should be correct already.
> 
> [1]: https://lore.kernel.org/linux-iio/CAMknhBF5mAsN1c-194Qwa5oKmqKzef2khXnqA1cSdKpWHKWp0w@mail.gmail.com/