From patchwork Tue Oct 16 10:59:04 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Russell King X-Patchwork-Id: 1599981 Return-Path: X-Original-To: patchwork-linux-omap@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id E667540ABA for ; Tue, 16 Oct 2012 10:59:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753527Ab2JPK7L (ORCPT ); Tue, 16 Oct 2012 06:59:11 -0400 Received: from caramon.arm.linux.org.uk ([78.32.30.218]:53220 "EHLO caramon.arm.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753839Ab2JPK7J (ORCPT ); Tue, 16 Oct 2012 06:59:09 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=arm.linux.org.uk; s=caramon; h=Date:Sender:Message-Id:Subject:To:From:References:In-Reply-To; bh=6sm9aWMTDZVTChGa91yo/4ZeSPgQ0IwN4jXZKoEaBOI=; b=hzmGJ0b9EACDaLW3mjmi6SJWnshXY9dayeeOyxuetLO6JiZW7a3nKTRaQl7LjhChRyEf+jhf+qR7cKRCyyT+hGYCWxYpNorkt+otYgfywlHHPlG11suqgOTETrmVRsVquayF+3JNMq9JH4WCkI0j7bq0V80Rivsp99LZQJw4Mcs=; Received: from e0022681537dd.dyn.arm.linux.org.uk ([2002:4e20:1eda:1:222:68ff:fe15:37dd]:51479 helo=rmk-PC.arm.linux.org.uk) by caramon.arm.linux.org.uk with esmtpsa (TLSv1:AES256-SHA:256) (Exim 4.76) (envelope-from ) id 1TO4rZ-00007c-1r; Tue, 16 Oct 2012 11:59:05 +0100 Received: from rmk by rmk-PC.arm.linux.org.uk with local (Exim 4.76) (envelope-from ) id 1TO4rY-0000W2-8X; Tue, 16 Oct 2012 11:59:04 +0100 In-Reply-To: <20121016101458.GZ21164@n2100.arm.linux.org.uk> References: <20121016101458.GZ21164@n2100.arm.linux.org.uk> From: Russell King To: , Subject: [PATCH 04/11] SERIAL: core: add throttle/unthrottle callbacks for hardware assisted flow control Message-Id: Date: Tue, 16 Oct 2012 11:59:04 +0100 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org Add two callbacks for hardware assisted flow control; we need to know when the tty layers want us to stop and restart due to their buffer levels. Call a driver specific throttle/unthrottle function if and only if the driver indicates that it is using an enabled hardware assisted flow control method, otherwise fall back to the non-hardware assisted methods. Acked-by: Alan Cox Signed-off-by: Russell King --- drivers/tty/serial/serial_core.c | 31 +++++++++++++++++++++++++++---- include/linux/serial_core.h | 2 ++ 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c index 9d8796e..098bb99 100644 --- a/drivers/tty/serial/serial_core.c +++ b/drivers/tty/serial/serial_core.c @@ -610,27 +610,50 @@ static void uart_send_xchar(struct tty_struct *tty, char ch) static void uart_throttle(struct tty_struct *tty) { struct uart_state *state = tty->driver_data; + struct uart_port *port = state->uart_port; + uint32_t mask = 0; if (I_IXOFF(tty)) + mask |= UPF_SOFT_FLOW; + if (tty->termios.c_cflag & CRTSCTS) + mask |= UPF_HARD_FLOW; + + if (port->flags & mask) { + port->ops->throttle(port); + mask &= ~port->flags; + } + + if (mask & UPF_SOFT_FLOW) uart_send_xchar(tty, STOP_CHAR(tty)); - if (tty->termios.c_cflag & CRTSCTS) - uart_clear_mctrl(state->uart_port, TIOCM_RTS); + if (mask & UPF_HARD_FLOW) + uart_clear_mctrl(port, TIOCM_RTS); } static void uart_unthrottle(struct tty_struct *tty) { struct uart_state *state = tty->driver_data; struct uart_port *port = state->uart_port; + uint32_t mask = 0; - if (I_IXOFF(tty)) { + if (I_IXOFF(tty)) + mask |= UPF_SOFT_FLOW; + if (tty->termios.c_cflag & CRTSCTS) + mask |= UPF_HARD_FLOW; + + if (port->flags & mask) { + port->ops->unthrottle(port); + mask &= ~port->flags; + } + + if (mask & UPF_SOFT_FLOW) { if (port->x_char) port->x_char = 0; else uart_send_xchar(tty, START_CHAR(tty)); } - if (tty->termios.c_cflag & CRTSCTS) + if (mask & UPF_HARD_FLOW) uart_set_mctrl(port, TIOCM_RTS); } diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h index e2cda5d..c6690a2 100644 --- a/include/linux/serial_core.h +++ b/include/linux/serial_core.h @@ -46,6 +46,8 @@ struct uart_ops { unsigned int (*get_mctrl)(struct uart_port *); void (*stop_tx)(struct uart_port *); void (*start_tx)(struct uart_port *); + void (*throttle)(struct uart_port *); + void (*unthrottle)(struct uart_port *); void (*send_xchar)(struct uart_port *, char ch); void (*stop_rx)(struct uart_port *); void (*enable_ms)(struct uart_port *);