From patchwork Wed Oct 26 16:50:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Niedermaier X-Patchwork-Id: 13020918 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 C7F86C433FE for ; Wed, 26 Oct 2022 17:09:16 +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=GeVtYZZJD2TStzHlOOJ6Nyi+TbxyITNLofVZNjG1zms=; b=bHZiXULrdaFJqM MDxFKj/vZSDHBpaY4PIcmxT/lrzPqKmNwRfwEjoRqrtIwkdQl3lfL5gw6mHM1Cn85lgCyuxAS/oP5 HOqHtEW3RNp4vEbscE2tRBYLjwupW8jgUXc3Ifjs36Bu6KACvyD8dTh44kNrSAxNbLNkfMo1uuK1t fu3DsHjIs0Xnqz9Jo+x6zAQpEascArYsBC517VtSjPtypYDOn08W23iE/+zZOMihDQJOa3RsaPwbY ym8MvdrsZoFlkJ3Z5J3NMTF7yBxlWxVHOD2pYH6tGFTHlk0bnDf1eteqYwLWjhTY1t1WT97UTerfP UXm2AyzaxkUpvSU4W1mA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1onjsy-00AIWc-2O; Wed, 26 Oct 2022 17:08:12 +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 1onjsu-00AIVP-Sw for linux-arm-kernel@lists.infradead.org; Wed, 26 Oct 2022 17:08:10 +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 CAF475E898; Wed, 26 Oct 2022 19:07:30 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dh-electronics.com; s=dhelectronicscom; t=1666804052; bh=ZyqBHi0qzZwUyvfT3QboVMHj6xLTnCn8xFrtj9J/hwk=; h=From:To:CC:Subject:Date:In-Reply-To:References:From; b=hLqRmxCNpFO+6liZwMXIb5SVN5jpOh6FG/0zLNsGRYa1OGHbQ5ikup6X+orq0erIW oUt5HkVCSIuYvUCzKGHeAsy8IzIE9/fxoe4XbG98DV9Wg9BaSCss6Hp55KciDOeejJ lf7ISmEztIvdj4lQaQFp1dOC+1QXJiwirRTsMcNr1rMBiciC1voR3+NQYky+JvkrIL dxd4jcqAMP8OLss56FSTEUb7xCNq3aZOR4SqOaqEwtzfBl/tid0h0mJx42JvIRJZlk xyVQF1ngHkJIBgrurcYR/yb3oRt4DrcC5WlinRB7SYGmaQIc4JIWG39A/K9GQ4QN49 Te1E+fFfuHxMA== 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.15; Wed, 26 Oct 2022 18:52:18 +0200 Received: from localhost.localdomain (172.16.51.8) 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.15 via Frontend Transport; Wed, 26 Oct 2022 18:52:18 +0200 From: Christoph Niedermaier To: , CC: , , , Christoph Niedermaier , Greg Kroah-Hartman , Rob Herring , Subject: [PATCH 1/4] dt_bindings: rs485: Add binding for GPIO that controls Rx enable during Tx Date: Wed, 26 Oct 2022 18:50:46 +0200 Message-ID: <20221026165049.9541-2-cniedermaier@dh-electronics.com> X-Mailer: git-send-email 2.11.0 X-klartext: yes In-Reply-To: <20221026165049.9541-1-cniedermaier@dh-electronics.com> References: <20221026165049.9541-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-20221026_100809_183984_5274EC45 X-CRM114-Status: GOOD ( 12.29 ) 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 Add the binding for a generic definition of a GPIO, that controls whether Rx is connected or disconnected by an electrical circuit to have the ability to receive the signals on the bus during sending or disable receiving during sending. Signed-off-by: Christoph Niedermaier --- Cc: Greg Kroah-Hartman Cc: Rob Herring Cc: Krzysztof Kozlowski Cc: Marek Vasut Cc: devicetree@vger.kernel.org To: linux-serial@vger.kernel.org To: linux-arm-kernel@lists.infradead.org --- 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..0ebd7690f85d 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: GPIO pin to control RS485 Rx enable during Tx. + maxItems: 1 + additionalProperties: true ... From patchwork Wed Oct 26 16:50:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Niedermaier X-Patchwork-Id: 13020893 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 5A341C38A2D for ; Wed, 26 Oct 2022 16:54:29 +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=c3KSMXM8ca/5AB4ZtyRbFXGNlgAtr8p1PSY20aGS+tc=; b=VH8X5Kj65abjfx 1AH5WZYdeOArySE3i1DyKQM0AmJbO5J6wd2OswyDqsHKjB82GKSYj9vYRKRzxYGWbDUY5HXejRqOA 5F1D6GjWYvng3hrsiwVxvZTc8+OtSJR2gXqZ827pnTTgAyRws2JiwHyVhBZxPa27LmYaw2bucwWD9 oGGotgZ8Scdd+kOQ1PsCfmU2K6ipg/CQR0BPCRXi9leZKQS3Rk1M3gj7n/kNmjAjcFD3fDU+DIVJ9 zlp4BtmaW3BfPM8RHhUMlLpikOd5+vE8ABWz3xFTPQxUFB0eoTL+55N68BQYhpwSwM5Hs8+ceXcnA L9RgWb1zmYTC6j7+/7MQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1onjep-00AEPO-Ey; Wed, 26 Oct 2022 16:53:35 +0000 Received: from mx4.securetransport.de ([178.254.6.145]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1onjel-00AENR-UL for linux-arm-kernel@lists.infradead.org; Wed, 26 Oct 2022 16:53:33 +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 mx4.securetransport.de (Postfix) with ESMTPSA id A1006720612; Wed, 26 Oct 2022 18:52:30 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dh-electronics.com; s=dhelectronicscom; t=1666803150; bh=P5tRVMcnlNYMWhLvLu89wfasV6TP7daHT6i93HjdQ/M=; h=From:To:CC:Subject:Date:In-Reply-To:References:From; b=ZrXM05iVd0VPQfJj2CPr1wrTQz7cL42g/I9tg6GMsdR1S9gtogia9TQa8LO/6t2Mw H14lC5qhHoYcATOtsYzoWI/T6gFM2SQbYeD0S83j23ErtheW+hyZU73aDnSyi5t5FT ONFdGx8xfmJgJms1PBdr/tIBf+acTUk0h4eno8STjCtqRX7NEowPw9d76JtpvCeC4Q xnNXWAlK5U/5sUFfRDWPjsrY6uUn8PFHSmmNz0weqETqLD36bj4YKw0kfD5QaPwAhz xareh9ToMv0JE+anvSET07Dbn8A91ZDtn13vYel5UosQT/c81Bg3pjccEySdLvJBP3 bhGW8PCazeAXA== 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.15; Wed, 26 Oct 2022 18:52:19 +0200 Received: from localhost.localdomain (172.16.51.8) 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.15 via Frontend Transport; Wed, 26 Oct 2022 18:52:19 +0200 From: Christoph Niedermaier To: , CC: , , , Christoph Niedermaier , Greg Kroah-Hartman , Linux Team Subject: [PATCH 2/4] serial: core: Add option to control rs485 RX_DURING_TX by a GPIO Date: Wed, 26 Oct 2022 18:50:47 +0200 Message-ID: <20221026165049.9541-3-cniedermaier@dh-electronics.com> X-Mailer: git-send-email 2.11.0 X-klartext: yes In-Reply-To: <20221026165049.9541-1-cniedermaier@dh-electronics.com> References: <20221026165049.9541-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-20221026_095332_150680_D38C9818 X-CRM114-Status: GOOD ( 16.14 ) 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 the use of the rs485 feature RX_DURING_TX controlled by a GPIO. 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: Marek Vasut Cc: Linux Team To: linux-serial@vger.kernel.org To: linux-arm-kernel@lists.infradead.org --- 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 179ee199df34..63150d922aa1 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 d657f2a42a7b..b4cdeb6e952a 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; /* Controls RS485 Rx enable during Tx */ struct serial_iso7816 iso7816; void *private_data; /* generic platform data pointer */ }; From patchwork Wed Oct 26 16:50:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Niedermaier X-Patchwork-Id: 13020922 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 81567C38A2D for ; Wed, 26 Oct 2022 17:24:25 +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=PuMMJaBC/x/dK2lg0o+5ULvHb0C+U7OB6/g83zF40VQ=; b=mI7Oa29ZPzfm5q PuxY4l+aY4YsPIB1ZUYqaY2sWvK84PMs58Lkj2D/vWAyD1t07Di4smOJo9ghvDRBXkog+/A6i83dz y6rvHHcAwDAKlib7aX218qI+LC5vkTIsNnwYIoA7URDCZhCabLvo/7CwEARIgr4AjTxjgOHEvErKI OdysvJGEIDo3ZQI5LQsgNFW/KqAcjTafqY8fklhaH6nHO384d0v16YDRYkVaw2VEUeh724YYuYUdM 7SQUqHik9aPqQVceqs0oIe7sR9LFaKZKe5YvQAP7Jy2xS9KIdIktPGc04RQ9CYowcCsVBMVKRZ1nI 26VBvXXvEeFM7XwuQ+tA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1onk7Y-00ALKc-9W; Wed, 26 Oct 2022 17:23:16 +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 1onk7T-00ALHT-3g for linux-arm-kernel@lists.infradead.org; Wed, 26 Oct 2022 17:23:13 +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 67F545DCC6; Wed, 26 Oct 2022 19:22:35 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dh-electronics.com; s=dhelectronicscom; t=1666804957; bh=7bASoVJYWw0nTMzLn8cj2xEolAZJM/TyDIkS61tWXuk=; h=From:To:CC:Subject:Date:In-Reply-To:References:From; b=V7jVUhyLTxOjnPArByEhFDEamM69r3l7rA9Z3iohzeffduMrP7fmH5Sh1DSBqamNc a07oUJ20B/oE6hY6nSR1YAdEwgnq/ECX6q7msrTrzZCQLCOVdPo/OMPqdmmmjCAGe2 0vKQehkCZWU1tkAcdLGIDpBmzcmoj4f8hqbu444QAiEcmxiLsA/8p5UYi1KcXVGWiJ rr26RX8JStZwfLgzEunHtPKWtzOw4XP+4CiQM0bAnecV6HYMziwNb2Ilgh80NwUAjM rnXpdEfZCDz4O2ibYYUS4KVEKhMoDnz9gmPPGaKMNqrmOXCIShymN5fpgfEHxgmxoG H80sMcRNoZhNA== 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.15; Wed, 26 Oct 2022 18:52:20 +0200 Received: from localhost.localdomain (172.16.51.8) 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.15 via Frontend Transport; Wed, 26 Oct 2022 18:52:19 +0200 From: Christoph Niedermaier To: , CC: , , , Christoph Niedermaier , Greg Kroah-Hartman , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , Linux Team Subject: [PATCH 3/4] serial: imx: Add support for rs485 RX_DURING_TX GPIO Date: Wed, 26 Oct 2022 18:50:48 +0200 Message-ID: <20221026165049.9541-4-cniedermaier@dh-electronics.com> X-Mailer: git-send-email 2.11.0 X-klartext: yes In-Reply-To: <20221026165049.9541-1-cniedermaier@dh-electronics.com> References: <20221026165049.9541-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-20221026_102311_512251_07A4304E X-CRM114-Status: GOOD ( 17.37 ) 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: Fabio Estevam Cc: Marek Vasut Cc: Linux Team To: linux-serial@vger.kernel.org To: linux-arm-kernel@lists.infradead.org --- 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 05b432dc7a85..16f8baaf4f12 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; } @@ -697,7 +698,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; @@ -1931,6 +1933,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 Oct 26 16:50:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Niedermaier X-Patchwork-Id: 13020927 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 24B64C433FE for ; Wed, 26 Oct 2022 17:39:13 +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=xocMmUEkM639ZgEYp41UC6gg/T0pKa3vSuDCKlZ6Ilk=; b=NRNliFkCs8Vqw8 SF00MGQZCYV7XZSJHHnCIYK77OZc5kK3TB2ZpqAbfpjoOA1RCHm+LSaBn2Qo8B3suFc5Lj18sv0cP U0n//puXWtRxIAwXiHpOQNmBdZxkm+mnAmHacnKkgO+50FN7UxUOu9s3Ge0shjLV4bG/r6cAXFfHS RbGuIhWLDaWrPpSqX6tBTZIUXd7WPBHZEe0Jt32mLGmh6wgcL+DGkBWBwG5UIDrYXC/n4+WIvaNng f7SEd1Ae9thNkL5joRF5ETx1AZKlVNZCVE33dOIGhm8BgHc57F4lrVkkpCkTCOqlfLaTuzC1jui6c +Rlgh/CgVORZMSjdg/2Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1onkM8-00AP9y-Bb; Wed, 26 Oct 2022 17:38:20 +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 1onkM5-00AP8Q-3E for linux-arm-kernel@lists.infradead.org; Wed, 26 Oct 2022 17:38:18 +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 DD3A75E898; Wed, 26 Oct 2022 19:37:38 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dh-electronics.com; s=dhelectronicscom; t=1666805859; bh=TmMyXjcM0YsNPNvSSd5+dJKufXYGQ0pbaGROlQHD9IE=; h=From:To:CC:Subject:Date:In-Reply-To:References:From; b=GxJf0zvnl0KTpx/0pucbPmBQKBITUWdxmwkTOJH53+8vAEvqnD2SVfGlGTku6G4OM fPnxiHqLDzfxB176zJj2TDCnjU6IpLzfcFjXWzdNqjiBlnPDolTO4eNAxRnf+iOqqx 3jnshxwyQtQ6BZxdZyiXQRpq+dGDxDxmR2QlQ9AuCrnNbfdjdGAo9MN3fgl5hF3YGx s+LF5zdSfuTPGnlwY7SRCoU6CGM+rTfDRc9jNorZgiH6eE7/SlHtSX2zQIDnhCaMNS rsTOMY0BRcKtgbizCJom3OAon6IJwZunaKybGQLsDgP/pVUYCoET04keyOkFwAx2vO EVnBQO8uGVRSw== 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.15; Wed, 26 Oct 2022 18:52:21 +0200 Received: from localhost.localdomain (172.16.51.8) 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.15 via Frontend Transport; Wed, 26 Oct 2022 18:52:21 +0200 From: Christoph Niedermaier To: , CC: , , , Christoph Niedermaier , Greg Kroah-Hartman , Maxime Coquelin , Alexandre Torgue , Subject: [PATCH 4/4] serial: stm32: Add support for rs485 RX_DURING_TX GPIO Date: Wed, 26 Oct 2022 18:50:49 +0200 Message-ID: <20221026165049.9541-5-cniedermaier@dh-electronics.com> X-Mailer: git-send-email 2.11.0 X-klartext: yes In-Reply-To: <20221026165049.9541-1-cniedermaier@dh-electronics.com> References: <20221026165049.9541-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-20221026_103817_398618_BF13ACD1 X-CRM114-Status: GOOD ( 14.92 ) 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: Marek Vasut Cc: linux-stm32@st-md-mailman.stormreply.com To: linux-serial@vger.kernel.org To: linux-arm-kernel@lists.infradead.org --- 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 dfdbcf092fac..91ff6d386932 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);