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: 8588371 Return-Path: X-Original-To: patchwork-linux-spi@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 05267C0553 for ; Tue, 15 Mar 2016 13:24:46 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 14841202AE for ; Tue, 15 Mar 2016 13:24:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id EA76E20272 for ; Tue, 15 Mar 2016 13:24:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933884AbcCONYn (ORCPT ); Tue, 15 Mar 2016 09:24:43 -0400 Received: from smtp6-v.fe.bosch.de ([139.15.237.11]:53702 "EHLO smtp6-v.fe.bosch.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932449AbcCONYm (ORCPT ); Tue, 15 Mar 2016 09:24:42 -0400 Received: from vsmta14.fe.internet.bosch.com (unknown [10.4.98.54]) by imta24.fe.bosch.de (Postfix) with ESMTP id 78B55D80204 for ; Tue, 15 Mar 2016 14:24:40 +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 FE-HUB1000.de.bosch.com (vsgw22.fe.internet.bosch.com [10.4.98.11]) by vsmta14.fe.internet.bosch.com (Postfix) with ESMTP id 1A45FA403EE for ; Tue, 15 Mar 2016 14:24:40 +0100 (CET) Received: from hi-z5661.hi.de.bosch.com (10.34.218.199) by FE-HUB1000.de.bosch.com (10.4.103.107) 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: CC: , Vladimir Zapolskiy , Sascha Hauer , Mark Brown , Knut Wohlrab , Dirk Behme 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== Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=unavailable 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;