Received: by 10.192.165.156 with SMTP id m28csp857993imm; Thu, 19 Apr 2018 08:41:02 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+FnBfjR0AIlXnsAOsW+KN7zwwyr7DYUuMX523S7EfeG/JIE/+C4KlXJwDQ5acWOTdHr9KJ X-Received: by 10.98.214.218 with SMTP id a87mr1863584pfl.200.1524152462007; Thu, 19 Apr 2018 08:41:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524152461; cv=none; d=google.com; s=arc-20160816; b=mMTZF+MEJ4s0ZuBzgd2XjfO1o3nJLjq5fJCGfXCnZXKsk333j+4xTt6flljA6IBuju oSAo9EIl9fVKjx/A0/rvFA/XjmZDp1IzajZyUefhGgIsGdHPHXID99yHL1OOE3nYgw4M Zwk4/x1+WHs+bhZS2niHp97GjMd88aSAtgORuYrx48Of6iVV9iYg/eyKOMmcynM141iV usQtOmWiXfIi8zoSvqgqXIva0DdpqXGVg4K+L2HZfFuqt93XmKQdbXv34GhVVdLThLoB BRgE4ODxeQzPmEV2bAosgEbTT75zcYUv4qttobf4OtnJdYZdM/UqjUCdRe2jvOKZjeE9 Bqmw== 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=Vu0uYOcRvk+/DMLWEfpg0IGK8oDyiCWKh1AddMSZVX8=; b=pVwA9p5aN6JnbL0YKrDjtV/6xwyXmcJOi/8NY5p810IZZQx/Ua+K+Y1avLD9UcphEt 2QQ3ciikQtWTm/Pm+ioz0dkTLX8X02E+FSAhgYrdkJAqCUPTPYvU3M6LV3zx39tlVR4o +s2m6WeYB9G1OVG8gMzbW4vMlsXjbFkJZR7ClZCsQWhSfYkku//WxClrLbbYFQigRdBu kHVPuGTDaFd/g9gukPGJM2HCXIQC9Wp3WfX2PmY8iYQcCrna5QS8+XbMOILRZYqVONeB YuVpn4vlhfoWlHJLlMq/auzutQQwZbvDUN7c1SuUwbUhVw6Tm7MX1bqdX8BRgii/tTOn 67KQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@agner.ch header.s=dkim header.b=YYoR4L/L; 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 8si3457854pfv.115.2018.04.19.08.40.46; Thu, 19 Apr 2018 08:41:01 -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=YYoR4L/L; 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 S1752953AbeDSPj1 (ORCPT + 99 others); Thu, 19 Apr 2018 11:39:27 -0400 Received: from mail.kmu-office.ch ([178.209.48.109]:50472 "EHLO mail.kmu-office.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752644AbeDSPjZ (ORCPT ); Thu, 19 Apr 2018 11:39:25 -0400 Received: from trochilidae.toradex.int (unknown [IPv6:2001:1620:c6e:10::3]) by mail.kmu-office.ch (Postfix) with ESMTPSA id 476CB5C036A; Thu, 19 Apr 2018 17:39:23 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=agner.ch; s=dkim; t=1524152363; 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=Vu0uYOcRvk+/DMLWEfpg0IGK8oDyiCWKh1AddMSZVX8=; b=YYoR4L/LFqsIgNY276BTfyHXaRjO6qN2P3H1dfHzNdOi1xRQdKHsbr+SSbss6z5BgeMMhw iZzbrxKbcas8EnOvNYMKQFcuppvtAiPF6WkZu5WA4UcSfiezl22F3+9VmbYoglzT2/orx1 0f8a5sDK8f5bjthbNdwswnu37Gc5MLg= 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 v3] serial: imx: warn user when using unsupported configuration Date: Thu, 19 Apr 2018 17:39:16 +0200 Message-Id: <20180419153916.21898-1-stefan@agner.ch> X-Mailer: git-send-email 2.17.0 X-Spamd-Result: default: False [-1.80 / 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.70)[98.69%]; 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 when using i.MX UART RTS/CTS control. 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 | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c index 91f3a1a5cb7f..65d7a2bfb6d2 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 && !sport->have_rtsgpio && + !(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,18 @@ 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"); + /* + * If using the i.MX UART RTS/CTS control then 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->have_rtsgpio && + (!(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