linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/2] Add SPI offload trigger offset
@ 2025-09-18 17:33 Marcelo Schmitt
  2025-09-18 17:34 ` [PATCH v2 1/2] spi: offload: types: add offset parameter Marcelo Schmitt
  2025-09-18 17:34 ` [PATCH v2 2/2] spi: spi-offload-trigger-pwm: Use duty offset Marcelo Schmitt
  0 siblings, 2 replies; 5+ messages in thread
From: Marcelo Schmitt @ 2025-09-18 17:33 UTC (permalink / raw)
  To: linux-spi, linux-iio, linux-kernel
  Cc: broonie, jic23, nuno.sa, dlechner, ahaslam, andy,
	marcelo.schmitt1

This was initially proposed as part of a patch set to a driver in the IIO
subsystem [1].

The changes to code in the SPI subsystem are minimal. From that first version
to this one, the changes are:

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

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'.


[1] https://lore.kernel.org/linux-iio/cover.1756511030.git.marcelo.schmitt@analog.com/

Best regards,
Marcelo


Axel Haslam (2):
  spi: offload: types: add offset parameter
  spi: spi-offload-trigger-pwm: Use duty offset

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


base-commit: e27fcbde216b317fecfd4487ffcd7f81726ac8ea
-- 
2.50.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v2 1/2] spi: offload: types: add offset parameter
  2025-09-18 17:33 [PATCH v2 0/2] Add SPI offload trigger offset Marcelo Schmitt
@ 2025-09-18 17:34 ` Marcelo Schmitt
  2025-09-18 19:12   ` David Lechner
  2025-09-18 17:34 ` [PATCH v2 2/2] spi: spi-offload-trigger-pwm: Use duty offset Marcelo Schmitt
  1 sibling, 1 reply; 5+ messages in thread
From: Marcelo Schmitt @ 2025-09-18 17:34 UTC (permalink / raw)
  To: linux-spi, linux-iio, linux-kernel
  Cc: Axel Haslam, broonie, jic23, nuno.sa, dlechner, andy,
	marcelo.schmitt1

From: Axel Haslam <ahaslam@baylibre.com>

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.

Signed-off-by: Axel Haslam <ahaslam@baylibre.com>
Signed-off-by: Marcelo Schmitt <marcelo.schmitt@analog.com>
---
 include/linux/spi/offload/types.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/include/linux/spi/offload/types.h b/include/linux/spi/offload/types.h
index 6f7892347871..0170fd1f42e5 100644
--- a/include/linux/spi/offload/types.h
+++ b/include/linux/spi/offload/types.h
@@ -59,6 +59,7 @@ enum spi_offload_trigger_type {
 
 struct spi_offload_trigger_periodic {
 	u64 frequency_hz;
+	u64 offset_ns;
 };
 
 struct spi_offload_trigger_config {
-- 
2.50.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH v2 2/2] spi: spi-offload-trigger-pwm: Use duty offset
  2025-09-18 17:33 [PATCH v2 0/2] Add SPI offload trigger offset Marcelo Schmitt
  2025-09-18 17:34 ` [PATCH v2 1/2] spi: offload: types: add offset parameter Marcelo Schmitt
@ 2025-09-18 17:34 ` Marcelo Schmitt
  2025-09-18 19:19   ` David Lechner
  1 sibling, 1 reply; 5+ messages in thread
From: Marcelo Schmitt @ 2025-09-18 17:34 UTC (permalink / raw)
  To: linux-spi, linux-iio, linux-kernel
  Cc: Axel Haslam, broonie, jic23, nuno.sa, dlechner, andy,
	marcelo.schmitt1

From: Axel Haslam <ahaslam@baylibre.com>

Pass the duty offset to the waveform pwm.

Signed-off-by: Axel Haslam <ahaslam@baylibre.com>
Signed-off-by: Marcelo Schmitt <marcelo.schmitt@analog.com>
---
 drivers/spi/spi-offload-trigger-pwm.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/spi/spi-offload-trigger-pwm.c b/drivers/spi/spi-offload-trigger-pwm.c
index 805ed41560df..3e8c19227edb 100644
--- a/drivers/spi/spi-offload-trigger-pwm.c
+++ b/drivers/spi/spi-offload-trigger-pwm.c
@@ -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);
 }
-- 
2.50.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH v2 1/2] spi: offload: types: add offset parameter
  2025-09-18 17:34 ` [PATCH v2 1/2] spi: offload: types: add offset parameter Marcelo Schmitt
@ 2025-09-18 19:12   ` David Lechner
  0 siblings, 0 replies; 5+ messages in thread
From: David Lechner @ 2025-09-18 19:12 UTC (permalink / raw)
  To: Marcelo Schmitt, linux-spi, linux-iio, linux-kernel
  Cc: Axel Haslam, broonie, jic23, nuno.sa, andy, marcelo.schmitt1

On 9/18/25 12:34 PM, Marcelo Schmitt wrote:
> From: Axel Haslam <ahaslam@baylibre.com>
> 
> 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.
> 
> Signed-off-by: Axel Haslam <ahaslam@baylibre.com>
> Signed-off-by: Marcelo Schmitt <marcelo.schmitt@analog.com>
> ---
>  include/linux/spi/offload/types.h | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/include/linux/spi/offload/types.h b/include/linux/spi/offload/types.h
> index 6f7892347871..0170fd1f42e5 100644
> --- a/include/linux/spi/offload/types.h
> +++ b/include/linux/spi/offload/types.h
> @@ -59,6 +59,7 @@ enum spi_offload_trigger_type {
>  


I think this would be a good time to add some documentation comments:

/**
 * 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 {


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2 2/2] spi: spi-offload-trigger-pwm: Use duty offset
  2025-09-18 17:34 ` [PATCH v2 2/2] spi: spi-offload-trigger-pwm: Use duty offset Marcelo Schmitt
@ 2025-09-18 19:19   ` David Lechner
  0 siblings, 0 replies; 5+ messages in thread
From: David Lechner @ 2025-09-18 19:19 UTC (permalink / raw)
  To: Marcelo Schmitt, linux-spi, linux-iio, linux-kernel
  Cc: Axel Haslam, broonie, jic23, nuno.sa, andy, marcelo.schmitt1

On 9/18/25 12:34 PM, Marcelo Schmitt wrote:
> From: Axel Haslam <ahaslam@baylibre.com>
> 
> Pass the duty offset to the waveform pwm.
> 
> Signed-off-by: Axel Haslam <ahaslam@baylibre.com>
> Signed-off-by: Marcelo Schmitt <marcelo.schmitt@analog.com>
> ---
>  drivers/spi/spi-offload-trigger-pwm.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/spi/spi-offload-trigger-pwm.c b/drivers/spi/spi-offload-trigger-pwm.c
> index 805ed41560df..3e8c19227edb 100644
> --- a/drivers/spi/spi-offload-trigger-pwm.c
> +++ b/drivers/spi/spi-offload-trigger-pwm.c
> @@ -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);
>  }

Does this really need to be a separate patch from the one
that adds the field?

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2025-09-18 19:19 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-18 17:33 [PATCH v2 0/2] Add SPI offload trigger offset Marcelo Schmitt
2025-09-18 17:34 ` [PATCH v2 1/2] spi: offload: types: add offset parameter Marcelo Schmitt
2025-09-18 19:12   ` David Lechner
2025-09-18 17:34 ` [PATCH v2 2/2] spi: spi-offload-trigger-pwm: Use duty offset Marcelo Schmitt
2025-09-18 19:19   ` David Lechner

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).