Message ID | 20240319-adding-new-ad738x-driver-v5-7-ce7df004ceb3@baylibre.com (mailing list archive) |
---|---|
State | Changes Requested |
Headers | show |
Series | iio: adc: add new ad7380 driver | expand |
On Tue, 19 Mar 2024 11:11:28 +0100 Julien Stephan <jstephan@baylibre.com> wrote: > Add support for ad7380/1/2/3-4 parts which are 4 channels > variants from ad7380/1/2/3 > > Signed-off-by: Julien Stephan <jstephan@baylibre.com> This and other patches I didn't comment on all look good to me. So just those minor few bits and bobs for v6 and I'll pick this up if nothing else comes in. Thanks, Jonathan > --- > drivers/iio/adc/ad7380.c | 75 +++++++++++++++++++++++++++++++++++++++++++++++- > 1 file changed, 74 insertions(+), 1 deletion(-) > > diff --git a/drivers/iio/adc/ad7380.c b/drivers/iio/adc/ad7380.c > index 3aca41ce9a14..cf9d2ace5f20 100644 > --- a/drivers/iio/adc/ad7380.c > +++ b/drivers/iio/adc/ad7380.c > @@ -8,6 +8,9 @@ > * Datasheets of supported parts: > * ad7380/1 : https://www.analog.com/media/en/technical-documentation/data-sheets/AD7380-7381.pdf > * ad7383/4 : https://www.analog.com/media/en/technical-documentation/data-sheets/ad7383-7384.pdf > + * ad7380-4 : https://www.analog.com/media/en/technical-documentation/data-sheets/ad7380-4.pdf > + * ad7381-4 : https://www.analog.com/media/en/technical-documentation/data-sheets/ad7381-4.pdf > + * ad7383/4-4 : https://www.analog.com/media/en/technical-documentation/data-sheets/ad7383-4-ad7384-4.pdf > */ > > #include <linux/bitfield.h> > @@ -29,7 +32,7 @@ > #include <linux/iio/trigger_consumer.h> > #include <linux/iio/triggered_buffer.h> > > -#define MAX_NUM_CHANNELS 2 > +#define MAX_NUM_CHANNELS 4 > /* 2.5V internal reference voltage */ > #define AD7380_INTERNAL_REF_MV 2500 > > @@ -106,27 +109,53 @@ static const struct iio_chan_spec name[] = { \ > IIO_CHAN_SOFT_TIMESTAMP(2), \ > } > > +#define DEFINE_AD7380_4_CHANNEL(name, bits, diff) \ > +static const struct iio_chan_spec name[] = { \ > + AD7380_CHANNEL(0, bits, diff), \ > + AD7380_CHANNEL(1, bits, diff), \ > + AD7380_CHANNEL(2, bits, diff), \ > + AD7380_CHANNEL(3, bits, diff), \ > + IIO_CHAN_SOFT_TIMESTAMP(4), \ > +} > + > /* fully differential */ > DEFINE_AD7380_2_CHANNEL(ad7380_channels, 16, 1); > DEFINE_AD7380_2_CHANNEL(ad7381_channels, 14, 1); > +DEFINE_AD7380_4_CHANNEL(ad7380_4_channels, 16, 1); > +DEFINE_AD7380_4_CHANNEL(ad7381_4_channels, 14, 1); > /* pseudo differential */ > DEFINE_AD7380_2_CHANNEL(ad7383_channels, 16, 0); > DEFINE_AD7380_2_CHANNEL(ad7384_channels, 14, 0); > +DEFINE_AD7380_4_CHANNEL(ad7383_4_channels, 16, 0); > +DEFINE_AD7380_4_CHANNEL(ad7384_4_channels, 14, 0); > > static const char * const ad7380_2_channel_vcm_supplies[] = { > "aina", "ainb", > }; > > +static const char * const ad7380_4_channel_vcm_supplies[] = { > + "aina", "ainb", "ainc", "aind", > +}; > + > /* Since this is simultaneous sampling, we don't allow individual channels. */ > static const unsigned long ad7380_2_channel_scan_masks[] = { > GENMASK(1, 0), > 0 > }; > > +static const unsigned long ad7380_4_channel_scan_masks[] = { > + GENMASK(3, 0), > + 0 > +}; > + > static const struct ad7380_timing_specs ad7380_timing = { > .t_csh_ns = 10, > }; > > +static const struct ad7380_timing_specs ad7380_4_timing = { > + .t_csh_ns = 20, > +}; > + > static const struct ad7380_chip_info ad7380_chip_info = { > .name = "ad7380", > .channels = ad7380_channels, > @@ -163,6 +192,42 @@ static const struct ad7380_chip_info ad7384_chip_info = { > .timing_specs = &ad7380_timing, > }; > > +static const struct ad7380_chip_info ad7380_4_chip_info = { > + .name = "ad7380-4", > + .channels = ad7380_4_channels, > + .num_channels = ARRAY_SIZE(ad7380_4_channels), > + .available_scan_masks = ad7380_4_channel_scan_masks, > + .timing_specs = &ad7380_4_timing, > +}; > + > +static const struct ad7380_chip_info ad7381_4_chip_info = { > + .name = "ad7381-4", > + .channels = ad7381_4_channels, > + .num_channels = ARRAY_SIZE(ad7381_4_channels), > + .available_scan_masks = ad7380_4_channel_scan_masks, > + .timing_specs = &ad7380_4_timing, > +}; > + > +static const struct ad7380_chip_info ad7383_4_chip_info = { > + .name = "ad7383-4", > + .channels = ad7383_4_channels, > + .num_channels = ARRAY_SIZE(ad7383_4_channels), > + .vcm_supplies = ad7380_4_channel_vcm_supplies, > + .num_vcm_supplies = ARRAY_SIZE(ad7380_4_channel_vcm_supplies), > + .available_scan_masks = ad7380_4_channel_scan_masks, > + .timing_specs = &ad7380_4_timing, > +}; > + > +static const struct ad7380_chip_info ad7384_4_chip_info = { > + .name = "ad7384-4", > + .channels = ad7384_4_channels, > + .num_channels = ARRAY_SIZE(ad7384_4_channels), > + .vcm_supplies = ad7380_4_channel_vcm_supplies, > + .num_vcm_supplies = ARRAY_SIZE(ad7380_4_channel_vcm_supplies), > + .available_scan_masks = ad7380_4_channel_scan_masks, > + .timing_specs = &ad7380_4_timing, > +}; > + > struct ad7380_state { > const struct ad7380_chip_info *chip_info; > struct spi_device *spi; > @@ -514,6 +579,10 @@ static const struct of_device_id ad7380_of_match_table[] = { > { .compatible = "adi,ad7381", .data = &ad7381_chip_info }, > { .compatible = "adi,ad7383", .data = &ad7383_chip_info }, > { .compatible = "adi,ad7384", .data = &ad7384_chip_info }, > + { .compatible = "adi,ad7380-4", .data = &ad7380_4_chip_info }, > + { .compatible = "adi,ad7381-4", .data = &ad7381_4_chip_info }, > + { .compatible = "adi,ad7383-4", .data = &ad7383_4_chip_info }, > + { .compatible = "adi,ad7384-4", .data = &ad7384_4_chip_info }, > { } > }; > > @@ -522,6 +591,10 @@ static const struct spi_device_id ad7380_id_table[] = { > { "ad7381", (kernel_ulong_t)&ad7381_chip_info }, > { "ad7383", (kernel_ulong_t)&ad7383_chip_info }, > { "ad7384", (kernel_ulong_t)&ad7384_chip_info }, > + { "ad7380-4", (kernel_ulong_t)&ad7380_4_chip_info }, > + { "ad7381-4", (kernel_ulong_t)&ad7381_4_chip_info }, > + { "ad7383-4", (kernel_ulong_t)&ad7383_4_chip_info }, > + { "ad7384-4", (kernel_ulong_t)&ad7384_4_chip_info }, > { } > }; > MODULE_DEVICE_TABLE(spi, ad7380_id_table); >
On Sun, Mar 24, 2024 at 8:11 AM Jonathan Cameron <jic23@kernel.org> wrote: > > On Tue, 19 Mar 2024 11:11:28 +0100 > Julien Stephan <jstephan@baylibre.com> wrote: > > > Add support for ad7380/1/2/3-4 parts which are 4 channels > > variants from ad7380/1/2/3 > > > > Signed-off-by: Julien Stephan <jstephan@baylibre.com> > This and other patches I didn't comment on all look good to me. > So just those minor few bits and bobs for v6 and I'll pick this up > if nothing else comes in. > Hi Jonathan, as a reminder, this is the driver we dropped from the 6.9 cycle. We still don't have a patch prepared for the resolution boost feature that may require us to reconsider some of our userspace interface choices here. Hopefully we can get that sorted out in the next 6 weeks, but I just wanted to make you aware ahead of time so that we don't end up in the same situation in case things don't go as planned again. Do you have "usual" way you prefer to handle a situation like this?
On Mon, 25 Mar 2024 10:01:29 -0500 David Lechner <dlechner@baylibre.com> wrote: > On Sun, Mar 24, 2024 at 8:11 AM Jonathan Cameron <jic23@kernel.org> wrote: > > > > On Tue, 19 Mar 2024 11:11:28 +0100 > > Julien Stephan <jstephan@baylibre.com> wrote: > > > > > Add support for ad7380/1/2/3-4 parts which are 4 channels > > > variants from ad7380/1/2/3 > > > > > > Signed-off-by: Julien Stephan <jstephan@baylibre.com> > > This and other patches I didn't comment on all look good to me. > > So just those minor few bits and bobs for v6 and I'll pick this up > > if nothing else comes in. > > > > Hi Jonathan, as a reminder, this is the driver we dropped from the 6.9 > cycle. We still don't have a patch prepared for the resolution boost > feature that may require us to reconsider some of our userspace > interface choices here. Hopefully we can get that sorted out in the > next 6 weeks, but I just wanted to make you aware ahead of time so > that we don't end up in the same situation in case things don't go as > planned again. Do you have "usual" way you prefer to handle a > situation like this? My preferences: Post as an RFC with a comment on what is unresolved. I'll still review the RFC but won't apply until you let me know it's good to go (ideally by posting a non RFC version) Jonathan
diff --git a/drivers/iio/adc/ad7380.c b/drivers/iio/adc/ad7380.c index 3aca41ce9a14..cf9d2ace5f20 100644 --- a/drivers/iio/adc/ad7380.c +++ b/drivers/iio/adc/ad7380.c @@ -8,6 +8,9 @@ * Datasheets of supported parts: * ad7380/1 : https://www.analog.com/media/en/technical-documentation/data-sheets/AD7380-7381.pdf * ad7383/4 : https://www.analog.com/media/en/technical-documentation/data-sheets/ad7383-7384.pdf + * ad7380-4 : https://www.analog.com/media/en/technical-documentation/data-sheets/ad7380-4.pdf + * ad7381-4 : https://www.analog.com/media/en/technical-documentation/data-sheets/ad7381-4.pdf + * ad7383/4-4 : https://www.analog.com/media/en/technical-documentation/data-sheets/ad7383-4-ad7384-4.pdf */ #include <linux/bitfield.h> @@ -29,7 +32,7 @@ #include <linux/iio/trigger_consumer.h> #include <linux/iio/triggered_buffer.h> -#define MAX_NUM_CHANNELS 2 +#define MAX_NUM_CHANNELS 4 /* 2.5V internal reference voltage */ #define AD7380_INTERNAL_REF_MV 2500 @@ -106,27 +109,53 @@ static const struct iio_chan_spec name[] = { \ IIO_CHAN_SOFT_TIMESTAMP(2), \ } +#define DEFINE_AD7380_4_CHANNEL(name, bits, diff) \ +static const struct iio_chan_spec name[] = { \ + AD7380_CHANNEL(0, bits, diff), \ + AD7380_CHANNEL(1, bits, diff), \ + AD7380_CHANNEL(2, bits, diff), \ + AD7380_CHANNEL(3, bits, diff), \ + IIO_CHAN_SOFT_TIMESTAMP(4), \ +} + /* fully differential */ DEFINE_AD7380_2_CHANNEL(ad7380_channels, 16, 1); DEFINE_AD7380_2_CHANNEL(ad7381_channels, 14, 1); +DEFINE_AD7380_4_CHANNEL(ad7380_4_channels, 16, 1); +DEFINE_AD7380_4_CHANNEL(ad7381_4_channels, 14, 1); /* pseudo differential */ DEFINE_AD7380_2_CHANNEL(ad7383_channels, 16, 0); DEFINE_AD7380_2_CHANNEL(ad7384_channels, 14, 0); +DEFINE_AD7380_4_CHANNEL(ad7383_4_channels, 16, 0); +DEFINE_AD7380_4_CHANNEL(ad7384_4_channels, 14, 0); static const char * const ad7380_2_channel_vcm_supplies[] = { "aina", "ainb", }; +static const char * const ad7380_4_channel_vcm_supplies[] = { + "aina", "ainb", "ainc", "aind", +}; + /* Since this is simultaneous sampling, we don't allow individual channels. */ static const unsigned long ad7380_2_channel_scan_masks[] = { GENMASK(1, 0), 0 }; +static const unsigned long ad7380_4_channel_scan_masks[] = { + GENMASK(3, 0), + 0 +}; + static const struct ad7380_timing_specs ad7380_timing = { .t_csh_ns = 10, }; +static const struct ad7380_timing_specs ad7380_4_timing = { + .t_csh_ns = 20, +}; + static const struct ad7380_chip_info ad7380_chip_info = { .name = "ad7380", .channels = ad7380_channels, @@ -163,6 +192,42 @@ static const struct ad7380_chip_info ad7384_chip_info = { .timing_specs = &ad7380_timing, }; +static const struct ad7380_chip_info ad7380_4_chip_info = { + .name = "ad7380-4", + .channels = ad7380_4_channels, + .num_channels = ARRAY_SIZE(ad7380_4_channels), + .available_scan_masks = ad7380_4_channel_scan_masks, + .timing_specs = &ad7380_4_timing, +}; + +static const struct ad7380_chip_info ad7381_4_chip_info = { + .name = "ad7381-4", + .channels = ad7381_4_channels, + .num_channels = ARRAY_SIZE(ad7381_4_channels), + .available_scan_masks = ad7380_4_channel_scan_masks, + .timing_specs = &ad7380_4_timing, +}; + +static const struct ad7380_chip_info ad7383_4_chip_info = { + .name = "ad7383-4", + .channels = ad7383_4_channels, + .num_channels = ARRAY_SIZE(ad7383_4_channels), + .vcm_supplies = ad7380_4_channel_vcm_supplies, + .num_vcm_supplies = ARRAY_SIZE(ad7380_4_channel_vcm_supplies), + .available_scan_masks = ad7380_4_channel_scan_masks, + .timing_specs = &ad7380_4_timing, +}; + +static const struct ad7380_chip_info ad7384_4_chip_info = { + .name = "ad7384-4", + .channels = ad7384_4_channels, + .num_channels = ARRAY_SIZE(ad7384_4_channels), + .vcm_supplies = ad7380_4_channel_vcm_supplies, + .num_vcm_supplies = ARRAY_SIZE(ad7380_4_channel_vcm_supplies), + .available_scan_masks = ad7380_4_channel_scan_masks, + .timing_specs = &ad7380_4_timing, +}; + struct ad7380_state { const struct ad7380_chip_info *chip_info; struct spi_device *spi; @@ -514,6 +579,10 @@ static const struct of_device_id ad7380_of_match_table[] = { { .compatible = "adi,ad7381", .data = &ad7381_chip_info }, { .compatible = "adi,ad7383", .data = &ad7383_chip_info }, { .compatible = "adi,ad7384", .data = &ad7384_chip_info }, + { .compatible = "adi,ad7380-4", .data = &ad7380_4_chip_info }, + { .compatible = "adi,ad7381-4", .data = &ad7381_4_chip_info }, + { .compatible = "adi,ad7383-4", .data = &ad7383_4_chip_info }, + { .compatible = "adi,ad7384-4", .data = &ad7384_4_chip_info }, { } }; @@ -522,6 +591,10 @@ static const struct spi_device_id ad7380_id_table[] = { { "ad7381", (kernel_ulong_t)&ad7381_chip_info }, { "ad7383", (kernel_ulong_t)&ad7383_chip_info }, { "ad7384", (kernel_ulong_t)&ad7384_chip_info }, + { "ad7380-4", (kernel_ulong_t)&ad7380_4_chip_info }, + { "ad7381-4", (kernel_ulong_t)&ad7381_4_chip_info }, + { "ad7383-4", (kernel_ulong_t)&ad7383_4_chip_info }, + { "ad7384-4", (kernel_ulong_t)&ad7384_4_chip_info }, { } }; MODULE_DEVICE_TABLE(spi, ad7380_id_table);
Add support for ad7380/1/2/3-4 parts which are 4 channels variants from ad7380/1/2/3 Signed-off-by: Julien Stephan <jstephan@baylibre.com> --- drivers/iio/adc/ad7380.c | 75 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 74 insertions(+), 1 deletion(-)