Skip to contentSkip to conversation

spi: davinci: add support for adding delay between word's transmission

PATCH Superseded Grygorii Strashko 3 participants 7 messages Sep 9, 2014 – Sep 10, 2014

Subsystems (2)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 spi: davinci: add support for adding delay between word's transmission

From: Murali Karicheri <[email protected]>

This patch adds ability to configure delay between transmission of words over SPI bus if it's required by SPI slave devices.

New optional SPI slave properties:
- ti,spi-word-delay : delay between transmission of words (SPIFMTn.WDELAY, SPIDAT1.WDEL)

- ti,spi-c2t-delay: Chip-select-active-to-transmit-start delay (SPIDELAY.C2TDELAY)

- ti,spi-t2c-delay: Transmit-end-to-chip-select-inactive delay (SPIDELAY.T2CDELAY)

- ti,spi-disable-cstimer: disable CS timer (SPIFMTn.DISCSTIMERS).

If WDELAY, C2TDELAY, T2CDELAY are configured then delay between transmission of words will be added as following:

wdelay = T2CDELAY + WDELAY + C2TDELAY.

If "ti,spi-disable-cstimer" is configured:

wdelay = WDELAY.

---

Changes in v2:
- reduced number of new parameters
- bindings updated

Link on v1:
http://www.spinics.net/lists/linux-spi/msg01609.html

 .../devicetree/bindings/spi/spi-davinci.txt        | 50 +++++++++++++++++
 drivers/spi/spi-davinci.c                          | 62 +++++++++++++++++++---
 2 files changed, 105 insertions(+), 7 deletions(-)
Documentation/devicetree/bindings/spi/spi-davinci.txt +50 -0
index f80887b..1c336d4 100644
@@ -24,6 +24,54 @@ Optional:
 	cs-gpios = <0>, <0>, <0>, <&gpio1 30 0>, <&gpio1 31 0>;
 	where first three are internal CS and last two are GPIO CS.
 
+Optional properties for slave devices:
+SPI slave nodes can contain the following properties.
+Not all SPI Peripherals from Texas Instruments support this.
+Please check SPI peripheral documentation for a device before using these.
+
+- ti,spi-word-delay : delay between transmission of words
+	(SPIFMTn.WDELAY, SPIDAT1.WDEL) must be specified in number of SPI module
+	clock periods.
+
+	delay = WDELAY * SPI_module_clock_period + 2 * SPI_module_clock_period
+
+- ti,spi-c2t-delay: Chip-select-active-to-transmit-start delay
+	(SPIDELAY.C2TDELAY) must be specified in number of SPI module
+	clock periods. if 0 - delay is not applied.
+
+	delay = (C2TDELAY + 2) * SPI_module_clock_period
+
+- ti,spi-t2c-delay: Transmit-end-to-chip-select-inactive delay
+	(SPIDELAY.T2CDELAY) must be specified in number of SPI module
+	clock periods. if 0 - delay is not applied.
+
+	delay = (T2CDELAY + 1) * SPI_module_clock_period
+
+- ti,spi-disable-cstimer: disable CS timer (SPIFMTn.DISCSTIMERS). Boolean
+	property that the C2TDELAY and T2CDELAY timers should be disabled.
+
+Below is timing diagram which shows functional meaning of
+"ti,spi-word-delay", "ti,spi-c2t-delay" and "ti,spi-t2c-delay" parameters.
+
+             +-+ +-+ +-+ +-+ +-+                           +-+ +-+ +-+
+SPI_CLK      | | | | | | | | | |                           | | | | | |
+  +----------+ +-+ +-+ +-+ +-+ +---------------------------+ +-+ +-+ +-
+
+SPI_SOMI/SIMO+-----------------+                           +-----------
+  +----------+ word1           +---------------------------+word2
+             +-----------------+                           +-----------
+                                          WDELAY
+                                         <--------->
+                                        +           +
+SPI_CS                                  |           |
+  +----+                                +-----------+
+       |                                |           |
+       +-----+-----------------+--------+           +-----+------------
+       |     |                 |        |           |     |
+       +     +                 +        |           +     +
+        <--->                   <------>             <--->
+       C2TDELAY                 T2CDELAY            C2TDELAY
+
 Example of a NOR flash slave device (n25q032) connected to DaVinci
 SPI controller device over the SPI bus.
 
@@ -43,6 +91,8 @@ spi0:spi at 20BF0000 {
 		compatible = "st,m25p32";
 		spi-max-frequency = <25000000>;
 		reg = <0>;
+		ti,spi-c2t-delay = <8>;
+		ti,spi-t2c-delay = <8>;
 
 		partition at 0 {
 			label = "u-boot-spl";
drivers/spi/spi-davinci.c +55 -7

121 lines not on this page · raw message

Signature · 1 line
1.9.1
maintainer
#1 lore raw

PATCH v2 1/1 spi: davinci: add support for adding delay between word's transmission

Quoted 5 lines · Grygorii Strashko

- ti,spi-c2t-delay: Chip-select-active-to-transmit-start delay (SPIDELAY.C2TDELAY)

- ti,spi-t2c-delay: Transmit-end-to-chip-select-inactive delay (SPIDELAY.T2CDELAY)

Now I look at these they look very much like the standard delay feature
that the SPI subsystem has already - are they?
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140909/ed08dafc/attachment.sig>

#2 lore raw

PATCH v2 1/1 spi: davinci: add support for adding delay between word's transmission

Quoted 10 lines · Mark Brown
Quoted 5 lines · Grygorii Strashko

- ti,spi-c2t-delay: Chip-select-active-to-transmit-start delay (SPIDELAY.C2TDELAY)

- ti,spi-t2c-delay: Transmit-end-to-chip-select-inactive delay (SPIDELAY.T2CDELAY)

Now I look at these they look very much like the standard delay feature that the SPI subsystem has already - are they?

Mark,

As Grygorii explained in previous postings (reproduced below), these delays are handled by the SPI hardware on Keystone and affect the delay between successive word tranmssion and has nothing to do with the delay you are talking about. Isn't the standard delay you mention here is between successive packets send down to the lower level driver (in this case spi-davinci.c) ?

Murali

Below is timing diagram which shows, in general, how these new parameters affect on words transmission over Keystone/Davinci SPI bus:

              +-+ +-+ +-+ +-+ +-+                           +-+ +-+ +-+
SPI_CLK      | | | | | | | | | |                           | | | | | |
   +----------+ +-+ +-+ +-+ +-+ +---------------------------+ +-+ +-+ +-

SPI_SOMI/SIMO+-----------------+ +-----------

   +----------+ word1           +---------------------------+word2
              +-----------------+                           +-----------

WDELAY
<--------->
+ +
SPI_CS | |

   +----+                                +-----------+
        |                                |           |
        +-----+-----------------+--------+           +-----+------------
        |     |                 |        |           |     |
        +     +                 +        |           +     +
         <--->                   <------>             <--->
        C2TDELAY                 T2CDELAY            C2TDELAY

Where:
WDELAY - Delay in between transmissions
C2TDELAY - Chip-select-active-to-transmit-start-delay T2CDELAY - Transmit-end-to-chip-select-inactive-delay

maintainer
#3 lore raw

PATCH v2 1/1 spi: davinci: add support for adding delay between word's transmission

Quoted 12 lines · Murali Karicheri
Quoted 10 lines · Mark Brown
Quoted 5 lines · Grygorii Strashko

- ti,spi-c2t-delay: Chip-select-active-to-transmit-start delay (SPIDELAY.C2TDELAY)

- ti,spi-t2c-delay: Transmit-end-to-chip-select-inactive delay (SPIDELAY.T2CDELAY)

Now I look at these they look very much like the standard delay feature that the SPI subsystem has already - are they?

Quoted 6 lines

As Grygorii explained in previous postings (reproduced below), these delays are handled by the SPI hardware on Keystone and affect the delay between successive word tranmssion and has nothing to do with the delay you are talking about. Isn't the standard delay you mention here is between successive packets send down to the lower level driver (in this case spi-davinci.c) ?

He talked about such delays between words (and there were some other delays listed which seemed to meet that description) but the above don't appear to refer to them, the above refer to delays around chip select which most definitely are covered with the standard delays.

If these delays are not related to chip select then the documentation
needs to be fixed to not refer to chip select.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140909/ce792e6d/attachment.sig>

#4 lore raw

PATCH v2 1/1 spi: davinci: add support for adding delay between word's transmission

Quoted 20 lines · Mark Brown
Quoted 12 lines · Murali Karicheri
Quoted 10 lines · Mark Brown
Quoted 5 lines · Grygorii Strashko

- ti,spi-c2t-delay: Chip-select-active-to-transmit-start delay (SPIDELAY.C2TDELAY)

- ti,spi-t2c-delay: Transmit-end-to-chip-select-inactive delay (SPIDELAY.T2CDELAY)

Now I look at these they look very much like the standard delay feature that the SPI subsystem has already - are they?

Quoted 6 lines

As Grygorii explained in previous postings (reproduced below), these delays are handled by the SPI hardware on Keystone and affect the delay between successive word tranmssion and has nothing to do with the delay you are talking about. Isn't the standard delay you mention here is between successive packets send down to the lower level driver (in this case spi-davinci.c) ?

Quoted 7 lines

He talked about such delays between words (and there were some other delays listed which seemed to meet that description) but the above don't appear to refer to them, the above refer to delays around chip select which most definitely are covered with the standard delays.

If these delays are not related to chip select then the documentation needs to be fixed to not refer to chip select.

Ok. So what I understand is the issue is not having the right description to indicate that these parameters are delays associated with tranmission of successive words on the wire. Personally I like these description match with what is described in the device spec/ user guide and what is described above match with that. However we could add additional description as below to to make it more explicit.

spi-c2t-delay - delay after CS is asserted before output bits on wire spi-t2c-delay - delay after tramission of bits and before deasserting CS wdelay - delay between successive word transmission.

Do you think this will help?

Murali

maintainer
#5 lore raw

PATCH v2 1/1 spi: davinci: add support for adding delay between word's transmission

Quoted 12 lines · Murali Karicheri
Quoted 2 lines · Mark Brown

If these delays are not related to chip select then the documentation needs to be fixed to not refer to chip select.

Ok. So what I understand is the issue is not having the right description to indicate that these parameters are delays associated with tranmission of successive words on the wire. Personally I like these description match with what is described in the device spec/ user guide and what is described above match with that. However we could add additional description as below to to make it more explicit.

Quoted 4 lines

spi-c2t-delay - delay after CS is asserted before output bits on wire spi-t2c-delay - delay after tramission of bits and before deasserting CS

Do you think this will help?

No, that doesn't help at all. You keep claiming that these parameters
are related to the intervals between words but then providing
descriptions of these parameters which relate to intervals around
changes in /CS which is patently not something connected with the gaps
between words. Either your description of parameters which do not
relate to /CS should not need to mention /CS or the parameters are in
fact related to /CS, both can't simultaneously be true.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140909/8daba7ee/attachment.sig>

#6 lore raw

PATCH v2 1/1 spi: davinci: add support for adding delay between word's transmission

Hi Mark,

Quoted 18 lines · Mark Brown
Quoted 12 lines · Murali Karicheri
Quoted 2 lines · Mark Brown

If these delays are not related to chip select then the documentation needs to be fixed to not refer to chip select.

Ok. So what I understand is the issue is not having the right description to indicate that these parameters are delays associated with tranmission of successive words on the wire. Personally I like these description match with what is described in the device spec/ user guide and what is described above match with that. However we could add additional description as below to to make it more explicit.

Quoted 4 lines

spi-c2t-delay - delay after CS is asserted before output bits on wire spi-t2c-delay - delay after tramission of bits and before deasserting CS

Do you think this will help?

Quoted 8 lines

No, that doesn't help at all. You keep claiming that these parameters are related to the intervals between words but then providing descriptions of these parameters which relate to intervals around changes in /CS which is patently not something connected with the gaps between words. Either your description of parameters which do not relate to /CS should not need to mention /CS or the parameters are in fact related to /CS, both can't simultaneously be true.

This is what we have in DM (http://www.ti.com/lit/ug/sprugp2a/sprugp2a.pdf):
=========================================
2.5.1.3 Automatic Delay Between Transfers

The SPI master can automatically insert a delay of between 2 and 65 SPI module clock cycles between transmissions. This delay is controlled by the WDELAY field in the SPI data format register n (SPIFMTn) and is enabled by setting the WDEL bit in the SPI transmit data register (SPIDAT1) to 1. The WDELAY period begins when the T2EDELAY period terminates (if T2E delay period is enabled) or when
the T2CDELAY period terminates (if T2E delay period was disabled and T2C delay period was enabled) or when the master deasserts SPISCS[n] (if T2E and T2C delay periods are disabled). If a transfer is initiated by writing a 32-bit value to SPIDAT1, then the new values of SPIDAT1.WDEL and SPIFMTn.WDELAY are used; otherwise, the old values of SPIDAT1.WDEL and SPIFMTn.WDELAY are used. The WDELAY delay period is specified by:

2.5.1.4 Chip Select Hold Option
There are slave devices available that require the chip select signal to be held continuously active during several consecutive data word transfers. Other slave devices require the chip select signal to be deactivated between consecutive data word transfers. The SPI can support both types of slave devices. The CSHOLD bit in the SPI transmit data register (SPIDAT1) selects between the two options.

If the chip select hold option is enabled, the chip select will not toggle between two consecutive accesses. Therefore, the SPIDELAY.T2CDELAY of the first transfer and the SPIDELAY.C2TDELAY of the second transfer will not be applied. However, the wait delay could still be applied between the two transactions, if the WDEL bit in SPIDAT1 is set to 1.

When the CSHOLD bit is 0, during the data transmission, the value of the chip select number field (CSNR[n:0]) in the SPIDAT1 register is put on the chip select SPISCS[n] to SPISCS[0] pins. When the transmission finishes, the chip select default pattern (CSDEF[n:0]) is put on the SPISCS[n] to SPISCS[0] pins.
=========================================

And according to above the final delay between consecutive data word transfers can be formed as sum of T2CDELAY WDELAY, C2TDELAY and can include CS toggling (exactly as shown on diagram).

I'm going to drop "spi-c2t-delay"/"spi-t2c-delay" properties, because CSHOLD is always set now by Davinci SPI driver, so these delays will not be applied (this feature can be enabled later).
But WDELAY is important for us as we have issue with custom SPI device (FPGA based).

So, next version will only have "ti,spi-word-delay". Is it okay for you?

Best regards,
-grygorii