Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1573007 > unrolled thread
| Started by | Lee Jones <lee.jones@linaro.org> |
|---|---|
| First post | 2017-02-03 11:30 +0100 |
| Last post | 2017-02-03 11:30 +0100 |
| Articles | 10 — 2 participants |
Back to article view | Back to linux.kernel
[PATCH v4 00/10] serial: st-asc: Allow handling of RTS lin Lee Jones <lee.jones@linaro.org> - 2017-02-03 11:30 +0100
[PATCH v4 04/10] serial: st-asc: (De)Register GPIOD and swap Pinctrl profiles Lee Jones <lee.jones@linaro.org> - 2017-02-03 11:30 +0100
[PATCH v4 01/10] serial: st-asc: Ignore the parity error bit if 8-bit mode is enabled Lee Jones <lee.jones@linaro.org> - 2017-02-03 11:30 +0100
[PATCH v4 09/10] ARM: dts: STiH407-family: Use new Pinctrl groups Lee Jones <lee.jones@linaro.org> - 2017-02-03 11:30 +0100
[PATCH v4 07/10] ARM: dts: STiH410-b2260: Identify the UART RTS line Lee Jones <lee.jones@linaro.org> - 2017-02-03 11:30 +0100
[PATCH v4 08/10] ARM: dts: STiH407-pinctrl: Add Pinctrl group for HW flow-control Lee Jones <lee.jones@linaro.org> - 2017-02-03 11:30 +0100
[PATCH v4 06/10] dt-bindings: serial: Update 'uart-has-rtscts' description Lee Jones <lee.jones@linaro.org> - 2017-02-03 11:30 +0100
Re: [PATCH v4 06/10] dt-bindings: serial: Update 'uart-has-rtscts' description Rob Herring <robh@kernel.org> - 2017-02-08 22:20 +0100
[PATCH v4 10/10] ARM: dts: STiH410-b2260: Enable HW flow-control Lee Jones <lee.jones@linaro.org> - 2017-02-03 11:30 +0100
[PATCH v4 02/10] serial: st-asc: Provide RTS functionality Lee Jones <lee.jones@linaro.org> - 2017-02-03 11:30 +0100
| From | Lee Jones <lee.jones@linaro.org> |
|---|---|
| Date | 2017-02-03 11:30 +0100 |
| Subject | [PATCH v4 00/10] serial: st-asc: Allow handling of RTS lin |
| Message-ID | <t6JhT-kD-7@gated-at.bofh.it> |
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 set ensures the correct Pinctrl groups are configured and obtained for both manual toggling of the RTS line and for the IP to take over the lines when HW flow-control is requested by the user. Lee Jones (10): serial: st-asc: Ignore the parity error bit if 8-bit mode is enabled serial: st-asc: Provide RTS functionality serial: st-asc: Read in all Pinctrl states serial: st-asc: (De)Register GPIOD and swap Pinctrl profiles serial: st-asc: Use generic DT binding for announcing RTS/CTS lines dt-bindings: serial: Update 'uart-has-rtscts' description ARM: dts: STiH410-b2260: Identify the UART RTS line ARM: dts: STiH407-pinctrl: Add Pinctrl group for HW flow-control ARM: dts: STiH407-family: Use new Pinctrl groups ARM: dts: STiH410-b2260: Enable HW flow-control .../devicetree/bindings/serial/serial.txt | 3 +- arch/arm/boot/dts/stih407-family.dtsi | 3 +- arch/arm/boot/dts/stih407-pinctrl.dtsi | 12 ++- arch/arm/boot/dts/stih410-b2260.dts | 5 + drivers/tty/serial/st-asc.c | 101 +++++++++++++++++++-- 5 files changed, 110 insertions(+), 14 deletions(-) -- 2.9.3
[toc] | [next] | [standalone]
| From | Lee Jones <lee.jones@linaro.org> |
|---|---|
| Date | 2017-02-03 11:30 +0100 |
| Subject | [PATCH v4 04/10] serial: st-asc: (De)Register GPIOD and swap Pinctrl profiles |
| Message-ID | <t6JhT-kD-11@gated-at.bofh.it> |
| In reply to | #1573007 |
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
[toc] | [prev] | [next] | [standalone]
| From | Lee Jones <lee.jones@linaro.org> |
|---|---|
| Date | 2017-02-03 11:30 +0100 |
| Subject | [PATCH v4 01/10] serial: st-asc: Ignore the parity error bit if 8-bit mode is enabled |
| Message-ID | <t6JhT-kD-13@gated-at.bofh.it> |
| In reply to | #1573007 |
The datasheet states:
"If the MODE field selects an 8-bit frame then this [parity error] bit
is undefined. Software should ignore this bit when reading 8-bit frames."
Acked-by: Peter Griffin <peter.griffin@linaro.org>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
---
drivers/tty/serial/st-asc.c | 16 +++++++++++++---
1 file changed, 13 insertions(+), 3 deletions(-)
diff --git a/drivers/tty/serial/st-asc.c b/drivers/tty/serial/st-asc.c
index 379e5bd..69e6232 100644
--- a/drivers/tty/serial/st-asc.c
+++ b/drivers/tty/serial/st-asc.c
@@ -287,9 +287,19 @@ static void asc_transmit_chars(struct uart_port *port)
static void asc_receive_chars(struct uart_port *port)
{
struct tty_port *tport = &port->state->port;
- unsigned long status;
+ unsigned long status, mode;
unsigned long c = 0;
char flag;
+ bool ignore_pe = false;
+
+ /*
+ * Datasheet states: If the MODE field selects an 8-bit frame then
+ * this [parity error] bit is undefined. Software should ignore this
+ * bit when reading 8-bit frames.
+ */
+ mode = asc_in(port, ASC_CTL) & ASC_CTL_MODE_MSK;
+ if (mode == ASC_CTL_MODE_8BIT || mode == ASC_CTL_MODE_8BIT_PAR)
+ ignore_pe = true;
if (port->irq_wake)
pm_wakeup_event(tport->tty->dev, 0);
@@ -299,8 +309,8 @@ static void asc_receive_chars(struct uart_port *port)
flag = TTY_NORMAL;
port->icount.rx++;
- if ((c & (ASC_RXBUF_FE | ASC_RXBUF_PE)) ||
- status & ASC_STA_OE) {
+ if (status & ASC_STA_OE || c & ASC_RXBUF_FE ||
+ (c & ASC_RXBUF_PE && !ignore_pe)) {
if (c & ASC_RXBUF_FE) {
if (c == (ASC_RXBUF_FE | ASC_RXBUF_DUMMY_RX)) {
--
2.9.3
[toc] | [prev] | [next] | [standalone]
| From | Lee Jones <lee.jones@linaro.org> |
|---|---|
| Date | 2017-02-03 11:30 +0100 |
| Subject | [PATCH v4 09/10] ARM: dts: STiH407-family: Use new Pinctrl groups |
| Message-ID | <t6JhU-kD-19@gated-at.bofh.it> |
| In reply to | #1573007 |
Having just defined some new Pinctrl groups for when HW flow-control
is {en,dis}abled, let's reference them for use within the driver.
Acked-by: Peter Griffin <peter.griffin@linaro.org>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
---
arch/arm/boot/dts/stih407-family.dtsi | 3 +--
arch/arm/boot/dts/stih410-b2260.dts | 5 ++++-
2 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/arch/arm/boot/dts/stih407-family.dtsi b/arch/arm/boot/dts/stih407-family.dtsi
index c8b2944..e480e32 100644
--- a/arch/arm/boot/dts/stih407-family.dtsi
+++ b/arch/arm/boot/dts/stih407-family.dtsi
@@ -222,9 +222,8 @@
compatible = "st,asc";
reg = <0x9830000 0x2c>;
interrupts = <GIC_SPI 122 IRQ_TYPE_NONE>;
- pinctrl-names = "default";
- pinctrl-0 = <&pinctrl_serial0>;
clocks = <&clk_s_c0_flexgen CLK_EXT2F_A9>;
+ /* Pinctrl moved out to a per-board configuration */
status = "disabled";
};
diff --git a/arch/arm/boot/dts/stih410-b2260.dts b/arch/arm/boot/dts/stih410-b2260.dts
index fa16aba..cbcbcb4 100644
--- a/arch/arm/boot/dts/stih410-b2260.dts
+++ b/arch/arm/boot/dts/stih410-b2260.dts
@@ -62,8 +62,11 @@
/* Low speed expansion connector */
uart0: serial@9830000 {
label = "LS-UART0";
- status = "okay";
+ pinctrl-names = "default", "no-hw-flowctrl";
+ pinctrl-0 = <&pinctrl_serial0_hw_flowctrl>;
+ pinctrl-1 = <&pinctrl_serial0>;
rts-gpios = <&pio17 3 GPIO_ACTIVE_LOW>;
+ status = "okay";
};
/* Low speed expansion connector */
--
2.9.3
[toc] | [prev] | [next] | [standalone]
| From | Lee Jones <lee.jones@linaro.org> |
|---|---|
| Date | 2017-02-03 11:30 +0100 |
| Subject | [PATCH v4 07/10] ARM: dts: STiH410-b2260: Identify the UART RTS line |
| Message-ID | <t6JhU-kD-21@gated-at.bofh.it> |
| In reply to | #1573007 |
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 configures the UART RTS line as a GPIO for manipulation
within the UART driver when HW flow-control is not enabled.
Acked-by: Peter Griffin <peter.griffin@linaro.org>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
---
arch/arm/boot/dts/stih410-b2260.dts | 1 +
1 file changed, 1 insertion(+)
diff --git a/arch/arm/boot/dts/stih410-b2260.dts b/arch/arm/boot/dts/stih410-b2260.dts
index 06b0696..fa16aba 100644
--- a/arch/arm/boot/dts/stih410-b2260.dts
+++ b/arch/arm/boot/dts/stih410-b2260.dts
@@ -63,6 +63,7 @@
uart0: serial@9830000 {
label = "LS-UART0";
status = "okay";
+ rts-gpios = <&pio17 3 GPIO_ACTIVE_LOW>;
};
/* Low speed expansion connector */
--
2.9.3
[toc] | [prev] | [next] | [standalone]
| From | Lee Jones <lee.jones@linaro.org> |
|---|---|
| Date | 2017-02-03 11:30 +0100 |
| Subject | [PATCH v4 08/10] ARM: dts: STiH407-pinctrl: Add Pinctrl group for HW flow-control |
| Message-ID | <t6JhU-kD-33@gated-at.bofh.it> |
| In reply to | #1573007 |
Each serial port which supports HW flow-control should have 2 Pinctrl
groups. One for when HW flow-control is in progress, where the IP
will take over controlling the lines and another group which enables
the lines to be toggled using GPIO mechanisms.
Acked-by: Peter Griffin <peter.griffin@linaro.org>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
---
arch/arm/boot/dts/stih407-pinctrl.dtsi | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/arch/arm/boot/dts/stih407-pinctrl.dtsi b/arch/arm/boot/dts/stih407-pinctrl.dtsi
index daab16b..bd1a82e 100644
--- a/arch/arm/boot/dts/stih407-pinctrl.dtsi
+++ b/arch/arm/boot/dts/stih407-pinctrl.dtsi
@@ -465,8 +465,16 @@
serial0 {
pinctrl_serial0: serial0-0 {
st,pins {
- tx = <&pio17 0 ALT1 OUT>;
- rx = <&pio17 1 ALT1 IN>;
+ tx = <&pio17 0 ALT1 OUT>;
+ rx = <&pio17 1 ALT1 IN>;
+ };
+ };
+ pinctrl_serial0_hw_flowctrl: serial0-0_hw_flowctrl {
+ st,pins {
+ tx = <&pio17 0 ALT1 OUT>;
+ rx = <&pio17 1 ALT1 IN>;
+ cts = <&pio17 2 ALT1 IN>;
+ rts = <&pio17 3 ALT1 OUT>;
};
};
};
--
2.9.3
[toc] | [prev] | [next] | [standalone]
| From | Lee Jones <lee.jones@linaro.org> |
|---|---|
| Date | 2017-02-03 11:30 +0100 |
| Subject | [PATCH v4 06/10] dt-bindings: serial: Update 'uart-has-rtscts' description |
| Message-ID | <t6JhU-kD-31@gated-at.bofh.it> |
| In reply to | #1573007 |
'uart-has-rtscts' property and 'rts-gpios|cts-gpios' are normally
mutually exclusive, however it is possible for some drivers to have
a dynamic approach, meaning that both properties can be relevant.
Acked-by: Peter Griffin <peter.griffin@linaro.org>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
---
Documentation/devicetree/bindings/serial/serial.txt | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/Documentation/devicetree/bindings/serial/serial.txt b/Documentation/devicetree/bindings/serial/serial.txt
index fd970f7..b542a0e 100644
--- a/Documentation/devicetree/bindings/serial/serial.txt
+++ b/Documentation/devicetree/bindings/serial/serial.txt
@@ -23,7 +23,8 @@ Optional properties:
they are available for use (wired and enabled by pinmux configuration).
This depends on both the UART hardware and the board wiring.
Note that this property is mutually-exclusive with "cts-gpios" and
- "rts-gpios" above.
+ "rts-gpios" above, unless support is provided to switch between modes
+ dynamically.
Examples:
--
2.9.3
[toc] | [prev] | [next] | [standalone]
| From | Rob Herring <robh@kernel.org> |
|---|---|
| Date | 2017-02-08 22:20 +0100 |
| Subject | Re: [PATCH v4 06/10] dt-bindings: serial: Update 'uart-has-rtscts' description |
| Message-ID | <t8HOH-5t6-35@gated-at.bofh.it> |
| In reply to | #1573014 |
On Fri, Feb 03, 2017 at 10:23:15AM +0000, Lee Jones wrote: > 'uart-has-rtscts' property and 'rts-gpios|cts-gpios' are normally > mutually exclusive, however it is possible for some drivers to have > a dynamic approach, meaning that both properties can be relevant. > > Acked-by: Peter Griffin <peter.griffin@linaro.org> > Signed-off-by: Lee Jones <lee.jones@linaro.org> > --- > Documentation/devicetree/bindings/serial/serial.txt | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) Thought I acked this... Acked-by: Rob Herring <robh@kernel.org>
[toc] | [prev] | [next] | [standalone]
| From | Lee Jones <lee.jones@linaro.org> |
|---|---|
| Date | 2017-02-03 11:30 +0100 |
| Subject | [PATCH v4 10/10] ARM: dts: STiH410-b2260: Enable HW flow-control |
| Message-ID | <t6JhU-kD-35@gated-at.bofh.it> |
| In reply to | #1573007 |
Hardware flow-control capability must be specified at a platform
level in order to inform the ASC driver that the platform is capable
(i.e. are the lines wired up, etc). STiH4{07,10} devices are indeed
capable, so let's provide the property.
Acked-by: Peter Griffin <peter.griffin@linaro.org>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
---
arch/arm/boot/dts/stih410-b2260.dts | 1 +
1 file changed, 1 insertion(+)
diff --git a/arch/arm/boot/dts/stih410-b2260.dts b/arch/arm/boot/dts/stih410-b2260.dts
index cbcbcb4..93c14d1 100644
--- a/arch/arm/boot/dts/stih410-b2260.dts
+++ b/arch/arm/boot/dts/stih410-b2260.dts
@@ -66,6 +66,7 @@
pinctrl-0 = <&pinctrl_serial0_hw_flowctrl>;
pinctrl-1 = <&pinctrl_serial0>;
rts-gpios = <&pio17 3 GPIO_ACTIVE_LOW>;
+ uart-has-rtscts;
status = "okay";
};
--
2.9.3
[toc] | [prev] | [next] | [standalone]
| From | Lee Jones <lee.jones@linaro.org> |
|---|---|
| Date | 2017-02-03 11:30 +0100 |
| Subject | [PATCH v4 02/10] serial: st-asc: Provide RTS functionality |
| Message-ID | <t6JhU-kD-37@gated-at.bofh.it> |
| In reply to | #1573007 |
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
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web