From patchwork Sat Jul 15 01:03:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabrizio Castro X-Patchwork-Id: 120720 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a6b2:0:b0:3e4:2afc:c1 with SMTP id c18csp2836501vqm; Fri, 14 Jul 2023 19:46:55 -0700 (PDT) X-Google-Smtp-Source: APBJJlGjUBrWm6mN4QVTxy6bxLVI1ig6Ze+io0UnNmhRiIV60sQK2Ve7AuHtfLOO3NxPWTi94byU X-Received: by 2002:aa7:cf0f:0:b0:51a:5e8f:ac1 with SMTP id a15-20020aa7cf0f000000b0051a5e8f0ac1mr6437250edy.23.1689389214994; Fri, 14 Jul 2023 19:46:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689389214; cv=none; d=google.com; s=arc-20160816; b=LfecGWymkGeGrIfF2h3lNYsoFPP6BOnVcaLz/o8HtbVpbofUP3tfmO/RVst3C0bT31 /xx/Fap1gyGVC3y1iviBNQ6GUxhke9+N8/73dLcv6MNDhJzxWYvpX2cZCMdPPTGibO7G 8JJbIwxdqZO0IQrN8jmOcQlG+fhRO1jADIx5gxi2uGjLpewFSoyHE1rdZXyHczussCjd 6Q/6puiTVioWr3Kmk6JUyGo/y7+KqKf4tX5Kn0mIFGzjPEN5jiJL/P4FSOvueYUjzX7e bXFiz+04/IgGkMGRQRPmBbaHUvhFB1M/5IdFfmptZqp9rdg7OK8KuGNrwzZzWvKlPwTp hjwQ== 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=oT1gSvbqVo5qURZITwZMhVSFHDJ0vzwILLRGT3ztW+Q=; fh=8SPOXdXcsbbrdLjCtKFrhdDDaSSTCLFzjvpt84tri9w=; b=CCQ5jPQLyqaklb6V6jYskGfrSdHeMRZqFrtBwCRjZdQnm6IqDTatFWridT6WXG1O2J sFCdXmwGRQrPPLBmnSx13zs/tWGftLQkuiIre2yDt50ma3JYSt6pbaRond30TsCs+bQN Nzt+0oPev/VOG4o6+Y9AKTK7SpaqdhtFddtd4DhFNwm7mciVNUF7hzml1ABd6wx1VGdi nAI/KxCVLKuX1Vj03+RVMuqbndr/cbIfGhozfXrQUh3RoNafs01al5KpylWaFQVWpmoo qIhDz24ByS9L7jl3vADpD2uP5H0XnrkRBLyCYukSILCF6zv9tTefa8fxBxSMHevLoNqg YxpQ== 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 n19-20020aa7c693000000b0051e10991ea9si9539656edq.142.2023.07.14.19.46.31; Fri, 14 Jul 2023 19:46:54 -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 S230090AbjGOBEV (ORCPT + 99 others); Fri, 14 Jul 2023 21:04:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38872 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229526AbjGOBET (ORCPT ); Fri, 14 Jul 2023 21:04:19 -0400 Received: from relmlie5.idc.renesas.com (relmlor1.renesas.com [210.160.252.171]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id C04003A9C; Fri, 14 Jul 2023 18:04:18 -0700 (PDT) X-IronPort-AV: E=Sophos;i="6.01,206,1684767600"; d="scan'208";a="169014698" Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie5.idc.renesas.com with ESMTP; 15 Jul 2023 10:04:18 +0900 Received: from mulinux.home (unknown [10.226.92.194]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id 84DFC40A10D5; Sat, 15 Jul 2023 10:04:15 +0900 (JST) From: Fabrizio Castro To: Mark Brown , Geert Uytterhoeven Cc: Fabrizio Castro , Andy Shevchenko , linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org, Chris Paterson , Biju Das , Lad Prabhakar , linux-renesas-soc@vger.kernel.org Subject: [PATCH 01/10] spi: rzv2m-csi: Add missing include Date: Sat, 15 Jul 2023 02:03:58 +0100 Message-Id: <20230715010407.1751715-2-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 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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771452985460496738 X-GMAIL-MSGID: 1771452985460496738 Add missing include of bits.h file. Signed-off-by: Fabrizio Castro --- drivers/spi/spi-rzv2m-csi.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/spi/spi-rzv2m-csi.c b/drivers/spi/spi-rzv2m-csi.c index c0d9a776770f..b595f3b7294d 100644 --- a/drivers/spi/spi-rzv2m-csi.c +++ b/drivers/spi/spi-rzv2m-csi.c @@ -5,6 +5,7 @@ * Copyright (C) 2023 Renesas Electronics Corporation */ +#include #include #include #include From patchwork Sat Jul 15 01:03:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabrizio Castro X-Patchwork-Id: 120716 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a6b2:0:b0:3e4:2afc:c1 with SMTP id c18csp2815212vqm; Fri, 14 Jul 2023 18:05:45 -0700 (PDT) X-Google-Smtp-Source: APBJJlFAoaaRiNkulL9SZFOUhmGZ1GuZJs1y1rzBAja7arCXysNXlV6CAjNJIgOBiUmxaAwNhmlk X-Received: by 2002:a05:6a00:16c1:b0:668:9dca:13ac with SMTP id l1-20020a056a0016c100b006689dca13acmr7062258pfc.7.1689383145541; Fri, 14 Jul 2023 18:05:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689383145; cv=none; d=google.com; s=arc-20160816; b=InImUHJgA1B1ZI6T/p42MGTsuWI/xL6FpDx3ijjU+qfp8KyXJ6SrXsXg9nUAsxh+AI bGp0+JaEF+pF8wQPUxo2zAQTfrUMLSciRIqoQ/JvSR4POWJCcZhjsERg/OTrA5Uv538Y jMBYometeHKEB9QSBeQnquphVIcHDXikOkTKyrxjWqZwgnqcQOabY69qBYGXFZRsgyRL AOt/+ycKTMfKZ+M+fyvxcmlE/fa53GkwC/M/ke+WuvL4QIFTw6d7jN5PIvJeDM00sRRX VC1AjW+kfSEqcAcSKQGccAeqyxvP0r8dxbQ0y8JXHfBfR1yKfLGGHY6yZVCHDtc4S3/5 ugbA== 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=eI2bs8i6gBtkET+lLuxLm34o/EqIyASryS2F9XqcunY=; fh=8SPOXdXcsbbrdLjCtKFrhdDDaSSTCLFzjvpt84tri9w=; b=TXRRt6ztd1fL/nKLmoiPRZI5rlqDX75liBtAc0S7XGrEWlkQGdxsLivTNh6wm8kKMY XJufZhRbq+pK3fAHTIy/E8MPoxHJ7t3sCb+2Tq+dZeAXTjZtWnIuTeAZ0BCCrsSs/ayN Rtlk0ksUT34pSAd9ncFb5GSmM8ZWJlf19ZcpGpNcMawcZUkWAhWIaCesv/qEUSiuqEaA ULSjPu2zgzfQHTUDPNoLCvJSP40Ft5gUuD0CF4myeafdwOZ/TaAuSip2WbRAaiS5WsaS 805LZko/feHxDiMq+6mOjan518DkinDz0WfbIOL+U+8HeOejUcAIflyuPxbI3WI3P5o6 MCxQ== 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 m19-20020a056a00081300b00668873710d9si2721047pfk.162.2023.07.14.18.05.32; Fri, 14 Jul 2023 18:05:45 -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 S229636AbjGOBE2 (ORCPT + 99 others); Fri, 14 Jul 2023 21:04:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38936 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230156AbjGOBE0 (ORCPT ); Fri, 14 Jul 2023 21:04:26 -0400 Received: from relmlie6.idc.renesas.com (relmlor2.renesas.com [210.160.252.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 0866A3AA3; Fri, 14 Jul 2023 18:04:22 -0700 (PDT) X-IronPort-AV: E=Sophos;i="6.01,206,1684767600"; d="scan'208";a="172657788" Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie6.idc.renesas.com with ESMTP; 15 Jul 2023 10:04:22 +0900 Received: from mulinux.home (unknown [10.226.92.194]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id 2AAA140A10D5; Sat, 15 Jul 2023 10:04:18 +0900 (JST) From: Fabrizio Castro To: Mark Brown , Geert Uytterhoeven Cc: Fabrizio Castro , Andy Shevchenko , linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org, Chris Paterson , Biju Das , Lad Prabhakar , linux-renesas-soc@vger.kernel.org Subject: [PATCH 02/10] spi: rzv2m-csi: Adopt HZ_PER_MHZ for max spi clock Date: Sat, 15 Jul 2023 02:03:59 +0100 Message-Id: <20230715010407.1751715-3-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 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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771446621344091551 X-GMAIL-MSGID: 1771446621344091551 Make use of HZ_PER_MHZ for CSI_MAX_SPI_SCKO to make it clear what its value means. Signed-off-by: Fabrizio Castro Reviewed-by: Geert Uytterhoeven --- drivers/spi/spi-rzv2m-csi.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/spi/spi-rzv2m-csi.c b/drivers/spi/spi-rzv2m-csi.c index b595f3b7294d..3931045a85eb 100644 --- a/drivers/spi/spi-rzv2m-csi.c +++ b/drivers/spi/spi-rzv2m-csi.c @@ -13,6 +13,7 @@ #include #include #include +#include /* Registers */ #define CSI_MODE 0x00 /* CSI mode control */ @@ -71,7 +72,7 @@ #define TX_TIMEOUT_ERROR BIT(2) #define RX_TIMEOUT_ERROR BIT(3) -#define CSI_MAX_SPI_SCKO 8000000 +#define CSI_MAX_SPI_SCKO (8 * HZ_PER_MHZ) struct rzv2m_csi_priv { void __iomem *base; From patchwork Sat Jul 15 01:04:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabrizio Castro X-Patchwork-Id: 120724 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a6b2:0:b0:3e4:2afc:c1 with SMTP id c18csp2836813vqm; Fri, 14 Jul 2023 19:48:17 -0700 (PDT) X-Google-Smtp-Source: APBJJlGdnR5nGa7t/Ms86YeIZGdyFBwpQBFyCCSb4a7DWPHhMLTcjjao00A+V31eML3hm2v3Zisw X-Received: by 2002:a17:906:28a:b0:993:a37a:cb4c with SMTP id 10-20020a170906028a00b00993a37acb4cmr5787227ejf.9.1689389297096; Fri, 14 Jul 2023 19:48:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689389297; cv=none; d=google.com; s=arc-20160816; b=sY+UVcwPxw6jptXs5HpA9lNp9VbOiYyy0wJ2A40ELEcZF6cuoqfON2LPZQN+h0myDX 7nNcOcC68/siISDiqSddp8YWaXzoyOLWKLOGsy0yOFK/IlwAXvLnvRQ31K8jHLCH83sa KKXhS339oBIpVzHJcjQSst7cOBOVpEMAoMKtV/6OfC4fses0yqn4eXfWWnGyKwenpnCr XR9XI9nUgUKqCF2xcwguV7Up0FbcPHjo0VCQrHvoiNfLIk42FpH+obQdu6E+OJ0lfH5A GEp162c+nNNHfKN43Zx4ICG9MUc3vtMFdOq7wBZg90v72HytOz65H28HlzFgq/uGLea5 IKKA== 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=VDA9NpR+9Sg4wqsA/iVRiRDK6i8+5geo4C9KREefwqI=; fh=8SPOXdXcsbbrdLjCtKFrhdDDaSSTCLFzjvpt84tri9w=; b=tv0uVIKI5f7M2DBi+er0nhgifn6qdOvzbVdKSbsXT0/uSrdSfhAWy1cThOE94tM8Qv /7OytXznzw02L5YeIbHEYVu5NzhDX31mtni5s1Nzw59Kkgbh9tL5D1vGk6m353HqZVU4 c7o7fWbcUBTjxGFBpfFCoXVPFa6FxRmTMtcbijnlIRmyvE5aLSP4hIwm6m06Zzrn9wRb 16u/M5gioad0nbfMvhof/uoVokIwdTySkjuA/yfWoyY9O/v340y/W+IIN62onpU/u641 kYcHwVYoUFkLWxJXyGLeCiyi8zCQs6stFdP/+lwZsivgWjzOmxYyB4StSs7p2dw7FzB1 T3Qw== 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 u26-20020a1709064ada00b009924c43105csi9827143ejt.94.2023.07.14.19.47.54; Fri, 14 Jul 2023 19:48:17 -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 S230171AbjGOBEa (ORCPT + 99 others); Fri, 14 Jul 2023 21:04:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38946 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229719AbjGOBE1 (ORCPT ); Fri, 14 Jul 2023 21:04:27 -0400 Received: from relmlie6.idc.renesas.com (relmlor2.renesas.com [210.160.252.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 0C5373AAD; Fri, 14 Jul 2023 18:04:25 -0700 (PDT) X-IronPort-AV: E=Sophos;i="6.01,206,1684767600"; d="scan'208";a="172657800" Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie6.idc.renesas.com with ESMTP; 15 Jul 2023 10:04:25 +0900 Received: from mulinux.home (unknown [10.226.92.194]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id C4D6140C4DA2; Sat, 15 Jul 2023 10:04:22 +0900 (JST) From: Fabrizio Castro To: Mark Brown , Geert Uytterhoeven Cc: Fabrizio Castro , Andy Shevchenko , linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org, Chris Paterson , Biju Das , Lad Prabhakar , linux-renesas-soc@vger.kernel.org Subject: [PATCH 03/10] spi: rzv2m-csi: Rework CSI_CKS_MAX definition Date: Sat, 15 Jul 2023 02:04:00 +0100 Message-Id: <20230715010407.1751715-4-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 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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771453071538712325 X-GMAIL-MSGID: 1771453071538712325 Clock "csiclk" gets divided by 2 * CSI_CLKSEL_CKS in order to generate the serial clock (output from master), with CSI_CLKSEL_CKS ranging from 0x1 (that means "csiclk" is divided by 2) to 0x3FFF ("csiclk" is divided by 32766). CSI_CKS_MAX is used for referring to the setting corresponding to the maximum frequency divider. Value 0x3FFF for CSI_CKS_MAX doesn't really means much to the reader without an explanation and a more readable definition. Add a comment with a meaningful description and also replace value 0x3FFF with the corresponding GENMASK, to make it very clear what the macro means. Signed-off-by: Fabrizio Castro Reviewed-by: Geert Uytterhoeven --- drivers/spi/spi-rzv2m-csi.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/spi/spi-rzv2m-csi.c b/drivers/spi/spi-rzv2m-csi.c index 3931045a85eb..621774949bde 100644 --- a/drivers/spi/spi-rzv2m-csi.c +++ b/drivers/spi/spi-rzv2m-csi.c @@ -65,7 +65,12 @@ #define CSI_FIFO_SIZE_BYTES 32 #define CSI_FIFO_HALF_SIZE 16 #define CSI_EN_DIS_TIMEOUT_US 100 -#define CSI_CKS_MAX 0x3FFF +/* + * Clock "csiclk" gets divided by 2 * CSI_CLKSEL_CKS in order to generate the + * serial clock (output from master), with CSI_CLKSEL_CKS ranging from 0x1 (that + * means "csiclk" is divided by 2) to 0x3FFF ("csiclk" is divided by 32766). + */ +#define CSI_CKS_MAX GENMASK(13, 0) #define UNDERRUN_ERROR BIT(0) #define OVERFLOW_ERROR BIT(1) From patchwork Sat Jul 15 01:04:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabrizio Castro X-Patchwork-Id: 120719 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a6b2:0:b0:3e4:2afc:c1 with SMTP id c18csp2835871vqm; Fri, 14 Jul 2023 19:43:46 -0700 (PDT) X-Google-Smtp-Source: APBJJlH8H4QzCiRgtoa7BXCTZUxaWUjo1UiEHBfKdKFM7inrddgJ38/dBPrnAo1C2b9tZKBrtvgu X-Received: by 2002:a50:ed16:0:b0:51d:d41b:26a5 with SMTP id j22-20020a50ed16000000b0051dd41b26a5mr6373668eds.14.1689389026386; Fri, 14 Jul 2023 19:43:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689389026; cv=none; d=google.com; s=arc-20160816; b=t8eM71OxB1m0GBdEeFqW2OlAH7I3yzavFd77fKE3pYe0HqXRtN6dS6up2WOFKX+Uzr p9TgHiXFvTSyzakiyPl0XQkpMnrH2FJ53T1RoxuOXjf8GRW0+j7UO1QPAS/bPgVFLbwx yd/+neMOn8KjYEWE5GdVnsgr9he444G5Rq/vPdkiKh1npnsk3C4ZmZShlHaCo1Dg3+9q HAkwlDZu0e548mFEjbbOwsXoIkCb91mObbpBH+8Oid7CocSBTg9129ya8ZqqioONyN56 KSLyyYA5yYAyRCt42TyXv4JPBXgkHsnG95a3CBycoM1rpxhxnz7bVhC12wUbJ8FT2xzU D7AA== 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=yp+ETdNN2aAWyFDK3t0R4RWtFtgRgy2zVtOpW2ht8Ek=; fh=8SPOXdXcsbbrdLjCtKFrhdDDaSSTCLFzjvpt84tri9w=; b=yAZFtJGKk7HDouDF2CfDohccKgaR2EB9ohooE9Ylf5zN5Azmdxcw75go2VnEfkTDdb vJA/E8Cqmlaeo47+kbyLwJdypT3IVHPqSdHIf1i8FLD3ItyZipaCqNZIc3cAliq0haV4 X+06Ai7uvvBnrnpuv3iIqi+jxiLucbXIVPq+FMy8YisRj7nD7JmdqiQxle7mIAKESpuH smKqRJH8IiIg4dGpW9VdpdwMBHav2yGMsu1u0/sSyiaX1OOYmlIvXVhyJmqdKU6DckD+ p3oPrtyrKZFtEFIJMmfW2Xj7IRx6O7fHIOSyHoQwEgyouwl1t1qZV6jxterlJ9dvugsd jkrw== 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 k11-20020aa7d8cb000000b0051df47ad1f0si4116533eds.659.2023.07.14.19.43.15; Fri, 14 Jul 2023 19:43:46 -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 S229513AbjGOBEj (ORCPT + 99 others); Fri, 14 Jul 2023 21:04:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39202 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230408AbjGOBEg (ORCPT ); Fri, 14 Jul 2023 21:04:36 -0400 Received: from relmlie5.idc.renesas.com (relmlor1.renesas.com [210.160.252.171]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 108933AB7; Fri, 14 Jul 2023 18:04:29 -0700 (PDT) X-IronPort-AV: E=Sophos;i="6.01,206,1684767600"; d="scan'208";a="169014721" Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie5.idc.renesas.com with ESMTP; 15 Jul 2023 10:04:29 +0900 Received: from mulinux.home (unknown [10.226.92.194]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id 6D12240C4DAF; Sat, 15 Jul 2023 10:04:26 +0900 (JST) From: Fabrizio Castro To: Mark Brown , Geert Uytterhoeven Cc: Fabrizio Castro , Andy Shevchenko , linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org, Chris Paterson , Biju Das , Lad Prabhakar , linux-renesas-soc@vger.kernel.org Subject: [PATCH 04/10] spi: rzv2m-csi: Leave readl_poll_timeout calls for last Date: Sat, 15 Jul 2023 02:04:01 +0100 Message-Id: <20230715010407.1751715-5-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 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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771452787932847625 X-GMAIL-MSGID: 1771452787932847625 Both rzv2m_csi_sw_reset and rzv2m_csi_start_stop_operation call into readl_poll_timeout upon a certain condition, and return 0 otherwise. Flip the logic to improve readability. Signed-off-by: Fabrizio Castro Reviewed-by: Geert Uytterhoeven --- drivers/spi/spi-rzv2m-csi.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/drivers/spi/spi-rzv2m-csi.c b/drivers/spi/spi-rzv2m-csi.c index 621774949bde..1c65cd5f2039 100644 --- a/drivers/spi/spi-rzv2m-csi.c +++ b/drivers/spi/spi-rzv2m-csi.c @@ -131,13 +131,12 @@ static int rzv2m_csi_sw_reset(struct rzv2m_csi_priv *csi, int assert) rzv2m_csi_reg_write_bit(csi, CSI_CNT, CSI_CNT_CSIRST, assert); - if (assert) { - return readl_poll_timeout(csi->base + CSI_MODE, reg, - !(reg & CSI_MODE_CSOT), 0, - CSI_EN_DIS_TIMEOUT_US); - } + if (!assert) + return 0; - return 0; + return readl_poll_timeout(csi->base + CSI_MODE, reg, + !(reg & CSI_MODE_CSOT), 0, + CSI_EN_DIS_TIMEOUT_US); } static int rzv2m_csi_start_stop_operation(const struct rzv2m_csi_priv *csi, @@ -147,12 +146,12 @@ static int rzv2m_csi_start_stop_operation(const struct rzv2m_csi_priv *csi, rzv2m_csi_reg_write_bit(csi, CSI_MODE, CSI_MODE_CSIE, enable); - if (!enable && wait) - return readl_poll_timeout(csi->base + CSI_MODE, reg, - !(reg & CSI_MODE_CSOT), 0, - CSI_EN_DIS_TIMEOUT_US); + if (enable || !wait) + return 0; - return 0; + return readl_poll_timeout(csi->base + CSI_MODE, reg, + !(reg & CSI_MODE_CSOT), 0, + CSI_EN_DIS_TIMEOUT_US); } static int rzv2m_csi_fill_txfifo(struct rzv2m_csi_priv *csi) From patchwork Sat Jul 15 01:04:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabrizio Castro X-Patchwork-Id: 120722 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a6b2:0:b0:3e4:2afc:c1 with SMTP id c18csp2836523vqm; Fri, 14 Jul 2023 19:46:59 -0700 (PDT) X-Google-Smtp-Source: APBJJlGVmlTFWj3dHw1FdvxJoJP1pMbYl1bzFQSV+5LcTSC8Ayf+5riux4yvtlxMT4VEDgpris68 X-Received: by 2002:a17:906:9614:b0:993:f9d4:eaac with SMTP id s20-20020a170906961400b00993f9d4eaacmr5039327ejx.24.1689389219562; Fri, 14 Jul 2023 19:46:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689389219; cv=none; d=google.com; s=arc-20160816; b=c9/iXoeNo/eydq3T/Xu5vO+ZHgqH0tQZDvCXgR43PlpV/tRzNqXV+IFzQG/Fdc89mg Qdl9eGyefjHb8vzTbIbKfPLfxUdNMTq77mXBOBZbDZmUZgj0jy/kMQSVJ7ggWcvzoRMG bEOSpu4sMyITnVruZBsFvTqNQim1pDiOAn3TGdhxbYfF2CszfzupavN5GTWp2ddwUYAd 1FJqth0wMV83R0XoRFwSbjQe5qPWcof+N6N2U02aLzO1sXv1XtBkY9ROuBSgf6cVolao pjghUsi/vuUZx0BjRGTw46babdFQnCwcLWyW3OTqYj6i8yeklFkz9kv+F9EwwZp8tgGp BRXg== 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=fAtEu7Fuh9Zpf8JH8xxmJ+z5LjVk8hBYwmDaFinb864=; fh=8SPOXdXcsbbrdLjCtKFrhdDDaSSTCLFzjvpt84tri9w=; b=ZbXqlhrdVL7KvtcvIAd5WDP4vpAdSzNRZNmtZC5t/l3wODHSyCeWnHLBruouFL9OBP jVlBYRjRUhRLZQh2KIAnylJtar/E/9UT2rhSrw6h8x6+Kq1W7Zhaa5yDzvUUTGuGFArk FD+UWaHT2JcgpY4TxNYk7MqYQw9sU8f1xuC6P9EgVCmPL0DsX4zM+GPmJVz5TqvWaVKO ZGlOC462LEslzpDTzEgZP0Q6rHD7NakVoysBUtNIwk+DZF5qYCMXHLjc+RMZlFHDkmC5 q5G6sk3mQlGoHjMmRYX06XkfFTJcaV/SdWtWqIbO+NoJyM0PoK6ZjUO6CckGFoIQc+3F 8EMQ== 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 w10-20020a1709060a0a00b0099364d9f0e0si3091160ejf.540.2023.07.14.19.46.36; Fri, 14 Jul 2023 19:46:59 -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 S230029AbjGOBEp (ORCPT + 99 others); Fri, 14 Jul 2023 21:04:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39418 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229991AbjGOBEn (ORCPT ); Fri, 14 Jul 2023 21:04:43 -0400 Received: from relmlie6.idc.renesas.com (relmlor2.renesas.com [210.160.252.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 1B7963AAF; Fri, 14 Jul 2023 18:04:33 -0700 (PDT) X-IronPort-AV: E=Sophos;i="6.01,206,1684767600"; d="scan'208";a="172657821" Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie6.idc.renesas.com with ESMTP; 15 Jul 2023 10:04:33 +0900 Received: from mulinux.home (unknown [10.226.92.194]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id 14F9340C4DAF; Sat, 15 Jul 2023 10:04:29 +0900 (JST) From: Fabrizio Castro To: Mark Brown , Geert Uytterhoeven Cc: Fabrizio Castro , Andy Shevchenko , linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org, Chris Paterson , Biju Das , Lad Prabhakar , linux-renesas-soc@vger.kernel.org Subject: [PATCH 05/10] spi: rzv2m-csi: Replace unnecessary ternary operators Date: Sat, 15 Jul 2023 02:04:02 +0100 Message-Id: <20230715010407.1751715-6-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 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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771452990344911145 X-GMAIL-MSGID: 1771452990344911145 The ternary operators used to initialize tx_completed and rx_completed are not necessary, replace them with a better implementation. Signed-off-by: Fabrizio Castro Reviewed-by: Geert Uytterhoeven --- drivers/spi/spi-rzv2m-csi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/spi/spi-rzv2m-csi.c b/drivers/spi/spi-rzv2m-csi.c index 1c65cd5f2039..038f1486b7d7 100644 --- a/drivers/spi/spi-rzv2m-csi.c +++ b/drivers/spi/spi-rzv2m-csi.c @@ -439,8 +439,8 @@ static int rzv2m_csi_setup(struct spi_device *spi) static int rzv2m_csi_pio_transfer(struct rzv2m_csi_priv *csi) { - bool tx_completed = csi->txbuf ? false : true; - bool rx_completed = csi->rxbuf ? false : true; + bool tx_completed = !csi->txbuf; + bool rx_completed = !csi->rxbuf; int ret = 0; /* Make sure the TX FIFO is empty */ From patchwork Sat Jul 15 01:04:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabrizio Castro X-Patchwork-Id: 120725 Return-Path: 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 + 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 ); 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 To: Mark Brown , Geert Uytterhoeven Cc: Fabrizio Castro , Andy Shevchenko , linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org, Chris Paterson , Biju Das , Lad Prabhakar , 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 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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771453081496128306 X-GMAIL-MSGID: 1771453081496128306 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 --- drivers/spi/spi-rzv2m-csi.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) 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, From patchwork Sat Jul 15 01:04:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabrizio Castro X-Patchwork-Id: 120723 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a6b2:0:b0:3e4:2afc:c1 with SMTP id c18csp2836800vqm; Fri, 14 Jul 2023 19:48:15 -0700 (PDT) X-Google-Smtp-Source: APBJJlGnETKX3czNz6KDBhQ2oA1IdENiHTgunbzyWWMJmc2INv1Tpu2PsJM+9wHVr/hD55wtQLxl X-Received: by 2002:a2e:924b:0:b0:2b6:d326:156d with SMTP id v11-20020a2e924b000000b002b6d326156dmr5059959ljg.19.1689389294767; Fri, 14 Jul 2023 19:48:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689389294; cv=none; d=google.com; s=arc-20160816; b=t3ll+hgo7Dt5nY1ez/qxUXBeIM80rh3pFlH4Y6wLdcQTKpJBDEgIuasW2dGNFhhUs0 mcnLqT4MCZHothqBmTvGY1lLvgO97S1VOf0/5xyAWB0F5ctHShjU/7MMYyRz7p7fqSNs NtbQSTH2t2/LVdKxVXZpn11rrjMyAE1wvx2yKrJG2L2yG3GKiivMMHwD5BQzdu298NOl o0SAcrcUPKRwl0WnKEp7gPDiTuY/inWEP4bP8vGU0eOf7qEbsvv1N9gFcELpd3q7DVWb Kv2KP6KpCVNEQPRqI9Z3EF85nOK8xDkBr7STKek4rCSD9NwM8ya7LlNNHHSuL3opRXB6 bqGA== 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=oAk6hkdrBV9Bb/0GZTDXw88LMyiPxlb3FRPWnynrxl4=; fh=8SPOXdXcsbbrdLjCtKFrhdDDaSSTCLFzjvpt84tri9w=; b=YFPxvmYEClEfdX7hiDGSrV8R6sh8q1OsCarJFKbVilYl8+UU01ISFvf1a/PBztXbHD sO7nGyfh8vt4U6VuwIreG6OhffCgV1OZHJmhEW5XiF5K9BSz3NDP0hGm1OTXhLzuMBJs Zbtn8TYunIbbuJ2OOwlm7BIlCfC1QF6rUa67j2g4kZEsP/mMju1QiEsnSohRfKBKx887 RZJB/9mSes0qIElWBbpf6MlDjKdd5lZBs5m2VYlaDXlcSRQZESGUZ2DtVijmLLQjgb1t tPxFKVdipX4PxRsFVlHJiW7+L4GyWvp7sjjloTJKmPgNupgVfxH8FBGD2q79faa9Mk/A pWrw== 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 k11-20020aa7d8cb000000b0051df47ad1f0si4116533eds.659.2023.07.14.19.47.51; Fri, 14 Jul 2023 19:48:14 -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 S229745AbjGOBFI (ORCPT + 99 others); Fri, 14 Jul 2023 21:05:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39796 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229986AbjGOBE7 (ORCPT ); Fri, 14 Jul 2023 21:04:59 -0400 Received: from relmlie6.idc.renesas.com (relmlor2.renesas.com [210.160.252.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id A12933C18; Fri, 14 Jul 2023 18:04:40 -0700 (PDT) X-IronPort-AV: E=Sophos;i="6.01,206,1684767600"; d="scan'208";a="172657855" Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie6.idc.renesas.com with ESMTP; 15 Jul 2023 10:04:40 +0900 Received: from mulinux.home (unknown [10.226.92.194]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id 59A9C40C4DBE; Sat, 15 Jul 2023 10:04:37 +0900 (JST) From: Fabrizio Castro To: Mark Brown , Geert Uytterhoeven Cc: Fabrizio Castro , Andy Shevchenko , linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org, Chris Paterson , Biju Das , Lad Prabhakar , linux-renesas-soc@vger.kernel.org Subject: [PATCH 07/10] spi: rzv2m-csi: Switch to using {read,write}s{b,w} Date: Sat, 15 Jul 2023 02:04:04 +0100 Message-Id: <20230715010407.1751715-8-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 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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771453069155482088 X-GMAIL-MSGID: 1771453069155482088 The RX/TX FIFOs implemented by the CSI IP are accessed by repeatedly reading/writing the same memory address, and therefore they are the ideal candidate for {read,write}s{b,w}. The RZ/V2M CSI driver currently implements loops to fill up the TX FIFO and empty the RX FIFO, differentiating between 8-bit and 16-bit word size. Switch to using {read,write}s{b,w} to get rid of the bespoke loops. Signed-off-by: Fabrizio Castro --- drivers/spi/spi-rzv2m-csi.c | 42 +++++++++++++------------------------ 1 file changed, 14 insertions(+), 28 deletions(-) diff --git a/drivers/spi/spi-rzv2m-csi.c b/drivers/spi/spi-rzv2m-csi.c index faf5898bc3e0..d0d6b183ffaf 100644 --- a/drivers/spi/spi-rzv2m-csi.c +++ b/drivers/spi/spi-rzv2m-csi.c @@ -86,8 +86,8 @@ struct rzv2m_csi_priv { struct clk *pclk; struct device *dev; struct spi_controller *controller; - const u8 *txbuf; - u8 *rxbuf; + const void *txbuf; + void *rxbuf; int buffer_len; int bytes_sent; int bytes_received; @@ -157,22 +157,15 @@ static int rzv2m_csi_start_stop_operation(const struct rzv2m_csi_priv *csi, static int rzv2m_csi_fill_txfifo(struct rzv2m_csi_priv *csi) { - int i; - if (readl(csi->base + CSI_OFIFOL)) return -EIO; - if (csi->bytes_per_word == 2) { - u16 *buf = (u16 *)csi->txbuf; - - for (i = 0; i < csi->words_to_transfer; i++) - writel(buf[i], csi->base + CSI_OFIFO); - } else { - u8 *buf = (u8 *)csi->txbuf; - - for (i = 0; i < csi->words_to_transfer; i++) - writel(buf[i], csi->base + CSI_OFIFO); - } + if (csi->bytes_per_word == 2) + writesw(csi->base + CSI_OFIFO, csi->txbuf, + csi->words_to_transfer); + else + writesb(csi->base + CSI_OFIFO, csi->txbuf, + csi->words_to_transfer); csi->txbuf += csi->bytes_to_transfer; csi->bytes_sent += csi->bytes_to_transfer; @@ -182,22 +175,15 @@ static int rzv2m_csi_fill_txfifo(struct rzv2m_csi_priv *csi) static int rzv2m_csi_read_rxfifo(struct rzv2m_csi_priv *csi) { - int i; - if (readl(csi->base + CSI_IFIFOL) != csi->bytes_to_transfer) return -EIO; - if (csi->bytes_per_word == 2) { - u16 *buf = (u16 *)csi->rxbuf; - - for (i = 0; i < csi->words_to_transfer; i++) - buf[i] = (u16)readl(csi->base + CSI_IFIFO); - } else { - u8 *buf = (u8 *)csi->rxbuf; - - for (i = 0; i < csi->words_to_transfer; i++) - buf[i] = (u8)readl(csi->base + CSI_IFIFO); - } + if (csi->bytes_per_word == 2) + readsw(csi->base + CSI_IFIFO, csi->rxbuf, + csi->words_to_transfer); + else + readsb(csi->base + CSI_IFIFO, csi->rxbuf, + csi->words_to_transfer); csi->rxbuf += csi->bytes_to_transfer; csi->bytes_received += csi->bytes_to_transfer; From patchwork Sat Jul 15 01:04:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabrizio Castro X-Patchwork-Id: 120718 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a6b2:0:b0:3e4:2afc:c1 with SMTP id c18csp2827551vqm; Fri, 14 Jul 2023 19:03:44 -0700 (PDT) X-Google-Smtp-Source: APBJJlHUTm/wNpznTygl2lbkus8NXzU/XWoQmdbHwCVMBVtT9otoNtACdT3vwcG55H/rHfQE265T X-Received: by 2002:aa7:cf0f:0:b0:51a:5e8f:ac1 with SMTP id a15-20020aa7cf0f000000b0051a5e8f0ac1mr6393296edy.23.1689386624554; Fri, 14 Jul 2023 19:03:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689386624; cv=none; d=google.com; s=arc-20160816; b=Fz9scw238jJS/BETJrj3GwE29Kqfc4ya3gpoYdEe+9Wk118Sd5v83Eg6XiDYh4yWj1 E5ML61c9N1sH+KV3cPjm/BLqJni/DKtJCwR+I09GVue9gAH9PH1bDcxSmKtI4ODKTedw U7izllrZU8lLa3sxK9c9+KGNA8ZUm5TeUXvZg6/oR45d51rB5liPwjXcFfEpy7r6/uV/ 8hibB9OW44q+cnHSlzGrK4Z9L/yXNGTLA4i6GCmT207dBAf93mH/py4UiagCqnz1nIys y0MKQoFfVEShyfuJ4eDv6aeI+d/q1Bf3aPLbibrxRMBBKbySRSCUIH6GaptwQ+B2zW5p /S3A== 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=yIGSqGMgumH78+oAvBhGL0Chn5SSJCinBN4HB7l1ENc=; fh=8SPOXdXcsbbrdLjCtKFrhdDDaSSTCLFzjvpt84tri9w=; b=NKIv6bU1cQNq23wRfxap4TOQ3O7pvzMMAABWiKOwc8w5OBHFfckiv/Kic1pjuWSDve MiiCwMqaDVWh41+VP1SmyvHhshnDExOQTqTbHgOfnfbPl0STluKk2zyOzftiy28A3+Zr 5aE1cpLY+G5gp/czyNN+csX7D0vsAX5J9EfqwjbmvcQkNnEzQAFU9glpEJTl+FHcbUur QgSX3qky/XJbA+anLHFeAZ5hx8Bxubc5TFX9yz/T0lsD2JmBZTGZVs4raDO3aNCBYMhw Fd6rvVV6OOAqCnc0QBlDaexyz+3Jcns9c0FDIN5bnrn3t/2jNtacSbuWUDcusx0qtoj7 +u8A== 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 t10-20020a05640203ca00b0051ff3df2c1dsi3531035edw.640.2023.07.14.19.03.05; Fri, 14 Jul 2023 19:03:44 -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 S230108AbjGOBFL (ORCPT + 99 others); Fri, 14 Jul 2023 21:05:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39922 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229526AbjGOBFF (ORCPT ); Fri, 14 Jul 2023 21:05:05 -0400 Received: from relmlie6.idc.renesas.com (relmlor2.renesas.com [210.160.252.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 4E4493C22; Fri, 14 Jul 2023 18:04:44 -0700 (PDT) X-IronPort-AV: E=Sophos;i="6.01,206,1684767600"; d="scan'208";a="172657866" Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie6.idc.renesas.com with ESMTP; 15 Jul 2023 10:04:44 +0900 Received: from mulinux.home (unknown [10.226.92.194]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id F419B40C4DAF; Sat, 15 Jul 2023 10:04:40 +0900 (JST) From: Fabrizio Castro To: Mark Brown , Geert Uytterhoeven Cc: Fabrizio Castro , Andy Shevchenko , linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org, Chris Paterson , Biju Das , Lad Prabhakar , linux-renesas-soc@vger.kernel.org Subject: [PATCH 08/10] spi: rzv2m-csi: Improve data types and alignment Date: Sat, 15 Jul 2023 02:04:05 +0100 Message-Id: <20230715010407.1751715-9-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 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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771450269213295161 X-GMAIL-MSGID: 1771450269213295161 "unsigned int" is more appropriate than "int" for the members of "struct rzv2m_csi_priv". Also, members "bytes_per_word" and "errors" introduce gaps in the structure. Adjust "struct rzv2m_csi_priv" and its members usage accordingly. While at it, remove the unnecessary casting of "data" to "struct rzv2m_csi_priv*" in function "rzv2m_csi_irq_handler". Signed-off-by: Fabrizio Castro Reviewed-by: Geert Uytterhoeven --- drivers/spi/spi-rzv2m-csi.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/drivers/spi/spi-rzv2m-csi.c b/drivers/spi/spi-rzv2m-csi.c index d0d6b183ffaf..1e5ed1089f42 100644 --- a/drivers/spi/spi-rzv2m-csi.c +++ b/drivers/spi/spi-rzv2m-csi.c @@ -63,8 +63,8 @@ /* CSI_FIFOTRG */ #define CSI_FIFOTRG_R_TRG GENMASK(2, 0) -#define CSI_FIFO_SIZE_BYTES 32 -#define CSI_FIFO_HALF_SIZE 16 +#define CSI_FIFO_SIZE_BYTES 32U +#define CSI_FIFO_HALF_SIZE 16U #define CSI_EN_DIS_TIMEOUT_US 100 /* * Clock "csiclk" gets divided by 2 * CSI_CLKSEL_CKS in order to generate the @@ -88,14 +88,14 @@ struct rzv2m_csi_priv { struct spi_controller *controller; const void *txbuf; void *rxbuf; - int buffer_len; - int bytes_sent; - int bytes_received; - int bytes_to_transfer; - int words_to_transfer; - unsigned char bytes_per_word; + unsigned int buffer_len; + unsigned int bytes_sent; + unsigned int bytes_received; + unsigned int bytes_to_transfer; + unsigned int words_to_transfer; + unsigned int bytes_per_word; wait_queue_head_t wait; - u8 errors; + u32 errors; u32 status; }; @@ -193,9 +193,9 @@ static int rzv2m_csi_read_rxfifo(struct rzv2m_csi_priv *csi) static inline void rzv2m_csi_calc_current_transfer(struct rzv2m_csi_priv *csi) { - int bytes_transferred = max_t(int, csi->bytes_received, csi->bytes_sent); - int bytes_remaining = csi->buffer_len - bytes_transferred; - int to_transfer; + unsigned int bytes_transferred = max(csi->bytes_received, csi->bytes_sent); + unsigned int bytes_remaining = csi->buffer_len - bytes_transferred; + unsigned int to_transfer; if (csi->txbuf) /* @@ -203,9 +203,9 @@ static inline void rzv2m_csi_calc_current_transfer(struct rzv2m_csi_priv *csi) * hard to raise an overflow error (which is only possible * when IP transmits and receives at the same time). */ - to_transfer = min_t(int, CSI_FIFO_HALF_SIZE, bytes_remaining); + to_transfer = min(CSI_FIFO_HALF_SIZE, bytes_remaining); else - to_transfer = min_t(int, CSI_FIFO_SIZE_BYTES, bytes_remaining); + to_transfer = min(CSI_FIFO_SIZE_BYTES, bytes_remaining); if (csi->bytes_per_word == 2) to_transfer >>= 1; @@ -325,7 +325,7 @@ static inline int rzv2m_csi_wait_for_rx_ready(struct rzv2m_csi_priv *csi) static irqreturn_t rzv2m_csi_irq_handler(int irq, void *data) { - struct rzv2m_csi_priv *csi = (struct rzv2m_csi_priv *)data; + struct rzv2m_csi_priv *csi = data; csi->status = readl(csi->base + CSI_INT); rzv2m_csi_disable_irqs(csi, csi->status); From patchwork Sat Jul 15 01:04:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabrizio Castro X-Patchwork-Id: 120726 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a6b2:0:b0:3e4:2afc:c1 with SMTP id c18csp2836870vqm; Fri, 14 Jul 2023 19:48:28 -0700 (PDT) X-Google-Smtp-Source: APBJJlEb4G8bYesV09Xyd7B1gvX5ZIeXdftkrkNRGavt9QIu8WyJf91HG4cjWI9xC7MPsf3XlX79 X-Received: by 2002:a17:907:900e:b0:982:bbc7:15c0 with SMTP id ay14-20020a170907900e00b00982bbc715c0mr4821644ejc.66.1689389308269; Fri, 14 Jul 2023 19:48:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689389308; cv=none; d=google.com; s=arc-20160816; b=ddrRTXROwScPOJEMM+MN1Zw1SEydvXvbPvMq8j+lur1mHik4in1hW1TDQAM2eMs7bK gcF2nZqpslMuCS9sVT0gmAObvzYlPcfY76Bjktzm20AOm7hEon03cIEJSowsgdBnv+I8 G+BKXPoCy5lgXnjA3aQWwlNM2VX8tdBu9LlCn8Ruclk0O9viCOvX2fYInF1dRKBHAQg9 8M76KBWHovMY87j1LVzWqrUkIcAiWyTqDCHzHWgiGMWyVVVhvPn+ZZRVIj8mwBvWEEFQ CJ0GSLkp6Mh10y6OFXpMsJEgx9NNm2KaRU4QdC9s5/T5sUdVcsQWTaPJdn8Z6+nRltIM Ks6A== 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=HL+D4nQeb+xia0gyg0Jdz6AiVpSz2jaeXqr0qVO/GYE=; fh=8SPOXdXcsbbrdLjCtKFrhdDDaSSTCLFzjvpt84tri9w=; b=0K7u0iVDxTeIGW03PuuzZPjJ/rSX+5JkekrfcZchoPDwxGAGOkSeJwtIsXoNDZxVNs EYa3Z0WfkYLyp+Z4ylgCiPK/jgSJ84aceKUq3DBRm6ca3/Eix4Cs/vbeagyJ0uqT/lMQ 36DC9lGhX3q4kVgbauo5xNnbhu9B7CP/jtKfPmXQaUwxMbVSYq/aijstFWiGaI9O+Dzf nZNyXHLzyagNdJ11WiaFYDxwDMOijBfqCCkcc3vAvul/KXvmoYBHg0fymmsdsdPUecYs Gk9jgrMpYE4angVgNYqt9l67mL3xdaQrhFr0kHULteGHFOM0exs6YiYSyT/qFppRow4s 5YGg== 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 i20-20020a170906115400b00992acfbcee1si9489286eja.851.2023.07.14.19.48.05; Fri, 14 Jul 2023 19:48:28 -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 S229821AbjGOBFW (ORCPT + 99 others); Fri, 14 Jul 2023 21:05:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39916 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229506AbjGOBFS (ORCPT ); Fri, 14 Jul 2023 21:05:18 -0400 Received: from relmlie6.idc.renesas.com (relmlor2.renesas.com [210.160.252.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 53DA43C3F; Fri, 14 Jul 2023 18:04:55 -0700 (PDT) X-IronPort-AV: E=Sophos;i="6.01,206,1684767600"; d="scan'208";a="172657879" Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie6.idc.renesas.com with ESMTP; 15 Jul 2023 10:04:47 +0900 Received: from mulinux.home (unknown [10.226.92.194]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id 9AA9B40C4DAF; Sat, 15 Jul 2023 10:04:44 +0900 (JST) From: Fabrizio Castro To: Mark Brown , Geert Uytterhoeven Cc: Fabrizio Castro , Andy Shevchenko , linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org, Chris Paterson , Biju Das , Lad Prabhakar , linux-renesas-soc@vger.kernel.org Subject: [PATCH 09/10] spi: rzv2m-csi: Get rid of the x_trg{_words} tables Date: Sat, 15 Jul 2023 02:04:06 +0100 Message-Id: <20230715010407.1751715-10-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 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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771453083006673363 X-GMAIL-MSGID: 1771453083006673363 Table x_trg can be replaced with ilog2(), and table x_trg_words can be replaced with rounddown_pow_of_two(). Replace the tables usage with the corresponding macros. While at it, remove a couple of unnecessary empty lines. Signed-off-by: Fabrizio Castro Reviewed-by: Geert Uytterhoeven --- drivers/spi/spi-rzv2m-csi.c | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-) diff --git a/drivers/spi/spi-rzv2m-csi.c b/drivers/spi/spi-rzv2m-csi.c index 1e5ed1089f42..1874ca1c2747 100644 --- a/drivers/spi/spi-rzv2m-csi.c +++ b/drivers/spi/spi-rzv2m-csi.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -99,20 +100,6 @@ struct rzv2m_csi_priv { u32 status; }; -static const unsigned char x_trg[] = { - 0, 1, 1, 2, 2, 2, 2, 3, - 3, 3, 3, 3, 3, 3, 3, 4, - 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 5 -}; - -static const unsigned char x_trg_words[] = { - 1, 2, 2, 4, 4, 4, 4, 8, - 8, 8, 8, 8, 8, 8, 8, 16, - 16, 16, 16, 16, 16, 16, 16, 16, - 16, 16, 16, 16, 16, 16, 16, 32 -}; - static void rzv2m_csi_reg_write_bit(const struct rzv2m_csi_priv *csi, int reg_offs, int bit_mask, u32 value) { @@ -216,7 +203,7 @@ static inline void rzv2m_csi_calc_current_transfer(struct rzv2m_csi_priv *csi) * less than or equal to the number of bytes we need to transfer. * This may result in multiple smaller transfers. */ - csi->words_to_transfer = x_trg_words[to_transfer - 1]; + csi->words_to_transfer = rounddown_pow_of_two(to_transfer); if (csi->bytes_per_word == 2) csi->bytes_to_transfer = csi->words_to_transfer << 1; @@ -227,7 +214,7 @@ static inline void rzv2m_csi_calc_current_transfer(struct rzv2m_csi_priv *csi) static inline void rzv2m_csi_set_rx_fifo_trigger_level(struct rzv2m_csi_priv *csi) { rzv2m_csi_reg_write_bit(csi, CSI_FIFOTRG, CSI_FIFOTRG_R_TRG, - x_trg[csi->words_to_transfer - 1]); + ilog2(csi->words_to_transfer)); } static inline void rzv2m_csi_enable_rx_trigger(struct rzv2m_csi_priv *csi, @@ -300,7 +287,6 @@ static int rzv2m_csi_wait_for_tx_empty(struct rzv2m_csi_priv *csi) return 0; ret = rzv2m_csi_wait_for_interrupt(csi, CSI_INT_TREND, CSI_CNT_TREND_E); - if (ret == -ETIMEDOUT) csi->errors |= TX_TIMEOUT_ERROR; @@ -316,7 +302,6 @@ static inline int rzv2m_csi_wait_for_rx_ready(struct rzv2m_csi_priv *csi) ret = rzv2m_csi_wait_for_interrupt(csi, CSI_INT_R_TRGR, CSI_CNT_R_TRGR_E); - if (ret == -ETIMEDOUT) csi->errors |= RX_TIMEOUT_ERROR; From patchwork Sat Jul 15 01:04:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabrizio Castro X-Patchwork-Id: 120721 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a6b2:0:b0:3e4:2afc:c1 with SMTP id c18csp2836522vqm; Fri, 14 Jul 2023 19:46:59 -0700 (PDT) X-Google-Smtp-Source: APBJJlEaclLU95yuuE8GItR8M90+vmmNrTpk7j9IGSRpJ1pHOh7WCEjXw0xWhsmkdXxjur9fs5MF X-Received: by 2002:a05:6512:21a6:b0:4f9:5ca5:f1a6 with SMTP id c6-20020a05651221a600b004f95ca5f1a6mr4069157lft.17.1689389219248; Fri, 14 Jul 2023 19:46:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689389219; cv=none; d=google.com; s=arc-20160816; b=OrZr+32mXrXGM+ZLgV84T+RX+YFfc/3wovPtCWSWZOSguL5OOOruW6np42L9MXnT25 me/R4PjdX+qICLScpTMCU49wTOuzjsTY/HV8HF9XfJVtGOMBTf+b16j/HsvFaYtk8GMd 2ShZyLU9CmBAxEXSMom2p33Y1SZKkAu44DXkiHUOL2ASFh/9SdIz9pejaxz4Ea12WIk+ BaMt5589RDHspce00Z5zShgxAMRkXP0D6P8JYECm9ygStGp8jlKn5DHk7ZPPgrUnpm/v +7ClWoGIJUVETGXEQ4qRt65rFFyQVu88nPC7pY2/fAp0dApEcZ5jbMW7Yqir7Bq4FVZO JFtA== 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=Ygwk/hO2kVASU6NwotXf52E1DjnMEsnx4qkxFQb2zps=; fh=8SPOXdXcsbbrdLjCtKFrhdDDaSSTCLFzjvpt84tri9w=; b=p0w7qRGPGnGWPXwLE4IMjhi8aifxB22z7/GezKkkVCEH4yKFEjrZPJouJYCZzD3pUE vS26jVJwHDUSWtQYdzkZp/0Kg2EIqnCUf2dUpNamDPRTUozMb7jJyua0l+O6i8czTR3u puDILOVS8h1MbWLJ4FDTGNwvw5eF6ZAWzcF0lF9yd1eIpwspbWRqzKnEPWyeW5GLypni Dh4wXZfhSWnMqbyqChbLgnZb+nF/9IRmkT44XbZ3B6+9mwtfVBdxIcwCkA6yb51E4/ts wEFBh1WfGAXtTI6OvgUZN/MjHSkXGKkQLTELt72DBHQjEUQ8rFYtslHdAX5cYa8eseAH CdGA== 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 c20-20020aa7df14000000b0051e0f286ebasi9599198edy.491.2023.07.14.19.46.35; Fri, 14 Jul 2023 19:46:59 -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 S229506AbjGOBFu (ORCPT + 99 others); Fri, 14 Jul 2023 21:05:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40652 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229526AbjGOBFo (ORCPT ); Fri, 14 Jul 2023 21:05:44 -0400 Received: from relmlie6.idc.renesas.com (relmlor2.renesas.com [210.160.252.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 5335D3AA9; Fri, 14 Jul 2023 18:05:18 -0700 (PDT) X-IronPort-AV: E=Sophos;i="6.01,206,1684767600"; d="scan'208";a="172657895" Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie6.idc.renesas.com with ESMTP; 15 Jul 2023 10:04:51 +0900 Received: from mulinux.home (unknown [10.226.92.194]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id 4445740C4DAF; Sat, 15 Jul 2023 10:04:48 +0900 (JST) From: Fabrizio Castro To: Mark Brown , Geert Uytterhoeven Cc: Fabrizio Castro , Andy Shevchenko , linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org, Chris Paterson , Biju Das , Lad Prabhakar , linux-renesas-soc@vger.kernel.org Subject: [PATCH 10/10] spi: rzv2m-csi: Make use of device_set_node Date: Sat, 15 Jul 2023 02:04:07 +0100 Message-Id: <20230715010407.1751715-11-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 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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771452989987139112 X-GMAIL-MSGID: 1771452989987139112 Use device_set_node instead of assigning controller->dev.of_node directly. Signed-off-by: Fabrizio Castro --- drivers/spi/spi-rzv2m-csi.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/spi/spi-rzv2m-csi.c b/drivers/spi/spi-rzv2m-csi.c index 1874ca1c2747..ad7ca514eb09 100644 --- a/drivers/spi/spi-rzv2m-csi.c +++ b/drivers/spi/spi-rzv2m-csi.c @@ -575,12 +575,13 @@ static int rzv2m_csi_probe(struct platform_device *pdev) init_waitqueue_head(&csi->wait); controller->mode_bits = SPI_CPOL | SPI_CPHA | SPI_LSB_FIRST; - controller->dev.of_node = pdev->dev.of_node; controller->bits_per_word_mask = SPI_BPW_MASK(16) | SPI_BPW_MASK(8); controller->setup = rzv2m_csi_setup; controller->transfer_one = rzv2m_csi_transfer_one; controller->use_gpio_descriptors = true; + device_set_node(&controller->dev, dev_fwnode(dev)); + ret = devm_request_irq(dev, irq, rzv2m_csi_irq_handler, 0, dev_name(dev), csi); if (ret)