From patchwork Tue Mar 15 13:24:36 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dirk Behme X-Patchwork-Id: 8588391 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id C6C1EC0553 for ; Tue, 15 Mar 2016 13:35:53 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D12A220272 for ; Tue, 15 Mar 2016 13:35:52 +0000 (UTC) Received: from bombadil.infradead.org (unknown [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E763B20259 for ; Tue, 15 Mar 2016 13:35:51 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1afoyB-0002ll-UG; Tue, 15 Mar 2016 13:25:07 +0000 Received: from smtp6-v.fe.bosch.de ([2a03:cc00:ff0:100::2]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1afoy8-000210-4P for linux-arm-kernel@lists.infradead.org; Tue, 15 Mar 2016 13:25:06 +0000 Received: from vsmta11.fe.internet.bosch.com (unknown [10.4.98.51]) by imta23.fe.bosch.de (Postfix) with ESMTP id E578815801DC for ; Tue, 15 Mar 2016 14:24:39 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=de.bosch.com; s=2015-01-21; t=1458048280; bh=ouBWHh5srlogj/Sk3yWmNfyMJAskJgSoTHPUkeXkeks=; l=10; h=From:From:Reply-To:Sender; b=cwO5Ht8mu856//pvwzQdzxv85Jm9ve9JvfkMiQ0z6KBwlckLcAO9P59Z/AOZHACJN 0Oaimx5/965xXruTSQ5dh0Ltx6mYUcvA4zeKwBjSpUGVWoBcwIclu9aDgzgY2WNXP2 moWjxPaXKmjk6ef70M6OhDplAMocXV+cOqTpCNfQ= Received: from SI-HUB1000.de.bosch.com (vsgw23.fe.internet.bosch.com [10.4.98.23]) by vsmta11.fe.internet.bosch.com (Postfix) with ESMTP id 32FD023803E2 for ; Tue, 15 Mar 2016 14:24:39 +0100 (CET) Received: from hi-z5661.hi.de.bosch.com (10.34.218.199) by SI-HUB1000.de.bosch.com (10.4.103.106) with Microsoft SMTP Server id 14.3.195.1; Tue, 15 Mar 2016 14:24:38 +0100 Received: from hi-z5661.hi.de.bosch.com (localhost [127.0.0.1]) by hi-z5661.hi.de.bosch.com (Postfix) with ESMTP id 9AA9B41938; Tue, 15 Mar 2016 14:24:38 +0100 (CET) From: Dirk Behme To: Subject: [PATCH] spi: imx: only do necessary changes to ECSPIx_CONFIGREG Date: Tue, 15 Mar 2016 14:24:36 +0100 Message-ID: <1458048276-31884-1-git-send-email-dirk.behme@de.bosch.com> X-Mailer: git-send-email 2.5.0 MIME-Version: 1.0 X-TM-AS-MML: disable X-TM-AS-Product-Ver: IMSS-7.1.0.1679-8.0.0.1202-22194.006 X-TMASE-MatchedRID: yFnf+gesVg3a2uUBzc39cxWCVBr+Ay98uLwbhNl9B5VG4xBL094F0zUi 2rTIOxGGixoMhF/zQlMinacvtkUAF/MtVkU5mvDe+Fq9Vk/m1NpQCOsAlaxN7xQLE16MmfDLA0L 8HE1Djlm1wEUPgBP4eg8At07mNNbxMA8bs51X9/kZXJLztZviXPaS52LUPfcSRi9INZ1ZpGE0Tu QyyQD42+L5LHX7Wlu62wh79NdRsvWQqMvYg6LYsAe06kQGFaIWF7ufiw/c2JBOCKknS3UyncF/O 5AVoFmw4vM1YF6AJbbCCfuIMF6xLSdET58jp62SpFHROTfIzK5iT7cJ+IZDoWl4pWDyNdlw2MxD ldQGVaR58vGhQHTbMEs47Dv2T7h3iIxs+3k/GKzo2P94SDjYCe4iGUJg/RIoXCkStwzPypokBnZ dbUCO7dP+R0Mb1QdVNPmhoVMfCdppb8gNRjT19Q== X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160315_062504_753204_53952DA7 X-CRM114-Status: GOOD ( 12.55 ) X-Spam-Score: -7.0 (-------) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Dirk Behme , Sascha Hauer , Mark Brown , linux-arm-kernel@lists.infradead.org, Knut Wohlrab , Vladimir Zapolskiy Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-3.3 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, RDNS_NONE, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Knut Wohlrab If the SPI chip select (CS) for a dedicated channel is done manually by the used higher device driver, the CS may be active while writing to ECSPIx_CONFIGREG. To prevent unwanted clock edges when selecting the clock mode, only do the necessary changes to the i.MX SPI configuration register and leave not selected channels untouched. To prevent unwanted clock edges on first use, an empty dummy transmission shall be done by the initialization procedure of the device driver of this channel. This will set the clock mode to the correct state. Signed-off-by: Knut Wohlrab Signed-off-by: Dirk Behme Acked-by: Sascha Hauer --- This is regarding the discussion in http://www.spinics.net/lists/arm-kernel/msg489107.html and the revert https://git.kernel.org/cgit/linux/kernel/git/broonie/spi.git/commit/drivers/spi/spi-imx.c?h=for-linus&id=c34de7168cd201ab757b11bfc7899953948d7753 This version is mainly the same like the reverted one, but making sure that the cfg variable isn't just 0. This patch is against https://git.kernel.org/cgit/linux/kernel/git/broonie/spi.git/log/?h=for-linus commit d00de215041f706 drivers/spi/spi-imx.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/spi/spi-imx.c b/drivers/spi/spi-imx.c index e7a19be..b79d70d 100644 --- a/drivers/spi/spi-imx.c +++ b/drivers/spi/spi-imx.c @@ -333,8 +333,9 @@ static void __maybe_unused mx51_ecspi_trigger(struct spi_imx_data *spi_imx) static int __maybe_unused mx51_ecspi_config(struct spi_imx_data *spi_imx, struct spi_imx_config *config) { - u32 ctrl = MX51_ECSPI_CTRL_ENABLE, cfg = 0; + u32 ctrl = MX51_ECSPI_CTRL_ENABLE; u32 clk = config->speed_hz, delay, reg; + u32 cfg = readl(spi_imx->base + MX51_ECSPI_CONFIG); /* * The hardware seems to have a race condition when changing modes. The @@ -358,13 +359,20 @@ static int __maybe_unused mx51_ecspi_config(struct spi_imx_data *spi_imx, if (config->mode & SPI_CPHA) cfg |= MX51_ECSPI_CONFIG_SCLKPHA(config->cs); + else + cfg &= ~MX51_ECSPI_CONFIG_SCLKPHA(config->cs); if (config->mode & SPI_CPOL) { cfg |= MX51_ECSPI_CONFIG_SCLKPOL(config->cs); cfg |= MX51_ECSPI_CONFIG_SCLKCTL(config->cs); + } else { + cfg &= ~MX51_ECSPI_CONFIG_SCLKPOL(config->cs); + cfg &= ~MX51_ECSPI_CONFIG_SCLKCTL(config->cs); } if (config->mode & SPI_CS_HIGH) cfg |= MX51_ECSPI_CONFIG_SSBPOL(config->cs); + else + cfg &= ~MX51_ECSPI_CONFIG_SSBPOL(config->cs); if (spi_imx->usedma) ctrl |= MX51_ECSPI_CTRL_SMC;