1 From 9581329eff9db72ab4fbb46a594fd7fdda3c51b0 Mon Sep 17 00:00:00 2001
2 From: Eugen Hristev <eugen.hristev@microchip.com>
3 Date: Tue, 27 Feb 2018 12:25:07 +0200
4 Subject: spi: atmel: init FIFOs before spi enable
6 From: Eugen Hristev <eugen.hristev@microchip.com>
8 commit 9581329eff9db72ab4fbb46a594fd7fdda3c51b0 upstream.
10 The datasheet recommends initializing FIFOs before
11 SPI enable. If we do not do it like this, there may be
12 a strange behavior. We noticed that DMA does not work properly
13 with FIFOs if we do not clear them beforehand or enable them
16 Signed-off-by: Eugen Hristev <eugen.hristev@microchip.com>
17 Acked-by: Nicolas Ferre <nicolas.ferre@microchip.com>
18 Signed-off-by: Mark Brown <broonie@kernel.org>
19 Cc: stable@vger.kernel.org
20 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
23 drivers/spi/spi-atmel.c | 8 +++++---
24 1 file changed, 5 insertions(+), 3 deletions(-)
26 --- a/drivers/spi/spi-atmel.c
27 +++ b/drivers/spi/spi-atmel.c
28 @@ -1512,6 +1512,11 @@ static void atmel_spi_init(struct atmel_
30 spi_writel(as, CR, SPI_BIT(SWRST));
31 spi_writel(as, CR, SPI_BIT(SWRST)); /* AT91SAM9263 Rev B workaround */
33 + /* It is recommended to enable FIFOs first thing after reset */
35 + spi_writel(as, CR, SPI_BIT(FIFOEN));
37 if (as->caps.has_wdrbt) {
38 spi_writel(as, MR, SPI_BIT(WDRBT) | SPI_BIT(MODFDIS)
40 @@ -1522,9 +1527,6 @@ static void atmel_spi_init(struct atmel_
42 spi_writel(as, PTCR, SPI_BIT(RXTDIS) | SPI_BIT(TXTDIS));
43 spi_writel(as, CR, SPI_BIT(SPIEN));
46 - spi_writel(as, CR, SPI_BIT(FIFOEN));
49 static int atmel_spi_probe(struct platform_device *pdev)