* [PATCH RFC 0/4] ad7380: add adaq4370-4 and adaq4380-4 support
@ 2024-10-15 9:09 Julien Stephan
2024-10-15 9:09 ` [PATCH RFC 1/4] dt-bindings: iio: adc: ad7380: add adaq4370-4 and adaq4380-4 compatible parts Julien Stephan
` (4 more replies)
0 siblings, 5 replies; 16+ messages in thread
From: Julien Stephan @ 2024-10-15 9:09 UTC (permalink / raw)
To: Lars-Peter Clausen, Michael Hennerich, Nuno Sá,
David Lechner, Jonathan Cameron, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Jonathan Corbet
Cc: linux-iio, devicetree, linux-kernel, linux-doc, Julien Stephan
Hello,
This series add support for adaq4370-4 (2MSPS) and adaq4380-4 (4MSPS)
which are quad-channel precision data acquisition signal chain μModule
solutions compatible with the ad738x family, with the following differences:
- configurable gain in front of each 4 adc
- internal reference is 3V derived from refin-supply (5V)
- additional supplies
This series depends on [1] which fix several supplies issues
[1]: https://lore.kernel.org/all/20241007-ad7380-fix-supplies-v1-0-badcf813c9b9@baylibre.com/
Signed-off-by: Julien Stephan <jstephan@baylibre.com>
---
Julien Stephan (4):
dt-bindings: iio: adc: ad7380: add adaq4370-4 and adaq4380-4 compatible parts
iio: adc: ad7380: fix oversampling formula
iio: adc: ad7380: add support for adaq4370-4 and adaq4380-4
docs: iio: ad7380: add adaq4370-4 and adaq4380-4
.../devicetree/bindings/iio/adc/adi,ad7380.yaml | 117 ++++++++++++++++++
Documentation/iio/ad7380.rst | 15 +++
drivers/iio/adc/ad7380.c | 135 +++++++++++++++++++--
3 files changed, 258 insertions(+), 9 deletions(-)
---
base-commit: 8bea3878a1511bceadc2fbf284b00bcc5a2ef28d
change-id: 20241015-ad7380-add-adaq4380-4-support-14dc17ec0029
prerequisite-change-id: 20241004-ad7380-fix-supplies-3677365cf8aa:v1
prerequisite-patch-id: 6d87f69eed38931663a1fe4035d92bdddcc06da2
prerequisite-patch-id: 337292de00e31ecc2f71eac207542f236d8c0ff4
prerequisite-patch-id: 7dee57142d0d12682b0be3b62f1c16851aeac069
prerequisite-patch-id: 4ca1d234fa53f27d4e73150df5b00e245a142f67
prerequisite-patch-id: d42f3c478b92a6f97194853fac271add226803cf
prerequisite-patch-id: 972bdbf06bafa7c56f604dbe8eb7d236aadaad99
Best regards,
--
Julien Stephan <jstephan@baylibre.com>
^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH RFC 1/4] dt-bindings: iio: adc: ad7380: add adaq4370-4 and adaq4380-4 compatible parts
2024-10-15 9:09 [PATCH RFC 0/4] ad7380: add adaq4370-4 and adaq4380-4 support Julien Stephan
@ 2024-10-15 9:09 ` Julien Stephan
2024-10-15 20:49 ` Rob Herring
` (2 more replies)
2024-10-15 9:09 ` [PATCH RFC 2/4] iio: adc: ad7380: fix oversampling formula Julien Stephan
` (3 subsequent siblings)
4 siblings, 3 replies; 16+ messages in thread
From: Julien Stephan @ 2024-10-15 9:09 UTC (permalink / raw)
To: Lars-Peter Clausen, Michael Hennerich, Nuno Sá,
David Lechner, Jonathan Cameron, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Jonathan Corbet
Cc: linux-iio, devicetree, linux-kernel, linux-doc, Julien Stephan
adaq4370-4 (2MSPS) and adaq4380-4 (4MSPS) are quad-channel precision data
acquisition signal chain μModule solutions compatible with the ad738x
family, with the following differences:
- configurable gain in front of each 4 adc
- internal reference is 3V derived from refin-supply (5V)
- additional supplies
To configure the gain a new patternProperties is added to describe each
channel. It is restricted to adaq devices.
Signed-off-by: Julien Stephan <jstephan@baylibre.com>
---
.../devicetree/bindings/iio/adc/adi,ad7380.yaml | 117 +++++++++++++++++++++
1 file changed, 117 insertions(+)
diff --git a/Documentation/devicetree/bindings/iio/adc/adi,ad7380.yaml b/Documentation/devicetree/bindings/iio/adc/adi,ad7380.yaml
index 74d82721637c..3007d8e39684 100644
--- a/Documentation/devicetree/bindings/iio/adc/adi,ad7380.yaml
+++ b/Documentation/devicetree/bindings/iio/adc/adi,ad7380.yaml
@@ -25,6 +25,8 @@ description: |
* https://www.analog.com/en/products/ad7386-4.html
* https://www.analog.com/en/products/ad7387-4.html
* https://www.analog.com/en/products/ad7388-4.html
+ * https://www.analog.com/en/products/adaq4370-4.html
+ * https://www.analog.com/en/products/adaq4380-4.html
$ref: /schemas/spi/spi-peripheral-props.yaml#
@@ -46,6 +48,8 @@ properties:
- adi,ad7386-4
- adi,ad7387-4
- adi,ad7388-4
+ - adi,adaq4370-4
+ - adi,adaq4380-4
reg:
maxItems: 1
@@ -59,6 +63,9 @@ properties:
vlogic-supply: true
refio-supply: true
refin-supply: true
+ vs-p-supply: true
+ vs-n-supply: true
+ ldo-supply: true
aina-supply:
description:
@@ -86,12 +93,43 @@ properties:
specify the ALERT interrupt.
maxItems: 1
+ '#address-cells':
+ const: 1
+
+ '#size-cells':
+ const: 0
+
required:
- compatible
- reg
- vcc-supply
- vlogic-supply
+patternProperties:
+ "^channel@([0-3])$":
+ $ref: adc.yaml
+ type: object
+
+ properties:
+ reg:
+ description:
+ The channel number. From 0 to 3 corresponding to channels A,B,C,D
+ items:
+ minimum: 0
+ maximum: 3
+
+ adi,gain-milli:
+ description:
+ The hardware gain applied to the ADC input (in milli units).
+ If not present, default to 1000 (no actual gain applied).
+ $ref: /schemas/types.yaml#/definitions/uint32
+ default: 1000
+
+ required:
+ - reg
+
+ additionalProperties: false
+
unevaluatedProperties: false
allOf:
@@ -128,7 +166,21 @@ allOf:
ainc-supply: false
aind-supply: false
+ # Using channel to declare gain property only applies to adaq devices
+ - if:
+ properties:
+ compatible:
+ not:
+ contains:
+ enum:
+ - adi,adaq4370-4
+ - adi,adaq4380-4
+ then:
+ patternProperties:
+ "^channel@([0-3])$": false
+
# ad7380-4 uses refin-supply as external reference.
+ # adaq devices use internal reference only, derived from refin-supply
# All other chips from ad738x family use refio as optional external reference.
# When refio-supply is omitted, internal reference is used.
- if:
@@ -136,6 +188,8 @@ allOf:
compatible:
enum:
- adi,ad7380-4
+ - adi,adaq4370-4
+ - adi,adaq4380-4
then:
properties:
refio-supply: false
@@ -145,6 +199,24 @@ allOf:
properties:
refin-supply: false
+ # adaq devices need more supplies
+ - if:
+ properties:
+ compatible:
+ enum:
+ - adi,adaq4370-4
+ - adi,adaq4380-4
+ then:
+ required:
+ - vs-p-supply
+ - vs-n-supply
+ - ldo-supply
+ else:
+ properties:
+ vs-p-supply: false
+ vs-n-supply: false
+ ldo-supply: false
+
examples:
- |
#include <dt-bindings/interrupt-controller/irq.h>
@@ -169,3 +241,48 @@ examples:
refio-supply = <&supply_2_5V>;
};
};
+
+ - |
+ #include <dt-bindings/interrupt-controller/irq.h>
+
+ spi {
+ #address-cells = <1>;
+ #size-cells = <0>;
+
+ adc@0 {
+ compatible = "adi,adaq4380-4";
+ 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>;
+ refin-supply = <&supply_5V>;
+ vs-p-supply = <&supply_5V>;
+ vs-n-supply = <&supply_0V>;
+ ldo-supply = <&supply_5V>;
+
+ #address-cells = <1>;
+ #size-cells = <0>;
+
+ channel@0 {
+ reg = <0>;
+ adi,gain-milli = <300>;
+ };
+
+ channel@2 {
+ reg = <2>;
+ adi,gain-milli = <600>;
+ };
+
+ channel@3 {
+ reg = <3>;
+ adi,gain-milli = <1000>;
+ };
+ };
+ };
--
2.46.0
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH RFC 2/4] iio: adc: ad7380: fix oversampling formula
2024-10-15 9:09 [PATCH RFC 0/4] ad7380: add adaq4370-4 and adaq4380-4 support Julien Stephan
2024-10-15 9:09 ` [PATCH RFC 1/4] dt-bindings: iio: adc: ad7380: add adaq4370-4 and adaq4380-4 compatible parts Julien Stephan
@ 2024-10-15 9:09 ` Julien Stephan
2024-10-15 9:09 ` [PATCH RFC 3/4] iio: adc: ad7380: add support for adaq4370-4 and adaq4380-4 Julien Stephan
` (2 subsequent siblings)
4 siblings, 0 replies; 16+ messages in thread
From: Julien Stephan @ 2024-10-15 9:09 UTC (permalink / raw)
To: Lars-Peter Clausen, Michael Hennerich, Nuno Sá,
David Lechner, Jonathan Cameron, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Jonathan Corbet
Cc: linux-iio, devicetree, linux-kernel, linux-doc, Julien Stephan
The formula in the datasheet for oversampling time conversion seems to
be valid when device is at full speed using the maximum number of SDO
lines. The driver currently support only 1 SDO line. The formula will
produce larger delays than what is currently set, but some devices
actually require it.
Signed-off-by: Julien Stephan <jstephan@baylibre.com>
---
drivers/iio/adc/ad7380.c | 19 ++++++++++++++-----
1 file changed, 14 insertions(+), 5 deletions(-)
diff --git a/drivers/iio/adc/ad7380.c b/drivers/iio/adc/ad7380.c
index e9784769baa9..15ca85c70ebd 100644
--- a/drivers/iio/adc/ad7380.c
+++ b/drivers/iio/adc/ad7380.c
@@ -77,6 +77,12 @@
#define T_CONVERT_X_NS 500 /* xth conversion start time (oversampling) */
#define T_POWERUP_MS 5 /* Power up */
+/*
+ * AD738x support several SDO lines to increase throughput, but driver currently
+ * supports only 1 SDO line (standard SPI transaction)
+ */
+#define AD7380_NUM_SDO_LINES 1
+
struct ad7380_timing_specs {
const unsigned int t_csh_ns; /* CS minimum high time */
};
@@ -649,7 +655,8 @@ static int ad7380_set_ch(struct ad7380_state *st, unsigned int ch)
if (st->oversampling_ratio > 1)
xfer.delay.value = T_CONVERT_0_NS +
- T_CONVERT_X_NS * (st->oversampling_ratio - 1);
+ T_CONVERT_X_NS * (st->oversampling_ratio - 1) *
+ st->chip_info->num_simult_channels / AD7380_NUM_SDO_LINES;
return spi_sync_transfer(st->spi, &xfer, 1);
}
@@ -667,12 +674,13 @@ static void ad7380_update_xfers(struct ad7380_state *st,
/*
* In the case of oversampling, conversion time is higher than in normal
- * mode. Technically T_CONVERT_X_NS is lower for some chips, but we use
- * the maximum value for simplicity for now.
+ * mode: t_convert = T_CONVERT_0_NS + T_CONVERT_X_NS*(x - 1)*num_channel/number_of_sdo_lines
+ * where x is the oversampling ratio
*/
if (st->oversampling_ratio > 1)
t_convert = T_CONVERT_0_NS + T_CONVERT_X_NS *
- (st->oversampling_ratio - 1);
+ (st->oversampling_ratio - 1) *
+ st->chip_info->num_simult_channels / AD7380_NUM_SDO_LINES;
if (st->seq) {
xfer[0].delay.value = xfer[1].delay.value = t_convert;
@@ -1021,7 +1029,8 @@ static int ad7380_init(struct ad7380_state *st, bool external_ref_en)
/* SPI 1-wire mode */
return regmap_update_bits(st->regmap, AD7380_REG_ADDR_CONFIG2,
AD7380_CONFIG2_SDO,
- FIELD_PREP(AD7380_CONFIG2_SDO, 1));
+ FIELD_PREP(AD7380_CONFIG2_SDO,
+ AD7380_NUM_SDO_LINES));
}
static int ad7380_probe(struct spi_device *spi)
--
2.46.0
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH RFC 3/4] iio: adc: ad7380: add support for adaq4370-4 and adaq4380-4
2024-10-15 9:09 [PATCH RFC 0/4] ad7380: add adaq4370-4 and adaq4380-4 support Julien Stephan
2024-10-15 9:09 ` [PATCH RFC 1/4] dt-bindings: iio: adc: ad7380: add adaq4370-4 and adaq4380-4 compatible parts Julien Stephan
2024-10-15 9:09 ` [PATCH RFC 2/4] iio: adc: ad7380: fix oversampling formula Julien Stephan
@ 2024-10-15 9:09 ` Julien Stephan
2024-10-20 13:18 ` Jonathan Cameron
2024-10-15 9:09 ` [PATCH RFC 4/4] docs: iio: ad7380: add " Julien Stephan
2024-10-15 16:43 ` [PATCH RFC 0/4] ad7380: add adaq4370-4 and adaq4380-4 support Conor Dooley
4 siblings, 1 reply; 16+ messages in thread
From: Julien Stephan @ 2024-10-15 9:09 UTC (permalink / raw)
To: Lars-Peter Clausen, Michael Hennerich, Nuno Sá,
David Lechner, Jonathan Cameron, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Jonathan Corbet
Cc: linux-iio, devicetree, linux-kernel, linux-doc, Julien Stephan
adaq4370-4 (2MSPS) and adaq4380-4 (4MSPS) are quad-channel precision data
acquisition signal chain μModule solutions compatible with the ad738x
family, with the following differences:
- configurable gain in front of each 4 adc
- internal reference is 3V derived from refin-supply (5V)
- additional supplies
This implies that IIO_CHAN_INFO_SCALE can not be shared by type.
Signed-off-by: Julien Stephan <jstephan@baylibre.com>
---
drivers/iio/adc/ad7380.c | 116 +++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 112 insertions(+), 4 deletions(-)
diff --git a/drivers/iio/adc/ad7380.c b/drivers/iio/adc/ad7380.c
index 15ca85c70ebd..12c19913d75d 100644
--- a/drivers/iio/adc/ad7380.c
+++ b/drivers/iio/adc/ad7380.c
@@ -13,6 +13,8 @@
* 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
* ad7386/7/8-4 : https://www.analog.com/media/en/technical-documentation/data-sheets/ad7386-4-7387-4-7388-4.pdf
+ * adaq4370-4 : https://www.analog.com/media/en/technical-documentation/data-sheets/adaq4370-4.pdf
+ * adaq4380-4 : https://www.analog.com/media/en/technical-documentation/data-sheets/adaq4380-4.pdf
*/
#include <linux/align.h>
@@ -22,11 +24,13 @@
#include <linux/device.h>
#include <linux/err.h>
#include <linux/kernel.h>
+#include <linux/math.h>
#include <linux/module.h>
#include <linux/regmap.h>
#include <linux/regulator/consumer.h>
#include <linux/slab.h>
#include <linux/spi/spi.h>
+#include <linux/units.h>
#include <linux/iio/buffer.h>
#include <linux/iio/iio.h>
@@ -36,6 +40,8 @@
#define MAX_NUM_CHANNELS 8
/* 2.5V internal reference voltage */
#define AD7380_INTERNAL_REF_MV 2500
+/* 3.3V internal reference voltage for ADAQ */
+#define ADAQ4380_INTERNAL_REF_MV 3300
/* reading and writing registers is more reliable at lower than max speed */
#define AD7380_REG_WR_SPEED_HZ 10000000
@@ -82,6 +88,7 @@
* supports only 1 SDO line (standard SPI transaction)
*/
#define AD7380_NUM_SDO_LINES 1
+#define AD7380_DEFAULT_GAIN_MILLI 1000
struct ad7380_timing_specs {
const unsigned int t_csh_ns; /* CS minimum high time */
@@ -92,10 +99,12 @@ struct ad7380_chip_info {
const struct iio_chan_spec *channels;
unsigned int num_channels;
unsigned int num_simult_channels;
+ bool has_hardware_gain;
bool has_mux;
const char * const *supplies;
unsigned int num_supplies;
bool external_ref_only;
+ bool adaq_internal_ref_only;
const char * const *vcm_supplies;
unsigned int num_vcm_supplies;
const unsigned long *available_scan_masks;
@@ -187,11 +196,12 @@ static const struct iio_scan_type ad7380_scan_type_16_u[] = {
},
};
-#define AD7380_CHANNEL(index, bits, diff, sign) { \
+#define _AD7380_CHANNEL(index, bits, diff, sign, gain) { \
.type = IIO_VOLTAGE, \
.info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | \
+ ((gain) ? BIT(IIO_CHAN_INFO_SCALE) : 0) | \
((diff) ? 0 : BIT(IIO_CHAN_INFO_OFFSET)), \
- .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE) | \
+ .info_mask_shared_by_type = ((gain) ? 0 : BIT(IIO_CHAN_INFO_SCALE)) | \
BIT(IIO_CHAN_INFO_OVERSAMPLING_RATIO), \
.info_mask_shared_by_type_available = \
BIT(IIO_CHAN_INFO_OVERSAMPLING_RATIO), \
@@ -205,6 +215,12 @@ static const struct iio_scan_type ad7380_scan_type_16_u[] = {
.num_ext_scan_type = ARRAY_SIZE(ad7380_scan_type_##bits##_##sign), \
}
+#define AD7380_CHANNEL(index, bits, diff, sign) \
+ _AD7380_CHANNEL(index, bits, diff, sign, false)
+
+#define ADAQ4380_CHANNEL(index, bits, diff, sign) \
+ _AD7380_CHANNEL(index, bits, diff, sign, true)
+
#define DEFINE_AD7380_2_CHANNEL(name, bits, diff, sign) \
static const struct iio_chan_spec name[] = { \
AD7380_CHANNEL(0, bits, diff, sign), \
@@ -221,6 +237,15 @@ static const struct iio_chan_spec name[] = { \
IIO_CHAN_SOFT_TIMESTAMP(4), \
}
+#define DEFINE_ADAQ4380_4_CHANNEL(name, bits, diff, sign) \
+static const struct iio_chan_spec name[] = { \
+ ADAQ4380_CHANNEL(0, bits, diff, sign), \
+ ADAQ4380_CHANNEL(1, bits, diff, sign), \
+ ADAQ4380_CHANNEL(2, bits, diff, sign), \
+ ADAQ4380_CHANNEL(3, bits, diff, sign), \
+ IIO_CHAN_SOFT_TIMESTAMP(4), \
+}
+
#define DEFINE_AD7380_8_CHANNEL(name, bits, diff, sign) \
static const struct iio_chan_spec name[] = { \
AD7380_CHANNEL(0, bits, diff, sign), \
@@ -239,6 +264,7 @@ DEFINE_AD7380_2_CHANNEL(ad7380_channels, 16, 1, s);
DEFINE_AD7380_2_CHANNEL(ad7381_channels, 14, 1, s);
DEFINE_AD7380_4_CHANNEL(ad7380_4_channels, 16, 1, s);
DEFINE_AD7380_4_CHANNEL(ad7381_4_channels, 14, 1, s);
+DEFINE_ADAQ4380_4_CHANNEL(adaq4380_4_channels, 16, 1, s);
/* pseudo differential */
DEFINE_AD7380_2_CHANNEL(ad7383_channels, 16, 0, s);
DEFINE_AD7380_2_CHANNEL(ad7384_channels, 14, 0, s);
@@ -257,6 +283,10 @@ static const char * const ad7380_supplies[] = {
"vcc", "vlogic",
};
+static const char * const adaq4380_supplies[] = {
+ "ldo", "vcc", "vlogic", "vs-p", "vs-n", "refin",
+};
+
static const char * const ad7380_2_channel_vcm_supplies[] = {
"aina", "ainb",
};
@@ -516,6 +546,32 @@ static const struct ad7380_chip_info ad7388_4_chip_info = {
.timing_specs = &ad7380_4_timing,
};
+static const struct ad7380_chip_info adaq4370_4_chip_info = {
+ .name = "adaq4370-4",
+ .channels = adaq4380_4_channels,
+ .num_channels = ARRAY_SIZE(adaq4380_4_channels),
+ .num_simult_channels = 4,
+ .supplies = adaq4380_supplies,
+ .num_supplies = ARRAY_SIZE(adaq4380_supplies),
+ .adaq_internal_ref_only = true,
+ .has_hardware_gain = true,
+ .available_scan_masks = ad7380_4_channel_scan_masks,
+ .timing_specs = &ad7380_4_timing,
+};
+
+static const struct ad7380_chip_info adaq4380_4_chip_info = {
+ .name = "adaq4380-4",
+ .channels = adaq4380_4_channels,
+ .num_channels = ARRAY_SIZE(adaq4380_4_channels),
+ .num_simult_channels = 4,
+ .supplies = adaq4380_supplies,
+ .num_supplies = ARRAY_SIZE(adaq4380_supplies),
+ .adaq_internal_ref_only = true,
+ .has_hardware_gain = true,
+ .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;
@@ -526,6 +582,7 @@ struct ad7380_state {
bool seq;
unsigned int vref_mv;
unsigned int vcm_mv[MAX_NUM_CHANNELS];
+ unsigned int gain_milli[MAX_NUM_CHANNELS];
/* xfers, message an buffer for reading sample data */
struct spi_transfer normal_xfer[2];
struct spi_message normal_msg;
@@ -876,8 +933,15 @@ static int ad7380_read_raw(struct iio_dev *indio_dev,
* * (2 × VREF) / 2^N, for differential chips
* * VREF / 2^N, for pseudo-differential chips
* where N is the ADC resolution (i.e realbits)
+ *
+ * The gain is stored as a fraction of 1000 and, as we need to
+ * divide vref_mv by the gain, we invert the gain/1000 fraction.
*/
- *val = st->vref_mv;
+ if (st->chip_info->has_hardware_gain)
+ *val = mult_frac(st->vref_mv, MILLI,
+ st->gain_milli[chan->scan_index]);
+ else
+ *val = st->vref_mv;
*val2 = scan_type->realbits - chan->differential;
return IIO_VAL_FRACTIONAL_LOG2;
@@ -1058,7 +1122,19 @@ static int ad7380_probe(struct spi_device *spi)
"Failed to enable power supplies\n");
msleep(T_POWERUP_MS);
- if (st->chip_info->external_ref_only) {
+ if (st->chip_info->adaq_internal_ref_only) {
+ /*
+ * ADAQ chips use fixed internal reference but still
+ * require an external reference supply to power it.
+ * "refin" is already enabled with other power supplies
+ * in bulk_get_enable().
+ */
+
+ st->vref_mv = ADAQ4380_INTERNAL_REF_MV;
+
+ /* these chips don't have a register bit for this */
+ external_ref_en = false;
+ } else if (st->chip_info->external_ref_only) {
ret = devm_regulator_get_enable_read_voltage(&spi->dev,
"refin");
if (ret < 0)
@@ -1104,6 +1180,34 @@ static int ad7380_probe(struct spi_device *spi)
st->vcm_mv[i] = ret / 1000;
}
+ for (i = 0; i < MAX_NUM_CHANNELS; i++)
+ st->gain_milli[i] = AD7380_DEFAULT_GAIN_MILLI;
+
+ if (st->chip_info->has_hardware_gain) {
+ device_for_each_child_node_scoped(&spi->dev, node) {
+ unsigned int channel, gain;
+
+ ret = fwnode_property_read_u32(node, "reg", &channel);
+ if (ret)
+ return dev_err_probe(&spi->dev, ret,
+ "Failed to read reg property\n");
+
+ if (channel >= st->chip_info->num_channels - 1)
+ return dev_err_probe(&spi->dev, -EINVAL,
+ "Invalid channel number %i\n",
+ channel);
+
+ ret = fwnode_property_read_u32(node, "adi,gain-milli",
+ &gain);
+ if (ret && ret != -EINVAL)
+ return dev_err_probe(&spi->dev, ret,
+ "Failed to read gain for channel %i\n",
+ channel);
+ if (ret != -EINVAL)
+ st->gain_milli[channel] = gain;
+ }
+ }
+
st->regmap = devm_regmap_init(&spi->dev, NULL, st, &ad7380_regmap_config);
if (IS_ERR(st->regmap))
return dev_err_probe(&spi->dev, PTR_ERR(st->regmap),
@@ -1186,6 +1290,8 @@ static const struct of_device_id ad7380_of_match_table[] = {
{ .compatible = "adi,ad7386-4", .data = &ad7386_4_chip_info },
{ .compatible = "adi,ad7387-4", .data = &ad7387_4_chip_info },
{ .compatible = "adi,ad7388-4", .data = &ad7388_4_chip_info },
+ { .compatible = "adi,adaq4370-4", .data = &adaq4370_4_chip_info },
+ { .compatible = "adi,adaq4380-4", .data = &adaq4380_4_chip_info },
{ }
};
@@ -1204,6 +1310,8 @@ static const struct spi_device_id ad7380_id_table[] = {
{ "ad7386-4", (kernel_ulong_t)&ad7386_4_chip_info },
{ "ad7387-4", (kernel_ulong_t)&ad7387_4_chip_info },
{ "ad7388-4", (kernel_ulong_t)&ad7388_4_chip_info },
+ { "adaq4370-4", (kernel_ulong_t)&adaq4370_4_chip_info },
+ { "adaq4380-4", (kernel_ulong_t)&adaq4380_4_chip_info },
{ }
};
MODULE_DEVICE_TABLE(spi, ad7380_id_table);
--
2.46.0
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH RFC 4/4] docs: iio: ad7380: add adaq4370-4 and adaq4380-4
2024-10-15 9:09 [PATCH RFC 0/4] ad7380: add adaq4370-4 and adaq4380-4 support Julien Stephan
` (2 preceding siblings ...)
2024-10-15 9:09 ` [PATCH RFC 3/4] iio: adc: ad7380: add support for adaq4370-4 and adaq4380-4 Julien Stephan
@ 2024-10-15 9:09 ` Julien Stephan
2024-10-15 16:43 ` [PATCH RFC 0/4] ad7380: add adaq4370-4 and adaq4380-4 support Conor Dooley
4 siblings, 0 replies; 16+ messages in thread
From: Julien Stephan @ 2024-10-15 9:09 UTC (permalink / raw)
To: Lars-Peter Clausen, Michael Hennerich, Nuno Sá,
David Lechner, Jonathan Cameron, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Jonathan Corbet
Cc: linux-iio, devicetree, linux-kernel, linux-doc, Julien Stephan
Adding documentation for adaq4370-4 and adaq4380-4 supported devices. In
particular, document the reference voltage mechanism and the gain
parameter that are specific to adaq devices.
Signed-off-by: Julien Stephan <jstephan@baylibre.com>
---
Documentation/iio/ad7380.rst | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/Documentation/iio/ad7380.rst b/Documentation/iio/ad7380.rst
index 6f70b49b9ef2..eeffd19db642 100644
--- a/Documentation/iio/ad7380.rst
+++ b/Documentation/iio/ad7380.rst
@@ -27,6 +27,8 @@ The following chips are supported by this driver:
* `AD7386-4 <https://www.analog.com/en/products/ad7386-4.html>`_
* `AD7387-4 <https://www.analog.com/en/products/ad7387-4.html>`_
* `AD7388-4 <https://www.analog.com/en/products/ad7388-4.html>`_
+* `ADAQ4370-4 <https://www.analog.com/en/products/adaq4370-4.html>`_
+* `ADAQ4380-4 <https://www.analog.com/en/products/adaq4380-4.html>`_
Supported features
@@ -47,6 +49,12 @@ ad7380-4
ad7380-4 supports only an external reference voltage (2.5V to 3.3V). It must be
declared in the device tree as ``refin-supply``.
+adaq devices
+~~~~~~~~~~~~
+
+adaq4370-4 and adaq4380-4 don't have an external reference, but use a 3V
+internal reference derived from one of its supplies (``refin-supply``)
+
All other devices from ad738x family
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -121,6 +129,13 @@ Example for AD7386/7/8 (2 channels parts):
When enabling sequencer mode, the effective sampling rate is divided by two.
+
+Gain (adaq devices only)
+~~~~~~~~~~~~~~~~~~~~~~~~
+
+adaq devices have a configurable gain in front of each adc. The appropriate gain
+is selectable from device tree using the ``adi,gain-milli`` property.
+
Unimplemented features
----------------------
--
2.46.0
^ permalink raw reply related [flat|nested] 16+ messages in thread
* Re: [PATCH RFC 0/4] ad7380: add adaq4370-4 and adaq4380-4 support
2024-10-15 9:09 [PATCH RFC 0/4] ad7380: add adaq4370-4 and adaq4380-4 support Julien Stephan
` (3 preceding siblings ...)
2024-10-15 9:09 ` [PATCH RFC 4/4] docs: iio: ad7380: add " Julien Stephan
@ 2024-10-15 16:43 ` Conor Dooley
2024-10-16 7:25 ` Julien Stephan
4 siblings, 1 reply; 16+ messages in thread
From: Conor Dooley @ 2024-10-15 16:43 UTC (permalink / raw)
To: Julien Stephan
Cc: Lars-Peter Clausen, Michael Hennerich, Nuno Sá,
David Lechner, Jonathan Cameron, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Jonathan Corbet, linux-iio, devicetree,
linux-kernel, linux-doc
[-- Attachment #1: Type: text/plain, Size: 666 bytes --]
On Tue, Oct 15, 2024 at 11:09:05AM +0200, Julien Stephan wrote:
> Hello,
>
> This series add support for adaq4370-4 (2MSPS) and adaq4380-4 (4MSPS)
> which are quad-channel precision data acquisition signal chain μModule
> solutions compatible with the ad738x family, with the following differences:
>
> - configurable gain in front of each 4 adc
> - internal reference is 3V derived from refin-supply (5V)
> - additional supplies
>
> This series depends on [1] which fix several supplies issues
>
> [1]: https://lore.kernel.org/all/20241007-ad7380-fix-supplies-v1-0-badcf813c9b9@baylibre.com/
What exactly makes this series RFC rather than v1?
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH RFC 1/4] dt-bindings: iio: adc: ad7380: add adaq4370-4 and adaq4380-4 compatible parts
2024-10-15 9:09 ` [PATCH RFC 1/4] dt-bindings: iio: adc: ad7380: add adaq4370-4 and adaq4380-4 compatible parts Julien Stephan
@ 2024-10-15 20:49 ` Rob Herring
2024-10-17 18:05 ` Jonathan Cameron
2024-10-20 13:20 ` Jonathan Cameron
2 siblings, 0 replies; 16+ messages in thread
From: Rob Herring @ 2024-10-15 20:49 UTC (permalink / raw)
To: Julien Stephan
Cc: Lars-Peter Clausen, Michael Hennerich, Nuno Sá,
David Lechner, Jonathan Cameron, Krzysztof Kozlowski,
Conor Dooley, Jonathan Corbet, linux-iio, devicetree,
linux-kernel, linux-doc
On Tue, Oct 15, 2024 at 11:09:06AM +0200, Julien Stephan wrote:
> adaq4370-4 (2MSPS) and adaq4380-4 (4MSPS) are quad-channel precision data
> acquisition signal chain μModule solutions compatible with the ad738x
> family, with the following differences:
>
> - configurable gain in front of each 4 adc
> - internal reference is 3V derived from refin-supply (5V)
> - additional supplies
>
> To configure the gain a new patternProperties is added to describe each
> channel. It is restricted to adaq devices.
>
> Signed-off-by: Julien Stephan <jstephan@baylibre.com>
> ---
> .../devicetree/bindings/iio/adc/adi,ad7380.yaml | 117 +++++++++++++++++++++
> 1 file changed, 117 insertions(+)
>
> diff --git a/Documentation/devicetree/bindings/iio/adc/adi,ad7380.yaml b/Documentation/devicetree/bindings/iio/adc/adi,ad7380.yaml
> index 74d82721637c..3007d8e39684 100644
> --- a/Documentation/devicetree/bindings/iio/adc/adi,ad7380.yaml
> +++ b/Documentation/devicetree/bindings/iio/adc/adi,ad7380.yaml
> @@ -25,6 +25,8 @@ description: |
> * https://www.analog.com/en/products/ad7386-4.html
> * https://www.analog.com/en/products/ad7387-4.html
> * https://www.analog.com/en/products/ad7388-4.html
> + * https://www.analog.com/en/products/adaq4370-4.html
> + * https://www.analog.com/en/products/adaq4380-4.html
>
>
> $ref: /schemas/spi/spi-peripheral-props.yaml#
> @@ -46,6 +48,8 @@ properties:
> - adi,ad7386-4
> - adi,ad7387-4
> - adi,ad7388-4
> + - adi,adaq4370-4
> + - adi,adaq4380-4
>
> reg:
> maxItems: 1
> @@ -59,6 +63,9 @@ properties:
> vlogic-supply: true
> refio-supply: true
> refin-supply: true
> + vs-p-supply: true
> + vs-n-supply: true
> + ldo-supply: true
>
> aina-supply:
> description:
> @@ -86,12 +93,43 @@ properties:
> specify the ALERT interrupt.
> maxItems: 1
>
> + '#address-cells':
> + const: 1
> +
> + '#size-cells':
> + const: 0
> +
> required:
> - compatible
> - reg
> - vcc-supply
> - vlogic-supply
>
> +patternProperties:
> + "^channel@([0-3])$":
> + $ref: adc.yaml
> + type: object
> +
> + properties:
> + reg:
> + description:
> + The channel number. From 0 to 3 corresponding to channels A,B,C,D
> + items:
> + minimum: 0
> + maximum: 3
This allows mutiple entries. Is that intended? If so, define the range
(minItems/maxItems). If not, drop 'items'.
> +
> + adi,gain-milli:
> + description:
> + The hardware gain applied to the ADC input (in milli units).
> + If not present, default to 1000 (no actual gain applied).
> + $ref: /schemas/types.yaml#/definitions/uint32
Elsewhere the same property is a uint16. Don't define different types
for the same property name.
> + default: 1000
Constraints? minimum/maximum/enum?
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH RFC 0/4] ad7380: add adaq4370-4 and adaq4380-4 support
2024-10-15 16:43 ` [PATCH RFC 0/4] ad7380: add adaq4370-4 and adaq4380-4 support Conor Dooley
@ 2024-10-16 7:25 ` Julien Stephan
2024-10-18 18:11 ` Jonathan Cameron
0 siblings, 1 reply; 16+ messages in thread
From: Julien Stephan @ 2024-10-16 7:25 UTC (permalink / raw)
To: Conor Dooley
Cc: Lars-Peter Clausen, Michael Hennerich, Nuno Sá,
David Lechner, Jonathan Cameron, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Jonathan Corbet, linux-iio, devicetree,
linux-kernel, linux-doc
Le mar. 15 oct. 2024 à 18:43, Conor Dooley <conor@kernel.org> a écrit :
>
> On Tue, Oct 15, 2024 at 11:09:05AM +0200, Julien Stephan wrote:
> > Hello,
> >
> > This series add support for adaq4370-4 (2MSPS) and adaq4380-4 (4MSPS)
> > which are quad-channel precision data acquisition signal chain μModule
> > solutions compatible with the ad738x family, with the following differences:
> >
> > - configurable gain in front of each 4 adc
> > - internal reference is 3V derived from refin-supply (5V)
> > - additional supplies
> >
> > This series depends on [1] which fix several supplies issues
> >
> > [1]: https://lore.kernel.org/all/20241007-ad7380-fix-supplies-v1-0-badcf813c9b9@baylibre.com/
>
> What exactly makes this series RFC rather than v1?
Hi Conor,
I am sorry I forgot to add some context here... There is an ongoing
discussion on the dependent series about power supplies and Jonathan
asked me to send this series to see how to properly handle the supply
fix...
See https://lore.kernel.org/all/20241014193701.40e3785a@jic23-huawei/
Cheers,
Julien
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH RFC 1/4] dt-bindings: iio: adc: ad7380: add adaq4370-4 and adaq4380-4 compatible parts
2024-10-15 9:09 ` [PATCH RFC 1/4] dt-bindings: iio: adc: ad7380: add adaq4370-4 and adaq4380-4 compatible parts Julien Stephan
2024-10-15 20:49 ` Rob Herring
@ 2024-10-17 18:05 ` Jonathan Cameron
2024-10-18 7:36 ` Julien Stephan
2024-10-20 13:20 ` Jonathan Cameron
2 siblings, 1 reply; 16+ messages in thread
From: Jonathan Cameron @ 2024-10-17 18:05 UTC (permalink / raw)
To: Julien Stephan
Cc: Lars-Peter Clausen, Michael Hennerich, Nuno Sá,
David Lechner, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Jonathan Corbet, linux-iio, devicetree, linux-kernel, linux-doc
On Tue, 15 Oct 2024 11:09:06 +0200
Julien Stephan <jstephan@baylibre.com> wrote:
> adaq4370-4 (2MSPS) and adaq4380-4 (4MSPS) are quad-channel precision data
> acquisition signal chain μModule solutions compatible with the ad738x
> family, with the following differences:
>
> - configurable gain in front of each 4 adc
> - internal reference is 3V derived from refin-supply (5V)
Now I'm confused.
The earlier refin-supply change appears unused in this patch.
I was expecting it to be required for the additional devices.
With additions to the docs from the fix to explain the new
cases. I'm not seeing that in here.
> - additional supplies
>
> To configure the gain a new patternProperties is added to describe each
> channel. It is restricted to adaq devices.
>
> Signed-off-by: Julien Stephan <jstephan@baylibre.com>
> ---
> .../devicetree/bindings/iio/adc/adi,ad7380.yaml | 117 +++++++++++++++++++++
> 1 file changed, 117 insertions(+)
>
> diff --git a/Documentation/devicetree/bindings/iio/adc/adi,ad7380.yaml b/Documentation/devicetree/bindings/iio/adc/adi,ad7380.yaml
> index 74d82721637c..3007d8e39684 100644
> --- a/Documentation/devicetree/bindings/iio/adc/adi,ad7380.yaml
> +++ b/Documentation/devicetree/bindings/iio/adc/adi,ad7380.yaml
> @@ -25,6 +25,8 @@ description: |
> * https://www.analog.com/en/products/ad7386-4.html
> * https://www.analog.com/en/products/ad7387-4.html
> * https://www.analog.com/en/products/ad7388-4.html
> + * https://www.analog.com/en/products/adaq4370-4.html
> + * https://www.analog.com/en/products/adaq4380-4.html
>
>
> $ref: /schemas/spi/spi-peripheral-props.yaml#
> @@ -46,6 +48,8 @@ properties:
> - adi,ad7386-4
> - adi,ad7387-4
> - adi,ad7388-4
> + - adi,adaq4370-4
> + - adi,adaq4380-4
>
> reg:
> maxItems: 1
> @@ -59,6 +63,9 @@ properties:
> vlogic-supply: true
> refio-supply: true
> refin-supply: true
> + vs-p-supply: true
> + vs-n-supply: true
> + ldo-supply: true
>
> aina-supply:
> description:
> @@ -86,12 +93,43 @@ properties:
> specify the ALERT interrupt.
> maxItems: 1
>
> + '#address-cells':
> + const: 1
> +
> + '#size-cells':
> + const: 0
> +
> required:
> - compatible
> - reg
> - vcc-supply
> - vlogic-supply
>
> +patternProperties:
> + "^channel@([0-3])$":
> + $ref: adc.yaml
> + type: object
> +
> + properties:
> + reg:
> + description:
> + The channel number. From 0 to 3 corresponding to channels A,B,C,D
> + items:
> + minimum: 0
> + maximum: 3
> +
> + adi,gain-milli:
> + description:
> + The hardware gain applied to the ADC input (in milli units).
> + If not present, default to 1000 (no actual gain applied).
> + $ref: /schemas/types.yaml#/definitions/uint32
> + default: 1000
> +
> + required:
> + - reg
> +
> + additionalProperties: false
> +
> unevaluatedProperties: false
>
> allOf:
> @@ -128,7 +166,21 @@ allOf:
> ainc-supply: false
> aind-supply: false
>
> + # Using channel to declare gain property only applies to adaq devices
> + - if:
> + properties:
> + compatible:
> + not:
> + contains:
> + enum:
> + - adi,adaq4370-4
> + - adi,adaq4380-4
> + then:
> + patternProperties:
> + "^channel@([0-3])$": false
> +
> # ad7380-4 uses refin-supply as external reference.
> + # adaq devices use internal reference only, derived from refin-supply
> # All other chips from ad738x family use refio as optional external reference.
> # When refio-supply is omitted, internal reference is used.
> - if:
> @@ -136,6 +188,8 @@ allOf:
> compatible:
> enum:
> - adi,ad7380-4
> + - adi,adaq4370-4
> + - adi,adaq4380-4
> then:
> properties:
> refio-supply: false
> @@ -145,6 +199,24 @@ allOf:
> properties:
> refin-supply: false
>
> + # adaq devices need more supplies
> + - if:
> + properties:
> + compatible:
> + enum:
> + - adi,adaq4370-4
> + - adi,adaq4380-4
> + then:
> + required:
> + - vs-p-supply
> + - vs-n-supply
> + - ldo-supply
> + else:
> + properties:
> + vs-p-supply: false
> + vs-n-supply: false
> + ldo-supply: false
> +
> examples:
> - |
> #include <dt-bindings/interrupt-controller/irq.h>
> @@ -169,3 +241,48 @@ examples:
> refio-supply = <&supply_2_5V>;
> };
> };
> +
> + - |
> + #include <dt-bindings/interrupt-controller/irq.h>
> +
> + spi {
> + #address-cells = <1>;
> + #size-cells = <0>;
> +
> + adc@0 {
> + compatible = "adi,adaq4380-4";
> + 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>;
> + refin-supply = <&supply_5V>;
> + vs-p-supply = <&supply_5V>;
> + vs-n-supply = <&supply_0V>;
> + ldo-supply = <&supply_5V>;
> +
> + #address-cells = <1>;
> + #size-cells = <0>;
> +
> + channel@0 {
> + reg = <0>;
> + adi,gain-milli = <300>;
> + };
> +
> + channel@2 {
> + reg = <2>;
> + adi,gain-milli = <600>;
> + };
> +
> + channel@3 {
> + reg = <3>;
> + adi,gain-milli = <1000>;
> + };
> + };
> + };
>
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH RFC 1/4] dt-bindings: iio: adc: ad7380: add adaq4370-4 and adaq4380-4 compatible parts
2024-10-17 18:05 ` Jonathan Cameron
@ 2024-10-18 7:36 ` Julien Stephan
2024-10-18 18:09 ` Jonathan Cameron
0 siblings, 1 reply; 16+ messages in thread
From: Julien Stephan @ 2024-10-18 7:36 UTC (permalink / raw)
To: Jonathan Cameron
Cc: Lars-Peter Clausen, Michael Hennerich, Nuno Sá,
David Lechner, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Jonathan Corbet, linux-iio, devicetree, linux-kernel, linux-doc
Le jeu. 17 oct. 2024 à 20:05, Jonathan Cameron <jic23@kernel.org> a écrit :
>
> On Tue, 15 Oct 2024 11:09:06 +0200
> Julien Stephan <jstephan@baylibre.com> wrote:
>
> > adaq4370-4 (2MSPS) and adaq4380-4 (4MSPS) are quad-channel precision data
> > acquisition signal chain μModule solutions compatible with the ad738x
> > family, with the following differences:
> >
> > - configurable gain in front of each 4 adc
> > - internal reference is 3V derived from refin-supply (5V)
>
> Now I'm confused.
>
> The earlier refin-supply change appears unused in this patch.
> I was expecting it to be required for the additional devices.
> With additions to the docs from the fix to explain the new
> cases. I'm not seeing that in here.
>
>
> > - additional supplies
> >
> > To configure the gain a new patternProperties is added to describe each
> > channel. It is restricted to adaq devices.
> >
> > Signed-off-by: Julien Stephan <jstephan@baylibre.com>
> > ---
> > .../devicetree/bindings/iio/adc/adi,ad7380.yaml | 117 +++++++++++++++++++++
> > 1 file changed, 117 insertions(+)
> >
> > diff --git a/Documentation/devicetree/bindings/iio/adc/adi,ad7380.yaml b/Documentation/devicetree/bindings/iio/adc/adi,ad7380.yaml
> > index 74d82721637c..3007d8e39684 100644
> > --- a/Documentation/devicetree/bindings/iio/adc/adi,ad7380.yaml
> > +++ b/Documentation/devicetree/bindings/iio/adc/adi,ad7380.yaml
> > @@ -25,6 +25,8 @@ description: |
> > * https://www.analog.com/en/products/ad7386-4.html
> > * https://www.analog.com/en/products/ad7387-4.html
> > * https://www.analog.com/en/products/ad7388-4.html
> > + * https://www.analog.com/en/products/adaq4370-4.html
> > + * https://www.analog.com/en/products/adaq4380-4.html
> >
> >
> > $ref: /schemas/spi/spi-peripheral-props.yaml#
> > @@ -46,6 +48,8 @@ properties:
> > - adi,ad7386-4
> > - adi,ad7387-4
> > - adi,ad7388-4
> > + - adi,adaq4370-4
> > + - adi,adaq4380-4
> >
> > reg:
> > maxItems: 1
> > @@ -59,6 +63,9 @@ properties:
> > vlogic-supply: true
> > refio-supply: true
> > refin-supply: true
> > + vs-p-supply: true
> > + vs-n-supply: true
> > + ldo-supply: true
> >
> > aina-supply:
> > description:
> > @@ -86,12 +93,43 @@ properties:
> > specify the ALERT interrupt.
> > maxItems: 1
> >
> > + '#address-cells':
> > + const: 1
> > +
> > + '#size-cells':
> > + const: 0
> > +
> > required:
> > - compatible
> > - reg
> > - vcc-supply
> > - vlogic-supply
> >
> > +patternProperties:
> > + "^channel@([0-3])$":
> > + $ref: adc.yaml
> > + type: object
> > +
> > + properties:
> > + reg:
> > + description:
> > + The channel number. From 0 to 3 corresponding to channels A,B,C,D
> > + items:
> > + minimum: 0
> > + maximum: 3
> > +
> > + adi,gain-milli:
> > + description:
> > + The hardware gain applied to the ADC input (in milli units).
> > + If not present, default to 1000 (no actual gain applied).
> > + $ref: /schemas/types.yaml#/definitions/uint32
> > + default: 1000
> > +
> > + required:
> > + - reg
> > +
> > + additionalProperties: false
> > +
> > unevaluatedProperties: false
> >
> > allOf:
> > @@ -128,7 +166,21 @@ allOf:
> > ainc-supply: false
> > aind-supply: false
> >
> > + # Using channel to declare gain property only applies to adaq devices
> > + - if:
> > + properties:
> > + compatible:
> > + not:
> > + contains:
> > + enum:
> > + - adi,adaq4370-4
> > + - adi,adaq4380-4
> > + then:
> > + patternProperties:
> > + "^channel@([0-3])$": false
> > +
> > # ad7380-4 uses refin-supply as external reference.
> > + # adaq devices use internal reference only, derived from refin-supply
Hi Jonathan,
here I add a quick description on how adaq devices are using refin-supply ...
> > # All other chips from ad738x family use refio as optional external reference.
> > # When refio-supply is omitted, internal reference is used.
> > - if:
> > @@ -136,6 +188,8 @@ allOf:
> > compatible:
> > enum:
> > - adi,ad7380-4
> > + - adi,adaq4370-4
> > + - adi,adaq4380-4
... and adaq devices are added here to require refin-supply.
Maybe I am missing your point? or I still need to improve the description?
Cheers
Julien
> > then:
> > properties:
> > refio-supply: false
> > @@ -145,6 +199,24 @@ allOf:
> > properties:
> > refin-supply: false
> >
> > + # adaq devices need more supplies
> > + - if:
> > + properties:
> > + compatible:
> > + enum:
> > + - adi,adaq4370-4
> > + - adi,adaq4380-4
> > + then:
> > + required:
> > + - vs-p-supply
> > + - vs-n-supply
> > + - ldo-supply
> > + else:
> > + properties:
> > + vs-p-supply: false
> > + vs-n-supply: false
> > + ldo-supply: false
> > +
> > examples:
> > - |
> > #include <dt-bindings/interrupt-controller/irq.h>
> > @@ -169,3 +241,48 @@ examples:
> > refio-supply = <&supply_2_5V>;
> > };
> > };
> > +
> > + - |
> > + #include <dt-bindings/interrupt-controller/irq.h>
> > +
> > + spi {
> > + #address-cells = <1>;
> > + #size-cells = <0>;
> > +
> > + adc@0 {
> > + compatible = "adi,adaq4380-4";
> > + 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>;
> > + refin-supply = <&supply_5V>;
> > + vs-p-supply = <&supply_5V>;
> > + vs-n-supply = <&supply_0V>;
> > + ldo-supply = <&supply_5V>;
> > +
> > + #address-cells = <1>;
> > + #size-cells = <0>;
> > +
> > + channel@0 {
> > + reg = <0>;
> > + adi,gain-milli = <300>;
> > + };
> > +
> > + channel@2 {
> > + reg = <2>;
> > + adi,gain-milli = <600>;
> > + };
> > +
> > + channel@3 {
> > + reg = <3>;
> > + adi,gain-milli = <1000>;
> > + };
> > + };
> > + };
> >
>
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH RFC 1/4] dt-bindings: iio: adc: ad7380: add adaq4370-4 and adaq4380-4 compatible parts
2024-10-18 7:36 ` Julien Stephan
@ 2024-10-18 18:09 ` Jonathan Cameron
0 siblings, 0 replies; 16+ messages in thread
From: Jonathan Cameron @ 2024-10-18 18:09 UTC (permalink / raw)
To: Julien Stephan
Cc: Lars-Peter Clausen, Michael Hennerich, Nuno Sá,
David Lechner, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Jonathan Corbet, linux-iio, devicetree, linux-kernel, linux-doc
On Fri, 18 Oct 2024 09:36:52 +0200
Julien Stephan <jstephan@baylibre.com> wrote:
> Le jeu. 17 oct. 2024 à 20:05, Jonathan Cameron <jic23@kernel.org> a écrit :
> >
> > On Tue, 15 Oct 2024 11:09:06 +0200
> > Julien Stephan <jstephan@baylibre.com> wrote:
> >
> > > adaq4370-4 (2MSPS) and adaq4380-4 (4MSPS) are quad-channel precision data
> > > acquisition signal chain μModule solutions compatible with the ad738x
> > > family, with the following differences:
> > >
> > > - configurable gain in front of each 4 adc
> > > - internal reference is 3V derived from refin-supply (5V)
> >
> > Now I'm confused.
> >
> > The earlier refin-supply change appears unused in this patch.
> > I was expecting it to be required for the additional devices.
> > With additions to the docs from the fix to explain the new
> > cases. I'm not seeing that in here.
> >
> >
> > > - additional supplies
> > >
> > > To configure the gain a new patternProperties is added to describe each
> > > channel. It is restricted to adaq devices.
> > >
> > > Signed-off-by: Julien Stephan <jstephan@baylibre.com>
> > > ---
> > > .../devicetree/bindings/iio/adc/adi,ad7380.yaml | 117 +++++++++++++++++++++
> > > 1 file changed, 117 insertions(+)
> > >
> > > diff --git a/Documentation/devicetree/bindings/iio/adc/adi,ad7380.yaml b/Documentation/devicetree/bindings/iio/adc/adi,ad7380.yaml
> > > index 74d82721637c..3007d8e39684 100644
> > > --- a/Documentation/devicetree/bindings/iio/adc/adi,ad7380.yaml
> > > +++ b/Documentation/devicetree/bindings/iio/adc/adi,ad7380.yaml
> > > @@ -25,6 +25,8 @@ description: |
> > > * https://www.analog.com/en/products/ad7386-4.html
> > > * https://www.analog.com/en/products/ad7387-4.html
> > > * https://www.analog.com/en/products/ad7388-4.html
> > > + * https://www.analog.com/en/products/adaq4370-4.html
> > > + * https://www.analog.com/en/products/adaq4380-4.html
> > >
> > >
> > > $ref: /schemas/spi/spi-peripheral-props.yaml#
> > > @@ -46,6 +48,8 @@ properties:
> > > - adi,ad7386-4
> > > - adi,ad7387-4
> > > - adi,ad7388-4
> > > + - adi,adaq4370-4
> > > + - adi,adaq4380-4
> > >
> > > reg:
> > > maxItems: 1
> > > @@ -59,6 +63,9 @@ properties:
> > > vlogic-supply: true
> > > refio-supply: true
> > > refin-supply: true
> > > + vs-p-supply: true
> > > + vs-n-supply: true
> > > + ldo-supply: true
> > >
> > > aina-supply:
> > > description:
> > > @@ -86,12 +93,43 @@ properties:
> > > specify the ALERT interrupt.
> > > maxItems: 1
> > >
> > > + '#address-cells':
> > > + const: 1
> > > +
> > > + '#size-cells':
> > > + const: 0
> > > +
> > > required:
> > > - compatible
> > > - reg
> > > - vcc-supply
> > > - vlogic-supply
> > >
> > > +patternProperties:
> > > + "^channel@([0-3])$":
> > > + $ref: adc.yaml
> > > + type: object
> > > +
> > > + properties:
> > > + reg:
> > > + description:
> > > + The channel number. From 0 to 3 corresponding to channels A,B,C,D
> > > + items:
> > > + minimum: 0
> > > + maximum: 3
> > > +
> > > + adi,gain-milli:
> > > + description:
> > > + The hardware gain applied to the ADC input (in milli units).
> > > + If not present, default to 1000 (no actual gain applied).
> > > + $ref: /schemas/types.yaml#/definitions/uint32
> > > + default: 1000
> > > +
> > > + required:
> > > + - reg
> > > +
> > > + additionalProperties: false
> > > +
> > > unevaluatedProperties: false
> > >
> > > allOf:
> > > @@ -128,7 +166,21 @@ allOf:
> > > ainc-supply: false
> > > aind-supply: false
> > >
> > > + # Using channel to declare gain property only applies to adaq devices
> > > + - if:
> > > + properties:
> > > + compatible:
> > > + not:
> > > + contains:
> > > + enum:
> > > + - adi,adaq4370-4
> > > + - adi,adaq4380-4
> > > + then:
> > > + patternProperties:
> > > + "^channel@([0-3])$": false
> > > +
> > > # ad7380-4 uses refin-supply as external reference.
> > > + # adaq devices use internal reference only, derived from refin-supply
>
> Hi Jonathan,
>
> here I add a quick description on how adaq devices are using refin-supply ...
>
> > > # All other chips from ad738x family use refio as optional external reference.
> > > # When refio-supply is omitted, internal reference is used.
> > > - if:
> > > @@ -136,6 +188,8 @@ allOf:
> > > compatible:
> > > enum:
> > > - adi,ad7380-4
> > > + - adi,adaq4370-4
> > > + - adi,adaq4380-4
>
> ... and adaq devices are added here to require refin-supply.
>
> Maybe I am missing your point? or I still need to improve the description?
Nope. I just misread the diff! Thanks for pointing out the key bits.
Jonathan
>
> Cheers
> Julien
>
> > > then:
> > > properties:
> > > refio-supply: false
> > > @@ -145,6 +199,24 @@ allOf:
> > > properties:
> > > refin-supply: false
> > >
> > > + # adaq devices need more supplies
> > > + - if:
> > > + properties:
> > > + compatible:
> > > + enum:
> > > + - adi,adaq4370-4
> > > + - adi,adaq4380-4
> > > + then:
> > > + required:
> > > + - vs-p-supply
> > > + - vs-n-supply
> > > + - ldo-supply
> > > + else:
> > > + properties:
> > > + vs-p-supply: false
> > > + vs-n-supply: false
> > > + ldo-supply: false
> > > +
> > > examples:
> > > - |
> > > #include <dt-bindings/interrupt-controller/irq.h>
> > > @@ -169,3 +241,48 @@ examples:
> > > refio-supply = <&supply_2_5V>;
> > > };
> > > };
> > > +
> > > + - |
> > > + #include <dt-bindings/interrupt-controller/irq.h>
> > > +
> > > + spi {
> > > + #address-cells = <1>;
> > > + #size-cells = <0>;
> > > +
> > > + adc@0 {
> > > + compatible = "adi,adaq4380-4";
> > > + 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>;
> > > + refin-supply = <&supply_5V>;
> > > + vs-p-supply = <&supply_5V>;
> > > + vs-n-supply = <&supply_0V>;
> > > + ldo-supply = <&supply_5V>;
> > > +
> > > + #address-cells = <1>;
> > > + #size-cells = <0>;
> > > +
> > > + channel@0 {
> > > + reg = <0>;
> > > + adi,gain-milli = <300>;
> > > + };
> > > +
> > > + channel@2 {
> > > + reg = <2>;
> > > + adi,gain-milli = <600>;
> > > + };
> > > +
> > > + channel@3 {
> > > + reg = <3>;
> > > + adi,gain-milli = <1000>;
> > > + };
> > > + };
> > > + };
> > >
> >
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH RFC 0/4] ad7380: add adaq4370-4 and adaq4380-4 support
2024-10-16 7:25 ` Julien Stephan
@ 2024-10-18 18:11 ` Jonathan Cameron
0 siblings, 0 replies; 16+ messages in thread
From: Jonathan Cameron @ 2024-10-18 18:11 UTC (permalink / raw)
To: Julien Stephan
Cc: Conor Dooley, Lars-Peter Clausen, Michael Hennerich, Nuno Sá,
David Lechner, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Jonathan Corbet, linux-iio, devicetree, linux-kernel, linux-doc
On Wed, 16 Oct 2024 09:25:53 +0200
Julien Stephan <jstephan@baylibre.com> wrote:
> Le mar. 15 oct. 2024 à 18:43, Conor Dooley <conor@kernel.org> a écrit :
> >
> > On Tue, Oct 15, 2024 at 11:09:05AM +0200, Julien Stephan wrote:
> > > Hello,
> > >
> > > This series add support for adaq4370-4 (2MSPS) and adaq4380-4 (4MSPS)
> > > which are quad-channel precision data acquisition signal chain μModule
> > > solutions compatible with the ad738x family, with the following differences:
> > >
> > > - configurable gain in front of each 4 adc
> > > - internal reference is 3V derived from refin-supply (5V)
> > > - additional supplies
> > >
> > > This series depends on [1] which fix several supplies issues
> > >
> > > [1]: https://lore.kernel.org/all/20241007-ad7380-fix-supplies-v1-0-badcf813c9b9@baylibre.com/
> >
> > What exactly makes this series RFC rather than v1?
>
> Hi Conor,
> I am sorry I forgot to add some context here... There is an ongoing
> discussion on the dependent series about power supplies and Jonathan
> asked me to send this series to see how to properly handle the supply
> fix...
> See https://lore.kernel.org/all/20241014193701.40e3785a@jic23-huawei/
Thanks,
It did the job for that. Given it's on list, do you want a review
of the rest of the patch set, or is it still enough of a work in progress
that we should hold off?
Thanks,
Jonathan
>
> Cheers,
> Julien
>
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH RFC 3/4] iio: adc: ad7380: add support for adaq4370-4 and adaq4380-4
2024-10-15 9:09 ` [PATCH RFC 3/4] iio: adc: ad7380: add support for adaq4370-4 and adaq4380-4 Julien Stephan
@ 2024-10-20 13:18 ` Jonathan Cameron
0 siblings, 0 replies; 16+ messages in thread
From: Jonathan Cameron @ 2024-10-20 13:18 UTC (permalink / raw)
To: Julien Stephan
Cc: Lars-Peter Clausen, Michael Hennerich, Nuno Sá,
David Lechner, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Jonathan Corbet, linux-iio, devicetree, linux-kernel, linux-doc
On Tue, 15 Oct 2024 11:09:08 +0200
Julien Stephan <jstephan@baylibre.com> wrote:
> adaq4370-4 (2MSPS) and adaq4380-4 (4MSPS) are quad-channel precision data
> acquisition signal chain μModule solutions compatible with the ad738x
> family, with the following differences:
>
> - configurable gain in front of each 4 adc
> - internal reference is 3V derived from refin-supply (5V)
> - additional supplies
>
> This implies that IIO_CHAN_INFO_SCALE can not be shared by type.
>
> Signed-off-by: Julien Stephan <jstephan@baylibre.com>
Not that much code, so I'll give it a quick review even though I know
you posted it for that one specific dt binding question.
Main thing here is I'd drop the scale from dt bindings and make it writable
via write_raw. You'll also need to compute the appropriate _available
stuff so userspace knows what scales it can use.
Jonathan
> @@ -876,8 +933,15 @@ static int ad7380_read_raw(struct iio_dev *indio_dev,
> * * (2 × VREF) / 2^N, for differential chips
> * * VREF / 2^N, for pseudo-differential chips
> * where N is the ADC resolution (i.e realbits)
> + *
> + * The gain is stored as a fraction of 1000 and, as we need to
> + * divide vref_mv by the gain, we invert the gain/1000 fraction.
> */
> - *val = st->vref_mv;
> + if (st->chip_info->has_hardware_gain)
> + *val = mult_frac(st->vref_mv, MILLI,
> + st->gain_milli[chan->scan_index]);
> + else
> + *val = st->vref_mv;
> *val2 = scan_type->realbits - chan->differential;
>
> return IIO_VAL_FRACTIONAL_LOG2;
> @@ -1058,7 +1122,19 @@ static int ad7380_probe(struct spi_device *spi)
> "Failed to enable power supplies\n");
> msleep(T_POWERUP_MS);
>
> - if (st->chip_info->external_ref_only) {
> + if (st->chip_info->adaq_internal_ref_only) {
> + /*
> + * ADAQ chips use fixed internal reference but still
> + * require an external reference supply to power it.
I'd just go with
* require a specific external supply to power it.
Reference kind of implies it is a quality supply. This is 4.5-5.5V
so not so much ;)
> + * "refin" is already enabled with other power supplies
> + * in bulk_get_enable().
> + */
> +
> + st->vref_mv = ADAQ4380_INTERNAL_REF_MV;
> +
> + /* these chips don't have a register bit for this */
> + external_ref_en = false;
> + } else if (st->chip_info->external_ref_only) {
> ret = devm_regulator_get_enable_read_voltage(&spi->dev,
> "refin");
> if (ret < 0)
> @@ -1104,6 +1180,34 @@ static int ad7380_probe(struct spi_device *spi)
> st->vcm_mv[i] = ret / 1000;
> }
>
> + for (i = 0; i < MAX_NUM_CHANNELS; i++)
> + st->gain_milli[i] = AD7380_DEFAULT_GAIN_MILLI;
> +
> + if (st->chip_info->has_hardware_gain) {
Why is this a DT thing rather than exposed to userspace?
Mostly we only control ranges in DT for output devices (where there is a chance
of burning things if we let them be controlled from userspace.).
For ADC amplifiers we tend to just expose them as controllable _SCALE.
> + device_for_each_child_node_scoped(&spi->dev, node) {
> + unsigned int channel, gain;
> +
> + ret = fwnode_property_read_u32(node, "reg", &channel);
> + if (ret)
> + return dev_err_probe(&spi->dev, ret,
> + "Failed to read reg property\n");
> +
> + if (channel >= st->chip_info->num_channels - 1)
> + return dev_err_probe(&spi->dev, -EINVAL,
> + "Invalid channel number %i\n",
> + channel);
> +
> + ret = fwnode_property_read_u32(node, "adi,gain-milli",
> + &gain);
> + if (ret && ret != -EINVAL)
> + return dev_err_probe(&spi->dev, ret,
> + "Failed to read gain for channel %i\n",
> + channel);
> + if (ret != -EINVAL)
> + st->gain_milli[channel] = gain;
> + }
> + }
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH RFC 1/4] dt-bindings: iio: adc: ad7380: add adaq4370-4 and adaq4380-4 compatible parts
2024-10-15 9:09 ` [PATCH RFC 1/4] dt-bindings: iio: adc: ad7380: add adaq4370-4 and adaq4380-4 compatible parts Julien Stephan
2024-10-15 20:49 ` Rob Herring
2024-10-17 18:05 ` Jonathan Cameron
@ 2024-10-20 13:20 ` Jonathan Cameron
2024-10-21 13:25 ` Julien Stephan
2 siblings, 1 reply; 16+ messages in thread
From: Jonathan Cameron @ 2024-10-20 13:20 UTC (permalink / raw)
To: Julien Stephan
Cc: Lars-Peter Clausen, Michael Hennerich, Nuno Sá,
David Lechner, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Jonathan Corbet, linux-iio, devicetree, linux-kernel, linux-doc
On Tue, 15 Oct 2024 11:09:06 +0200
Julien Stephan <jstephan@baylibre.com> wrote:
> adaq4370-4 (2MSPS) and adaq4380-4 (4MSPS) are quad-channel precision data
> acquisition signal chain μModule solutions compatible with the ad738x
> family, with the following differences:
>
> - configurable gain in front of each 4 adc
As per quick review I gave for the driver code, I'm not seeing why
a configurable gain is a DT thing on an ADC vs something that belongs
in userspace control. I may be missing something though.
It exists for the ad4000 because the control isn't via registers
but via pin straps so we can't control it sensibly from userspace.
Jonathan
> - internal reference is 3V derived from refin-supply (5V)
> - additional supplies
>
> To configure the gain a new patternProperties is added to describe each
> channel. It is restricted to adaq devices.
>
> Signed-off-by: Julien Stephan <jstephan@baylibre.com>
> ---
> .../devicetree/bindings/iio/adc/adi,ad7380.yaml | 117 +++++++++++++++++++++
> 1 file changed, 117 insertions(+)
>
> diff --git a/Documentation/devicetree/bindings/iio/adc/adi,ad7380.yaml b/Documentation/devicetree/bindings/iio/adc/adi,ad7380.yaml
> index 74d82721637c..3007d8e39684 100644
> --- a/Documentation/devicetree/bindings/iio/adc/adi,ad7380.yaml
> +++ b/Documentation/devicetree/bindings/iio/adc/adi,ad7380.yaml
> @@ -25,6 +25,8 @@ description: |
> * https://www.analog.com/en/products/ad7386-4.html
> * https://www.analog.com/en/products/ad7387-4.html
> * https://www.analog.com/en/products/ad7388-4.html
> + * https://www.analog.com/en/products/adaq4370-4.html
> + * https://www.analog.com/en/products/adaq4380-4.html
>
>
> $ref: /schemas/spi/spi-peripheral-props.yaml#
> @@ -46,6 +48,8 @@ properties:
> - adi,ad7386-4
> - adi,ad7387-4
> - adi,ad7388-4
> + - adi,adaq4370-4
> + - adi,adaq4380-4
>
> reg:
> maxItems: 1
> @@ -59,6 +63,9 @@ properties:
> vlogic-supply: true
> refio-supply: true
> refin-supply: true
> + vs-p-supply: true
> + vs-n-supply: true
> + ldo-supply: true
>
> aina-supply:
> description:
> @@ -86,12 +93,43 @@ properties:
> specify the ALERT interrupt.
> maxItems: 1
>
> + '#address-cells':
> + const: 1
> +
> + '#size-cells':
> + const: 0
> +
> required:
> - compatible
> - reg
> - vcc-supply
> - vlogic-supply
>
> +patternProperties:
> + "^channel@([0-3])$":
> + $ref: adc.yaml
> + type: object
> +
> + properties:
> + reg:
> + description:
> + The channel number. From 0 to 3 corresponding to channels A,B,C,D
> + items:
> + minimum: 0
> + maximum: 3
> +
> + adi,gain-milli:
> + description:
> + The hardware gain applied to the ADC input (in milli units).
> + If not present, default to 1000 (no actual gain applied).
> + $ref: /schemas/types.yaml#/definitions/uint32
> + default: 1000
> +
> + required:
> + - reg
> +
> + additionalProperties: false
> +
> unevaluatedProperties: false
>
> allOf:
> @@ -128,7 +166,21 @@ allOf:
> ainc-supply: false
> aind-supply: false
>
> + # Using channel to declare gain property only applies to adaq devices
> + - if:
> + properties:
> + compatible:
> + not:
> + contains:
> + enum:
> + - adi,adaq4370-4
> + - adi,adaq4380-4
> + then:
> + patternProperties:
> + "^channel@([0-3])$": false
> +
> # ad7380-4 uses refin-supply as external reference.
> + # adaq devices use internal reference only, derived from refin-supply
> # All other chips from ad738x family use refio as optional external reference.
> # When refio-supply is omitted, internal reference is used.
> - if:
> @@ -136,6 +188,8 @@ allOf:
> compatible:
> enum:
> - adi,ad7380-4
> + - adi,adaq4370-4
> + - adi,adaq4380-4
> then:
> properties:
> refio-supply: false
> @@ -145,6 +199,24 @@ allOf:
> properties:
> refin-supply: false
>
> + # adaq devices need more supplies
> + - if:
> + properties:
> + compatible:
> + enum:
> + - adi,adaq4370-4
> + - adi,adaq4380-4
> + then:
> + required:
> + - vs-p-supply
> + - vs-n-supply
> + - ldo-supply
> + else:
> + properties:
> + vs-p-supply: false
> + vs-n-supply: false
> + ldo-supply: false
> +
> examples:
> - |
> #include <dt-bindings/interrupt-controller/irq.h>
> @@ -169,3 +241,48 @@ examples:
> refio-supply = <&supply_2_5V>;
> };
> };
> +
> + - |
> + #include <dt-bindings/interrupt-controller/irq.h>
> +
> + spi {
> + #address-cells = <1>;
> + #size-cells = <0>;
> +
> + adc@0 {
> + compatible = "adi,adaq4380-4";
> + 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>;
> + refin-supply = <&supply_5V>;
> + vs-p-supply = <&supply_5V>;
> + vs-n-supply = <&supply_0V>;
> + ldo-supply = <&supply_5V>;
> +
> + #address-cells = <1>;
> + #size-cells = <0>;
> +
> + channel@0 {
> + reg = <0>;
> + adi,gain-milli = <300>;
> + };
> +
> + channel@2 {
> + reg = <2>;
> + adi,gain-milli = <600>;
> + };
> +
> + channel@3 {
> + reg = <3>;
> + adi,gain-milli = <1000>;
> + };
> + };
> + };
>
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH RFC 1/4] dt-bindings: iio: adc: ad7380: add adaq4370-4 and adaq4380-4 compatible parts
2024-10-20 13:20 ` Jonathan Cameron
@ 2024-10-21 13:25 ` Julien Stephan
2024-10-21 18:17 ` Jonathan Cameron
0 siblings, 1 reply; 16+ messages in thread
From: Julien Stephan @ 2024-10-21 13:25 UTC (permalink / raw)
To: Jonathan Cameron
Cc: Lars-Peter Clausen, Michael Hennerich, Nuno Sá,
David Lechner, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Jonathan Corbet, linux-iio, devicetree, linux-kernel, linux-doc
Le dim. 20 oct. 2024 à 15:21, Jonathan Cameron <jic23@kernel.org> a écrit :
>
> On Tue, 15 Oct 2024 11:09:06 +0200
> Julien Stephan <jstephan@baylibre.com> wrote:
>
> > adaq4370-4 (2MSPS) and adaq4380-4 (4MSPS) are quad-channel precision data
> > acquisition signal chain μModule solutions compatible with the ad738x
> > family, with the following differences:
> >
> > - configurable gain in front of each 4 adc
> As per quick review I gave for the driver code, I'm not seeing why
> a configurable gain is a DT thing on an ADC vs something that belongs
> in userspace control. I may be missing something though.
>
> It exists for the ad4000 because the control isn't via registers
> but via pin straps so we can't control it sensibly from userspace.
Hi Jonathan,
I indeed based my work on ad4000. I think my commit description is
erroneous and confusing.
On the first page of the datasheet
(https://www.analog.com/media/en/technical-documentation/data-sheets/adaq4380-4.pdf)
it's written : Pin selectable Gain/attenuation. So I guess adaq4380-4
and adaq4370-4 are working the same way as the adaq4000 series.
I'll rewrite my commit message. Also, I didn't want to restrict users
to the gain values in the datasheet, because I thought they are just
examples and users can always use additional resistance to change the
gain. Am I correct? Or should I use the datasheet values (as adaq4000
series does) ?
Cheers
Julien
>
> Jonathan
>
> > - internal reference is 3V derived from refin-supply (5V)
> > - additional supplies
> >
> > To configure the gain a new patternProperties is added to describe each
> > channel. It is restricted to adaq devices.
> >
> > Signed-off-by: Julien Stephan <jstephan@baylibre.com>
> > ---
> > .../devicetree/bindings/iio/adc/adi,ad7380.yaml | 117 +++++++++++++++++++++
> > 1 file changed, 117 insertions(+)
> >
> > diff --git a/Documentation/devicetree/bindings/iio/adc/adi,ad7380.yaml b/Documentation/devicetree/bindings/iio/adc/adi,ad7380.yaml
> > index 74d82721637c..3007d8e39684 100644
> > --- a/Documentation/devicetree/bindings/iio/adc/adi,ad7380.yaml
> > +++ b/Documentation/devicetree/bindings/iio/adc/adi,ad7380.yaml
> > @@ -25,6 +25,8 @@ description: |
> > * https://www.analog.com/en/products/ad7386-4.html
> > * https://www.analog.com/en/products/ad7387-4.html
> > * https://www.analog.com/en/products/ad7388-4.html
> > + * https://www.analog.com/en/products/adaq4370-4.html
> > + * https://www.analog.com/en/products/adaq4380-4.html
> >
> >
> > $ref: /schemas/spi/spi-peripheral-props.yaml#
> > @@ -46,6 +48,8 @@ properties:
> > - adi,ad7386-4
> > - adi,ad7387-4
> > - adi,ad7388-4
> > + - adi,adaq4370-4
> > + - adi,adaq4380-4
> >
> > reg:
> > maxItems: 1
> > @@ -59,6 +63,9 @@ properties:
> > vlogic-supply: true
> > refio-supply: true
> > refin-supply: true
> > + vs-p-supply: true
> > + vs-n-supply: true
> > + ldo-supply: true
> >
> > aina-supply:
> > description:
> > @@ -86,12 +93,43 @@ properties:
> > specify the ALERT interrupt.
> > maxItems: 1
> >
> > + '#address-cells':
> > + const: 1
> > +
> > + '#size-cells':
> > + const: 0
> > +
> > required:
> > - compatible
> > - reg
> > - vcc-supply
> > - vlogic-supply
> >
> > +patternProperties:
> > + "^channel@([0-3])$":
> > + $ref: adc.yaml
> > + type: object
> > +
> > + properties:
> > + reg:
> > + description:
> > + The channel number. From 0 to 3 corresponding to channels A,B,C,D
> > + items:
> > + minimum: 0
> > + maximum: 3
> > +
> > + adi,gain-milli:
> > + description:
> > + The hardware gain applied to the ADC input (in milli units).
> > + If not present, default to 1000 (no actual gain applied).
> > + $ref: /schemas/types.yaml#/definitions/uint32
> > + default: 1000
> > +
> > + required:
> > + - reg
> > +
> > + additionalProperties: false
> > +
> > unevaluatedProperties: false
> >
> > allOf:
> > @@ -128,7 +166,21 @@ allOf:
> > ainc-supply: false
> > aind-supply: false
> >
> > + # Using channel to declare gain property only applies to adaq devices
> > + - if:
> > + properties:
> > + compatible:
> > + not:
> > + contains:
> > + enum:
> > + - adi,adaq4370-4
> > + - adi,adaq4380-4
> > + then:
> > + patternProperties:
> > + "^channel@([0-3])$": false
> > +
> > # ad7380-4 uses refin-supply as external reference.
> > + # adaq devices use internal reference only, derived from refin-supply
> > # All other chips from ad738x family use refio as optional external reference.
> > # When refio-supply is omitted, internal reference is used.
> > - if:
> > @@ -136,6 +188,8 @@ allOf:
> > compatible:
> > enum:
> > - adi,ad7380-4
> > + - adi,adaq4370-4
> > + - adi,adaq4380-4
> > then:
> > properties:
> > refio-supply: false
> > @@ -145,6 +199,24 @@ allOf:
> > properties:
> > refin-supply: false
> >
> > + # adaq devices need more supplies
> > + - if:
> > + properties:
> > + compatible:
> > + enum:
> > + - adi,adaq4370-4
> > + - adi,adaq4380-4
> > + then:
> > + required:
> > + - vs-p-supply
> > + - vs-n-supply
> > + - ldo-supply
> > + else:
> > + properties:
> > + vs-p-supply: false
> > + vs-n-supply: false
> > + ldo-supply: false
> > +
> > examples:
> > - |
> > #include <dt-bindings/interrupt-controller/irq.h>
> > @@ -169,3 +241,48 @@ examples:
> > refio-supply = <&supply_2_5V>;
> > };
> > };
> > +
> > + - |
> > + #include <dt-bindings/interrupt-controller/irq.h>
> > +
> > + spi {
> > + #address-cells = <1>;
> > + #size-cells = <0>;
> > +
> > + adc@0 {
> > + compatible = "adi,adaq4380-4";
> > + 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>;
> > + refin-supply = <&supply_5V>;
> > + vs-p-supply = <&supply_5V>;
> > + vs-n-supply = <&supply_0V>;
> > + ldo-supply = <&supply_5V>;
> > +
> > + #address-cells = <1>;
> > + #size-cells = <0>;
> > +
> > + channel@0 {
> > + reg = <0>;
> > + adi,gain-milli = <300>;
> > + };
> > +
> > + channel@2 {
> > + reg = <2>;
> > + adi,gain-milli = <600>;
> > + };
> > +
> > + channel@3 {
> > + reg = <3>;
> > + adi,gain-milli = <1000>;
> > + };
> > + };
> > + };
> >
>
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH RFC 1/4] dt-bindings: iio: adc: ad7380: add adaq4370-4 and adaq4380-4 compatible parts
2024-10-21 13:25 ` Julien Stephan
@ 2024-10-21 18:17 ` Jonathan Cameron
0 siblings, 0 replies; 16+ messages in thread
From: Jonathan Cameron @ 2024-10-21 18:17 UTC (permalink / raw)
To: Julien Stephan
Cc: Lars-Peter Clausen, Michael Hennerich, Nuno Sá,
David Lechner, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Jonathan Corbet, linux-iio, devicetree, linux-kernel, linux-doc
On Mon, 21 Oct 2024 15:25:23 +0200
Julien Stephan <jstephan@baylibre.com> wrote:
> Le dim. 20 oct. 2024 à 15:21, Jonathan Cameron <jic23@kernel.org> a écrit :
> >
> > On Tue, 15 Oct 2024 11:09:06 +0200
> > Julien Stephan <jstephan@baylibre.com> wrote:
> >
> > > adaq4370-4 (2MSPS) and adaq4380-4 (4MSPS) are quad-channel precision data
> > > acquisition signal chain μModule solutions compatible with the ad738x
> > > family, with the following differences:
> > >
> > > - configurable gain in front of each 4 adc
> > As per quick review I gave for the driver code, I'm not seeing why
> > a configurable gain is a DT thing on an ADC vs something that belongs
> > in userspace control. I may be missing something though.
> >
> > It exists for the ad4000 because the control isn't via registers
> > but via pin straps so we can't control it sensibly from userspace.
>
>
> Hi Jonathan,
> I indeed based my work on ad4000. I think my commit description is
> erroneous and confusing.
> On the first page of the datasheet
> (https://www.analog.com/media/en/technical-documentation/data-sheets/adaq4380-4.pdf)
> it's written : Pin selectable Gain/attenuation. So I guess adaq4380-4
> and adaq4370-4 are working the same way as the adaq4000 series.
> I'll rewrite my commit message. Also, I didn't want to restrict users
> to the gain values in the datasheet, because I thought they are just
> examples and users can always use additional resistance to change the
> gain. Am I correct? Or should I use the datasheet values (as adaq4000
> series does) ?
Ah. Now seeing how this works.
Hmm. For completely external circuitry we have the various analog front
end drivers that act as a consumer of an ADC. For this case it is messier
as there are internal resistors. However I don't immediately see examples
of using external registers to some of the pins and not others.
So I'd be inclined to just allow the pin strap values as show in figure
50 to 55.
So I'd just add docs to give the pin wiring as well as the gain.
Afterall DT writer probably has a circuit diagram, not a statement
of the gain of that circuit.
Jonathan
>
> Cheers
> Julien
>
> >
> > Jonathan
> >
> > > - internal reference is 3V derived from refin-supply (5V)
> > > - additional supplies
> > >
> > > To configure the gain a new patternProperties is added to describe each
> > > channel. It is restricted to adaq devices.
> > >
> > > Signed-off-by: Julien Stephan <jstephan@baylibre.com>
> > > ---
> > > .../devicetree/bindings/iio/adc/adi,ad7380.yaml | 117 +++++++++++++++++++++
> > > 1 file changed, 117 insertions(+)
> > >
> > > diff --git a/Documentation/devicetree/bindings/iio/adc/adi,ad7380.yaml b/Documentation/devicetree/bindings/iio/adc/adi,ad7380.yaml
> > > index 74d82721637c..3007d8e39684 100644
> > > --- a/Documentation/devicetree/bindings/iio/adc/adi,ad7380.yaml
> > > +++ b/Documentation/devicetree/bindings/iio/adc/adi,ad7380.yaml
> > > @@ -25,6 +25,8 @@ description: |
> > > * https://www.analog.com/en/products/ad7386-4.html
> > > * https://www.analog.com/en/products/ad7387-4.html
> > > * https://www.analog.com/en/products/ad7388-4.html
> > > + * https://www.analog.com/en/products/adaq4370-4.html
> > > + * https://www.analog.com/en/products/adaq4380-4.html
> > >
> > >
> > > $ref: /schemas/spi/spi-peripheral-props.yaml#
> > > @@ -46,6 +48,8 @@ properties:
> > > - adi,ad7386-4
> > > - adi,ad7387-4
> > > - adi,ad7388-4
> > > + - adi,adaq4370-4
> > > + - adi,adaq4380-4
> > >
> > > reg:
> > > maxItems: 1
> > > @@ -59,6 +63,9 @@ properties:
> > > vlogic-supply: true
> > > refio-supply: true
> > > refin-supply: true
> > > + vs-p-supply: true
> > > + vs-n-supply: true
> > > + ldo-supply: true
> > >
> > > aina-supply:
> > > description:
> > > @@ -86,12 +93,43 @@ properties:
> > > specify the ALERT interrupt.
> > > maxItems: 1
> > >
> > > + '#address-cells':
> > > + const: 1
> > > +
> > > + '#size-cells':
> > > + const: 0
> > > +
> > > required:
> > > - compatible
> > > - reg
> > > - vcc-supply
> > > - vlogic-supply
> > >
> > > +patternProperties:
> > > + "^channel@([0-3])$":
> > > + $ref: adc.yaml
> > > + type: object
> > > +
> > > + properties:
> > > + reg:
> > > + description:
> > > + The channel number. From 0 to 3 corresponding to channels A,B,C,D
> > > + items:
> > > + minimum: 0
> > > + maximum: 3
> > > +
> > > + adi,gain-milli:
> > > + description:
> > > + The hardware gain applied to the ADC input (in milli units).
> > > + If not present, default to 1000 (no actual gain applied).
> > > + $ref: /schemas/types.yaml#/definitions/uint32
> > > + default: 1000
> > > +
> > > + required:
> > > + - reg
> > > +
> > > + additionalProperties: false
> > > +
> > > unevaluatedProperties: false
> > >
> > > allOf:
> > > @@ -128,7 +166,21 @@ allOf:
> > > ainc-supply: false
> > > aind-supply: false
> > >
> > > + # Using channel to declare gain property only applies to adaq devices
> > > + - if:
> > > + properties:
> > > + compatible:
> > > + not:
> > > + contains:
> > > + enum:
> > > + - adi,adaq4370-4
> > > + - adi,adaq4380-4
> > > + then:
> > > + patternProperties:
> > > + "^channel@([0-3])$": false
> > > +
> > > # ad7380-4 uses refin-supply as external reference.
> > > + # adaq devices use internal reference only, derived from refin-supply
> > > # All other chips from ad738x family use refio as optional external reference.
> > > # When refio-supply is omitted, internal reference is used.
> > > - if:
> > > @@ -136,6 +188,8 @@ allOf:
> > > compatible:
> > > enum:
> > > - adi,ad7380-4
> > > + - adi,adaq4370-4
> > > + - adi,adaq4380-4
> > > then:
> > > properties:
> > > refio-supply: false
> > > @@ -145,6 +199,24 @@ allOf:
> > > properties:
> > > refin-supply: false
> > >
> > > + # adaq devices need more supplies
> > > + - if:
> > > + properties:
> > > + compatible:
> > > + enum:
> > > + - adi,adaq4370-4
> > > + - adi,adaq4380-4
> > > + then:
> > > + required:
> > > + - vs-p-supply
> > > + - vs-n-supply
> > > + - ldo-supply
> > > + else:
> > > + properties:
> > > + vs-p-supply: false
> > > + vs-n-supply: false
> > > + ldo-supply: false
> > > +
> > > examples:
> > > - |
> > > #include <dt-bindings/interrupt-controller/irq.h>
> > > @@ -169,3 +241,48 @@ examples:
> > > refio-supply = <&supply_2_5V>;
> > > };
> > > };
> > > +
> > > + - |
> > > + #include <dt-bindings/interrupt-controller/irq.h>
> > > +
> > > + spi {
> > > + #address-cells = <1>;
> > > + #size-cells = <0>;
> > > +
> > > + adc@0 {
> > > + compatible = "adi,adaq4380-4";
> > > + 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>;
> > > + refin-supply = <&supply_5V>;
> > > + vs-p-supply = <&supply_5V>;
> > > + vs-n-supply = <&supply_0V>;
> > > + ldo-supply = <&supply_5V>;
> > > +
> > > + #address-cells = <1>;
> > > + #size-cells = <0>;
> > > +
> > > + channel@0 {
> > > + reg = <0>;
> > > + adi,gain-milli = <300>;
> > > + };
> > > +
> > > + channel@2 {
> > > + reg = <2>;
> > > + adi,gain-milli = <600>;
> > > + };
> > > +
> > > + channel@3 {
> > > + reg = <3>;
> > > + adi,gain-milli = <1000>;
> > > + };
> > > + };
> > > + };
> > >
> >
^ permalink raw reply [flat|nested] 16+ messages in thread
end of thread, other threads:[~2024-10-21 18:17 UTC | newest]
Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-15 9:09 [PATCH RFC 0/4] ad7380: add adaq4370-4 and adaq4380-4 support Julien Stephan
2024-10-15 9:09 ` [PATCH RFC 1/4] dt-bindings: iio: adc: ad7380: add adaq4370-4 and adaq4380-4 compatible parts Julien Stephan
2024-10-15 20:49 ` Rob Herring
2024-10-17 18:05 ` Jonathan Cameron
2024-10-18 7:36 ` Julien Stephan
2024-10-18 18:09 ` Jonathan Cameron
2024-10-20 13:20 ` Jonathan Cameron
2024-10-21 13:25 ` Julien Stephan
2024-10-21 18:17 ` Jonathan Cameron
2024-10-15 9:09 ` [PATCH RFC 2/4] iio: adc: ad7380: fix oversampling formula Julien Stephan
2024-10-15 9:09 ` [PATCH RFC 3/4] iio: adc: ad7380: add support for adaq4370-4 and adaq4380-4 Julien Stephan
2024-10-20 13:18 ` Jonathan Cameron
2024-10-15 9:09 ` [PATCH RFC 4/4] docs: iio: ad7380: add " Julien Stephan
2024-10-15 16:43 ` [PATCH RFC 0/4] ad7380: add adaq4370-4 and adaq4380-4 support Conor Dooley
2024-10-16 7:25 ` Julien Stephan
2024-10-18 18:11 ` Jonathan Cameron
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).