Message ID | 20230715010407.1751715-7-fabrizio.castro.jz@renesas.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a6b2:0:b0:3e4:2afc:c1 with SMTP id c18csp2836861vqm; Fri, 14 Jul 2023 19:48:26 -0700 (PDT) X-Google-Smtp-Source: APBJJlFfyyiiIb/mJ+K89r6Tm74M6AWLU3wQ3xVdGRlfuAzOg72PcLbdiICARi5qA3pKmWox24aa X-Received: by 2002:a17:906:7482:b0:991:da66:e40b with SMTP id e2-20020a170906748200b00991da66e40bmr5850466ejl.13.1689389306451; Fri, 14 Jul 2023 19:48:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689389306; cv=none; d=google.com; s=arc-20160816; b=JiVvAS1Y+P1+Sxpp6emwLj3lFsIpuFGt0JwjrK+jUEdW4ify9dqxtS8P8PlcnNxdli uy7BirhUs+QPV8QzGtkSBzDu86yi0aEQ+fUbmeGshvc5gzg9Frhu+X46WiLxLJbXrJIv TY19bLvJwOKzGuEEKk+fk6ZuuuLydvacMXy+zIbQNVCSECwSkLzIol5LXAqUSK4h6gP4 BQq+54fBVHO9OqACDjj75tcgWie0ebyXhB0EIFtPZUflzUb+Ay94LibkTxhXDZEzBYdU RrV4cGHX6jaK6/vdWdI8N+h9ACJYxLCwiBe62hB+wYuoo4cF15f7+Y/lhovj51wufO5I jg3w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=QIrg7A20Rz1B8760wruwhlDpX5PdSOgkx1Yppzs/pcA=; fh=8SPOXdXcsbbrdLjCtKFrhdDDaSSTCLFzjvpt84tri9w=; b=oT2uAqHEjjS23Z4IOsMPxrSfrZLqabpI0TOrwDFHx5GEC8UCqPzX+38zudCdagGKN8 ZIVMgaZFZ1wvwMwtDfzaaQ3ZenJN4q8l3f/9AVhAGSkLnwJ14bkID05nf1X9r+F2fCTQ iwMqCZ3iOsfmkp8rkmXgc8TJ8fmNzDcUGvPI6XzMl5CiAlXhQdpWwx27VHyVUBjUVafd NCRZGrW5urUsQul1LunnI2lJVhX9kbNpr9kbZT7ry9LZAIvE2Yw7+TAL6pFaA5tRI4RA gv1y6CtDxL54CnAtUwFHmbOpt5X52eJUx76l5lmPEJS4Av1xdpHBaos9rk9lRKQYhi0/ rHtA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=renesas.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i5-20020a1709061cc500b0099396546ffesi9226627ejh.768.2023.07.14.19.48.03; Fri, 14 Jul 2023 19:48:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=renesas.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229666AbjGOBE4 (ORCPT <rfc822;hadasmailinglist@gmail.com> + 99 others); Fri, 14 Jul 2023 21:04:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39686 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229526AbjGOBEy (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 14 Jul 2023 21:04:54 -0400 Received: from relmlie5.idc.renesas.com (relmlor1.renesas.com [210.160.252.171]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id C2D2B3AA6; Fri, 14 Jul 2023 18:04:37 -0700 (PDT) X-IronPort-AV: E=Sophos;i="6.01,206,1684767600"; d="scan'208";a="169014747" Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie5.idc.renesas.com with ESMTP; 15 Jul 2023 10:04:36 +0900 Received: from mulinux.home (unknown [10.226.92.194]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id AFF4240C4DAF; Sat, 15 Jul 2023 10:04:33 +0900 (JST) From: Fabrizio Castro <fabrizio.castro.jz@renesas.com> To: Mark Brown <broonie@kernel.org>, Geert Uytterhoeven <geert+renesas@glider.be> Cc: Fabrizio Castro <fabrizio.castro.jz@renesas.com>, Andy Shevchenko <andy.shevchenko@gmail.com>, linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org, Chris Paterson <Chris.Paterson2@renesas.com>, Biju Das <biju.das@bp.renesas.com>, Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>, linux-renesas-soc@vger.kernel.org Subject: [PATCH 06/10] spi: rzv2m-csi: Squash timing settings into one statement Date: Sat, 15 Jul 2023 02:04:03 +0100 Message-Id: <20230715010407.1751715-7-fabrizio.castro.jz@renesas.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230715010407.1751715-1-fabrizio.castro.jz@renesas.com> References: <20230715010407.1751715-1-fabrizio.castro.jz@renesas.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771453081496128306 X-GMAIL-MSGID: 1771453081496128306 |
Series |
spi: rzv2m-csi: Code refactoring
|
|
Commit Message
Fabrizio Castro
July 15, 2023, 1:04 a.m. UTC
Register CLKSEL hosts the configuration for both clock polarity
and data phase, and both values can be set in one write operation.
Squash the clock polarity and data phase register writes into
one statement, for efficiency.
Signed-off-by: Fabrizio Castro <fabrizio.castro.jz@renesas.com>
---
drivers/spi/spi-rzv2m-csi.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
Comments
On Sat, Jul 15, 2023 at 4:04 AM Fabrizio Castro <fabrizio.castro.jz@renesas.com> wrote: > > Register CLKSEL hosts the configuration for both clock polarity > and data phase, and both values can be set in one write operation. > > Squash the clock polarity and data phase register writes into > one statement, for efficiency. ... > /* Setup clock polarity and phase timing */ > - rzv2m_csi_reg_write_bit(csi, CSI_CLKSEL, CSI_CLKSEL_CKP, > - !(spi->mode & SPI_CPOL)); > - rzv2m_csi_reg_write_bit(csi, CSI_CLKSEL, CSI_CLKSEL_DAP, > - !(spi->mode & SPI_CPHA)); > + rzv2m_csi_reg_write_bit(csi, CSI_CLKSEL, CSI_CLKSEL_MODE, > + ~spi->mode & SPI_MODE_X_MASK); I think this now regresses due to the absence of parentheses.
Hi Andy, Thanks for your reply. > From: Andy Shevchenko <andy.shevchenko@gmail.com> > Subject: Re: [PATCH 06/10] spi: rzv2m-csi: Squash timing settings into > one statement > > On Sat, Jul 15, 2023 at 4:04 AM Fabrizio Castro > <fabrizio.castro.jz@renesas.com> wrote: > > > > Register CLKSEL hosts the configuration for both clock polarity > > and data phase, and both values can be set in one write operation. > > > > Squash the clock polarity and data phase register writes into > > one statement, for efficiency. > > ... > > > /* Setup clock polarity and phase timing */ > > - rzv2m_csi_reg_write_bit(csi, CSI_CLKSEL, CSI_CLKSEL_CKP, > > - !(spi->mode & SPI_CPOL)); > > - rzv2m_csi_reg_write_bit(csi, CSI_CLKSEL, CSI_CLKSEL_DAP, > > - !(spi->mode & SPI_CPHA)); > > + rzv2m_csi_reg_write_bit(csi, CSI_CLKSEL, CSI_CLKSEL_MODE, > > + ~spi->mode & SPI_MODE_X_MASK); > > I think this now regresses due to the absence of parentheses. This looks okay to me. CSI_CLKSEL_CKP needs to contain the inverted value of SPI_CPOL, and CSI_CLKSEL_DAP needs to contain the inverted value of SPI_CPHA, and that happens with both use cases. Thanks, Fab > > -- > With Best Regards, > Andy Shevchenko
On Mon, Jul 17, 2023 at 1:44 PM Fabrizio Castro <fabrizio.castro.jz@renesas.com> wrote: > > From: Andy Shevchenko <andy.shevchenko@gmail.com> > > On Sat, Jul 15, 2023 at 4:04 AM Fabrizio Castro > > <fabrizio.castro.jz@renesas.com> wrote: ... > > > /* Setup clock polarity and phase timing */ > > > - rzv2m_csi_reg_write_bit(csi, CSI_CLKSEL, CSI_CLKSEL_CKP, > > > - !(spi->mode & SPI_CPOL)); > > > - rzv2m_csi_reg_write_bit(csi, CSI_CLKSEL, CSI_CLKSEL_DAP, > > > - !(spi->mode & SPI_CPHA)); > > > + rzv2m_csi_reg_write_bit(csi, CSI_CLKSEL, CSI_CLKSEL_MODE, > > > + ~spi->mode & SPI_MODE_X_MASK); > > > > I think this now regresses due to the absence of parentheses. > > This looks okay to me. CSI_CLKSEL_CKP needs to contain the inverted value > of SPI_CPOL, and CSI_CLKSEL_DAP needs to contain the inverted value of > SPI_CPHA, and that happens with both use cases. Ah, this is interchangeable since we will get the same bits in the end, indeed.
diff --git a/drivers/spi/spi-rzv2m-csi.c b/drivers/spi/spi-rzv2m-csi.c index 038f1486b7d7..faf5898bc3e0 100644 --- a/drivers/spi/spi-rzv2m-csi.c +++ b/drivers/spi/spi-rzv2m-csi.c @@ -38,6 +38,7 @@ /* CSI_CLKSEL */ #define CSI_CLKSEL_CKP BIT(17) #define CSI_CLKSEL_DAP BIT(16) +#define CSI_CLKSEL_MODE (CSI_CLKSEL_CKP|CSI_CLKSEL_DAP) #define CSI_CLKSEL_SLAVE BIT(15) #define CSI_CLKSEL_CKS GENMASK(14, 1) @@ -408,10 +409,8 @@ static int rzv2m_csi_setup(struct spi_device *spi) writel(CSI_MODE_SETUP, csi->base + CSI_MODE); /* Setup clock polarity and phase timing */ - rzv2m_csi_reg_write_bit(csi, CSI_CLKSEL, CSI_CLKSEL_CKP, - !(spi->mode & SPI_CPOL)); - rzv2m_csi_reg_write_bit(csi, CSI_CLKSEL, CSI_CLKSEL_DAP, - !(spi->mode & SPI_CPHA)); + rzv2m_csi_reg_write_bit(csi, CSI_CLKSEL, CSI_CLKSEL_MODE, + ~spi->mode & SPI_MODE_X_MASK); /* Setup serial data order */ rzv2m_csi_reg_write_bit(csi, CSI_MODE, CSI_MODE_DIR,