linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] spi: tegra20-slink: change chip select action order
@ 2019-03-26 14:30 Randolph Maaßen
  2019-03-26 14:44 ` Thierry Reding
  2019-03-28 16:34 ` Thierry Reding
  0 siblings, 2 replies; 4+ messages in thread
From: Randolph Maaßen @ 2019-03-26 14:30 UTC (permalink / raw)
  To: gaireg
  Cc: Laxman Dewangan, Mark Brown, Thierry Reding, Jonathan Hunter,
	linux-spi, linux-tegra, linux-kernel

To transfer via SPI the tegra20-slink driver first sets the command
register, which contains the chip select value, and after that the
command2 register, which contains the chip select line. This leads to a
small spike in the chip selct 0 line between the set of the value and
the selection of the chip select line.

This commit changes the order of the register writes so that first the
chip select line is chosen and then the value is set, removing the
spike.

Signed-off-by: Randolph Maaßen <gaireg@gaireg.de>
---
 drivers/spi/spi-tegra20-slink.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/spi/spi-tegra20-slink.c b/drivers/spi/spi-tegra20-slink.c
index 1427f343b39a..6d4679126213 100644
--- a/drivers/spi/spi-tegra20-slink.c
+++ b/drivers/spi/spi-tegra20-slink.c
@@ -717,9 +717,6 @@ static int tegra_slink_start_transfer_one(struct spi_device *spi,
 	command2 = tspi->command2_reg;
 	command2 &= ~(SLINK_RXEN | SLINK_TXEN);
 
-	tegra_slink_writel(tspi, command, SLINK_COMMAND);
-	tspi->command_reg = command;
-
 	tspi->cur_direction = 0;
 	if (t->rx_buf) {
 		command2 |= SLINK_RXEN;
@@ -729,9 +726,18 @@ static int tegra_slink_start_transfer_one(struct spi_device *spi,
 		command2 |= SLINK_TXEN;
 		tspi->cur_direction |= DATA_DIR_TX;
 	}
+
+	/*
+	 * Writing to the command2 register bevore the command register prevents
+	 * a spike in chip_select line 0. This selects the chip_select line
+	 * before changing the chip_select value.
+	 */
 	tegra_slink_writel(tspi, command2, SLINK_COMMAND2);
 	tspi->command2_reg = command2;
 
+	tegra_slink_writel(tspi, command, SLINK_COMMAND);
+	tspi->command_reg = command;
+
 	if (total_fifo_words > SLINK_FIFO_DEPTH)
 		ret = tegra_slink_start_dma_based_transfer(tspi, t);
 	else
-- 
2.11.0


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

* Re: [PATCH] spi: tegra20-slink: change chip select action order
  2019-03-26 14:30 [PATCH] spi: tegra20-slink: change chip select action order Randolph Maaßen
@ 2019-03-26 14:44 ` Thierry Reding
  2019-03-26 19:11   ` Sowjanya Komatineni
  2019-03-28 16:34 ` Thierry Reding
  1 sibling, 1 reply; 4+ messages in thread
From: Thierry Reding @ 2019-03-26 14:44 UTC (permalink / raw)
  To: Randolph Maaßen
  Cc: Laxman Dewangan, Mark Brown, Jonathan Hunter,
	Sowjanya Komatineni, linux-spi, linux-tegra, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 2093 bytes --]

On Tue, Mar 26, 2019 at 03:30:50PM +0100, Randolph Maaßen wrote:
> To transfer via SPI the tegra20-slink driver first sets the command
> register, which contains the chip select value, and after that the
> command2 register, which contains the chip select line. This leads to a
> small spike in the chip selct 0 line between the set of the value and
> the selection of the chip select line.
> 
> This commit changes the order of the register writes so that first the
> chip select line is chosen and then the value is set, removing the
> spike.
> 
> Signed-off-by: Randolph Maaßen <gaireg@gaireg.de>
> ---
>  drivers/spi/spi-tegra20-slink.c | 12 +++++++++---
>  1 file changed, 9 insertions(+), 3 deletions(-)

Looks good to me. Adding Sowjanya who has been looking into SPI
recently.

Thierry

> diff --git a/drivers/spi/spi-tegra20-slink.c b/drivers/spi/spi-tegra20-slink.c
> index 1427f343b39a..6d4679126213 100644
> --- a/drivers/spi/spi-tegra20-slink.c
> +++ b/drivers/spi/spi-tegra20-slink.c
> @@ -717,9 +717,6 @@ static int tegra_slink_start_transfer_one(struct spi_device *spi,
>  	command2 = tspi->command2_reg;
>  	command2 &= ~(SLINK_RXEN | SLINK_TXEN);
>  
> -	tegra_slink_writel(tspi, command, SLINK_COMMAND);
> -	tspi->command_reg = command;
> -
>  	tspi->cur_direction = 0;
>  	if (t->rx_buf) {
>  		command2 |= SLINK_RXEN;
> @@ -729,9 +726,18 @@ static int tegra_slink_start_transfer_one(struct spi_device *spi,
>  		command2 |= SLINK_TXEN;
>  		tspi->cur_direction |= DATA_DIR_TX;
>  	}
> +
> +	/*
> +	 * Writing to the command2 register bevore the command register prevents
> +	 * a spike in chip_select line 0. This selects the chip_select line
> +	 * before changing the chip_select value.
> +	 */
>  	tegra_slink_writel(tspi, command2, SLINK_COMMAND2);
>  	tspi->command2_reg = command2;
>  
> +	tegra_slink_writel(tspi, command, SLINK_COMMAND);
> +	tspi->command_reg = command;
> +
>  	if (total_fifo_words > SLINK_FIFO_DEPTH)
>  		ret = tegra_slink_start_dma_based_transfer(tspi, t);
>  	else
> -- 
> 2.11.0
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* RE: [PATCH] spi: tegra20-slink: change chip select action order
  2019-03-26 14:44 ` Thierry Reding
@ 2019-03-26 19:11   ` Sowjanya Komatineni
  0 siblings, 0 replies; 4+ messages in thread
From: Sowjanya Komatineni @ 2019-03-26 19:11 UTC (permalink / raw)
  To: Thierry Reding, Randolph Maaßen
  Cc: Laxman Dewangan, Mark Brown, Jonathan Hunter, linux-spi,
	linux-tegra, linux-kernel

> On Tue, Mar 26, 2019 at 03:30:50PM +0100, Randolph Maaßen wrote:
> > To transfer via SPI the tegra20-slink driver first sets the command 
> > register, which contains the chip select value, and after that the
> > command2 register, which contains the chip select line. This leads to 
> > a small spike in the chip selct 0 line between the set of the value 
> > and the selection of the chip select line.
> > 
> > This commit changes the order of the register writes so that first the 
> > chip select line is chosen and then the value is set, removing the 
> > spike.
> > 
> > Signed-off-by: Randolph Maaßen <gaireg@gaireg.de>

Very minor typo in the comment below:

Fix looks good as chip select need to be selected prior to asserting during
start of transfer.

Reviewed-by: Sowjanya Komatineni <skomatineni@nvidia.com>

> > ---
> >  drivers/spi/spi-tegra20-slink.c | 12 +++++++++---
> >  1 file changed, 9 insertions(+), 3 deletions(-)
>
> Looks good to me. Adding Sowjanya who has been looking into SPI recently.
>
> Thierry
>
> > diff --git a/drivers/spi/spi-tegra20-slink.c 
> > b/drivers/spi/spi-tegra20-slink.c index 1427f343b39a..6d4679126213 
> > 100644
> > --- a/drivers/spi/spi-tegra20-slink.c
> > +++ b/drivers/spi/spi-tegra20-slink.c
> > @@ -717,9 +717,6 @@ static int tegra_slink_start_transfer_one(struct spi_device *spi,
> >  	command2 = tspi->command2_reg;
> >  	command2 &= ~(SLINK_RXEN | SLINK_TXEN);
> >  
> > -	tegra_slink_writel(tspi, command, SLINK_COMMAND);
> > -	tspi->command_reg = command;
> > -
> >  	tspi->cur_direction = 0;
> >  	if (t->rx_buf) {
> >  		command2 |= SLINK_RXEN;
> > @@ -729,9 +726,18 @@ static int tegra_slink_start_transfer_one(struct spi_device *spi,
> >  		command2 |= SLINK_TXEN;
> >  		tspi->cur_direction |= DATA_DIR_TX;
> >  	}
> > +
> > +	/*
> > +	 * Writing to the command2 register bevore the command register prevents
> > +	 * a spike in chip_select line 0. This selects the chip_select line
> > +	 * before changing the chip_select value.
> > +	 */

Type "before"

> >  	tegra_slink_writel(tspi, command2, SLINK_COMMAND2);
> >  	tspi->command2_reg = command2;
> >  
> > +	tegra_slink_writel(tspi, command, SLINK_COMMAND);
> > +	tspi->command_reg = command;
> > +
> >  	if (total_fifo_words > SLINK_FIFO_DEPTH)
> >  		ret = tegra_slink_start_dma_based_transfer(tspi, t);
> >  	else
> > --
> > 2.11.0
> > 

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

* Re: [PATCH] spi: tegra20-slink: change chip select action order
  2019-03-26 14:30 [PATCH] spi: tegra20-slink: change chip select action order Randolph Maaßen
  2019-03-26 14:44 ` Thierry Reding
@ 2019-03-28 16:34 ` Thierry Reding
  1 sibling, 0 replies; 4+ messages in thread
From: Thierry Reding @ 2019-03-28 16:34 UTC (permalink / raw)
  To: Randolph Maaßen
  Cc: Laxman Dewangan, Mark Brown, Jonathan Hunter, linux-spi,
	linux-tegra, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 838 bytes --]

On Tue, Mar 26, 2019 at 03:30:50PM +0100, Randolph Maaßen wrote:
> To transfer via SPI the tegra20-slink driver first sets the command
> register, which contains the chip select value, and after that the
> command2 register, which contains the chip select line. This leads to a
> small spike in the chip selct 0 line between the set of the value and
> the selection of the chip select line.
> 
> This commit changes the order of the register writes so that first the
> chip select line is chosen and then the value is set, removing the
> spike.
> 
> Signed-off-by: Randolph Maaßen <gaireg@gaireg.de>
> ---
>  drivers/spi/spi-tegra20-slink.c | 12 +++++++++---
>  1 file changed, 9 insertions(+), 3 deletions(-)

With the typofix that Sowjanya pointed out, this patch is:

Acked-by: Thierry Reding <treding@nvidia.com>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

end of thread, other threads:[~2019-03-28 16:34 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-26 14:30 [PATCH] spi: tegra20-slink: change chip select action order Randolph Maaßen
2019-03-26 14:44 ` Thierry Reding
2019-03-26 19:11   ` Sowjanya Komatineni
2019-03-28 16:34 ` Thierry Reding

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