linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] spi: atmel: init FIFOs before spi enable
@ 2018-02-27 10:25 Eugen Hristev
  2018-02-27 10:29 ` Nicolas Ferre
  2018-02-28 11:06 ` Applied "spi: atmel: init FIFOs before spi enable" to the spi tree Mark Brown
  0 siblings, 2 replies; 3+ messages in thread
From: Eugen Hristev @ 2018-02-27 10:25 UTC (permalink / raw)
  To: nicolas.ferre, broonie, linux-spi, linux-kernel, linux-arm-kernel
  Cc: Eugen Hristev

The datasheet recommends initializing FIFOs before
SPI enable. If we do not do it like this, there may be
a strange behavior. We noticed that DMA does not work properly
with FIFOs if we do not clear them beforehand or enable them
before SPIEN.

Signed-off-by: Eugen Hristev <eugen.hristev@microchip.com>
---
 drivers/spi/spi-atmel.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/spi/spi-atmel.c b/drivers/spi/spi-atmel.c
index 6694709..0478758 100644
--- a/drivers/spi/spi-atmel.c
+++ b/drivers/spi/spi-atmel.c
@@ -1489,6 +1489,11 @@ static void atmel_spi_init(struct atmel_spi *as)
 {
 	spi_writel(as, CR, SPI_BIT(SWRST));
 	spi_writel(as, CR, SPI_BIT(SWRST)); /* AT91SAM9263 Rev B workaround */
+
+	/* It is recommended to enable FIFOs first thing after reset */
+	if (as->fifo_size)
+		spi_writel(as, CR, SPI_BIT(FIFOEN));
+
 	if (as->caps.has_wdrbt) {
 		spi_writel(as, MR, SPI_BIT(WDRBT) | SPI_BIT(MODFDIS)
 				| SPI_BIT(MSTR));
@@ -1499,9 +1504,6 @@ static void atmel_spi_init(struct atmel_spi *as)
 	if (as->use_pdc)
 		spi_writel(as, PTCR, SPI_BIT(RXTDIS) | SPI_BIT(TXTDIS));
 	spi_writel(as, CR, SPI_BIT(SPIEN));
-
-	if (as->fifo_size)
-		spi_writel(as, CR, SPI_BIT(FIFOEN));
 }
 
 static int atmel_spi_probe(struct platform_device *pdev)
-- 
2.7.4

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

* Re: [PATCH] spi: atmel: init FIFOs before spi enable
  2018-02-27 10:25 [PATCH] spi: atmel: init FIFOs before spi enable Eugen Hristev
@ 2018-02-27 10:29 ` Nicolas Ferre
  2018-02-28 11:06 ` Applied "spi: atmel: init FIFOs before spi enable" to the spi tree Mark Brown
  1 sibling, 0 replies; 3+ messages in thread
From: Nicolas Ferre @ 2018-02-27 10:29 UTC (permalink / raw)
  To: Eugen Hristev, broonie; +Cc: linux-spi, linux-kernel, linux-arm-kernel

On 27/02/2018 at 11:25, Eugen Hristev wrote:
> The datasheet recommends initializing FIFOs before
> SPI enable. If we do not do it like this, there may be
> a strange behavior. We noticed that DMA does not work properly
> with FIFOs if we do not clear them beforehand or enable them
> before SPIEN.
> 
> Signed-off-by: Eugen Hristev <eugen.hristev@microchip.com>

Ok, good:
Acked-by: Nicolas Ferre <nicolas.ferre@microchip.com>

> ---
>   drivers/spi/spi-atmel.c | 8 +++++---
>   1 file changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/spi/spi-atmel.c b/drivers/spi/spi-atmel.c
> index 6694709..0478758 100644
> --- a/drivers/spi/spi-atmel.c
> +++ b/drivers/spi/spi-atmel.c
> @@ -1489,6 +1489,11 @@ static void atmel_spi_init(struct atmel_spi *as)
>   {
>   	spi_writel(as, CR, SPI_BIT(SWRST));
>   	spi_writel(as, CR, SPI_BIT(SWRST)); /* AT91SAM9263 Rev B workaround */
> +
> +	/* It is recommended to enable FIFOs first thing after reset */
> +	if (as->fifo_size)
> +		spi_writel(as, CR, SPI_BIT(FIFOEN));
> +
>   	if (as->caps.has_wdrbt) {
>   		spi_writel(as, MR, SPI_BIT(WDRBT) | SPI_BIT(MODFDIS)
>   				| SPI_BIT(MSTR));
> @@ -1499,9 +1504,6 @@ static void atmel_spi_init(struct atmel_spi *as)
>   	if (as->use_pdc)
>   		spi_writel(as, PTCR, SPI_BIT(RXTDIS) | SPI_BIT(TXTDIS));
>   	spi_writel(as, CR, SPI_BIT(SPIEN));
> -
> -	if (as->fifo_size)
> -		spi_writel(as, CR, SPI_BIT(FIFOEN));
>   }
>   
>   static int atmel_spi_probe(struct platform_device *pdev)
> 


-- 
Nicolas Ferre

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

* Applied "spi: atmel: init FIFOs before spi enable" to the spi tree
  2018-02-27 10:25 [PATCH] spi: atmel: init FIFOs before spi enable Eugen Hristev
  2018-02-27 10:29 ` Nicolas Ferre
@ 2018-02-28 11:06 ` Mark Brown
  1 sibling, 0 replies; 3+ messages in thread
From: Mark Brown @ 2018-02-28 11:06 UTC (permalink / raw)
  To: Eugen Hristev
  Cc: Nicolas Ferre, Mark Brown, stable, nicolas.ferre, broonie,
	linux-spi, linux-kernel, linux-arm-kernel, linux-spi

The patch

   spi: atmel: init FIFOs before spi enable

has been applied to the spi tree at

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git 

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.  

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

>From 9581329eff9db72ab4fbb46a594fd7fdda3c51b0 Mon Sep 17 00:00:00 2001
From: Eugen Hristev <eugen.hristev@microchip.com>
Date: Tue, 27 Feb 2018 12:25:07 +0200
Subject: [PATCH] spi: atmel: init FIFOs before spi enable

The datasheet recommends initializing FIFOs before
SPI enable. If we do not do it like this, there may be
a strange behavior. We noticed that DMA does not work properly
with FIFOs if we do not clear them beforehand or enable them
before SPIEN.

Signed-off-by: Eugen Hristev <eugen.hristev@microchip.com>
Acked-by: Nicolas Ferre <nicolas.ferre@microchip.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
Cc: stable@vger.kernel.org
---
 drivers/spi/spi-atmel.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/spi/spi-atmel.c b/drivers/spi/spi-atmel.c
index 4a11fc0d4136..b7936f815373 100644
--- a/drivers/spi/spi-atmel.c
+++ b/drivers/spi/spi-atmel.c
@@ -1512,6 +1512,11 @@ static void atmel_spi_init(struct atmel_spi *as)
 {
 	spi_writel(as, CR, SPI_BIT(SWRST));
 	spi_writel(as, CR, SPI_BIT(SWRST)); /* AT91SAM9263 Rev B workaround */
+
+	/* It is recommended to enable FIFOs first thing after reset */
+	if (as->fifo_size)
+		spi_writel(as, CR, SPI_BIT(FIFOEN));
+
 	if (as->caps.has_wdrbt) {
 		spi_writel(as, MR, SPI_BIT(WDRBT) | SPI_BIT(MODFDIS)
 				| SPI_BIT(MSTR));
@@ -1522,9 +1527,6 @@ static void atmel_spi_init(struct atmel_spi *as)
 	if (as->use_pdc)
 		spi_writel(as, PTCR, SPI_BIT(RXTDIS) | SPI_BIT(TXTDIS));
 	spi_writel(as, CR, SPI_BIT(SPIEN));
-
-	if (as->fifo_size)
-		spi_writel(as, CR, SPI_BIT(FIFOEN));
 }
 
 static int atmel_spi_probe(struct platform_device *pdev)
-- 
2.16.1

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

end of thread, other threads:[~2018-02-28 11:06 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-27 10:25 [PATCH] spi: atmel: init FIFOs before spi enable Eugen Hristev
2018-02-27 10:29 ` Nicolas Ferre
2018-02-28 11:06 ` Applied "spi: atmel: init FIFOs before spi enable" to the spi tree Mark Brown

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