Skip to contentSkip to conversation

iio: adc: ad7380: fix SPI offload trigger rate

PATCH Applied David Lechner 2 participants 2 messages Sep 19, 2025 – Sep 27, 2025

Subsystems (3)
lore
Share & tools
lore

David Lechner

author reviewer
#0 lore raw

PATCH 1/1 iio: adc: ad7380: fix SPI offload trigger rate

Add a special case to double the SPI offload trigger rate when all channels of a single-ended chip are enabled in a buffered read.

The single-ended chips in the AD738x family can only do simultaneous sampling of half their channels and have a multiplexer to allow reading the other half. To comply with the IIO definition of sampling_frequency, we need to trigger twice as often when the sequencer is enabled to so that both banks can be read in a single sample period.

Fixes bbeaec81a03e ("iio: ad7380: add support for SPI offload")

---
There was some unresolved discussion about this when we were adding SPI offload support to the ad7380 driver, but it turns out that handling the sampling frequency correctly for single-ended chips is actually quite simple.

---
 drivers/iio/adc/ad7380.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/iio/adc/ad7380.c +8 -0
index fa251dc1aae6ab0a0d36792fa37b2cc22b99dfe6..bfd908deefc0f40b42bd8a44bfce7a2510b2fdf1 100644
@@ -1227,6 +1227,14 @@ static int ad7380_offload_buffer_postenable(struct iio_dev *indio_dev)
 	if (ret)
 		return ret;
 
+	/*
+	 * When the sequencer is required to read all channels, we need to
+	 * trigger twice per sample period in order to read one complete set
+	 * of samples.
+	 */
+	if (st->seq)
+		config.periodic.frequency_hz *= 2;
+
 	ret = spi_offload_trigger_enable(st->offload, st->offload_trigger, &config);
 	if (ret)
 		spi_unoptimize_message(&st->offload_msg);

---
base-commit: 561285d048053fec8a3d6d1e3ddc60df11c393a0
change-id: 20250919-iio-adc-ad7380-fix-sampling-frequency-for-single-ended-chips-05bbfea8891c

Best regards,

Signature · 1 line
David Lechner <[email protected]>
maintainer Applied
#1 lore raw
Quoted 11 lines · On Fri, 19 Sep 2025 15:50:34 -0500 David Lechner <[email protected]> wrote:

Add a special case to double the SPI offload trigger rate when all channels of a single-ended chip are enabled in a buffered read.

The single-ended chips in the AD738x family can only do simultaneous sampling of half their channels and have a multiplexer to allow reading the other half. To comply with the IIO definition of sampling_frequency, we need to trigger twice as often when the sequencer is enabled to so that both banks can be read in a single sample period.

Fixes bbeaec81a03e ("iio: ad7380: add support for SPI offload")

Applied to my temporary fixes branch (always fun at this point in cycle). It'll become the normal fixes branch after rc1.

J

Quoted 34 lines

---
There was some unresolved discussion about this when we were adding SPI offload support to the ad7380 driver, but it turns out that handling the sampling frequency correctly for single-ended chips is actually quite simple.

---
 drivers/iio/adc/ad7380.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/iio/adc/ad7380.c +8 -1
index fa251dc1aae6ab0a0d36792fa37b2cc22b99dfe6..bfd908deefc0f40b42bd8a44bfce7a2510b2fdf1 100644
@@ -1227,6 +1227,14 @@ static int ad7380_offload_buffer_postenable(struct iio_dev *indio_dev)
 	if (ret)
 		return ret;
 
+	/*
+	 * When the sequencer is required to read all channels, we need to
+	 * trigger twice per sample period in order to read one complete set
+	 * of samples.
+	 */
+	if (st->seq)
+		config.periodic.frequency_hz *= 2;
+
 	ret = spi_offload_trigger_enable(st->offload, st->offload_trigger, &config);
 	if (ret)
 		spi_unoptimize_message(&st->offload_msg);
 
---

base-commit: 561285d048053fec8a3d6d1e3ddc60df11c393a0
change-id: 20250919-iio-adc-ad7380-fix-sampling-frequency-for-single-ended-chips-05bbfea8891c

Best regards,