From patchwork Sat May 20 19:08:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Boerge Struempfel X-Patchwork-Id: 684447 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 1F89AC7EE2A for ; Sat, 20 May 2023 19:09:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230434AbjETTJX (ORCPT ); Sat, 20 May 2023 15:09:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37496 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230286AbjETTJW (ORCPT ); Sat, 20 May 2023 15:09:22 -0400 Received: from mail-ed1-x529.google.com (mail-ed1-x529.google.com [IPv6:2a00:1450:4864:20::529]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DE7EDFD; Sat, 20 May 2023 12:09:21 -0700 (PDT) Received: by mail-ed1-x529.google.com with SMTP id 4fb4d7f45d1cf-510c734fa2dso4184143a12.0; Sat, 20 May 2023 12:09:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1684609760; x=1687201760; 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=6Prd49snigix6d9LdTUvvFg72tuSsEwzo0jpnKwNXRk=; b=ndI3RtV5qmFrjHrE6BKMjECSkT20DVBp7Fue59KF0+oaitRjsrEcMladLVERxPc5UQ e/LsHMtgtkrGylZMv5O4JnivQhj5OL4MdXbiSwc5IfxdboznIpiikyJf/S99yZ8JryQw yktfPync3jHIUGhOvZGYvtUuZZTRa/tH3lGuvweh02Ki+lKA4KEjXJbvrC4ZLnsjH7dt 0fQHvezbu2jrgev7rqUOKcix0i+LnHPu7e0PZQ3BL9lAMdmPCyHvJ33pSjPJXhoQyLFQ 2/CoTTN3rZTuBy9wHRrfFmMhbcEOodkaHnhYwpiq/UTPpzeueQrHn2Ib8V1uID0VCGx6 /HhA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684609760; x=1687201760; 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=6Prd49snigix6d9LdTUvvFg72tuSsEwzo0jpnKwNXRk=; b=CJXnZAlvuiXPNb0B5rZt1J5piVSldZ6ojXUEjx1jxmHgiBDUnlbEeLhQ3z0jAqfSMr 4HRhPtyZUpkyz/j6Jf75OOLlgAzEt4mnJbqCS4YPVKo0R1M/+hTzFGyrn5kCcDfxkBRp 0TjB24XRcUTOgnqQYox59AfJTivfY+lY5xEw23B0yWxSqqTHULMeg8WeIuJgLEs7ffNU B1r0GZqPSLJCJgaP6wP3ZdbXjTzH0FWSjtY4nWGKEbY62wAPmlprX8crhZdWkYk5nTvg pr195CL7PZYGJqAfZSDjAAijENGTtadl2xvsY9+8acr5ooURnjEfw137KcF9AQT4GwCQ 0XCA== X-Gm-Message-State: AC+VfDxAJqnQ7FWpyFdq2xEFdnF5Xz54i8IBEgf0IofCqGrVQVUrEkgv ZAJXA6fS+0MOYgGlQxIcyldBcobid0IGLh19 X-Google-Smtp-Source: ACHHUZ76/oWY1oGRjWs/DHANNHrsB+kDQgU8CeglBDWDZRg+EPTSOsRPu3rZ3iR0oZNvNzGhkJ9DQg== X-Received: by 2002:a05:6402:1603:b0:4ad:738b:6706 with SMTP id f3-20020a056402160300b004ad738b6706mr6368047edv.2.1684609760129; Sat, 20 May 2023 12:09:20 -0700 (PDT) Received: from wslxew193.fritz.box (p200300c78700c900cb504b662390cd6b.dip0.t-ipconnect.de. [2003:c7:8700:c900:cb50:4b66:2390:cd6b]) by smtp.gmail.com with ESMTPSA id ba7-20020a0564021ac700b0050daa883545sm1065889edb.64.2023.05.20.12.09.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 20 May 2023 12:09:19 -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 v5 1/4] spi: add SPI_MOSI_IDLE_LOW mode bit Date: Sat, 20 May 2023 21:08:52 +0200 Message-Id: <20230520190856.34720-2-boerge.struempfel@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230520190856.34720-1-boerge.struempfel@gmail.com> References: <20230520190856.34720-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 Sat May 20 19:08:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Boerge Struempfel X-Patchwork-Id: 684710 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 16012C77B7F for ; Sat, 20 May 2023 19:09:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231292AbjETTJZ (ORCPT ); Sat, 20 May 2023 15:09:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37502 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231208AbjETTJY (ORCPT ); Sat, 20 May 2023 15:09:24 -0400 Received: from mail-ed1-x52a.google.com (mail-ed1-x52a.google.com [IPv6:2a00:1450:4864:20::52a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 46308FB; Sat, 20 May 2023 12:09:23 -0700 (PDT) Received: by mail-ed1-x52a.google.com with SMTP id 4fb4d7f45d1cf-510b56724caso4053560a12.1; Sat, 20 May 2023 12:09:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1684609761; x=1687201761; 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=/FsOd9MgDJMeorWa734Iw1cUVj+gA3xOrUBWqtCM238=; b=Lvvrq1SrYEfGFtgK7XhopNNUW54VnLwwME7kwJUCt8G3GVicDeIZlxWmgHie87B7Fj jNjvyjTlE2nrdtNCtNTpva74t5epP7ecc8iHlMyYNZBDgieD5hu+rMHoaiaCerMoSbV4 aaUGZy0qXj9W4hG+6stW0yxr5OGId1vwY0oazw7+h1Di4bRquJoi6C0AictpcJPUZYyV s0N7kVc/l8gQquPgec2NT6Coo+RLxAVlICYzly6v+1M9FurbqPW+KISKYgkHBiwjYwbf pP4qihvHvrnYy6fFre6NHS9YFlVLhPN7tiC1IqnIM/G1VliqjeLV4ldyuKgUFVHn4i27 Xn1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684609761; x=1687201761; 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=/FsOd9MgDJMeorWa734Iw1cUVj+gA3xOrUBWqtCM238=; b=kVDQYlGPnXClfEg+C/XKHTqb4fD68jM2ywXXqo6x32Tgq2mga3Vq2X0Zt1awN0gApz fJripBeD+mwRijMoLqNbuOsdgaa3Lim0tNw8TotTAZ/6y58ROJfQo2VgF9uW9zidWjrG asQob2YwgFWMwUsXT+Ibt2vx4IzVjW0yiRyh4tS27SG5KlhiziU46V1f1ayyEYGOsP0d VLifqe06cD2jPwB7kkEp3RlDSgyY2gEeG5rjehkePHyKeZWVbKDZaEpJxLhtQmq5Ofov bJKZ5n9IYwQRhvlmxWJr4OB8DasINwOeus87nBOqnv1D8thKqZg8X7eadm/mFWu+1VGT Yn9Q== X-Gm-Message-State: AC+VfDzzlaYIVA+g9exRpwS5TH1DHnbaDGMntNCBmSlgZcXjH77S72UF mykrYrXl18CL6vZiaDhhuF0= X-Google-Smtp-Source: ACHHUZ7/zpj7cLb82AnNyJLgCRKb4XbhmL6eH35FJLdOfnh75t+GIrt5AA62jl7FxhUG5JPQW71JcQ== X-Received: by 2002:aa7:cd06:0:b0:50d:8d42:a454 with SMTP id b6-20020aa7cd06000000b0050d8d42a454mr5224238edw.21.1684609761696; Sat, 20 May 2023 12:09:21 -0700 (PDT) Received: from wslxew193.fritz.box (p200300c78700c900cb504b662390cd6b.dip0.t-ipconnect.de. [2003:c7:8700:c900:cb50:4b66:2390:cd6b]) by smtp.gmail.com with ESMTPSA id ba7-20020a0564021ac700b0050daa883545sm1065889edb.64.2023.05.20.12.09.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 20 May 2023 12:09:21 -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 v5 2/4] spi: spi-imx: add support for SPI_MOSI_IDLE_LOW mode bit Date: Sat, 20 May 2023 21:08:53 +0200 Message-Id: <20230520190856.34720-3-boerge.struempfel@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230520190856.34720-1-boerge.struempfel@gmail.com> References: <20230520190856.34720-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 Sat May 20 19:08:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Boerge Struempfel X-Patchwork-Id: 684446 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 0607BC7EE2A for ; Sat, 20 May 2023 19:09:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230286AbjETTJ2 (ORCPT ); Sat, 20 May 2023 15:09:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37508 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231320AbjETTJZ (ORCPT ); Sat, 20 May 2023 15:09:25 -0400 Received: from mail-ed1-x534.google.com (mail-ed1-x534.google.com [IPv6:2a00:1450:4864:20::534]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BFB2BFD; Sat, 20 May 2023 12:09:24 -0700 (PDT) Received: by mail-ed1-x534.google.com with SMTP id 4fb4d7f45d1cf-510f3db1cd8so4176870a12.1; Sat, 20 May 2023 12:09:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1684609763; x=1687201763; 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=Liz5Dg4FexydxAHAog0MQJzFgR4/1Nt82myf27DAU2g=; b=R0CfSQu+hMLrhno/D5JAHpmhdZi05gFJbZSlR3tuNEydH5yJx+OKYM/CKoiJ+n7VZN 7RS7tOqVM35ccT7fOAYCTmJyW3wY3h1lV8Ph/KIZpRfIwx8fnXtSq9HTfpcJCXdI4srg lpFCoTSks5KQnVydSwzDsMEk3hv4Xqz3NBOkRmcpiPUQHnN5NmFyinDZFo1tAt4vaDmH n/SGNffJlJAwisPiQfznL1wMQo36Le+E6q6/4VLZVThnroLErFPRhAzc70RZIvAI6v6K M222L2yOUeT43XApFvqfsnCxLGsvZ3QhG8h+zbOSEFfL/SKIfFMtwZy8cVRdc7WhLyb/ tOYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684609763; x=1687201763; 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=Liz5Dg4FexydxAHAog0MQJzFgR4/1Nt82myf27DAU2g=; b=OvXOEuYDEY8+EnP7j9dqALhLoltNStJSScSALYis/3xQmtBsay/vB1m//uE18Pyzym k9raygnb28paokWH+XEjndxj/m/w0r2QBcAjw1iqc/7tmZ0XID6DyqDUS81WsEzY6djb 6FeQeg6wzZlJlHFvZAYmxyfO7YPxzQJD9aIUT/Z6hVcQOXLmREDR11PAzAQ2wmV7FfH0 2DxRIMrlAVJ9lwo/ubOFFlRBPLK5LJjWg/AN/H0fa+Q+XKAPlI0DLQsIrYUfkqb4HyC9 jbBVJboA8WMz4XhV3+PYULnaUPG9uPYhVPjDp0KAJM7XrrrtUBeCoFv5leYNo/AEQaRF UiWw== X-Gm-Message-State: AC+VfDzTqvhKmFO/V9qaFOXoAca5DF/ytZigTJuLFnpM4Bd0DqX+e4+7 kDnFhzUUZcV+vHkWJnsa0ak= X-Google-Smtp-Source: ACHHUZ4Q4Gg9nU2iYf22SEZ5qd35Lxxxnhppfn4OdwDLMfZQ3G0ZYwaJxtB8V5caPx/MmbGoiEcxSw== X-Received: by 2002:aa7:cb51:0:b0:50d:1e11:eb9 with SMTP id w17-20020aa7cb51000000b0050d1e110eb9mr4953165edt.1.1684609763205; Sat, 20 May 2023 12:09:23 -0700 (PDT) Received: from wslxew193.fritz.box (p200300c78700c900cb504b662390cd6b.dip0.t-ipconnect.de. [2003:c7:8700:c900:cb50:4b66:2390:cd6b]) by smtp.gmail.com with ESMTPSA id ba7-20020a0564021ac700b0050daa883545sm1065889edb.64.2023.05.20.12.09.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 20 May 2023 12:09:22 -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 v5 3/4] spi: spidev: add two new spi mode bits Date: Sat, 20 May 2023 21:08:54 +0200 Message-Id: <20230520190856.34720-4-boerge.struempfel@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230520190856.34720-1-boerge.struempfel@gmail.com> References: <20230520190856.34720-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 Sat May 20 19:08:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Boerge Struempfel X-Patchwork-Id: 684709 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 9A4B7C77B7A for ; Sat, 20 May 2023 19:09:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231907AbjETTJ2 (ORCPT ); Sat, 20 May 2023 15:09:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37522 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231828AbjETTJ1 (ORCPT ); Sat, 20 May 2023 15:09:27 -0400 Received: from mail-ej1-x634.google.com (mail-ej1-x634.google.com [IPv6:2a00:1450:4864:20::634]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 947A9FB; Sat, 20 May 2023 12:09:26 -0700 (PDT) Received: by mail-ej1-x634.google.com with SMTP id a640c23a62f3a-96f7bf29550so233695566b.3; Sat, 20 May 2023 12:09:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1684609765; x=1687201765; 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=Cxu/hN/yK7OupNfwRZcHuiPf8qpTU+y9P6Uuv9Z+8+k=; b=fI8cbEpZa+OoKwzjyrGPjKaOFq3Lq7USodXSV/3C+uJTowv8BGnn543SNz5+7Kkiwz NabcaqAofjndqfnHRA4Dq4lm3iJjBPTuSieYEhnseD+Z4y7wlJaLYB/ypZaclnX6EbVx IqSt9rfXj7PWLXzapc9fehES/xzM8QX0Wh7UnFOI7P9Eh4+BWOESjvRg9iSceK7FwFvU L2Vcq2X4kQhzGrjP+JvAG8D/kahtaDk4jWniGsdi3IpW04njFz+1+LPY6h1yB1ZMWw+j daIHObvkPSmbRzu/sFTh/DDPnGrrYbktJLGMstLBWLAJikjhxAMz5PshgupdSVc4koh0 HvYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684609765; x=1687201765; 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=Cxu/hN/yK7OupNfwRZcHuiPf8qpTU+y9P6Uuv9Z+8+k=; b=JB0BdC+Bb5CYfY9w/yXuqDzJbVgJNwFJuwDgoTKy3iwIonIrstqNs3i+G41enr9l2a lirjIQEwhIE2jPrlkL+Ro0c8pD20SORwcWAG+RpT+QHhiuqXJExNbXHkYEh1/S9PUOsV DbPWSjG6tItKrXdV0Fzlq82c9gStwbO0fAuqLV6XCTOKls9OSpdfZuDF7iswp42BBPzF Zl5nStMNVSstKeGnyAlWHmj/scbaUQxL+OoN67abNGH4BGrbEef6NqylKfYx4bk/keUo i47qizrU8gJU1bvs2k4mK8CG8hOMOcJucvUi+E08ZCKgRaY89NCheRVgy/QbGiP/d4LM CXaQ== X-Gm-Message-State: AC+VfDxgiNZ/qxcQUQHvg3c62Hb2l2vV0wrUZMhdDnuQrd5CZrOLpVTX OiGbTXK8vVCHPrdZlfDFP8kDwR7Ju8ouDtMu X-Google-Smtp-Source: ACHHUZ7s03mDt2dM5b8wIGEec+Qgu4rxkO5o3ziWSbAfs/ZsSJ2/+Reu1b5H8B/isfZs0YyNS9z7NA== X-Received: by 2002:a17:906:5d04:b0:96a:8412:a44d with SMTP id g4-20020a1709065d0400b0096a8412a44dmr5353078ejt.36.1684609764743; Sat, 20 May 2023 12:09:24 -0700 (PDT) Received: from wslxew193.fritz.box (p200300c78700c900cb504b662390cd6b.dip0.t-ipconnect.de. [2003:c7:8700:c900:cb50:4b66:2390:cd6b]) by smtp.gmail.com with ESMTPSA id ba7-20020a0564021ac700b0050daa883545sm1065889edb.64.2023.05.20.12.09.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 20 May 2023 12:09:24 -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 v5 4/4] spi: spidev_test Add three missing spi mode bits Date: Sat, 20 May 2023 21:08:55 +0200 Message-Id: <20230520190856.34720-5-boerge.struempfel@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230520190856.34720-1-boerge.struempfel@gmail.com> References: <20230520190856.34720-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. Due to the length of the new options, the indentation of the options in the help message was also adjusted for all other options. Signed-off-by: Boerge Struempfel --- tools/spi/spidev_test.c | 101 +++++++++++++++++++++++----------------- 1 file changed, 58 insertions(+), 43 deletions(-) diff --git a/tools/spi/spidev_test.c b/tools/spi/spidev_test.c index b0ca44c70e83..66bfe90c541e 100644 --- a/tools/spi/spidev_test.c +++ b/tools/spi/spidev_test.c @@ -172,28 +172,31 @@ 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 [-DsbdlHOLC3ZFMvpNR24SI]\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" + " -Z --3wire-hiz high impedance turnaround\n" + " -F --rx-cpha-flip flip CPHA on Rx only xfer\n" + " -M --mosi-idle-low leave mosi line low when idle\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"); exit(1); } @@ -201,31 +204,34 @@ 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' }, + { "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' }, + { "3wire-hiz", 0, 0, 'Z' }, + { "rx-cpha-flip", 0, 0, 'F' }, + { "mosi-idle-low", 0, 0, 'M' }, + { "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' }, { 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) @@ -268,6 +274,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;