From patchwork Fri Sep 30 08:58:01 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Genoud X-Patchwork-Id: 9357833 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 36B4F6075E for ; Fri, 30 Sep 2016 09:02:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 25BDD29F22 for ; Fri, 30 Sep 2016 09:02:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1A70B29F27; Fri, 30 Sep 2016 09:02:33 +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 9C94729F22 for ; Fri, 30 Sep 2016 09:02:32 +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 1bptgh-0002Kk-3o; Fri, 30 Sep 2016 09:00:59 +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 1bptek-00006T-GU for linux-arm-kernel@lists.infradead.org; Fri, 30 Sep 2016 08:58:59 +0000 Received: by mail-wm0-x242.google.com with SMTP id p138so2441056wmb.0 for ; Fri, 30 Sep 2016 01:58:37 -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=dEOrR9ieC0Bz16pDkkviA6F6PgD6Mc0saBlBpeQiCTM=; b=U+NqvknBU1Z0M+K+dgKOc72Rb8T1CJZOFgOIB7+AUkXrLLYuisxsIOPEDDkTDNk+gO mhNx2rRWqNgwQVYH5o8bC0ezKGdriVrMN7GK7oyx+F1SAIaiYSJOVhuF2KX5lgtPrR9r C/evcGYbjLjUdga7OrnBphKvvFXyUrSsnpL8mtrSyiYAMKxLnV8wuu574uqNAjJTj6hx MpHCHHsOcvx0MvYsbWgIHyE3cgWMYZ+vA1CQdZVJuIe5/JJh6ebTRskvdwAFiddSMoNW 43QzT6XflG6pega7dvHTGm0ilrwlbNlRJ8ZHz9SUmmVvEyMgFPZzg+4UAZ8WZ2tvnAvV SRlw== 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=dEOrR9ieC0Bz16pDkkviA6F6PgD6Mc0saBlBpeQiCTM=; b=FSbiVp+/SfCQtC96pSWXXtpSunhnxCkjyTk9RAY0DXOfwNIMlpLi28YC9lxHihSgNu DtG6KaPx1UucDsJqvnW7/eevCbImfLAh6o5wNuaYdeT9ls9mEzHeA69fCj09rTSz+dh3 LfdoCpQepTWXjRV5akJnv06fPBcpViQWjTbcOpNwNzGM2RaoUZfbYBqhBotLA/BRe8vB 9uD+vKBbbnFVuGF1/hnpQ/zDzxff1JSN9JRsof/bXkkn/OGRrNaeqNsA70l9E7cuiFi7 S2FiJXaCLwW+HOjv6Cfll/TOL6LPgROYx5DunSoUyblVnNobX0cjG3xQlaNAIVwyT6J8 584A== X-Gm-Message-State: AA6/9RmGqDYDSBWGdzYz+sKoQls9331p4ArZfDq70KWmpc8WEF0JxxjwuC/mLochGOl4WA== X-Received: by 10.28.92.71 with SMTP id q68mr2499846wmb.85.1475225916292; Fri, 30 Sep 2016 01:58:36 -0700 (PDT) Received: from localhost ([46.227.18.67]) by smtp.gmail.com with ESMTPSA id o5sm18359832wjj.46.2016.09.30.01.58.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 30 Sep 2016 01:58:35 -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 3/3] tty/serial: at91: fix hardware handshake on SAM9x5 (without GPIOs) Date: Fri, 30 Sep 2016 10:58:01 +0200 Message-Id: <20160930085801.21497-4-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_015858_808030_7DD2732B X-CRM114-Status: GOOD ( 12.94 ) 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 on SAM9x5 platforms. On Atmel platforms, the USART can only handle the handware handshake (ATMEL_US_USMODE_HWHS) if FIFOs or PDC are used. Thus, ATMEL_US_USMODE_HWHS mode should only be used in this case. For SAM9x5, there's no FIFOs nor PDC for the USART, so the mode should be ATMEL_US_USMODE_NORMAL and the RTS pin should be controlled by the driver. NB: -stable is not Cced because it doesn't cleanly apply on 4.1+ Tested on SAM9G35-CM with and without DMA Signed-off-by: Richard Genoud Fixes: 1cf6e8fc8341 ("tty/serial: at91: fix RTS line management when hardware handshake is enabled") --- drivers/tty/serial/atmel_serial.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/drivers/tty/serial/atmel_serial.c b/drivers/tty/serial/atmel_serial.c index b01b68ece35c..4d033e6af44a 100644 --- a/drivers/tty/serial/atmel_serial.c +++ b/drivers/tty/serial/atmel_serial.c @@ -2131,19 +2131,23 @@ static void atmel_set_termios(struct uart_port *port, struct ktermios *termios, port->rs485.delay_rts_after_send); mode |= ATMEL_US_USMODE_RS485; } else if ((termios->c_cflag & CRTSCTS) && - !mctrl_gpio_use_rtscts(atmel_port->gpios)) { + !mctrl_gpio_use_rtscts(atmel_port->gpios) && + (atmel_use_pdc_rx(port) || atmel_use_fifo(port))) { /* - * RS232 with hardware handshake (RTS/CTS) - * handled by the controller. + * Automatic hardware handshake (RTS/CTS) only work with + * FIFOs or PDC. + * Meaning that on SAM9x5 the controller can't handle + * the hardware handshake (no FIFOs nor PDC on these platforms). */ - 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; - } else { - mode |= ATMEL_US_USMODE_HWHS; - } + mode |= ATMEL_US_USMODE_HWHS; } else { - /* RS232 without hardware handshake or controlled by GPIOs */ + /* + * Other cases are: + * - RS232 without hardware handshake + * - RS232 with hardware handshake and: + * - controller unable to handle CTS/RTS by itself + * - or CTS/RTS handled by GPIOs + */ mode |= ATMEL_US_USMODE_NORMAL; }