]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
greybus: uart: Handle CRTSCTS flag in termios
authorAxel Haslam <ahaslam@baylibre.com>
Tue, 31 May 2016 12:36:08 +0000 (14:36 +0200)
committerGreg Kroah-Hartman <gregkh@google.com>
Wed, 1 Jun 2016 00:18:18 +0000 (17:18 -0700)
Handle the CRTSCTS flag in set_termios, so that auto
flow control can be turned off. For this, add a new flag
in the line coding request specifically for this purpose.

Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Axel Haslam <ahaslam@baylibre.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
drivers/staging/greybus/greybus_protocols.h
drivers/staging/greybus/uart.c

index 77ac3f2a48d24a5ec44a527128eef636ffe49a68..072e5c99a93485d31d717e625a91b6cb15d05607 100644 (file)
@@ -1304,6 +1304,9 @@ struct gb_uart_set_line_coding_request {
 #define GB_SERIAL_SPACE_PARITY                 4
 
        __u8    data_bits;
+
+       __u8    flow_control;
+#define GB_SERIAL_AUTO_RTSCTS_EN               0x1
 } __packed;
 
 /* output control lines */
index 5d8f4e8095d90fb3c2c6a244e42fb5e2f27d4fc3..44d8b9ad183ac083c1b5582cb9f02a4fe2cae74e 100644 (file)
@@ -39,6 +39,7 @@ struct gb_tty_line_coding {
        __u8    format;
        __u8    parity;
        __u8    data_bits;
+       __u8    flow_control;
 };
 
 struct gb_tty {
@@ -375,9 +376,9 @@ static void gb_tty_set_termios(struct tty_struct *tty,
 
        if (C_BAUD(tty) == B0) {
                newline.rate = gb_tty->line_coding.rate;
-               newctrl &= ~GB_UART_CTRL_DTR;
+               newctrl &= ~(GB_UART_CTRL_DTR | GB_UART_CTRL_RTS);
        } else if (termios_old && (termios_old->c_cflag & CBAUD) == B0) {
-               newctrl |= GB_UART_CTRL_DTR;
+               newctrl |= (GB_UART_CTRL_DTR | GB_UART_CTRL_RTS);
        }
 
        if (newctrl != gb_tty->ctrlout) {
@@ -385,6 +386,11 @@ static void gb_tty_set_termios(struct tty_struct *tty,
                send_control(gb_tty, newctrl);
        }
 
+       if (C_CRTSCTS(tty) && C_BAUD(tty) != B0)
+               newline.flow_control |= GB_SERIAL_AUTO_RTSCTS_EN;
+       else
+               newline.flow_control &= ~GB_SERIAL_AUTO_RTSCTS_EN;
+
        if (memcmp(&gb_tty->line_coding, &newline, sizeof(newline))) {
                memcpy(&gb_tty->line_coding, &newline, sizeof(newline));
                send_line_coding(gb_tty);