From patchwork Wed May 24 09:19:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Boerge Struempfel X-Patchwork-Id: 685587 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7235BC77B7A for ; Wed, 24 May 2023 09:20:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240637AbjEXJU5 (ORCPT ); Wed, 24 May 2023 05:20:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44792 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240630AbjEXJU4 (ORCPT ); Wed, 24 May 2023 05:20:56 -0400 Received: from mail-ej1-x62a.google.com (mail-ej1-x62a.google.com [IPv6:2a00:1450:4864:20::62a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B4F63132; Wed, 24 May 2023 02:20:50 -0700 (PDT) Received: by mail-ej1-x62a.google.com with SMTP id a640c23a62f3a-96f50e26b8bso106613766b.2; Wed, 24 May 2023 02:20:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1684920049; x=1687512049; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=5HSi9nI0Vdoo7olldvTKRpyWvo8hGHic3PEr2+B6W30=; b=mvpiWeCm5PWLRuR8ZVPFkuCwRwM2ADb4HlrCe9mCtdkeEdjGhr7lpteWYLy/Idm+uG 4WZBbBvxVKjXnffbpqJ0PZnY8kXj1ekE8TzwUXA+inB6cAnHxFTYwH+rRGfBrkrRb6C5 suycniREcCSRBAryOgFmajKBrwIzcrI7yiV0jznHDWmKJKo430KCld3usGdCxo7ARbFU NbGPfAAF/CLznVS98S/4Z0rVSTmLJC0j/hFPawOCaTLAMkDfry3SkUs0IRNqLjCUGwrZ CoKbo6zCBSIaJ/hIcalP/FCe5+jYc3LqCZ2tWR1DR7gGWHnKrsSuz8BWXY7tM/BbCZ9J Jg4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684920049; x=1687512049; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=5HSi9nI0Vdoo7olldvTKRpyWvo8hGHic3PEr2+B6W30=; b=Kvt4OTq3ZhPsqPtBK8V8nQ6Z2dC6Sj2BcRwB17KuiGGq2g37lVkQY8gJcLUV82DvdO olmcv4iQ7AbnHKwAlGCT/GsZIcQtfGkjeZZ3bcCoFR2Vpnta/xQz2KqiTw7ZxOeIQ3J5 5YfkMENc8ASWbNBTvFAHNQCKRz9jO7jyxpZzoPhDH0IAjQdRt7bJUY4HT5c6YV1BatOb mSMlqEOflFyMHOtkqhD7cMHMj+C2nfEJlIMHmsvyONgaiN5joUs0VgRpsJGxok1y7ayz 3s7mcRC9FT0u+6/505FIJ87Mgy4yjdxe24QLYBNNZLkKRJHUc5TkRfDJ7tYmD95qN9HQ Y+8A== X-Gm-Message-State: AC+VfDzjU2RBVh4J1mNnZt3+RgPUd/M9K9ErnpogsuDBxEuQRp3HQW5+ Wl7GH8zIpzR5ODzwheodKPE= X-Google-Smtp-Source: ACHHUZ4U/jA+zgcfnilFF7yu0vKhbCwB0As2RQWv0J1VRkwy8P5PS8onhZ6aufK7zvFCMwzgk0l4/w== X-Received: by 2002:a17:907:9411:b0:94e:d951:d4e7 with SMTP id dk17-20020a170907941100b0094ed951d4e7mr15853132ejc.59.1684920048959; Wed, 24 May 2023 02:20:48 -0700 (PDT) Received: from wslxew193.ultratronik.de (p200300c78700c900fd67df8b3b199594.dip0.t-ipconnect.de. [2003:c7:8700:c900:fd67:df8b:3b19:9594]) by smtp.gmail.com with ESMTPSA id jy22-20020a170907763600b0096fbc516a93sm4579527ejc.211.2023.05.24.02.20.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 May 2023 02:20:48 -0700 (PDT) From: Boerge Struempfel Cc: boerge.struempfel@gmail.com, bstruempfel@ultratronik.de, andy.shevchenko@gmail.com, festevam@gmail.com, amit.kumar-mahapatra@amd.com, broonie@kernel.org, Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , NXP Linux Team , linux-spi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v6 1/5] spi: add SPI_MOSI_IDLE_LOW mode bit Date: Wed, 24 May 2023 11:19:44 +0200 Message-Id: <20230524091948.41779-2-boerge.struempfel@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230524091948.41779-1-boerge.struempfel@gmail.com> References: <20230524091948.41779-1-boerge.struempfel@gmail.com> MIME-Version: 1.0 To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org Some spi controller switch the mosi line to high, whenever they are idle. This may not be desired in all use cases. For example neopixel leds can get confused and flicker due to misinterpreting the idle state. Therefore, we introduce a new spi-mode bit, with which the idle behaviour can be overwritten on a per device basis. Signed-off-by: Boerge Struempfel --- include/uapi/linux/spi/spi.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/uapi/linux/spi/spi.h b/include/uapi/linux/spi/spi.h index 9d5f58059703..ca56e477d161 100644 --- a/include/uapi/linux/spi/spi.h +++ b/include/uapi/linux/spi/spi.h @@ -28,6 +28,7 @@ #define SPI_RX_OCTAL _BITUL(14) /* receive with 8 wires */ #define SPI_3WIRE_HIZ _BITUL(15) /* high impedance turnaround */ #define SPI_RX_CPHA_FLIP _BITUL(16) /* flip CPHA on Rx only xfer */ +#define SPI_MOSI_IDLE_LOW _BITUL(17) /* leave mosi line low when idle */ /* * All the bits defined above should be covered by SPI_MODE_USER_MASK. @@ -37,6 +38,6 @@ * These bits must not overlap. A static assert check should make sure of that. * If adding extra bits, make sure to increase the bit index below as well. */ -#define SPI_MODE_USER_MASK (_BITUL(17) - 1) +#define SPI_MODE_USER_MASK (_BITUL(18) - 1) #endif /* _UAPI_SPI_H */ From patchwork Wed May 24 09:19:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Boerge Struempfel X-Patchwork-Id: 685882 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B62E0C7EE31 for ; Wed, 24 May 2023 09:20:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240639AbjEXJU7 (ORCPT ); Wed, 24 May 2023 05:20:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44828 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240636AbjEXJU5 (ORCPT ); Wed, 24 May 2023 05:20:57 -0400 Received: from mail-ed1-x535.google.com (mail-ed1-x535.google.com [IPv6:2a00:1450:4864:20::535]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1D1E0FC; Wed, 24 May 2023 02:20:52 -0700 (PDT) Received: by mail-ed1-x535.google.com with SMTP id 4fb4d7f45d1cf-510b7b6ef59so1689625a12.3; Wed, 24 May 2023 02:20:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1684920050; x=1687512050; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=8/xRPtd2AmjbmXpgou4sQlZTgH09nz9cR2dZE8lQL3E=; b=PPtskXMBVcYltGkT+VrqN9E+v3cEyV6+544dMX+xoe1iClmJetzSs7Bs6ON/ySpouZ NCeMuYoojyfioAV/tXwL+MQaKkjDlZk42y+VRAK/rmGj5ZJQ7v20k0kpi7yauOAlK9XY wAlIVf3gO9r5KHISM9/VrOCUQDL4P0N00GsnlWZ7nvO/VA9q6Tk/dx5Up9yxR8GGl2/i NVBrR2EYOE6CrKvLeBNSRmsBddDLbmo1MRrnOLkMgrWwAgxYbSqTLWnkYdsdwrgqWMkz bXKdXA73poVgAsLl8sUoPKwtEU2exVXfOBZEEosJOrB4zPlM4m5iQi8I4L7qlJS7uMdM zR3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684920050; x=1687512050; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=8/xRPtd2AmjbmXpgou4sQlZTgH09nz9cR2dZE8lQL3E=; b=lJVBBu6AX7TtUKkxfmbmBG47MyCxPqi9lRHxFNKE62gCBEW7hyhw8w2wjo3GTrNlLI 7R4Kqdnuvxh0M9/OcU97xLkQLAexMA1N6qX6teTemI1S6T3iYG2Q97aYUhJNbnKvxxrJ +MdhiXmdpxvZLMRwf2xQa4hl9bbttqOQjhBh/WoCcoZGdKjy3+YzYFHRmJg1RQMUxs2e duN0ubYb8F7NI6oJDP0Zi1O79gEBQ1/HICsoES8hlZiHjFhp4RpI6d6Zhbv6ihdgc8Zi 8PbgVWJwhqadC3uZYpYWB/GS3pjT0eLET3egbxC5xbwbi9XleQoZMo9Tagitdp3TiM/D eilA== X-Gm-Message-State: AC+VfDwUs80IWPAwcSqNvqMz36h5bd4DFgnCgJd6GATA40PnDr3uxqxt dpf56c+BwgkhZrUEqi/c0N8= X-Google-Smtp-Source: ACHHUZ4ArixSPchxmOg3uVHa68zXOjZi+cEwG9Jj0dh24gaZ1G5fD+6w7OttPO0/0uqQ5IuwliWrUQ== X-Received: by 2002:a17:907:96a1:b0:959:bbda:fa51 with SMTP id hd33-20020a17090796a100b00959bbdafa51mr18565467ejc.41.1684920050496; Wed, 24 May 2023 02:20:50 -0700 (PDT) Received: from wslxew193.ultratronik.de (p200300c78700c900fd67df8b3b199594.dip0.t-ipconnect.de. [2003:c7:8700:c900:fd67:df8b:3b19:9594]) by smtp.gmail.com with ESMTPSA id jy22-20020a170907763600b0096fbc516a93sm4579527ejc.211.2023.05.24.02.20.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 May 2023 02:20:50 -0700 (PDT) From: Boerge Struempfel Cc: boerge.struempfel@gmail.com, bstruempfel@ultratronik.de, andy.shevchenko@gmail.com, festevam@gmail.com, amit.kumar-mahapatra@amd.com, broonie@kernel.org, Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , NXP Linux Team , linux-spi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v6 2/5] spi: spi-imx: add support for SPI_MOSI_IDLE_LOW mode bit Date: Wed, 24 May 2023 11:19:45 +0200 Message-Id: <20230524091948.41779-3-boerge.struempfel@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230524091948.41779-1-boerge.struempfel@gmail.com> References: <20230524091948.41779-1-boerge.struempfel@gmail.com> MIME-Version: 1.0 To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org By default, the spi-imx controller pulls the mosi line high, whenever it is idle. This behaviour can be inverted per CS by setting the corresponding DATA_CTL bit in the config register of the controller. Also, since the controller mode-bits have to be touched anyways, the SPI_CPOL and SPI_CPHA are replaced by the combined SPI_MODE_X_MASK flag. Signed-off-by: Boerge Struempfel --- drivers/spi/spi-imx.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/spi/spi-imx.c b/drivers/spi/spi-imx.c index 34e5f81ec431..1c4172fcba2d 100644 --- a/drivers/spi/spi-imx.c +++ b/drivers/spi/spi-imx.c @@ -281,6 +281,7 @@ static bool spi_imx_can_dma(struct spi_controller *controller, struct spi_device #define MX51_ECSPI_CONFIG_SCLKPOL(cs) (1 << ((cs & 3) + 4)) #define MX51_ECSPI_CONFIG_SBBCTRL(cs) (1 << ((cs & 3) + 8)) #define MX51_ECSPI_CONFIG_SSBPOL(cs) (1 << ((cs & 3) + 12)) +#define MX51_ECSPI_CONFIG_DATACTL(cs) (1 << ((cs & 3) + 16)) #define MX51_ECSPI_CONFIG_SCLKCTL(cs) (1 << ((cs & 3) + 20)) #define MX51_ECSPI_INT 0x10 @@ -573,6 +574,11 @@ static int mx51_ecspi_prepare_message(struct spi_imx_data *spi_imx, cfg &= ~MX51_ECSPI_CONFIG_SCLKCTL(spi_get_chipselect(spi, 0)); } + if (spi->mode & SPI_MOSI_IDLE_LOW) + cfg |= MX51_ECSPI_CONFIG_DATACTL(spi_get_chipselect(spi, 0)); + else + cfg &= ~MX51_ECSPI_CONFIG_DATACTL(spi_get_chipselect(spi, 0)); + if (spi->mode & SPI_CS_HIGH) cfg |= MX51_ECSPI_CONFIG_SSBPOL(spi_get_chipselect(spi, 0)); else @@ -1743,7 +1749,8 @@ static int spi_imx_probe(struct platform_device *pdev) spi_imx->controller->prepare_message = spi_imx_prepare_message; spi_imx->controller->unprepare_message = spi_imx_unprepare_message; spi_imx->controller->slave_abort = spi_imx_slave_abort; - spi_imx->controller->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH | SPI_NO_CS; + spi_imx->controller->mode_bits = SPI_MODE_X_MASK | SPI_CS_HIGH | SPI_NO_CS | + SPI_MOSI_IDLE_LOW; if (is_imx35_cspi(spi_imx) || is_imx51_ecspi(spi_imx) || is_imx53_ecspi(spi_imx)) From patchwork Wed May 24 09:19:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Boerge Struempfel X-Patchwork-Id: 685586 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8590FC7EE2C for ; Wed, 24 May 2023 09:21:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240648AbjEXJU7 (ORCPT ); Wed, 24 May 2023 05:20:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44842 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240644AbjEXJU6 (ORCPT ); Wed, 24 May 2023 05:20:58 -0400 Received: from mail-ej1-x629.google.com (mail-ej1-x629.google.com [IPv6:2a00:1450:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 08B768E; Wed, 24 May 2023 02:20:54 -0700 (PDT) Received: by mail-ej1-x629.google.com with SMTP id a640c23a62f3a-96f588bc322so96110566b.1; Wed, 24 May 2023 02:20:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1684920052; x=1687512052; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=RZI6N7rpTTulbByVXfKdZOIC7A9MiWqLIoC8OTG2ppM=; b=Dxc3ZW9z/Ys+/4mWm314kdDq9GMYYvyhgztHGsNKUjlrTHXldppbzal4TlSdjZaSen +LbaFjbIbQAMC63Q0UowKHnLJ264+8iKyID49hkbBS1edkI/CVKjopYy3flbXGu2jvpu CA4c51l0G8JGxV47HEV9nlYnikwZaovuCFhv2wgk0mZxq3OJb4LC/tt+oPN0Mq+AI9au tw8mP35h9Nbs2RwSPdeLGEwehBQvrm+VDckyL73xR7A/lpVmjQAHgSONigTGwIfcon7U UussDbwyLFyMPFR1NPCB4NxFivTNmMZ8AlNHe8MzRXcRWTe6P+a+Us5RQqEikXAkn/tw OGBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684920052; x=1687512052; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=RZI6N7rpTTulbByVXfKdZOIC7A9MiWqLIoC8OTG2ppM=; b=RSShDCKsai/b7aosl0C9EmGl47hryUVSIr3fwEtaGIuI8Vb8emZfByj6RMedqekTJS 71Npk9lD1FLEh9Qo/lqY/wIva5rSS5J6AYAU1zSsKDOTul5aWgXY/ST1pTea1CfSWz3O fbSGy4pkPBpCT2MRB7o/ufqlaWpdMUlblI3yiygK+hvlw9xnGUsUgLENcwhgiEeJWhRu /5OjYtsqu4rldFnQBSKGLvXMvl499VPsYt68eCij74KeM7nZojpvnmKIhxT7gKm6TCJa JNmPCFd9s6P2gDPdb3zlJh/dRN14eb0MQo3AkAClK7rzvgTADWXibCcLCO74ixUAZH99 DuUg== X-Gm-Message-State: AC+VfDyIR1wIfufou5tU4piraX+X1nRasQGt7G49rpQHC1/LdaDUvGD1 nebJVt/N6yxkqDlzgGTB2V8= X-Google-Smtp-Source: ACHHUZ5mduA17zD2smOHb4wfIDa1rKzPe3tFsTTOvBk3Uel45R1amPI12lMOFupYDV1yLDxltzX40w== X-Received: by 2002:a17:907:96a3:b0:96f:e45f:92e9 with SMTP id hd35-20020a17090796a300b0096fe45f92e9mr9902305ejc.16.1684920052104; Wed, 24 May 2023 02:20:52 -0700 (PDT) Received: from wslxew193.ultratronik.de (p200300c78700c900fd67df8b3b199594.dip0.t-ipconnect.de. [2003:c7:8700:c900:fd67:df8b:3b19:9594]) by smtp.gmail.com with ESMTPSA id jy22-20020a170907763600b0096fbc516a93sm4579527ejc.211.2023.05.24.02.20.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 May 2023 02:20:51 -0700 (PDT) From: Boerge Struempfel Cc: boerge.struempfel@gmail.com, bstruempfel@ultratronik.de, andy.shevchenko@gmail.com, festevam@gmail.com, amit.kumar-mahapatra@amd.com, broonie@kernel.org, Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , NXP Linux Team , linux-spi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v6 3/5] spi: spidev: add two new spi mode bits Date: Wed, 24 May 2023 11:19:46 +0200 Message-Id: <20230524091948.41779-4-boerge.struempfel@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230524091948.41779-1-boerge.struempfel@gmail.com> References: <20230524091948.41779-1-boerge.struempfel@gmail.com> MIME-Version: 1.0 To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org Allow userspace to set SPI_MOSI_IDLE_LOW and the SPI_3WIRE_HIZ mode bit using the SPI_IOC_WR_MODE32 ioctl. Signed-off-by: Boerge Struempfel --- drivers/spi/spidev.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/spi/spidev.c b/drivers/spi/spidev.c index 39d94c850839..c8b938e0f342 100644 --- a/drivers/spi/spidev.c +++ b/drivers/spi/spidev.c @@ -64,7 +64,8 @@ static_assert(N_SPI_MINORS > 0 && N_SPI_MINORS <= 256); | SPI_NO_CS | SPI_READY | SPI_TX_DUAL \ | SPI_TX_QUAD | SPI_TX_OCTAL | SPI_RX_DUAL \ | SPI_RX_QUAD | SPI_RX_OCTAL \ - | SPI_RX_CPHA_FLIP) + | SPI_RX_CPHA_FLIP | SPI_3WIRE_HIZ \ + | SPI_MOSI_IDLE_LOW) struct spidev_data { dev_t devt; From patchwork Wed May 24 09:19:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Boerge Struempfel X-Patchwork-Id: 685881 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B2F7AC7EE2E for ; Wed, 24 May 2023 09:21:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240645AbjEXJVA (ORCPT ); Wed, 24 May 2023 05:21:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44858 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240641AbjEXJU7 (ORCPT ); Wed, 24 May 2023 05:20:59 -0400 Received: from mail-ed1-x535.google.com (mail-ed1-x535.google.com [IPv6:2a00:1450:4864:20::535]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6DE8797; Wed, 24 May 2023 02:20:55 -0700 (PDT) Received: by mail-ed1-x535.google.com with SMTP id 4fb4d7f45d1cf-510d6e1f1abso1697483a12.2; Wed, 24 May 2023 02:20:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1684920054; x=1687512054; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=9sM32gSBhwgEqaXvzS8WOOQz2iG5ex22tKZyotsu4MA=; b=svSeqL2a836MyN3Lh+GhmGvhRNpuYmyJzL09ZhhsYR0nYfng/wK0beNPJ7h0wCO9Z3 Kp+C8zfucYeFSg1+uXvXE969TH5l6WEDw1PdrHnh21DoiwsfcgkGl8AyC9K9iEqyJ4zJ 18qc3rkONa9hgoZxF632LUWLsMg+xU3ee6mX67de6g/hAN2u+3Aw8WLGYuF+iqmDI3oi ACEfsCivMPPlsh94ZBBhu4WYDEhwX0DTX+ITOurDYwHPqLSYejqownFAbV+JqgvqUcP8 YWYqlz58drVwQcGI9f/VpEABoGUq4cXMjFMF842TjWMN4jz0uODZbwU2EuqPtdFp5s5M CFjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684920054; x=1687512054; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=9sM32gSBhwgEqaXvzS8WOOQz2iG5ex22tKZyotsu4MA=; b=BM9uv77uuiahDyDprKhX/jh7kDnJW4P148XrUuUNjFW3GrEPQ7fFceanRhnoMf5JAm ct87wvQmGeC6h2uXC7YssVRGSBdCp1cItEEYrbo+Y9P3AbwRbYyLiHXG/xEBQFZ6f9UG LeyQ2OmbCeZtPwYZyYaykVkPowI1O3Vmu9bFEU3d79Ou6wPGoNqPbDAc63jLoXrrdcON Rq9NyLzo0FGdu+PTm7M0hABodKD/AGkVtpks3dpSFh2RYPmKiKXDJ8/yF6DD1/o1Rk34 Eo9SucCqW2pTCXO+koonaDLZTZD2iphuwnVGKDcVUmrQaes539oVOfYFn6CoRhXffSvk AKGw== X-Gm-Message-State: AC+VfDyofME22gDLSkfYGEq5JQghcycMUyVNe/hqkpp0KQpmFAJITln5 JLoqcSexKU7jpAEoRhbBx9Q= X-Google-Smtp-Source: ACHHUZ6VV5ioQe3gO5I8qNjlJascX2pu++ASofeKQ2DiCk/4YAb+mhkr8Q90SzoVVowk1ARtuuZpjg== X-Received: by 2002:a17:907:94d5:b0:973:8198:bbf7 with SMTP id dn21-20020a17090794d500b009738198bbf7mr1706801ejc.11.1684920053544; Wed, 24 May 2023 02:20:53 -0700 (PDT) Received: from wslxew193.ultratronik.de (p200300c78700c900fd67df8b3b199594.dip0.t-ipconnect.de. [2003:c7:8700:c900:fd67:df8b:3b19:9594]) by smtp.gmail.com with ESMTPSA id jy22-20020a170907763600b0096fbc516a93sm4579527ejc.211.2023.05.24.02.20.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 May 2023 02:20:53 -0700 (PDT) From: Boerge Struempfel Cc: boerge.struempfel@gmail.com, bstruempfel@ultratronik.de, andy.shevchenko@gmail.com, festevam@gmail.com, amit.kumar-mahapatra@amd.com, broonie@kernel.org, Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , NXP Linux Team , linux-spi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v6 4/5] spi: spidev_test: Sorted the options into logical groups Date: Wed, 24 May 2023 11:19:47 +0200 Message-Id: <20230524091948.41779-5-boerge.struempfel@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230524091948.41779-1-boerge.struempfel@gmail.com> References: <20230524091948.41779-1-boerge.struempfel@gmail.com> MIME-Version: 1.0 To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org In order to increase usability, the command line options are sorted into logical groups. In addition, the usage string was sorted alphabetically, and the missing parameters '8','i' and 'o' were added. Furthermore, the option descriptions were moved further to the right, in order to allow for longer option names. Signed-off-by: Boerge Struempfel --- tools/spi/spidev_test.c | 90 ++++++++++++++++++++++------------------- 1 file changed, 48 insertions(+), 42 deletions(-) diff --git a/tools/spi/spidev_test.c b/tools/spi/spidev_test.c index b0ca44c70e83..2d2cee339b39 100644 --- a/tools/spi/spidev_test.c +++ b/tools/spi/spidev_test.c @@ -172,28 +172,34 @@ static void print_usage(const char *prog) { - printf("Usage: %s [-DsbdlHOLC3vpNR24SI]\n", prog); - puts(" -D --device device to use (default /dev/spidev1.1)\n" - " -s --speed max speed (Hz)\n" - " -d --delay delay (usec)\n" - " -b --bpw bits per word\n" - " -i --input input data from a file (e.g. \"test.bin\")\n" - " -o --output output data to a file (e.g. \"results.bin\")\n" - " -l --loop loopback\n" - " -H --cpha clock phase\n" - " -O --cpol clock polarity\n" - " -L --lsb least significant bit first\n" - " -C --cs-high chip select active high\n" - " -3 --3wire SI/SO signals shared\n" - " -v --verbose Verbose (show tx buffer)\n" - " -p Send data (e.g. \"1234\\xde\\xad\")\n" - " -N --no-cs no chip select\n" - " -R --ready slave pulls low to pause\n" - " -2 --dual dual transfer\n" - " -4 --quad quad transfer\n" - " -8 --octal octal transfer\n" - " -S --size transfer size\n" - " -I --iter iterations\n"); + printf("Usage: %s [-2348CDHILNORSbdilopsv]\n", prog); + puts("general device settings:\n" + " -D --device device to use (default /dev/spidev1.1)\n" + " -s --speed max speed (Hz)\n" + " -d --delay delay (usec)\n" + " -l --loop loopback\n" + "spi mode:\n" + " -H --cpha clock phase\n" + " -O --cpol clock polarity\n" + "number of wires for transmission:\n" + " -2 --dual dual transfer\n" + " -4 --quad quad transfer\n" + " -8 --octal octal transfer\n" + " -3 --3wire SI/SO signals shared\n" + "data:\n" + " -i --input input data from a file (e.g. \"test.bin\")\n" + " -o --output output data to a file (e.g. \"results.bin\")\n" + " -p Send data (e.g. \"1234\\xde\\xad\")\n" + " -S --size transfer size\n" + " -I --iter iterations\n" + "additional parameters:\n" + " -b --bpw bits per word\n" + " -L --lsb least significant bit first\n" + " -C --cs-high chip select active high\n" + " -N --no-cs no chip select\n" + " -R --ready slave pulls low to pause\n" + "misc:\n" + " -v --verbose Verbose (show tx buffer)\n"); exit(1); } @@ -201,26 +207,26 @@ static void parse_opts(int argc, char *argv[]) { while (1) { static const struct option lopts[] = { - { "device", 1, 0, 'D' }, - { "speed", 1, 0, 's' }, - { "delay", 1, 0, 'd' }, - { "bpw", 1, 0, 'b' }, - { "input", 1, 0, 'i' }, - { "output", 1, 0, 'o' }, - { "loop", 0, 0, 'l' }, - { "cpha", 0, 0, 'H' }, - { "cpol", 0, 0, 'O' }, - { "lsb", 0, 0, 'L' }, - { "cs-high", 0, 0, 'C' }, - { "3wire", 0, 0, '3' }, - { "no-cs", 0, 0, 'N' }, - { "ready", 0, 0, 'R' }, - { "dual", 0, 0, '2' }, - { "verbose", 0, 0, 'v' }, - { "quad", 0, 0, '4' }, - { "octal", 0, 0, '8' }, - { "size", 1, 0, 'S' }, - { "iter", 1, 0, 'I' }, + { "device", 1, 0, 'D' }, + { "speed", 1, 0, 's' }, + { "delay", 1, 0, 'd' }, + { "loop", 0, 0, 'l' }, + { "cpha", 0, 0, 'H' }, + { "cpol", 0, 0, 'O' }, + { "dual", 0, 0, '2' }, + { "quad", 0, 0, '4' }, + { "octal", 0, 0, '8' }, + { "3wire", 0, 0, '3' }, + { "input", 1, 0, 'i' }, + { "output", 1, 0, 'o' }, + { "size", 1, 0, 'S' }, + { "iter", 1, 0, 'I' }, + { "bpw", 1, 0, 'b' }, + { "lsb", 0, 0, 'L' }, + { "cs-high", 0, 0, 'C' }, + { "no-cs", 0, 0, 'N' }, + { "ready", 0, 0, 'R' }, + { "verbose", 0, 0, 'v' }, { NULL, 0, 0, 0 }, }; int c; From patchwork Wed May 24 09:19:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Boerge Struempfel X-Patchwork-Id: 685585 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2120CC7EE2E for ; Wed, 24 May 2023 09:21:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240671AbjEXJVF (ORCPT ); Wed, 24 May 2023 05:21:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44912 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240663AbjEXJVD (ORCPT ); Wed, 24 May 2023 05:21:03 -0400 Received: from mail-ed1-x52f.google.com (mail-ed1-x52f.google.com [IPv6:2a00:1450:4864:20::52f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F3D33195; Wed, 24 May 2023 02:20:56 -0700 (PDT) Received: by mail-ed1-x52f.google.com with SMTP id 4fb4d7f45d1cf-51426347bd2so521304a12.2; Wed, 24 May 2023 02:20:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1684920055; x=1687512055; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=w3S98eKsmu2BFFqj9FoRZCJ7VYZdqAy52J8ICuBM5wA=; b=I2E8B+EExYp0Evh1Ei1iZTtTSQh2hhyTyS+CDeeLozxgHfeVVlRRYmGiQ5V4hFuzKl uD/IPQ2EdLmzKbl07uy3UnAvHmL6S3oyCBRgmHfNEB7djRY4uNW9Nj9ml29W9ym6/KhE KLICc43Cb7AqC27HvTK3/5jQdSZPg/6aq1AjjgAbIOd9RrHj3lrTm6V0FLhnQe2rAwdc Atk2hq3j+gnldy+Ati8DhBOUaJmvr3nT/00UKFC65JoCqaS0C3Coyh5wykzTOX4UqAs8 ZxSldTIvhdbqYobVq8RVBA0L4Y4enKzndB2UlzLpSXT+xng63CUJOqZ5DlU/MBIGU0i0 cvhQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684920055; x=1687512055; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=w3S98eKsmu2BFFqj9FoRZCJ7VYZdqAy52J8ICuBM5wA=; b=GaC5IbepcCjYxk6EJWJY1FSlIuSqR1R74Ak0E3OsiSR4qEYr8mN7z0MPys0hwWrpQL ENLcXaqz4ZKuQNlUQjXKuTevFAXzj+QYMnbTrULAWlM0zT5ld4w2Lr961aoFqkKTENdF LAldDaFExQpPs2jUINnuEzokurKZqr6y+cZIFwkJ3osZvzruKLrFZzuE+1Yy9ksQ9GZJ b5a0o3aw+2cVbQxmTCCE8M082yah3Kyv5mx/6Uzv8B836v30QqsnRQOHxIePfxkB+kYD jjWD4ph0Pknahaq3k2NXKN7dfh888q6T28CViQouPnBC+r2D1+rSpoeyd5ZYKfNmfv/n m01g== X-Gm-Message-State: AC+VfDz3LT1SiX1j4V+uVQLn6+n4Hom0ZoBwpSSnWc4vv7ZOTavR83p7 GSYa1ZYnho47G9vFM0yQIx8= X-Google-Smtp-Source: ACHHUZ7se64qwjasCPMUqE0Jm/aXFla0NiRJTyI+0UtLKLFcLGR3R6dR9FfIqijKkIlUCdkXv5d8yA== X-Received: by 2002:a17:906:4d8f:b0:94f:3bf7:dacf with SMTP id s15-20020a1709064d8f00b0094f3bf7dacfmr15858057eju.71.1684920055149; Wed, 24 May 2023 02:20:55 -0700 (PDT) Received: from wslxew193.ultratronik.de (p200300c78700c900fd67df8b3b199594.dip0.t-ipconnect.de. [2003:c7:8700:c900:fd67:df8b:3b19:9594]) by smtp.gmail.com with ESMTPSA id jy22-20020a170907763600b0096fbc516a93sm4579527ejc.211.2023.05.24.02.20.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 May 2023 02:20:54 -0700 (PDT) From: Boerge Struempfel Cc: boerge.struempfel@gmail.com, bstruempfel@ultratronik.de, andy.shevchenko@gmail.com, festevam@gmail.com, amit.kumar-mahapatra@amd.com, broonie@kernel.org, Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , NXP Linux Team , linux-spi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v6 5/5] spi: spidev_test Add three missing spi mode bits Date: Wed, 24 May 2023 11:19:48 +0200 Message-Id: <20230524091948.41779-6-boerge.struempfel@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230524091948.41779-1-boerge.struempfel@gmail.com> References: <20230524091948.41779-1-boerge.struempfel@gmail.com> MIME-Version: 1.0 To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org Added the three missing spi mode bits SPI_3WIRE_HIZ, SPI_RX_CPHA_FLIP, and SPI_MOSI_IDLE_LOW. Signed-off-by: Boerge Struempfel --- tools/spi/spidev_test.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/tools/spi/spidev_test.c b/tools/spi/spidev_test.c index 2d2cee339b39..9179942d7f15 100644 --- a/tools/spi/spidev_test.c +++ b/tools/spi/spidev_test.c @@ -172,7 +172,7 @@ static void transfer(int fd, uint8_t const *tx, uint8_t const *rx, size_t len) static void print_usage(const char *prog) { - printf("Usage: %s [-2348CDHILNORSbdilopsv]\n", prog); + printf("Usage: %s [-2348CDFHILMNORSZbdilopsv]\n", prog); puts("general device settings:\n" " -D --device device to use (default /dev/spidev1.1)\n" " -s --speed max speed (Hz)\n" @@ -181,11 +181,13 @@ static void print_usage(const char *prog) "spi mode:\n" " -H --cpha clock phase\n" " -O --cpol clock polarity\n" + " -F --rx-cpha-flip flip CPHA on Rx only xfer\n" "number of wires for transmission:\n" " -2 --dual dual transfer\n" " -4 --quad quad transfer\n" " -8 --octal octal transfer\n" " -3 --3wire SI/SO signals shared\n" + " -Z --3wire-hiz high impedance turnaround\n" "data:\n" " -i --input input data from a file (e.g. \"test.bin\")\n" " -o --output output data to a file (e.g. \"results.bin\")\n" @@ -198,6 +200,7 @@ static void print_usage(const char *prog) " -C --cs-high chip select active high\n" " -N --no-cs no chip select\n" " -R --ready slave pulls low to pause\n" + " -M --mosi-idle-low leave mosi line low when idle\n" "misc:\n" " -v --verbose Verbose (show tx buffer)\n"); exit(1); @@ -213,10 +216,12 @@ static void parse_opts(int argc, char *argv[]) { "loop", 0, 0, 'l' }, { "cpha", 0, 0, 'H' }, { "cpol", 0, 0, 'O' }, + { "rx-cpha-flip", 0, 0, 'F' }, { "dual", 0, 0, '2' }, { "quad", 0, 0, '4' }, { "octal", 0, 0, '8' }, { "3wire", 0, 0, '3' }, + { "3wire-hiz", 0, 0, 'Z' }, { "input", 1, 0, 'i' }, { "output", 1, 0, 'o' }, { "size", 1, 0, 'S' }, @@ -226,12 +231,13 @@ static void parse_opts(int argc, char *argv[]) { "cs-high", 0, 0, 'C' }, { "no-cs", 0, 0, 'N' }, { "ready", 0, 0, 'R' }, + { "mosi-idle-low", 0, 0, 'M' }, { "verbose", 0, 0, 'v' }, { NULL, 0, 0, 0 }, }; int c; - c = getopt_long(argc, argv, "D:s:d:b:i:o:lHOLC3NR248p:vS:I:", + c = getopt_long(argc, argv, "D:s:d:b:i:o:lHOLC3ZFMNR248p:vS:I:", lopts, NULL); if (c == -1) @@ -274,6 +280,15 @@ static void parse_opts(int argc, char *argv[]) case '3': mode |= SPI_3WIRE; break; + case 'Z': + mode |= SPI_3WIRE_HIZ; + break; + case 'F': + mode |= SPI_RX_CPHA_FLIP; + break; + case 'M': + mode |= SPI_MOSI_IDLE_LOW; + break; case 'N': mode |= SPI_NO_CS; break;