Received: by 10.192.165.156 with SMTP id m28csp1274943imm; Wed, 18 Apr 2018 07:09:20 -0700 (PDT) X-Google-Smtp-Source: AIpwx49KgsYROpkzZGyHL6JT/O74ynd7+zlskYrwJ6DbAYU9hmplDgz78n5OF1XJ8P6n3pPcHQyD X-Received: by 10.99.138.202 with SMTP id y193mr1884884pgd.224.1524060559988; Wed, 18 Apr 2018 07:09:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524060559; cv=none; d=google.com; s=arc-20160816; b=CYwLi2A4NMOTtKihg88xVCBPuh+nUQr85Nt/yHkCzQvaG5yFYFUGmjqkbUcoYXZDt5 7yvtF/zewHeQucG+T+Nsitdy7xaRoC2MnaGw9/QKwtqk2t7/xlgyv4QUB/dvb2B2eQEg 29H52GnCrlY9E/KhuwuXvK1Y2GECGBPm3me/1PdITN1wCW6ZkY0bdkXCpFQoRx7AbtVL eYnqOAtwohsSIXHNptLcqw5qd4loeRe6/OYOfqipuKeRklvVmc30xe7in3yHqeRfry33 DTs0IZind5fX9qde1YCQTHaZoz9/swhTn+0kweF70k9ooMIAd9Kad8h/UHoFOWHJJnWN STwg== 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=zJYPYT83kKYfKSC+/tocWeA/onKktDgr80VCv0SqADc=; b=kbo+nyUS8SqSG4mnUSeyER/6qSQDlJoS2phzwqNtuIHRip4s8ieUbnLIqAr07+zQkr Z/Owp3lqvwNjwmerO8HXoea5tkeyBRgqm/tUJYkm8F6TmP2rBCA1lXIbhlzkD5SyCKNY GV6oA5BzWnDCHPyjOcul6Man26liHYLdhCcKG+y/x5vPOHe9SVGZigJPu8W5B/fVHJtl 4q0gY1/tSPv6KeiwUz//GMaNzSMkisriDLosdS3wyitd+tNcaJoPy/ogTEJMtfOFjoBF 0NCY+erK6XeVpRgPSTliG27WkYGV7Uo0PbTCuGPZlrInd2u2PC/dJPIJryG+KctWcVRO ymfA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@agner.ch header.s=dkim header.b=S6E17FCL; 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 m72si1234352pfi.236.2018.04.18.07.09.05; Wed, 18 Apr 2018 07:09:19 -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=S6E17FCL; 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 S1753551AbeDROGp (ORCPT + 99 others); Wed, 18 Apr 2018 10:06:45 -0400 Received: from mail.kmu-office.ch ([178.209.48.109]:37254 "EHLO mail.kmu-office.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752649AbeDROGn (ORCPT ); Wed, 18 Apr 2018 10:06:43 -0400 Received: from trochilidae.toradex.int (unknown [IPv6:2001:1620:c6e:10::3]) by mail.kmu-office.ch (Postfix) with ESMTPSA id 567435C04C0; Wed, 18 Apr 2018 16:06:41 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=agner.ch; s=dkim; t=1524060401; 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=zJYPYT83kKYfKSC+/tocWeA/onKktDgr80VCv0SqADc=; b=S6E17FCL9MAOnIyM4ma3nTD7XiBSsWwMsJw7SXF1vz3zLoTGa1xx86UTvGz2heK9yg+msI EeQHEwCzE1srYiGwVjTp4dVngdg/WtUWUn0QhTKqMCb1eioTnROSmrh24VjED0cRjxsR6I ZsUEYj0gAWsOfnSBxnsMhWzHZmCOXAk= 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 v2] serial: imx: warn user when using unsupported configuration Date: Wed, 18 Apr 2018 16:06:38 +0200 Message-Id: <20180418140638.19331-1-stefan@agner.ch> X-Mailer: git-send-email 2.17.0 X-Spamd-Result: default: False [-0.55 / 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(-1.45)[91.34%]; 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 --- 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; + /* disable transmitter */ ucr2 = imx_uart_readl(sport, UCR2); if (rs485conf->flags & SER_RS485_RTS_AFTER_SEND) @@ -2265,6 +2270,16 @@ 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