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);