Received: by 10.192.165.156 with SMTP id m28csp1365461imm; Wed, 18 Apr 2018 08:32:39 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/MLfWpIGl7SlisI/CPvYDox7DVTxRr6wtMpG6c6TKwcYfWFyZ4beLJPJMHdLecY5wYR0zm X-Received: by 2002:a17:902:a5c2:: with SMTP id t2-v6mr2531572plq.360.1524065559908; Wed, 18 Apr 2018 08:32:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524065559; cv=none; d=google.com; s=arc-20160816; b=DFvGJfkU/AbryHvELhaJ9dPGLxmWoF839Nt0MwLR4HhZ7DcNOG1rl8ESMB0e6zP5TB gHokJXejizR67fcHq+1n3MDQnQuA/Ub2OoEw7AxXvmiXyLouD2uKF9MHpjJn4OANPEC8 v3L8gbxmb2omaYmLCnyEJpsa2RlSO8/IQQALk05FwwmBuWepg42RWZ88gW5FiDh7Pcl1 flpeKEZ4NMHoHwa/F3xO5dOfvSekOJer7z03YZkLIJ0zOwIOC5IwbiVZ0DOvIsC+/Upe 6ubNK4EUsIZunUnpBn+Epkv6UQymLHfu+vc49dQYD+GxlsuHonGNhOIoGM8uMBKSZX8M NAEA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:message-id:references :in-reply-to:subject:cc:to:from:date:content-transfer-encoding :mime-version:dkim-signature:arc-authentication-results; bh=f/RZf02aBINtHvdKEWxHEK99UpUvnSXoUl6QwBgVCV4=; b=csxuBUwYQ28W5qp/xryBkbcIrey371zxeRyvZTgKHsvSb2PVcy0h0uEeAvSTMoQUpz v1422oUwcCPtVYv7MLoW6GmjuXNfgbVBWmpC/8c/it0m9DolFGgEQLTEc5ETjOQGuyRz HFqGYAQuYl3w4ba8rF75NTgDiebCx4LpxZIATDeDHQNYnucf6aib9yg42Un4T5AaOsVd rStCtEHAYPzScpRDllQebQ+OY/m0q03V/16JwwDTS89hp4ZDpXD4RqXVY2Eh/Tp6xqqg RfPC4E0fPgUgiJs9jtQKK+pUCCidmiu/Mlpd+hwGNUrznUbYjmP7ApTQ/b9YDwq1x6Ki yEIg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@agner.ch header.s=dkim header.b=FPkJZQXz; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v6-v6si1547018plp.31.2018.04.18.08.32.25; Wed, 18 Apr 2018 08:32:39 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@agner.ch header.s=dkim header.b=FPkJZQXz; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752913AbeDRPat (ORCPT + 99 others); Wed, 18 Apr 2018 11:30:49 -0400 Received: from mail.kmu-office.ch ([178.209.48.109]:38282 "EHLO mail.kmu-office.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752634AbeDRPaq (ORCPT ); Wed, 18 Apr 2018 11:30:46 -0400 Received: from webmail.kmu-office.ch (unknown [IPv6:2a02:418:6a02::a3]) by mail.kmu-office.ch (Postfix) with ESMTPSA id 15D435C055E; Wed, 18 Apr 2018 17:30:43 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=agner.ch; s=dkim; t=1524065443; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=f/RZf02aBINtHvdKEWxHEK99UpUvnSXoUl6QwBgVCV4=; b=FPkJZQXztduyZwVa2CejdVSpxLxV6KWYBWRsFljJc4C6g7Qw+/cd0op0Vh5dpkQ4cfAtQK WmXqlj3E6zKqMf/tzLzO0GirYjOR53ANFanAkbTuDKkW9uPVkkt/a+rvelP/sACwCfWy/A EJ7jBhhkF/pr17KiH57DbOU2fDQj3hE= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Date: Wed, 18 Apr 2018 17:30:42 +0200 From: Stefan Agner To: =?UTF-8?Q?Uwe_Kleine-K=C3=B6nig?= Cc: gregkh@linuxfoundation.org, lukas@wunner.de, jslaby@suse.com, linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] serial: imx: warn user when using unsupported configuration In-Reply-To: <20180418145341.xwsah7spyfazcb63@pengutronix.de> References: <20180418140638.19331-1-stefan@agner.ch> <20180418145341.xwsah7spyfazcb63@pengutronix.de> Message-ID: <6cdfd27073006d0959c21eca23fa56e1@agner.ch> X-Sender: stefan@agner.ch User-Agent: Roundcube Webmail/1.3.4 X-Spamd-Result: default: False [-2.12 / 15.00]; RCVD_TLS_ALL(0.00)[]; ASN(0.00)[asn:29691, ipnet:2a02:418::/29, country:CH]; RCVD_COUNT_ZERO(0.00)[0]; RCPT_COUNT_FIVE(0.00)[6]; FROM_HAS_DN(0.00)[]; MID_RHS_MATCH_FROM(0.00)[]; TO_DN_SOME(0.00)[]; MIME_GOOD(-0.10)[text/plain]; FROM_EQ_ENVFROM(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; BAYES_HAM(-2.02)[95.20%]; ARC_NA(0.00)[]; DKIM_SIGNED(0.00)[] Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 18.04.2018 16:53, Uwe Kleine-König wrote: > On Wed, Apr 18, 2018 at 04:06:38PM +0200, Stefan Agner wrote: >> When using half-duplex mode (which disables receiver during txing) >> the RTS signal cannot be driven low during transmission. This seems >> to be a limitation of the i.MX UART IP: The RTS (CTS_B) signal is >> controlled by the receiver. When the receiver is disabled, the >> signal stays in UART logic idle state which is high... >> >> If SER_RS485_RTS_ON_SEND is used, RTS needs to be high active during >> transmission. Since this is the default state of the RTS (CTS_B) >> signal when the receiver is off, half-duplex mode in this >> configuration works fine. >> >> However, a low-active RTS signal (flag SER_RS485_RTS_ON_SEND not set) >> cannot be generated when the receiver is turned off. >> >> Print an error if the user selects this unsupported configuration >> (both SER_RS485_RTS_ON_SEND and SER_RS485_RX_DURING_TX unset) and >> configure the closest working configuration (set the >> SER_RS485_RX_DURING_TX flag). >> >> Signed-off-by: Stefan Agner >> --- >> Changes since v1: >> - Consistently check for sport->have_rtscts && !(rs485conf->flags & >> SER_RS485_RTS_ON_SEND) >> - Don't break printed message >> >> drivers/tty/serial/imx.c | 15 +++++++++++++++ >> 1 file changed, 15 insertions(+) >> >> diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c >> index 91f3a1a5cb7f..1c1080fc8084 100644 >> --- a/drivers/tty/serial/imx.c >> +++ b/drivers/tty/serial/imx.c >> @@ -1833,6 +1833,11 @@ static int imx_uart_rs485_config(struct uart_port *port, >> rs485conf->flags &= ~SER_RS485_ENABLED; >> >> if (rs485conf->flags & SER_RS485_ENABLED) { >> + /* Enable receiver if low-active RTS signal is requested */ >> + if (sport->have_rtscts && >> + !(rs485conf->flags & SER_RS485_RTS_ON_SEND)) >> + rs485conf->flags |= SER_RS485_RX_DURING_TX; >> + > > I wonder what should happen, if the device tree has both > > uart-has-rtscts; > rts-gpios = <...>; Hm, it seems that the code controls both in that case. > > . I think the right thing would be to check for > > sport->have_rtscts && !sport->have_rtsgpio I agree, since it controls both one can use the GPIO to have a working half duplex with low-active RTS configuration. Will send v3. -- Stefan