From patchwork Mon Jul 22 19:22:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Sergey Organov X-Patchwork-Id: 11053337 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 F2B96112C for ; Mon, 22 Jul 2019 19:23:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E5C5F2837D for ; Mon, 22 Jul 2019 19:23:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D9A8228508; Mon, 22 Jul 2019 19:23:00 +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 8A7932837D for ; Mon, 22 Jul 2019 19:23: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:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version: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=s8X9OpMLQDlHWYn39tJVt26AoFhfwjKZ5a9pPAf5qkU=; b=pIGkF8sIMRhEP0 +b3IEe8aft36m5YIWlskDl3CRrgcfVpY2Sj8m2EXMdbsDmuIXB5sHFbh6DGmh6nI/bmkNlvTbeTlj iNlsXA4l1cZ0SKH4HlpaCVEurs5CY0W3BqgK7suRKw+TB8WIPGFSSbSjINMfC7GHjHsvBQKu7BZS8 PqMNoV4pxseKb8iXt6xhEcc4y9cReESlNQPffOOstNXIC/StOd7/kRd1JH/k/S+dKq6dpbdIrVA5O tGPodDjujdZby+B38Ujf7k0iE5shd6TR3BZL4dd3woYMftetBUMkPyeDCj9QY2T6lNhztTDG/PWDY TL9P+ids6u5L6alFgkuA==; 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 1hpdtj-0000LW-0L; Mon, 22 Jul 2019 19:22:59 +0000 Received: from mail-lf1-x143.google.com ([2a00:1450:4864:20::143]) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1hpdt9-00009M-9f for linux-arm-kernel@lists.infradead.org; Mon, 22 Jul 2019 19:22:24 +0000 Received: by mail-lf1-x143.google.com with SMTP id p197so27461966lfa.2 for ; Mon, 22 Jul 2019 12:22:23 -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 :mime-version:content-transfer-encoding; bh=wnit4p85ORmgfnZn4hAkBjNauy9f4K7ibUxB6LLunYI=; b=OUXCvoenllByUjPJujE3BRthxEaq55rjTdMdDKZp1dI1QYrJTD2K8yttKXVEoegkQL S5TEfmkT0MGc9WDr6KJrdjXGkCsrYMQDp9Z4/n8X7I4PNIdtNP0IW1v1q5HLSytSq/ME c7+Hz9PGlgCvXv/XMZyoXv5XTIx0Z99iD9yGwJIQvDQ+Rh6DAf/9Kgn+jo/c0rLjhOFC 3ifUNZTT9BKarFYuliptX8RhH1F3Oz2hSge3fxjwKJIyANBBy2z1VHE/NRJ9d/td9H7w +CdL0YySrgG8y3EXrz4n8d9JArm9kQ5VizLJXDawq1AbcZYduiTn0+avPqmNuhh/ZSZU XmZw== 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:mime-version:content-transfer-encoding; bh=wnit4p85ORmgfnZn4hAkBjNauy9f4K7ibUxB6LLunYI=; b=j6mDTO/sKDSOYl/sfqCJadShJ5EmPZoJkRT5ScyM+5CJ8O1jztkakld1vlAhclOloO FdjXNZFO0LGFBQBVfcxvQkuwfDOiklW+oMxr3FrEyxhvOIb3d/IP8CbjYAsV27L2yyZG Hpk0NsAJc7TkCG22xJgDXq86nAtsMrq/oGdABF3I7CIf96E6G45c+aNtzfOLzpEjjagN gHg7ssS2dq9VP8p2Wck2K8S4qfJRw14KctoHTzMYwOHqgL0YpH4vZFNKQY49RhkOyLnN AdwFEWQRfgtR1B1MF78hKDLHQ8PuMFpeXbQC57XTHNWDySQDoPkp5NICJld8zkSGjTlb TYQw== X-Gm-Message-State: APjAAAWu/xRCslCv+X6sMHMZgHDoxFPt4cejwFTnXR4dqbY6vXphB52t 5aL+iawFKkbX1XpbYF14Gx8= X-Google-Smtp-Source: APXvYqzMcAxtvEzeZaLbMfwbcBn9qKi7e4zuAuT1RxXDnSo2B3PtPcOpAQp3OSoAIKssKwyHOq2Ljg== X-Received: by 2002:ac2:563c:: with SMTP id b28mr20156125lff.93.1563823342006; Mon, 22 Jul 2019 12:22:22 -0700 (PDT) Received: from osv.localdomain ([89.175.180.246]) by smtp.gmail.com with ESMTPSA id n124sm6129307lfd.46.2019.07.22.12.22.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 22 Jul 2019 12:22:21 -0700 (PDT) From: Sergey Organov To: linux-serial@vger.kernel.org Subject: [PATCH v6 2/3] serial: imx: set_mctrl(): correctly restore autoRTS state Date: Mon, 22 Jul 2019 22:22:10 +0300 Message-Id: <1563823331-5629-3-git-send-email-sorganov@gmail.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1563823331-5629-1-git-send-email-sorganov@gmail.com> References: <20190614072801.3187-1-s.hauer@pengutronix.de> <1563823331-5629-1-git-send-email-sorganov@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190722_122223_344722_56474302 X-CRM114-Status: GOOD ( 13.75 ) 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 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. Acked-by: Uwe Kleine-König 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 32f36d8..059ba35 100644 --- a/drivers/tty/serial/imx.c +++ b/drivers/tty/serial/imx.c @@ -974,10 +974,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); }