From patchwork Mon Jul 22 09:22:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Sergey Organov X-Patchwork-Id: 11051861 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 B19286C5 for ; Mon, 22 Jul 2019 09:23:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A00F82847B for ; Mon, 22 Jul 2019 09:23:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9387428595; Mon, 22 Jul 2019 09:23:13 +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 288352847B for ; Mon, 22 Jul 2019 09:23:13 +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=mQQJrY3As+NeBsrD0/S6kY7ui++8QCsGA8daaxGustw=; b=j8aDTyW/y+V4gd ZI33PihY3waLcbBoGtR9xy9YF3GWroXeo9HVwkPgOy1QdWw3g36RUGMRHaitlEnUdu2YMXmx4qo6i 0lMQhGH9DtGc2dJicTQNjF85/UYPUntdU/XS7qYJ9CHtYlW6Q7KzpDzuo5fpK8QSprhgtXmSYxSNQ Yrn1Q2a86SS0+kpME9jjcvk7YkJXXTbM9E9wdSj6G3tXWv91RA8M6SKF+tPV01ryvJjf5zTvFlc/B NCQRHafACkPAX5uVG3OZ/f4OlHBFv6/tg/OTDsYGzqDT/LCD/pR+8FyWz82db8vsqI3OA+Wlp+a6s 5ZpfmXIwxXwlJbi9KlkA==; 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 1hpUXI-0006yM-8j; Mon, 22 Jul 2019 09:23:12 +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 1hpUWV-0005Z0-M6 for linux-arm-kernel@lists.infradead.org; Mon, 22 Jul 2019 09:22:25 +0000 Received: by mail-lj1-x241.google.com with SMTP id v18so36837390ljh.6 for ; Mon, 22 Jul 2019 02: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=HA2f/ifCDrGNgMEk+3HGOD0y69BKIfJxvyiY4pBfCgE=; b=rkiUfHF7VO9LHPZzsQsdyww5l9RzJLCGBPEXFixUlamFHpcZviC1GyG+PGFCV1kfV5 2pw/X06gPcEtd2xBNg4sYqs6Galcx91JalyNsJXvnA0cyf2tmcWAy+OaHTEnTrHKAp81 UQmhlLZ03gKxTuSeE0Sg7s3/Wd9ugLfkJfc+MXWEo+d9e7s+h5872OBuSF57/+BjrXVt QYdVjb67iC0uqfvACfS/8hHNPJou1yuRG3SoM6UOSqqyG3EKll/rUuGa2YOEKyGoUAyv XVE+cTY7SdA2AkRVY+1O22dRjkAcB21FJ8OfqjiR1bQ1ofYDvag8nYU3hy5gRLYOgKKg yZxw== 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=HA2f/ifCDrGNgMEk+3HGOD0y69BKIfJxvyiY4pBfCgE=; b=V8ntcaF2IwZesdSPT7p23m1XgF41MrIh/4ShhYtBqsGIqsRaIAkphzeDaFSH6L3z/h 2D5TjgCAhnNAycAXv4v/1lMgFUtf0Iqwv4DHbZwF6a3+HYIYoCB+k65nTM+3oUP+6J+D O0MABZ6X1woT+V/2Ouw1B2f7jKItXB/2BT25IElLjO8oGbUEU54WFjZGDd7yfJYp7dIa Z06AUSvzXiEfrwFPa9/tdvKI1Z4O3O379TCy92r7/6wadOirQNOkuwY/oXIZCfxr/xNl bYa/BQsMSx4Lp3eeHTxxoL0fFJMCoEEDFDYpgKqPQrp7M1SAVYNsLnoDtmKf3dKB/3Pk I4zw== X-Gm-Message-State: APjAAAU2jKXQlWDckB78XipMwsrq9Y7QIlqPtEUgmyqIbG4VTyOVma0/ vDogs4tTh80TlwTvkxg+Rd4= X-Google-Smtp-Source: APXvYqwHAC3dvb2De+mxHlgp8DFhqzN74V36dBGcVrQ3LpNHmBSOnGLfnvFLH5JXbGLQHaiAKsyRTQ== X-Received: by 2002:a2e:8007:: with SMTP id j7mr35899636ljg.191.1563787341958; Mon, 22 Jul 2019 02:22:21 -0700 (PDT) Received: from osv.localdomain ([89.175.180.246]) by smtp.gmail.com with ESMTPSA id b68sm8425088ljb.0.2019.07.22.02.22.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 22 Jul 2019 02:22:21 -0700 (PDT) From: Sergey Organov To: linux-serial@vger.kernel.org Subject: [PATCH v5 2/3] serial: imx: set_mctrl(): correctly restore autoRTS state Date: Mon, 22 Jul 2019 12:22:09 +0300 Message-Id: <1563787330-1394-3-git-send-email-sorganov@gmail.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1563787330-1394-1-git-send-email-sorganov@gmail.com> References: <20190614072801.3187-1-s.hauer@pengutronix.de> <1563787330-1394-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_022223_723833_1C771588 X-CRM114-Status: GOOD ( 13.87 ) 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. Reviewed-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); }