From patchwork Wed Sep 7 16:13:23 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Genoud X-Patchwork-Id: 9319633 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 0F13C60752 for ; Wed, 7 Sep 2016 16:16:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F0DF6293D6 for ; Wed, 7 Sep 2016 16:16:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E502B29403; Wed, 7 Sep 2016 16:16:54 +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=ham 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 9D7A5293D6 for ; Wed, 7 Sep 2016 16:16:54 +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 1bhfUY-0003vu-PB; Wed, 07 Sep 2016 16:14:26 +0000 Received: from mail-wm0-x241.google.com ([2a00:1450:400c:c09::241]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bhfUH-0003lb-QG for linux-arm-kernel@lists.infradead.org; Wed, 07 Sep 2016 16:14:10 +0000 Received: by mail-wm0-x241.google.com with SMTP id w12so3713211wmf.1 for ; Wed, 07 Sep 2016 09:13:48 -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=mTkk9ajz1KYiMJnnc6ZKdXl/J7/vnnGkI/QPQsEbktY=; b=Fwlr6OEMFoFAuK2OJTz+/h9+nx3O/875nBXpkzFykXpYgdbJrm7vsJp7se3GWNLoIT g+1qjQ1vk4Rc71BsinFbiklmqCqAQihTHSAMuPyTbnFOe4HznfZiwXn1KwJav92axYhW ij3Vaad5RVWd+IRoQ+slku1/fwsQ/Mh0R3nwzQ5MpBynueebLBWvee7Vb7A4lBesb8h+ FrcqrKMVNU2o853nDlRGoBm6Y6NjNNUb4swC7YD96TYKlHWYwotQvfzGaD4YgUSHH4no pPvPm48UkBB+Y6P0y9j85pvJqob1M789wAk5I8uaNrZoInL8jge++EHU9aadHIOYmP73 IXpw== 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=mTkk9ajz1KYiMJnnc6ZKdXl/J7/vnnGkI/QPQsEbktY=; b=OQAH7lg61vit73G3U2c624dAyQ8DBsl12JbKMgqRxg1jeEhxIoA27k4cYoscRFvMVE yNgfwrOB1KhVcaAKjaNID2jJh6evHdoI0hkbyNkNc9Usjk0oSsHN7t227sJ28yp+cByW t+gpkAmysVHd8E1fonJcZn4ZG8A0jH+fiEoYrNZfbAd4XIedquNkv/MVwNLKt7PdLTaW orxvFoouYpxvU8S85vjo4boHP+2yn/w6LjIvlbzpMUIF0fTWL/6LoqU7OPPtvBZlNv3q sUBomJ0tLncaSwKXZ778LCLdLT3HotWcomJlH0iCTdelp7e+7T3wvQGx3lhX4LrHK3Si Q8JQ== X-Gm-Message-State: AE9vXwNqbh+imseFfMMXpPhWWGTYFFa1sD+3UBw+eQi6IDmE4uEpCu9NJTYgn3CE1r/TlQ== X-Received: by 10.28.9.7 with SMTP id 7mr4740864wmj.95.1473264826965; Wed, 07 Sep 2016 09:13:46 -0700 (PDT) Received: from localhost ([46.227.18.67]) by smtp.gmail.com with ESMTPSA id bc10sm39581957wjc.32.2016.09.07.09.13.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 07 Sep 2016 09:13:46 -0700 (PDT) From: Richard Genoud To: Cyrille Pitchen , Alexandre Belloni , Nicolas Ferre Subject: [PATCH 2/3] tty/serial: at91: fix hardware handshake with GPIOs Date: Wed, 7 Sep 2016 18:13:23 +0200 Message-Id: <20160907161324.27774-2-richard.genoud@gmail.com> X-Mailer: git-send-email 2.10.0 In-Reply-To: <20160907161324.27774-1-richard.genoud@gmail.com> References: <20160907161324.27774-1-richard.genoud@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160907_091410_066953_F2AE2864 X-CRM114-Status: GOOD ( 13.05 ) 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 , Greg Kroah-Hartman , 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 Fixes: 1cf6e8fc8341 ("tty/serial: at91: fix RTS line management when hardware handshake is enabled") Acked-by: Alexandre Belloni --- 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; }