From patchwork Wed Feb 1 14:31:37 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 93032 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp2443595qgi; Wed, 1 Feb 2017 06:32:20 -0800 (PST) X-Received: by 10.99.102.135 with SMTP id a129mr4027239pgc.220.1485959540313; Wed, 01 Feb 2017 06:32:20 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m32si19326794pld.31.2017.02.01.06.32.20; Wed, 01 Feb 2017 06:32:20 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-serial-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-serial-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-serial-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751722AbdBAOb4 (ORCPT + 2 others); Wed, 1 Feb 2017 09:31:56 -0500 Received: from mail-wm0-f51.google.com ([74.125.82.51]:38105 "EHLO mail-wm0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751694AbdBAOby (ORCPT ); Wed, 1 Feb 2017 09:31:54 -0500 Received: by mail-wm0-f51.google.com with SMTP id r141so41166160wmg.1 for ; Wed, 01 Feb 2017 06:31:54 -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=Cl47T1k+1yfQv+bczL2EGud1S5wFTOL8UU37tjHcLAIhM62X7IGXdQlgg7rrNRgzMz s+RR3T6vaYfSbZsVrtKUM9Y2v+3H1dRgHEiGm8smxW3AvShUPVApKyOSBezS0fFKWg2z KvAY4ca1Zt/6+haQLjB/llcZPoyWib13BILn4= 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=ljC9fX0OneMonaC0+RTSU63D1CtAhmkqhx2XBLLbCh2SEg+X6UdDPQPeMuIXL2WFYD QVCzyG42E1fQSoXr9SbHGAjlpA+f+2y+/HqAXmBigPy2M6RcbQr8qrrsUyOyngVTDSgm babRGRusofovWm7rT4z0JH84YCi6m5zT/5zi2DMWLjLstwD5nmIdb7qsR0PbhlFiJYoO tAfZyIseyO1XFLxfA8UbFy4FHHiH/C5wPqTP67jnuK5i2CoILBOVW7FZ8FIwdW1/8UL0 adLPLBf/3AjTvqbNbV2+/wWuZ+1eJkRrRP4U+TJhE66r52Z5BFRjuYWd6hYoUPz8knc8 ggmA== X-Gm-Message-State: AIkVDXL7tHYJCcLzVvNymtz4oTQ3vsQGVD4BK/IqtBK39je+PpbrmNlDXrVHsi4OtLsTlf1c X-Received: by 10.28.218.4 with SMTP id r4mr22580783wmg.105.1485959513193; Wed, 01 Feb 2017 06:31:53 -0800 (PST) Received: from localhost.localdomain (host81-158-165-111.range81-158.btcentralplus.com. [81.158.165.111]) by smtp.gmail.com with ESMTPSA id l37sm34420245wrc.41.2017.02.01.06.31.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 01 Feb 2017 06:31:52 -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: Wed, 1 Feb 2017 14:31:37 +0000 Message-Id: <20170201143145.31962-3-lee.jones@linaro.org> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170201143145.31962-1-lee.jones@linaro.org> References: <20170201143145.31962-1-lee.jones@linaro.org> Sender: linux-serial-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-serial@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 -- To unsubscribe from this list: send the line "unsubscribe linux-serial" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html 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]; }