From patchwork Fri Sep 30 08:58:00 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Genoud X-Patchwork-Id: 9357819 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 DD9746075E for ; Fri, 30 Sep 2016 09:01:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CD00C29F22 for ; Fri, 30 Sep 2016 09:01:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C1EA829F26; Fri, 30 Sep 2016 09:01:38 +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 CDF8A29F22 for ; Fri, 30 Sep 2016 09:01:33 +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 1bptfs-0000v6-N0; Fri, 30 Sep 2016 09:00:08 +0000 Received: from mail-wm0-x244.google.com ([2a00:1450:400c:c09::244]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bptea-0008Vq-Tz for linux-arm-kernel@lists.infradead.org; Fri, 30 Sep 2016 08:58:51 +0000 Received: by mail-wm0-x244.google.com with SMTP id b4so2440242wmb.2 for ; Fri, 30 Sep 2016 01:58:32 -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=fS4sRkHybZWvfY/ZzCyJxhNCUM859/TyDjsBu69bWUE=; b=XI086Ap+Qq/d1Bqbb8024+24ON79l2foCns0AS7R3OKxC4A7e7LH50/2ATdznPPrzd BSvLsBWYnMyT51FzQSzHHw74F5+YKDPNPF7kPdNF9VU71YKJ8Q59/JF92g0ziBsqFZmX waSYItwsPHfYmdcv9nSR2G7/G9UOOeHLCcbVoZlFTpbCH6Ok+SHI5+PoZzJdrjuzQNMa 8qDFwdWRnckfRTQqAETbE+ugzgzS9xo8Wsh4hGupafgp3xDiXtouPR3ickvbwxI36HYw RgX8ircSlNT3UXatEjqabZYqxDLLq5xK/n2agNuEz0AMqU8M9YD9SHsBJAoTzaG1fm6B wODQ== 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=fS4sRkHybZWvfY/ZzCyJxhNCUM859/TyDjsBu69bWUE=; b=EYm7OSYmgfssOHP6ip8lkMhYxVpFjQ0fKKkZvq/7t370gJ4FhgbGQiI9jtZ2fhBMO3 rfLh6u8+SyH+HAjCsPn383Z1A36HpviyItOeBMdhrT5e8P6q0wfH5mNiZS2CnMZpnLfC 1N5e+/Z84sXdGLNK92NcWqdOu3+4WNqHeKYpgCSxRe8IagzUEuBHPlrZx0BOnmZ3Fr9P OdPhvU8yhmfE3QZn0sl2ZfBOt/jDTcRgdckB3uvDBI/NzTn45e77MJnzO1nmkPMW9kK7 kA9nan3oVvikoGwF3gRx2l2MjaGb7c5YH1VwvsOzONxEoSkrZJtPqjjm3Xkqob4BE4Od p8sw== X-Gm-Message-State: AA6/9RkhvDMLwSrUoug9dKYZ1HmaTw6kmxE0/5oxL2oqG7CpIbaAVphKbz0rueFRa9EHFQ== X-Received: by 10.194.88.74 with SMTP id be10mr5091066wjb.120.1475225911307; Fri, 30 Sep 2016 01:58:31 -0700 (PDT) Received: from localhost ([46.227.18.67]) by smtp.gmail.com with ESMTPSA id x124sm2998402wmf.22.2016.09.30.01.58.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 30 Sep 2016 01:58:30 -0700 (PDT) From: Richard Genoud To: =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , Nicolas Ferre , Alexandre Belloni , Greg Kroah-Hartman , Cyrille Pitchen Subject: [PATCHv4 2/3] tty/serial: at91: fix hardware handshake with GPIOs Date: Fri, 30 Sep 2016 10:58:00 +0200 Message-Id: <20160930085801.21497-3-richard.genoud@gmail.com> X-Mailer: git-send-email 2.10.0 In-Reply-To: <20160930085801.21497-1-richard.genoud@gmail.com> References: <20160930085801.21497-1-richard.genoud@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160930_015849_347019_CBD78AA3 X-CRM114-Status: GOOD ( 11.97 ) 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 fd8aa1f4ba78..b01b68ece35c 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; }