From patchwork Fri Feb 3 10:23:13 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 93167 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp525626qgi; Fri, 3 Feb 2017 02:25:22 -0800 (PST) X-Received: by 10.99.55.91 with SMTP id g27mr16862667pgn.65.1486117522794; Fri, 03 Feb 2017 02:25:22 -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:22 -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 S1753246AbdBCKZA (ORCPT + 25 others); Fri, 3 Feb 2017 05:25:00 -0500 Received: from mail-wm0-f53.google.com ([74.125.82.53]:34925 "EHLO mail-wm0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753148AbdBCKX3 (ORCPT ); Fri, 3 Feb 2017 05:23:29 -0500 Received: by mail-wm0-f53.google.com with SMTP id b65so21486434wmf.0 for ; Fri, 03 Feb 2017 02:23:28 -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=Nz6EcBz3574CcrlMAxjV2FdHcsra/7R+6yMcnHO9ZTA=; b=AjYnXZSUFL8XRo9dFfKQHJt452En9DtE+VF3BoHw2DD3VAfk/XbELo4TKyIPOfB0sk b8gwtefg9/uYfBOjSqC7Rfh5H+6/mzOyUWK9guCYjKA0HmlvPWdrdFm3w80sj2V7LDNz Yu5P2NUCf4Z0re4srg3iHNKL/252lLJotvfOo= 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=Nz6EcBz3574CcrlMAxjV2FdHcsra/7R+6yMcnHO9ZTA=; b=iyXpTCUKiTLNDpW5ogFqe2rZsoR5uhjBM05ZUg28Y9hfja3kuogDCELr8ADw3jRvHU po3h5TkRzhBZGMLhbRVoBm5nFx9FWpSDeC1qjXo4NpGcylcmfhYgyjzd4W1JT81WRXAx KnYxwWA81RcY+wzbjk4mpzU4mOR9fpZxJYSR4ewGxZetqJnPpayFwZAoiqQP603tH387 YhZ5w7ymPah9jhZWNeBeDf0efd1340jIGTzX3LqMeEmC554OjcRuJUal1gcPWdjo7cBk SsD3V4umfIqOOSVQBbm6uYiRnDOqyilwZS7w++MT9kyqlc+66b0d1BLZ8UO1lpax2y27 cByw== X-Gm-Message-State: AIkVDXK13ehDv2+pr8kMDcKhnVJAjoJstBxbnHovfkRPKnOo2pGk/hvKxWOlRLWBIfqN54p9 X-Received: by 10.223.168.87 with SMTP id l81mr13816705wrc.194.1486117407973; Fri, 03 Feb 2017 02:23:27 -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.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 03 Feb 2017 02:23:27 -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 04/10] serial: st-asc: (De)Register GPIOD and swap Pinctrl profiles Date: Fri, 3 Feb 2017 10:23:13 +0000 Message-Id: <20170203102319.23489-5-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 When hardware flow-control is disabled, manual toggling of the UART's reset line (RTS) using userland applications (e.g. stty) is not possible, since the ASC IP does not provide this functionality in the same was as some other IPs do. Thus, we have to do this manually. This patch ensures that when HW flow-control is disabled the RTS/CTS lines are free to be registered via the GPIO API. It also ensures any registered GPIO lines are unregistered when HW flow-control is requested, allowing the IP to control them automatically. Acked-by: Peter Griffin Signed-off-by: Lee Jones --- drivers/tty/serial/st-asc.c | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) -- 2.9.3 diff --git a/drivers/tty/serial/st-asc.c b/drivers/tty/serial/st-asc.c index 1058020..e521078 100644 --- a/drivers/tty/serial/st-asc.c +++ b/drivers/tty/serial/st-asc.c @@ -513,6 +513,8 @@ static void asc_set_termios(struct uart_port *port, struct ktermios *termios, struct ktermios *old) { struct asc_port *ascport = to_asc_port(port); + struct device_node *np = port->dev->of_node; + struct gpio_desc *gpiod; unsigned int baud; u32 ctrl_val; tcflag_t cflag; @@ -556,9 +558,32 @@ static void asc_set_termios(struct uart_port *port, struct ktermios *termios, ctrl_val |= ASC_CTL_PARITYODD; /* hardware flow control */ - if ((cflag & CRTSCTS)) + if ((cflag & CRTSCTS)) { ctrl_val |= ASC_CTL_CTSENABLE; + /* If flow-control selected, stop handling RTS manually */ + if (ascport->rts) { + devm_gpiod_put(port->dev, ascport->rts); + ascport->rts = NULL; + + pinctrl_select_state(ascport->pinctrl, + ascport->states[DEFAULT]); + } + } else { + /* If flow-control disabled, it's safe to handle RTS manually */ + if (!ascport->rts && ascport->states[NO_HW_FLOWCTRL]) { + pinctrl_select_state(ascport->pinctrl, + ascport->states[NO_HW_FLOWCTRL]); + + gpiod = devm_get_gpiod_from_child(port->dev, "rts", + &np->fwnode); + if (!IS_ERR(gpiod)) { + gpiod_direction_output(gpiod, 0); + ascport->rts = gpiod; + } + } + } + if ((baud < 19200) && !ascport->force_m1) { asc_out(port, ASC_BAUDRATE, (port->uartclk / (16 * baud))); } else {