Skip to contentSkip to conversation

Add SPI offload trigger offset

PATCH Superseded Marcelo Schmitt 5 participants 6 messages Sep 26, 2025 – Sep 29, 2025

Subsystems (3)

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

v3 cover Add SPI offload trigger offset

Add SPI offload offset parameter needed to achieve high sample rates with ADCs that require some synchronization between a conversion start signal and the issue of data transfers.

Change log v1 -> v2
- Using upper case: adc -> ADC.
- Codestyle/readability improvements according to suggestions.

Change log v2 -> v3
- Squashed SPI offload trigger commits.
- Added documentation to offload trigger periodic parameters.
- Picked up reviewed-by tags.

The updates to the ADC driver that use these changes proposed to the SPI subsystem will go in a patch set titled 'Add SPI offload support to AD4030'.

Link to v1: https://lore.kernel.org/linux-iio/[email protected]/
Link to v2: https://lore.kernel.org/linux-spi/[email protected]/

Axel Haslam (1):
spi: offload: Add offset parameter

 drivers/spi/spi-offload-trigger-pwm.c |  3 +++
 include/linux/spi/offload/types.h     | 10 ++++++++++
 2 files changed, 13 insertions(+)

base-commit: 7e2212429ec9a7b11644a7971d5d606d44ee4d78

Signature · 1 line
2.39.2
#1 lore raw

PATCH v3 1/1 spi: offload: Add offset parameter

From: Axel Haslam <[email protected]>

Add an offset parameter that can be passed in the periodic trigger. This is useful for example when ADC drivers implement a separate periodic signal to trigger conversion and need offload to read the result with some delay. While at it, add some documentation to offload periodic trigger parameters.

---
Change log v2 -> v3
- Squashed SPI offload trigger commits.
- Added documentation to offload trigger periodic parameters.
- Picked up reviewed-by tags.

 drivers/spi/spi-offload-trigger-pwm.c |  3 +++
 include/linux/spi/offload/types.h     | 10 ++++++++++
 2 files changed, 13 insertions(+)
drivers/spi/spi-offload-trigger-pwm.c +3 -0
index 805ed41560df..3e8c19227edb 100644
@@ -51,12 +51,14 @@ static int spi_offload_trigger_pwm_validate(struct spi_offload_trigger *trigger,
 	wf.period_length_ns = DIV_ROUND_UP_ULL(NSEC_PER_SEC, periodic->frequency_hz);
 	/* REVISIT: 50% duty-cycle for now - may add config parameter later */
 	wf.duty_length_ns = wf.period_length_ns / 2;
+	wf.duty_offset_ns = periodic->offset_ns;
 
 	ret = pwm_round_waveform_might_sleep(st->pwm, &wf);
 	if (ret < 0)
 		return ret;
 
 	periodic->frequency_hz = DIV_ROUND_UP_ULL(NSEC_PER_SEC, wf.period_length_ns);
+	periodic->offset_ns = wf.duty_offset_ns;
 
 	return 0;
 }
@@ -77,6 +79,7 @@ static int spi_offload_trigger_pwm_enable(struct spi_offload_trigger *trigger,
 	wf.period_length_ns = DIV_ROUND_UP_ULL(NSEC_PER_SEC, periodic->frequency_hz);
 	/* REVISIT: 50% duty-cycle for now - may add config parameter later */
 	wf.duty_length_ns = wf.period_length_ns / 2;
+	wf.duty_offset_ns = periodic->offset_ns;
 
 	return pwm_set_waveform_might_sleep(st->pwm, &wf, false);
 }
include/linux/spi/offload/types.h +10 -0
index 6f7892347871..b56d01ba0b2e 100644
@@ -57,8 +57,18 @@ enum spi_offload_trigger_type {
 	SPI_OFFLOAD_TRIGGER_PERIODIC,
 };
 
+
+/**
+ * spi_offload_trigger_periodic - configuration parameters for periodic triggers
+ * @frequency_hz: The rate that the trigger should fire in Hz.
+ * @offset_ns: A delay in nanoseconds between when this trigger fires
+ *	       compared to another trigger. This requires specialized hardware
+ *	       that supports such synchronization with a delay between two or
+ *	       more triggers. Set to 0 when not needed.
+ */
 struct spi_offload_trigger_periodic {
 	u64 frequency_hz;
+	u64 offset_ns;
 };
 
 struct spi_offload_trigger_config {
Signature · 1 line
2.39.2
reviewer Reviewed-by on v3 1/1
#2 lore raw

Re: [PATCH v3 1/1] spi: offload: Add offset parameter

Quoted 11 lines · Marcelo Schmitt

From: Axel Haslam <[email protected]>

Add an offset parameter that can be passed in the periodic trigger. This is useful for example when ADC drivers implement a separate periodic signal to trigger conversion and need offload to read the result with some delay. While at it, add some documentation to offload periodic trigger parameters.

---

maintainer
#3 lore raw

Re: [PATCH v3 1/1] spi: offload: Add offset parameter

In reply to Marcelo Schmitt
Quoted 10 lines · On Fri, 26 Sep 2025 16:01:05 -0300 Marcelo Schmitt…

From: Axel Haslam <[email protected]>

Add an offset parameter that can be passed in the periodic trigger. This is useful for example when ADC drivers implement a separate periodic signal to trigger conversion and need offload to read the result with some delay. While at it, add some documentation to offload periodic trigger parameters.

Hi Axel, Marcelo,

Is there a build time dependency on this for the ad4030 series? I'm assuming this will go via Mark's SPI tree, so this is really a question of do we need to ask him for an immutable branch or not.

I don't think there is such a dependency but just wanted to check!

Jonathan

#4 lore raw

Re: [PATCH v3 1/1] spi: offload: Add offset parameter

Hi Jonathan,

Yes, current ad4030 series depends on this.
Though, since this updates the SPI subsystem, I separated it from ad4030 set. I missed that aspect of the devel process. If we need an immutable branch to make this split series for ad4030 work, then yes, please, I'd like an immutable branch with this patch.

Quoted 23 lines · Jonathan Cameron
Quoted 10 lines · On Fri, 26 Sep 2025 16:01:05 -0300 Marcelo Schmitt…

From: Axel Haslam <[email protected]>

Add an offset parameter that can be passed in the periodic trigger. This is useful for example when ADC drivers implement a separate periodic signal to trigger conversion and need offload to read the result with some delay. While at it, add some documentation to offload periodic trigger parameters.

Hi Axel, Marcelo,

Is there a build time dependency on this for the ad4030 series? I'm assuming this will go via Mark's SPI tree, so this is really a question of do we need to ask him for an immutable branch or not.

I don't think there is such a dependency but just wanted to check!

Jonathan

maintainer
#5 lore raw
In reply to Marcelo Schmitt
Quoted 3 lines · Marcelo Schmitt

Add SPI offload offset parameter needed to achieve high sample rates with ADCs that require some synchronization between a conversion start signal and the issue of data transfers.

Please don't send cover letters for single patches, if there is anything that needs saying put it in the changelog of the patch or after the --- if it's administrative stuff. This reduces mail volume and ensures that any important information is recorded in the changelog rather than being lost.