From patchwork Thu Dec 1 11:02:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Niedermaier X-Patchwork-Id: 13061248 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 38FF5C43217 for ; Thu, 1 Dec 2022 11:35:56 +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=11s/oYhCAT1IEfljYMV/4Meh6r1/iTKUrP4uZ5kt28Y=; b=biFB+kszJN9h2p qdOHKJ2CmEcI6yhx9SlvLdDi9sJUUBD/p55j1PGWortaLsDUHgXIkZEn3j1+uN80YF0HqkJtOseDg Oe/8Hj0UsDDAoirKPruz23OJ3ydrkNaPtL3IcJ+5YTxfQXxh5weK9IERNt0BKqMZZCwQS2iN/oLhK xVaE5Jyiig2DWx/cqpvELJz9nR2nA3xXpahZJ2pMbmrF+/kUD9ypN60KAPVAgUZI40CIFsT4055Kc LQHYkD6grW91/2m3EV+iKSyLd4g6RZqOeSTRk1NcWXjXCqK2U9+1hdvHPejGSJZER0k8MfRF4lkkY u50gTpFILvwPThqN4gag==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1p0hqE-0075fx-P9; Thu, 01 Dec 2022 11:34:58 +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 1p0hqB-0075eX-EP for linux-arm-kernel@lists.infradead.org; Thu, 01 Dec 2022 11:34:57 +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 6352F7201A0; Thu, 1 Dec 2022 12:34:19 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dh-electronics.com; s=dhelectronicscom; t=1669894460; bh=9ujjmTadCqgRplD/C+UF7LiiPFXJKdji9P3pRC4ewyI=; h=From:To:CC:Subject:Date:In-Reply-To:References:From; b=depJ/V/kI5LzkGlqKhGXy4IKA60XFdogMBkEyrpXlFe9Ko/QMvNd8NdZ+vdAqIfUr uJxE8MgUnNjJEcyGcM9dxSa55YWc4DXzF4LfNg5K9XSNLonzu15FQ/GrCQUoTlKARO msEwljNySFvJTgnNmAvskptBMzY2QzP4z2MqrTatTmPeYOuZY8Oktxh3zcJat41UCN m1Cr7PTtvTlsYI1XkMsxLk2KNdFdoSnYEZa1A2nn0kLeOlVx4FTPWn5/OHctexgvYJ GBmLQ777wQgMxCCHHF1pDlx3D9ULwDgIRtGANWPPHBwM6pXK+Wmv7JYXDhcIcP50Em Q99x/niPJInng== 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; Thu, 1 Dec 2022 12:03:58 +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; Thu, 1 Dec 2022 12:03:57 +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 V3 3/4] serial: imx: Add support for RS485 RX_DURING_TX output GPIO Date: Thu, 1 Dec 2022 12:02:36 +0100 Message-ID: <20221201110237.7917-3-cniedermaier@dh-electronics.com> X-Mailer: git-send-email 2.11.0 X-klartext: yes In-Reply-To: <20221201110237.7917-1-cniedermaier@dh-electronics.com> References: <20221201110237.7917-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-20221201_033455_732267_EF8AD401 X-CRM114-Status: GOOD ( 17.66 ) 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 V3: - No changes --- 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; }