From: Lee Jones <lee.jones@linaro.org>
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 <lee.jones@linaro.org>
Subject: [PATCH 4/8] serial: st-asc: (De)Register GPIOD and swap Pinctrl profiles
Date: Tue, 24 Jan 2017 13:43:06 +0000 [thread overview]
Message-ID: <20170124134310.27512-5-lee.jones@linaro.org> (raw)
In-Reply-To: <20170124134310.27512-1-lee.jones@linaro.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.
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 03801ed..2c4b5f5 100644
--- a/drivers/tty/serial/st-asc.c
+++ b/drivers/tty/serial/st-asc.c
@@ -512,6 +512,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;
@@ -555,9 +557,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[MANUAL_RTS]) {
+ pinctrl_select_state(ascport->pinctrl,
+ ascport->states[MANUAL_RTS]);
+
+ 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.10.2
next prev parent reply other threads:[~2017-01-24 13:43 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-24 13:43 [PATCH 0/8] serial: st-asc: Allow handling of RTS line Lee Jones
[not found] ` <20170124134310.27512-1-lee.jones-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2017-01-24 13:43 ` [PATCH 1/8] serial: st-asc: Ignore the parity error bit if 8-bit mode is enabled Lee Jones
2017-01-25 11:02 ` [STLinux Kernel] " Peter Griffin
2017-01-24 13:43 ` [PATCH 2/8] serial: st-asc: Provide RTS functionality Lee Jones
2017-01-25 11:03 ` [STLinux Kernel] " Peter Griffin
2017-01-24 13:43 ` [PATCH 3/8] serial: st-asc: Read in all Pinctrl states Lee Jones
2017-01-24 21:28 ` kbuild test robot
2017-01-25 11:21 ` [STLinux Kernel] " Peter Griffin
2017-01-27 11:54 ` Lee Jones
2017-01-30 14:23 ` Peter Griffin
2017-01-30 15:32 ` Lee Jones
2017-01-30 16:10 ` Peter Griffin
2017-01-30 19:11 ` Lee Jones
2017-01-30 22:35 ` Peter Griffin
2017-01-31 10:13 ` Lee Jones
2017-01-31 11:31 ` Peter Griffin
2017-01-31 12:27 ` Lee Jones
2017-02-01 11:50 ` Peter Griffin
2017-02-01 12:47 ` Lee Jones
2017-01-24 13:43 ` [PATCH 8/8] ARM: dts: STiH407-family: Enable HW flow-control Lee Jones
[not found] ` <20170124134310.27512-9-lee.jones-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2017-01-25 10:59 ` [STLinux Kernel] " Peter Griffin
2017-01-25 11:40 ` Peter Griffin
2017-01-27 11:33 ` Lee Jones
2017-01-27 11:32 ` Lee Jones
2017-01-24 13:43 ` Lee Jones [this message]
[not found] ` <20170124134310.27512-5-lee.jones-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2017-01-24 22:00 ` [PATCH 4/8] serial: st-asc: (De)Register GPIOD and swap Pinctrl profiles kbuild test robot
2017-01-25 11:24 ` [STLinux Kernel] " Peter Griffin
2017-01-24 13:43 ` [PATCH 5/8] ARM: dts: STiH410-b2260: Identify the UART RTS line Lee Jones
2017-01-24 13:43 ` [PATCH 6/8] ARM: dts: STiH407-pinctrl: Add Pinctrl group for HW flow-control Lee Jones
2017-01-25 11:01 ` [STLinux Kernel] " Peter Griffin
2017-01-24 13:43 ` [PATCH 7/8] ARM: dts: STiH407-family: Use new Pinctrl groups Lee Jones
2017-01-25 11:54 ` [STLinux Kernel] " Peter Griffin
2017-01-27 11:03 ` Lee Jones
2017-01-27 11:29 ` Lee Jones
2017-01-25 10:07 ` [PATCH 0/8] serial: st-asc: Allow handling of RTS line Greg KH
[not found] ` <20170125100722.GB17954-U8xfFu+wG4EAvxtiuMwx3w@public.gmane.org>
2017-01-25 15:35 ` Lee Jones
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170124134310.27512-5-lee.jones@linaro.org \
--to=lee.jones@linaro.org \
--cc=devicetree@vger.kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=jslaby@suse.com \
--cc=kernel@stlinux.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-serial@vger.kernel.org \
--cc=patrice.chotard@st.com \
--cc=robh+dt@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).