From patchwork Fri Apr 11 19:17:57 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Murali Karicheri X-Patchwork-Id: 28291 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ob0-f197.google.com (mail-ob0-f197.google.com [209.85.214.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 016412100C for ; Fri, 11 Apr 2014 19:19:00 +0000 (UTC) Received: by mail-ob0-f197.google.com with SMTP id wp18sf27059914obc.4 for ; Fri, 11 Apr 2014 12:19:00 -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=gq3m4JXfUnEz5Op3dW5UINSu9eo7SGT6WE7MSGhy1dM=; b=HWZTda7uC8or9xQrg3G/qtO9JPmCWwQO2PZgc5KdlJCb7Pph/k4rQSc9tw7eMth71y 9vAt0+BYVsOEYNJqcGvuOecza07TOB12CdKv2TuYNU0MA2P91Q+pJ7l/7JkLQ06RB+Dr ucly6E40GdwyeOtS6IWHhAP2FG9aVcyMPk21E1Bxwab6G2bjUmmT6R+4m5zh+xlHLCp3 8MP2HlEjKjakkFwFfyusREBgVT/YWM0Y4EDcBYLdvW757jVPR1f8oDM97OS9yIO/ncoz xMWG+nbEmbihHs+kfqWo1x+dNk5CnzNQ+jhafrqxa5AZCHOAqr/cTT/SE1N0dIq7UPlJ O7hQ== X-Gm-Message-State: ALoCoQld1IaV7KN9x3YteRgssTiP7J42l49y0TQmi9PKt3XglPU9jODWR0YNyqyf0dMsbONzAIGw X-Received: by 10.43.135.4 with SMTP id ie4mr10945791icc.1.1397243940289; Fri, 11 Apr 2014 12:19:00 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.17.3 with SMTP id 3ls1747227qgc.83.gmail; Fri, 11 Apr 2014 12:19:00 -0700 (PDT) X-Received: by 10.221.29.137 with SMTP id ry9mr21378585vcb.6.1397243940128; Fri, 11 Apr 2014 12:19:00 -0700 (PDT) Received: from mail-vc0-f178.google.com (mail-vc0-f178.google.com [209.85.220.178]) by mx.google.com with ESMTPS id b7si1511967vev.94.2014.04.11.12.19.00 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 11 Apr 2014 12:19:00 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.178 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.178; Received: by mail-vc0-f178.google.com with SMTP id im17so5136838vcb.37 for ; Fri, 11 Apr 2014 12:19:00 -0700 (PDT) X-Received: by 10.52.25.202 with SMTP id e10mr2354209vdg.30.1397243940046; Fri, 11 Apr 2014 12:19:00 -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 ib8csp80742vcb; Fri, 11 Apr 2014 12:18:59 -0700 (PDT) X-Received: by 10.68.136.226 with SMTP id qd2mr14637745pbb.72.1397243939263; Fri, 11 Apr 2014 12:18:59 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id pu6si2682131pac.266.2014.04.11.12.18.58; Fri, 11 Apr 2014 12:18:58 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754493AbaDKTS5 (ORCPT + 9 others); Fri, 11 Apr 2014 15:18:57 -0400 Received: from comal.ext.ti.com ([198.47.26.152]:47078 "EHLO comal.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754477AbaDKTSy (ORCPT ); Fri, 11 Apr 2014 15:18:54 -0400 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by comal.ext.ti.com (8.13.7/8.13.7) with ESMTP id s3BJICLc024030; Fri, 11 Apr 2014 14:18:12 -0500 Received: from DFLE73.ent.ti.com (dfle73.ent.ti.com [128.247.5.110]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id s3BJICkG032011; Fri, 11 Apr 2014 14:18:12 -0500 Received: from dlep33.itg.ti.com (157.170.170.75) by DFLE73.ent.ti.com (128.247.5.110) with Microsoft SMTP Server id 14.3.174.1; Fri, 11 Apr 2014 14:18:11 -0500 Received: from ares-ubuntu.am.dhcp.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by dlep33.itg.ti.com (8.14.3/8.13.8) with ESMTP id s3BJIBvC023851; Fri, 11 Apr 2014 14:18:11 -0500 Received: from a0868495 by ares-ubuntu.am.dhcp.ti.com with local (Exim 4.76) (envelope-from ) id 1WYgxn-0006L7-42; Fri, 11 Apr 2014 15:18:11 -0400 From: Murali Karicheri To: , , , CC: , Murali Karicheri , Rob Herring , Mark Rutland , Ian Campbell , Kumar Gala , Randy Dunlap , Greg Kroah-Hartman , Jiri Slaby Subject: [PATCH] serial: uart: add hw flow control support configuration Date: Fri, 11 Apr 2014 15:17:57 -0400 Message-ID: <1397243877-23234-1-git-send-email-m-karicheri2@ti.com> X-Mailer: git-send-email 1.7.9.5 MIME-Version: 1.0 Sender: devicetree-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: devicetree@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: 209.85.220.178 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) 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. 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 Signed-off-by: Murali Karicheri --- .../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..6b1b868 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;