From patchwork Mon Sep 12 09:47:32 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Genoud X-Patchwork-Id: 9326067 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 5C67E60839 for ; Mon, 12 Sep 2016 09:50:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4AE59289F2 for ; Mon, 12 Sep 2016 09:50:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3CBD528CB0; Mon, 12 Sep 2016 09:50:09 +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=-4.1 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FROM,RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 3119F289F2 for ; Mon, 12 Sep 2016 09:50:07 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1bjNr4-00072L-N3; Mon, 12 Sep 2016 09:48:46 +0000 Received: from mail-wm0-x242.google.com ([2a00:1450:400c:c09::242]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bjNqX-0006cA-2U for linux-arm-kernel@lists.infradead.org; Mon, 12 Sep 2016 09:48:18 +0000 Received: by mail-wm0-x242.google.com with SMTP id a6so12788496wmc.2 for ; Mon, 12 Sep 2016 02:47:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=3yWa/GvTpNIULc+880kAX5IYZd72WOxeUftZ1pQKVd8=; b=WFhvmLWPPDUJ/uZc8skb4IcZv4H9tEtmfS1k8Y3QEvok9UZA45J6mfHx2JiN++30wB m9wZ5PpTMO2MZCYeqvWeLWQIw3aOXnqhhb/6MDIDe8F4f1WPV/rClOictkwOVQRB/zal k6gJljIEkW9qAmTq+keDo7ke/wM96sjRucm3/enmQHzNtf6Lgcxe873pYClF4/IUfx3p hRywns8l4zPveW4BcelsRDZ+l+n7dULB7IW2M3eSuUd3fONHi+uCX9ihkGMZoTUo6xta p7/YyFPOI9YC6LYj9yf1HRCld7cnD0lq3m6NKYhHCIylgP29aWcjxz6Fcx60ybGdnye4 9Pgg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=3yWa/GvTpNIULc+880kAX5IYZd72WOxeUftZ1pQKVd8=; b=X2Cw2hDI2rnxSIGspp7BcrgkWZt7ZcuWko3mu+5F8UqKrDPjDyIXF9GPITiXR0fpX9 BNKeYdPsiZF1t5XP0L39LHOrOnmiCJdyEyfBETNMVccmD+Ubagf4lx5pW2qfI0hOh/NZ tBDXnsxotKWPSbiQOHbc9ltJMY8oYVoiGJI1gk99yWLpIqkTq3etmdoJ1C2yxggUJ8Rl 5PxXlgKtZYwNHGL0cHTMrj6gDx/yR2WCTfL8y/Bn229J0LDxFo/aaZ+gNBI7Py4nAOim IuwKnFtDHDAkStUAtDB1cLk3K2+l2qKHm8T4eKH7OQexJ/mYlpV5oR704LjHXJO7saA4 dEcw== X-Gm-Message-State: AE9vXwNJOV7SujSazleokBccckptG07J4nHCmaCkNCuN/uRicOiKzQQdwI07EM1ttkgk4A== X-Received: by 10.194.87.34 with SMTP id u2mr16478469wjz.118.1473673672059; Mon, 12 Sep 2016 02:47:52 -0700 (PDT) Received: from localhost ([46.227.18.67]) by smtp.gmail.com with ESMTPSA id de8sm9552073wjc.24.2016.09.12.02.47.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 12 Sep 2016 02:47:51 -0700 (PDT) From: Richard Genoud To: Cyrille Pitchen , Alexandre Belloni , Nicolas Ferre , Greg Kroah-Hartman Subject: [PATCHv2 2/3] tty/serial: at91: fix hardware handshake with GPIOs Date: Mon, 12 Sep 2016 11:47:32 +0200 Message-Id: <20160912094733.21501-3-richard.genoud@gmail.com> X-Mailer: git-send-email 2.10.0 In-Reply-To: <20160912094733.21501-1-richard.genoud@gmail.com> References: <20160912094733.21501-1-richard.genoud@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160912_024813_524109_E5C4F77B X-CRM114-Status: GOOD ( 12.99 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Richard Genoud , linux-serial@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.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 Commit 1cf6e8fc8341 ("tty/serial: at91: fix RTS line management when hardware handshake is enabled") broke the hardware handshake when GPIOs where used. Hardware handshake with GPIOs used to work before this commit because the CRTSCTS flag (termios->c_cflag) was set, but not the ATMEL_US_USMODE_HWHS flag (controller register) ; so hardware handshake enabled, but not handled by the controller. This commit restores this behaviour. NB: -stable is not Cced because it doesn't cleanly apply on 4.1+ and it will also need previous commit: "serial: mctrl_gpio: implement mctrl_gpio_use_rtscts" Signed-off-by: Richard Genoud Acked-by: Alexandre Belloni Fixes: 1cf6e8fc8341 ("tty/serial: at91: fix RTS line management when hardware handshake is enabled") --- drivers/tty/serial/atmel_serial.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/tty/serial/atmel_serial.c b/drivers/tty/serial/atmel_serial.c index 2eaa18ddef61..e9b4fbf88c2d 100644 --- a/drivers/tty/serial/atmel_serial.c +++ b/drivers/tty/serial/atmel_serial.c @@ -2025,6 +2025,7 @@ static void atmel_serial_pm(struct uart_port *port, unsigned int state, static void atmel_set_termios(struct uart_port *port, struct ktermios *termios, struct ktermios *old) { + struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); unsigned long flags; unsigned int old_mode, mode, imr, quot, baud; @@ -2126,8 +2127,12 @@ static void atmel_set_termios(struct uart_port *port, struct ktermios *termios, atmel_uart_writel(port, ATMEL_US_TTGR, port->rs485.delay_rts_after_send); mode |= ATMEL_US_USMODE_RS485; - } else if (termios->c_cflag & CRTSCTS) { - /* RS232 with hardware handshake (RTS/CTS) */ + } else if ((termios->c_cflag & CRTSCTS) && + !mctrl_gpio_use_rtscts(atmel_port->gpios)) { + /* + * RS232 with hardware handshake (RTS/CTS) + * handled by the controller. + */ if (atmel_use_dma_rx(port) && !atmel_use_fifo(port)) { dev_info(port->dev, "not enabling hardware flow control because DMA is used"); termios->c_cflag &= ~CRTSCTS; @@ -2135,7 +2140,7 @@ static void atmel_set_termios(struct uart_port *port, struct ktermios *termios, mode |= ATMEL_US_USMODE_HWHS; } } else { - /* RS232 without hadware handshake */ + /* RS232 without hadware handshake or controlled by GPIOs */ mode |= ATMEL_US_USMODE_NORMAL; }