Received: by 10.223.185.116 with SMTP id b49csp4781667wrg; Tue, 27 Feb 2018 02:29:19 -0800 (PST) X-Google-Smtp-Source: AH8x227MnrR0qbi766TgQLO5IL8QD61WIwk4DCNRyvi0/Jgsu6QtVIHMqVCRVFholQhhg2N+5dW1 X-Received: by 2002:a17:902:8501:: with SMTP id bj1-v6mr14098730plb.110.1519727358924; Tue, 27 Feb 2018 02:29:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519727358; cv=none; d=google.com; s=arc-20160816; b=YXtKhuIGPO2UAhkbbUE2v0nUmlC7vQOTQHKMtkPVHyTWCBu3jxTB1REDwvNYUL+Tk5 Baf+9Ad74jIRPnYvXlc9zYM8jl/pxCrwmQjhWlxp4gMMWHwykCdL3dbGLHIImXhXI7pQ OPF90JMeIvLmVmxeK1XkJSlmXlTtPLZQzs6OUaMs7Wfm0dssKfL2tDBrwMLl9iNfSXTy rG6de3qRXxrtvCcS6s7vmD0JkxTibdIjBXZg8cbbnk76UOA5xjtlY+du24k5ZDNesD9M oDGtPbCOLUVAPNrZith0OAGuJ+Saen5ctd5FfFrqDULY1fiAUjBvITuXBq0xZbLsxR/U o43g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from:arc-authentication-results; bh=Mh6+DJLnmIiVsh8l/dy5N9LTa3I31S973I6OapbQ2C4=; b=EZyUfjAPm1hpGjqUdRErK7cLisE/QviSukIF5B9Or9YKrz5eKsGoQ2ZFFFp4pimDjq 2VjXU802JDxlAVI/CVUp+j8ydIR7L0t1j8zuuwetTfX7k4SoRkyKUdub8y9uykdcsubh eZfUOVA3lbH4Hs8J3c1ekyvnb8USKXH3kr39C+5Lx5z+iCZyBN8YnezOYpyeY7zLCtWZ GNYifMIR9lESipgCt1PXddRipHM6DlPvBj3EOHx9kEWoDDn5eGamJhTyUDCyAhaUu+/T 4xQ0fTzwH6rYCgGx/JSJDz/tuNGpgXCpkCTd+xorZZVG71fl33oQKpWyXoCfLTIoPApB N3Dg== 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 x6si1662456pgp.254.2018.02.27.02.29.04; Tue, 27 Feb 2018 02:29:18 -0800 (PST) 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 S1752855AbeB0K1t (ORCPT + 99 others); Tue, 27 Feb 2018 05:27:49 -0500 Received: from esa6.microchip.iphmx.com ([216.71.154.253]:51940 "EHLO esa6.microchip.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752689AbeB0K1s (ORCPT ); Tue, 27 Feb 2018 05:27:48 -0500 X-IronPort-AV: E=Sophos;i="5.47,400,1515481200"; d="scan'208";a="9188935" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa6.microchip.iphmx.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 27 Feb 2018 03:27:47 -0700 Received: from eh-station.microchip.com (10.10.76.4) by chn-sv-exch04.mchp-main.com (10.10.76.105) with Microsoft SMTP Server id 14.3.352.0; Tue, 27 Feb 2018 03:27:46 -0700 From: Eugen Hristev To: , , , , CC: Eugen Hristev Subject: [PATCH] spi: atmel: init FIFOs before spi enable Date: Tue, 27 Feb 2018 12:25:07 +0200 Message-ID: <1519727107-5821-1-git-send-email-eugen.hristev@microchip.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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