devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 0/3] iio: imu: adis: Use spi cs inactive delay
@ 2023-10-27 14:03 Ramona Gradinariu
  2023-10-27 14:03 ` [PATCH v3 1/3] " Ramona Gradinariu
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Ramona Gradinariu @ 2023-10-27 14:03 UTC (permalink / raw)
  To: jic23, nuno.sa, robh+dt, krzysztof.kozlowski+dt, conor+dt,
	linux-iio, linux-kernel, devicetree
  Cc: Ramona Gradinariu

A delay is needed each time the chip selected becomes inactive,
even after burst data readings are performed.
Currently, there is no delay added after a burst reading
and in case a new SPI transfer is performed before
the needed delay, the adis device becomes unresponsive until
reset.

This commit is adding the needed delay directly to the spi driver,
using the cs_inactive parameter, in case it is not set and is
removing the additional chip select change delay present in adis
APIs to remove the double delay.

Ramona Gradinariu (3):
  iio: imu: adis: Use spi cs inactive delay
  dt-bindings: adis16475: Add 'spi-cs-inactive-delay-ns' property
  dt-bindings: adis16460: Add 'spi-cs-inactive-delay-ns' property

 .../bindings/iio/imu/adi,adis16460.yaml        |  4 ++++
 .../bindings/iio/imu/adi,adis16475.yaml        |  4 ++++
 drivers/iio/imu/adis.c                         | 18 ++++++------------
 3 files changed, 14 insertions(+), 12 deletions(-)

--
2.34.1


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

* [PATCH v3 1/3] iio: imu: adis: Use spi cs inactive delay
  2023-10-27 14:03 [PATCH v3 0/3] iio: imu: adis: Use spi cs inactive delay Ramona Gradinariu
@ 2023-10-27 14:03 ` Ramona Gradinariu
  2023-10-27 14:03 ` [PATCH v3 2/3] dt-bindings: adis16475: Add 'spi-cs-inactive-delay-ns' property Ramona Gradinariu
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Ramona Gradinariu @ 2023-10-27 14:03 UTC (permalink / raw)
  To: jic23, nuno.sa, robh+dt, krzysztof.kozlowski+dt, conor+dt,
	linux-iio, linux-kernel, devicetree
  Cc: Ramona Gradinariu

A delay is needed each time the chip selected becomes inactive,
even after burst data readings are performed.
Currently, there is no delay added after a burst reading
and in case a new SPI transfer is performed before
the needed delay, the adis device becomes unresponsive until
reset.

This commit is adding the needed delay directly to the spi driver,
using the cs_inactive parameter, in case it is not set and is
removing the additional chip select change delay present in adis
APIs to remove the double delay.

Signed-off-by: Ramona Gradinariu <ramona.gradinariu@analog.com>
---
 drivers/iio/imu/adis.c | 18 ++++++------------
 1 file changed, 6 insertions(+), 12 deletions(-)

diff --git a/drivers/iio/imu/adis.c b/drivers/iio/imu/adis.c
index bc40240b29e2..495caf4ce87a 100644
--- a/drivers/iio/imu/adis.c
+++ b/drivers/iio/imu/adis.c
@@ -44,8 +44,6 @@ int __adis_write_reg(struct adis *adis, unsigned int reg, unsigned int value,
 			.cs_change = 1,
 			.delay.value = adis->data->write_delay,
 			.delay.unit = SPI_DELAY_UNIT_USECS,
-			.cs_change_delay.value = adis->data->cs_change_delay,
-			.cs_change_delay.unit = SPI_DELAY_UNIT_USECS,
 		}, {
 			.tx_buf = adis->tx + 2,
 			.bits_per_word = 8,
@@ -53,8 +51,6 @@ int __adis_write_reg(struct adis *adis, unsigned int reg, unsigned int value,
 			.cs_change = 1,
 			.delay.value = adis->data->write_delay,
 			.delay.unit = SPI_DELAY_UNIT_USECS,
-			.cs_change_delay.value = adis->data->cs_change_delay,
-			.cs_change_delay.unit = SPI_DELAY_UNIT_USECS,
 		}, {
 			.tx_buf = adis->tx + 4,
 			.bits_per_word = 8,
@@ -62,8 +58,6 @@ int __adis_write_reg(struct adis *adis, unsigned int reg, unsigned int value,
 			.cs_change = 1,
 			.delay.value = adis->data->write_delay,
 			.delay.unit = SPI_DELAY_UNIT_USECS,
-			.cs_change_delay.value = adis->data->cs_change_delay,
-			.cs_change_delay.unit = SPI_DELAY_UNIT_USECS,
 		}, {
 			.tx_buf = adis->tx + 6,
 			.bits_per_word = 8,
@@ -144,8 +138,6 @@ int __adis_read_reg(struct adis *adis, unsigned int reg, unsigned int *val,
 			.cs_change = 1,
 			.delay.value = adis->data->write_delay,
 			.delay.unit = SPI_DELAY_UNIT_USECS,
-			.cs_change_delay.value = adis->data->cs_change_delay,
-			.cs_change_delay.unit = SPI_DELAY_UNIT_USECS,
 		}, {
 			.tx_buf = adis->tx + 2,
 			.bits_per_word = 8,
@@ -153,8 +145,6 @@ int __adis_read_reg(struct adis *adis, unsigned int reg, unsigned int *val,
 			.cs_change = 1,
 			.delay.value = adis->data->read_delay,
 			.delay.unit = SPI_DELAY_UNIT_USECS,
-			.cs_change_delay.value = adis->data->cs_change_delay,
-			.cs_change_delay.unit = SPI_DELAY_UNIT_USECS,
 		}, {
 			.tx_buf = adis->tx + 4,
 			.rx_buf = adis->rx,
@@ -163,8 +153,6 @@ int __adis_read_reg(struct adis *adis, unsigned int reg, unsigned int *val,
 			.cs_change = 1,
 			.delay.value = adis->data->read_delay,
 			.delay.unit = SPI_DELAY_UNIT_USECS,
-			.cs_change_delay.value = adis->data->cs_change_delay,
-			.cs_change_delay.unit = SPI_DELAY_UNIT_USECS,
 		}, {
 			.rx_buf = adis->rx + 2,
 			.bits_per_word = 8,
@@ -524,6 +512,12 @@ int adis_init(struct adis *adis, struct iio_dev *indio_dev,
 	}
 
 	mutex_init(&adis->state_lock);
+
+	if (!spi->cs_inactive.value) {
+		spi->cs_inactive.value = data->cs_change_delay;
+		spi->cs_inactive.unit = SPI_DELAY_UNIT_USECS;
+	}
+
 	adis->spi = spi;
 	adis->data = data;
 	iio_device_set_drvdata(indio_dev, adis);
-- 
2.34.1


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

* [PATCH v3 2/3] dt-bindings: adis16475: Add 'spi-cs-inactive-delay-ns' property
  2023-10-27 14:03 [PATCH v3 0/3] iio: imu: adis: Use spi cs inactive delay Ramona Gradinariu
  2023-10-27 14:03 ` [PATCH v3 1/3] " Ramona Gradinariu
@ 2023-10-27 14:03 ` Ramona Gradinariu
  2023-10-27 14:03 ` [PATCH v3 3/3] dt-bindings: adis16460: " Ramona Gradinariu
  2023-10-28 15:23 ` [PATCH v3 0/3] iio: imu: adis: Use spi cs inactive delay Jonathan Cameron
  3 siblings, 0 replies; 5+ messages in thread
From: Ramona Gradinariu @ 2023-10-27 14:03 UTC (permalink / raw)
  To: jic23, nuno.sa, robh+dt, krzysztof.kozlowski+dt, conor+dt,
	linux-iio, linux-kernel, devicetree
  Cc: Ramona Gradinariu, Krzysztof Kozlowski

The devices supported by adis16475 driver require a stall period
between SPI transactions (during which the chip select is
inactive), with a minimum value equal to 16 microseconds, thus
adding 'spi-cs-inactive-delay-ns' property, which should indicate
the stall time between consecutive SPI transactions.
The specified minimum time may not be sufficient for all
configurations.

Signed-off-by: Ramona Gradinariu <ramona.gradinariu@analog.com>
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
---
changes in v3:
 - removed description
 - updated commit message
 Documentation/devicetree/bindings/iio/imu/adi,adis16475.yaml | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/Documentation/devicetree/bindings/iio/imu/adi,adis16475.yaml b/Documentation/devicetree/bindings/iio/imu/adi,adis16475.yaml
index c73533c54588..9b7ad609f7db 100644
--- a/Documentation/devicetree/bindings/iio/imu/adi,adis16475.yaml
+++ b/Documentation/devicetree/bindings/iio/imu/adi,adis16475.yaml
@@ -47,6 +47,10 @@ properties:
   spi-max-frequency:
     maximum: 2000000

+  spi-cs-inactive-delay-ns:
+    minimum: 16000
+    default: 16000
+
   interrupts:
     maxItems: 1

--
2.34.1


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

* [PATCH v3 3/3] dt-bindings: adis16460: Add 'spi-cs-inactive-delay-ns' property
  2023-10-27 14:03 [PATCH v3 0/3] iio: imu: adis: Use spi cs inactive delay Ramona Gradinariu
  2023-10-27 14:03 ` [PATCH v3 1/3] " Ramona Gradinariu
  2023-10-27 14:03 ` [PATCH v3 2/3] dt-bindings: adis16475: Add 'spi-cs-inactive-delay-ns' property Ramona Gradinariu
@ 2023-10-27 14:03 ` Ramona Gradinariu
  2023-10-28 15:23 ` [PATCH v3 0/3] iio: imu: adis: Use spi cs inactive delay Jonathan Cameron
  3 siblings, 0 replies; 5+ messages in thread
From: Ramona Gradinariu @ 2023-10-27 14:03 UTC (permalink / raw)
  To: jic23, nuno.sa, robh+dt, krzysztof.kozlowski+dt, conor+dt,
	linux-iio, linux-kernel, devicetree
  Cc: Ramona Gradinariu, Krzysztof Kozlowski

The adis16460 device requires a stall time between SPI
transactions (during which the chip select is inactive),
with a minimum value equal to 16 microseconds.
This commit adds 'spi-cs-inactive-delay-ns' property, which should
indicate the stall time between consecutive SPI transactions.
The specified minimum time may not be sufficient for all
configurations.

Signed-off-by: Ramona Gradinariu <ramona.gradinariu@analog.com>
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
---
changes in v3:
 - removed description
 - updated commit message
 Documentation/devicetree/bindings/iio/imu/adi,adis16460.yaml | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/Documentation/devicetree/bindings/iio/imu/adi,adis16460.yaml b/Documentation/devicetree/bindings/iio/imu/adi,adis16460.yaml
index 4e43c80e5119..4cacc9948726 100644
--- a/Documentation/devicetree/bindings/iio/imu/adi,adis16460.yaml
+++ b/Documentation/devicetree/bindings/iio/imu/adi,adis16460.yaml
@@ -25,6 +25,10 @@ properties:

   spi-cpol: true

+  spi-cs-inactive-delay-ns:
+    minimum: 16000
+    default: 16000
+
   interrupts:
     maxItems: 1

--
2.34.1


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

* Re: [PATCH v3 0/3] iio: imu: adis: Use spi cs inactive delay
  2023-10-27 14:03 [PATCH v3 0/3] iio: imu: adis: Use spi cs inactive delay Ramona Gradinariu
                   ` (2 preceding siblings ...)
  2023-10-27 14:03 ` [PATCH v3 3/3] dt-bindings: adis16460: " Ramona Gradinariu
@ 2023-10-28 15:23 ` Jonathan Cameron
  3 siblings, 0 replies; 5+ messages in thread
From: Jonathan Cameron @ 2023-10-28 15:23 UTC (permalink / raw)
  To: Ramona Gradinariu
  Cc: nuno.sa, robh+dt, krzysztof.kozlowski+dt, conor+dt, linux-iio,
	linux-kernel, devicetree

On Fri, 27 Oct 2023 17:03:55 +0300
Ramona Gradinariu <ramona.gradinariu@analog.com> wrote:

> A delay is needed each time the chip selected becomes inactive,
> even after burst data readings are performed.
> Currently, there is no delay added after a burst reading
> and in case a new SPI transfer is performed before
> the needed delay, the adis device becomes unresponsive until
> reset.
> 
> This commit is adding the needed delay directly to the spi driver,
> using the cs_inactive parameter, in case it is not set and is
> removing the additional chip select change delay present in adis
> APIs to remove the double delay.

Series applied.

I'm a bit confused though as this one is turning up in patchwork.
Meh, maybe a delay and it will show up soon.

Jonathan

> 
> Ramona Gradinariu (3):
>   iio: imu: adis: Use spi cs inactive delay
>   dt-bindings: adis16475: Add 'spi-cs-inactive-delay-ns' property
>   dt-bindings: adis16460: Add 'spi-cs-inactive-delay-ns' property
> 
>  .../bindings/iio/imu/adi,adis16460.yaml        |  4 ++++
>  .../bindings/iio/imu/adi,adis16475.yaml        |  4 ++++
>  drivers/iio/imu/adis.c                         | 18 ++++++------------
>  3 files changed, 14 insertions(+), 12 deletions(-)
> 
> --
> 2.34.1
> 


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

end of thread, other threads:[~2023-10-28 15:23 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-27 14:03 [PATCH v3 0/3] iio: imu: adis: Use spi cs inactive delay Ramona Gradinariu
2023-10-27 14:03 ` [PATCH v3 1/3] " Ramona Gradinariu
2023-10-27 14:03 ` [PATCH v3 2/3] dt-bindings: adis16475: Add 'spi-cs-inactive-delay-ns' property Ramona Gradinariu
2023-10-27 14:03 ` [PATCH v3 3/3] dt-bindings: adis16460: " Ramona Gradinariu
2023-10-28 15:23 ` [PATCH v3 0/3] iio: imu: adis: Use spi cs inactive delay 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).