Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1571592
| Path | csiph.com!1.us.feeder.erje.net!2.us.feeder.erje.net!feeder.erje.net!1.eu.feeder.erje.net!weretis.net!feeder4.news.weretis.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 02/10] serial: st-asc: Provide RTS functionality |
| Date | Wed, 01 Feb 2017 15:40:02 +0100 |
| Message-ID | <t64eK-77f-31@gated-at.bofh.it> (permalink) |
| References | <t64eJ-77f-5@gated-at.bofh.it> |
| 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=QPl/UqIWyAPsKvTLWcwz3sDe7wUWfEcVifdSdDZ+2fEz0WqwLgSrliVLIlDcsXdK3U nnsCUFrlRqLc+cG4je1znxikhtWGFfkR84dYv51BmdgjZozMLP41LTvLEc03yV6/mywx 6Q4b6EZ7iuQb5Zj7CFVP8d9c1f7n2c8rFjRuTRTa3ohKv+KqXCufinSMwo5kNjNWTItd kOdeaYLnVV8N7p5ILltiaDwh/2jvl0EPoy7aHH+w3Hb+w1iegDj1nfvn+k5jAXJymH98 sc+mRv8FYcj+uVb3r9yhi3Oe7jBwA9FH+LG8YXB39YZIRN7OogVRIFLoD/jnrdvg4bHP Dcpw== |
| X-Gm-Message-State | AIkVDXJhXNDvahlfzU6ZDxBbvK6A2KZEP+NhUYYhpC2KSjKI//cNB5n50yzEzf8L9qIgyJuo |
| X-Received | by 10.28.218.4 with SMTP id r4mr22580783wmg.105.1485959513193; Wed, 01 Feb 2017 06:31:53 -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 | 75 |
| 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:37 +0000 |
| X-Original-Message-ID | <20170201143145.31962-3-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:1571592 |
Show key headers only | View raw
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 <peter.griffin@linaro.org>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
---
drivers/tty/serial/st-asc.c | 27 +++++++++++++++++++++++----
1 file changed, 23 insertions(+), 4 deletions(-)
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 <linux/of_platform.h>
#include <linux/serial_core.h>
#include <linux/clk.h>
+#include <linux/gpio/consumer.h>
#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];
}
--
2.9.3
Back to linux.kernel | Previous | Next | Find similar | Unroll thread
[PATCH v2 02/10] serial: st-asc: Provide RTS functionality Lee Jones <lee.jones@linaro.org> - 2017-02-01 15:40 +0100
csiph-web