Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1571602

[PATCH v2 04/10] serial: st-asc: (De)Register GPIOD and swap Pinctrl profiles

Path csiph.com!1.us.feeder.erje.net!2.us.feeder.erje.net!feeder.erje.net!1.eu.feeder.erje.net!news.unit0.net!news.mixmin.net!aioe.org!bofh.it!news.nic.it!robomod
From Lee Jones <lee.jones@linaro.org>
Newsgroups linux.kernel
Subject [PATCH v2 04/10] serial: st-asc: (De)Register GPIOD and swap Pinctrl profiles
Date Wed, 01 Feb 2017 15:40:03 +0100
Message-ID <t64eL-77f-47@gated-at.bofh.it> (permalink)
References <t64eJ-77f-5@gated-at.bofh.it>
X-Original-To gregkh@linuxfoundation.org, jslaby@suse.com, linux-serial@vger.kernel.org, dt@kernel.org, devicetree@vger.kernel.org
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=QZqEtxbJaAwjhluOCHRbfBz0Vzpu3RRdbwtfDDHXKNMHVPVW+83XObO56Eoc1krOAW /KkEqYpj9i1oVhFBogx3qY52vskgORWpduzjWuU//4salyxLkpnCk7SO//fdihxBkpSV QSEuL/iDO1ooX7UKYlsLD4AFH7WmP6Euc/cz4=
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=IvnPJ+x9XJLsIOKM9w1mIhi3AiNKqYt+YhJyNgZv/YLeopy+Ni4//zwDsH/Fjd2KlY vz8c53ZaahM6NKjfAbegFN/qYuCdZfFYOQy5EZq0SRJ5oIcfnjpn+4RSLDUoplcXqwM/ sjXz9qahm9xmEa8Q5vxFBH8yRy0cjgMkXFSq9A9MzHgH3b27y0M5AauhwRFZI6h1C2+9 P0mTaGrWTIyFC2doVM+VC0q8XMs84f/gFAOF3leUdDxRF7NlZuWwmBRY2Nk6x7IN73vj WSipqRjO9YsvccRgdsclR6i9Zowls+9u0WF9vKP27brSnf3RITjc11UQ2DERAFB2vAKa 6tXA==
X-Gm-Message-State AIkVDXKlL+2q5HzuK3vizUGwdXKoc1CBR7BBBA7aiYSl/C2S6SPd8c/o9us1qPcuVK4EACIv
X-Received by 10.223.150.34 with SMTP id b31mr2969464wra.196.1485959516900; Wed, 01 Feb 2017 06:31:56 -0800 (PST)
X-Mailer git-send-email 2.9.3
Sender robomod@news.nic.it
List-ID <linux-kernel.vger.kernel.org>
X-Mailing-List linux-kernel@vger.kernel.org
Approved robomod@news.nic.it
Lines 65
Organization linux.* mail to news gateway
X-Original-Cc linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, kernel@stlinux.com, patrice.chotard@st.com, Lee Jones <lee.jones@linaro.org>
X-Original-Date Wed, 1 Feb 2017 14:31:39 +0000
X-Original-Message-ID <20170201143145.31962-5-lee.jones@linaro.org>
X-Original-References <20170201143145.31962-1-lee.jones@linaro.org>
X-Original-Sender linux-kernel-owner@vger.kernel.org
Xref csiph.com linux.kernel:1571602

Show key headers only | View raw


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 <peter.griffin@linaro.org>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
---
 drivers/tty/serial/st-asc.c | 27 ++++++++++++++++++++++++++-
 1 file changed, 26 insertions(+), 1 deletion(-)

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 {
-- 
2.9.3

Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH v2 00/10] serial: st-asc: Allow handling of RTS line Lee Jones <lee.jones@linaro.org> - 2017-02-01 15:40 +0100
  [PATCH v2 04/10] serial: st-asc: (De)Register GPIOD and swap Pinctrl profiles Lee Jones <lee.jones@linaro.org> - 2017-02-01 15:40 +0100
  [PATCH v2 08/10] ARM: dts: STiH407-pinctrl: Add Pinctrl group for HW flow-control Lee Jones <lee.jones@linaro.org> - 2017-02-01 15:40 +0100
  [PATCH v2 03/10] serial: st-asc: Read in all Pinctrl states Lee Jones <lee.jones@linaro.org> - 2017-02-01 15:40 +0100
    Re: [STLinux Kernel] [PATCH v2 03/10] serial: st-asc: Read in all  Pinctrl states Peter Griffin <peter.griffin@linaro.org> - 2017-02-01 16:00 +0100
  Re: [PATCH v2 00/10] serial: st-asc: Allow handling of RTS line Greg KH <gregkh@linuxfoundation.org> - 2017-02-03 10:20 +0100
    Re: [PATCH v2 00/10] serial: st-asc: Allow handling of RTS line Lee Jones <lee.jones@linaro.org> - 2017-02-03 11:20 +0100

csiph-web