Received: by 10.192.165.148 with SMTP id m20csp2544802imm; Sun, 22 Apr 2018 09:15:03 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+OjpG0VjsXPW6VyrUdjdEbWtPucjGnwBs1KmW0XmdGKSQzry2bdhmT4jZmGM2+ofTQKPHs X-Received: by 10.167.128.81 with SMTP id y17mr16721893pfm.194.1524413703394; Sun, 22 Apr 2018 09:15:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524413703; cv=none; d=google.com; s=arc-20160816; b=BK6qR9O/QYFHn9tEoBv2z40dIepgkBZymu+p3i/6634m7n0WpXHN0v08F3Sk4whTMX /5XM2WiRtnD6B3ArTXRkkn3S2doW+xE0Czi1JCXUpIWeaHGCfV6kmzolu6+EQ5WjK8Us 27kBWU/2UkhWGzfpsEzfhgj10I1gUs1kzNdajk8oLuH3XcziIA51ZRGVXXjVZedkz9b/ B6S1t1lB1WxqLg3hGSgq5EnGGsbT3KIdnapDSe6RRpz1kQp+IfVyPMy3AMNPpzvAIFSt zw/NI7LaDL31sZ/kTzH95jkqnZxTtmEe75zdiRCrKBBcZl/QedvT2aWcwKAZnj64Hw6/ e81w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=jiPDKOiA0dIH4aNGVEGGr4FgrTwOzVXF1YmpIFNKRAk=; b=GiPE6StcGOzhOOdu/3MmNpq9I/TOvZ74JMfc+X/ifcAVv/q82RMFF3NFPrZ3pIOpdt 3p1BCuxRarKaceXCaCR7aRmX3RnJZ1hBCw0Zop18p819BvL3+k4sX2urmZnT+haCJbuL OumL3Zm4rczat8iGFCCaMO1kugc/3W54vD4EfYI4UF3uyyvJpxZJjps7gCwQDAmO829I aXX18XOTCsi+4ITujPPiIdxTEi/ypU10PkZ+e11yw9lhHMa/fDkYc+dlUazBmp5BX0eh 8Av73PkltNgcFoXZ7q4PDJzrk490pK62OTkdCsQitUtVE2oyHUlo66SHMlfcm/HUZi67 s5Qg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 9-v6si10191631plb.415.2018.04.22.09.14.49; Sun, 22 Apr 2018 09:15:03 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753564AbeDVNzg (ORCPT + 99 others); Sun, 22 Apr 2018 09:55:36 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:44680 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753508AbeDVNzc (ORCPT ); Sun, 22 Apr 2018 09:55:32 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 7D84E904; Sun, 22 Apr 2018 13:55:31 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Eugen Hristev , Nicolas Ferre , Mark Brown Subject: [PATCH 4.16 027/196] spi: atmel: init FIFOs before spi enable Date: Sun, 22 Apr 2018 15:50:47 +0200 Message-Id: <20180422135105.523241803@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180422135104.278511750@linuxfoundation.org> References: <20180422135104.278511750@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.16-stable review patch. If anyone has any objections, please let me know. ------------------ From: Eugen Hristev commit 9581329eff9db72ab4fbb46a594fd7fdda3c51b0 upstream. 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 Acked-by: Nicolas Ferre Signed-off-by: Mark Brown Cc: stable@vger.kernel.org Signed-off-by: Greg Kroah-Hartman --- drivers/spi/spi-atmel.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) --- a/drivers/spi/spi-atmel.c +++ b/drivers/spi/spi-atmel.c @@ -1512,6 +1512,11 @@ static void atmel_spi_init(struct atmel_ { 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_ 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)