Received: by 10.192.165.156 with SMTP id m28csp1238455imm; Wed, 18 Apr 2018 06:33:57 -0700 (PDT) X-Google-Smtp-Source: AIpwx48Rnb8W9IwU92HtsV+XbNvFBOpUITDgwur0r6kGLYOFLGG4X3+MPMQ9f8CjDAQHo2Tu57mx X-Received: by 2002:a17:902:7290:: with SMTP id d16-v6mr2128021pll.43.1524058437467; Wed, 18 Apr 2018 06:33:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524058437; cv=none; d=google.com; s=arc-20160816; b=poHJBQ96m6IMJggT2TxSTo+LZ8GC3ee8w9YDWYtUrxEp/MrYljw0okUlsdv4QtM6yh tm2+KtwWe4BHin5mcIyhVfz9K8Li+HTYoo0fzl132eKuPKw0Z/yV04T2eU2NYj+nbm9x vf/XMSn5uc5/EkHOTv7FZhGQoZZOwp3zeBhkki/KjGAr58YwGAYZD3ihmqkdu24z+RNU D2LE59CFYnBIxHYWM3HlvNAaz75EUk94HGR9eun9LxSNsEJPTuiuNb2Isn3pe94RYwrw vu00xdiW4Ayqqcay4VIunMkceMbhdHF6up1IPjp0TH/tESaViKVhfh2S185EVvpDRtQB sHCQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=gAi0X/HppQ5e5aCHyUihpcy96s2UELH5PUOtxEDXJlA=; b=Be5y78yb5PeH0jv62zgmT0/KL4e8S7lnBdJoOfye8XxGLRu3cyMQB/SZ/hX7TtCfnL UZpUsh3VNIcYxFSRdvlV3fv7uSYIMd/1AjHkud8cZ8xQ9rTqJ7skn1CCF79pA7Hw517r QcgEyDT+hdcNPwCUdSHCDUsLdjBT1N88xiE9PyapK4YCmhSkS3KvFqAPRngn8vQqnZEW GLxNeHSsL4wvSFhGVDQYBYiLXG6tGvyvlQDPLOBlDoKbE9fLyqc58m8bjOE9gJKBDV5y huJ1gAS/37IJm4Yr3K4e0+ecYWXC1cDJGMmral0AHTZzhMmMquTMLpnG96pOKwUhNibe I/tw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@agner.ch header.s=dkim header.b=c4TzRVOg; 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 k2-v6si1217170plt.406.2018.04.18.06.33.42; Wed, 18 Apr 2018 06:33:57 -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=c4TzRVOg; 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 S1752696AbeDRNcY (ORCPT + 99 others); Wed, 18 Apr 2018 09:32:24 -0400 Received: from mail.kmu-office.ch ([178.209.48.109]:36878 "EHLO mail.kmu-office.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750872AbeDRNcW (ORCPT ); Wed, 18 Apr 2018 09:32:22 -0400 Received: from trochilidae.toradex.int (unknown [IPv6:2001:1620:c6e:10::3]) by mail.kmu-office.ch (Postfix) with ESMTPSA id 3F80D5C04C0; Wed, 18 Apr 2018 15:32:21 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=agner.ch; s=dkim; t=1524058341; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:content-type:content-transfer-encoding: in-reply-to:references; bh=gAi0X/HppQ5e5aCHyUihpcy96s2UELH5PUOtxEDXJlA=; b=c4TzRVOgyiIAuk27DwFEwWU9cFDR4KnKwYiq/A+ou7ayCbakHAw9ywX5GMt0RFjURs2ayE +KUR1dWKNftUzE63bnOeUm30ws6mkj2f1bnmMPWi9NmGFwFMSmyx11Sep9YeAvsOMryEzQ FypOw8335SUllYM+wuJNG/S+spuBs3M= From: Stefan Agner To: gregkh@linuxfoundation.org, u.kleine-koenig@pengutronix.de Cc: lukas@wunner.de, jslaby@suse.com, linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, Stefan Agner Subject: [PATCH] serial: imx: warn user when using unsupported configuration Date: Wed, 18 Apr 2018 15:32:17 +0200 Message-Id: <20180418133217.14568-1-stefan@agner.ch> X-Mailer: git-send-email 2.17.0 X-Spamd-Result: default: False [-2.06 / 15.00]; RCVD_TLS_ALL(0.00)[]; ASN(0.00)[asn:13030, ipnet:2001:1620::/32, country:CH]; RCVD_COUNT_ZERO(0.00)[0]; FROM_HAS_DN(0.00)[]; MID_CONTAINS_FROM(1.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.96)[99.85%]; ARC_NA(0.00)[]; DKIM_SIGNED(0.00)[]; RCPT_COUNT_SEVEN(0.00)[7] Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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..1ba7e98ddc76 100644 --- a/drivers/tty/serial/imx.c +++ b/drivers/tty/serial/imx.c @@ -1833,6 +1833,10 @@ 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 (rs485conf->flags & SER_RS485_RTS_AFTER_SEND) + rs485conf->flags |= SER_RS485_RX_DURING_TX; + /* disable transmitter */ ucr2 = imx_uart_readl(sport, UCR2); if (rs485conf->flags & SER_RS485_RTS_AFTER_SEND) @@ -2265,6 +2269,17 @@ static int imx_uart_probe(struct platform_device *pdev) (!sport->have_rtscts && !sport->have_rtsgpio)) dev_err(&pdev->dev, "no RTS control, disabling rs485\n"); + /* + * The RTS (CTS_B) signal cannot be set low during transmission + * in case the receiver is off (limitation of the i.MX UART IP). + */ + if (sport->port.rs485.flags & SER_RS485_ENABLED && sport->have_rtscts && + (!(sport->port.rs485.flags & SER_RS485_RTS_ON_SEND) && + !(sport->port.rs485.flags & SER_RS485_RX_DURING_TX))) + dev_err(&pdev->dev, + "low-active RTS not possible when receiver is off, " + "enabling receiver\n"); + imx_uart_rs485_config(&sport->port, &sport->port.rs485); /* Disable interrupts before requesting them */ -- 2.17.0