Skip to contentSkip to conversation

spi: davinci: fixes and updates

PATCH New Grygorii Strashko 2 participants 11 messages Aug 21, 2014 – Sep 8, 2014

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover spi: davinci: fixes and updates

The first patch fixes the issue for the case when SPI_NO_CS flag is set which was introduced by previous
commit a88e34ea213e1b ("spi: davinci: add support to configure gpio cs through dt").

The second patch completes migration of Davinci SPI driver to DT and adds ability to configure additional properties for SPI slave devices which were possible to configure only from platform code through struct davinci_spi_config

Grygorii Strashko (2):
spi: davinci: fix SPI_NO_CS functionality
spi: davinci: support adding delay between transmission

 .../devicetree/bindings/spi/spi-davinci.txt        |   18 ++++
 drivers/spi/spi-davinci.c                          |   96 +++++++++++++++++---
 2 files changed, 99 insertions(+), 15 deletions(-)
Signature · 1 line
1.7.9.5
#1 lore raw

PATCH 1/2 spi: davinci: fix SPI_NO_CS functionality

The driver should not touch CS lines if SPI_NO_CS flag is set.
This patch fixes it as this functionality was broken accidentally
by
commit a88e34ea213e1b ("spi: davinci: add support to configure gpio cs through dt").

---
 drivers/spi/spi-davinci.c |   16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
drivers/spi/spi-davinci.c +8 -8
index 276a388..48f1d26 100644
@@ -417,16 +417,16 @@ static int davinci_spi_setup(struct spi_device *spi)
 						  flags, dev_name(&spi->dev));
 			internal_cs = false;
 		}
-	}
 
-	if (retval) {
-		dev_err(&spi->dev, "GPIO %d setup failed (%d)\n",
-			spi->cs_gpio, retval);
-		return retval;
-	}
+		if (retval) {
+			dev_err(&spi->dev, "GPIO %d setup failed (%d)\n",
+				spi->cs_gpio, retval);
+			return retval;
+		}
 
-	if (internal_cs)
-		set_io_bits(dspi->base + SPIPC0, 1 << spi->chip_select);
+		if (internal_cs)
+			set_io_bits(dspi->base + SPIPC0, 1 << spi->chip_select);
+	}
 
 	if (spi->mode & SPI_READY)
 		set_io_bits(dspi->base + SPIPC0, SPIPC0_SPIENA_MASK);
Signature · 1 line
1.7.9.5
maintainer
#2 lore raw

PATCH 1/2 spi: davinci: fix SPI_NO_CS functionality

Quoted 4 lines · Grygorii Strashko

The driver should not touch CS lines if SPI_NO_CS flag is set.
This patch fixes it as this functionality was broken accidentally
by
commit a88e34ea213e1b ("spi: davinci: add support to configure gpio cs through dt").

Applied, thanks.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140821/07768d23/attachment.sig>

#3 lore raw

PATCH 2/2 spi: davinci: support adding delay between transmission

In reply to Grygorii Strashko

This patch completes migration of Davinci SPI driver to DT and adds ability to configure additional properties for SPI slave devices which were possible to configure only from platform code through struct davinci_spi_config before this patch.

New optional SPI slave properties:
- ti,davinci-spi-wdelay : delay between transmissions.
- ti,davinci-spi-odd-parity : odd partity enabled OR
ti,davinci-spi-even-parity : even parity enabled
- ti,davinci-spi-io-type: io type
- ti,davinci-spi-disable-timer: disable CS timer (SPIFMTn)
- ti,davinci-spi-c2t-delay: c2t delay
- ti,davinci-spi-t2c-delay: t2c delay
- ti,davinci-spi-t2e-delay: t2e delay
- ti,davinci-spi-c2e-delay: c2e delay

---
 .../devicetree/bindings/spi/spi-davinci.txt        |   18 +++++
 drivers/spi/spi-davinci.c                          |   80 ++++++++++++++++++--
 2 files changed, 91 insertions(+), 7 deletions(-)
Documentation/devicetree/bindings/spi/spi-davinci.txt +18 -0
index f80887b..bfcd42d 100644
@@ -24,6 +24,22 @@ 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,davinci-spi-wdelay : delay between transmissions.
+- ti,davinci-spi-odd-parity : odd partity enabled
+   OR
+  ti,davinci-spi-even-parity : even parity enabled
+- ti,davinci-spi-io-type: io type (check platform_data/spi-davinci.h)
+- ti,davinci-spi-disable-timer: disable CS timer (SPIFMTn)
+- ti,davinci-spi-c2t-delay: c2t delay
+- ti,davinci-spi-t2c-delay: t2c delay
+- ti,davinci-spi-t2e-delay: t2e delay
+- ti,davinci-spi-c2e-delay: c2e delay
+
 Example of a NOR flash slave device (n25q032) connected to DaVinci
 SPI controller device over the SPI bus.
 
@@ -43,6 +59,8 @@ spi0:spi at 20BF0000 {
 		compatible = "st,m25p32";
 		spi-max-frequency = <25000000>;
 		reg = <0>;
+		ti,davinci-spi-c2t-delay = <8>;
+		ti,davinci-spi-t2c-delay = <8>;
 
 		partition at 0 {
 			label = "u-boot-spl";
drivers/spi/spi-davinci.c +73 -7

139 lines not on this page · raw message

Signature · 1 line
1.7.9.5
maintainer
#4 lore raw

PATCH 2/2 spi: davinci: support adding delay between transmission

Quoted 1 line · Grygorii Strashko

+- ti,davinci-spi-wdelay : delay between transmissions.

I don't understand why this is here - there is already standard support in the SPI core for client drivers specifying inter-transfer delays. If there is a need to provide platform configuration for this in addition to that then it should also be a standard property, there is nothing device specific about these.

Documentation/devicetree/bindings/spi/spi-davinci.txt Optional: · line 35

Quoted 3 lines

+- ti,davinci-spi-odd-parity : odd partity enabled

Documentation/devicetree/bindings/spi/spi-davinci.txt +2 -0
+   OR
+  ti,davinci-spi-even-parity : even parity enabled

What do these mean?

Quoted 1 line

+- ti,davinci-spi-io-type: io type (check platform_data/spi-davinci.h)

The bindings should be independent of the kernel, the values need to be included here (and the defines moved to include/dt-bindings so they can be used when writing DTs).

Quoted 5 lines
+- ti,davinci-spi-disable-timer: disable CS timer (SPIFMTn)
+- ti,davinci-spi-c2t-delay: c2t delay
+- ti,davinci-spi-t2c-delay: t2c delay
+- ti,davinci-spi-t2e-delay: t2e delay
+- ti,davinci-spi-c2e-delay: c2e delay

What are all these timers/delays - at least some reference to the
datasheet please?
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140821/09a45eb3/attachment.sig>

#5 lore raw

PATCH 2/2 spi: davinci: support adding delay between transmission

Hi Mark,

Quoted 9 lines · Mark Brown
Quoted 1 line · Grygorii Strashko

+- ti,davinci-spi-wdelay : delay between transmissions.

I don't understand why this is here - there is already standard support in the SPI core for client drivers specifying inter-transfer delays. If there is a need to provide platform configuration for this in addition to that then it should also be a standard property, there is nothing device specific about these.

Sorry, may be I've missed smth, because I was not able to find such common property in SPI bindings document and code. Could you point me on, pls?

In our case it's hardware delay applied between transmissions:
"Delay in between transmissions. Idle time that will be applied at
the end of the current transmission if the bit WDEL is
set in the current buffer. The delay to be applied is equal to:
WDELAY ? PSPI module clock + 2 ? PSPI module clock
PSPI module clock -> Period of SPI module clock"

Quoted 6 lines

Documentation/devicetree/bindings/spi/spi-davinci.txt Optional: · line 35

Quoted 4 lines

+- ti,davinci-spi-odd-parity : odd partity enabled

Documentation/devicetree/bindings/spi/spi-davinci.txt +2 -0
+   OR
+  ti,davinci-spi-even-parity : even parity enabled

What do these mean?

Supported by OMAP-L138/da830:
"
SPIFMTn[23].PARPOL - Parity polarity: even or odd. PARPOL can be modified in privilege mode only.
0 An even parity flag is added at the end of the transmit data stream.
1 An odd parity flag is added at the end of the transmit data stream.

SPIFMTn[22].PARENA - Parity enable.
0 - No parity generation/ verification is performed.
1 - A parity is transmitted at the end of each transmit data stream. At the end of a transfer the parity generator compares the received parity bit with the locally calculated parity flag. If the parity bits do not match the PARERR flag is set in the corresponding control field. The parity type (even or odd) can be selected via the PARPOL bit.
"

Quoted 6 lines
Quoted 2 lines

+- ti,davinci-spi-io-type: io type (check platform_data/spi-davinci.h)

The bindings should be independent of the kernel, the values need to be included here (and the defines moved to include/dt-bindings so they can be used when writing DTs).

Allowed values here are:
#define SPI_IO_TYPE_INTR 0
#define SPI_IO_TYPE_POLL 1
#define SPI_IO_TYPE_DMA 2

I'll update.

Quoted 10 lines
Quoted 6 lines
+- ti,davinci-spi-disable-timer: disable CS timer (SPIFMTn)
+- ti,davinci-spi-c2t-delay: c2t delay
+- ti,davinci-spi-t2c-delay: t2c delay
+- ti,davinci-spi-t2e-delay: t2e delay
+- ti,davinci-spi-c2e-delay: c2e delay

What are all these timers/delays - at least some reference to the datasheet please?

Sorry, I'll update bindings with links on datasheet.

Keystone 2:
http://www.ti.com/lit/ug/sprugp2a/sprugp2a.pdf

Davinci:
dm644x - http://www.ti.com/lit/ug/sprue32a/sprue32a.pdf
OMAP-L138/da830 - http://www.ti.com/lit/ug/spruh77a/spruh77a.pdf

Regards,
-grygorii

maintainer
#6 lore raw

PATCH 2/2 spi: davinci: support adding delay between transmission

Quoted 5 lines · Grygorii Strashko
Quoted 3 lines · Mark Brown
Quoted 1 line · Grygorii Strashko

+- ti,davinci-spi-wdelay : delay between transmissions.

Quoted 8 lines
Quoted 5 lines

I don't understand why this is here - there is already standard support in the SPI core for client drivers specifying inter-transfer delays. If there is a need to provide platform configuration for this in addition to that then it should also be a standard property, there is nothing device specific about these.

Sorry, may be I've missed smth, because I was not able to find such common property in SPI bindings document and code. Could you point me on, pls?

It's not a property, it's what the delay_usecs in the transfer does. There is no obvious reason to apply something like this unconditionally on every transfer in DT - either it's needed only at particular points in the transfer for device reasons (in which case the device driver needs to know about it) or we need some sort of association with what the device is doing since the way the client driver splits up transfers is entirely up to it.

Quoted 11 lines
Quoted 5 lines

Documentation/devicetree/bindings/spi/spi-davinci.txt Optional: · line 35

Quoted 3 lines

+- ti,davinci-spi-odd-parity : odd partity enabled

Documentation/devicetree/bindings/spi/spi-davinci.txt +2 -0
+   OR
+  ti,davinci-spi-even-parity : even parity enabled

What do these mean?

Supported by OMAP-L138/da830:
"
SPIFMTn[23].PARPOL - Parity polarity: even or odd. PARPOL can be modified in privilege mode only.
0 An even parity flag is added at the end of the transmit data stream.
1 An odd parity flag is added at the end of the transmit data stream.

Why would these be specified in DT and not with runtime flags enabled by the device? It looks like they affect the data stream generated by the controller so the client device needs to know about them; I'd expect that it's device driver would be controlling when they are enabled if the controller supports them.

Quoted 6 lines
Quoted 5 lines
Quoted 1 line

+- ti,davinci-spi-io-type: io type (check platform_data/spi-davinci.h)

The bindings should be independent of the kernel, the values need to be included here (and the defines moved to include/dt-bindings so they can be used when writing DTs).

Quoted 6 lines

Allowed values here are:
#define SPI_IO_TYPE_INTR 0
#define SPI_IO_TYPE_POLL 1
#define SPI_IO_TYPE_DMA 2

I'll update.

Now I see these it's not at all clear why this is configurable at all - I would expect the controller driver to automatically select the most appropriate scheme for the transfers it's doing in order to obtain the best performance rather than having a global switch for this. For almost all devices the best results will be obtained by doing a mix of these modes.

Typically for each level of transfer there will be some minimal size
below which it doesn't make sense to use that control type, for example
it's common to only DMA if there's more than a FIFO worth of data to
transfer.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140822/f295cffa/attachment.sig>

#7 lore raw

PATCH 2/2 spi: davinci: support adding delay between transmission

Hi Mark,

I'm very sorry for delayed replay.

Quoted 15 lines · Mark Brown
Quoted 5 lines · Grygorii Strashko
Quoted 3 lines · Mark Brown
Quoted 1 line · Grygorii Strashko

+- ti,davinci-spi-wdelay : delay between transmissions.

Quoted 8 lines
Quoted 5 lines

I don't understand why this is here - there is already standard support in the SPI core for client drivers specifying inter-transfer delays. If there is a need to provide platform configuration for this in addition to that then it should also be a standard property, there is nothing device specific about these.

Sorry, may be I've missed smth, because I was not able to find such common property in SPI bindings document and code. Could you point me on, pls?

Quoted 7 lines

It's not a property, it's what the delay_usecs in the transfer does. There is no obvious reason to apply something like this unconditionally on every transfer in DT - either it's needed only at particular points in the transfer for device reasons (in which case the device driver needs to know about it) or we need some sort of association with what the device is doing since the way the client driver splits up transfers is entirely up to it.

I think we have some misunderstanding here :(
1) All new properties a optional and should be specified for SPI Slave devices
2) Seems we are talking using different terms:
- you referring to the term "transfers" - sequence of packets. Each packet is one transfer (array of words).
- while these new properties affect on "transmissions" - sequence of words. Each word is one transmission.

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

Also, below is additional information about properties which are used in 5-pin mode (SPI_READY) to improve error detection [OMAP-L138/da830 - http://www.ti.com/lit/ug/spruh77a/spruh77a.pdf]:

Quoted 1 line

- ti,davinci-spi-t2e-delay: t2e delay

Transmit-data-finished-to-SPIx_ENA-pin-inactive-time-out. T2EDELAY is used in master mode only. It defines a time-out value as a multiple of SPI clock before the SPIx_ENA signal has to become inactive and after the CS becomes inactive. The SPI clock depends on which data format is selected. If the slave device is missing one or more clock edges, it is becoming desynchronized. Although the master has finished the data transfer the slave is still waiting for the missed clock pulses and the SPIx_ENA signal is not disabled. The T2EDELAY defines a time-out value that triggers the DESYNC flag, if the SPIx_ENA signal is not deactivated in time. The DESYNC flag is set to indicate that the slave device did not deassert its SPIx_ENA pin in time to acknowledge that it has received all the bits of the sent character. The DESYNC flag is also set if the SPI detects a deassertion of the SPIx_ENA pin even before the end of the transmission.

Quoted 1 line

- ti,davinci-spi-c2e-delay: c2e delay

Chip-select-active-to-SPIx_ENA-signal-active-time-out. C2EDELAY is used only in master mode and it applies only if the addressed slave generates an SPIx_ENA signal as a hardware handshake response. C2EDELAY defines the maximum time between the SPI activates the chip select signal and the addressed slave has to respond by activating the SPIx_ENA signal.

Quoted 13 lines
Quoted 5 lines
Quoted 4 lines
Quoted 4 lines

+- ti,davinci-spi-odd-parity : odd partity enabled

Documentation/devicetree/bindings/spi/spi-davinci.txt +2 -0
+   OR
+  ti,davinci-spi-even-parity : even parity enabled
Quoted 7 lines
Quoted 1 line

What do these mean?

Supported by OMAP-L138/da830:
"
SPIFMTn[23].PARPOL - Parity polarity: even or odd. PARPOL can be modified in privilege mode only.
0 An even parity flag is added at the end of the transmit data stream.
1 An odd parity flag is added at the end of the transmit data stream.

Quoted 6 lines

Why would these be specified in DT and not with runtime flags enabled by the device? It looks like they affect the data stream generated by the controller so the client device needs to know about them; I'd expect that it's device driver would be controlling when they are enabled if the controller supports them.

Could you clarify, pls - Do you mean that struct spi_device.mode and common SPI DT bindings should be extended to support this?

Quoted 20 lines
Quoted 6 lines
Quoted 5 lines
Quoted 1 line

+- ti,davinci-spi-io-type: io type (check platform_data/spi-davinci.h)

The bindings should be independent of the kernel, the values need to be included here (and the defines moved to include/dt-bindings so they can be used when writing DTs).

Quoted 6 lines

Allowed values here are:
#define SPI_IO_TYPE_INTR 0
#define SPI_IO_TYPE_POLL 1
#define SPI_IO_TYPE_DMA 2

I'll update.

Now I see these it's not at all clear why this is configurable at all - I would expect the controller driver to automatically select the most appropriate scheme for the transfers it's doing in order to obtain the best performance rather than having a global switch for this. For almost all devices the best results will be obtained by doing a mix of these modes.

Quoted 5 lines

Typically for each level of transfer there will be some minimal size below which it doesn't make sense to use that control type, for example it's common to only DMA if there's more than a FIFO worth of data to transfer.

Ok. It can be dropped from DT

Best regards,
-grygorii

maintainer
#8 lore raw

PATCH 2/2 spi: davinci: support adding delay between transmission

Quoted 7 lines · Grygorii Strashko

I think we have some misunderstanding here :(
1) All new properties a optional and should be specified for SPI Slave devices
2) Seems we are talking using different terms:
- you referring to the term "transfers" - sequence of packets. Each packet is one transfer (array of words).
- while these new properties affect on "transmissions" - sequence of words. Each word is one transmission.

That's *very* unusual terminology which doesn't match my expectations at all. Please describe words as words, that'll be much more obvious.

Quoted 3 lines

Also, below is additional information about properties which are used in 5-pin mode (SPI_READY) to improve error detection [OMAP-L138/da830 - http://www.ti.com/lit/ug/spruh77a/spruh77a.pdf]:

This is a *whole* other thing, please split these out and work on this separately. The client device is going to need to be doing the same thing here so implementing this as a local option in the controller driver isn't the best way forwards.

Quoted 4 lines
Quoted 3 lines
Quoted 3 lines

SPIFMTn[23].PARPOL - Parity polarity: even or odd. PARPOL can be modified in privilege mode only.
0 An even parity flag is added at the end of the transmit data stream.
1 An odd parity flag is added at the end of the transmit data stream.

Quoted 8 lines
Quoted 5 lines

Why would these be specified in DT and not with runtime flags enabled by the device? It looks like they affect the data stream generated by the controller so the client device needs to know about them; I'd expect that it's device driver would be controlling when they are enabled if the controller supports them.

Could you clarify, pls - Do you mean that struct spi_device.mode and common SPI DT bindings should be extended to support this?

Yes, if they aren't something that's purely internal to the device they
need to be generic so that both devices can be configured appropriately.
-------------- 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/20140906/36c7ece5/attachment-0001.sig>

#9 lore raw

PATCH 2/2 spi: davinci: support adding delay between transmission

Hi Mark,

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

I think we have some misunderstanding here :(
1) All new properties a optional and should be specified for SPI Slave devices
2) Seems we are talking using different terms:
- you referring to the term "transfers" - sequence of packets. Each packet is one transfer (array of words).
- while these new properties affect on "transmissions" - sequence of words. Each word is one transmission.

Quoted 2 lines

That's *very* unusual terminology which doesn't match my expectations at all. Please describe words as words, that'll be much more obvious.

These terms are used in DM/TRM :(

I'll split this patch and first introduce WDELAY, C2TDELAY, T2CDELAY (with updated documentation).
The only question is - Should they be somehow common or specific for spi-davinci?

Quoted 20 lines
Quoted 4 lines

Also, below is additional information about properties which are used in 5-pin mode (SPI_READY) to improve error detection [OMAP-L138/da830 - http://www.ti.com/lit/ug/spruh77a/spruh77a.pdf]:

This is a *whole* other thing, please split these out and work on this separately. The client device is going to need to be doing the same thing here so implementing this as a local option in the controller driver isn't the best way forwards.

Quoted 9 lines
Quoted 9 lines
Quoted 3 lines

SPIFMTn[23].PARPOL - Parity polarity: even or odd. PARPOL can be modified in privilege mode only.
0 An even parity flag is added at the end of the transmit data stream.
1 An odd parity flag is added at the end of the transmit data stream.

Why would these be specified in DT and not with runtime flags enabled by the device? It looks like they affect the data stream generated by the controller so the client device needs to know about them; I'd expect that it's device driver would be controlling when they are enabled if the controller supports them.

Quoted 6 lines
Quoted 2 lines

Could you clarify, pls - Do you mean that struct spi_device.mode and common SPI DT bindings should be extended to support this?

Yes, if they aren't something that's purely internal to the device they need to be generic so that both devices can be configured appropriately.

Regards,
-grygorii

maintainer
#10 lore raw

PATCH 2/2 spi: davinci: support adding delay between transmission

Quoted 3 lines · Grygorii Strashko

I'll split this patch and first introduce WDELAY, C2TDELAY, T2CDELAY (with updated documentation).
The only question is - Should they be somehow common or specific for spi-davinci?

If they don't have any impact on the device at the remote end of the
link then making them device specific is fine.
-------------- 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/20140908/bc5f0571/attachment.sig>