From patchwork Fri Feb 3 10:23:11 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 93168 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp525629qgi; Fri, 3 Feb 2017 02:25:23 -0800 (PST) X-Received: by 10.98.150.70 with SMTP id c67mr17003404pfe.84.1486117523164; Fri, 03 Feb 2017 02:25:23 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q5si25110532pfk.67.2017.02.03.02.25.22; Fri, 03 Feb 2017 02:25:23 -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 S1753333AbdBCKZD (ORCPT + 25 others); Fri, 3 Feb 2017 05:25:03 -0500 Received: from mail-wj0-f169.google.com ([209.85.210.169]:33554 "EHLO mail-wj0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753112AbdBCKX0 (ORCPT ); Fri, 3 Feb 2017 05:23:26 -0500 Received: by mail-wj0-f169.google.com with SMTP id la6so275611wjc.0 for ; Fri, 03 Feb 2017 02:23:26 -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=CnREFiNnqHl6LIxcsRKIDy83E+7UYP+/64RJ9cmGXXgW2ohqcTFnj7EEbK1n6gloeM jTV9aAgFU3uBb3jzKFlNbda01lmpZtRZPg4x3GUKZzsPfEkFiSLQGm8Q3d82HlGqCAFE L78cof/nwEmutx2gmXHs/9S7xdMN5FiP27Pb4= 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=KyHIG+w6ng8k8uogetM+ng1uCig4QKqPE32NMjsh+OydAtO4wIv07+Hapj4Sz0KIsp 4Q5M8xb0MJWnUVHDOc/x96k4Rh/WWdT2olHyFUasN5fA+zD/2W20kBKEd16Ylzy8g0fC 3vNuDEyXp+AlD43O5RYMZNMt/DJH+z5YJS1rCU0j2xeUVMW5kzOLKZWrbnpD/O3fJh0Q hs3M5EedwFBKLzlkeSeuvO9HN1Bo30GxRlVRXlZZED4zVjZP4NLLSNwFAuAl25BYpM83 PfnT+0TG+6j+zm/QI9ZUsECsh7NrE/QUDxlVDYmvXdTrBARAAgI206uWlI7kaJTPtSqO nzHA== X-Gm-Message-State: AIkVDXKjWVnyB2rbZHQ9ySv0B5KNBto9Q5u1tw8Rn1E3r6uk2gPGI3JkF0l5ESp9iKmb+VpX X-Received: by 10.223.136.109 with SMTP id e42mr11723708wre.14.1486117405444; Fri, 03 Feb 2017 02:23:25 -0800 (PST) Received: from dell.Home ([2a02:c7d:1faf:e900:a188:db10:388f:f973]) by smtp.gmail.com with ESMTPSA id z90sm44668100wrc.24.2017.02.03.02.23.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 03 Feb 2017 02:23:24 -0800 (PST) From: Lee Jones To: gregkh@linuxfoundation.org, jslaby@suse.com, linux-serial@vger.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 v4 02/10] serial: st-asc: Provide RTS functionality Date: Fri, 3 Feb 2017 10:23:11 +0000 Message-Id: <20170203102319.23489-3-lee.jones@linaro.org> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170203102319.23489-1-lee.jones@linaro.org> References: <20170203102319.23489-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]; }