From patchwork Fri Jul 19 08:47:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Organov X-Patchwork-Id: 11049877 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4EE9714F6 for ; Fri, 19 Jul 2019 08:49:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3E61A28884 for ; Fri, 19 Jul 2019 08:49:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 31E64288E0; Fri, 19 Jul 2019 08:49:01 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id C76D028889 for ; Fri, 19 Jul 2019 08:49:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=v7Zw6hEc5ikjieqvIQ9Jm80MIFetcZZThMKvimxDXzg=; b=lm2FaIPv7Bq9fVXmBzwmQpaquF TVjb0bIoD4/3kXVsag3H5/7C9g0z2gL5jrgg5PBDhyF/Zpl2IQ52Cb2SIOHyzBV3FHzE2bH8BAT4R PUdmf/+wxD0keV35wYBA4fgq2y6Wh4NjYAUB/ls43klMXes52FmDQi1BAvhTH05fGp+Qu4T2KjJ+k u6pfSBdgyGXpnp6s7hxGlQ2plDsoitUltq+cp2ttKlQHvWmZ9ISql1f/EcFlhpmGfqCTs7mk1YENw zdopBphEARKEZwuwOrCnyIHT2RFxJexLz8cAsHiEZey1EKBgZUpYUsJeNw6RSH9YovjhXkAa7iXom 7Ba7mqIg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1hoOZT-0000xj-8b; Fri, 19 Jul 2019 08:48:55 +0000 Received: from mail-lj1-x241.google.com ([2a00:1450:4864:20::241]) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1hoOYp-0000Ff-1R for linux-arm-kernel@lists.infradead.org; Fri, 19 Jul 2019 08:48:16 +0000 Received: by mail-lj1-x241.google.com with SMTP id p17so30047672ljg.1 for ; Fri, 19 Jul 2019 01:48:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=CKEfXVruFdZBhIgkyanOgCxjpHC1q3hmrulsl0t52XY=; b=WCTAmUGDqvk//uRjsx4yNZwDWCEZaUh9EqQ5WAyIJ61y63JhMrT4/rmPTjZx605sRM gEsSMkEGNCNlBoDbQ3VHnyKQPwI4x0j4unKXn//7+8rGand8vNpSVY9eSBiH/1QIWhU6 yrG0+bqFN/YCtCGyjxPfkWs4v8X9Ni6K7Urs7swOksTuqqPDbx9Yun/1CnoUNTx3g/K2 J/Lp74oUkzFaaGM6odKQKyBjQgmuF+KbXustr9/eNRpp+/fn9u+W5b+KDWJtlc8Zgfhs 5L+6ddrVo3gI+3QbD88Axaif551DaRuwWChS0hidEFYZIjM4zEmqi4ExOMVeV5Vf0OTT N5gQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=CKEfXVruFdZBhIgkyanOgCxjpHC1q3hmrulsl0t52XY=; b=FfuWxh1VNx/Dbn/mf+EbJHvQIrDp8/1AMRH17mHOGC4YLojiQXAA6PP++ueWfgxVS4 I+/a4tFjpn+ddOAKEEU3LiEPILmRVWM9uN/yxTeArkFM2tfmdWRQ6sNOlVcfXs2hRk3K FzxDMJobS8NVktH0GkzFsTAXJJmzVA7S6ebI6jbLwFcfZ9Ahy+EbnlEZxAehgg6L9rd6 PSbfGbWtW6hvl+R/ECdo9hPTOP4BDr/1skFfCeV8pJbhYVHscUJIDZ7ywTYtlayR7yEJ OTTlEa1O8sL9pKDYREgSF+PmQpLv+R5fHXaw3aWO8qhwyzEPnynPgfLG3pDbCfq6T/l+ 8+WA== X-Gm-Message-State: APjAAAVKK7jxVZvfomxtUD8+Z2t5+3UriYUqm+/4o7aTtYEW+axSfIqX CsrsJJanBt+EExPd5Nc+laQ= X-Google-Smtp-Source: APXvYqwDLMEJw/biWbIx3p9NfsGu/4MNp8AGQDzrNPIyoiDgfhVgD2DB93aCbDYl/FyEaHqnyg6UuA== X-Received: by 2002:a2e:3807:: with SMTP id f7mr13452098lja.87.1563526093353; Fri, 19 Jul 2019 01:48:13 -0700 (PDT) Received: from osv.localdomain ([89.175.180.246]) by smtp.gmail.com with ESMTPSA id s21sm5588742ljm.28.2019.07.19.01.48.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 19 Jul 2019 01:48:12 -0700 (PDT) From: Sergey Organov To: linux-serial@vger.kernel.org Subject: [PATCH v4 2/3] serial: imx: set_mctrl(): correctly restore autoRTS state Date: Fri, 19 Jul 2019 11:47:53 +0300 Message-Id: <1563526074-20399-3-git-send-email-sorganov@gmail.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1563526074-20399-1-git-send-email-sorganov@gmail.com> References: <20190614072801.3187-1-s.hauer@pengutronix.de> <1563526074-20399-1-git-send-email-sorganov@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190719_014815_082262_C997A3E1 X-CRM114-Status: GOOD ( 13.72 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Greg Kroah-Hartman , Sascha Hauer , Sergey Organov , NXP Linux Team , Pengutronix Kernel Team , =?utf-8?q?Uwe_Kleine-K?= =?utf-8?q?=C3=B6nig?= , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP imx_uart_set_mctrl() happened to set UCR2_CTSC bit whenever TIOCM_RTS was set, no matter if RTS/CTS handshake is enabled or not. Now fixed by turning handshake on only when CRTSCTS bit for the port is set. Reviewed-by: Sascha Hauer Tested-by: Sascha Hauer Signed-off-by: Sergey Organov --- drivers/tty/serial/imx.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c index 95d7984..34d61c4 100644 --- a/drivers/tty/serial/imx.c +++ b/drivers/tty/serial/imx.c @@ -970,10 +970,22 @@ static void imx_uart_set_mctrl(struct uart_port *port, unsigned int mctrl) if (!(port->rs485.flags & SER_RS485_ENABLED)) { u32 ucr2; + /* + * Turn off autoRTS if RTS is lowered and restore autoRTS + * setting if RTS is raised. + */ ucr2 = imx_uart_readl(sport, UCR2); ucr2 &= ~(UCR2_CTS | UCR2_CTSC); - if (mctrl & TIOCM_RTS) - ucr2 |= UCR2_CTS | UCR2_CTSC; + if (mctrl & TIOCM_RTS) { + ucr2 |= UCR2_CTS; + /* + * UCR2_IRTS is unset if and only if the port is + * configured for CRTSCTS, so we use inverted UCR2_IRTS + * to get the state to restore to. + */ + if (!(ucr2 & UCR2_IRTS)) + ucr2 |= UCR2_CTSC; + } imx_uart_writel(sport, ucr2, UCR2); }