From patchwork Tue Sep 27 14:13:12 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Genoud X-Patchwork-Id: 9351995 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 01EB76077B for ; Tue, 27 Sep 2016 14:16:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E667228F50 for ; Tue, 27 Sep 2016 14:16:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DAC8329243; Tue, 27 Sep 2016 14:16:06 +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 37DAC28F50 for ; Tue, 27 Sep 2016 14:16:03 +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 1bot9g-000261-Bb; Tue, 27 Sep 2016 14:14:44 +0000 Received: from mail-wm0-x243.google.com ([2a00:1450:400c:c09::243]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bot93-0001yf-VR for linux-arm-kernel@lists.infradead.org; Tue, 27 Sep 2016 14:14:10 +0000 Received: by mail-wm0-x243.google.com with SMTP id b4so1379139wmb.2 for ; Tue, 27 Sep 2016 07:13:50 -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=2e6kzrsodjB3vmL+hTTuX8/CtlMKnGmti4eYMjy5wXg=; b=PDMa45ZvOFFM4DgDngjXsy9Q0reXrQshr8fPv7e6/3z+iFrDBayNkdO1CfmNBylhrD 0EnDTNfBfGC6Bc8Tgw/1UdZ+QTV3wedgznzBsDglAOKXWqUsm7tbfmpELRnvPEYsPmVZ Nb1rLwWQzLRS1KC4X/+7MmLaVEI17dl+ZLbx65k0YjNNsB6AxscVB4ycCuK9ai5vYygi 0UAdBRU1OXEKfNTHy8POHCVZsMA/ya4T/NmNyIaY4O8NbzZjdv/YgNEImdmYGs2foxkb vB/9gBp9ZWgvda+aqawV2mhDI1xgF36vJkXwCV9qDiMSEvCoYhCoHxDKSVw5o/qqAQq7 zd5Q== 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=2e6kzrsodjB3vmL+hTTuX8/CtlMKnGmti4eYMjy5wXg=; b=NY060FKehyMEuce2qNS610XSLDFHZuZv39R/zo6nyZ7/nbrUlNtqtDSMe+P/5Ruk/a 7FxO24mXr7iHk0Jbny1AQSdwZh6JQ2OyRYt2WN67LhTOOxqXW7wXQjU2jzuc1yGy+PY/ uSAIZLQ9jY0hfCRWTs9T0SFKkFbF26DSQdaMSbcgtvlhB2f9CiMFZ4B/gPkZ+/79UmHB QrtMnrVR9gbtCg1BtsLpck0UL1YEZZyoNdb2kPS+TtF1OXNrhZMQupbV7Nt242jwiVEx oT0kq2osg0fOV4PRnsV5+m+aXY02CN3f7Kn3PcVGfYEry21DVidiuMFHrUg4QxsAd3At cq2Q== X-Gm-Message-State: AA6/9RmVHyLmaIeAruZM8ZPxaDV9FF9b625gVnLTTd7RRHqg/4I1fgbg4pNSj9vFYAkZqg== X-Received: by 10.28.211.10 with SMTP id k10mr3371136wmg.16.1474985629015; Tue, 27 Sep 2016 07:13:49 -0700 (PDT) Received: from localhost ([46.227.18.67]) by smtp.gmail.com with ESMTPSA id 193sm3379913wmo.14.2016.09.27.07.13.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 27 Sep 2016 07:13:48 -0700 (PDT) From: Richard Genoud To: =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , Nicolas Ferre , Alexandre Belloni , Greg Kroah-Hartman , Cyrille Pitchen Subject: [PATCHv3 2/3] tty/serial: at91: fix hardware handshake with GPIOs Date: Tue, 27 Sep 2016 16:13:12 +0200 Message-Id: <20160927141313.27668-3-richard.genoud@gmail.com> X-Mailer: git-send-email 2.10.0 In-Reply-To: <20160927141313.27668-1-richard.genoud@gmail.com> References: <20160927141313.27668-1-richard.genoud@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160927_071406_158043_151326F3 X-CRM114-Status: GOOD ( 12.25 ) 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: linux-arm-kernel@lists.infradead.org, Richard Genoud , linux-kernel@vger.kernel.org, linux-serial@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 were 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 | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/tty/serial/atmel_serial.c b/drivers/tty/serial/atmel_serial.c index 5f550d9feed9..14467d5e060b 100644 --- a/drivers/tty/serial/atmel_serial.c +++ b/drivers/tty/serial/atmel_serial.c @@ -2130,8 +2130,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; @@ -2139,7 +2143,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 hardware handshake or controlled by GPIOs */ mode |= ATMEL_US_USMODE_NORMAL; }