Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1833569yba; Thu, 4 Apr 2019 20:29:50 -0700 (PDT) X-Google-Smtp-Source: APXvYqxYOeOxwJy5bJU1RsrUt5cIdVRfELX+OcwizZeo68FYrvOTWdCr9SNGV+XCc2jrwco/+jG7 X-Received: by 2002:a17:902:1008:: with SMTP id b8mr10120308pla.120.1554434990093; Thu, 04 Apr 2019 20:29:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554434990; cv=none; d=google.com; s=arc-20160816; b=KVfHkLU8H3Lh36n5CdTCUGEckApkrhOysARVd+x5zmM0b1/EJe9y4ToDTQo7D9JSGl fFGzAjPGt3YbNkHir/oetLCR4gD0jVihEsNgcqhijPT9XcBqaB65Ga5mJVsunXrRRCJb QWvSFXIvbtsFLmfRF7HQqMh/K/O2IxL0oeMiPmYZlvajewMfIWvhM9/c2jEofkN+sKET QDaUBfMPmEtuEWOeOLnS6ai3Msovfe+rt5K+E5Dwz3fiA+MSGFw+GM5sBofKTqFh1W0z QSIxReCQGuHzRWUz0nojUJrMcHJzy83UNiKuxGtvEn8h0gz2jLN2WSU0vXOh0BwrxKl3 MQvA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:date:message-id:in-reply-to:subject:cc:to :from:dkim-signature; bh=xdSl9JUhngWotCtrT0gu8jVzPA3wB87/bI4tFDht9FY=; b=GN2alFy/I435+K84CmK/fhLuYyWKpzps3qgutUZoJR/h7AsTmD3GDAFRliH8hGdd3d c8QdtoBCuVTZr6/Y9eB6HrBt+5yVTBoiMpuhQFS96FC8ldcoNTng93qDr0f33VE3reXC GBT0Uq80L9GvdwLQr52fMrQ8ONLm/bHjNlOHNucUiB1b/AQeV8d1UL3f1gF3Gu7onSBz an/oyTMH0N1CEADcrjcxHx1Tm0Nr4fWM5Ve/CWp86bUtJygBw7VM4EkIcTqOOK1LPtp3 BOxIuNSNfwxOcvRjmsUI/6ZNWMREwLNjfXHomAYsOZ/1yjWbrSVz6lXAYoroSAU3VSL/ ifbw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@sirena.org.uk header.s=20170815-heliosphere header.b=Lobcdkaf; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ct1si18537459plb.419.2019.04.04.20.29.35; Thu, 04 Apr 2019 20:29:50 -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; dkim=fail header.i=@sirena.org.uk header.s=20170815-heliosphere header.b=Lobcdkaf; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730355AbfDED1O (ORCPT + 99 others); Thu, 4 Apr 2019 23:27:14 -0400 Received: from heliosphere.sirena.org.uk ([172.104.155.198]:34334 "EHLO heliosphere.sirena.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730237AbfDED1J (ORCPT ); Thu, 4 Apr 2019 23:27:09 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sirena.org.uk; s=20170815-heliosphere; h=Date:Message-Id:In-Reply-To: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:References: List-Id:List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner: List-Archive; bh=xdSl9JUhngWotCtrT0gu8jVzPA3wB87/bI4tFDht9FY=; b=Lobcdkaf4HRQ 8GAOVQZdQ3+M/vAgegaorWA26LlgFHNsEjh32RuyBiaFeAwaeme3ox3OoOx6SsMZz1ptQ6yDjQHQl P96CrKWt0TmL1XdkmLlLV9/1ZAM4uJgjp5rzWHiBZVNEbjZRgB9adpatIhDH6PLPF5Hu3pZqcP7Fl gjFlI=; Received: from [147.50.13.10] (helo=finisterre.ee.mobilebroadband) by heliosphere.sirena.org.uk with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1hCFVQ-0005gq-7f; Fri, 05 Apr 2019 03:27:04 +0000 Received: by finisterre.ee.mobilebroadband (Postfix, from userid 1000) id 14731441D3C; Fri, 5 Apr 2019 10:27:01 +0700 (+07) From: Mark Brown To: Sowjanya Komatineni Cc: Mark Brown , thierry.reding@gmail.com, jonathanh@nvidia.com, talho@nvidia.com, skomatineni@nvidia.com, broonie@kernel.org, robh+dt@kernel.org, mark.rutland@arm.com, kyarlagadda@nvidia.com, ldewangan@nvidia.com, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org, linux-spi@vger.kernel.org, devicetree@vger.kernel.org, linux-spi@vger.kernel.org Subject: Applied "spi: tegra114: de-assert CS before SPI mode change" to the spi tree In-Reply-To: <1554423259-26056-3-git-send-email-skomatineni@nvidia.com> X-Patchwork-Hint: ignore Message-Id: <20190405032701.14731441D3C@finisterre.ee.mobilebroadband> Date: Fri, 5 Apr 2019 10:27:01 +0700 (+07) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The patch spi: tegra114: de-assert CS before SPI mode change 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 f3e182c33e534f4caeb255a3ab927debc0d222aa Mon Sep 17 00:00:00 2001 From: Sowjanya Komatineni Date: Thu, 4 Apr 2019 17:14:02 -0700 Subject: [PATCH] spi: tegra114: de-assert CS before SPI mode change With SW CS, during the transfer completion CS is de-asserted by writing default command1 register value to SPI_COMMAND1 register. With this both mode and CS state are set at the same time and if current transfer mode is different to default SPI mode and if mode change happens prior to CS de-assert, clock polarity can change while CS is active before transfer finishes. This causes Slave to see spurious clock edges resulting in data mismatch. This patch fixes this by de-asserting CS before writing SPI_COMMAND1 to its default value so through out the transfer it will be in same SPI mode. Signed-off-by: Sowjanya Komatineni Signed-off-by: Mark Brown --- drivers/spi/spi-tegra114.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/drivers/spi/spi-tegra114.c b/drivers/spi/spi-tegra114.c index 09cfae3abce2..8de002fc6943 100644 --- a/drivers/spi/spi-tegra114.c +++ b/drivers/spi/spi-tegra114.c @@ -856,6 +856,19 @@ static void tegra_spi_transfer_delay(int delay) udelay(delay % 1000); } +static void tegra_spi_transfer_end(struct spi_device *spi) +{ + struct tegra_spi_data *tspi = spi_master_get_devdata(spi->master); + int cs_val = (spi->mode & SPI_CS_HIGH) ? 0 : 1; + + if (cs_val) + tspi->command1_reg |= SPI_CS_SW_VAL; + else + tspi->command1_reg &= ~SPI_CS_SW_VAL; + tegra_spi_writel(tspi, tspi->command1_reg, SPI_COMMAND1); + tegra_spi_writel(tspi, tspi->def_command1_reg, SPI_COMMAND1); +} + static int tegra_spi_transfer_one_message(struct spi_master *master, struct spi_message *msg) { @@ -918,8 +931,7 @@ static int tegra_spi_transfer_one_message(struct spi_master *master, complete_xfer: if (ret < 0 || skip) { - tegra_spi_writel(tspi, tspi->def_command1_reg, - SPI_COMMAND1); + tegra_spi_transfer_end(spi); tegra_spi_transfer_delay(xfer->delay_usecs); goto exit; } else if (list_is_last(&xfer->transfer_list, @@ -927,13 +939,11 @@ static int tegra_spi_transfer_one_message(struct spi_master *master, if (xfer->cs_change) tspi->cs_control = spi; else { - tegra_spi_writel(tspi, tspi->def_command1_reg, - SPI_COMMAND1); + tegra_spi_transfer_end(spi); tegra_spi_transfer_delay(xfer->delay_usecs); } } else if (xfer->cs_change) { - tegra_spi_writel(tspi, tspi->def_command1_reg, - SPI_COMMAND1); + tegra_spi_transfer_end(spi); tegra_spi_transfer_delay(xfer->delay_usecs); } -- 2.20.1