]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/4.16.4/spi-atmel-init-fifos-before-spi-enable.patch
Fixes for 4.19
[thirdparty/kernel/stable-queue.git] / releases / 4.16.4 / spi-atmel-init-fifos-before-spi-enable.patch
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
5
6 From: Eugen Hristev <eugen.hristev@microchip.com>
7
8 commit 9581329eff9db72ab4fbb46a594fd7fdda3c51b0 upstream.
9
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
14 before SPIEN.
15
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>
21
22 ---
23 drivers/spi/spi-atmel.c | 8 +++++---
24 1 file changed, 5 insertions(+), 3 deletions(-)
25
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_
29 {
30 spi_writel(as, CR, SPI_BIT(SWRST));
31 spi_writel(as, CR, SPI_BIT(SWRST)); /* AT91SAM9263 Rev B workaround */
32 +
33 + /* It is recommended to enable FIFOs first thing after reset */
34 + if (as->fifo_size)
35 + spi_writel(as, CR, SPI_BIT(FIFOEN));
36 +
37 if (as->caps.has_wdrbt) {
38 spi_writel(as, MR, SPI_BIT(WDRBT) | SPI_BIT(MODFDIS)
39 | SPI_BIT(MSTR));
40 @@ -1522,9 +1527,6 @@ static void atmel_spi_init(struct atmel_
41 if (as->use_pdc)
42 spi_writel(as, PTCR, SPI_BIT(RXTDIS) | SPI_BIT(TXTDIS));
43 spi_writel(as, CR, SPI_BIT(SPIEN));
44 -
45 - if (as->fifo_size)
46 - spi_writel(as, CR, SPI_BIT(FIFOEN));
47 }
48
49 static int atmel_spi_probe(struct platform_device *pdev)