From patchwork Fri Jul 26 18:52:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Organov X-Patchwork-Id: 11061761 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 0C55D1398 for ; Fri, 26 Jul 2019 18:53:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EF43F28B2D for ; Fri, 26 Jul 2019 18:53:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E379828B38; Fri, 26 Jul 2019 18:53:57 +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 881F228B2D for ; Fri, 26 Jul 2019 18:53:57 +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=ZelUfE2u0eHeIDfg/5/2+5RbY9HgWtVJIEgczYPAPWI=; b=nSA8qgc8afKmzMj6f/fx6fAsSk KVYTIvtBDxmRHQynCFitLhc3XCEBSpkjlnnmt5nI6f4JIv9psj8WKwBUGXdjvsoi/r48w44iD/iZl jsVI8kz9FEjCB4v5UwXgeNib+bxJnkuTy6UzZR8uVh9W105lRLowiwk7Ht7GvPXDEnRvTd/JJsXYy 09kNrnRFt4UPiDgx4BZhkx8Lbrb8wmzgdEJF9eq25yJuUmWj9u27/51zZY+xyM2ncTvXSmLPTcXHB 5B6Bn9Xsh5Evko9gwORNXu1Dtutp8h1XRtiehaLX1lY0pWu0fSiMY4s9/0m8hPKta5pUcVRVSh9L7 hNJSGx2w==; 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 1hr5Lo-0000pc-OP; Fri, 26 Jul 2019 18:53:56 +0000 Received: from mail-lf1-x144.google.com ([2a00:1450:4864:20::144]) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1hr5LF-0000Mb-8C for linux-arm-kernel@lists.infradead.org; Fri, 26 Jul 2019 18:53:22 +0000 Received: by mail-lf1-x144.google.com with SMTP id u10so37735301lfm.12 for ; Fri, 26 Jul 2019 11:53:21 -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=jZWmDj4ynzd3H3aeFWqnlP+/VckrZm4pXfnfA3698MQ=; b=t5TcUS9UG2i5BR3IcZr5CmtPv66vh9zRIHMqIt473cvspguf8CZe3XhCSnDOBGMWA6 eldCZ9MHwOB4FqX2NZ9kFZpblp41KqM86nHTzn+sDqjcpEMN9SVPfjbqah+X7cjKkxj4 UBkGk05DQBCAk/uvjG5M9ZopALgp/vk9DFqrR2LoN4zW2D93/gi36smZWEzb9HlNSIAA K/7v6gZ9G4RpQifGemYt1Gj9BO/W8h/HMVFX7tOywWxr/hON/wIs2L3VERCK7ZbeOcec owqpIWi5oNY4OblefEjU6W2VBwpQY/XxfgIzg93eACVx2iqMnKdX1blwnXuXxLkig3R7 b6YA== 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=jZWmDj4ynzd3H3aeFWqnlP+/VckrZm4pXfnfA3698MQ=; b=Rrrd6RkSTvYagwRAbWgOStfEJoHDeOeNHri/Wg5KlRRvPODu/wJ73P4TSCKKgS7u0J lBn6p7jpDrnqxOnnXvBgJsrBqBir8uEHCLU8V7Bk5l48/L4hGhr03mkrUpQHR3kOTTQa R82kVUQMwPXFK1XZsjh08pwMp6XQ7qlEcYM9EzfL9TjP99/W8Wo78taffNwj8hZsZFyF PQKjsyyX36V6eQ1HDxSMLE9x5qgp+k0IYAOa9EKPShsiPHY3HS1QnKGXJ/60i2BWwi7T SI6/3R4s8O5U/RGMFULvyO0LxkgRiSNn9AV2WN4KkJ7CPLQ1668xHRAu09Oz9EA5w1OK Omyg== X-Gm-Message-State: APjAAAUCcFqFTrInrFCAIVuoFrC5xeFjEZlUB9qHkBIr3v36nJ/uZLbl UW+WddGWSKtYAXiFS20/fKw= X-Google-Smtp-Source: APXvYqyGHeBm5PjleeluML4AzpxpOJHQoGmOKRykfTe+PMMgtgbeCze1llNiRpIuXxA9yu4ft7G/bA== X-Received: by 2002:a19:5217:: with SMTP id m23mr44591619lfb.124.1564167199911; Fri, 26 Jul 2019 11:53:19 -0700 (PDT) Received: from osv.localdomain ([89.175.180.246]) by smtp.gmail.com with ESMTPSA id u15sm10254810lji.61.2019.07.26.11.53.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 26 Jul 2019 11:53:19 -0700 (PDT) From: Sergey Organov To: linux-serial@vger.kernel.org Subject: [PATCH v7 2/3] serial: imx: set_mctrl(): correctly restore autoRTS state Date: Fri, 26 Jul 2019 21:52:40 +0300 Message-Id: <1564167161-3972-3-git-send-email-sorganov@gmail.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1564167161-3972-1-git-send-email-sorganov@gmail.com> References: <20190614072801.3187-1-s.hauer@pengutronix.de> <1564167161-3972-1-git-send-email-sorganov@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190726_115321_291375_AD8E14C0 X-CRM114-Status: GOOD ( 13.54 ) 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 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); }