From patchwork Wed Nov 23 12:30:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Christoph Niedermaier X-Patchwork-Id: 13053606 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 41581C433FE for ; Wed, 23 Nov 2022 12:34:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:CC :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=0WlS2UgBVxO/z22Bo0HxZl9S1YY8a6lOS5G8mUgCXYs=; b=kgzCq9zigCVFqQ Z4dpxRQZ8Y3hm5qdP/KrF2ndGyk6xA8lSo8A4rQVe5xN7cTFoCGy330lYqck9f5AwFmCO7qCL2+yy 76RyCpYkwuWOIZnWszndJOL5d2poHsN0z+xIRSsAcKqTPOPYsaLmmCF53i2P8SWbYeWaLOl+kjoSH uGbdeL2FK4wcOwX/3lC7w3+uxrZKYnM9vzOOKUhyezjhveBIO/wr+l1pyXAjKtJAFSRVmXUCdfttp mBPBhIUZTqrTnBTefjfWNfvXOUE0VW0dzntsTkT1vMOmbrw+LsF7u3rjCVqMiX5hLBNvbLa3eXuQK iUuoIZWvlKfeWToakj3A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oxovP-00GwXp-BI; Wed, 23 Nov 2022 12:32:23 +0000 Received: from mx3.securetransport.de ([2a01:4f8:c0c:92be::1]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oxovL-00GwVz-Hj for linux-arm-kernel@lists.infradead.org; Wed, 23 Nov 2022 12:32:21 +0000 Received: from mail.dh-electronics.com (unknown [77.24.89.57]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx3.securetransport.de (Postfix) with ESMTPSA id 6E7055DD10; Wed, 23 Nov 2022 13:31:42 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dh-electronics.com; s=dhelectronicscom; t=1669206704; bh=amx/zyjZBJGMftjsLDTt/UwXEKNtP40hnCvAlZShRs0=; h=From:To:CC:Subject:Date:From; b=X0YGN9WQubxi+RS9cHBTzEKkoHha0d2OCtorSlc2w/ZUFq0m6TEOzpMN9eWl8EnUv V1wJfiodEBRgt2OXqSpt6maVGDPPfELx8T1OJ6o1y6XvJSHjozg7Vk+TxI+usooc09 RvEpwp4fxgDlRV3YK+y5E+Hmvfa+OghNXrdhxd5DL2whrHmzusR80+b4ci4oRVCwDY XN3/TfKXDDglivO/lf9nD1PVz0vTZ30h6yMB1iPMpQKrv08LVkb1HkWgVwf3xqhteL PYFUwzDsKVVQepp3gEDVfI6V9GT+BXSPYNIEPVevyH9Jj+pjWilkFlronYGj2v2e9Q fWHpmPTy9uxvw== Received: from DHPWEX01.DH-ELECTRONICS.ORG (10.64.2.30) by DHPWEX01.DH-ELECTRONICS.ORG (10.64.2.30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.20; Wed, 23 Nov 2022 13:31:35 +0100 Received: from localhost.localdomain (172.16.51.2) by DHPWEX01.DH-ELECTRONICS.ORG (10.64.2.30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.20 via Frontend Transport; Wed, 23 Nov 2022 13:31:34 +0100 From: Christoph Niedermaier To: , CC: , , , Christoph Niedermaier , Greg Kroah-Hartman , Rob Herring , "Alexander Dahl" , , Subject: [PATCH V2 1/4] dt_bindings: rs485: Add binding for GPIO that controls Rx enable during Tx Date: Wed, 23 Nov 2022 13:30:01 +0100 Message-ID: <20221123123004.7216-1-cniedermaier@dh-electronics.com> X-Mailer: git-send-email 2.11.0 X-klartext: yes MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221123_043219_859999_55101FE5 X-CRM114-Status: GOOD ( 17.49 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This patch adds a binding for a generic definition of an output GPIO that indicates the state of rs485-rx-during-tx. The idea is that the hardware already controls the option receiving during sending before it gets to the signal receiving hardware. The standard RS485 is a half-duplex bus that in most cases is driven by an UART controller. The advantage of using this GPIO is that it is independent of the capabilities of the UART core and the UART driver. On the hardware side the interface to the bus is controlled by a transceiver, that has a pin called RE (RX enable) or similar, which connects the bus to the RX signal of the UART controller. The GPIO can switch between two states to control the RE pin via an electrical circuit: - Active: The RE pin is always active. The UART RX see everything on the bus and therefore also what happens with the TX signal on the bus. - Inactive: The RE pin is always active, but during sending on the bus the pin RE is inactive. So basically the receiving during sending is suppressed. A possible circuit diagram could look like this: ┌──────────────────┐ │ RS485 │ TX ───────────────┤D │ │ Transceiver │ RTS ────┬──────────┤DE │ │ │ │ │ ┌─────┐ │ │ └─┤& │ │ │ │ ├──┤!RE │ !rx_during_tx_gpio ──────┤ │ │ │ └─────┘ │ │ │ │ RX ───────────────┤R │ │ │ └──────────────────┘ Here the RTS pin of the UART core is used to control TX via the transceiver pin DE (Drive Enable). RE and rx_during_tx_gpio are active low. Signed-off-by: Christoph Niedermaier --- Cc: Greg Kroah-Hartman Cc: Rob Herring Cc: Krzysztof Kozlowski Cc: Alexander Dahl Cc: Marek Vasut Cc: kernel@dh-electronics.com Cc: devicetree@vger.kernel.org To: linux-serial@vger.kernel.org To: linux-arm-kernel@lists.infradead.org --- V2: - Rework of the commit message - Rework GPIO property comment --- Documentation/devicetree/bindings/serial/rs485.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Documentation/devicetree/bindings/serial/rs485.yaml b/Documentation/devicetree/bindings/serial/rs485.yaml index 90a1bab40f05..6d780911e342 100644 --- a/Documentation/devicetree/bindings/serial/rs485.yaml +++ b/Documentation/devicetree/bindings/serial/rs485.yaml @@ -51,6 +51,10 @@ properties: description: GPIO pin to enable RS485 bus termination. maxItems: 1 + rs485-rx-during-tx-gpios: + description: Output GPIO pin that indicates the state of rs485-rx-during-tx. + maxItems: 1 + additionalProperties: true ... From patchwork Wed Nov 23 12:30:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Niedermaier X-Patchwork-Id: 13053610 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5060FC4167D for ; Wed, 23 Nov 2022 12:48:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=DLlEzjlVssB0aO1Mg4+otkuRdNfBzuQJD4s8Rvkp9NU=; b=H0uVHfGsGvJ9v/ wFMu9kqiZ5+x1KPSkZOhvuXhK9IrGjPCrIM2WJFfgtLH+wf2AJgI4gvH7qaI5TPh/RfroN9d5BKfE 8t3ndwvmJaOSPd585EQ2OoHXycd4vW1mZu0kKzt55VU2jmm5dPoZRqUnEP7Bl3TxCxzqWsFgr1S+w ThPC5DXBju/CdQRSel2iQV6ovzPEPh23n/ha+K0iOK3YsE92m3ts6A4KDMvB004XwppdSvq/oCOpN 8U+n8jK8fDN4Rttnbk84JhQMWfrP3fJc7kCGx6+F3pSHsPmMbTZa2H2C5BrSO249ZDmuY2P28cjIR vV0wrzoTllh9k3ORSUOA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oxp9t-00H24V-33; Wed, 23 Nov 2022 12:47:21 +0000 Received: from mx3.securetransport.de ([116.203.31.6]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oxp9k-00H1zu-IX for linux-arm-kernel@lists.infradead.org; Wed, 23 Nov 2022 12:47:14 +0000 Received: from mail.dh-electronics.com (unknown [77.24.89.57]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx3.securetransport.de (Postfix) with ESMTPSA id 8BE0D5DD10; Wed, 23 Nov 2022 13:46:45 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dh-electronics.com; s=dhelectronicscom; t=1669207606; bh=xK8zJcTf25/mDwEWUMWN/rNLwZTPLWF2eRCfj7fpGBM=; h=From:To:CC:Subject:Date:In-Reply-To:References:From; b=ceMOykJDfXcdnR/yPSmFS3I3aTEQH1bpav5lEO47OxvgP4IPcrt5AKVh2kt+FFdxi csx/RcP4AJXQS1meqAenLt6Q0whDgZMymbFEYIZ7XIrAVX5M+wUI1wuLoh/DRz0+jH YwU5tdM+FLzQaLU4gIVK6uNS/72P7FhPRGnpErcY3w7qTMPmoicbxzsYy9SK5xEgkI NNXSoXbd4/qAyuaeZSAOyAFSk7ZjCRO65Obem6fVQV+0rrDJuDcxViodHxvYrtoRuA m4CFqptlPPtfolhtPTdgje+Gk3uO8dDbHWtBIcgXTDaCNCpJ1kKfZlIiDU3Pgfel4W EatrQraZx7EbQ== Received: from DHPWEX01.DH-ELECTRONICS.ORG (10.64.2.30) by DHPWEX01.DH-ELECTRONICS.ORG (10.64.2.30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.20; Wed, 23 Nov 2022 13:31:36 +0100 Received: from localhost.localdomain (172.16.51.2) by DHPWEX01.DH-ELECTRONICS.ORG (10.64.2.30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.20 via Frontend Transport; Wed, 23 Nov 2022 13:31:35 +0100 From: Christoph Niedermaier To: , CC: , , , Christoph Niedermaier , Greg Kroah-Hartman , Alexander Dahl , , Linux Team Subject: [PATCH V2 2/4] serial: core: Add option to output RS485 RX_DURING_TX state via GPIO Date: Wed, 23 Nov 2022 13:30:02 +0100 Message-ID: <20221123123004.7216-2-cniedermaier@dh-electronics.com> X-Mailer: git-send-email 2.11.0 X-klartext: yes In-Reply-To: <20221123123004.7216-1-cniedermaier@dh-electronics.com> References: <20221123123004.7216-1-cniedermaier@dh-electronics.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221123_044712_975023_0AA2205F X-CRM114-Status: GOOD ( 18.16 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This patch provides a generic GPIO variable for outputting the state of RS485 RX_DURING_TX. The GPIO is defined by the devicetree property "rs485-rx-during-tx-gpios". To use it in a low level serial driver, the evaluation of this variable must be implemented there accordingly. Signed-off-by: Christoph Niedermaier --- Cc: Greg Kroah-Hartman Cc: Jiri Slaby Cc: Alexander Dahl Cc: Marek Vasut Cc: kernel@dh-electronics.com Cc: Linux Team To: linux-serial@vger.kernel.org To: linux-arm-kernel@lists.infradead.org --- V2: - Rework of the commit message - Rework GPIO property comment --- drivers/tty/serial/serial_core.c | 12 ++++++++++++ include/linux/serial_core.h | 1 + 2 files changed, 13 insertions(+) diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c index b9fbbee598b8..867f2675caca 100644 --- a/drivers/tty/serial/serial_core.c +++ b/drivers/tty/serial/serial_core.c @@ -3410,6 +3410,7 @@ int uart_get_rs485_mode(struct uart_port *port) struct device *dev = port->dev; u32 rs485_delay[2]; int ret; + int rx_during_tx_gpio_flag; ret = device_property_read_u32_array(dev, "rs485-rts-delay", rs485_delay, 2); @@ -3458,6 +3459,17 @@ int uart_get_rs485_mode(struct uart_port *port) if (port->rs485_term_gpio) port->rs485_supported.flags |= SER_RS485_TERMINATE_BUS; + rx_during_tx_gpio_flag = (rs485conf->flags & SER_RS485_RX_DURING_TX) ? + GPIOD_OUT_HIGH : GPIOD_OUT_LOW; + port->rs485_rx_during_tx_gpio = devm_gpiod_get_optional(dev, + "rs485-rx-during-tx", + rx_during_tx_gpio_flag); + if (IS_ERR(port->rs485_rx_during_tx_gpio)) { + ret = PTR_ERR(port->rs485_rx_during_tx_gpio); + port->rs485_rx_during_tx_gpio = NULL; + return dev_err_probe(dev, ret, "Cannot get rs485-rx-during-tx-gpios\n"); + } + return 0; } EXPORT_SYMBOL_GPL(uart_get_rs485_mode); diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h index fd59f600094a..e0c83d05ae7b 100644 --- a/include/linux/serial_core.h +++ b/include/linux/serial_core.h @@ -579,6 +579,7 @@ struct uart_port { struct serial_rs485 rs485; struct serial_rs485 rs485_supported; /* Supported mask for serial_rs485 */ struct gpio_desc *rs485_term_gpio; /* enable RS485 bus termination */ + struct gpio_desc *rs485_rx_during_tx_gpio; /* Output GPIO that indicates the state of RS485 RX during TX */ struct serial_iso7816 iso7816; void *private_data; /* generic platform data pointer */ }; From patchwork Wed Nov 23 12:30:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Niedermaier X-Patchwork-Id: 13053621 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CF2B8C4332F for ; Wed, 23 Nov 2022 13:04:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=cvH8C+Br7PCyu09BG1Vl9UGyFad8c+ssNCKbaypYDoA=; b=HGZ61i9rjO+xn6 R3eHZgWto/fMP0/I3U1HuZccqHZQXK0o5o48F1ke6hg6uqtpVgfT0qM+IMCUYb7bwF1W4vhcnp1+o 2GntD0ch4bLs8leNSAhqFSnn6jM+4SIQ7VepVrUlAQTsff+9J6flMDv3gVTZqXEcC2/rbuI8wocZ4 e49NNH7QSyl/Lp2Km2s3axDgxRnmUyzZxc4fvUQIHexSQOcoygczWarAR6JmZkxIVHOmOpZjPsIms Zgk+NWtol4UQ0IQVD9SkJFooZGLlam+R1zpExOirbfGRttKn1hwsqurUZy97Te76AfNx/NfVPyFvc 02p3X8IQ7lkrq2yAqsAQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oxpOk-00H6bJ-Vd; Wed, 23 Nov 2022 13:02:43 +0000 Received: from mx2.securetransport.de ([2a03:4000:13:6c7::1]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oxpOg-00H6Yr-U4 for linux-arm-kernel@lists.infradead.org; Wed, 23 Nov 2022 13:02:40 +0000 Received: from mail.dh-electronics.com (unknown [77.24.89.57]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx2.securetransport.de (Postfix) with ESMTPSA id 6E8735E8BF; Wed, 23 Nov 2022 14:01:47 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dh-electronics.com; s=dhelectronicscom; t=1669208511; bh=8bejrz9uFar5stLsX8M9y4eC0FFkLbxKABV8dztCfEM=; h=From:To:CC:Subject:Date:In-Reply-To:References:From; b=IpMkv+vtJFaL1LZo77zphXuZU8ZCVGlm55iTUXh8oJTlvSc4/YnFx/XMZ2b+ZT34f Y1BI5cu+J7LpIHynil2pORWpt3yrHUDCTUET4ofY6URFVV081Uiy6erz/pm0REvARK PWMgS3iK77g5CJ7gHfjC1hiXznOb8gUSIjAhvw0WU45gMEpNEkDeWFc+uJoqaIwZpD xRdDTS3dr6YO/FhiUQ1UG/MEsbUI/KFnmnnRegObdZX7jRekv4Uo3MCY7D3lzbcyE0 Su+D51FZRpHy40vwQqNmi9nOlx+kDamPHjaNI9p600qClJOehqda4TutccZ/bR014P U+o2STpUPSjjw== Received: from DHPWEX01.DH-ELECTRONICS.ORG (10.64.2.30) by DHPWEX01.DH-ELECTRONICS.ORG (10.64.2.30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.20; Wed, 23 Nov 2022 13:31:37 +0100 Received: from localhost.localdomain (172.16.51.2) by DHPWEX01.DH-ELECTRONICS.ORG (10.64.2.30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.20 via Frontend Transport; Wed, 23 Nov 2022 13:31:36 +0100 From: Christoph Niedermaier To: , CC: , , , Christoph Niedermaier , Greg Kroah-Hartman , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Alexander Dahl , Fabio Estevam , , Linux Team Subject: [PATCH V2 3/4] serial: imx: Add support for RS485 RX_DURING_TX output GPIO Date: Wed, 23 Nov 2022 13:30:03 +0100 Message-ID: <20221123123004.7216-3-cniedermaier@dh-electronics.com> X-Mailer: git-send-email 2.11.0 X-klartext: yes In-Reply-To: <20221123123004.7216-1-cniedermaier@dh-electronics.com> References: <20221123123004.7216-1-cniedermaier@dh-electronics.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221123_050239_230483_A2773989 X-CRM114-Status: GOOD ( 19.12 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org If a RX_DURING_TX GPIO is defined by the DT property "rs485-rx-during-tx-gpios" this patch switches this GPIO accordingly to the RS485 flag RX_DURING_TX in user space. In addition, the i.MX UART receiver is no longer turned on and off during sending, because now the hardware is responsible for connecting or disconnecting RX during TX controlled by this GPIO. Signed-off-by: Christoph Niedermaier --- Cc: Greg Kroah-Hartman Cc: Jiri Slaby Cc: Shawn Guo Cc: Sascha Hauer Cc: Pengutronix Kernel Team Cc: Alexander Dahl Cc: Fabio Estevam Cc: Marek Vasut Cc: kernel@dh-electronics.com Cc: Linux Team To: linux-serial@vger.kernel.org To: linux-arm-kernel@lists.infradead.org --- V2: - Rework of the commit message --- drivers/tty/serial/imx.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c index 757825edb0cd..f241f16472f2 100644 --- a/drivers/tty/serial/imx.c +++ b/drivers/tty/serial/imx.c @@ -476,7 +476,8 @@ static void imx_uart_stop_tx(struct uart_port *port) imx_uart_rts_inactive(sport, &ucr2); imx_uart_writel(sport, ucr2, UCR2); - imx_uart_start_rx(port); + if (!port->rs485_rx_during_tx_gpio) + imx_uart_start_rx(port); sport->tx_state = OFF; } @@ -705,7 +706,8 @@ static void imx_uart_start_tx(struct uart_port *port) imx_uart_rts_inactive(sport, &ucr2); imx_uart_writel(sport, ucr2, UCR2); - if (!(port->rs485.flags & SER_RS485_RX_DURING_TX)) + if (!(port->rs485.flags & SER_RS485_RX_DURING_TX) && + !port->rs485_rx_during_tx_gpio) imx_uart_stop_rx(port); sport->tx_state = WAIT_AFTER_RTS; @@ -1955,6 +1957,13 @@ static int imx_uart_rs485_config(struct uart_port *port, struct ktermios *termio rs485conf->flags & SER_RS485_RX_DURING_TX) imx_uart_start_rx(port); + if (port->rs485_rx_during_tx_gpio) { + if (rs485conf->flags & SER_RS485_RX_DURING_TX) + gpiod_set_value_cansleep(port->rs485_rx_during_tx_gpio, 1); + else + gpiod_set_value_cansleep(port->rs485_rx_during_tx_gpio, 0); + } + return 0; } From patchwork Wed Nov 23 12:30:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Niedermaier X-Patchwork-Id: 13053644 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 842FDC4332F for ; Wed, 23 Nov 2022 13:19:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=uFn+qt0fFYGuybG9eOVvBkfSAa6mkbXqUhGkQXZ5+NA=; b=P7AOnTrocR3hHy UNbjSam7ATz3WvXSfHjTmGSYyofgWeRELOpQ5kXNIwXeLqLoxYMWZzZZljnsgqTbxGnAL/DErTb7n Lloo8mQDq7tTRMiAbFxl/iC/uKTNKlUqwYOGRnbR5zYJ7HaQDpkFl60Yw/tSPNgy4Sv+iog334PI9 BckEr/EpRbMvT/oBj7VwRlNp46aMwk+1lB1s3V/iB0aESE6FVVQ92zB5e8ksr03cW9ybYhHIXAV5R UTIgjeomVFz8aKWenl/YbGiiAfpRZ0N0Js1mAprU2d4tpD0MARZ3T0YOeLN9uoGS9U7XdJrd/saY3 QBX2YzzjiISEx2d/9eUg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oxpdH-00HBBl-1y; Wed, 23 Nov 2022 13:17:43 +0000 Received: from mx2.securetransport.de ([188.68.39.254]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oxpdD-00HB9I-WF for linux-arm-kernel@lists.infradead.org; Wed, 23 Nov 2022 13:17:41 +0000 Received: from mail.dh-electronics.com (unknown [77.24.89.57]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx2.securetransport.de (Postfix) with ESMTPSA id 22D355E973; Wed, 23 Nov 2022 14:16:53 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dh-electronics.com; s=dhelectronicscom; t=1669209413; bh=9l+U0q1LwCO0vtHgcdR98p9wmZWrEebnFiCSoMawdM0=; h=From:To:CC:Subject:Date:In-Reply-To:References:From; b=yG4yxHzEW1c4Ez6SK+GxpG5yP61Y+0MdwAs4TSCDgC1W5LvH5AVHK2d1X+/pqgobl xvgQXlVbq+sn0KCmnBQQokVjfol8sLAFrj98osrQLB2+T7aB6yHs/oO+weIHDW1olW Q9JJ66eV7U5p6k9IIrqmcqv3Ll35x/N3iv3mF7wlA6C6ZRjvi8OD2pACxQ+650XluY eGQxgCJmxhc4XZllQru9OnlrcrUOc0TX8+dlKw6PGpA7Z7ilE3MItgmMhxGVGV9JMR ERIebJO7/4IhbV9thdzQ2ioHTK1Ru22iG0P9L8VjXfZVCW/W+nWVWY8G/TSoH4os1H /XqcAyupw+cEg== Received: from DHPWEX01.DH-ELECTRONICS.ORG (10.64.2.30) by DHPWEX01.DH-ELECTRONICS.ORG (10.64.2.30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.20; Wed, 23 Nov 2022 13:31:38 +0100 Received: from localhost.localdomain (172.16.51.2) by DHPWEX01.DH-ELECTRONICS.ORG (10.64.2.30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.20 via Frontend Transport; Wed, 23 Nov 2022 13:31:37 +0100 From: Christoph Niedermaier To: , CC: , , , Christoph Niedermaier , Greg Kroah-Hartman , Maxime Coquelin , Alexandre Torgue , Alexander Dahl , , Subject: [PATCH V2 4/4] serial: stm32: Add support for rs485 RX_DURING_TX output GPIO Date: Wed, 23 Nov 2022 13:30:04 +0100 Message-ID: <20221123123004.7216-4-cniedermaier@dh-electronics.com> X-Mailer: git-send-email 2.11.0 X-klartext: yes In-Reply-To: <20221123123004.7216-1-cniedermaier@dh-electronics.com> References: <20221123123004.7216-1-cniedermaier@dh-electronics.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221123_051740_361735_45ABF487 X-CRM114-Status: GOOD ( 16.30 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org If a RX_DURING_TX GPIO is defined by the DT property "rs485-rx-during-tx-gpios" this patch switches this GPIO accordingly to the RS485 flag RX_DURING_TX in user space. Controlled by this GPIO, now the hardware is responsible for connecting or disconnecting RX during TX. Signed-off-by: Christoph Niedermaier --- Cc: Greg Kroah-Hartman Cc: Jiri Slaby Cc: Maxime Coquelin Cc: Alexandre Torgue Cc: Alexander Dahl Cc: Marek Vasut Cc: kernel@dh-electronics.com Cc: linux-stm32@st-md-mailman.stormreply.com To: linux-serial@vger.kernel.org To: linux-arm-kernel@lists.infradead.org --- V2: - Rework of the commit message --- drivers/tty/serial/stm32-usart.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/tty/serial/stm32-usart.c b/drivers/tty/serial/stm32-usart.c index 24def72b2565..f1bef784b020 100644 --- a/drivers/tty/serial/stm32-usart.c +++ b/drivers/tty/serial/stm32-usart.c @@ -226,7 +226,14 @@ static int stm32_usart_config_rs485(struct uart_port *port, struct ktermios *ter stm32_usart_clr_bits(port, ofs->cr1, BIT(cfg->uart_enable_bit)); - rs485conf->flags |= SER_RS485_RX_DURING_TX; + if (port->rs485_rx_during_tx_gpio) { + if (rs485conf->flags & SER_RS485_RX_DURING_TX) + gpiod_set_value_cansleep(port->rs485_rx_during_tx_gpio, 1); + else + gpiod_set_value_cansleep(port->rs485_rx_during_tx_gpio, 0); + } else { + rs485conf->flags |= SER_RS485_RX_DURING_TX; + } if (rs485conf->flags & SER_RS485_ENABLED) { cr1 = readl_relaxed(port->membase + ofs->cr1);