From patchwork Tue Jan 24 13:43:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 92354 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp1718381qgi; Tue, 24 Jan 2017 05:43:29 -0800 (PST) X-Received: by 10.98.89.21 with SMTP id n21mr39241886pfb.163.1485265409165; Tue, 24 Jan 2017 05:43:29 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p126si19203324pfg.209.2017.01.24.05.43.28; Tue, 24 Jan 2017 05:43:29 -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 S1751146AbdAXNnV (ORCPT + 25 others); Tue, 24 Jan 2017 08:43:21 -0500 Received: from mail-wm0-f46.google.com ([74.125.82.46]:38323 "EHLO mail-wm0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750972AbdAXNlS (ORCPT ); Tue, 24 Jan 2017 08:41:18 -0500 Received: by mail-wm0-f46.google.com with SMTP id r144so209572051wme.1 for ; Tue, 24 Jan 2017 05:41:18 -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=XUYm1776dO3/GxAeGc68Bd4UjRLYuKRKuBg+0C++tm4=; b=CzAng511mV+2lyeERghR0J1kuGBexOT5URnnuqd2xV1e+kuyCpa3mbaFcRa9KGcyX2 IhGLEgcRFv7MyKQYKX3Pf2oVjSPi4Mx82CU0N9opuzeKsHL3wL1PTfgXoJGDxB+h3KwV SnpvpLlZpP2Z7GasSSiyBZ3TrW2zaHRtIXO9o= 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=XUYm1776dO3/GxAeGc68Bd4UjRLYuKRKuBg+0C++tm4=; b=TXxzsgayN//g51r6+AW4tYy1L5+m2jlQXYryYBqFatTJF1tt111K7RP9tHyc+qBpDy XZSq9O1JGhj51Pite8gibBUGswhAb/eI23vMyNOUo2maOxKDjCGminKawR++AZAi+v7b ZohSIMPVv/9Jong7ohnmoPecxnyVnT8RBVNB/Vrc6zSfXzVqgeqA+i4llq2P+3TXZWSV lTfK7s6IzYctIuyWplfOM38gC3o7UqCO9K419+zXPg7Fps3mR0/vOYjyypzOUty4TnXj 8WgzwyaAttf72tSoBrVHHIKCzc1W+MSxlnNJHfajcrquwu75hoCEFRaiuQpU+4RVnlf+ 1gjQ== X-Gm-Message-State: AIkVDXJlfSgLVSZTyduibbL8HJdVDssyvi9oPoUdt6FgU9f+OXLS+nmcyJ29kIsONWQ7ClTr X-Received: by 10.28.92.83 with SMTP id q80mr18828730wmb.69.1485265277347; Tue, 24 Jan 2017 05:41:17 -0800 (PST) Received: from localhost.localdomain (host81-129-172-30.range81-129.btcentralplus.com. [81.129.172.30]) by smtp.gmail.com with ESMTPSA id d42sm19966165wrd.7.2017.01.24.05.41.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 24 Jan 2017 05:41:16 -0800 (PST) From: Lee Jones To: gregkh@linuxfoundation.org, jslaby@suse.com, linux-serial@vger.kernel.org, robh+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 2/8] serial: st-asc: Provide RTS functionality Date: Tue, 24 Jan 2017 13:43:04 +0000 Message-Id: <20170124134310.27512-3-lee.jones@linaro.org> X-Mailer: git-send-email 2.10.2 In-Reply-To: <20170124134310.27512-1-lee.jones@linaro.org> References: <20170124134310.27512-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. Signed-off-by: Lee Jones --- drivers/tty/serial/st-asc.c | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) -- 2.10.2 Acked-by: Peter Griffin 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]; }