iio: adc: Add support for LTC2378 and similar ADCs
Marcelo Schmitt
maintainerv9 cover iio: adc: Add support for LTC2378 and similar ADCs
This patch series adds support for LTC2378 and similar low noise, low power, high speed, successive approximation register (SAR) ADCs. These ADCs are similar among each other, varying mainly on the amount of precision bits, maximum sample rate, and input configuration (either fully differential or pseudo-differential).
Patch 1 adds device tree documentation for LTC2378.
Patch 2 enables single-shot sample read with a GPIO connected to the LTC2378 CNV pin.
Patch 3 enables high-speed data captures with SPI offloading.
The setup is similar to AD4030, with a specialized PWM generator being used both for SPI offload triggering and conversion start signaling.
Patch 4 enables running buffered data captures without SPI offloading.
Patch 5 adds support for LTC2338-18.
Patch 6 recommends using voltageY-voltageZ ABI for differential parts.
Even though these parts are somewhat similar to AD4000, the wiring configuration for LTC parts is different as well as the available HDL for high speed sample rate mode. Because of that, I propose creating a new device driver for supporting LTC2378-like devices.
Specifications can be found at:
https://www.analog.com/media/en/technical-documentation/data-sheets/233818fa.pdf
https://www.analog.com/media/en/technical-documentation/data-sheets/236416fa.pdf
https://www.analog.com/media/en/technical-documentation/data-sheets/236418f.pdf
https://www.analog.com/media/en/technical-documentation/data-sheets/236716fa.pdf
https://www.analog.com/media/en/technical-documentation/data-sheets/236718f.pdf
https://www.analog.com/media/en/technical-documentation/data-sheets/236816f.pdf
https://www.analog.com/media/en/technical-documentation/data-sheets/236818f.pdf
https://www.analog.com/media/en/technical-documentation/data-sheets/236918fa.pdf
https://www.analog.com/media/en/technical-documentation/data-sheets/237016fa.pdf
https://www.analog.com/media/en/technical-documentation/data-sheets/237616fa.pdf
https://www.analog.com/media/en/technical-documentation/data-sheets/237618fa.pdf
https://www.analog.com/media/en/technical-documentation/data-sheets/237620fb.pdf
https://www.analog.com/media/en/technical-documentation/data-sheets/237716fa.pdf
https://www.analog.com/media/en/technical-documentation/data-sheets/237718fa.pdf
https://www.analog.com/media/en/technical-documentation/data-sheets/237720fb.pdf
https://www.analog.com/media/en/technical-documentation/data-sheets/237816fa.pdf
https://www.analog.com/media/en/technical-documentation/data-sheets/237818fa.pdf
https://www.analog.com/media/en/technical-documentation/data-sheets/237820fb.pdf
https://www.analog.com/media/en/technical-documentation/data-sheets/237918fb.pdf
https://www.analog.com/media/en/technical-documentation/data-sheets/238016fb.pdf
Previous submissions:
v8: https://lore.kernel.org/linux-iio/[email protected]/
v7: https://lore.kernel.org/linux-iio/[email protected]/
v6: https://lore.kernel.org/linux-iio/[email protected]/
v5: https://lore.kernel.org/linux-iio/[email protected]/
v4: https://lore.kernel.org/linux-iio/[email protected]/
v3: https://lore.kernel.org/linux-iio/[email protected]/
v2: https://lore.kernel.org/linux-iio/[email protected]/
v1: https://lore.kernel.org/linux-iio/[email protected]/
Change log v8 -> v9:
[DT]
No changes in device tree doc.
[IIO]
- Took LTC2338-18 input attenuation effect into account for _scale calculation.
- Split LTC2338-18 into a separate new patch.
With best regards,
Marcelo
Marcelo Schmitt (6):
dt-bindings: iio: adc: Add ltc2378
iio: adc: ltc2378: Add support for LTC2378-20 and similar ADCs
iio: adc: ltc2378: Enable high-speed data capture
iio: adc: ltc2378: Enable triggered buffer data capture
iio: adc: ltc2378: Add support for LTC2338-18
iio: ABI: Encourage differential voltage ABI usage
Documentation/ABI/testing/sysfs-bus-iio | 9 +- .../bindings/iio/adc/adi,ltc2378.yaml | 170 ++++ MAINTAINERS | 8 + drivers/iio/adc/Kconfig | 19 + drivers/iio/adc/Makefile | 1 + drivers/iio/adc/ltc2378.c | 856 ++++++++++++++++++ 6 files changed, 1059 insertions(+), 4 deletions(-) create mode 100644 Documentation/devicetree/bindings/iio/adc/adi,ltc2378.yaml create mode 100644 drivers/iio/adc/ltc2378.c
base-commit: aa58ecc73466d0cb8c418de98e2225490bf600e3
Signature · 1 line
2.53.0
Marcelo Schmitt
maintainerPATCH v9 1/6 dt-bindings: iio: adc: Add ltc2378
Document how to describe LTC2378-20 and similar ADCs in device tree.
---
Change log v8 -> v9:
No changes in device tree doc.
.../bindings/iio/adc/adi,ltc2378.yaml | 170 ++++++++++++++++++ MAINTAINERS | 7 + 2 files changed, 177 insertions(+) create mode 100644 Documentation/devicetree/bindings/iio/adc/adi,ltc2378.yaml
Documentation/devicetree/bindings/iio/adc/adi,ltc2378.yaml new file +170 -0
@@ -0,0 +1,170 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/adc/adi,ltc2378.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Analog Devices LTC2378 and similar Analog to Digital Converters + +maintainers: + - Marcelo Schmitt <[email protected]> + +description: | + Analog Devices LTC2378 series of ADCs. + Specifications can be found at: + https://www.analog.com/media/en/technical-documentation/data-sheets/233818fa.pdf + https://www.analog.com/media/en/technical-documentation/data-sheets/236416fa.pdf + https://www.analog.com/media/en/technical-documentation/data-sheets/236418f.pdf + https://www.analog.com/media/en/technical-documentation/data-sheets/236716fa.pdf + https://www.analog.com/media/en/technical-documentation/data-sheets/236718f.pdf + https://www.analog.com/media/en/technical-documentation/data-sheets/236816f.pdf + https://www.analog.com/media/en/technical-documentation/data-sheets/236818f.pdf + https://www.analog.com/media/en/technical-documentation/data-sheets/236918fa.pdf + https://www.analog.com/media/en/technical-documentation/data-sheets/237016fa.pdf + https://www.analog.com/media/en/technical-documentation/data-sheets/237616fa.pdf + https://www.analog.com/media/en/technical-documentation/data-sheets/237618fa.pdf + https://www.analog.com/media/en/technical-documentation/data-sheets/237620fb.pdf + https://www.analog.com/media/en/technical-documentation/data-sheets/237716fa.pdf + https://www.analog.com/media/en/technical-documentation/data-sheets/237718fa.pdf + https://www.analog.com/media/en/technical-documentation/data-sheets/237720fb.pdf + https://www.analog.com/media/en/technical-documentation/data-sheets/237816fa.pdf + https://www.analog.com/media/en/technical-documentation/data-sheets/237818fa.pdf + https://www.analog.com/media/en/technical-documentation/data-sheets/237820fb.pdf + https://www.analog.com/media/en/technical-documentation/data-sheets/237918fb.pdf + https://www.analog.com/media/en/technical-documentation/data-sheets/238016fb.pdf + +$ref: /schemas/spi/spi-peripheral-props.yaml# + +properties: + compatible: + oneOf: + # Single compatible string match. + - enum: + - adi,ltc2338-18 + - adi,ltc2364-16 + - adi,ltc2364-18 + - adi,ltc2376-16 + - adi,ltc2376-18 + - adi,ltc2376-20 + + # Low sample rate fallback for 16-bit unipolar sensors. + - items: + - enum: + - adi,ltc2370-16 # 2 MSPS + - adi,ltc2368-16 # 1 MSPS + - adi,ltc2367-16 # 500 kSPS + - const: adi,ltc2364-16 # fallback (250 kSPS) + + # Low sample rate fallback for 18-bit unipolar sensors. + - items: + - enum: + - adi,ltc2369-18 # 1.6 MSPS + - adi,ltc2368-18 # 1 MSPS + - adi,ltc2367-18 # 500 kSPS + - const: adi,ltc2364-18 # fallback (250 kSPS) + + # Low sample rate fallback for 16-bit bipolar sensors. + - items: + - enum: + - adi,ltc2380-16 # 2 MSPS + - adi,ltc2378-16 # 1 MSPS + - adi,ltc2377-16 # 500 kSPS + - const: adi,ltc2376-16 # fallback (250 kSPS) + + # Low sample rate fallback for 18-bit bipolar sensors. + - items: + - enum: + - adi,ltc2379-18 # 1.6 MSPS + - adi,ltc2378-18 # 1 MSPS + - adi,ltc2377-18 # 500 kSPS + - const: adi,ltc2376-18 # fallback (250 kSPS) + + # Low sample rate fallback for 20-bit bipolar sensors. + - items: + - enum: + - adi,ltc2378-20 # 1 MSPS + - adi,ltc2377-20 # 500 kSPS + - const: adi,ltc2376-20 # fallback (250 kSPS) + + reg: + maxItems: 1 + + spi-max-frequency: + maximum: 100000000 + + vdd-supply: + description: A 2.5V supply that powers the chip (VDD). + + ovdd-supply: + description: + A 1.71V to 5.25V supply that sets the logic level for digital interface. + + ref-supply: + description: + Voltage reference input that determines the scale of ADC conversions. + + refin-supply: + description: + Alternative voltage reference input. + + cnv-gpios: + description: + When provided, this property indicates the GPIO that is connected to the + CNV pin. + maxItems: 1 + + pwms: + description: PWM signal connected to the CNV pin. + maxItems: 1 + + interrupts: + description: + Interrupt for signaling the completion of conversion results. The active + low signal provided on the BUSY pin asserts when ADC conversions finish. + maxItems: 1 + +required: + - compatible + - reg + - vdd-supply + - ovdd-supply + +allOf: + # Except for LTC2338, all designs require a voltage reference input + - if: + properties: + compatible: + not: + contains: + enum: + - adi,ltc2338-18 + then: + required: + - ref-supply + properties: + refin-supply: false + else: + properties: + ref-supply: false + +unevaluatedProperties: false + +examples: + - | + #include <dt-bindings/gpio/gpio.h> + #include <dt-bindings/interrupt-controller/irq.h> + spi { + #address-cells = <1>; + #size-cells = <0>; + adc@0 { + compatible = "adi,ltc2378-20", "adi,ltc2376-20"; + reg = <0>; + spi-max-frequency = <71000000>; + vdd-supply = <&supply_2_5V>; + ovdd-supply = <&supply_3_3V>; + ref-supply = <&supply_5V>; + cnv-gpios = <&gpio0 88 GPIO_ACTIVE_HIGH>; + interrupts = <7 IRQ_TYPE_EDGE_FALLING>; + interrupt-parent = <&gpio>; + }; + };
MAINTAINERS +7 -0
@@ -15343,6 +15343,13 @@ S: Maintained F: Documentation/devicetree/bindings/iio/dac/lltc,ltc1660.yaml F: drivers/iio/dac/ltc1660.c +LTC2378 IIO ADC DRIVER +M: Marcelo Schmitt <[email protected]> +L: [email protected] +S: Supported +W: https://ez.analog.com/linux-software-drivers +F: Documentation/devicetree/bindings/iio/adc/adi,ltc2378.yaml + LTC2664 IIO DAC DRIVER M: Michael Hennerich <[email protected]> M: Kim Seer Paller <[email protected]>
Signature · 1 line
2.53.0
Marcelo Schmitt
maintainerPATCH v9 2/6 iio: adc: ltc2378: Add support for LTC2378-20 and similar ADCs
In reply to Marcelo SchmittSupport for LTC2378-20 and similar analog-to-digital converters.
---
Change log v8 -> v9:
- Extracted LTC2338-18 support to a separate follow up patch.
MAINTAINERS | 1 + drivers/iio/adc/Kconfig | 12 ++ drivers/iio/adc/Makefile | 1 + drivers/iio/adc/ltc2378.c | 387 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 401 insertions(+) create mode 100644 drivers/iio/adc/ltc2378.c
MAINTAINERS +1 -0
@@ -15349,6 +15349,7 @@ L: [email protected] S: Supported W: https://ez.analog.com/linux-software-drivers F: Documentation/devicetree/bindings/iio/adc/adi,ltc2378.yaml +F: drivers/iio/adc/ltc2378.c LTC2664 IIO DAC DRIVER M: Michael Hennerich <[email protected]>
drivers/iio/adc/Kconfig +12 -0
@@ -943,6 +943,18 @@ config LTC2309 This driver can also be built as a module. If so, the module will be called ltc2309. +config LTC2378 + tristate "Analog Devices LTC2378 ADC driver" + depends on SPI + depends on REGULATOR || COMPILE_TEST + depends on GPIOLIB + help + Say yes here to build support for Analog Devices LTC2378-20 and + similar analog to digital converters. + + This driver can also be built as a module. If so, the module will + be called ltc2378. + config LTC2471 tristate "Linear Technology LTC2471 and LTC2473 ADC driver" depends on I2C
drivers/iio/adc/Makefile +1 -0
@@ -81,6 +81,7 @@ obj-$(CONFIG_LP8788_ADC) += lp8788_adc.o obj-$(CONFIG_LPC18XX_ADC) += lpc18xx_adc.o obj-$(CONFIG_LPC32XX_ADC) += lpc32xx_adc.o obj-$(CONFIG_LTC2309) += ltc2309.o +obj-$(CONFIG_LTC2378) += ltc2378.o obj-$(CONFIG_LTC2471) += ltc2471.o obj-$(CONFIG_LTC2485) += ltc2485.o obj-$(CONFIG_LTC2496) += ltc2496.o ltc2497-core.o
drivers/iio/adc/ltc2378.c new file +387 -0
387 lines not on this page · raw message
Signature · 1 line
2.53.0
[email protected]
AI reviewRe: [PATCH v9 2/6] iio: adc: ltc2378: Add support for LTC2378-20 and similar ADCs
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [High] Holding CNV high during SPI transfer breaks 3-wire SPI wiring mode. --
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Holding CNV high during SPI transfer breaks 3-wire SPI wiring mode. --
--- Patch [2]: [PATCH v9 2/6] iio: adc: ltc2378: Add support for LTC2378-20 and similar ADCs --- commit 4d4231cee28f9742280dd61ed84f85cf3b4e0386
Author: Marcelo Schmitt <[email protected]>
iio: adc: ltc2378: Add support for LTC2378-20 and similar ADCs
This commit adds support for the Analog Devices LTC2378-20 and similar analog-to-digital converters.
Quoted 4 lines
drivers/iio/adc/ltc2378.c new file +0
-0
[ ... ]
drivers/iio/adc/ltc2378.c line 187
Quoted 8 lines
drivers/iio/adc/ltc2378.c new file +8
-0+static int ltc2378_convert_and_acquire (struct ltc2378_state *st) +{ +int ret; + +/* Cause a rising edge of CNV to initiate a new ADC conversion */ +gpiod_set_value_cansleep (st->cnv_gpio,1 ); +fsleep (LTC2378_MAX_DATA_WAIT_US ); + ret =spi_sync_transfer (st->spi, &st->xfer,1 );
[Severity: High]
Does holding CNV high during the SPI transfer break 3-wire SPI wiring mode? In 3-wire mode (where SDI is tied to GND), the SDO pin of the ADC remains in a high-impedance state as long as the CNV pin is held high.
Since the CNV pin remains high throughout the SPI transfer, could the SPI controller clock in garbage data from a floating bus?
Would lowering CNV after the fsleep() wait and before calling spi_sync_transfer() correctly enable SDO for 3-wire mode while remaining compatible with 4-wire (CS) mode?
Quoted 4 lines
drivers/iio/adc/ltc2378.c new file +4
-0+gpiod_set_value_cansleep (st->cnv_gpio,0 ); + +return ret; +}
[ ... ]
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
Re: [PATCH v9 2/6] iio: adc: ltc2378: Add support for LTC2378-20 and similar ADCs
Quoted 18 lines · On 07/27, [email protected] wrote:
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Holding CNV high during SPI transfer breaks 3-wire SPI wiring mode. ----- Patch [2]: [PATCH v9 2/6] iio: adc: ltc2378: Add support for LTC2378-20 and similar ADCs --- commit
4d4231cee28f9742280dd61ed84f85cf3b4e0386
Author: Marcelo Schmitt <[email protected]>iio: adc: ltc2378: Add support for LTC2378-20 and similar ADCs
This commit adds support for the Analog Devices LTC2378-20 and similar analog-to-digital converters.
Quoted 4 lines
drivers/iio/adc/ltc2378.c new file +0
-0[ ... ]
Quoted 13 lines
drivers/iio/adc/ltc2378.c line 187
Quoted 8 lines
drivers/iio/adc/ltc2378.c new file +8
-0+static int ltc2378_convert_and_acquire (struct ltc2378_state *st) +{ +int ret; + +/* Cause a rising edge of CNV to initiate a new ADC conversion */ +gpiod_set_value_cansleep (st->cnv_gpio,1 ); +fsleep (LTC2378_MAX_DATA_WAIT_US ); + ret =spi_sync_transfer (st->spi, &st->xfer,1 );[Severity: High]
Does holding CNV high during the SPI transfer break 3-wire SPI wiring mode? In 3-wire mode (where SDI is tied to GND), the SDO pin of the ADC remains in a high-impedance state as long as the CNV pin is held high.
No.
Quoted 3 lines
Since the CNV pin remains high throughout the SPI transfer, could the SPI controller clock in garbage data from a floating bus?
No. That would only happen if the controller runs more SCLKs than the amount of precision/resolution bits (non-offload use case) but in those cases we right shift by _storage_bits - _real_bits, discarding any potential unwanted noise.
Quoted 4 lines
Would lowering CNV after the
fsleep()wait and before callingspi_sync_transfer()correctly enable SDO for 3-wire mode while remaining compatible with 4-wire (CS) mode?
These devices don't have a CS pin. SDI is tied to GND in the currently supported wiring configuration (single device normal mode). There is no SPI 4-wire mode.
Quoted 9 lines
Quoted 5 lines
drivers/iio/adc/ltc2378.c new file +4
-0+gpiod_set_value_cansleep (st->cnv_gpio,0 ); + +return ret; +}[ ... ]
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
Marcelo Schmitt
maintainerPATCH v9 3/6 iio: adc: ltc2378: Enable high-speed data capture
In reply to Marcelo SchmittMake use of SPI transfer offloading to speed up data capture, enabling data acquisition at faster sample rates (up to 2 MSPS).
---
Change log v8 -> v9:
No changes in v9.
drivers/iio/adc/Kconfig | 6 + drivers/iio/adc/ltc2378.c | 404 +++++++++++++++++++++++++++++++++++++- 2 files changed, 407 insertions(+), 3 deletions(-)
drivers/iio/adc/Kconfig +6 -0
@@ -948,6 +948,12 @@ config LTC2378 depends on SPI depends on REGULATOR || COMPILE_TEST depends on GPIOLIB + depends on PWM + select IIO_BUFFER + select IIO_BUFFER_DMA + select IIO_BUFFER_DMAENGINE + select SPI_OFFLOAD + select SPI_OFFLOAD_TRIGGER_PWM help Say yes here to build support for Analog Devices LTC2378-20 and similar analog to digital converters.
drivers/iio/adc/ltc2378.c +401 -3
559 lines not on this page · raw message
Signature · 1 line
2.53.0
[email protected]
AI reviewRe: [PATCH v9 3/6] iio: adc: ltc2378: Enable high-speed data capture
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [High] Missing bounds check on rounded PWM period leads to divide-by-zero panic and ADC overclocking. --
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Missing bounds check on rounded PWM period leads to divide-by-zero panic and ADC overclocking. --
--- Patch [3]: [PATCH v9 3/6] iio: adc: ltc2378: Enable high-speed data capture --- commit ebabc81c7c955467e478de14bdd64baea8b0e439
Author: Marcelo Schmitt <[email protected]>
iio: adc: ltc2378: Enable high-speed data capture
Make use of SPI transfer offloading to speed up data capture, enabling data acquisition at faster sample rates (up to 2 MSPS).
Quoted 4 lines
drivers/iio/adc/ltc2378.c +0
-0
[ ... ]
Quoted 37 lines
drivers/iio/adc/ltc2378.c +37
-0+static int ltc2378_update_conversion_rate (struct ltc2378_state *st,int freq_Hz) +{ +struct spi_offload_trigger_config config = st->offload_trigger_config; +unsigned int min_read_offset, offload_period_ns; +struct pwm_waveform cnv_wf = { }; +u64 target =LTC2378_TCNV_HIGH_NS ; +unsigned int count; +u64 offload_offset_ns; +int ret; + +if (freq_Hz ==0 ) +return -EINVAL ; + +if (!in_range (freq_Hz,1 , st->info->max_sample_rate_Hz)) +return -ERANGE ; + +/* Configure CNV PWM waveform */ + cnv_wf.period_length_ns =DIV_ROUND_CLOSEST (NSEC_PER_SEC , freq_Hz); + +/* +* Ensure CNV high time meets minimum requirement (20ns). The PWM +* hardware may round the duty cycle, so iterate until we get at least +* the minimum required high time (or reach a try count limit). +*/ + count =100 ; +do { + cnv_wf.duty_length_ns = target; + ret =pwm_round_waveform_might_sleep (st->cnv_trigger, &cnv_wf); +if (ret) +return ret; + target +=10 ;/* Increment by PWM duty cycle period */ + }while (count-- && cnv_wf.duty_length_ns <LTC2378_TCNV_HIGH_NS ); + +/* Check the minimum CNV high time is met */ +if (cnv_wf.duty_length_ns <LTC2378_TCNV_HIGH_NS ) +return -EDOM ; +
drivers/iio/adc/ltc2378.c static int ltc2378_read_raw(struct iio_dev *indio_dev, · line 467
Quoted 10 lines
drivers/iio/adc/ltc2378.c +10
-0+/* +* Configure SPI offload PWM trigger. +* The trigger should fire after tBUSYLH + tCONV + tDSDOBUSYL. +* Minimum time needed: TBUSYLH (13ns) + TCONV (part-specific) + TDSDOBUSYL (5ns) +* +* Use the same period as CNV PWM to avoid timing issues. +* Convert back from period to frequency for the SPI offload API. +*/ + offload_period_ns = cnv_wf.period_length_ns; + config.periodic.frequency_hz =div_u64 (HZ_PER_GHZ , offload_period_ns);
[Severity: High]
If the hardware PWM driver rounds the requested period up beyond 1e9 ns (for example, if a 1 Hz frequency request yields 1,000,000,001 ns), does this division evaluate to 0?
Quoted 7 lines
drivers/iio/adc/ltc2378.c +7
-0+ min_read_offset =LTC2378_TBUSYLH_NS + st->info->tconv_ns +LTC2378_TDSDOBUSYL_NS ; + offload_offset_ns = min_read_offset; + count =100 ; + do { + config.periodic.offset_ns = offload_offset_ns; + ret = spi_offload_trigger_validate(st->offload_trigger, &config); + if (ret)
drivers/iio/adc/ltc2378.c static int ltc2378_read_raw(struct iio_dev *indio_dev, · line 484
Quoted 10 lines
drivers/iio/adc/ltc2378.c +10
-0+return ret; + offload_offset_ns +=10 ; + }while (count-- && config.periodic.offset_ns < min_read_offset); + +/* Check the minimum CNV to SCLK delay is met */ +if (config.periodic.offset_ns < min_read_offset) +return -EDOM ; + +/* Check the PWM periods remain the same */ + offload_period_ns =div64_u64 (HZ_PER_GHZ , config.periodic.frequency_hz);
[Severity: High]
If frequency_hz evaluates to 0 above, does this cause a divide-by-zero panic here?
Additionally, if the PWM driver rounds the period down when the user requests max_sample_rate_Hz, could the actual frequency silently exceed the ADC's hardware limits? Does the period need to be re-validated against bounds after pwm_round_waveform_might_sleep() is called?
Quoted 9 lines
drivers/iio/adc/ltc2378.c +9
-0+if (cnv_wf.period_length_ns != offload_period_ns) +return -EDOM ; + + st->offload_trigger_config = config; + st->cnv_wf = cnv_wf; + st->cnv_Hz =DIV_ROUND_CLOSEST_ULL (HZ_PER_GHZ , cnv_wf.period_length_ns); + +return 0 ; +}
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=3
Marcelo Schmitt
maintainerPATCH v9 4/6 iio: adc: ltc2378: Enable triggered buffer data capture
In reply to Marcelo SchmittEnable users to run triggered data captures with LTC2378 and similar ADCs.
---
Change log v8 -> v9:
No changes in v9.
drivers/iio/adc/Kconfig | 1 + drivers/iio/adc/ltc2378.c | 73 +++++++++++++++++++++++++++------------ 2 files changed, 52 insertions(+), 22 deletions(-)
drivers/iio/adc/Kconfig +1 -0
@@ -952,6 +952,7 @@ config LTC2378 select IIO_BUFFER select IIO_BUFFER_DMA select IIO_BUFFER_DMAENGINE + select IIO_TRIGGERED_BUFFER select SPI_OFFLOAD select SPI_OFFLOAD_TRIGGER_PWM help
drivers/iio/adc/ltc2378.c +51 -22
217 lines not on this page · raw message
Signature · 1 line
2.53.0
Marcelo Schmitt
maintainerPATCH v9 5/6 iio: adc: ltc2378: Add support for LTC2338-18
In reply to Marcelo SchmittLTC2338-18 is similar to LTC2378-18, differentiating from the already supported part mainly on the embedment of an internal voltage reference and addition of a resistor divider network connected to the input signal path. Extend the device driver, handling the internal reference and input signal attenuation, enabling it to also support LTC2338-18.
---
New patch mainly extracted from the base driver patch with the addition of input attenuation handling for LTC2338-18.
drivers/iio/adc/ltc2378.c | 44 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-)
drivers/iio/adc/ltc2378.c +43 -1
@@ -107,6 +107,8 @@struct ltc2378_chip_info {const char *name; +unsigned int internal_ref_uV; +struct u32_fract internal_div;struct iio_chan_spec chan[2 ];/* 1 physical chan + 1 timestamp chan */ struct iio_chan_spec offload_chan;unsigned int max_sample_rate_Hz;
@@ -145,6 +147,16 @@ struct ltc2378_state { } scan__aligned(IIO_DMA_MINALIGN) ; }; +static const struct ltc2378_chip_info ltc2338_18_chip_info = { + .name ="ltc2338-18" , + .internal_ref_uV =2048000 , + .internal_div = { .numerator =5 , .denominator =2 }, + .chan = {LTC2378_DIFF_CHANNEL (18 ),IIO_CHAN_SOFT_TIMESTAMP (1 ) }, + .offload_chan =LTC2378_OFFLOAD_DIFF_CHANNEL (18 ), + .max_sample_rate_Hz =1 *HZ_PER_MHZ , + .tconv_ns =527 , +}; +static const struct ltc2378_chip_info ltc2364_16_chip_info = { .name ="ltc2364-16" , .chan = {LTC2378_PSEUDO_DIFF_CHANNEL (16 ),IIO_CHAN_SOFT_TIMESTAMP (1 ) },
@@ -383,7 +395,10 @@ static int ltc2378_read_raw(struct iio_dev *indio_dev,return IIO_VAL_INT ; }case IIO_CHAN_INFO_SCALE : +struct u32_fract fract = st->info->internal_div; *val = st->ref_uV /MILLI ; +if (fract.numerator && fract.denominator) + *val =mult_frac (*val, fract.numerator, fract.denominator);/* * For all LTC2378-like devices, the amount of bits that express * voltage magnitude depend on the polarity / output code format:
@@ -641,6 +656,28 @@ static const struct spi_offload_config ltc2378_offload_config = { SPI_OFFLOAD_CAP_RX_STREAM_DMA, }; +static int ltc2378_refin_setup (struct device *dev,struct ltc2378_state *st) +{ +int ret; + +/* +* The internal reference buffer amplifies both the internal reference +* and REFIN by a factor of 2. +*/ + ret =devm_regulator_get_enable_read_voltage (dev,"refin" ); +if (ret == -ENODEV ) {/* refin is optional */ + st->ref_uV = st->info->internal_ref_uV *2 ; +return 0 ; + } + +if (ret <0 ) +return dev_err_probe (dev, ret,"failed to read refin regulator\n" ); + + st->ref_uV = ret *2 ; + +return 0 ; +} +static int ltc2378_ref_setup (struct device *dev,struct ltc2378_state *st) {int ret;
@@ -676,7 +713,10 @@ static int ltc2378_probe(struct spi_device *spi)if (!st->info)return -EINVAL ; - ret =ltc2378_ref_setup (dev, st); +if (st->info->internal_ref_uV) + ret =ltc2378_refin_setup (dev, st); +else + ret =ltc2378_ref_setup (dev, st);if (ret)return ret;
@@ -750,6 +790,7 @@ static int ltc2378_probe(struct spi_device *spi) }static const struct of_device_id ltc2378_of_match[] = { + { .compatible ="adi,ltc2338-18" , .data = <c2338_18_chip_info }, { .compatible ="adi,ltc2364-16" , .data = <c2364_16_chip_info }, { .compatible ="adi,ltc2364-18" , .data = <c2364_18_chip_info }, { .compatible ="adi,ltc2367-16" , .data = <c2367_16_chip_info },
@@ -774,6 +815,7 @@ static const struct of_device_id ltc2378_of_match[] = {MODULE_DEVICE_TABLE (of, ltc2378_of_match);static const struct spi_device_id ltc2378_spi_id[] = { + { .name ="ltc2338-18" , .driver_data = (kernel_ulong_t)<c2338_18_chip_info }, { .name ="ltc2364-16" , .driver_data = (kernel_ulong_t)<c2364_16_chip_info }, { .name ="ltc2364-18" , .driver_data = (kernel_ulong_t)<c2364_18_chip_info }, { .name ="ltc2367-16" , .driver_data = (kernel_ulong_t)<c2367_16_chip_info },
Signature · 1 line
2.53.0
[email protected]
AI reviewRe: [PATCH v9 5/6] iio: adc: ltc2378: Add support for LTC2338-18
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Low] Declaring a variable immediately after a switch case label without a block statement causes a…
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] Declaring a variable immediately after a switch case label without a block statement causes a compilation error. --
--- Patch [5]: [PATCH v9 5/6] iio: adc: ltc2378: Add support for LTC2338-18 --- commit 29728b1d34f34b2970657e2d83536de22940ee2e
Author: Marcelo Schmitt <[email protected]>
iio: adc: ltc2378: Add support for LTC2338-18
This commit adds support for the LTC2338-18 ADC to the existing ltc2378 driver. It extends the driver to handle the internal voltage reference and input signal attenuation specific to this part.
Quoted 3 lines
drivers/iio/adc/ltc2378.c +0
-0
[ ... ]
drivers/iio/adc/ltc2378.c static int ltc2378_read_raw(struct iio_dev *indio_dev, · line 398
Quoted 5 lines
drivers/iio/adc/ltc2378.c +1
-0@@ -383,7 +395,10 @@ static int ltc2378_read_raw(struct iio_dev *indio_dev,return IIO_VAL_INT ; }case IIO_CHAN_INFO_SCALE : +struct u32_fract fract = st->info->internal_div;
[Severity: Low]
Does this declaration cause a build error? Declaring a variable immediately after a switch case label without a block statement is not a valid statement in C and usually causes a compiler error. Could this case be wrapped in a block to scope the variable, or the declaration be moved to the top of the function?
Quoted 6 lines
drivers/iio/adc/ltc2378.c +2
-0*val = st->ref_uV /MILLI ; +if (fract.numerator && fract.denominator) + *val =mult_frac (*val, fract.numerator, fract.denominator);/* * For all LTC2378-like devices, the amount of bits that express * voltage magnitude depend on the polarity / output code format:
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=5
Re: [PATCH v9 5/6] iio: adc: ltc2378: Add support for LTC2338-18
Quoted 20 lines · On 07/27, [email protected] wrote:
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] Declaring a variable immediately after a switch case label without a block statement causes a compilation error. ----- Patch [5]: [PATCH v9 5/6] iio: adc: ltc2378: Add support for LTC2338-18 --- commit
29728b1d34f34b2970657e2d83536de22940ee2e
Author: Marcelo Schmitt <[email protected]>iio: adc: ltc2378: Add support for LTC2338-18
This commit adds support for the LTC2338-18 ADC to the existing ltc2378 driver. It extends the driver to handle the internal voltage reference and input signal attenuation specific to this part.
Quoted 3 lines
drivers/iio/adc/ltc2378.c +0
-0[ ... ]
Quoted 8 lines
drivers/iio/adc/ltc2378.c static int ltc2378_read_raw(struct iio_dev *indio_dev, · line 398
Quoted 5 lines
drivers/iio/adc/ltc2378.c +1
-0@@ -383,7 +395,10 @@ static int ltc2378_read_raw(struct iio_dev *indio_dev,return IIO_VAL_INT ; }case IIO_CHAN_INFO_SCALE : +struct u32_fract fract = st->info->internal_div;[Severity: Low]
Does this declaration cause a build error?
No, at least not when I built with clang/llvm-22.
Quoted 15 lines
Declaring a variable immediately
after a switch case label without a block statement is not a valid statement in C and usually causes a compiler error. Could this case be wrapped in a block to scope the variable, or the declaration be moved to the top of the function?Quoted 6 lines
drivers/iio/adc/ltc2378.c +2
-0*val = st->ref_uV /MILLI ; +if (fract.numerator && fract.denominator) + *val =mult_frac (*val, fract.numerator, fract.denominator);/* * For all LTC2378-like devices, the amount of bits that express * voltage magnitude depend on the polarity / output code format: Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=5
Jonathan Cameron
maintainerRe: [PATCH v9 5/6] iio: adc: ltc2378: Add support for LTC2338-18
Quoted 29 lines · On Tue, 28 Jul 2026 10:12:34 -0300 Marcelo Schmitt…
Quoted 20 lines · On 07/27, [email protected] wrote:
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] Declaring a variable immediately after a switch case label without a block statement causes a compilation error. ----- Patch [5]: [PATCH v9 5/6] iio: adc: ltc2378: Add support for LTC2338-18 --- commit
29728b1d34f34b2970657e2d83536de22940ee2e
Author: Marcelo Schmitt <[email protected]>iio: adc: ltc2378: Add support for LTC2338-18
This commit adds support for the LTC2338-18 ADC to the existing ltc2378 driver. It extends the driver to handle the internal voltage reference and input signal attenuation specific to this part.
Quoted 3 lines
drivers/iio/adc/ltc2378.c +0
-0[ ... ]
Quoted 8 lines
drivers/iio/adc/ltc2378.c static int ltc2378_read_raw(struct iio_dev *indio_dev, · line 398
Quoted 5 lines
drivers/iio/adc/ltc2378.c +1
-0@@ -383,7 +395,10 @@ static int ltc2378_read_raw(struct iio_dev *indio_dev,return IIO_VAL_INT ; }case IIO_CHAN_INFO_SCALE : +struct u32_fract fract = st->info->internal_div;[Severity: Low]
Does this declaration cause a build error?
Quoted 1 line
No, at least not when I built with clang/llvm-22.
Maybe but given we still stick to declarations at top of scope (if not strictly required) makes me want add scope here anyway.
So I tweaked it to add the {}
Series applied to the testing branch of iio.git.
Thanks,
Jonathan
Quoted 17 lines
Quoted 16 lines
Declaring a variable immediately
after a switch case label without a block statement is not a valid statement in C and usually causes a compiler error. Could this case be wrapped in a block to scope the variable, or the declaration be moved to the top of the function?Quoted 6 lines
drivers/iio/adc/ltc2378.c +2
-0*val = st->ref_uV /MILLI ; +if (fract.numerator && fract.denominator) + *val =mult_frac (*val, fract.numerator, fract.denominator);/* * For all LTC2378-like devices, the amount of bits that express * voltage magnitude depend on the polarity / output code format: Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=5
Re: [PATCH v9 5/6] iio: adc: ltc2378: Add support for LTC2338-18
In reply to Marcelo SchmittQuoted 5 lines · Marcelo Schmitt
LTC2338-18 is similar to LTC2378-18, differentiating from the already supported part mainly on the embedment of an internal voltage reference and addition of a resistor divider network connected to the input signal path. Extend the device driver, handling the internal reference and input signal attenuation, enabling it to also support LTC2338-18.
...
Quoted 10 lines
drivers/iio/adc/ltc2378.c +10
-0+static int ltc2378_refin_setup (struct device *dev,struct ltc2378_state *st) +{ +int ret; + +/* +* The internal reference buffer amplifies both the internal reference +* and REFIN by a factor of 2. +*/ + ret =devm_regulator_get_enable_read_voltage (dev,"refin" ); +if (ret == -ENODEV ) {/* refin is optional */
drivers/iio/adc/ltc2378.c static const struct spi_offload_config ltc2378_offload_config = { · line 678
Quoted 10 lines
drivers/iio/adc/ltc2378.c +10
-0+ st->ref_uV = st->info->internal_ref_uV *2 ; +return 0 ; + } + +if (ret <0 ) +return dev_err_probe (dev, ret,"failed to read refin regulator\n" ); + + st->ref_uV = ret *2 ; + +return 0 ;
I'm not sure about others' preferences, but I would do it as if-else-if and remove dup return 0.
if (ret == -ENODEV) /* refin is optional */ st->ref_uV = st->info->internal_ref_uV * 2; else if (ret < 0) return dev_err_probe(dev, ret, "failed to read refin regulator\n"); else st->ref_uV = ret * 2; return 0;
It also makes code shorter (in amount of LoC).
Quoted 1 line
+}
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH v9 5/6] iio: adc: ltc2378: Add support for LTC2338-18
Hi Andy,
Quoted 42 lines · Andy Shevchenko
Quoted 5 lines · Marcelo Schmitt
LTC2338-18 is similar to LTC2378-18, differentiating from the already supported part mainly on the embedment of an internal voltage reference and addition of a resistor divider network connected to the input signal path. Extend the device driver, handling the internal reference and input signal attenuation, enabling it to also support LTC2338-18.
...
Quoted 10 lines
drivers/iio/adc/ltc2378.c +10
-0+static int ltc2378_refin_setup (struct device *dev,struct ltc2378_state *st) +{ +int ret; + +/* +* The internal reference buffer amplifies both the internal reference +* and REFIN by a factor of 2. +*/ + ret =devm_regulator_get_enable_read_voltage (dev,"refin" ); +if (ret == -ENODEV ) {/* refin is optional */ drivers/iio/adc/ltc2378.c static const struct spi_offload_config ltc2378_offload_config = { · line 678
Quoted 10 lines
drivers/iio/adc/ltc2378.c +10
-0+ st->ref_uV = st->info->internal_ref_uV *2 ; +return 0 ; + } + +if (ret <0 ) +return dev_err_probe (dev, ret,"failed to read refin regulator\n" ); + + st->ref_uV = ret *2 ; + +return 0 ;I'm not sure about others' preferences, but I would do it as if-else-if and remove dup return 0.
if (ret == -ENODEV) /* refin is optional */ st->ref_uV = st->info->internal_ref_uV * 2; else if (ret < 0) return dev_err_probe(dev, ret, "failed to read refin regulator\n"); else st->ref_uV = ret * 2; return 0;
Quoted 1 line
It also makes code shorter (in amount of LoC).
This has already been applied to IIO testing. I do send another version of this specific patch if that's okay.
With Best Regards,
Marcelo
Re: [PATCH v9 5/6] iio: adc: ltc2378: Add support for LTC2338-18
On Mon, Aug 10, 2026 at 11:45:55PM -0300, Marcelo Schmitt wrote:
...
Quoted 27 lines
Quoted 27 lines
Quoted 6 lines
drivers/iio/adc/ltc2378.c +6
-0+/* +* The internal reference buffer amplifies both the internal reference +* and REFIN by a factor of 2. +*/ + ret =devm_regulator_get_enable_read_voltage (dev,"refin" ); +if (ret == -ENODEV ) {/* refin is optional */ drivers/iio/adc/ltc2378.c static const struct spi_offload_config ltc2378_offload_config = { · line 678
Quoted 10 lines
drivers/iio/adc/ltc2378.c +10
-0+ st->ref_uV = st->info->internal_ref_uV *2 ; +return 0 ; + } + +if (ret <0 ) +return dev_err_probe (dev, ret,"failed to read refin regulator\n" ); + + st->ref_uV = ret *2 ; + +return 0 ;I'm not sure about others' preferences, but I would do it as if-else-if and remove dup return 0.
if (ret == -ENODEV) /* refin is optional */ st->ref_uV = st->info->internal_ref_uV * 2; else if (ret < 0) return dev_err_probe(dev, ret, "failed to read refin regulator\n"); else st->ref_uV = ret * 2;
Quoted 6 lines
Quoted 3 lines
return 0;It also makes code shorter (in amount of LoC).
This has already been applied to IIO testing. I do send another version of this specific patch if that's okay.
Jonathan can replace it there, as rebase is inevitable anyway. Let's ask his
opinion: Jonathan, do you want a followup that can be folded or a new version of this patch?
Signature · 2 lines
With Best Regards, Andy Shevchenko
Jonathan Cameron
maintainerRe: [PATCH v9 5/6] iio: adc: ltc2378: Add support for LTC2338-18
Quoted 33 lines · On Tue, 11 Aug 2026 11:56:27 +0300 Andy Shevchenko…
On Mon, Aug 10, 2026 at 11:45:55PM -0300, Marcelo Schmitt wrote:
...
Quoted 29 lines
Quoted 29 lines
Quoted 6 lines
drivers/iio/adc/ltc2378.c +6
-0+/* +* The internal reference buffer amplifies both the internal reference +* and REFIN by a factor of 2. +*/ + ret =devm_regulator_get_enable_read_voltage (dev,"refin" ); +if (ret == -ENODEV ) {/* refin is optional */ drivers/iio/adc/ltc2378.c static const struct spi_offload_config ltc2378_offload_config = { · line 678
Quoted 10 lines
drivers/iio/adc/ltc2378.c +10
-0+ st->ref_uV = st->info->internal_ref_uV *2 ; +return 0 ; + } + +if (ret <0 ) +return dev_err_probe (dev, ret,"failed to read refin regulator\n" ); + + st->ref_uV = ret *2 ; + +return 0 ;I'm not sure about others' preferences, but I would do it as if-else-if and remove dup return 0.
if (ret == -ENODEV) /* refin is optional */ st->ref_uV = st->info->internal_ref_uV * 2; else if (ret < 0) return dev_err_probe(dev, ret, "failed to read refin regulator\n"); else st->ref_uV = ret * 2; return 0;
Quoted 8 lines
Quoted 4 lines
Quoted 1 line
It also makes code shorter (in amount of LoC).
This has already been applied to IIO testing. I do send another version of this specific patch if that's okay.
Jonathan can replace it there, as rebase is inevitable anyway. Let's ask his
opinion: Jonathan, do you want a followup that can be folded or a new version of this patch?
Patch on top. Pull request went out. I was busy with some other stuff so didn't get a chance to catch up with outstanding discussion before sending that.
Jonathan
Quoted 1 line
Marcelo Schmitt
maintainerPATCH v9 6/6 iio: ABI: Encourage differential voltage ABI usage
In reply to Marcelo SchmittSo far, parts that could only do differential voltage measurements were only required to have a consistent labeling of their channels by complying either to voltageY or to voltageY-voltageZ ABI. Over time, code maintainers came to the conclusion that the voltageY-voltageZ ABI is better suited for differential-only chips as it provides a simple indication to users that the channels measure the difference of two inputs.
Adjust the ABI documentation to recommend using the voltageY-voltageZ ABI for chips that do only differential voltage measurements.
---
No changes in v9.
Documentation/ABI/testing/sysfs-bus-iio | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
Documentation/ABI/testing/sysfs-bus-iio +5 -4
@@ -162,10 +162,11 @@ Contact: [email protected] Description: Raw (unscaled) differential voltage measurement equivalent to channel Y - channel Z where these channel numbers apply to the - physically equivalent inputs when non differential readings are - separately available. In differential only parts, then all that - is required is a consistent labeling. Units after application - of scale and offset are millivolts. + physically equivalent inputs when non-differential readings are + separately available. Even though differential-only parts had + been merely required to have consistent channel labeling, this + ABI is preferred over the non-differential one for those chips. + Units after application of scale and offset are millivolts. What: /sys/bus/iio/devices/iio:deviceX/in_altvoltageY_rms_raw KernelVersion: 6.18
Signature · 1 line
2.53.0
Jonathan Cameron
maintainerRe: [PATCH v9 6/6] iio: ABI: Encourage differential voltage ABI usage
Quoted 11 lines · On Mon, 27 Jul 2026 18:32:18 -0300 Marcelo Schmitt…
So far, parts that could only do differential voltage measurements were only required to have a consistent labeling of their channels by complying either to voltageY or to voltageY-voltageZ ABI. Over time, code maintainers came to the conclusion that the voltageY-voltageZ ABI is better suited for differential-only chips as it provides a simple indication to users that the channels measure the difference of two inputs.
Adjust the ABI documentation to recommend using the voltageY-voltageZ ABI for chips that do only differential voltage measurements.
Signed-off-by Marcelo Schmitt <[email protected]>
Hi Marcelo
Whilst looking at another series, I noticed we did something different again in the devicetree bindings for those devices that have restrictive muxes that means the positive and negative lines always change together. For those we let
diff-channels = <1 1>
which tends to map to
in_voltageX-voltageX_raw
I'm not sure if we want to explicitly call that out as an option. There is nothing in your new text saying we can't do that.
Worth also noting there are short circuit parts where you really do connect both ends of the differential ADC to the same input pin. I think it can be useful for testing / calibration?
Jonathan
Quoted 26 lines
---
No changes in v9.Documentation/ABI/testing/sysfs-bus-iio | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)Documentation/ABI/testing/sysfs-bus-iio +5
-4@@ -162,10 +162,11 @@ Contact: [email protected] Description: Raw (unscaled) differential voltage measurement equivalent to channel Y - channel Z where these channel numbers apply to the - physically equivalent inputs when non differential readings are - separately available. In differential only parts, then all that - is required is a consistent labeling. Units after application - of scale and offset are millivolts. + physically equivalent inputs when non-differential readings are + separately available. Even though differential-only parts had + been merely required to have consistent channel labeling, this + ABI is preferred over the non-differential one for those chips. + Units after application of scale and offset are millivolts. What: /sys/bus/iio/devices/iio:deviceX/in_altvoltageY_rms_raw KernelVersion: 6.18
Re: [PATCH v9 6/6] iio: ABI: Encourage differential voltage ABI usage
Quoted 21 lines · Jonathan Cameron
Quoted 11 lines · On Mon, 27 Jul 2026 18:32:18 -0300 Marcelo Schmitt…
So far, parts that could only do differential voltage measurements were only required to have a consistent labeling of their channels by complying either to voltageY or to voltageY-voltageZ ABI. Over time, code maintainers came to the conclusion that the voltageY-voltageZ ABI is better suited for differential-only chips as it provides a simple indication to users that the channels measure the difference of two inputs.
Adjust the ABI documentation to recommend using the voltageY-voltageZ ABI for chips that do only differential voltage measurements.
Signed-off-by Marcelo Schmitt <[email protected]>Hi Marcelo
Whilst looking at another series, I noticed we did something different again in the devicetree bindings for those devices that have restrictive muxes that means the positive and negative lines always change together. For those we let
Quoted 4 lines
diff-channels = <1 1>
which tends to map toin_voltageX-voltageX_raw
Hmm, that sounds awesome. Probably a much more accurate way of presenting the channel(s) to user space. Wish I had realized that earlier.
Quoted 3 lines
I'm not sure if we want to explicitly call that out as an option. There is nothing in your new text saying we can't do that.
I'd say probably best to mention the voltageX-X case. These fully differential inputs (that have the positive and negative lines changing together) are not uncommon. Sure, let me write something more comprehensive.
It would also be best to use that notation for ltc2378. IIRC, it's okay to not specify the ADC channels in dt if all channels have the same properties so no need to update the dt-doc. For the IIO driver, we have the channel sysfs entries changing name. Will send v10 in case there's still any chance to get it updated. Also okay to wait for the next release cycle if possible.
Quoted 7 lines
Worth also noting there are short circuit parts where you really do connect both ends of the differential ADC to the same input pin. I think it can be useful for testing / calibration?
Jonathan
Thanks,
Marcelo
Quoted 28 lines
Quoted 27 lines
---
No changes in v9.Documentation/ABI/testing/sysfs-bus-iio | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)Documentation/ABI/testing/sysfs-bus-iio +5
-4@@ -162,10 +162,11 @@ Contact: [email protected] Description: Raw (unscaled) differential voltage measurement equivalent to channel Y - channel Z where these channel numbers apply to the - physically equivalent inputs when non differential readings are - separately available. In differential only parts, then all that - is required is a consistent labeling. Units after application - of scale and offset are millivolts. + physically equivalent inputs when non-differential readings are + separately available. Even though differential-only parts had + been merely required to have consistent channel labeling, this + ABI is preferred over the non-differential one for those chips. + Units after application of scale and offset are millivolts. What: /sys/bus/iio/devices/iio:deviceX/in_altvoltageY_rms_raw KernelVersion: 6.18
Jonathan Cameron
maintainerRe: [PATCH v9 6/6] iio: ABI: Encourage differential voltage ABI usage
Quoted 38 lines · On Wed, 12 Aug 2026 15:25:41 -0300 Marcelo Schmitt…
Quoted 21 lines · Jonathan Cameron
Quoted 11 lines · On Mon, 27 Jul 2026 18:32:18 -0300 Marcelo Schmitt…
So far, parts that could only do differential voltage measurements were only required to have a consistent labeling of their channels by complying either to voltageY or to voltageY-voltageZ ABI. Over time, code maintainers came to the conclusion that the voltageY-voltageZ ABI is better suited for differential-only chips as it provides a simple indication to users that the channels measure the difference of two inputs.
Adjust the ABI documentation to recommend using the voltageY-voltageZ ABI for chips that do only differential voltage measurements.
Signed-off-by Marcelo Schmitt <[email protected]>Hi Marcelo
Whilst looking at another series, I noticed we did something different again in the devicetree bindings for those devices that have restrictive muxes that means the positive and negative lines always change together. For those we let
Quoted 4 lines
diff-channels = <1 1>
which tends to map toin_voltageX-voltageX_raw
Hmm, that sounds awesome. Probably a much more accurate way of presenting the channel(s) to user space. Wish I had realized that earlier.
Quoted 3 lines
I'm not sure if we want to explicitly call that out as an option. There is nothing in your new text saying we can't do that.
I'd say probably best to mention the voltageX-X case. These fully differential inputs (that have the positive and negative lines changing together) are not uncommon. Sure, let me write something more comprehensive.
Quoted 5 lines
It would also be best to use that notation for ltc2378. IIRC, it's okay to not specify the ADC channels in dt if all channels have the same properties so no need to update the dt-doc. For the IIO driver, we have the channel sysfs entries changing name. Will send v10 in case there's still any chance to get it updated. Also okay to wait for the next release cycle if possible.
Feel free to end an update and we'll sneak it in during the RCs as an 'abi' fix (sort of) Stick a note asking me to do that under the --- so I don't forget.
Jonathan
Quoted 40 lines
Quoted 8 lines
Worth also noting there are short circuit parts where you really do connect both ends of the differential ADC to the same input pin. I think it can be useful for testing / calibration?
Jonathan
Thanks,
MarceloQuoted 28 lines
Quoted 27 lines
---
No changes in v9.Documentation/ABI/testing/sysfs-bus-iio | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)Documentation/ABI/testing/sysfs-bus-iio +5
-4@@ -162,10 +162,11 @@ Contact: [email protected] Description: Raw (unscaled) differential voltage measurement equivalent to channel Y - channel Z where these channel numbers apply to the - physically equivalent inputs when non differential readings are - separately available. In differential only parts, then all that - is required is a consistent labeling. Units after application - of scale and offset are millivolts. + physically equivalent inputs when non-differential readings are + separately available. Even though differential-only parts had + been merely required to have consistent channel labeling, this + ABI is preferred over the non-differential one for those chips. + Units after application of scale and offset are millivolts. What: /sys/bus/iio/devices/iio:deviceX/in_altvoltageY_rms_raw KernelVersion: 6.18