From patchwork Thu May 1 19:04:53 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Murali Karicheri X-Patchwork-Id: 29529 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ob0-f200.google.com (mail-ob0-f200.google.com [209.85.214.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 6A0B020675 for ; Thu, 1 May 2014 19:05:51 +0000 (UTC) Received: by mail-ob0-f200.google.com with SMTP id vb8sf18442457obc.7 for ; Thu, 01 May 2014 12:05:50 -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=+jvm+WAPfaPGPO6agmNuZ6syB/UU+sTDP1dxH8FlOF4=; b=d3LuQfADrjciedzx82+/peq7Fgfq91iwwvjj0J3SCsK4m6EElYumrug/p7G0/MD6CL kUL0BwpzYTcWzTqydRlYnvrld4nBeZW6G1T2R3FlHxs3mfgJXPXVuSs38FstRUSMqNJy +Z7e+7BmhW2+Ks3YtH+zWM0oxcZkylMV1qOAcNFNMJ+IfRbSXPuHQb626MNyqGyywHcL jUmlkgPV7COYiWLh5g3ewoBLUajECS2cHVd/2MeVkJjb9Yi9SU8RAlwJ4DABSRQ3y3Nz 5uhzGs8QXcoR5IpkDVDyQsmwtpzw9/4ClRrAKpIXPWjf7p0DTmR6vsebPu34kvfzHWOB 0/0g== X-Gm-Message-State: ALoCoQkyUzAujY5byV3QFQtYaufRtus1543tq0PGHQ1m+IL6ZL1A9DoKHzM0U4BoTFrLTWugdFAV X-Received: by 10.43.88.73 with SMTP id az9mr5742750icc.5.1398971150590; Thu, 01 May 2014 12:05:50 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.38.133 with SMTP id t5ls1233240qgt.43.gmail; Thu, 01 May 2014 12:05:50 -0700 (PDT) X-Received: by 10.52.134.136 with SMTP id pk8mr5775vdb.70.1398971150363; Thu, 01 May 2014 12:05:50 -0700 (PDT) Received: from mail-ve0-f172.google.com (mail-ve0-f172.google.com [209.85.128.172]) by mx.google.com with ESMTPS id sh5si6214221vdc.68.2014.05.01.12.05.50 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 01 May 2014 12:05:50 -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.128.172; Received: by mail-ve0-f172.google.com with SMTP id jy13so4289984veb.17 for ; Thu, 01 May 2014 12:05:50 -0700 (PDT) X-Received: by 10.220.188.10 with SMTP id cy10mr877081vcb.36.1398971150272; Thu, 01 May 2014 12:05:50 -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 ib8csp47225vcb; Thu, 1 May 2014 12:05:49 -0700 (PDT) X-Received: by 10.67.5.7 with SMTP id ci7mr23925629pad.99.1398971149327; Thu, 01 May 2014 12:05:49 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id fd9si21578155pad.388.2014.05.01.12.05.48 for ; Thu, 01 May 2014 12:05:48 -0700 (PDT) Received-SPF: none (google.com: linux-kernel-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 S1751804AbaEATFh (ORCPT + 28 others); Thu, 1 May 2014 15:05:37 -0400 Received: from comal.ext.ti.com ([198.47.26.152]:52460 "EHLO comal.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751706AbaEATFf (ORCPT ); Thu, 1 May 2014 15:05:35 -0400 Received: from dflxv15.itg.ti.com ([128.247.5.124]) by comal.ext.ti.com (8.13.7/8.13.7) with ESMTP id s41J4tCq002796; Thu, 1 May 2014 14:04:55 -0500 Received: from DFLE72.ent.ti.com (dfle72.ent.ti.com [128.247.5.109]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id s41J4tbU024628; Thu, 1 May 2014 14:04:55 -0500 Received: from dlep33.itg.ti.com (157.170.170.75) by DFLE72.ent.ti.com (128.247.5.109) with Microsoft SMTP Server id 14.3.174.1; Thu, 1 May 2014 14:04:54 -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 s41J4sYP014807; Thu, 1 May 2014 14:04:54 -0500 Received: from a0868495 by ares-ubuntu.am.dhcp.ti.com with local (Exim 4.76) (envelope-from ) id 1WfwHu-0004TP-AW; Thu, 01 May 2014 15:04:54 -0400 From: Murali Karicheri To: , , , CC: Murali Karicheri , Rob Herring , Pawel Moll , Mark Rutland , "Ian Campbell" , Kumar Gala , Randy Dunlap , Greg Kroah-Hartman , Jiri Slaby , Santosh Shilimkar Subject: [PATCH v2] serial: uart: add hw flow control support configuration Date: Thu, 1 May 2014 15:04:53 -0400 Message-ID: <1398971093-17164-1-git-send-email-m-karicheri2@ti.com> X-Mailer: git-send-email 1.7.9.5 MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@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 Tested-by: dann frazier --- .../devicetree/bindings/serial/of-serial.txt | 1 + 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, 18 insertions(+), 5 deletions(-) diff --git a/Documentation/devicetree/bindings/serial/of-serial.txt b/Documentation/devicetree/bindings/serial/of-serial.txt index 1928a3e..7705477 100644 --- a/Documentation/devicetree/bindings/serial/of-serial.txt +++ b/Documentation/devicetree/bindings/serial/of-serial.txt @@ -37,6 +37,7 @@ 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. +- has-hw-flow-control: the hardware has flow control capability. Example: diff --git a/drivers/tty/serial/8250/8250_core.c b/drivers/tty/serial/8250/8250_core.c index 0e1bf88..b69aff2 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..77ec6a1 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, + "has-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 b68550d..851707a 100644 --- a/drivers/tty/serial/serial_core.c +++ b/drivers/tty/serial/serial_core.c @@ -174,8 +174,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; @@ -2772,7 +2776,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;