From patchwork Tue Apr 29 17:22:02 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Murali Karicheri X-Patchwork-Id: 29362 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ie0-f200.google.com (mail-ie0-f200.google.com [209.85.223.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 2658C202DD for ; Tue, 29 Apr 2014 17:22:58 +0000 (UTC) Received: by mail-ie0-f200.google.com with SMTP id lx4sf2483776iec.3 for ; Tue, 29 Apr 2014 10:22:54 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:cc:subject:date:message-id :mime-version:sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe:content-type; bh=hL9a6m3v3qBYfRVDvspJh5O/CSiJHWeaJoJYfwoge+4=; b=MRFaGrYNxVOhzVW8/ggOpAQbVHDjA2U79NlpZd3y6sOwZr1ZF542CsauclVvLU8Ufx 0drPtObQ9vGZJHiYGgdYpRvJ+4RAcPngflAhHmMC1XQt85aP5Xmpqsy1Ys/zZojFgwth nJ+zbVdPXaznrysqY9upm1s2Hg7yDVd1lhdAAjoFbSZis+tf/03xGhmzH3d/iI1kdJMK Ydzza8wOo7WSZIyOjbD+c+lVax7a9x7ncwsWf5yV8xBcgu7L0mPM0ogh+4avgXCfNJZM eA/U4mQquIRyol2r93sV+uikgTqCL9hSI4zCaD7onmNqw2EJRY8uUzxCAPWEQym/usr0 DUTA== X-Gm-Message-State: ALoCoQkuK6BKClzlUHUlxaxDJ15Lre4yuMSWTvYINaM+nb+Gg6fA1guJAcz8i0/1DWemB+PhBwuu X-Received: by 10.43.18.133 with SMTP id qg5mr14542865icb.13.1398792172910; Tue, 29 Apr 2014 10:22:52 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.24.146 with SMTP id 18ls256227qgr.58.gmail; Tue, 29 Apr 2014 10:22:52 -0700 (PDT) X-Received: by 10.58.54.12 with SMTP id f12mr84408vep.75.1398792172707; Tue, 29 Apr 2014 10:22:52 -0700 (PDT) Received: from mail-vc0-f169.google.com (mail-vc0-f169.google.com [209.85.220.169]) by mx.google.com with ESMTPS id fa16si4679178veb.28.2014.04.29.10.22.52 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 29 Apr 2014 10:22:52 -0700 (PDT) Received-SPF: none (google.com: patch+caf_=patchwork-forward=linaro.org@linaro.org does not designate permitted sender hosts) client-ip=209.85.220.169; Received: by mail-vc0-f169.google.com with SMTP id im17so690534vcb.14 for ; Tue, 29 Apr 2014 10:22:52 -0700 (PDT) X-Received: by 10.220.191.134 with SMTP id dm6mr376885vcb.16.1398792172544; Tue, 29 Apr 2014 10:22:52 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.220.221.72 with SMTP id ib8csp215056vcb; Tue, 29 Apr 2014 10:22:52 -0700 (PDT) X-Received: by 10.66.189.201 with SMTP id gk9mr988415pac.25.1398792171661; Tue, 29 Apr 2014 10:22:51 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ug9si13623760pab.253.2014.04.29.10.22.50; Tue, 29 Apr 2014 10:22:50 -0700 (PDT) Received-SPF: none (google.com: linux-serial-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758317AbaD2RWu (ORCPT + 2 others); Tue, 29 Apr 2014 13:22:50 -0400 Received: from devils.ext.ti.com ([198.47.26.153]:35726 "EHLO devils.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758306AbaD2RWs (ORCPT ); Tue, 29 Apr 2014 13:22:48 -0400 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by devils.ext.ti.com (8.13.7/8.13.7) with ESMTP id s3THMBsp010170; Tue, 29 Apr 2014 12:22:11 -0500 Received: from DLEE71.ent.ti.com (dlee71.ent.ti.com [157.170.170.114]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id s3THMBXV016607; Tue, 29 Apr 2014 12:22:11 -0500 Received: from dflp32.itg.ti.com (10.64.6.15) by DLEE71.ent.ti.com (157.170.170.114) with Microsoft SMTP Server id 14.3.174.1; Tue, 29 Apr 2014 12:22:11 -0500 Received: from ares-ubuntu.am.dhcp.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by dflp32.itg.ti.com (8.14.3/8.13.8) with ESMTP id s3THMAIN008280; Tue, 29 Apr 2014 12:22:10 -0500 Received: from a0868495 by ares-ubuntu.am.dhcp.ti.com with local (Exim 4.76) (envelope-from ) id 1WfBjO-0004qS-Dp; Tue, 29 Apr 2014 13:22:10 -0400 From: Murali Karicheri To: , , , CC: Murali Karicheri , Rob Herring , Mark Rutland , Ian Campbell , Kumar Gala , Randy Dunlap , Greg Kroah-Hartman , Jiri Slaby , Santosh Shilimkar Subject: [PATCH v1] serial: uart: add hw flow control support configuration Date: Tue, 29 Apr 2014 13:22:02 -0400 Message-ID: <1398792122-18592-1-git-send-email-m-karicheri2@ti.com> X-Mailer: git-send-email 1.7.9.5 MIME-Version: 1.0 Sender: linux-serial-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-serial@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: m-karicheri2@ti.com X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: patch+caf_=patchwork-forward=linaro.org@linaro.org does not designate permitted sender hosts) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 8250 uart driver currently supports only software assisted hw flow control. The software assisted hw flow control maintains a hw_stopped flag in the tty structure to stop and start transmission and use modem status interrupt for the event to drive the handshake signals. This is not needed if hw has flow control capabilities. This patch adds a DT attribute for enabling hw flow control for a uart port. Also skip stop and start if this flag is present in flag field of the port structure. Signed-off-by: Murali Karicheri CC: Rob Herring CC: Pawel Moll CC: Mark Rutland CC: Ian Campbell CC: Kumar Gala CC: Randy Dunlap CC: Greg Kroah-Hartman CC: Jiri Slaby CC: Santosh Shilimkar --- - Fixed brackets around port->flags & UPF_HARD_FLOW as per comments .../devicetree/bindings/serial/of-serial.txt | 2 ++ drivers/tty/serial/8250/8250_core.c | 6 ++++-- drivers/tty/serial/of_serial.c | 4 ++++ drivers/tty/serial/serial_core.c | 12 +++++++++--- 4 files changed, 19 insertions(+), 5 deletions(-) diff --git a/Documentation/devicetree/bindings/serial/of-serial.txt b/Documentation/devicetree/bindings/serial/of-serial.txt index 1928a3e..123de01 100644 --- a/Documentation/devicetree/bindings/serial/of-serial.txt +++ b/Documentation/devicetree/bindings/serial/of-serial.txt @@ -37,6 +37,8 @@ Optional properties: - auto-flow-control: one way to enable automatic flow control support. The driver is allowed to detect support for the capability even without this property. +- hw-flow-control: this enables pure hw flow control and no software + intervention needed. Example: diff --git a/drivers/tty/serial/8250/8250_core.c b/drivers/tty/serial/8250/8250_core.c index 81f909c..f145103 100644 --- a/drivers/tty/serial/8250/8250_core.c +++ b/drivers/tty/serial/8250/8250_core.c @@ -2338,9 +2338,11 @@ serial8250_do_set_termios(struct uart_port *port, struct ktermios *termios, * the trigger, or the MCR RTS bit is cleared. In the case where * the remote UART is not using CTS auto flow control, we must * have sufficient FIFO entries for the latency of the remote - * UART to respond. IOW, at least 32 bytes of FIFO. + * UART to respond. IOW, at least 32 bytes of FIFO. Also enable + * AFE if hw flow control is supported */ - if (up->capabilities & UART_CAP_AFE && port->fifosize >= 32) { + if ((up->capabilities & UART_CAP_AFE && (port->fifosize >= 32)) || + (port->flags & UPF_HARD_FLOW)) { up->mcr &= ~UART_MCR_AFE; if (termios->c_cflag & CRTSCTS) up->mcr |= UART_MCR_AFE; diff --git a/drivers/tty/serial/of_serial.c b/drivers/tty/serial/of_serial.c index 9924660..1a5f528 100644 --- a/drivers/tty/serial/of_serial.c +++ b/drivers/tty/serial/of_serial.c @@ -182,6 +182,10 @@ static int of_platform_serial_probe(struct platform_device *ofdev) "auto-flow-control")) port8250.capabilities |= UART_CAP_AFE; + if (of_property_read_bool(ofdev->dev.of_node, + "hw-flow-control")) + port8250.port.flags |= UPF_HARD_FLOW; + ret = serial8250_register_8250_port(&port8250); break; } diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c index 2cf5649..16e3615 100644 --- a/drivers/tty/serial/serial_core.c +++ b/drivers/tty/serial/serial_core.c @@ -170,8 +170,12 @@ static int uart_port_startup(struct tty_struct *tty, struct uart_state *state, if (tty->termios.c_cflag & CBAUD) uart_set_mctrl(uport, TIOCM_RTS | TIOCM_DTR); } - - if (tty_port_cts_enabled(port)) { + /* + * if hw support flow control without software intervention, + * then skip the below check + */ + if (tty_port_cts_enabled(port) && + !(uport->flags & UPF_HARD_FLOW)) { spin_lock_irq(&uport->lock); if (!(uport->ops->get_mctrl(uport) & TIOCM_CTS)) tty->hw_stopped = 1; @@ -2768,7 +2772,9 @@ void uart_handle_cts_change(struct uart_port *uport, unsigned int status) uport->icount.cts++; - if (tty_port_cts_enabled(port)) { + /* skip below code if the hw flow control is supported */ + if (tty_port_cts_enabled(port) && + !(uport->flags & UPF_HARD_FLOW)) { if (tty->hw_stopped) { if (status) { tty->hw_stopped = 0;