Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1565851 > unrolled thread
| Started by | Lee Jones <lee.jones@linaro.org> |
|---|---|
| First post | 2017-01-24 14:50 +0100 |
| Last post | 2017-01-25 12:30 +0100 |
| Articles | 2 — 2 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
[PATCH 4/8] serial: st-asc: (De)Register GPIOD and swap Pinctrl profiles Lee Jones <lee.jones@linaro.org> - 2017-01-24 14:50 +0100
Re: [STLinux Kernel] [PATCH 4/8] serial: st-asc: (De)Register GPIOD and swap Pinctrl profiles Peter Griffin <peter.griffin@linaro.org> - 2017-01-25 12:30 +0100
| From | Lee Jones <lee.jones@linaro.org> |
|---|---|
| Date | 2017-01-24 14:50 +0100 |
| Subject | [PATCH 4/8] serial: st-asc: (De)Register GPIOD and swap Pinctrl profiles |
| Message-ID | <t39DX-4W7-3@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 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
[toc] | [next] | [standalone]
| From | Peter Griffin <peter.griffin@linaro.org> |
|---|---|
| Date | 2017-01-25 12:30 +0100 |
| Subject | Re: [STLinux Kernel] [PATCH 4/8] serial: st-asc: (De)Register GPIOD and swap Pinctrl profiles |
| Message-ID | <t3tW1-16w-13@gated-at.bofh.it> |
| In reply to | #1565851 |
Hi Lee,
On Tue, 24 Jan 2017, Lee Jones wrote:
> 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.
Apart from my comment in previous mail about switching the meaning of
default & manual-rts groupings. It seems like a neat solution.
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 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 {
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web