From patchwork Fri Jan 27 17:27:56 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 92701 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp341247qgi; Fri, 27 Jan 2017 09:28:51 -0800 (PST) X-Received: by 10.98.82.216 with SMTP id g207mr10441443pfb.32.1485538131294; Fri, 27 Jan 2017 09:28:51 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c85si5023767pfk.224.2017.01.27.09.28.51; Fri, 27 Jan 2017 09:28:51 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933984AbdA0R2m (ORCPT + 25 others); Fri, 27 Jan 2017 12:28:42 -0500 Received: from mail-wm0-f53.google.com ([74.125.82.53]:36583 "EHLO mail-wm0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933292AbdA0R2e (ORCPT ); Fri, 27 Jan 2017 12:28:34 -0500 Received: by mail-wm0-f53.google.com with SMTP id c85so126743361wmi.1 for ; Fri, 27 Jan 2017 09:28:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=+TbcK3tAl8wsPQttyRMVtqp4DdtulUNNux8iFzN1UPI=; b=BIvDXgvgWSzew4DIFlCwQXs5mNdSG+6Jv1d7vA7il9npjKwwmR8cqfcEWx3wVPifkH Y/p4sNg3PF+OBBY+eG6H2Kqz3l4DroxXRIIeaXf09nE72JzXwRlayddIi/ld7zcSLiU3 QlGAOoPfRENlBUS4rY1DfFtzonpERGu5stpc4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=+TbcK3tAl8wsPQttyRMVtqp4DdtulUNNux8iFzN1UPI=; b=eaVW1nPhkHtXodBcgpXFJE6RX0/S7ew2BXySYePLRXYXI5FKsfqDVOoBS4e8ZqphSW 73rvfeyjzaDEfmsyw8H3TWQIeY1xnbofIA5j2lkvHVTx1eGTgNzpMngY0ydsdzVvKUpn Oxxx6xWH3vJNKF1tgjxVTVEsLDqK8WqwQxTmRjlTXW5cgTOLyK843S0DpgC7xfyWd66F HCzRuw6mBM+0wkM5fkpP92QJ7GL7ZTs8Gonn12c2Ye47NUvooc8QpESzByxI/UxCsU51 lrUJp37of627yxqzfPRhu6OEZ3fq31x/PD+WTymCnqRg6KgqQXChXuFOo+jYFV06lm9d EkbQ== X-Gm-Message-State: AIkVDXK1oDAMBV9dfURoPXOqqji8G+dEqvWiqyHOSnQF73HSL+UL1daU+hcN0I5ANb4HJscs X-Received: by 10.223.168.111 with SMTP id l102mr8250223wrc.150.1485538103132; Fri, 27 Jan 2017 09:28:23 -0800 (PST) Received: from localhost.localdomain ([2a01:4c8:1b:eeec:f122:1b92:9371:359c]) by smtp.gmail.com with ESMTPSA id k4sm4822140wmf.22.2017.01.27.09.28.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 27 Jan 2017 09:28:22 -0800 (PST) From: Lee Jones To: gregkh@linuxfoundation.org, jslaby@suse.com, linux-serial@vger.kernel.org, dt@kernel.org, devicetree@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, kernel@stlinux.com, patrice.chotard@st.com, Lee Jones Subject: [PATCH v2 02/10] serial: st-asc: Provide RTS functionality Date: Fri, 27 Jan 2017 17:27:56 +0000 Message-Id: <20170127172804.23881-3-lee.jones@linaro.org> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170127172804.23881-1-lee.jones@linaro.org> References: <20170127172804.23881-1-lee.jones@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Until this point, it has not been possible for userland serial applications (e.g. stty) to toggle the UART RTS line. This can be useful with certain configurations. For example, when using a Mezzanine on a Linaro 96board, RTS line is used to take the on-board microcontroller in and out of reset. Acked-by: Peter Griffin Signed-off-by: Lee Jones --- drivers/tty/serial/st-asc.c | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) -- 2.9.3 diff --git a/drivers/tty/serial/st-asc.c b/drivers/tty/serial/st-asc.c index 69e6232..397df50 100644 --- a/drivers/tty/serial/st-asc.c +++ b/drivers/tty/serial/st-asc.c @@ -30,6 +30,7 @@ #include #include #include +#include #define DRIVER_NAME "st-asc" #define ASC_SERIAL_NAME "ttyAS" @@ -38,6 +39,7 @@ struct asc_port { struct uart_port port; + struct gpio_desc *rts; struct clk *clk; unsigned int hw_flow_control:1; unsigned int force_m1:1; @@ -391,12 +393,27 @@ static unsigned int asc_tx_empty(struct uart_port *port) static void asc_set_mctrl(struct uart_port *port, unsigned int mctrl) { + struct asc_port *ascport = to_asc_port(port); + /* - * This routine is used for seting signals of: DTR, DCD, CTS/RTS - * We use ASC's hardware for CTS/RTS, so don't need any for that. - * Some boards have DTR and DCD implemented using PIO pins, - * code to do this should be hooked in here. + * This routine is used for seting signals of: DTR, DCD, CTS and RTS. + * We use ASC's hardware for CTS/RTS when hardware flow-control is + * enabled, however if the RTS line is required for another purpose, + * commonly controlled using HUP from userspace, then we need to toggle + * it manually, using GPIO. + * + * Some boards also have DTR and DCD implemented using PIO pins, code to + * do this should be hooked in here. */ + + if (!ascport->rts) + return; + + /* If HW flow-control is enabled, we can't fiddle with the RTS line */ + if (asc_in(port, ASC_CTL) & ASC_CTL_CTSENABLE) + return; + + gpiod_set_value(ascport->rts, mctrl & TIOCM_RTS); } static unsigned int asc_get_mctrl(struct uart_port *port) @@ -726,6 +743,8 @@ static struct asc_port *asc_of_get_asc_port(struct platform_device *pdev) "st,hw-flow-control"); asc_ports[id].force_m1 = of_property_read_bool(np, "st,force_m1"); asc_ports[id].port.line = id; + asc_ports[id].rts = NULL; + return &asc_ports[id]; }