diff options
author | Richard Ash <richard@audacityteam.org> | 2009-08-20 06:24:39 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2009-09-15 15:01:36 -0400 |
commit | 2715dd6a93c69b29f59bec4c6e2fca84883078f0 (patch) | |
tree | d16ad3b4642803a556a8a7757357c104bbdb5a52 /drivers/staging/quatech_usb2 | |
parent | 2feb633d6580d8e6a61890bef1c0ea9020e61225 (diff) |
Staging: quatech_usb2: vendor implementation of set_termios method
This patch imports the implementation of the set_termios method from the
vendor driver into the staging driver. The common terminal setting
changes should be supported.
Signed-off-by: Richard Ash <richard@audacityteam.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/staging/quatech_usb2')
-rw-r--r-- | drivers/staging/quatech_usb2/quatech_usb2.c | 330 |
1 files changed, 263 insertions, 67 deletions
diff --git a/drivers/staging/quatech_usb2/quatech_usb2.c b/drivers/staging/quatech_usb2/quatech_usb2.c index 77058566007..f71921998ce 100644 --- a/drivers/staging/quatech_usb2/quatech_usb2.c +++ b/drivers/staging/quatech_usb2/quatech_usb2.c | |||
@@ -52,12 +52,12 @@ static int debug; | |||
52 | #define QT_OPEN_CLOSE_CHANNEL 0xca | 52 | #define QT_OPEN_CLOSE_CHANNEL 0xca |
53 | /*#define QT_GET_SET_PREBUF_TRIG_LVL 0xcc | 53 | /*#define QT_GET_SET_PREBUF_TRIG_LVL 0xcc |
54 | #define QT_SET_ATF 0xcd*/ | 54 | #define QT_SET_ATF 0xcd*/ |
55 | #define QT2_GET_SET_REGISTER 0xc0 | 55 | #define QT2_GET_SET_REGISTER 0xc0 |
56 | #define QT_GET_SET_UART 0xc1 | 56 | #define QT2_GET_SET_UART 0xc1 |
57 | /*#define QT_HW_FLOW_CONTROL_MASK 0xc5 | 57 | #define QT2_HW_FLOW_CONTROL_MASK 0xc5 |
58 | #define QT_SW_FLOW_CONTROL_MASK 0xc6 | 58 | #define QT2_SW_FLOW_CONTROL_MASK 0xc6 |
59 | #define QT_SW_FLOW_CONTROL_DISABLE 0xc7 | 59 | #define QT2_SW_FLOW_CONTROL_DISABLE 0xc7 |
60 | #define QT_BREAK_CONTROL 0xc8 | 60 | /*#define QT_BREAK_CONTROL 0xc8 |
61 | #define QT_STOP_RECEIVE 0xe0*/ | 61 | #define QT_STOP_RECEIVE 0xe0*/ |
62 | #define QT2_FLUSH_DEVICE 0xc4 | 62 | #define QT2_FLUSH_DEVICE 0xc4 |
63 | #define QT_GET_SET_QMCR 0xe1 | 63 | #define QT_GET_SET_QMCR 0xe1 |
@@ -66,34 +66,35 @@ static int debug; | |||
66 | #define QT2_FLUSH_RX 0x00 | 66 | #define QT2_FLUSH_RX 0x00 |
67 | #define QT2_FLUSH_TX 0x01 | 67 | #define QT2_FLUSH_TX 0x01 |
68 | 68 | ||
69 | /* port setting constants */ | 69 | /* port setting constants, used to set up serial port speeds, flow |
70 | #define SERIAL_MCR_DTR 0x01 | 70 | * control and so on */ |
71 | #define SERIAL_MCR_RTS 0x02 | 71 | #define QT2_SERIAL_MCR_DTR 0x01 |
72 | #define SERIAL_MCR_LOOP 0x10 | 72 | #define QT2_SERIAL_MCR_RTS 0x02 |
73 | #define QT2_SERIAL_MCR_LOOP 0x10 | ||
73 | 74 | ||
74 | #define SERIAL_MSR_CTS 0x10 | 75 | #define QT2_SERIAL_MSR_CTS 0x10 |
75 | #define SERIAL_MSR_CD 0x80 | 76 | #define QT2_SERIAL_MSR_CD 0x80 |
76 | #define SERIAL_MSR_RI 0x40 | 77 | #define QT2_SERIAL_MSR_RI 0x40 |
77 | #define SERIAL_MSR_DSR 0x20 | 78 | #define QT2_SERIAL_MSR_DSR 0x20 |
78 | #define SERIAL_MSR_MASK 0xf0 | 79 | #define QT2_SERIAL_MSR_MASK 0xf0 |
79 | 80 | ||
80 | #define SERIAL_8_DATA 0x03 | 81 | #define QT2_SERIAL_8_DATA 0x03 |
81 | #define SERIAL_7_DATA 0x02 | 82 | #define QT2_SERIAL_7_DATA 0x02 |
82 | #define SERIAL_6_DATA 0x01 | 83 | #define QT2_SERIAL_6_DATA 0x01 |
83 | #define SERIAL_5_DATA 0x00 | 84 | #define QT2_SERIAL_5_DATA 0x00 |
84 | 85 | ||
85 | #define SERIAL_ODD_PARITY 0X08 | 86 | #define QT2_SERIAL_ODD_PARITY 0X08 |
86 | #define SERIAL_EVEN_PARITY 0X18 | 87 | #define QT2_SERIAL_EVEN_PARITY 0X18 |
87 | #define SERIAL_TWO_STOPB 0x04 | 88 | #define QT2_SERIAL_TWO_STOPB 0x04 |
88 | #define SERIAL_ONE_STOPB 0x00 | 89 | #define QT2_SERIAL_ONE_STOPB 0x00 |
89 | 90 | ||
90 | #define MAX_BAUD_RATE 921600 | 91 | #define QT2_MAX_BAUD_RATE 921600 |
91 | #define MAX_BAUD_REMAINDER 4608 | 92 | #define QT2_MAX_BAUD_REMAINDER 4608 |
92 | 93 | ||
93 | #define SERIAL_LSR_OE 0x02 | 94 | #define QT2_SERIAL_LSR_OE 0x02 |
94 | #define SERIAL_LSR_PE 0x04 | 95 | #define QT2_SERIAL_LSR_PE 0x04 |
95 | #define SERIAL_LSR_FE 0x08 | 96 | #define QT2_SERIAL_LSR_FE 0x08 |
96 | #define SERIAL_LSR_BI 0x10 | 97 | #define QT2_SERIAL_LSR_BI 0x10 |
97 | 98 | ||
98 | /* value of Line Status Register when UART has completed | 99 | /* value of Line Status Register when UART has completed |
99 | * emptying data out on the line */ | 100 | * emptying data out on the line */ |
@@ -268,11 +269,18 @@ static int qt2_box_set_register(struct usb_serial *serial, | |||
268 | unsigned short Value); | 269 | unsigned short Value); |
269 | static int qt2_box_flush(struct usb_serial *serial, unsigned char uart_number, | 270 | static int qt2_box_flush(struct usb_serial *serial, unsigned char uart_number, |
270 | unsigned short rcv_or_xmit); | 271 | unsigned short rcv_or_xmit); |
271 | static int qt2_write(struct tty_struct *tty, struct usb_serial_port *port, | 272 | static int qt2_boxsetuart(struct usb_serial *serial, unsigned short Uart_Number, |
273 | unsigned short default_divisor, unsigned char default_LCR); | ||
274 | /*static int qt2_write(struct tty_struct *tty, struct usb_serial_port *port, | ||
272 | const unsigned char *buf, int count); | 275 | const unsigned char *buf, int count); |
273 | static int qt2_tiocmget(struct tty_struct *tty, struct file *file); | 276 | static int qt2_tiocmget(struct tty_struct *tty, struct file *file); |
274 | static int qt2_tiocmset(struct tty_struct *tty, struct file *file, | 277 | static int qt2_tiocmset(struct tty_struct *tty, struct file *file, |
275 | unsigned int set, unsigned int clear); | 278 | unsigned int set, unsigned int clear);*/ |
279 | static int qt2_boxsethw_flowctl(struct usb_serial *serial, | ||
280 | unsigned int UartNumber, bool bSet); | ||
281 | static int qt2_boxsetsw_flowctl(struct usb_serial *serial, __u16 UartNumber, | ||
282 | unsigned char stop_char, unsigned char start_char); | ||
283 | static int qt2_boxunsetsw_flowctl(struct usb_serial *serial, __u16 UartNumber); | ||
276 | 284 | ||
277 | /* implementation functions, roughly in order of use, are here */ | 285 | /* implementation functions, roughly in order of use, are here */ |
278 | static int qt2_calc_num_ports(struct usb_serial *serial) | 286 | static int qt2_calc_num_ports(struct usb_serial *serial) |
@@ -452,7 +460,7 @@ int qt2_open(struct tty_struct *tty, struct usb_serial_port *port) | |||
452 | struct quatech2_dev *dev_extra; /* extra data for the device */ | 460 | struct quatech2_dev *dev_extra; /* extra data for the device */ |
453 | struct qt2_status_data ChannelData; | 461 | struct qt2_status_data ChannelData; |
454 | unsigned short default_divisor = QU2BOXSPD9600; | 462 | unsigned short default_divisor = QU2BOXSPD9600; |
455 | unsigned char default_LCR = SERIAL_8_DATA; | 463 | unsigned char default_LCR = QT2_SERIAL_8_DATA; |
456 | int status; | 464 | int status; |
457 | int result; | 465 | int result; |
458 | 466 | ||
@@ -495,11 +503,11 @@ int qt2_open(struct tty_struct *tty, struct usb_serial_port *port) | |||
495 | return status; | 503 | return status; |
496 | } | 504 | } |
497 | port_extra->shadowLSR = ChannelData.line_status & | 505 | port_extra->shadowLSR = ChannelData.line_status & |
498 | (SERIAL_LSR_OE | SERIAL_LSR_PE | SERIAL_LSR_FE | | 506 | (QT2_SERIAL_LSR_OE | QT2_SERIAL_LSR_PE | |
499 | SERIAL_LSR_BI); | 507 | QT2_SERIAL_LSR_FE | QT2_SERIAL_LSR_BI); |
500 | port_extra->shadowMSR = ChannelData.modem_status & | 508 | port_extra->shadowMSR = ChannelData.modem_status & |
501 | (SERIAL_MSR_CTS | SERIAL_MSR_DSR | SERIAL_MSR_RI | | 509 | (QT2_SERIAL_MSR_CTS | QT2_SERIAL_MSR_DSR | |
502 | SERIAL_MSR_CD); | 510 | QT2_SERIAL_MSR_RI | QT2_SERIAL_MSR_CD); |
503 | 511 | ||
504 | /* port_extra->fifo_empty_flag = true;*/ | 512 | /* port_extra->fifo_empty_flag = true;*/ |
505 | dbg("qt2_openboxchannel on channel %d completed.", | 513 | dbg("qt2_openboxchannel on channel %d completed.", |
@@ -884,19 +892,19 @@ static int qt2_ioctl(struct tty_struct *tty, struct file *file, | |||
884 | switch (cmd) { | 892 | switch (cmd) { |
885 | case TIOCMBIS: | 893 | case TIOCMBIS: |
886 | if (value & TIOCM_RTS) | 894 | if (value & TIOCM_RTS) |
887 | mcr_value |= SERIAL_MCR_RTS; | 895 | mcr_value |= QT2_SERIAL_MCR_RTS; |
888 | if (value & TIOCM_DTR) | 896 | if (value & TIOCM_DTR) |
889 | mcr_value |= SERIAL_MCR_DTR; | 897 | mcr_value |= QT2_SERIAL_MCR_DTR; |
890 | if (value & TIOCM_LOOP) | 898 | if (value & TIOCM_LOOP) |
891 | mcr_value |= SERIAL_MCR_LOOP; | 899 | mcr_value |= QT2_SERIAL_MCR_LOOP; |
892 | break; | 900 | break; |
893 | case TIOCMBIC: | 901 | case TIOCMBIC: |
894 | if (value & TIOCM_RTS) | 902 | if (value & TIOCM_RTS) |
895 | mcr_value &= ~SERIAL_MCR_RTS; | 903 | mcr_value &= ~QT2_SERIAL_MCR_RTS; |
896 | if (value & TIOCM_DTR) | 904 | if (value & TIOCM_DTR) |
897 | mcr_value &= ~SERIAL_MCR_DTR; | 905 | mcr_value &= ~QT2_SERIAL_MCR_DTR; |
898 | if (value & TIOCM_LOOP) | 906 | if (value & TIOCM_LOOP) |
899 | mcr_value &= ~SERIAL_MCR_LOOP; | 907 | mcr_value &= ~QT2_SERIAL_MCR_LOOP; |
900 | break; | 908 | break; |
901 | default: | 909 | default: |
902 | break; | 910 | break; |
@@ -911,7 +919,7 @@ static int qt2_ioctl(struct tty_struct *tty, struct file *file, | |||
911 | } else if (cmd == TIOCMIWAIT) { | 919 | } else if (cmd == TIOCMIWAIT) { |
912 | dbg("%s() port %d, cmd == TIOCMIWAIT enter", | 920 | dbg("%s() port %d, cmd == TIOCMIWAIT enter", |
913 | __func__, port->number); | 921 | __func__, port->number); |
914 | prev_msr_value = port_extra->shadowMSR & SERIAL_MSR_MASK; | 922 | prev_msr_value = port_extra->shadowMSR & QT2_SERIAL_MSR_MASK; |
915 | while (1) { | 923 | while (1) { |
916 | add_wait_queue(&port_extra->wait, &wait); | 924 | add_wait_queue(&port_extra->wait, &wait); |
917 | set_current_state(TASK_INTERRUPTIBLE); | 925 | set_current_state(TASK_INTERRUPTIBLE); |
@@ -922,21 +930,21 @@ static int qt2_ioctl(struct tty_struct *tty, struct file *file, | |||
922 | /* see if a signal woke us up */ | 930 | /* see if a signal woke us up */ |
923 | if (signal_pending(current)) | 931 | if (signal_pending(current)) |
924 | return -ERESTARTSYS; | 932 | return -ERESTARTSYS; |
925 | msr_value = port_extra->shadowMSR & SERIAL_MSR_MASK; | 933 | msr_value = port_extra->shadowMSR & QT2_SERIAL_MSR_MASK; |
926 | if (msr_value == prev_msr_value) | 934 | if (msr_value == prev_msr_value) |
927 | return -EIO; /* no change - error */ | 935 | return -EIO; /* no change - error */ |
928 | if ((arg & TIOCM_RNG && | 936 | if ((arg & TIOCM_RNG && |
929 | ((prev_msr_value & SERIAL_MSR_RI) == | 937 | ((prev_msr_value & QT2_SERIAL_MSR_RI) == |
930 | (msr_value & SERIAL_MSR_RI))) || | 938 | (msr_value & QT2_SERIAL_MSR_RI))) || |
931 | (arg & TIOCM_DSR && | 939 | (arg & TIOCM_DSR && |
932 | ((prev_msr_value & SERIAL_MSR_DSR) == | 940 | ((prev_msr_value & QT2_SERIAL_MSR_DSR) == |
933 | (msr_value & SERIAL_MSR_DSR))) || | 941 | (msr_value & QT2_SERIAL_MSR_DSR))) || |
934 | (arg & TIOCM_CD && | 942 | (arg & TIOCM_CD && |
935 | ((prev_msr_value & SERIAL_MSR_CD) == | 943 | ((prev_msr_value & QT2_SERIAL_MSR_CD) == |
936 | (msr_value & SERIAL_MSR_CD))) || | 944 | (msr_value & QT2_SERIAL_MSR_CD))) || |
937 | (arg & TIOCM_CTS && | 945 | (arg & TIOCM_CTS && |
938 | ((prev_msr_value & SERIAL_MSR_CTS) == | 946 | ((prev_msr_value & QT2_SERIAL_MSR_CTS) == |
939 | (msr_value & SERIAL_MSR_CTS)))) { | 947 | (msr_value & QT2_SERIAL_MSR_CTS)))) { |
940 | return 0; | 948 | return 0; |
941 | } | 949 | } |
942 | } /* end inifinite while */ | 950 | } /* end inifinite while */ |
@@ -952,6 +960,120 @@ static int qt2_ioctl(struct tty_struct *tty, struct file *file, | |||
952 | } | 960 | } |
953 | } | 961 | } |
954 | 962 | ||
963 | /* Called when the user wishes to change the port settings using the termios | ||
964 | * userspace interface */ | ||
965 | static void qt2_set_termios(struct tty_struct *tty, | ||
966 | struct usb_serial_port *port, struct ktermios *old_termios) | ||
967 | { | ||
968 | struct usb_serial *serial; /* parent serial device */ | ||
969 | int baud, divisor, remainder; | ||
970 | unsigned char LCR_change_to = 0; | ||
971 | int status; | ||
972 | __u16 UartNumber; | ||
973 | |||
974 | dbg("%s(): port %d", __func__, port->number); | ||
975 | |||
976 | serial = port->serial; | ||
977 | |||
978 | UartNumber = port->number; | ||
979 | |||
980 | if (old_termios) { | ||
981 | if ((tty->termios->c_cflag == old_termios->c_cflag) && | ||
982 | (RELEVANT_IFLAG(tty->termios->c_iflag) == | ||
983 | RELEVANT_IFLAG(old_termios->c_iflag))) { | ||
984 | dbg("%s(): Nothing to change", __func__); | ||
985 | return; | ||
986 | } | ||
987 | } | ||
988 | |||
989 | switch (tty->termios->c_cflag) { | ||
990 | case CS5: | ||
991 | LCR_change_to |= QT2_SERIAL_5_DATA; | ||
992 | break; | ||
993 | case CS6: | ||
994 | LCR_change_to |= QT2_SERIAL_6_DATA; | ||
995 | break; | ||
996 | case CS7: | ||
997 | LCR_change_to |= QT2_SERIAL_7_DATA; | ||
998 | break; | ||
999 | default: | ||
1000 | case CS8: | ||
1001 | LCR_change_to |= QT2_SERIAL_8_DATA; | ||
1002 | break; | ||
1003 | } | ||
1004 | |||
1005 | /* Parity stuff */ | ||
1006 | if (tty->termios->c_cflag & PARENB) { | ||
1007 | if (tty->termios->c_cflag & PARODD) | ||
1008 | LCR_change_to |= QT2_SERIAL_ODD_PARITY; | ||
1009 | else | ||
1010 | LCR_change_to |= QT2_SERIAL_EVEN_PARITY; | ||
1011 | } | ||
1012 | if (tty->termios->c_cflag & CSTOPB) | ||
1013 | LCR_change_to |= QT2_SERIAL_TWO_STOPB; | ||
1014 | else | ||
1015 | LCR_change_to |= QT2_SERIAL_ONE_STOPB; | ||
1016 | |||
1017 | /* Thats the LCR stuff, go ahead and set it */ | ||
1018 | baud = tty_get_baud_rate(tty); | ||
1019 | if (!baud) { | ||
1020 | /* pick a default, any default... */ | ||
1021 | baud = 9600; | ||
1022 | } | ||
1023 | dbg("%s(): got baud = %d", __func__, baud); | ||
1024 | |||
1025 | divisor = QT2_MAX_BAUD_RATE / baud; | ||
1026 | remainder = QT2_MAX_BAUD_RATE % baud; | ||
1027 | /* Round to nearest divisor */ | ||
1028 | if (((remainder * 2) >= baud) && (baud != 110)) | ||
1029 | divisor++; | ||
1030 | dbg("%s(): setting divisor = %d, QT2_MAX_BAUD_RATE = %d , LCR = 0x%x", | ||
1031 | __func__, divisor, QT2_MAX_BAUD_RATE, LCR_change_to); | ||
1032 | |||
1033 | status = qt2_boxsetuart(serial, UartNumber, (unsigned short) divisor, | ||
1034 | LCR_change_to); | ||
1035 | if (status < 0) { | ||
1036 | dbg("qt2_boxsetuart() failed"); | ||
1037 | return; | ||
1038 | } | ||
1039 | |||
1040 | /* Now determine flow control */ | ||
1041 | if (tty->termios->c_cflag & CRTSCTS) { | ||
1042 | dbg("%s(): Enabling HW flow control port %d", __func__, | ||
1043 | port->number); | ||
1044 | /* Enable RTS/CTS flow control */ | ||
1045 | status = qt2_boxsethw_flowctl(serial, UartNumber, true); | ||
1046 | if (status < 0) { | ||
1047 | dbg("qt2_boxsethw_flowctl() failed"); | ||
1048 | return; | ||
1049 | } | ||
1050 | } else { | ||
1051 | /* Disable RTS/CTS flow control */ | ||
1052 | dbg("%s(): disabling HW flow control port %d", __func__, | ||
1053 | port->number); | ||
1054 | status = qt2_boxsethw_flowctl(serial, UartNumber, false); | ||
1055 | if (status < 0) { | ||
1056 | dbg("qt2_boxsethw_flowctl failed"); | ||
1057 | return; | ||
1058 | } | ||
1059 | } | ||
1060 | /* if we are implementing XON/XOFF, set the start and stop character | ||
1061 | * in the device */ | ||
1062 | if (I_IXOFF(tty) || I_IXON(tty)) { | ||
1063 | unsigned char stop_char = STOP_CHAR(tty); | ||
1064 | unsigned char start_char = START_CHAR(tty); | ||
1065 | status = qt2_boxsetsw_flowctl(serial, UartNumber, stop_char, | ||
1066 | start_char); | ||
1067 | if (status < 0) | ||
1068 | dbg("qt2_boxsetsw_flowctl (enabled) failed"); | ||
1069 | } else { | ||
1070 | /* disable SW flow control */ | ||
1071 | status = qt2_boxunsetsw_flowctl(serial, UartNumber); | ||
1072 | if (status < 0) | ||
1073 | dbg("qt2_boxunsetsw_flowctl (disabling) failed"); | ||
1074 | } | ||
1075 | } | ||
1076 | |||
955 | static int qt2_tiocmget(struct tty_struct *tty, struct file *file) | 1077 | static int qt2_tiocmget(struct tty_struct *tty, struct file *file) |
956 | { | 1078 | { |
957 | struct usb_serial_port *port = tty->driver_data; | 1079 | struct usb_serial_port *port = tty->driver_data; |
@@ -977,17 +1099,17 @@ static int qt2_tiocmget(struct tty_struct *tty, struct file *file) | |||
977 | QT2_MODEM_STATUS_REGISTER, &msr_value); | 1099 | QT2_MODEM_STATUS_REGISTER, &msr_value); |
978 | } | 1100 | } |
979 | if (status >= 0) { | 1101 | if (status >= 0) { |
980 | result = ((mcr_value & SERIAL_MCR_DTR) ? TIOCM_DTR : 0) | 1102 | result = ((mcr_value & QT2_SERIAL_MCR_DTR) ? TIOCM_DTR : 0) |
981 | /*DTR set */ | 1103 | /*DTR set */ |
982 | | ((mcr_value & SERIAL_MCR_RTS) ? TIOCM_RTS : 0) | 1104 | | ((mcr_value & QT2_SERIAL_MCR_RTS) ? TIOCM_RTS : 0) |
983 | /*RTS set */ | 1105 | /*RTS set */ |
984 | | ((msr_value & SERIAL_MSR_CTS) ? TIOCM_CTS : 0) | 1106 | | ((msr_value & QT2_SERIAL_MSR_CTS) ? TIOCM_CTS : 0) |
985 | /* CTS set */ | 1107 | /* CTS set */ |
986 | | ((msr_value & SERIAL_MSR_CD) ? TIOCM_CAR : 0) | 1108 | | ((msr_value & QT2_SERIAL_MSR_CD) ? TIOCM_CAR : 0) |
987 | /*Carrier detect set */ | 1109 | /*Carrier detect set */ |
988 | | ((msr_value & SERIAL_MSR_RI) ? TIOCM_RI : 0) | 1110 | | ((msr_value & QT2_SERIAL_MSR_RI) ? TIOCM_RI : 0) |
989 | /* Ring indicator set */ | 1111 | /* Ring indicator set */ |
990 | | ((msr_value & SERIAL_MSR_DSR) ? TIOCM_DSR : 0); | 1112 | | ((msr_value & QT2_SERIAL_MSR_DSR) ? TIOCM_DSR : 0); |
991 | /* DSR set */ | 1113 | /* DSR set */ |
992 | return result; | 1114 | return result; |
993 | } else { | 1115 | } else { |
@@ -1017,13 +1139,14 @@ static int qt2_tiocmset(struct tty_struct *tty, struct file *file, | |||
1017 | 1139 | ||
1018 | /* Turn off RTS, DTR and loopback, then only turn on what was asked | 1140 | /* Turn off RTS, DTR and loopback, then only turn on what was asked |
1019 | * for */ | 1141 | * for */ |
1020 | mcr_value &= ~(SERIAL_MCR_RTS | SERIAL_MCR_DTR | SERIAL_MCR_LOOP); | 1142 | mcr_value &= ~(QT2_SERIAL_MCR_RTS | QT2_SERIAL_MCR_DTR | |
1143 | QT2_SERIAL_MCR_LOOP); | ||
1021 | if (set & TIOCM_RTS) | 1144 | if (set & TIOCM_RTS) |
1022 | mcr_value |= SERIAL_MCR_RTS; | 1145 | mcr_value |= QT2_SERIAL_MCR_RTS; |
1023 | if (set & TIOCM_DTR) | 1146 | if (set & TIOCM_DTR) |
1024 | mcr_value |= SERIAL_MCR_DTR; | 1147 | mcr_value |= QT2_SERIAL_MCR_DTR; |
1025 | if (set & TIOCM_LOOP) | 1148 | if (set & TIOCM_LOOP) |
1026 | mcr_value |= SERIAL_MCR_LOOP; | 1149 | mcr_value |= QT2_SERIAL_MCR_LOOP; |
1027 | 1150 | ||
1028 | status = qt2_box_set_register(port->serial, UartNumber, | 1151 | status = qt2_box_set_register(port->serial, UartNumber, |
1029 | QT2_MODEM_CONTROL_REGISTER, mcr_value); | 1152 | QT2_MODEM_CONTROL_REGISTER, mcr_value); |
@@ -1162,7 +1285,7 @@ static int qt2_conf_uart(struct usb_serial *serial, unsigned short Uart_Number, | |||
1162 | UartNumandLCR = (LCR << 8) + Uart_Number; | 1285 | UartNumandLCR = (LCR << 8) + Uart_Number; |
1163 | 1286 | ||
1164 | result = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), | 1287 | result = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), |
1165 | QT_GET_SET_UART, 0x40, divisor, UartNumandLCR, | 1288 | QT2_GET_SET_UART, 0x40, divisor, UartNumandLCR, |
1166 | NULL, 0, 300); | 1289 | NULL, 0, 300); |
1167 | return result; | 1290 | return result; |
1168 | } | 1291 | } |
@@ -1464,8 +1587,8 @@ static void qt2_process_line_status(struct usb_serial_port *port, | |||
1464 | { | 1587 | { |
1465 | /* obtain the private structure for the port */ | 1588 | /* obtain the private structure for the port */ |
1466 | struct quatech2_port *port_extra = qt2_get_port_private(port); | 1589 | struct quatech2_port *port_extra = qt2_get_port_private(port); |
1467 | port_extra->shadowLSR = LineStatus & (SERIAL_LSR_OE | SERIAL_LSR_PE | | 1590 | port_extra->shadowLSR = LineStatus & (QT2_SERIAL_LSR_OE | |
1468 | SERIAL_LSR_FE | SERIAL_LSR_BI); | 1591 | QT2_SERIAL_LSR_PE | QT2_SERIAL_LSR_FE | QT2_SERIAL_LSR_BI); |
1469 | } | 1592 | } |
1470 | static void qt2_process_modem_status(struct usb_serial_port *port, | 1593 | static void qt2_process_modem_status(struct usb_serial_port *port, |
1471 | unsigned char ModemStatus) | 1594 | unsigned char ModemStatus) |
@@ -1602,6 +1725,79 @@ static int qt2_box_flush(struct usb_serial *serial, unsigned char uart_number, | |||
1602 | return result; | 1725 | return result; |
1603 | } | 1726 | } |
1604 | 1727 | ||
1728 | /** qt2_boxsetuart - Issue a SET_UART vendor-spcific request on the default | ||
1729 | * control pipe. If successful sets baud rate divisor and LCR value. | ||
1730 | */ | ||
1731 | static int qt2_boxsetuart(struct usb_serial *serial, unsigned short Uart_Number, | ||
1732 | unsigned short default_divisor, unsigned char default_LCR) | ||
1733 | { | ||
1734 | unsigned short UartNumandLCR; | ||
1735 | |||
1736 | UartNumandLCR = (default_LCR << 8) + Uart_Number; | ||
1737 | |||
1738 | return usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), | ||
1739 | QT2_GET_SET_UART, 0x40, default_divisor, UartNumandLCR, | ||
1740 | NULL, 0, 300); | ||
1741 | } | ||
1742 | /** qt2_boxsethw_flowctl - Turn hardware (RTS/CTS) flow control on and off for | ||
1743 | * a hardware UART. | ||
1744 | */ | ||
1745 | static int qt2_boxsethw_flowctl(struct usb_serial *serial, | ||
1746 | unsigned int UartNumber, bool bSet) | ||
1747 | { | ||
1748 | __u8 MCR_Value = 0; | ||
1749 | __u8 MSR_Value = 0; | ||
1750 | __u16 MOUT_Value = 0; | ||
1751 | |||
1752 | if (bSet == true) { | ||
1753 | MCR_Value = QT2_SERIAL_MCR_RTS; | ||
1754 | /* flow control, box will clear RTS line to prevent remote | ||
1755 | * device from transmitting more chars */ | ||
1756 | } else { | ||
1757 | /* no flow control to remote device */ | ||
1758 | MCR_Value = 0; | ||
1759 | } | ||
1760 | MOUT_Value = MCR_Value << 8; | ||
1761 | |||
1762 | if (bSet == true) { | ||
1763 | MSR_Value = QT2_SERIAL_MSR_CTS; | ||
1764 | /* flow control on, box will inhibit tx data if CTS line is | ||
1765 | * asserted */ | ||
1766 | } else { | ||
1767 | /* Box will not inhibit tx data due to CTS line */ | ||
1768 | MSR_Value = 0; | ||
1769 | } | ||
1770 | MOUT_Value |= MSR_Value; | ||
1771 | return usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), | ||
1772 | QT2_HW_FLOW_CONTROL_MASK, 0x40, MOUT_Value, UartNumber, | ||
1773 | NULL, 0, 300); | ||
1774 | } | ||
1775 | |||
1776 | /** qt2_boxsetsw_flowctl - Turn software (XON/XOFF) flow control on for | ||
1777 | * a hardware UART, and set the XON and XOFF characters. | ||
1778 | */ | ||
1779 | static int qt2_boxsetsw_flowctl(struct usb_serial *serial, __u16 UartNumber, | ||
1780 | unsigned char stop_char, unsigned char start_char) | ||
1781 | { | ||
1782 | __u16 nSWflowout; | ||
1783 | |||
1784 | nSWflowout = start_char << 8; | ||
1785 | nSWflowout = (unsigned short)stop_char; | ||
1786 | return usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), | ||
1787 | QT2_SW_FLOW_CONTROL_MASK, 0x40, nSWflowout, UartNumber, | ||
1788 | NULL, 0, 300); | ||
1789 | } | ||
1790 | |||
1791 | /** qt2_boxunsetsw_flowctl - Turn software (XON/XOFF) flow control off for | ||
1792 | * a hardware UART. | ||
1793 | */ | ||
1794 | static int qt2_boxunsetsw_flowctl(struct usb_serial *serial, __u16 UartNumber) | ||
1795 | { | ||
1796 | return usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), | ||
1797 | QT2_SW_FLOW_CONTROL_DISABLE, 0x40, 0, UartNumber, NULL, | ||
1798 | 0, 300); | ||
1799 | } | ||
1800 | |||
1605 | /* | 1801 | /* |
1606 | * last things in file: stuff to register this driver into the generic | 1802 | * last things in file: stuff to register this driver into the generic |
1607 | * USB serial framework. | 1803 | * USB serial framework. |
@@ -1625,8 +1821,8 @@ static struct usb_serial_driver quatech2_device = { | |||
1625 | .unthrottle = qt_unthrottle,*/ | 1821 | .unthrottle = qt_unthrottle,*/ |
1626 | .calc_num_ports = qt2_calc_num_ports, | 1822 | .calc_num_ports = qt2_calc_num_ports, |
1627 | .ioctl = qt2_ioctl, | 1823 | .ioctl = qt2_ioctl, |
1628 | /*.set_termios = qt_set_termios, | 1824 | .set_termios = qt2_set_termios, |
1629 | .break_ctl = qt_break,*/ | 1825 | /*.break_ctl = qt_break,*/ |
1630 | .tiocmget = qt2_tiocmget, | 1826 | .tiocmget = qt2_tiocmget, |
1631 | .tiocmset = qt2_tiocmset, | 1827 | .tiocmset = qt2_tiocmset, |
1632 | .attach = qt2_attach, | 1828 | .attach = qt2_attach, |