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: 5705391 Return-Path: X-Original-To: patchwork-linux-arm@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 7C63F9F665 for ; Sun, 25 Jan 2015 19:47:44 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9A36520125 for ; Sun, 25 Jan 2015 19:47:43 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B57A82013A for ; Sun, 25 Jan 2015 19:47:42 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1YFT89-0008ID-Ne; Sun, 25 Jan 2015 19:45:57 +0000 Received: from mail-qg0-f45.google.com ([209.85.192.45]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1YFT7j-0008C3-Bu for linux-arm-kernel@lists.infradead.org; Sun, 25 Jan 2015 19:45:32 +0000 Received: by mail-qg0-f45.google.com with SMTP id q107so4416624qgd.4 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=GzarS7PoX364PFU2orq4gQv96ZIrTeN1tQqXvL6LryHDmGXU7SBqKbQLTz1FewQk63 8Tt8tGNJ1rvuz/OPGrIzGhLS9eBif765dDLP4/oEaNOEoi/5xUgxt9A0NsYmjmsaK5S2 oQePTUwYJgAef1lNQ2kyduM990dq6RjP3FS/L9Gfr4dzcr35iA10p7YSr64pvOhCmlV2 bVr2xwVcdqqKilaDFVMvKffBIT2Yus3UzKCMaBX2QRjfBuVsHFtO837GC2o7vo7ImkFL yobJH47xXpc1ZtMKLFR8LCYqtrgV6BxwBTqOPwWf/fG9tuMqCT4RsH0ZIx8PYcLR00KF 9aMg== X-Gm-Message-State: ALoCoQmtxs3XNzwIJA9j0jksnIzaHzUJ0rrhvej+9jHsS4t2YbQtJWJecQgwX1RaT/Zjl+TUPnZB 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 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> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150125_114531_500603_C3C72890 X-CRM114-Status: GOOD ( 11.68 ) X-Spam-Score: -0.7 (/) Cc: linux-omap@vger.kernel.org, Jiri Slaby , linux-arm-kernel@lists.infradead.org, linux-serial@vger.kernel.org, Peter Hurley X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable 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);