From patchwork Sun Jan 25 19:44:53 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Hurley X-Patchwork-Id: 5705361 Return-Path: X-Original-To: patchwork-linux-omap@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id AF76E9F1D6 for ; Sun, 25 Jan 2015 19:45:28 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C4BAE2013A for ; Sun, 25 Jan 2015 19:45:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B8A5F20148 for ; Sun, 25 Jan 2015 19:45:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755704AbbAYTpZ (ORCPT ); Sun, 25 Jan 2015 14:45:25 -0500 Received: from mail-qa0-f43.google.com ([209.85.216.43]:54859 "EHLO mail-qa0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755729AbbAYTpJ (ORCPT ); Sun, 25 Jan 2015 14:45:09 -0500 Received: by mail-qa0-f43.google.com with SMTP id v10so4398531qac.2 for ; Sun, 25 Jan 2015 11:45:08 -0800 (PST) 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=cfuzP92Do1Lxgo4HEQrJQBF6/dLQDb/AcZmOkLsQVKo=; b=KigQfGqI/SzDDIe5yMxXSW6bWCJV5VrH4QWWtIMdNS0vhGy1oa+3MtE5aTbkXAb6nJ NHJvIAV22eYseWJMSQTOkCOp6KHVN4p2BYt95kYdHBEyVc7aKVHwFcnjOFcDyR0FthIi AJbBuJmw1kTTkBCMCO58qyjM/xX3ZRsLnvJp0PQMK2heHZEhBYtp7CuKYQ8/v5/rTNj1 nMqT07l1VSRMlundDXdyJ2S4poPHInroTcFbQuG4uXjQks+vBNiTNIX113zKcLG7idC4 TEEY6UppoI10pyCTOPU6KRFRsJgyerarUlfWDp3GKwEaLEoRw6y8rHos8VjNhj0FDd/1 rl3g== X-Gm-Message-State: ALoCoQmhA3nPdJUH3U1pJVD5A5BUz4bxkjaMXc/nE2LCIMHe+c/tlWPOKhCxY++8HQN/EkGplPM9 X-Received: by 10.224.2.9 with SMTP id 9mr28609091qah.66.1422215108565; Sun, 25 Jan 2015 11:45:08 -0800 (PST) Received: from thor.lan (h96-61-87-245.cntcnh.dsl.dynamic.tds.net. [96.61.87.245]) by mx.google.com with ESMTPSA id g100sm7886794qge.1.2015.01.25.11.45.07 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 25 Jan 2015 11:45:08 -0800 (PST) From: Peter Hurley To: Greg Kroah-Hartman Cc: linux-serial@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-omap@vger.kernel.org, Jiri Slaby , Peter Hurley Subject: [PATCH 3/4] serial: omap: Fix RTS handling Date: Sun, 25 Jan 2015 14:44:53 -0500 Message-Id: <1422215094-3216-4-git-send-email-peter@hurleysoftware.com> X-Mailer: git-send-email 2.2.2 In-Reply-To: <1422215094-3216-1-git-send-email-peter@hurleysoftware.com> References: <1422215094-3216-1-git-send-email-peter@hurleysoftware.com> Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The OMAP UART ignores MCR[1] (ie., RTS) when in autoRTS mode. This makes it impossible for either the serial core or userspace to manually flow control the sender. Disable autoRTS mode when RTS is lowered and restore the previous mode when RTS is raised. Signed-off-by: Peter Hurley --- drivers/tty/serial/omap-serial.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/drivers/tty/serial/omap-serial.c b/drivers/tty/serial/omap-serial.c index b28cdca..e01b65e 100644 --- a/drivers/tty/serial/omap-serial.c +++ b/drivers/tty/serial/omap-serial.c @@ -681,7 +681,7 @@ static unsigned int serial_omap_get_mctrl(struct uart_port *port) static void serial_omap_set_mctrl(struct uart_port *port, unsigned int mctrl) { struct uart_omap_port *up = to_uart_omap_port(port); - unsigned char mcr = 0, old_mcr; + unsigned char mcr = 0, old_mcr, lcr; dev_dbg(up->port.dev, "serial_omap_set_mctrl+%d\n", up->port.line); if (mctrl & TIOCM_RTS) @@ -701,6 +701,17 @@ static void serial_omap_set_mctrl(struct uart_port *port, unsigned int mctrl) UART_MCR_DTR | UART_MCR_RTS); up->mcr = old_mcr | mcr; serial_out(up, UART_MCR, up->mcr); + + /* Turn off autoRTS if RTS is lowered; restore autoRTS if RTS raised */ + lcr = serial_in(up, UART_LCR); + serial_out(up, UART_LCR, UART_LCR_CONF_MODE_B); + if ((mctrl & TIOCM_RTS) && (port->status & UPSTAT_AUTORTS)) + up->efr |= UART_EFR_RTS; + else + up->efr &= UART_EFR_RTS; + serial_out(up, UART_EFR, up->efr); + serial_out(up, UART_LCR, lcr); + pm_runtime_mark_last_busy(up->dev); pm_runtime_put_autosuspend(up->dev); } @@ -756,8 +767,6 @@ static int serial_omap_startup(struct uart_port *port) * (they will be reenabled in set_termios()) */ serial_omap_clear_fifos(up); - /* For Hardware flow control */ - serial_out(up, UART_MCR, UART_MCR_RTS); /* * Clear the interrupt registers. @@ -1056,12 +1065,9 @@ serial_omap_set_termios(struct uart_port *port, struct ktermios *termios, up->port.status &= ~(UPSTAT_AUTOCTS | UPSTAT_AUTORTS | UPSTAT_AUTOXOFF); if (termios->c_cflag & CRTSCTS && up->port.flags & UPF_HARD_FLOW) { - /* Enable AUTORTS and AUTOCTS */ + /* Enable AUTOCTS (autoRTS is enabled when RTS is raised) */ up->port.status |= UPSTAT_AUTOCTS | UPSTAT_AUTORTS; - up->efr |= UART_EFR_CTS | UART_EFR_RTS; - - /* Ensure MCR RTS is asserted */ - up->mcr |= UART_MCR_RTS; + up->efr |= UART_EFR_CTS; } else { /* Disable AUTORTS and AUTOCTS */ up->efr &= ~(UART_EFR_CTS | UART_EFR_RTS);