aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorAlan Cox <alan@redhat.com>2008-07-22 06:11:23 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-07-22 16:03:23 -0400
commit464cbb24698ddb7bf24b2b73204e3dc121886211 (patch)
tree71fc92f99eba715d0c8ffd6d7fe725858c6d69ca /drivers
parent93c467952ff6b5c3d92fddf4b1a609e68f6d08d1 (diff)
ftdi_sio: Coding style
Signed-off-by: Alan Cox <alan@redhat.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/usb/serial/ftdi_sio.c1078
-rw-r--r--drivers/usb/serial/ftdi_sio.h126
2 files changed, 635 insertions, 569 deletions
diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
index abbb447e5375..838717250145 100644
--- a/drivers/usb/serial/ftdi_sio.c
+++ b/drivers/usb/serial/ftdi_sio.c
@@ -12,7 +12,8 @@
12 * the Free Software Foundation; either version 2 of the License, or 12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version. 13 * (at your option) any later version.
14 * 14 *
15 * See Documentation/usb/usb-serial.txt for more information on using this driver 15 * See Documentation/usb/usb-serial.txt for more information on using this
16 * driver
16 * 17 *
17 * See http://ftdi-usb-sio.sourceforge.net for upto date testing info 18 * See http://ftdi-usb-sio.sourceforge.net for upto date testing info
18 * and extra documentation 19 * and extra documentation
@@ -25,7 +26,8 @@
25/* Bill Ryder - bryder@sgi.com - wrote the FTDI_SIO implementation */ 26/* Bill Ryder - bryder@sgi.com - wrote the FTDI_SIO implementation */
26/* Thanx to FTDI for so kindly providing details of the protocol required */ 27/* Thanx to FTDI for so kindly providing details of the protocol required */
27/* to talk to the device */ 28/* to talk to the device */
28/* Thanx to gkh and the rest of the usb dev group for all code I have assimilated :-) */ 29/* Thanx to gkh and the rest of the usb dev group for all code I have
30 assimilated :-) */
29 31
30#include <linux/kernel.h> 32#include <linux/kernel.h>
31#include <linux/errno.h> 33#include <linux/errno.h>
@@ -36,7 +38,7 @@
36#include <linux/tty_flip.h> 38#include <linux/tty_flip.h>
37#include <linux/module.h> 39#include <linux/module.h>
38#include <linux/spinlock.h> 40#include <linux/spinlock.h>
39#include <asm/uaccess.h> 41#include <linux/uaccess.h>
40#include <linux/usb.h> 42#include <linux/usb.h>
41#include <linux/serial.h> 43#include <linux/serial.h>
42#include <linux/usb/serial.h> 44#include <linux/usb/serial.h>
@@ -55,17 +57,22 @@ static __u16 product;
55 57
56struct ftdi_private { 58struct ftdi_private {
57 ftdi_chip_type_t chip_type; 59 ftdi_chip_type_t chip_type;
58 /* type of the device, either SIO or FT8U232AM */ 60 /* type of device, either SIO or FT8U232AM */
59 int baud_base; /* baud base clock for divisor setting */ 61 int baud_base; /* baud base clock for divisor setting */
60 int custom_divisor; /* custom_divisor kludge, this is for baud_base (different from what goes to the chip!) */ 62 int custom_divisor; /* custom_divisor kludge, this is for
63 baud_base (different from what goes to the
64 chip!) */
61 __u16 last_set_data_urb_value ; 65 __u16 last_set_data_urb_value ;
62 /* the last data state set - needed for doing a break */ 66 /* the last data state set - needed for doing
63 int write_offset; /* This is the offset in the usb data block to write the serial data - 67 * a break
64 * it is different between devices 68 */
69 int write_offset; /* This is the offset in the usb data block to
70 * write the serial data - it varies between
71 * devices
65 */ 72 */
66 int flags; /* some ASYNC_xxxx flags are supported */ 73 int flags; /* some ASYNC_xxxx flags are supported */
67 unsigned long last_dtr_rts; /* saved modem control outputs */ 74 unsigned long last_dtr_rts; /* saved modem control outputs */
68 wait_queue_head_t delta_msr_wait; /* Used for TIOCMIWAIT */ 75 wait_queue_head_t delta_msr_wait; /* Used for TIOCMIWAIT */
69 char prev_status, diff_status; /* Used for TIOCMIWAIT */ 76 char prev_status, diff_status; /* Used for TIOCMIWAIT */
70 __u8 rx_flags; /* receive state flags (throttling) */ 77 __u8 rx_flags; /* receive state flags (throttling) */
71 spinlock_t rx_lock; /* spinlock for receive state */ 78 spinlock_t rx_lock; /* spinlock for receive state */
@@ -76,8 +83,10 @@ struct ftdi_private {
76 83
77 __u16 interface; /* FT2232C port interface (0 for FT232/245) */ 84 __u16 interface; /* FT2232C port interface (0 for FT232/245) */
78 85
79 speed_t force_baud; /* if non-zero, force the baud rate to this value */ 86 speed_t force_baud; /* if non-zero, force the baud rate to
80 int force_rtscts; /* if non-zero, force RTS-CTS to always be enabled */ 87 this value */
88 int force_rtscts; /* if non-zero, force RTS-CTS to always
89 be enabled */
81 90
82 spinlock_t tx_lock; /* spinlock for transmit state */ 91 spinlock_t tx_lock; /* spinlock for transmit state */
83 unsigned long tx_bytes; 92 unsigned long tx_bytes;
@@ -88,13 +97,14 @@ struct ftdi_private {
88/* struct ftdi_sio_quirk is used by devices requiring special attention. */ 97/* struct ftdi_sio_quirk is used by devices requiring special attention. */
89struct ftdi_sio_quirk { 98struct ftdi_sio_quirk {
90 int (*probe)(struct usb_serial *); 99 int (*probe)(struct usb_serial *);
91 void (*port_probe)(struct ftdi_private *); /* Special settings for probed ports. */ 100 /* Special settings for probed ports. */
101 void (*port_probe)(struct ftdi_private *);
92}; 102};
93 103
94static int ftdi_jtag_probe (struct usb_serial *serial); 104static int ftdi_jtag_probe(struct usb_serial *serial);
95static int ftdi_mtxorb_hack_setup (struct usb_serial *serial); 105static int ftdi_mtxorb_hack_setup(struct usb_serial *serial);
96static void ftdi_USB_UIRT_setup (struct ftdi_private *priv); 106static void ftdi_USB_UIRT_setup(struct ftdi_private *priv);
97static void ftdi_HE_TIRA1_setup (struct ftdi_private *priv); 107static void ftdi_HE_TIRA1_setup(struct ftdi_private *priv);
98 108
99static struct ftdi_sio_quirk ftdi_jtag_quirk = { 109static struct ftdi_sio_quirk ftdi_jtag_quirk = {
100 .probe = ftdi_jtag_probe, 110 .probe = ftdi_jtag_probe,
@@ -174,270 +184,270 @@ static struct usb_device_id id_table_combined [] = {
174 { USB_DEVICE(FTDI_VID, FTDI_MTXORB_4_PID) }, 184 { USB_DEVICE(FTDI_VID, FTDI_MTXORB_4_PID) },
175 { USB_DEVICE(FTDI_VID, FTDI_MTXORB_5_PID) }, 185 { USB_DEVICE(FTDI_VID, FTDI_MTXORB_5_PID) },
176 { USB_DEVICE(FTDI_VID, FTDI_MTXORB_6_PID) }, 186 { USB_DEVICE(FTDI_VID, FTDI_MTXORB_6_PID) },
177 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0100_PID) }, 187 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0100_PID) },
178 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0101_PID) }, 188 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0101_PID) },
179 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0102_PID) }, 189 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0102_PID) },
180 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0103_PID) }, 190 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0103_PID) },
181 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0104_PID) }, 191 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0104_PID) },
182 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0105_PID) }, 192 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0105_PID) },
183 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0106_PID) }, 193 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0106_PID) },
184 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0107_PID) }, 194 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0107_PID) },
185 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0108_PID) }, 195 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0108_PID) },
186 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0109_PID) }, 196 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0109_PID) },
187 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_010A_PID) }, 197 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_010A_PID) },
188 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_010B_PID) }, 198 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_010B_PID) },
189 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_010C_PID) }, 199 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_010C_PID) },
190 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_010D_PID) }, 200 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_010D_PID) },
191 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_010E_PID) }, 201 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_010E_PID) },
192 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_010F_PID) }, 202 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_010F_PID) },
193 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0110_PID) }, 203 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0110_PID) },
194 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0111_PID) }, 204 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0111_PID) },
195 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0112_PID) }, 205 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0112_PID) },
196 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0113_PID) }, 206 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0113_PID) },
197 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0114_PID) }, 207 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0114_PID) },
198 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0115_PID) }, 208 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0115_PID) },
199 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0116_PID) }, 209 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0116_PID) },
200 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0117_PID) }, 210 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0117_PID) },
201 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0118_PID) }, 211 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0118_PID) },
202 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0119_PID) }, 212 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0119_PID) },
203 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_011A_PID) }, 213 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_011A_PID) },
204 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_011B_PID) }, 214 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_011B_PID) },
205 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_011C_PID) }, 215 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_011C_PID) },
206 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_011D_PID) }, 216 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_011D_PID) },
207 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_011E_PID) }, 217 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_011E_PID) },
208 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_011F_PID) }, 218 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_011F_PID) },
209 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0120_PID) }, 219 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0120_PID) },
210 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0121_PID) }, 220 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0121_PID) },
211 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0122_PID) }, 221 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0122_PID) },
212 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0123_PID) }, 222 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0123_PID) },
213 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0124_PID) }, 223 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0124_PID) },
214 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0125_PID) }, 224 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0125_PID) },
215 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0126_PID) }, 225 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0126_PID) },
216 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0127_PID), 226 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0127_PID),
217 .driver_info = (kernel_ulong_t)&ftdi_mtxorb_hack_quirk }, 227 .driver_info = (kernel_ulong_t)&ftdi_mtxorb_hack_quirk },
218 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0128_PID) }, 228 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0128_PID) },
219 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0129_PID) }, 229 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0129_PID) },
220 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_012A_PID) }, 230 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_012A_PID) },
221 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_012B_PID) }, 231 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_012B_PID) },
222 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_012C_PID), 232 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_012C_PID),
223 .driver_info = (kernel_ulong_t)&ftdi_mtxorb_hack_quirk }, 233 .driver_info = (kernel_ulong_t)&ftdi_mtxorb_hack_quirk },
224 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_012D_PID) }, 234 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_012D_PID) },
225 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_012E_PID) }, 235 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_012E_PID) },
226 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_012F_PID) }, 236 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_012F_PID) },
227 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0130_PID) }, 237 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0130_PID) },
228 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0131_PID) }, 238 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0131_PID) },
229 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0132_PID) }, 239 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0132_PID) },
230 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0133_PID) }, 240 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0133_PID) },
231 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0134_PID) }, 241 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0134_PID) },
232 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0135_PID) }, 242 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0135_PID) },
233 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0136_PID) }, 243 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0136_PID) },
234 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0137_PID) }, 244 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0137_PID) },
235 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0138_PID) }, 245 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0138_PID) },
236 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0139_PID) }, 246 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0139_PID) },
237 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_013A_PID) }, 247 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_013A_PID) },
238 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_013B_PID) }, 248 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_013B_PID) },
239 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_013C_PID) }, 249 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_013C_PID) },
240 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_013D_PID) }, 250 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_013D_PID) },
241 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_013E_PID) }, 251 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_013E_PID) },
242 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_013F_PID) }, 252 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_013F_PID) },
243 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0140_PID) }, 253 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0140_PID) },
244 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0141_PID) }, 254 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0141_PID) },
245 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0142_PID) }, 255 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0142_PID) },
246 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0143_PID) }, 256 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0143_PID) },
247 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0144_PID) }, 257 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0144_PID) },
248 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0145_PID) }, 258 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0145_PID) },
249 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0146_PID) }, 259 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0146_PID) },
250 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0147_PID) }, 260 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0147_PID) },
251 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0148_PID) }, 261 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0148_PID) },
252 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0149_PID) }, 262 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0149_PID) },
253 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_014A_PID) }, 263 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_014A_PID) },
254 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_014B_PID) }, 264 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_014B_PID) },
255 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_014C_PID) }, 265 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_014C_PID) },
256 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_014D_PID) }, 266 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_014D_PID) },
257 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_014E_PID) }, 267 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_014E_PID) },
258 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_014F_PID) }, 268 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_014F_PID) },
259 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0150_PID) }, 269 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0150_PID) },
260 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0151_PID) }, 270 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0151_PID) },
261 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0152_PID) }, 271 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0152_PID) },
262 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0153_PID), 272 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0153_PID),
263 .driver_info = (kernel_ulong_t)&ftdi_mtxorb_hack_quirk }, 273 .driver_info = (kernel_ulong_t)&ftdi_mtxorb_hack_quirk },
264 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0154_PID), 274 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0154_PID),
265 .driver_info = (kernel_ulong_t)&ftdi_mtxorb_hack_quirk }, 275 .driver_info = (kernel_ulong_t)&ftdi_mtxorb_hack_quirk },
266 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0155_PID), 276 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0155_PID),
267 .driver_info = (kernel_ulong_t)&ftdi_mtxorb_hack_quirk }, 277 .driver_info = (kernel_ulong_t)&ftdi_mtxorb_hack_quirk },
268 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0156_PID), 278 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0156_PID),
269 .driver_info = (kernel_ulong_t)&ftdi_mtxorb_hack_quirk }, 279 .driver_info = (kernel_ulong_t)&ftdi_mtxorb_hack_quirk },
270 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0157_PID), 280 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0157_PID),
271 .driver_info = (kernel_ulong_t)&ftdi_mtxorb_hack_quirk }, 281 .driver_info = (kernel_ulong_t)&ftdi_mtxorb_hack_quirk },
272 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0158_PID), 282 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0158_PID),
273 .driver_info = (kernel_ulong_t)&ftdi_mtxorb_hack_quirk }, 283 .driver_info = (kernel_ulong_t)&ftdi_mtxorb_hack_quirk },
274 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0159_PID) }, 284 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0159_PID) },
275 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_015A_PID) }, 285 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_015A_PID) },
276 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_015B_PID) }, 286 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_015B_PID) },
277 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_015C_PID) }, 287 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_015C_PID) },
278 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_015D_PID) }, 288 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_015D_PID) },
279 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_015E_PID) }, 289 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_015E_PID) },
280 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_015F_PID) }, 290 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_015F_PID) },
281 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0160_PID) }, 291 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0160_PID) },
282 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0161_PID) }, 292 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0161_PID) },
283 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0162_PID) }, 293 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0162_PID) },
284 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0163_PID) }, 294 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0163_PID) },
285 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0164_PID) }, 295 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0164_PID) },
286 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0165_PID) }, 296 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0165_PID) },
287 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0166_PID) }, 297 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0166_PID) },
288 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0167_PID) }, 298 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0167_PID) },
289 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0168_PID) }, 299 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0168_PID) },
290 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0169_PID) }, 300 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0169_PID) },
291 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_016A_PID) }, 301 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_016A_PID) },
292 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_016B_PID) }, 302 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_016B_PID) },
293 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_016C_PID) }, 303 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_016C_PID) },
294 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_016D_PID) }, 304 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_016D_PID) },
295 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_016E_PID) }, 305 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_016E_PID) },
296 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_016F_PID) }, 306 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_016F_PID) },
297 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0170_PID) }, 307 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0170_PID) },
298 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0171_PID) }, 308 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0171_PID) },
299 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0172_PID) }, 309 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0172_PID) },
300 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0173_PID) }, 310 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0173_PID) },
301 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0174_PID) }, 311 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0174_PID) },
302 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0175_PID) }, 312 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0175_PID) },
303 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0176_PID) }, 313 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0176_PID) },
304 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0177_PID) }, 314 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0177_PID) },
305 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0178_PID) }, 315 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0178_PID) },
306 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0179_PID) }, 316 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0179_PID) },
307 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_017A_PID) }, 317 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_017A_PID) },
308 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_017B_PID) }, 318 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_017B_PID) },
309 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_017C_PID) }, 319 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_017C_PID) },
310 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_017D_PID) }, 320 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_017D_PID) },
311 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_017E_PID) }, 321 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_017E_PID) },
312 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_017F_PID) }, 322 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_017F_PID) },
313 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0180_PID) }, 323 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0180_PID) },
314 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0181_PID) }, 324 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0181_PID) },
315 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0182_PID) }, 325 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0182_PID) },
316 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0183_PID) }, 326 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0183_PID) },
317 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0184_PID) }, 327 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0184_PID) },
318 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0185_PID) }, 328 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0185_PID) },
319 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0186_PID) }, 329 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0186_PID) },
320 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0187_PID) }, 330 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0187_PID) },
321 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0188_PID) }, 331 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0188_PID) },
322 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0189_PID) }, 332 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0189_PID) },
323 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_018A_PID) }, 333 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_018A_PID) },
324 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_018B_PID) }, 334 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_018B_PID) },
325 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_018C_PID) }, 335 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_018C_PID) },
326 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_018D_PID) }, 336 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_018D_PID) },
327 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_018E_PID) }, 337 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_018E_PID) },
328 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_018F_PID) }, 338 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_018F_PID) },
329 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0190_PID) }, 339 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0190_PID) },
330 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0191_PID) }, 340 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0191_PID) },
331 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0192_PID) }, 341 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0192_PID) },
332 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0193_PID) }, 342 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0193_PID) },
333 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0194_PID) }, 343 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0194_PID) },
334 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0195_PID) }, 344 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0195_PID) },
335 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0196_PID) }, 345 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0196_PID) },
336 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0197_PID) }, 346 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0197_PID) },
337 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0198_PID) }, 347 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0198_PID) },
338 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0199_PID) }, 348 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0199_PID) },
339 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_019A_PID) }, 349 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_019A_PID) },
340 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_019B_PID) }, 350 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_019B_PID) },
341 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_019C_PID) }, 351 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_019C_PID) },
342 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_019D_PID) }, 352 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_019D_PID) },
343 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_019E_PID) }, 353 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_019E_PID) },
344 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_019F_PID) }, 354 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_019F_PID) },
345 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01A0_PID) }, 355 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01A0_PID) },
346 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01A1_PID) }, 356 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01A1_PID) },
347 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01A2_PID) }, 357 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01A2_PID) },
348 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01A3_PID) }, 358 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01A3_PID) },
349 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01A4_PID) }, 359 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01A4_PID) },
350 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01A5_PID) }, 360 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01A5_PID) },
351 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01A6_PID) }, 361 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01A6_PID) },
352 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01A7_PID) }, 362 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01A7_PID) },
353 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01A8_PID) }, 363 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01A8_PID) },
354 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01A9_PID) }, 364 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01A9_PID) },
355 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01AA_PID) }, 365 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01AA_PID) },
356 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01AB_PID) }, 366 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01AB_PID) },
357 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01AC_PID) }, 367 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01AC_PID) },
358 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01AD_PID) }, 368 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01AD_PID) },
359 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01AE_PID) }, 369 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01AE_PID) },
360 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01AF_PID) }, 370 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01AF_PID) },
361 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01B0_PID) }, 371 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01B0_PID) },
362 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01B1_PID) }, 372 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01B1_PID) },
363 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01B2_PID) }, 373 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01B2_PID) },
364 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01B3_PID) }, 374 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01B3_PID) },
365 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01B4_PID) }, 375 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01B4_PID) },
366 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01B5_PID) }, 376 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01B5_PID) },
367 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01B6_PID) }, 377 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01B6_PID) },
368 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01B7_PID) }, 378 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01B7_PID) },
369 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01B8_PID) }, 379 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01B8_PID) },
370 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01B9_PID) }, 380 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01B9_PID) },
371 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01BA_PID) }, 381 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01BA_PID) },
372 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01BB_PID) }, 382 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01BB_PID) },
373 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01BC_PID) }, 383 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01BC_PID) },
374 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01BD_PID) }, 384 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01BD_PID) },
375 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01BE_PID) }, 385 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01BE_PID) },
376 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01BF_PID) }, 386 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01BF_PID) },
377 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01C0_PID) }, 387 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01C0_PID) },
378 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01C1_PID) }, 388 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01C1_PID) },
379 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01C2_PID) }, 389 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01C2_PID) },
380 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01C3_PID) }, 390 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01C3_PID) },
381 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01C4_PID) }, 391 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01C4_PID) },
382 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01C5_PID) }, 392 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01C5_PID) },
383 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01C6_PID) }, 393 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01C6_PID) },
384 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01C7_PID) }, 394 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01C7_PID) },
385 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01C8_PID) }, 395 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01C8_PID) },
386 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01C9_PID) }, 396 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01C9_PID) },
387 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01CA_PID) }, 397 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01CA_PID) },
388 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01CB_PID) }, 398 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01CB_PID) },
389 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01CC_PID) }, 399 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01CC_PID) },
390 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01CD_PID) }, 400 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01CD_PID) },
391 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01CE_PID) }, 401 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01CE_PID) },
392 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01CF_PID) }, 402 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01CF_PID) },
393 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01D0_PID) }, 403 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01D0_PID) },
394 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01D1_PID) }, 404 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01D1_PID) },
395 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01D2_PID) }, 405 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01D2_PID) },
396 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01D3_PID) }, 406 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01D3_PID) },
397 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01D4_PID) }, 407 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01D4_PID) },
398 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01D5_PID) }, 408 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01D5_PID) },
399 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01D6_PID) }, 409 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01D6_PID) },
400 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01D7_PID) }, 410 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01D7_PID) },
401 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01D8_PID) }, 411 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01D8_PID) },
402 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01D9_PID) }, 412 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01D9_PID) },
403 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01DA_PID) }, 413 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01DA_PID) },
404 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01DB_PID) }, 414 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01DB_PID) },
405 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01DC_PID) }, 415 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01DC_PID) },
406 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01DD_PID) }, 416 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01DD_PID) },
407 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01DE_PID) }, 417 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01DE_PID) },
408 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01DF_PID) }, 418 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01DF_PID) },
409 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01E0_PID) }, 419 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01E0_PID) },
410 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01E1_PID) }, 420 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01E1_PID) },
411 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01E2_PID) }, 421 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01E2_PID) },
412 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01E3_PID) }, 422 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01E3_PID) },
413 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01E4_PID) }, 423 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01E4_PID) },
414 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01E5_PID) }, 424 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01E5_PID) },
415 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01E6_PID) }, 425 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01E6_PID) },
416 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01E7_PID) }, 426 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01E7_PID) },
417 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01E8_PID) }, 427 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01E8_PID) },
418 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01E9_PID) }, 428 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01E9_PID) },
419 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01EA_PID) }, 429 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01EA_PID) },
420 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01EB_PID) }, 430 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01EB_PID) },
421 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01EC_PID) }, 431 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01EC_PID) },
422 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01ED_PID) }, 432 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01ED_PID) },
423 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01EE_PID) }, 433 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01EE_PID) },
424 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01EF_PID) }, 434 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01EF_PID) },
425 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01F0_PID) }, 435 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01F0_PID) },
426 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01F1_PID) }, 436 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01F1_PID) },
427 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01F2_PID) }, 437 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01F2_PID) },
428 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01F3_PID) }, 438 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01F3_PID) },
429 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01F4_PID) }, 439 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01F4_PID) },
430 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01F5_PID) }, 440 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01F5_PID) },
431 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01F6_PID) }, 441 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01F6_PID) },
432 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01F7_PID) }, 442 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01F7_PID) },
433 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01F8_PID) }, 443 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01F8_PID) },
434 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01F9_PID) }, 444 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01F9_PID) },
435 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01FA_PID) }, 445 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01FA_PID) },
436 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01FB_PID) }, 446 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01FB_PID) },
437 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01FC_PID) }, 447 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01FC_PID) },
438 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01FD_PID) }, 448 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01FD_PID) },
439 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01FE_PID) }, 449 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01FE_PID) },
440 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01FF_PID) }, 450 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01FF_PID) },
441 { USB_DEVICE(FTDI_VID, FTDI_PERLE_ULTRAPORT_PID) }, 451 { USB_DEVICE(FTDI_VID, FTDI_PERLE_ULTRAPORT_PID) },
442 { USB_DEVICE(FTDI_VID, FTDI_PIEGROUP_PID) }, 452 { USB_DEVICE(FTDI_VID, FTDI_PIEGROUP_PID) },
443 { USB_DEVICE(FTDI_VID, FTDI_TNC_X_PID) }, 453 { USB_DEVICE(FTDI_VID, FTDI_TNC_X_PID) },
@@ -642,7 +652,7 @@ static struct usb_device_id id_table_combined [] = {
642 { } /* Terminating entry */ 652 { } /* Terminating entry */
643}; 653};
644 654
645MODULE_DEVICE_TABLE (usb, id_table_combined); 655MODULE_DEVICE_TABLE(usb, id_table_combined);
646 656
647static struct usb_driver ftdi_driver = { 657static struct usb_driver ftdi_driver = {
648 .name = "ftdi_sio", 658 .name = "ftdi_sio",
@@ -678,30 +688,37 @@ static const char *ftdi_chip_name[] = {
678 | ASYNC_SPD_CUST | ASYNC_SPD_SHI | ASYNC_SPD_WARP) 688 | ASYNC_SPD_CUST | ASYNC_SPD_SHI | ASYNC_SPD_WARP)
679 689
680/* function prototypes for a FTDI serial converter */ 690/* function prototypes for a FTDI serial converter */
681static int ftdi_sio_probe (struct usb_serial *serial, const struct usb_device_id *id); 691static int ftdi_sio_probe(struct usb_serial *serial,
682static void ftdi_shutdown (struct usb_serial *serial); 692 const struct usb_device_id *id);
683static int ftdi_sio_port_probe (struct usb_serial_port *port); 693static void ftdi_shutdown(struct usb_serial *serial);
684static int ftdi_sio_port_remove (struct usb_serial_port *port); 694static int ftdi_sio_port_probe(struct usb_serial_port *port);
685static int ftdi_open (struct tty_struct *tty, struct usb_serial_port *port, struct file *filp); 695static int ftdi_sio_port_remove(struct usb_serial_port *port);
686static void ftdi_close (struct tty_struct *tty, struct usb_serial_port *port, struct file *filp); 696static int ftdi_open(struct tty_struct *tty,
687static int ftdi_write (struct tty_struct *tty, struct usb_serial_port *port, const unsigned char *buf, int count); 697 struct usb_serial_port *port, struct file *filp);
688static int ftdi_write_room (struct tty_struct *tty); 698static void ftdi_close(struct tty_struct *tty,
689static int ftdi_chars_in_buffer (struct tty_struct *tty); 699 struct usb_serial_port *port, struct file *filp);
690static void ftdi_write_bulk_callback (struct urb *urb); 700static int ftdi_write(struct tty_struct *tty, struct usb_serial_port *port,
691static void ftdi_read_bulk_callback (struct urb *urb); 701 const unsigned char *buf, int count);
692static void ftdi_process_read (struct work_struct *work); 702static int ftdi_write_room(struct tty_struct *tty);
693static void ftdi_set_termios (struct tty_struct *tty, struct usb_serial_port *port, struct ktermios * old); 703static int ftdi_chars_in_buffer(struct tty_struct *tty);
694static int ftdi_tiocmget (struct tty_struct *tty, struct file *file); 704static void ftdi_write_bulk_callback(struct urb *urb);
695static int ftdi_tiocmset (struct tty_struct *tty, struct file * file, unsigned int set, unsigned int clear); 705static void ftdi_read_bulk_callback(struct urb *urb);
696static int ftdi_ioctl (struct tty_struct *tty, struct file * file, unsigned int cmd, unsigned long arg); 706static void ftdi_process_read(struct work_struct *work);
697static void ftdi_break_ctl (struct tty_struct *tty, int break_state ); 707static void ftdi_set_termios(struct tty_struct *tty,
698static void ftdi_throttle (struct tty_struct *tty); 708 struct usb_serial_port *port, struct ktermios *old);
699static void ftdi_unthrottle (struct tty_struct *tty); 709static int ftdi_tiocmget(struct tty_struct *tty, struct file *file);
700 710static int ftdi_tiocmset(struct tty_struct *tty, struct file *file,
701static unsigned short int ftdi_232am_baud_base_to_divisor (int baud, int base); 711 unsigned int set, unsigned int clear);
702static unsigned short int ftdi_232am_baud_to_divisor (int baud); 712static int ftdi_ioctl(struct tty_struct *tty, struct file *file,
703static __u32 ftdi_232bm_baud_base_to_divisor (int baud, int base); 713 unsigned int cmd, unsigned long arg);
704static __u32 ftdi_232bm_baud_to_divisor (int baud); 714static void ftdi_break_ctl(struct tty_struct *tty, int break_state);
715static void ftdi_throttle(struct tty_struct *tty);
716static void ftdi_unthrottle(struct tty_struct *tty);
717
718static unsigned short int ftdi_232am_baud_base_to_divisor(int baud, int base);
719static unsigned short int ftdi_232am_baud_to_divisor(int baud);
720static __u32 ftdi_232bm_baud_base_to_divisor(int baud, int base);
721static __u32 ftdi_232bm_baud_to_divisor(int baud);
705 722
706static struct usb_serial_driver ftdi_sio_device = { 723static struct usb_serial_driver ftdi_sio_device = {
707 .driver = { 724 .driver = {
@@ -752,44 +769,54 @@ static struct usb_serial_driver ftdi_sio_device = {
752static unsigned short int ftdi_232am_baud_base_to_divisor(int baud, int base) 769static unsigned short int ftdi_232am_baud_base_to_divisor(int baud, int base)
753{ 770{
754 unsigned short int divisor; 771 unsigned short int divisor;
755 int divisor3 = base / 2 / baud; // divisor shifted 3 bits to the left 772 /* divisor shifted 3 bits to the left */
756 if ((divisor3 & 0x7) == 7) divisor3 ++; // round x.7/8 up to x+1 773 int divisor3 = base / 2 / baud;
774 if ((divisor3 & 0x7) == 7)
775 divisor3++; /* round x.7/8 up to x+1 */
757 divisor = divisor3 >> 3; 776 divisor = divisor3 >> 3;
758 divisor3 &= 0x7; 777 divisor3 &= 0x7;
759 if (divisor3 == 1) divisor |= 0xc000; else // 0.125 778 if (divisor3 == 1)
760 if (divisor3 >= 4) divisor |= 0x4000; else // 0.5 779 divisor |= 0xc000;
761 if (divisor3 != 0) divisor |= 0x8000; // 0.25 780 else if (divisor3 >= 4)
762 if (divisor == 1) divisor = 0; /* special case for maximum baud rate */ 781 divisor |= 0x4000;
782 else if (divisor3 != 0)
783 divisor |= 0x8000;
784 else if (divisor == 1)
785 divisor = 0; /* special case for maximum baud rate */
763 return divisor; 786 return divisor;
764} 787}
765 788
766static unsigned short int ftdi_232am_baud_to_divisor(int baud) 789static unsigned short int ftdi_232am_baud_to_divisor(int baud)
767{ 790{
768 return(ftdi_232am_baud_base_to_divisor(baud, 48000000)); 791 return ftdi_232am_baud_base_to_divisor(baud, 48000000);
769} 792}
770 793
771static __u32 ftdi_232bm_baud_base_to_divisor(int baud, int base) 794static __u32 ftdi_232bm_baud_base_to_divisor(int baud, int base)
772{ 795{
773 static const unsigned char divfrac[8] = { 0, 3, 2, 4, 1, 5, 6, 7 }; 796 static const unsigned char divfrac[8] = { 0, 3, 2, 4, 1, 5, 6, 7 };
774 __u32 divisor; 797 __u32 divisor;
775 int divisor3 = base / 2 / baud; // divisor shifted 3 bits to the left 798 /* divisor shifted 3 bits to the left */
799 int divisor3 = base / 2 / baud;
776 divisor = divisor3 >> 3; 800 divisor = divisor3 >> 3;
777 divisor |= (__u32)divfrac[divisor3 & 0x7] << 14; 801 divisor |= (__u32)divfrac[divisor3 & 0x7] << 14;
778 /* Deal with special cases for highest baud rates. */ 802 /* Deal with special cases for highest baud rates. */
779 if (divisor == 1) divisor = 0; else // 1.0 803 if (divisor == 1)
780 if (divisor == 0x4001) divisor = 1; // 1.5 804 divisor = 0;
805 else if (divisor == 0x4001)
806 divisor = 1;
781 return divisor; 807 return divisor;
782} 808}
783 809
784static __u32 ftdi_232bm_baud_to_divisor(int baud) 810static __u32 ftdi_232bm_baud_to_divisor(int baud)
785{ 811{
786 return(ftdi_232bm_baud_base_to_divisor(baud, 48000000)); 812 return ftdi_232bm_baud_base_to_divisor(baud, 48000000);
787} 813}
788 814
789#define set_mctrl(port, set) update_mctrl((port), (set), 0) 815#define set_mctrl(port, set) update_mctrl((port), (set), 0)
790#define clear_mctrl(port, clear) update_mctrl((port), 0, (clear)) 816#define clear_mctrl(port, clear) update_mctrl((port), 0, (clear))
791 817
792static int update_mctrl(struct usb_serial_port *port, unsigned int set, unsigned int clear) 818static int update_mctrl(struct usb_serial_port *port, unsigned int set,
819 unsigned int clear)
793{ 820{
794 struct ftdi_private *priv = usb_get_serial_port_data(port); 821 struct ftdi_private *priv = usb_get_serial_port_data(port);
795 char *buf; 822 char *buf;
@@ -843,7 +870,8 @@ static int update_mctrl(struct usb_serial_port *port, unsigned int set, unsigned
843} 870}
844 871
845 872
846static __u32 get_ftdi_divisor(struct tty_struct *tty, struct usb_serial_port *port) 873static __u32 get_ftdi_divisor(struct tty_struct *tty,
874 struct usb_serial_port *port)
847{ /* get_ftdi_divisor */ 875{ /* get_ftdi_divisor */
848 struct ftdi_private *priv = usb_get_serial_port_data(port); 876 struct ftdi_private *priv = usb_get_serial_port_data(port);
849 __u32 div_value = 0; 877 __u32 div_value = 0;
@@ -851,48 +879,56 @@ static __u32 get_ftdi_divisor(struct tty_struct *tty, struct usb_serial_port *po
851 int baud; 879 int baud;
852 880
853 /* 881 /*
854 * The logic involved in setting the baudrate can be cleanly split in 3 steps. 882 * The logic involved in setting the baudrate can be cleanly split into
855 * Obtaining the actual baud rate is a little tricky since unix traditionally 883 * 3 steps.
856 * somehow ignored the possibility to set non-standard baud rates.
857 * 1. Standard baud rates are set in tty->termios->c_cflag 884 * 1. Standard baud rates are set in tty->termios->c_cflag
858 * 2. If these are not enough, you can set any speed using alt_speed as follows: 885 * 2. If these are not enough, you can set any speed using alt_speed as
886 * follows:
859 * - set tty->termios->c_cflag speed to B38400 887 * - set tty->termios->c_cflag speed to B38400
860 * - set your real speed in tty->alt_speed; it gets ignored when 888 * - set your real speed in tty->alt_speed; it gets ignored when
861 * alt_speed==0, (or) 889 * alt_speed==0, (or)
862 * - call TIOCSSERIAL ioctl with (struct serial_struct) set as follows: 890 * - call TIOCSSERIAL ioctl with (struct serial_struct) set as
863 * flags & ASYNC_SPD_MASK == ASYNC_SPD_[HI, VHI, SHI, WARP], this just 891 * follows:
864 * sets alt_speed to (HI: 57600, VHI: 115200, SHI: 230400, WARP: 460800) 892 * flags & ASYNC_SPD_MASK == ASYNC_SPD_[HI, VHI, SHI, WARP],
893 * this just sets alt_speed to (HI: 57600, VHI: 115200,
894 * SHI: 230400, WARP: 460800)
865 * ** Steps 1, 2 are done courtesy of tty_get_baud_rate 895 * ** Steps 1, 2 are done courtesy of tty_get_baud_rate
866 * 3. You can also set baud rate by setting custom divisor as follows 896 * 3. You can also set baud rate by setting custom divisor as follows
867 * - set tty->termios->c_cflag speed to B38400 897 * - set tty->termios->c_cflag speed to B38400
868 * - call TIOCSSERIAL ioctl with (struct serial_struct) set as follows: 898 * - call TIOCSSERIAL ioctl with (struct serial_struct) set as
899 * follows:
869 * o flags & ASYNC_SPD_MASK == ASYNC_SPD_CUST 900 * o flags & ASYNC_SPD_MASK == ASYNC_SPD_CUST
870 * o custom_divisor set to baud_base / your_new_baudrate 901 * o custom_divisor set to baud_base / your_new_baudrate
871 * ** Step 3 is done courtesy of code borrowed from serial.c - I should really 902 * ** Step 3 is done courtesy of code borrowed from serial.c
872 * spend some time and separate+move this common code to serial.c, it is 903 * I should really spend some time and separate + move this common
873 * replicated in nearly every serial driver you see. 904 * code to serial.c, it is replicated in nearly every serial driver
905 * you see.
874 */ 906 */
875 907
876 /* 1. Get the baud rate from the tty settings, this observes alt_speed hack */ 908 /* 1. Get the baud rate from the tty settings, this observes
909 alt_speed hack */
877 910
878 baud = tty_get_baud_rate(tty); 911 baud = tty_get_baud_rate(tty);
879 dbg("%s - tty_get_baud_rate reports speed %d", __func__, baud); 912 dbg("%s - tty_get_baud_rate reports speed %d", __func__, baud);
880 913
881 /* 2. Observe async-compatible custom_divisor hack, update baudrate if needed */ 914 /* 2. Observe async-compatible custom_divisor hack, update baudrate
915 if needed */
882 916
883 if (baud == 38400 && 917 if (baud == 38400 &&
884 ((priv->flags & ASYNC_SPD_MASK) == ASYNC_SPD_CUST) && 918 ((priv->flags & ASYNC_SPD_MASK) == ASYNC_SPD_CUST) &&
885 (priv->custom_divisor)) { 919 (priv->custom_divisor)) {
886 baud = priv->baud_base / priv->custom_divisor; 920 baud = priv->baud_base / priv->custom_divisor;
887 dbg("%s - custom divisor %d sets baud rate to %d", __func__, priv->custom_divisor, baud); 921 dbg("%s - custom divisor %d sets baud rate to %d",
922 __func__, priv->custom_divisor, baud);
888 } 923 }
889 924
890 /* 3. Convert baudrate to device-specific divisor */ 925 /* 3. Convert baudrate to device-specific divisor */
891 926
892 if (!baud) baud = 9600; 927 if (!baud)
893 switch(priv->chip_type) { 928 baud = 9600;
929 switch (priv->chip_type) {
894 case SIO: /* SIO chip */ 930 case SIO: /* SIO chip */
895 switch(baud) { 931 switch (baud) {
896 case 300: div_value = ftdi_sio_b300; break; 932 case 300: div_value = ftdi_sio_b300; break;
897 case 600: div_value = ftdi_sio_b600; break; 933 case 600: div_value = ftdi_sio_b600; break;
898 case 1200: div_value = ftdi_sio_b1200; break; 934 case 1200: div_value = ftdi_sio_b1200; break;
@@ -905,7 +941,8 @@ static __u32 get_ftdi_divisor(struct tty_struct *tty, struct usb_serial_port *po
905 case 115200: div_value = ftdi_sio_b115200; break; 941 case 115200: div_value = ftdi_sio_b115200; break;
906 } /* baud */ 942 } /* baud */
907 if (div_value == 0) { 943 if (div_value == 0) {
908 dbg("%s - Baudrate (%d) requested is not supported", __func__, baud); 944 dbg("%s - Baudrate (%d) requested is not supported",
945 __func__, baud);
909 div_value = ftdi_sio_b9600; 946 div_value = ftdi_sio_b9600;
910 baud = 9600; 947 baud = 9600;
911 div_okay = 0; 948 div_okay = 0;
@@ -915,7 +952,7 @@ static __u32 get_ftdi_divisor(struct tty_struct *tty, struct usb_serial_port *po
915 if (baud <= 3000000) { 952 if (baud <= 3000000) {
916 div_value = ftdi_232am_baud_to_divisor(baud); 953 div_value = ftdi_232am_baud_to_divisor(baud);
917 } else { 954 } else {
918 dbg("%s - Baud rate too high!", __func__); 955 dbg("%s - Baud rate too high!", __func__);
919 baud = 9600; 956 baud = 9600;
920 div_value = ftdi_232am_baud_to_divisor(9600); 957 div_value = ftdi_232am_baud_to_divisor(9600);
921 div_okay = 0; 958 div_okay = 0;
@@ -927,7 +964,7 @@ static __u32 get_ftdi_divisor(struct tty_struct *tty, struct usb_serial_port *po
927 if (baud <= 3000000) { 964 if (baud <= 3000000) {
928 div_value = ftdi_232bm_baud_to_divisor(baud); 965 div_value = ftdi_232bm_baud_to_divisor(baud);
929 } else { 966 } else {
930 dbg("%s - Baud rate too high!", __func__); 967 dbg("%s - Baud rate too high!", __func__);
931 div_value = ftdi_232bm_baud_to_divisor(9600); 968 div_value = ftdi_232bm_baud_to_divisor(9600);
932 div_okay = 0; 969 div_okay = 0;
933 baud = 9600; 970 baud = 9600;
@@ -942,14 +979,14 @@ static __u32 get_ftdi_divisor(struct tty_struct *tty, struct usb_serial_port *po
942 } 979 }
943 980
944 tty_encode_baud_rate(tty, baud, baud); 981 tty_encode_baud_rate(tty, baud, baud);
945 return(div_value); 982 return div_value;
946} 983}
947 984
948static int change_speed(struct tty_struct *tty, struct usb_serial_port *port) 985static int change_speed(struct tty_struct *tty, struct usb_serial_port *port)
949{ 986{
950 struct ftdi_private *priv = usb_get_serial_port_data(port); 987 struct ftdi_private *priv = usb_get_serial_port_data(port);
951 char *buf; 988 char *buf;
952 __u16 urb_value; 989 __u16 urb_value;
953 __u16 urb_index; 990 __u16 urb_index;
954 __u32 urb_index_value; 991 __u32 urb_index_value;
955 int rv; 992 int rv;
@@ -978,7 +1015,8 @@ static int change_speed(struct tty_struct *tty, struct usb_serial_port *port)
978 1015
979 1016
980 1017
981static int get_serial_info(struct usb_serial_port * port, struct serial_struct __user * retinfo) 1018static int get_serial_info(struct usb_serial_port *port,
1019 struct serial_struct __user *retinfo)
982{ 1020{
983 struct ftdi_private *priv = usb_get_serial_port_data(port); 1021 struct ftdi_private *priv = usb_get_serial_port_data(port);
984 struct serial_struct tmp; 1022 struct serial_struct tmp;
@@ -996,7 +1034,7 @@ static int get_serial_info(struct usb_serial_port * port, struct serial_struct _
996 1034
997 1035
998static int set_serial_info(struct tty_struct *tty, 1036static int set_serial_info(struct tty_struct *tty,
999 struct usb_serial_port * port, struct serial_struct __user * newinfo) 1037 struct usb_serial_port *port, struct serial_struct __user *newinfo)
1000{ /* set_serial_info */ 1038{ /* set_serial_info */
1001 struct ftdi_private *priv = usb_get_serial_port_data(port); 1039 struct ftdi_private *priv = usb_get_serial_port_data(port);
1002 struct serial_struct new_serial; 1040 struct serial_struct new_serial;
@@ -1004,7 +1042,7 @@ static int set_serial_info(struct tty_struct *tty,
1004 1042
1005 if (copy_from_user(&new_serial, newinfo, sizeof(new_serial))) 1043 if (copy_from_user(&new_serial, newinfo, sizeof(new_serial)))
1006 return -EFAULT; 1044 return -EFAULT;
1007 old_priv = * priv; 1045 old_priv = *priv;
1008 1046
1009 /* Do error checking and permission checking */ 1047 /* Do error checking and permission checking */
1010 1048
@@ -1025,7 +1063,7 @@ static int set_serial_info(struct tty_struct *tty,
1025 /* Make the changes - these are privileged changes! */ 1063 /* Make the changes - these are privileged changes! */
1026 1064
1027 priv->flags = ((priv->flags & ~ASYNC_FLAGS) | 1065 priv->flags = ((priv->flags & ~ASYNC_FLAGS) |
1028 (new_serial.flags & ASYNC_FLAGS)); 1066 (new_serial.flags & ASYNC_FLAGS));
1029 priv->custom_divisor = new_serial.custom_divisor; 1067 priv->custom_divisor = new_serial.custom_divisor;
1030 1068
1031 tty->low_latency = (priv->flags & ASYNC_LOW_LATENCY) ? 1 : 0; 1069 tty->low_latency = (priv->flags & ASYNC_LOW_LATENCY) ? 1 : 0;
@@ -1079,11 +1117,10 @@ static void ftdi_determine_type(struct usb_serial_port *port)
1079 priv->chip_type = FT2232C; 1117 priv->chip_type = FT2232C;
1080 /* Determine interface code. */ 1118 /* Determine interface code. */
1081 inter = serial->interface->altsetting->desc.bInterfaceNumber; 1119 inter = serial->interface->altsetting->desc.bInterfaceNumber;
1082 if (inter == 0) { 1120 if (inter == 0)
1083 priv->interface = PIT_SIOA; 1121 priv->interface = PIT_SIOA;
1084 } else { 1122 else
1085 priv->interface = PIT_SIOB; 1123 priv->interface = PIT_SIOB;
1086 }
1087 /* BM-type devices have a bug where bcdDevice gets set 1124 /* BM-type devices have a bug where bcdDevice gets set
1088 * to 0x200 when iSerialNumber is 0. */ 1125 * to 0x200 when iSerialNumber is 0. */
1089 if (version < 0x500) { 1126 if (version < 0x500) {
@@ -1117,7 +1154,8 @@ static void ftdi_determine_type(struct usb_serial_port *port)
1117 * *************************************************************************** 1154 * ***************************************************************************
1118 */ 1155 */
1119 1156
1120static ssize_t show_latency_timer(struct device *dev, struct device_attribute *attr, char *buf) 1157static ssize_t show_latency_timer(struct device *dev,
1158 struct device_attribute *attr, char *buf)
1121{ 1159{
1122 struct usb_serial_port *port = to_usb_serial_port(dev); 1160 struct usb_serial_port *port = to_usb_serial_port(dev);
1123 struct ftdi_private *priv = usb_get_serial_port_data(port); 1161 struct ftdi_private *priv = usb_get_serial_port_data(port);
@@ -1126,14 +1164,14 @@ static ssize_t show_latency_timer(struct device *dev, struct device_attribute *a
1126 int rv = 0; 1164 int rv = 0;
1127 1165
1128 1166
1129 dbg("%s",__func__); 1167 dbg("%s", __func__);
1130 1168
1131 rv = usb_control_msg(udev, 1169 rv = usb_control_msg(udev,
1132 usb_rcvctrlpipe(udev, 0), 1170 usb_rcvctrlpipe(udev, 0),
1133 FTDI_SIO_GET_LATENCY_TIMER_REQUEST, 1171 FTDI_SIO_GET_LATENCY_TIMER_REQUEST,
1134 FTDI_SIO_GET_LATENCY_TIMER_REQUEST_TYPE, 1172 FTDI_SIO_GET_LATENCY_TIMER_REQUEST_TYPE,
1135 0, priv->interface, 1173 0, priv->interface,
1136 (char*) &latency, 1, WDR_TIMEOUT); 1174 (char *) &latency, 1, WDR_TIMEOUT);
1137 1175
1138 if (rv < 0) { 1176 if (rv < 0) {
1139 dev_err(dev, "Unable to read latency timer: %i\n", rv); 1177 dev_err(dev, "Unable to read latency timer: %i\n", rv);
@@ -1143,8 +1181,9 @@ static ssize_t show_latency_timer(struct device *dev, struct device_attribute *a
1143} 1181}
1144 1182
1145/* Write a new value of the latency timer, in units of milliseconds. */ 1183/* Write a new value of the latency timer, in units of milliseconds. */
1146static ssize_t store_latency_timer(struct device *dev, struct device_attribute *attr, const char *valbuf, 1184static ssize_t store_latency_timer(struct device *dev,
1147 size_t count) 1185 struct device_attribute *attr, const char *valbuf,
1186 size_t count)
1148{ 1187{
1149 struct usb_serial_port *port = to_usb_serial_port(dev); 1188 struct usb_serial_port *port = to_usb_serial_port(dev);
1150 struct ftdi_private *priv = usb_get_serial_port_data(port); 1189 struct ftdi_private *priv = usb_get_serial_port_data(port);
@@ -1172,8 +1211,8 @@ static ssize_t store_latency_timer(struct device *dev, struct device_attribute *
1172 1211
1173/* Write an event character directly to the FTDI register. The ASCII 1212/* Write an event character directly to the FTDI register. The ASCII
1174 value is in the low 8 bits, with the enable bit in the 9th bit. */ 1213 value is in the low 8 bits, with the enable bit in the 9th bit. */
1175static ssize_t store_event_char(struct device *dev, struct device_attribute *attr, const char *valbuf, 1214static ssize_t store_event_char(struct device *dev,
1176 size_t count) 1215 struct device_attribute *attr, const char *valbuf, size_t count)
1177{ 1216{
1178 struct usb_serial_port *port = to_usb_serial_port(dev); 1217 struct usb_serial_port *port = to_usb_serial_port(dev);
1179 struct ftdi_private *priv = usb_get_serial_port_data(port); 1218 struct ftdi_private *priv = usb_get_serial_port_data(port);
@@ -1199,7 +1238,8 @@ static ssize_t store_event_char(struct device *dev, struct device_attribute *att
1199 return count; 1238 return count;
1200} 1239}
1201 1240
1202static DEVICE_ATTR(latency_timer, S_IWUSR | S_IRUGO, show_latency_timer, store_latency_timer); 1241static DEVICE_ATTR(latency_timer, S_IWUSR | S_IRUGO, show_latency_timer,
1242 store_latency_timer);
1203static DEVICE_ATTR(event_char, S_IWUSR, NULL, store_event_char); 1243static DEVICE_ATTR(event_char, S_IWUSR, NULL, store_event_char);
1204 1244
1205static int create_sysfs_attrs(struct usb_serial_port *port) 1245static int create_sysfs_attrs(struct usb_serial_port *port)
@@ -1207,7 +1247,7 @@ static int create_sysfs_attrs(struct usb_serial_port *port)
1207 struct ftdi_private *priv = usb_get_serial_port_data(port); 1247 struct ftdi_private *priv = usb_get_serial_port_data(port);
1208 int retval = 0; 1248 int retval = 0;
1209 1249
1210 dbg("%s",__func__); 1250 dbg("%s", __func__);
1211 1251
1212 /* XXX I've no idea if the original SIO supports the event_char 1252 /* XXX I've no idea if the original SIO supports the event_char
1213 * sysfs parameter, so I'm playing it safe. */ 1253 * sysfs parameter, so I'm playing it safe. */
@@ -1229,7 +1269,7 @@ static void remove_sysfs_attrs(struct usb_serial_port *port)
1229{ 1269{
1230 struct ftdi_private *priv = usb_get_serial_port_data(port); 1270 struct ftdi_private *priv = usb_get_serial_port_data(port);
1231 1271
1232 dbg("%s",__func__); 1272 dbg("%s", __func__);
1233 1273
1234 /* XXX see create_sysfs_attrs */ 1274 /* XXX see create_sysfs_attrs */
1235 if (priv->chip_type != SIO) { 1275 if (priv->chip_type != SIO) {
@@ -1250,9 +1290,11 @@ static void remove_sysfs_attrs(struct usb_serial_port *port)
1250 */ 1290 */
1251 1291
1252/* Probe function to check for special devices */ 1292/* Probe function to check for special devices */
1253static int ftdi_sio_probe (struct usb_serial *serial, const struct usb_device_id *id) 1293static int ftdi_sio_probe(struct usb_serial *serial,
1294 const struct usb_device_id *id)
1254{ 1295{
1255 struct ftdi_sio_quirk *quirk = (struct ftdi_sio_quirk *)id->driver_info; 1296 struct ftdi_sio_quirk *quirk =
1297 (struct ftdi_sio_quirk *)id->driver_info;
1256 1298
1257 if (quirk && quirk->probe) { 1299 if (quirk && quirk->probe) {
1258 int ret = quirk->probe(serial); 1300 int ret = quirk->probe(serial);
@@ -1271,17 +1313,18 @@ static int ftdi_sio_port_probe(struct usb_serial_port *port)
1271 struct ftdi_sio_quirk *quirk = usb_get_serial_data(port->serial); 1313 struct ftdi_sio_quirk *quirk = usb_get_serial_data(port->serial);
1272 1314
1273 1315
1274 dbg("%s",__func__); 1316 dbg("%s", __func__);
1275 1317
1276 priv = kzalloc(sizeof(struct ftdi_private), GFP_KERNEL); 1318 priv = kzalloc(sizeof(struct ftdi_private), GFP_KERNEL);
1277 if (!priv){ 1319 if (!priv) {
1278 err("%s- kmalloc(%Zd) failed.", __func__, sizeof(struct ftdi_private)); 1320 err("%s- kmalloc(%Zd) failed.", __func__,
1321 sizeof(struct ftdi_private));
1279 return -ENOMEM; 1322 return -ENOMEM;
1280 } 1323 }
1281 1324
1282 spin_lock_init(&priv->rx_lock); 1325 spin_lock_init(&priv->rx_lock);
1283 spin_lock_init(&priv->tx_lock); 1326 spin_lock_init(&priv->tx_lock);
1284 init_waitqueue_head(&priv->delta_msr_wait); 1327 init_waitqueue_head(&priv->delta_msr_wait);
1285 /* This will push the characters through immediately rather 1328 /* This will push the characters through immediately rather
1286 than queue a task to deliver them */ 1329 than queue a task to deliver them */
1287 priv->flags = ASYNC_LOW_LATENCY; 1330 priv->flags = ASYNC_LOW_LATENCY;
@@ -1291,9 +1334,9 @@ static int ftdi_sio_port_probe(struct usb_serial_port *port)
1291 1334
1292 /* Increase the size of read buffers */ 1335 /* Increase the size of read buffers */
1293 kfree(port->bulk_in_buffer); 1336 kfree(port->bulk_in_buffer);
1294 port->bulk_in_buffer = kmalloc (BUFSZ, GFP_KERNEL); 1337 port->bulk_in_buffer = kmalloc(BUFSZ, GFP_KERNEL);
1295 if (!port->bulk_in_buffer) { 1338 if (!port->bulk_in_buffer) {
1296 kfree (priv); 1339 kfree(priv);
1297 return -ENOMEM; 1340 return -ENOMEM;
1298 } 1341 }
1299 if (port->read_urb) { 1342 if (port->read_urb) {
@@ -1306,7 +1349,7 @@ static int ftdi_sio_port_probe(struct usb_serial_port *port)
1306 1349
1307 /* Free port's existing write urb and transfer buffer. */ 1350 /* Free port's existing write urb and transfer buffer. */
1308 if (port->write_urb) { 1351 if (port->write_urb) {
1309 usb_free_urb (port->write_urb); 1352 usb_free_urb(port->write_urb);
1310 port->write_urb = NULL; 1353 port->write_urb = NULL;
1311 } 1354 }
1312 kfree(port->bulk_out_buffer); 1355 kfree(port->bulk_out_buffer);
@@ -1314,7 +1357,7 @@ static int ftdi_sio_port_probe(struct usb_serial_port *port)
1314 1357
1315 usb_set_serial_port_data(port, priv); 1358 usb_set_serial_port_data(port, priv);
1316 1359
1317 ftdi_determine_type (port); 1360 ftdi_determine_type(port);
1318 create_sysfs_attrs(port); 1361 create_sysfs_attrs(port);
1319 return 0; 1362 return 0;
1320} 1363}
@@ -1322,9 +1365,9 @@ static int ftdi_sio_port_probe(struct usb_serial_port *port)
1322/* Setup for the USB-UIRT device, which requires hardwired 1365/* Setup for the USB-UIRT device, which requires hardwired
1323 * baudrate (38400 gets mapped to 312500) */ 1366 * baudrate (38400 gets mapped to 312500) */
1324/* Called from usbserial:serial_probe */ 1367/* Called from usbserial:serial_probe */
1325static void ftdi_USB_UIRT_setup (struct ftdi_private *priv) 1368static void ftdi_USB_UIRT_setup(struct ftdi_private *priv)
1326{ 1369{
1327 dbg("%s",__func__); 1370 dbg("%s", __func__);
1328 1371
1329 priv->flags |= ASYNC_SPD_CUST; 1372 priv->flags |= ASYNC_SPD_CUST;
1330 priv->custom_divisor = 77; 1373 priv->custom_divisor = 77;
@@ -1333,9 +1376,10 @@ static void ftdi_USB_UIRT_setup (struct ftdi_private *priv)
1333 1376
1334/* Setup for the HE-TIRA1 device, which requires hardwired 1377/* Setup for the HE-TIRA1 device, which requires hardwired
1335 * baudrate (38400 gets mapped to 100000) and RTS-CTS enabled. */ 1378 * baudrate (38400 gets mapped to 100000) and RTS-CTS enabled. */
1336static void ftdi_HE_TIRA1_setup (struct ftdi_private *priv) 1379
1380static void ftdi_HE_TIRA1_setup(struct ftdi_private *priv)
1337{ 1381{
1338 dbg("%s",__func__); 1382 dbg("%s", __func__);
1339 1383
1340 priv->flags |= ASYNC_SPD_CUST; 1384 priv->flags |= ASYNC_SPD_CUST;
1341 priv->custom_divisor = 240; 1385 priv->custom_divisor = 240;
@@ -1353,7 +1397,7 @@ static int ftdi_jtag_probe(struct usb_serial *serial)
1353 struct usb_device *udev = serial->dev; 1397 struct usb_device *udev = serial->dev;
1354 struct usb_interface *interface = serial->interface; 1398 struct usb_interface *interface = serial->interface;
1355 1399
1356 dbg("%s",__func__); 1400 dbg("%s", __func__);
1357 1401
1358 if (interface == udev->actconfig->interface[0]) { 1402 if (interface == udev->actconfig->interface[0]) {
1359 info("Ignoring serial port reserved for JTAG"); 1403 info("Ignoring serial port reserved for JTAG");
@@ -1387,7 +1431,7 @@ static int ftdi_mtxorb_hack_setup(struct usb_serial *serial)
1387 * calls __serial_close for each open of the port 1431 * calls __serial_close for each open of the port
1388 * shutdown is called then (ie ftdi_shutdown) 1432 * shutdown is called then (ie ftdi_shutdown)
1389 */ 1433 */
1390static void ftdi_shutdown (struct usb_serial *serial) 1434static void ftdi_shutdown(struct usb_serial *serial)
1391{ 1435{
1392 dbg("%s", __func__); 1436 dbg("%s", __func__);
1393} 1437}
@@ -1401,7 +1445,7 @@ static int ftdi_sio_port_remove(struct usb_serial_port *port)
1401 remove_sysfs_attrs(port); 1445 remove_sysfs_attrs(port);
1402 1446
1403 /* all open ports are closed at this point 1447 /* all open ports are closed at this point
1404 * (by usbserial.c:__serial_close, which calls ftdi_close) 1448 * (by usbserial.c:__serial_close, which calls ftdi_close)
1405 */ 1449 */
1406 1450
1407 if (priv) { 1451 if (priv) {
@@ -1462,12 +1506,14 @@ static int ftdi_open(struct tty_struct *tty,
1462 /* Start reading from the device */ 1506 /* Start reading from the device */
1463 priv->rx_processed = 0; 1507 priv->rx_processed = 0;
1464 usb_fill_bulk_urb(port->read_urb, dev, 1508 usb_fill_bulk_urb(port->read_urb, dev,
1465 usb_rcvbulkpipe(dev, port->bulk_in_endpointAddress), 1509 usb_rcvbulkpipe(dev, port->bulk_in_endpointAddress),
1466 port->read_urb->transfer_buffer, port->read_urb->transfer_buffer_length, 1510 port->read_urb->transfer_buffer,
1467 ftdi_read_bulk_callback, port); 1511 port->read_urb->transfer_buffer_length,
1512 ftdi_read_bulk_callback, port);
1468 result = usb_submit_urb(port->read_urb, GFP_KERNEL); 1513 result = usb_submit_urb(port->read_urb, GFP_KERNEL);
1469 if (result) 1514 if (result)
1470 err("%s - failed submitting read urb, error %d", __func__, result); 1515 err("%s - failed submitting read urb, error %d",
1516 __func__, result);
1471 1517
1472 1518
1473 return result; 1519 return result;
@@ -1493,7 +1539,7 @@ static void ftdi_close(struct tty_struct *tty,
1493 dbg("%s", __func__); 1539 dbg("%s", __func__);
1494 1540
1495 mutex_lock(&port->serial->disc_mutex); 1541 mutex_lock(&port->serial->disc_mutex);
1496 if (c_cflag & HUPCL && !port->serial->disconnected){ 1542 if (c_cflag & HUPCL && !port->serial->disconnected) {
1497 /* Disable flow control */ 1543 /* Disable flow control */
1498 if (usb_control_msg(port->serial->dev, 1544 if (usb_control_msg(port->serial->dev,
1499 usb_sndctrlpipe(port->serial->dev, 0), 1545 usb_sndctrlpipe(port->serial->dev, 0),
@@ -1553,7 +1599,7 @@ static int ftdi_write(struct tty_struct *tty, struct usb_serial_port *port,
1553 spin_unlock_irqrestore(&priv->tx_lock, flags); 1599 spin_unlock_irqrestore(&priv->tx_lock, flags);
1554 1600
1555 data_offset = priv->write_offset; 1601 data_offset = priv->write_offset;
1556 dbg("data_offset set to %d",data_offset); 1602 dbg("data_offset set to %d", data_offset);
1557 1603
1558 /* Determine total transfer size */ 1604 /* Determine total transfer size */
1559 transfer_size = count; 1605 transfer_size = count;
@@ -1564,7 +1610,7 @@ static int ftdi_write(struct tty_struct *tty, struct usb_serial_port *port,
1564 (PKTSZ - data_offset))); 1610 (PKTSZ - data_offset)));
1565 } 1611 }
1566 1612
1567 buffer = kmalloc (transfer_size, GFP_ATOMIC); 1613 buffer = kmalloc(transfer_size, GFP_ATOMIC);
1568 if (!buffer) { 1614 if (!buffer) {
1569 err("%s ran out of kernel memory for urb ...", __func__); 1615 err("%s ran out of kernel memory for urb ...", __func__);
1570 count = -ENOMEM; 1616 count = -ENOMEM;
@@ -1580,20 +1626,20 @@ static int ftdi_write(struct tty_struct *tty, struct usb_serial_port *port,
1580 1626
1581 /* Copy data */ 1627 /* Copy data */
1582 if (data_offset > 0) { 1628 if (data_offset > 0) {
1583 /* Original sio requires control byte at start of each packet. */ 1629 /* Original sio requires control byte at start of
1630 each packet. */
1584 int user_pktsz = PKTSZ - data_offset; 1631 int user_pktsz = PKTSZ - data_offset;
1585 int todo = count; 1632 int todo = count;
1586 unsigned char *first_byte = buffer; 1633 unsigned char *first_byte = buffer;
1587 const unsigned char *current_position = buf; 1634 const unsigned char *current_position = buf;
1588 1635
1589 while (todo > 0) { 1636 while (todo > 0) {
1590 if (user_pktsz > todo) { 1637 if (user_pktsz > todo)
1591 user_pktsz = todo; 1638 user_pktsz = todo;
1592 }
1593 /* Write the control byte at the front of the packet*/ 1639 /* Write the control byte at the front of the packet*/
1594 *first_byte = 1 | ((user_pktsz) << 2); 1640 *first_byte = 1 | ((user_pktsz) << 2);
1595 /* Copy data for packet */ 1641 /* Copy data for packet */
1596 memcpy (first_byte + data_offset, 1642 memcpy(first_byte + data_offset,
1597 current_position, user_pktsz); 1643 current_position, user_pktsz);
1598 first_byte += user_pktsz + data_offset; 1644 first_byte += user_pktsz + data_offset;
1599 current_position += user_pktsz; 1645 current_position += user_pktsz;
@@ -1602,20 +1648,23 @@ static int ftdi_write(struct tty_struct *tty, struct usb_serial_port *port,
1602 } else { 1648 } else {
1603 /* No control byte required. */ 1649 /* No control byte required. */
1604 /* Copy in the data to send */ 1650 /* Copy in the data to send */
1605 memcpy (buffer, buf, count); 1651 memcpy(buffer, buf, count);
1606 } 1652 }
1607 1653
1608 usb_serial_debug_data(debug, &port->dev, __func__, transfer_size, buffer); 1654 usb_serial_debug_data(debug, &port->dev, __func__,
1655 transfer_size, buffer);
1609 1656
1610 /* fill the buffer and send it */ 1657 /* fill the buffer and send it */
1611 usb_fill_bulk_urb(urb, port->serial->dev, 1658 usb_fill_bulk_urb(urb, port->serial->dev,
1612 usb_sndbulkpipe(port->serial->dev, port->bulk_out_endpointAddress), 1659 usb_sndbulkpipe(port->serial->dev,
1613 buffer, transfer_size, 1660 port->bulk_out_endpointAddress),
1614 ftdi_write_bulk_callback, port); 1661 buffer, transfer_size,
1662 ftdi_write_bulk_callback, port);
1615 1663
1616 status = usb_submit_urb(urb, GFP_ATOMIC); 1664 status = usb_submit_urb(urb, GFP_ATOMIC);
1617 if (status) { 1665 if (status) {
1618 err("%s - failed submitting write urb, error %d", __func__, status); 1666 err("%s - failed submitting write urb, error %d",
1667 __func__, status);
1619 count = status; 1668 count = status;
1620 goto error; 1669 goto error;
1621 } else { 1670 } else {
@@ -1634,7 +1683,7 @@ static int ftdi_write(struct tty_struct *tty, struct usb_serial_port *port,
1634error: 1683error:
1635 usb_free_urb(urb); 1684 usb_free_urb(urb);
1636error_no_urb: 1685error_no_urb:
1637 kfree (buffer); 1686 kfree(buffer);
1638error_no_buffer: 1687error_no_buffer:
1639 spin_lock_irqsave(&priv->tx_lock, flags); 1688 spin_lock_irqsave(&priv->tx_lock, flags);
1640 priv->tx_outstanding_urbs--; 1689 priv->tx_outstanding_urbs--;
@@ -1645,7 +1694,7 @@ error_no_buffer:
1645 1694
1646/* This function may get called when the device is closed */ 1695/* This function may get called when the device is closed */
1647 1696
1648static void ftdi_write_bulk_callback (struct urb *urb) 1697static void ftdi_write_bulk_callback(struct urb *urb)
1649{ 1698{
1650 unsigned long flags; 1699 unsigned long flags;
1651 struct usb_serial_port *port = urb->context; 1700 struct usb_serial_port *port = urb->context;
@@ -1655,7 +1704,7 @@ static void ftdi_write_bulk_callback (struct urb *urb)
1655 int status = urb->status; 1704 int status = urb->status;
1656 1705
1657 /* free up the transfer buffer, as usb_free_urb() does not do this */ 1706 /* free up the transfer buffer, as usb_free_urb() does not do this */
1658 kfree (urb->transfer_buffer); 1707 kfree(urb->transfer_buffer);
1659 1708
1660 dbg("%s - port %d", __func__, port->number); 1709 dbg("%s - port %d", __func__, port->number);
1661 1710
@@ -1738,9 +1787,11 @@ static void ftdi_read_bulk_callback(struct urb *urb)
1738 int status = urb->status; 1787 int status = urb->status;
1739 1788
1740 if (urb->number_of_packets > 0) { 1789 if (urb->number_of_packets > 0) {
1741 err("%s transfer_buffer_length %d actual_length %d number of packets %d",__func__, 1790 err("%s transfer_buffer_length %d actual_length %d number of packets %d",
1742 urb->transfer_buffer_length, urb->actual_length, urb->number_of_packets ); 1791 __func__,
1743 err("%s transfer_flags %x ", __func__,urb->transfer_flags ); 1792 urb->transfer_buffer_length,
1793 urb->actual_length, urb->number_of_packets);
1794 err("%s transfer_flags %x ", __func__, urb->transfer_flags);
1744 } 1795 }
1745 1796
1746 dbg("%s - port %d", __func__, port->number); 1797 dbg("%s - port %d", __func__, port->number);
@@ -1750,7 +1801,7 @@ static void ftdi_read_bulk_callback(struct urb *urb)
1750 1801
1751 tty = port->port.tty; 1802 tty = port->port.tty;
1752 if (!tty) { 1803 if (!tty) {
1753 dbg("%s - bad tty pointer - exiting",__func__); 1804 dbg("%s - bad tty pointer - exiting", __func__);
1754 return; 1805 return;
1755 } 1806 }
1756 1807
@@ -1760,14 +1811,13 @@ static void ftdi_read_bulk_callback(struct urb *urb)
1760 return; 1811 return;
1761 } 1812 }
1762 1813
1763 if (urb != port->read_urb) { 1814 if (urb != port->read_urb)
1764 err("%s - Not my urb!", __func__); 1815 err("%s - Not my urb!", __func__);
1765 }
1766 1816
1767 if (status) { 1817 if (status) {
1768 /* This will happen at close every time so it is a dbg not an err */ 1818 /* This will happen at close every time so it is a dbg not an
1769 dbg("(this is ok on close) nonzero read bulk status received: " 1819 err */
1770 "%d", status); 1820 dbg("(this is ok on close) nonzero read bulk status received: %d", status);
1771 return; 1821 return;
1772 } 1822 }
1773 1823
@@ -1783,7 +1833,7 @@ static void ftdi_read_bulk_callback(struct urb *urb)
1783} /* ftdi_read_bulk_callback */ 1833} /* ftdi_read_bulk_callback */
1784 1834
1785 1835
1786static void ftdi_process_read (struct work_struct *work) 1836static void ftdi_process_read(struct work_struct *work)
1787{ /* ftdi_process_read */ 1837{ /* ftdi_process_read */
1788 struct ftdi_private *priv = 1838 struct ftdi_private *priv =
1789 container_of(work, struct ftdi_private, rx_work.work); 1839 container_of(work, struct ftdi_private, rx_work.work);
@@ -1806,7 +1856,7 @@ static void ftdi_process_read (struct work_struct *work)
1806 1856
1807 tty = port->port.tty; 1857 tty = port->port.tty;
1808 if (!tty) { 1858 if (!tty) {
1809 dbg("%s - bad tty pointer - exiting",__func__); 1859 dbg("%s - bad tty pointer - exiting", __func__);
1810 return; 1860 return;
1811 } 1861 }
1812 1862
@@ -1830,11 +1880,11 @@ static void ftdi_process_read (struct work_struct *work)
1830 urb->actual_length - priv->rx_processed); 1880 urb->actual_length - priv->rx_processed);
1831 } else { 1881 } else {
1832 /* The first two bytes of every read packet are status */ 1882 /* The first two bytes of every read packet are status */
1833 if (urb->actual_length > 2) { 1883 if (urb->actual_length > 2)
1834 usb_serial_debug_data(debug, &port->dev, __func__, urb->actual_length, data); 1884 usb_serial_debug_data(debug, &port->dev, __func__,
1835 } else { 1885 urb->actual_length, data);
1836 dbg("Status only: %03oo %03oo",data[0],data[1]); 1886 else
1837 } 1887 dbg("Status only: %03oo %03oo", data[0], data[1]);
1838 } 1888 }
1839 1889
1840 1890
@@ -1844,16 +1894,19 @@ static void ftdi_process_read (struct work_struct *work)
1844 /* if CD is dropped and the line is not CLOCAL then we should hangup */ 1894 /* if CD is dropped and the line is not CLOCAL then we should hangup */
1845 1895
1846 need_flip = 0; 1896 need_flip = 0;
1847 for (packet_offset = priv->rx_processed; packet_offset < urb->actual_length; packet_offset += PKTSZ) { 1897 for (packet_offset = priv->rx_processed;
1898 packet_offset < urb->actual_length; packet_offset += PKTSZ) {
1848 int length; 1899 int length;
1849 1900
1850 /* Compare new line status to the old one, signal if different */ 1901 /* Compare new line status to the old one, signal if different/
1851 /* N.B. packet may be processed more than once, but differences 1902 N.B. packet may be processed more than once, but differences
1852 * are only processed once. */ 1903 are only processed once. */
1853 if (priv != NULL) { 1904 if (priv != NULL) {
1854 char new_status = data[packet_offset+0] & FTDI_STATUS_B0_MASK; 1905 char new_status = data[packet_offset + 0] &
1906 FTDI_STATUS_B0_MASK;
1855 if (new_status != priv->prev_status) { 1907 if (new_status != priv->prev_status) {
1856 priv->diff_status |= new_status ^ priv->prev_status; 1908 priv->diff_status |=
1909 new_status ^ priv->prev_status;
1857 wake_up_interruptible(&priv->delta_msr_wait); 1910 wake_up_interruptible(&priv->delta_msr_wait);
1858 priv->prev_status = new_status; 1911 priv->prev_status = new_status;
1859 } 1912 }
@@ -1870,30 +1923,31 @@ static void ftdi_process_read (struct work_struct *work)
1870 break; 1923 break;
1871 } 1924 }
1872 if (tty_buffer_request_room(tty, length) < length) { 1925 if (tty_buffer_request_room(tty, length) < length) {
1873 /* break out & wait for throttling/unthrottling to happen */ 1926 /* break out & wait for throttling/unthrottling to
1927 happen */
1874 dbg("%s - receive room low", __func__); 1928 dbg("%s - receive room low", __func__);
1875 break; 1929 break;
1876 } 1930 }
1877 1931
1878 /* Handle errors and break */ 1932 /* Handle errors and break */
1879 error_flag = TTY_NORMAL; 1933 error_flag = TTY_NORMAL;
1880 /* Although the device uses a bitmask and hence can have multiple */ 1934 /* Although the device uses a bitmask and hence can have
1881 /* errors on a packet - the order here sets the priority the */ 1935 multiple errors on a packet - the order here sets the
1882 /* error is returned to the tty layer */ 1936 priority the error is returned to the tty layer */
1883 1937
1884 if ( data[packet_offset+1] & FTDI_RS_OE ) { 1938 if (data[packet_offset+1] & FTDI_RS_OE) {
1885 error_flag = TTY_OVERRUN; 1939 error_flag = TTY_OVERRUN;
1886 dbg("OVERRRUN error"); 1940 dbg("OVERRRUN error");
1887 } 1941 }
1888 if ( data[packet_offset+1] & FTDI_RS_BI ) { 1942 if (data[packet_offset+1] & FTDI_RS_BI) {
1889 error_flag = TTY_BREAK; 1943 error_flag = TTY_BREAK;
1890 dbg("BREAK received"); 1944 dbg("BREAK received");
1891 } 1945 }
1892 if ( data[packet_offset+1] & FTDI_RS_PE ) { 1946 if (data[packet_offset+1] & FTDI_RS_PE) {
1893 error_flag = TTY_PARITY; 1947 error_flag = TTY_PARITY;
1894 dbg("PARITY error"); 1948 dbg("PARITY error");
1895 } 1949 }
1896 if ( data[packet_offset+1] & FTDI_RS_FE ) { 1950 if (data[packet_offset+1] & FTDI_RS_FE) {
1897 error_flag = TTY_FRAME; 1951 error_flag = TTY_FRAME;
1898 dbg("FRAMING error"); 1952 dbg("FRAMING error");
1899 } 1953 }
@@ -1902,7 +1956,8 @@ static void ftdi_process_read (struct work_struct *work)
1902 /* Note that the error flag is duplicated for 1956 /* Note that the error flag is duplicated for
1903 every character received since we don't know 1957 every character received since we don't know
1904 which character it applied to */ 1958 which character it applied to */
1905 tty_insert_flip_char(tty, data[packet_offset+i], error_flag); 1959 tty_insert_flip_char(tty,
1960 data[packet_offset + i], error_flag);
1906 } 1961 }
1907 need_flip = 1; 1962 need_flip = 1;
1908 } 1963 }
@@ -1910,19 +1965,19 @@ static void ftdi_process_read (struct work_struct *work)
1910#ifdef NOT_CORRECT_BUT_KEEPING_IT_FOR_NOW 1965#ifdef NOT_CORRECT_BUT_KEEPING_IT_FOR_NOW
1911 /* if a parity error is detected you get status packets forever 1966 /* if a parity error is detected you get status packets forever
1912 until a character is sent without a parity error. 1967 until a character is sent without a parity error.
1913 This doesn't work well since the application receives a never 1968 This doesn't work well since the application receives a
1914 ending stream of bad data - even though new data hasn't been sent. 1969 never ending stream of bad data - even though new data
1915 Therefore I (bill) have taken this out. 1970 hasn't been sent. Therefore I (bill) have taken this out.
1916 However - this might make sense for framing errors and so on 1971 However - this might make sense for framing errors and so on
1917 so I am leaving the code in for now. 1972 so I am leaving the code in for now.
1918 */ 1973 */
1919 else { 1974 else {
1920 if (error_flag != TTY_NORMAL){ 1975 if (error_flag != TTY_NORMAL) {
1921 dbg("error_flag is not normal"); 1976 dbg("error_flag is not normal");
1922 /* In this case it is just status - if that is an error send a bad character */ 1977 /* In this case it is just status - if that is
1923 if(tty->flip.count >= TTY_FLIPBUF_SIZE) { 1978 an error send a bad character */
1979 if (tty->flip.count >= TTY_FLIPBUF_SIZE)
1924 tty_flip_buffer_push(tty); 1980 tty_flip_buffer_push(tty);
1925 }
1926 tty_insert_flip_char(tty, 0xff, error_flag); 1981 tty_insert_flip_char(tty, 0xff, error_flag);
1927 need_flip = 1; 1982 need_flip = 1;
1928 } 1983 }
@@ -1931,9 +1986,8 @@ static void ftdi_process_read (struct work_struct *work)
1931 } /* "for(packet_offset=0..." */ 1986 } /* "for(packet_offset=0..." */
1932 1987
1933 /* Low latency */ 1988 /* Low latency */
1934 if (need_flip) { 1989 if (need_flip)
1935 tty_flip_buffer_push(tty); 1990 tty_flip_buffer_push(tty);
1936 }
1937 1991
1938 if (packet_offset < urb->actual_length) { 1992 if (packet_offset < urb->actual_length) {
1939 /* not completely processed - record progress */ 1993 /* not completely processed - record progress */
@@ -1952,12 +2006,11 @@ static void ftdi_process_read (struct work_struct *work)
1952 } 2006 }
1953 spin_unlock_irqrestore(&priv->rx_lock, flags); 2007 spin_unlock_irqrestore(&priv->rx_lock, flags);
1954 /* if the port is closed stop trying to read */ 2008 /* if the port is closed stop trying to read */
1955 if (port->port.count > 0){ 2009 if (port->port.count > 0)
1956 /* delay processing of remainder */ 2010 /* delay processing of remainder */
1957 schedule_delayed_work(&priv->rx_work, 1); 2011 schedule_delayed_work(&priv->rx_work, 1);
1958 } else { 2012 else
1959 dbg("%s - port is closed", __func__); 2013 dbg("%s - port is closed", __func__);
1960 }
1961 return; 2014 return;
1962 } 2015 }
1963 2016
@@ -1965,19 +2018,20 @@ static void ftdi_process_read (struct work_struct *work)
1965 priv->rx_processed = 0; 2018 priv->rx_processed = 0;
1966 2019
1967 /* if the port is closed stop trying to read */ 2020 /* if the port is closed stop trying to read */
1968 if (port->port.count > 0){ 2021 if (port->port.count > 0) {
1969 /* Continue trying to always read */ 2022 /* Continue trying to always read */
1970 usb_fill_bulk_urb(port->read_urb, port->serial->dev, 2023 usb_fill_bulk_urb(port->read_urb, port->serial->dev,
1971 usb_rcvbulkpipe(port->serial->dev, port->bulk_in_endpointAddress), 2024 usb_rcvbulkpipe(port->serial->dev,
1972 port->read_urb->transfer_buffer, port->read_urb->transfer_buffer_length, 2025 port->bulk_in_endpointAddress),
1973 ftdi_read_bulk_callback, port); 2026 port->read_urb->transfer_buffer,
2027 port->read_urb->transfer_buffer_length,
2028 ftdi_read_bulk_callback, port);
1974 2029
1975 result = usb_submit_urb(port->read_urb, GFP_ATOMIC); 2030 result = usb_submit_urb(port->read_urb, GFP_ATOMIC);
1976 if (result) 2031 if (result)
1977 err("%s - failed resubmitting read urb, error %d", __func__, result); 2032 err("%s - failed resubmitting read urb, error %d",
2033 __func__, result);
1978 } 2034 }
1979
1980 return;
1981} /* ftdi_process_read */ 2035} /* ftdi_process_read */
1982 2036
1983 2037
@@ -1992,22 +2046,23 @@ static void ftdi_break_ctl(struct tty_struct *tty, int break_state)
1992 /* see drivers/char/tty_io.c to see it used */ 2046 /* see drivers/char/tty_io.c to see it used */
1993 /* last_set_data_urb_value NEVER has the break bit set in it */ 2047 /* last_set_data_urb_value NEVER has the break bit set in it */
1994 2048
1995 if (break_state) { 2049 if (break_state)
1996 urb_value = priv->last_set_data_urb_value | FTDI_SIO_SET_BREAK; 2050 urb_value = priv->last_set_data_urb_value | FTDI_SIO_SET_BREAK;
1997 } else { 2051 else
1998 urb_value = priv->last_set_data_urb_value; 2052 urb_value = priv->last_set_data_urb_value;
1999 }
2000
2001 2053
2002 if (usb_control_msg(port->serial->dev, usb_sndctrlpipe(port->serial->dev, 0), 2054 if (usb_control_msg(port->serial->dev,
2003 FTDI_SIO_SET_DATA_REQUEST, 2055 usb_sndctrlpipe(port->serial->dev, 0),
2004 FTDI_SIO_SET_DATA_REQUEST_TYPE, 2056 FTDI_SIO_SET_DATA_REQUEST,
2005 urb_value , priv->interface, 2057 FTDI_SIO_SET_DATA_REQUEST_TYPE,
2006 buf, 0, WDR_TIMEOUT) < 0) { 2058 urb_value , priv->interface,
2007 err("%s FAILED to enable/disable break state (state was %d)", __func__,break_state); 2059 buf, 0, WDR_TIMEOUT) < 0) {
2060 err("%s FAILED to enable/disable break state (state was %d)",
2061 __func__, break_state);
2008 } 2062 }
2009 2063
2010 dbg("%s break state is %d - urb is %d", __func__,break_state, urb_value); 2064 dbg("%s break state is %d - urb is %d", __func__,
2065 break_state, urb_value);
2011 2066
2012} 2067}
2013 2068
@@ -2027,14 +2082,15 @@ static void ftdi_set_termios(struct tty_struct *tty,
2027 __u16 urb_value; /* will hold the new flags */ 2082 __u16 urb_value; /* will hold the new flags */
2028 char buf[1]; /* Perhaps I should dynamically alloc this? */ 2083 char buf[1]; /* Perhaps I should dynamically alloc this? */
2029 2084
2030 // Added for xon/xoff support 2085 /* Added for xon/xoff support */
2031 unsigned int iflag = termios->c_iflag; 2086 unsigned int iflag = termios->c_iflag;
2032 unsigned char vstop; 2087 unsigned char vstop;
2033 unsigned char vstart; 2088 unsigned char vstart;
2034 2089
2035 dbg("%s", __func__); 2090 dbg("%s", __func__);
2036 2091
2037 /* Force baud rate if this device requires it, unless it is set to B0. */ 2092 /* Force baud rate if this device requires it, unless it is set to
2093 B0. */
2038 if (priv->force_baud && ((termios->c_cflag & CBAUD) != B0)) { 2094 if (priv->force_baud && ((termios->c_cflag & CBAUD) != B0)) {
2039 dbg("%s: forcing baud rate for this device", __func__); 2095 dbg("%s: forcing baud rate for this device", __func__);
2040 tty_encode_baud_rate(tty, priv->force_baud, 2096 tty_encode_baud_rate(tty, priv->force_baud,
@@ -2053,8 +2109,8 @@ static void ftdi_set_termios(struct tty_struct *tty,
2053 not - so just do the change regardless - should be able to 2109 not - so just do the change regardless - should be able to
2054 compare old_termios and tty->termios */ 2110 compare old_termios and tty->termios */
2055 /* NOTE These routines can get interrupted by 2111 /* NOTE These routines can get interrupted by
2056 ftdi_sio_read_bulk_callback - need to examine what this 2112 ftdi_sio_read_bulk_callback - need to examine what this means -
2057 means - don't see any problems yet */ 2113 don't see any problems yet */
2058 2114
2059 /* Set number of data bits, parity, stop bits */ 2115 /* Set number of data bits, parity, stop bits */
2060 2116
@@ -2078,8 +2134,8 @@ static void ftdi_set_termios(struct tty_struct *tty,
2078 } 2134 }
2079 } 2135 }
2080 2136
2081 /* This is needed by the break command since it uses the same command - but is 2137 /* This is needed by the break command since it uses the same command
2082 * or'ed with this value */ 2138 - but is or'ed with this value */
2083 priv->last_set_data_urb_value = urb_value; 2139 priv->last_set_data_urb_value = urb_value;
2084 2140
2085 if (usb_control_msg(dev, usb_sndctrlpipe(dev, 0), 2141 if (usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
@@ -2091,7 +2147,7 @@ static void ftdi_set_termios(struct tty_struct *tty,
2091 } 2147 }
2092 2148
2093 /* Now do the baudrate */ 2149 /* Now do the baudrate */
2094 if ((cflag & CBAUD) == B0 ) { 2150 if ((cflag & CBAUD) == B0) {
2095 /* Disable flow control */ 2151 /* Disable flow control */
2096 if (usb_control_msg(dev, usb_sndctrlpipe(dev, 0), 2152 if (usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
2097 FTDI_SIO_SET_FLOW_CTRL_REQUEST, 2153 FTDI_SIO_SET_FLOW_CTRL_REQUEST,
@@ -2104,13 +2160,11 @@ static void ftdi_set_termios(struct tty_struct *tty,
2104 clear_mctrl(port, TIOCM_DTR | TIOCM_RTS); 2160 clear_mctrl(port, TIOCM_DTR | TIOCM_RTS);
2105 } else { 2161 } else {
2106 /* set the baudrate determined before */ 2162 /* set the baudrate determined before */
2107 if (change_speed(tty, port)) { 2163 if (change_speed(tty, port))
2108 err("%s urb failed to set baudrate", __func__); 2164 err("%s urb failed to set baudrate", __func__);
2109 }
2110 /* Ensure RTS and DTR are raised when baudrate changed from 0 */ 2165 /* Ensure RTS and DTR are raised when baudrate changed from 0 */
2111 if (!old_termios || (old_termios->c_cflag & CBAUD) == B0) { 2166 if (!old_termios || (old_termios->c_cflag & CBAUD) == B0)
2112 set_mctrl(port, TIOCM_DTR | TIOCM_RTS); 2167 set_mctrl(port, TIOCM_DTR | TIOCM_RTS);
2113 }
2114 } 2168 }
2115 2169
2116 /* Set flow control */ 2170 /* Set flow control */
@@ -2130,18 +2184,22 @@ static void ftdi_set_termios(struct tty_struct *tty,
2130 /* 2184 /*
2131 * Xon/Xoff code 2185 * Xon/Xoff code
2132 * 2186 *
2133 * Check the IXOFF status in the iflag component of the termios structure 2187 * Check the IXOFF status in the iflag component of the
2134 * if IXOFF is not set, the pre-xon/xoff code is executed. 2188 * termios structure. If IXOFF is not set, the pre-xon/xoff
2135 */ 2189 * code is executed.
2190 */
2136 if (iflag & IXOFF) { 2191 if (iflag & IXOFF) {
2137 dbg("%s request to enable xonxoff iflag=%04x",__func__,iflag); 2192 dbg("%s request to enable xonxoff iflag=%04x",
2138 // Try to enable the XON/XOFF on the ftdi_sio 2193 __func__, iflag);
2139 // Set the vstart and vstop -- could have been done up above where 2194 /* Try to enable the XON/XOFF on the ftdi_sio
2140 // a lot of other dereferencing is done but that would be very 2195 * Set the vstart and vstop -- could have been done up
2141 // inefficient as vstart and vstop are not always needed 2196 * above where a lot of other dereferencing is done but
2197 * that would be very inefficient as vstart and vstop
2198 * are not always needed.
2199 */
2142 vstart = termios->c_cc[VSTART]; 2200 vstart = termios->c_cc[VSTART];
2143 vstop = termios->c_cc[VSTOP]; 2201 vstop = termios->c_cc[VSTOP];
2144 urb_value=(vstop << 8) | (vstart); 2202 urb_value = (vstop << 8) | (vstart);
2145 2203
2146 if (usb_control_msg(dev, 2204 if (usb_control_msg(dev,
2147 usb_sndctrlpipe(dev, 0), 2205 usb_sndctrlpipe(dev, 0),
@@ -2153,8 +2211,9 @@ static void ftdi_set_termios(struct tty_struct *tty,
2153 err("urb failed to set to xon/xoff flow control"); 2211 err("urb failed to set to xon/xoff flow control");
2154 } 2212 }
2155 } else { 2213 } else {
2156 /* else clause to only run if cfag ! CRTSCTS and iflag ! XOFF */ 2214 /* else clause to only run if cflag ! CRTSCTS and iflag
2157 /* CHECKME Assuming XON/XOFF handled by tty stack - not by device */ 2215 * ! XOFF. CHECKME Assuming XON/XOFF handled by tty
2216 * stack - not by device */
2158 dbg("%s Turning off hardware flow control", __func__); 2217 dbg("%s Turning off hardware flow control", __func__);
2159 if (usb_control_msg(dev, 2218 if (usb_control_msg(dev,
2160 usb_sndctrlpipe(dev, 0), 2219 usb_sndctrlpipe(dev, 0),
@@ -2181,32 +2240,35 @@ static int ftdi_tiocmget(struct tty_struct *tty, struct file *file)
2181 switch (priv->chip_type) { 2240 switch (priv->chip_type) {
2182 case SIO: 2241 case SIO:
2183 /* Request the status from the device */ 2242 /* Request the status from the device */
2184 if ((ret = usb_control_msg(port->serial->dev, 2243 ret = usb_control_msg(port->serial->dev,
2185 usb_rcvctrlpipe(port->serial->dev, 0), 2244 usb_rcvctrlpipe(port->serial->dev, 0),
2186 FTDI_SIO_GET_MODEM_STATUS_REQUEST, 2245 FTDI_SIO_GET_MODEM_STATUS_REQUEST,
2187 FTDI_SIO_GET_MODEM_STATUS_REQUEST_TYPE, 2246 FTDI_SIO_GET_MODEM_STATUS_REQUEST_TYPE,
2188 0, 0, 2247 0, 0,
2189 buf, 1, WDR_TIMEOUT)) < 0 ) { 2248 buf, 1, WDR_TIMEOUT);
2249 if (ret < 0) {
2190 err("%s Could not get modem status of device - err: %d", __func__, 2250 err("%s Could not get modem status of device - err: %d", __func__,
2191 ret); 2251 ret);
2192 return(ret); 2252 return ret;
2193 } 2253 }
2194 break; 2254 break;
2195 case FT8U232AM: 2255 case FT8U232AM:
2196 case FT232BM: 2256 case FT232BM:
2197 case FT2232C: 2257 case FT2232C:
2198 case FT232RL: 2258 case FT232RL:
2199 /* the 8U232AM returns a two byte value (the sio is a 1 byte value) - in the same 2259 /* the 8U232AM returns a two byte value (the sio is a 1 byte
2200 format as the data returned from the in point */ 2260 value) - in the same format as the data returned from the in
2201 if ((ret = usb_control_msg(port->serial->dev, 2261 point */
2202 usb_rcvctrlpipe(port->serial->dev, 0), 2262 ret = usb_control_msg(port->serial->dev,
2203 FTDI_SIO_GET_MODEM_STATUS_REQUEST, 2263 usb_rcvctrlpipe(port->serial->dev, 0),
2204 FTDI_SIO_GET_MODEM_STATUS_REQUEST_TYPE, 2264 FTDI_SIO_GET_MODEM_STATUS_REQUEST,
2205 0, priv->interface, 2265 FTDI_SIO_GET_MODEM_STATUS_REQUEST_TYPE,
2206 buf, 2, WDR_TIMEOUT)) < 0 ) { 2266 0, priv->interface,
2267 buf, 2, WDR_TIMEOUT);
2268 if (ret < 0) {
2207 err("%s Could not get modem status of device - err: %d", __func__, 2269 err("%s Could not get modem status of device - err: %d", __func__,
2208 ret); 2270 ret);
2209 return(ret); 2271 return ret;
2210 } 2272 }
2211 break; 2273 break;
2212 default: 2274 default:
@@ -2221,7 +2283,7 @@ static int ftdi_tiocmget(struct tty_struct *tty, struct file *file)
2221 priv->last_dtr_rts; 2283 priv->last_dtr_rts;
2222} 2284}
2223 2285
2224static int ftdi_tiocmset(struct tty_struct *tty, struct file * file, 2286static int ftdi_tiocmset(struct tty_struct *tty, struct file *file,
2225 unsigned int set, unsigned int clear) 2287 unsigned int set, unsigned int clear)
2226{ 2288{
2227 struct usb_serial_port *port = tty->driver_data; 2289 struct usb_serial_port *port = tty->driver_data;
@@ -2230,7 +2292,8 @@ static int ftdi_tiocmset(struct tty_struct *tty, struct file * file,
2230} 2292}
2231 2293
2232 2294
2233static int ftdi_ioctl(struct tty_struct *tty, struct file * file, unsigned int cmd, unsigned long arg) 2295static int ftdi_ioctl(struct tty_struct *tty, struct file *file,
2296 unsigned int cmd, unsigned long arg)
2234{ 2297{
2235 struct usb_serial_port *port = tty->driver_data; 2298 struct usb_serial_port *port = tty->driver_data;
2236 struct ftdi_private *priv = usb_get_serial_port_data(port); 2299 struct ftdi_private *priv = usb_get_serial_port_data(port);
@@ -2241,10 +2304,12 @@ static int ftdi_ioctl(struct tty_struct *tty, struct file * file, unsigned int c
2241 switch (cmd) { 2304 switch (cmd) {
2242 2305
2243 case TIOCGSERIAL: /* gets serial port data */ 2306 case TIOCGSERIAL: /* gets serial port data */
2244 return get_serial_info(port, (struct serial_struct __user *) arg); 2307 return get_serial_info(port,
2308 (struct serial_struct __user *) arg);
2245 2309
2246 case TIOCSSERIAL: /* sets serial port data */ 2310 case TIOCSSERIAL: /* sets serial port data */
2247 return set_serial_info(tty, port, (struct serial_struct __user *) arg); 2311 return set_serial_info(tty, port,
2312 (struct serial_struct __user *) arg);
2248 2313
2249 /* 2314 /*
2250 * Wait for any of the 4 modem inputs (DCD,RI,DSR,CTS) to change 2315 * Wait for any of the 4 modem inputs (DCD,RI,DSR,CTS) to change
@@ -2263,23 +2328,24 @@ static int ftdi_ioctl(struct tty_struct *tty, struct file * file, unsigned int c
2263 else { 2328 else {
2264 char diff = priv->diff_status; 2329 char diff = priv->diff_status;
2265 2330
2266 if (diff == 0) { 2331 if (diff == 0)
2267 return -EIO; /* no change => error */ 2332 return -EIO; /* no change => error */
2268 }
2269 2333
2270 /* Consume all events */ 2334 /* Consume all events */
2271 priv->diff_status = 0; 2335 priv->diff_status = 0;
2272 2336
2273 /* Return 0 if caller wanted to know about these bits */ 2337 /* Return 0 if caller wanted to know about
2274 if ( ((arg & TIOCM_RNG) && (diff & FTDI_RS0_RI)) || 2338 these bits */
2275 ((arg & TIOCM_DSR) && (diff & FTDI_RS0_DSR)) || 2339 if (((arg & TIOCM_RNG) && (diff & FTDI_RS0_RI)) ||
2276 ((arg & TIOCM_CD) && (diff & FTDI_RS0_RLSD)) || 2340 ((arg & TIOCM_DSR) && (diff & FTDI_RS0_DSR)) ||
2277 ((arg & TIOCM_CTS) && (diff & FTDI_RS0_CTS)) ) { 2341 ((arg & TIOCM_CD) && (diff & FTDI_RS0_RLSD)) ||
2342 ((arg & TIOCM_CTS) && (diff & FTDI_RS0_CTS))) {
2278 return 0; 2343 return 0;
2279 } 2344 }
2280 /* 2345 /*
2281 * Otherwise caller can't care less about what happened, 2346 * Otherwise caller can't care less about what
2282 * and so we continue to wait for more events. 2347 * happened,and so we continue to wait for more
2348 * events.
2283 */ 2349 */
2284 } 2350 }
2285 } 2351 }
@@ -2287,8 +2353,8 @@ static int ftdi_ioctl(struct tty_struct *tty, struct file * file, unsigned int c
2287 default: 2353 default:
2288 break; 2354 break;
2289 } 2355 }
2290 /* This is not necessarily an error - turns out the higher layers will do 2356 /* This is not necessarily an error - turns out the higher layers
2291 * some ioctls itself (see comment above) 2357 * will do some ioctls themselves (see comment above)
2292 */ 2358 */
2293 dbg("%s arg not supported - it was 0x%04x - check /usr/include/asm/ioctls.h", __func__, cmd); 2359 dbg("%s arg not supported - it was 0x%04x - check /usr/include/asm/ioctls.h", __func__, cmd);
2294 return -ENOIOCTLCMD; 2360 return -ENOIOCTLCMD;
@@ -2326,7 +2392,7 @@ static void ftdi_unthrottle(struct tty_struct *tty)
2326 schedule_delayed_work(&priv->rx_work, 0); 2392 schedule_delayed_work(&priv->rx_work, 0);
2327} 2393}
2328 2394
2329static int __init ftdi_init (void) 2395static int __init ftdi_init(void)
2330{ 2396{
2331 int retval; 2397 int retval;
2332 2398
@@ -2356,13 +2422,13 @@ failed_sio_register:
2356} 2422}
2357 2423
2358 2424
2359static void __exit ftdi_exit (void) 2425static void __exit ftdi_exit(void)
2360{ 2426{
2361 2427
2362 dbg("%s", __func__); 2428 dbg("%s", __func__);
2363 2429
2364 usb_deregister (&ftdi_driver); 2430 usb_deregister(&ftdi_driver);
2365 usb_serial_deregister (&ftdi_sio_device); 2431 usb_serial_deregister(&ftdi_sio_device);
2366 2432
2367} 2433}
2368 2434
@@ -2370,8 +2436,8 @@ static void __exit ftdi_exit (void)
2370module_init(ftdi_init); 2436module_init(ftdi_init);
2371module_exit(ftdi_exit); 2437module_exit(ftdi_exit);
2372 2438
2373MODULE_AUTHOR( DRIVER_AUTHOR ); 2439MODULE_AUTHOR(DRIVER_AUTHOR);
2374MODULE_DESCRIPTION( DRIVER_DESC ); 2440MODULE_DESCRIPTION(DRIVER_DESC);
2375MODULE_LICENSE("GPL"); 2441MODULE_LICENSE("GPL");
2376 2442
2377module_param(debug, bool, S_IRUGO | S_IWUSR); 2443module_param(debug, bool, S_IRUGO | S_IWUSR);
diff --git a/drivers/usb/serial/ftdi_sio.h b/drivers/usb/serial/ftdi_sio.h
index 8302eca893ea..a577ea44dcf9 100644
--- a/drivers/usb/serial/ftdi_sio.h
+++ b/drivers/usb/serial/ftdi_sio.h
@@ -1,20 +1,20 @@
1/* 1/*
2 * Definitions for the FTDI USB Single Port Serial Converter - 2 * Definitions for the FTDI USB Single Port Serial Converter -
3 * known as FTDI_SIO (Serial Input/Output application of the chipset) 3 * known as FTDI_SIO (Serial Input/Output application of the chipset)
4 * 4 *
5 * The example I have is known as the USC-1000 which is available from 5 * The example I have is known as the USC-1000 which is available from
6 * http://www.dse.co.nz - cat no XH4214 It looks similar to this: 6 * http://www.dse.co.nz - cat no XH4214 It looks similar to this:
7 * http://www.dansdata.com/usbser.htm but I can't be sure There are other 7 * http://www.dansdata.com/usbser.htm but I can't be sure There are other
8 * USC-1000s which don't look like my device though so beware! 8 * USC-1000s which don't look like my device though so beware!
9 * 9 *
10 * The device is based on the FTDI FT8U100AX chip. It has a DB25 on one side, 10 * The device is based on the FTDI FT8U100AX chip. It has a DB25 on one side,
11 * USB on the other. 11 * USB on the other.
12 * 12 *
13 * Thanx to FTDI (http://www.ftdi.co.uk) for so kindly providing details 13 * Thanx to FTDI (http://www.ftdi.co.uk) for so kindly providing details
14 * of the protocol required to talk to the device and ongoing assistence 14 * of the protocol required to talk to the device and ongoing assistence
15 * during development. 15 * during development.
16 * 16 *
17 * Bill Ryder - bryder@sgi.com formerly of Silicon Graphics, Inc.- wrote the 17 * Bill Ryder - bryder@sgi.com formerly of Silicon Graphics, Inc.- wrote the
18 * FTDI_SIO implementation. 18 * FTDI_SIO implementation.
19 * 19 *
20 * Philipp Gühring - pg@futureware.at - added the Device ID of the USB relais 20 * Philipp Gühring - pg@futureware.at - added the Device ID of the USB relais
@@ -472,7 +472,7 @@
472/* 472/*
473 * DSS-20 Sync Station for Sony Ericsson P800 473 * DSS-20 Sync Station for Sony Ericsson P800
474 */ 474 */
475#define FTDI_DSS20_PID 0xFC82 475#define FTDI_DSS20_PID 0xFC82
476 476
477/* 477/*
478 * Home Electronics (www.home-electro.com) USB gadgets 478 * Home Electronics (www.home-electro.com) USB gadgets
@@ -884,7 +884,7 @@
884/* 884/*
885 * BmRequestType: 0100 0000B 885 * BmRequestType: 0100 0000B
886 * bRequest: FTDI_SIO_RESET 886 * bRequest: FTDI_SIO_RESET
887 * wValue: Control Value 887 * wValue: Control Value
888 * 0 = Reset SIO 888 * 0 = Reset SIO
889 * 1 = Purge RX buffer 889 * 1 = Purge RX buffer
890 * 2 = Purge TX buffer 890 * 2 = Purge TX buffer
@@ -952,7 +952,7 @@
952 * 101 - add .625 to divisor 952 * 101 - add .625 to divisor
953 * 110 - add .750 to divisor 953 * 110 - add .750 to divisor
954 * 111 - add .875 to divisor 954 * 111 - add .875 to divisor
955 * Bits 15 to 0 of the 17-bit divisor are placed in the urb value. Bit 16 is 955 * Bits 15 to 0 of the 17-bit divisor are placed in the urb value. Bit 16 is
956 * placed in bit 0 of the urb index. 956 * placed in bit 0 of the urb index.
957 * 957 *
958 * Note that there are a couple of special cases to support the highest baud 958 * Note that there are a couple of special cases to support the highest baud
@@ -971,8 +971,8 @@ typedef enum {
971} ftdi_chip_type_t; 971} ftdi_chip_type_t;
972 972
973typedef enum { 973typedef enum {
974 ftdi_sio_b300 = 0, 974 ftdi_sio_b300 = 0,
975 ftdi_sio_b600 = 1, 975 ftdi_sio_b600 = 1,
976 ftdi_sio_b1200 = 2, 976 ftdi_sio_b1200 = 2,
977 ftdi_sio_b2400 = 3, 977 ftdi_sio_b2400 = 3,
978 ftdi_sio_b4800 = 4, 978 ftdi_sio_b4800 = 4,
@@ -981,7 +981,7 @@ typedef enum {
981 ftdi_sio_b38400 = 7, 981 ftdi_sio_b38400 = 7,
982 ftdi_sio_b57600 = 8, 982 ftdi_sio_b57600 = 8,
983 ftdi_sio_b115200 = 9 983 ftdi_sio_b115200 = 9
984} FTDI_SIO_baudrate_t ; 984} FTDI_SIO_baudrate_t;
985 985
986/* 986/*
987 * The ftdi_8U232AM_xxMHz_byyy constants have been removed. The encoded divisor values 987 * The ftdi_8U232AM_xxMHz_byyy constants have been removed. The encoded divisor values
@@ -990,19 +990,19 @@ typedef enum {
990 990
991#define FTDI_SIO_SET_DATA_REQUEST FTDI_SIO_SET_DATA 991#define FTDI_SIO_SET_DATA_REQUEST FTDI_SIO_SET_DATA
992#define FTDI_SIO_SET_DATA_REQUEST_TYPE 0x40 992#define FTDI_SIO_SET_DATA_REQUEST_TYPE 0x40
993#define FTDI_SIO_SET_DATA_PARITY_NONE (0x0 << 8 ) 993#define FTDI_SIO_SET_DATA_PARITY_NONE (0x0 << 8)
994#define FTDI_SIO_SET_DATA_PARITY_ODD (0x1 << 8 ) 994#define FTDI_SIO_SET_DATA_PARITY_ODD (0x1 << 8)
995#define FTDI_SIO_SET_DATA_PARITY_EVEN (0x2 << 8 ) 995#define FTDI_SIO_SET_DATA_PARITY_EVEN (0x2 << 8)
996#define FTDI_SIO_SET_DATA_PARITY_MARK (0x3 << 8 ) 996#define FTDI_SIO_SET_DATA_PARITY_MARK (0x3 << 8)
997#define FTDI_SIO_SET_DATA_PARITY_SPACE (0x4 << 8 ) 997#define FTDI_SIO_SET_DATA_PARITY_SPACE (0x4 << 8)
998#define FTDI_SIO_SET_DATA_STOP_BITS_1 (0x0 << 11 ) 998#define FTDI_SIO_SET_DATA_STOP_BITS_1 (0x0 << 11)
999#define FTDI_SIO_SET_DATA_STOP_BITS_15 (0x1 << 11 ) 999#define FTDI_SIO_SET_DATA_STOP_BITS_15 (0x1 << 11)
1000#define FTDI_SIO_SET_DATA_STOP_BITS_2 (0x2 << 11 ) 1000#define FTDI_SIO_SET_DATA_STOP_BITS_2 (0x2 << 11)
1001#define FTDI_SIO_SET_BREAK (0x1 << 14) 1001#define FTDI_SIO_SET_BREAK (0x1 << 14)
1002/* FTDI_SIO_SET_DATA */ 1002/* FTDI_SIO_SET_DATA */
1003 1003
1004/* 1004/*
1005 * BmRequestType: 0100 0000B 1005 * BmRequestType: 0100 0000B
1006 * bRequest: FTDI_SIO_SET_DATA 1006 * bRequest: FTDI_SIO_SET_DATA
1007 * wValue: Data characteristics (see below) 1007 * wValue: Data characteristics (see below)
1008 * wIndex: Port 1008 * wIndex: Port
@@ -1035,7 +1035,7 @@ typedef enum {
1035#define FTDI_SIO_SET_MODEM_CTRL_REQUEST_TYPE 0x40 1035#define FTDI_SIO_SET_MODEM_CTRL_REQUEST_TYPE 0x40
1036#define FTDI_SIO_SET_MODEM_CTRL_REQUEST FTDI_SIO_MODEM_CTRL 1036#define FTDI_SIO_SET_MODEM_CTRL_REQUEST FTDI_SIO_MODEM_CTRL
1037 1037
1038/* 1038/*
1039 * BmRequestType: 0100 0000B 1039 * BmRequestType: 0100 0000B
1040 * bRequest: FTDI_SIO_MODEM_CTRL 1040 * bRequest: FTDI_SIO_MODEM_CTRL
1041 * wValue: ControlValue (see below) 1041 * wValue: ControlValue (see below)
@@ -1049,11 +1049,11 @@ typedef enum {
1049 */ 1049 */
1050 1050
1051#define FTDI_SIO_SET_DTR_MASK 0x1 1051#define FTDI_SIO_SET_DTR_MASK 0x1
1052#define FTDI_SIO_SET_DTR_HIGH ( 1 | ( FTDI_SIO_SET_DTR_MASK << 8)) 1052#define FTDI_SIO_SET_DTR_HIGH (1 | (FTDI_SIO_SET_DTR_MASK << 8))
1053#define FTDI_SIO_SET_DTR_LOW ( 0 | ( FTDI_SIO_SET_DTR_MASK << 8)) 1053#define FTDI_SIO_SET_DTR_LOW (0 | (FTDI_SIO_SET_DTR_MASK << 8))
1054#define FTDI_SIO_SET_RTS_MASK 0x2 1054#define FTDI_SIO_SET_RTS_MASK 0x2
1055#define FTDI_SIO_SET_RTS_HIGH ( 2 | ( FTDI_SIO_SET_RTS_MASK << 8 )) 1055#define FTDI_SIO_SET_RTS_HIGH (2 | (FTDI_SIO_SET_RTS_MASK << 8))
1056#define FTDI_SIO_SET_RTS_LOW ( 0 | ( FTDI_SIO_SET_RTS_MASK << 8 )) 1056#define FTDI_SIO_SET_RTS_LOW (0 | (FTDI_SIO_SET_RTS_MASK << 8))
1057 1057
1058/* 1058/*
1059 * ControlValue 1059 * ControlValue
@@ -1076,7 +1076,7 @@ typedef enum {
1076/* FTDI_SIO_SET_FLOW_CTRL */ 1076/* FTDI_SIO_SET_FLOW_CTRL */
1077#define FTDI_SIO_SET_FLOW_CTRL_REQUEST_TYPE 0x40 1077#define FTDI_SIO_SET_FLOW_CTRL_REQUEST_TYPE 0x40
1078#define FTDI_SIO_SET_FLOW_CTRL_REQUEST FTDI_SIO_SET_FLOW_CTRL 1078#define FTDI_SIO_SET_FLOW_CTRL_REQUEST FTDI_SIO_SET_FLOW_CTRL
1079#define FTDI_SIO_DISABLE_FLOW_CTRL 0x0 1079#define FTDI_SIO_DISABLE_FLOW_CTRL 0x0
1080#define FTDI_SIO_RTS_CTS_HS (0x1 << 8) 1080#define FTDI_SIO_RTS_CTS_HS (0x1 << 8)
1081#define FTDI_SIO_DTR_DSR_HS (0x2 << 8) 1081#define FTDI_SIO_DTR_DSR_HS (0x2 << 8)
1082#define FTDI_SIO_XON_XOFF_HS (0x4 << 8) 1082#define FTDI_SIO_XON_XOFF_HS (0x4 << 8)
@@ -1085,7 +1085,7 @@ typedef enum {
1085 * bRequest: FTDI_SIO_SET_FLOW_CTRL 1085 * bRequest: FTDI_SIO_SET_FLOW_CTRL
1086 * wValue: Xoff/Xon 1086 * wValue: Xoff/Xon
1087 * wIndex: Protocol/Port - hIndex is protocl / lIndex is port 1087 * wIndex: Protocol/Port - hIndex is protocl / lIndex is port
1088 * wLength: 0 1088 * wLength: 0
1089 * Data: None 1089 * Data: None
1090 * 1090 *
1091 * hIndex protocol is: 1091 * hIndex protocol is:
@@ -1101,10 +1101,10 @@ typedef enum {
1101 * 1101 *
1102 * A value of zero in the hIndex field disables handshaking 1102 * A value of zero in the hIndex field disables handshaking
1103 * 1103 *
1104 * If Xon/Xoff handshaking is specified, the hValue field should contain the XOFF character 1104 * If Xon/Xoff handshaking is specified, the hValue field should contain the XOFF character
1105 * and the lValue field contains the XON character. 1105 * and the lValue field contains the XON character.
1106 */ 1106 */
1107 1107
1108/* 1108/*
1109 * FTDI_SIO_GET_LATENCY_TIMER 1109 * FTDI_SIO_GET_LATENCY_TIMER
1110 * 1110 *
@@ -1118,7 +1118,7 @@ typedef enum {
1118#define FTDI_SIO_GET_LATENCY_TIMER_REQUEST FTDI_SIO_GET_LATENCY_TIMER 1118#define FTDI_SIO_GET_LATENCY_TIMER_REQUEST FTDI_SIO_GET_LATENCY_TIMER
1119#define FTDI_SIO_GET_LATENCY_TIMER_REQUEST_TYPE 0xC0 1119#define FTDI_SIO_GET_LATENCY_TIMER_REQUEST_TYPE 0xC0
1120 1120
1121/* 1121/*
1122 * BmRequestType: 1100 0000b 1122 * BmRequestType: 1100 0000b
1123 * bRequest: FTDI_SIO_GET_LATENCY_TIMER 1123 * bRequest: FTDI_SIO_GET_LATENCY_TIMER
1124 * wValue: 0 1124 * wValue: 0
@@ -1127,7 +1127,7 @@ typedef enum {
1127 * Data: latency (on return) 1127 * Data: latency (on return)
1128 */ 1128 */
1129 1129
1130/* 1130/*
1131 * FTDI_SIO_SET_LATENCY_TIMER 1131 * FTDI_SIO_SET_LATENCY_TIMER
1132 * 1132 *
1133 * Set the timeout interval. The FTDI collects data from the slave 1133 * Set the timeout interval. The FTDI collects data from the slave
@@ -1140,7 +1140,7 @@ typedef enum {
1140#define FTDI_SIO_SET_LATENCY_TIMER_REQUEST FTDI_SIO_SET_LATENCY_TIMER 1140#define FTDI_SIO_SET_LATENCY_TIMER_REQUEST FTDI_SIO_SET_LATENCY_TIMER
1141#define FTDI_SIO_SET_LATENCY_TIMER_REQUEST_TYPE 0x40 1141#define FTDI_SIO_SET_LATENCY_TIMER_REQUEST_TYPE 0x40
1142 1142
1143/* 1143/*
1144 * BmRequestType: 0100 0000b 1144 * BmRequestType: 0100 0000b
1145 * bRequest: FTDI_SIO_SET_LATENCY_TIMER 1145 * bRequest: FTDI_SIO_SET_LATENCY_TIMER
1146 * wValue: Latency (milliseconds) 1146 * wValue: Latency (milliseconds)
@@ -1155,7 +1155,7 @@ typedef enum {
1155 */ 1155 */
1156 1156
1157/* 1157/*
1158 * FTDI_SIO_SET_EVENT_CHAR 1158 * FTDI_SIO_SET_EVENT_CHAR
1159 * 1159 *
1160 * Set the special event character for the specified communications port. 1160 * Set the special event character for the specified communications port.
1161 * If the device sees this character it will immediately return the 1161 * If the device sees this character it will immediately return the
@@ -1168,7 +1168,7 @@ typedef enum {
1168#define FTDI_SIO_SET_EVENT_CHAR_REQUEST_TYPE 0x40 1168#define FTDI_SIO_SET_EVENT_CHAR_REQUEST_TYPE 0x40
1169 1169
1170 1170
1171/* 1171/*
1172 * BmRequestType: 0100 0000b 1172 * BmRequestType: 0100 0000b
1173 * bRequest: FTDI_SIO_SET_EVENT_CHAR 1173 * bRequest: FTDI_SIO_SET_EVENT_CHAR
1174 * wValue: EventChar 1174 * wValue: EventChar
@@ -1184,12 +1184,12 @@ typedef enum {
1184 * B9..15 Reserved 1184 * B9..15 Reserved
1185 * 1185 *
1186 */ 1186 */
1187 1187
1188/* FTDI_SIO_SET_ERROR_CHAR */ 1188/* FTDI_SIO_SET_ERROR_CHAR */
1189 1189
1190/* Set the parity error replacement character for the specified communications port */ 1190/* Set the parity error replacement character for the specified communications port */
1191 1191
1192/* 1192/*
1193 * BmRequestType: 0100 0000b 1193 * BmRequestType: 0100 0000b
1194 * bRequest: FTDI_SIO_SET_EVENT_CHAR 1194 * bRequest: FTDI_SIO_SET_EVENT_CHAR
1195 * wValue: Error Char 1195 * wValue: Error Char
@@ -1215,15 +1215,15 @@ typedef enum {
1215#define FTDI_SIO_DSR_MASK 0x20 1215#define FTDI_SIO_DSR_MASK 0x20
1216#define FTDI_SIO_RI_MASK 0x40 1216#define FTDI_SIO_RI_MASK 0x40
1217#define FTDI_SIO_RLSD_MASK 0x80 1217#define FTDI_SIO_RLSD_MASK 0x80
1218/* 1218/*
1219 * BmRequestType: 1100 0000b 1219 * BmRequestType: 1100 0000b
1220 * bRequest: FTDI_SIO_GET_MODEM_STATUS 1220 * bRequest: FTDI_SIO_GET_MODEM_STATUS
1221 * wValue: zero 1221 * wValue: zero
1222 * wIndex: Port 1222 * wIndex: Port
1223 * wLength: 1 1223 * wLength: 1
1224 * Data: Status 1224 * Data: Status
1225 * 1225 *
1226 * One byte of data is returned 1226 * One byte of data is returned
1227 * B0..3 0 1227 * B0..3 0
1228 * B4 CTS 1228 * B4 CTS
1229 * 0 = inactive 1229 * 0 = inactive
@@ -1236,15 +1236,15 @@ typedef enum {
1236 * 1 = active 1236 * 1 = active
1237 * B7 Receive Line Signal Detect (RLSD) 1237 * B7 Receive Line Signal Detect (RLSD)
1238 * 0 = inactive 1238 * 0 = inactive
1239 * 1 = active 1239 * 1 = active
1240 */ 1240 */
1241 1241
1242 1242
1243 1243
1244/* Descriptors returned by the device 1244/* Descriptors returned by the device
1245 * 1245 *
1246 * Device Descriptor 1246 * Device Descriptor
1247 * 1247 *
1248 * Offset Field Size Value Description 1248 * Offset Field Size Value Description
1249 * 0 bLength 1 0x12 Size of descriptor in bytes 1249 * 0 bLength 1 0x12 Size of descriptor in bytes
1250 * 1 bDescriptorType 1 0x01 DEVICE Descriptor Type 1250 * 1 bDescriptorType 1 0x01 DEVICE Descriptor Type
@@ -1260,9 +1260,9 @@ typedef enum {
1260 * 15 iProduct 1 0x02 Index of prod string desc 1260 * 15 iProduct 1 0x02 Index of prod string desc
1261 * 16 iSerialNumber 1 0x02 Index of serial nmr string desc 1261 * 16 iSerialNumber 1 0x02 Index of serial nmr string desc
1262 * 17 bNumConfigurations 1 0x01 Number of possible configurations 1262 * 17 bNumConfigurations 1 0x01 Number of possible configurations
1263 * 1263 *
1264 * Configuration Descriptor 1264 * Configuration Descriptor
1265 * 1265 *
1266 * Offset Field Size Value 1266 * Offset Field Size Value
1267 * 0 bLength 1 0x09 Size of descriptor in bytes 1267 * 0 bLength 1 0x09 Size of descriptor in bytes
1268 * 1 bDescriptorType 1 0x02 CONFIGURATION Descriptor Type 1268 * 1 bDescriptorType 1 0x02 CONFIGURATION Descriptor Type
@@ -1272,9 +1272,9 @@ typedef enum {
1272 * 6 iConfiguration 1 0x02 Index of config string descriptor 1272 * 6 iConfiguration 1 0x02 Index of config string descriptor
1273 * 7 bmAttributes 1 0x20 Config characteristics Remote Wakeup 1273 * 7 bmAttributes 1 0x20 Config characteristics Remote Wakeup
1274 * 8 MaxPower 1 0x1E Max power consumption 1274 * 8 MaxPower 1 0x1E Max power consumption
1275 * 1275 *
1276 * Interface Descriptor 1276 * Interface Descriptor
1277 * 1277 *
1278 * Offset Field Size Value 1278 * Offset Field Size Value
1279 * 0 bLength 1 0x09 Size of descriptor in bytes 1279 * 0 bLength 1 0x09 Size of descriptor in bytes
1280 * 1 bDescriptorType 1 0x04 INTERFACE Descriptor Type 1280 * 1 bDescriptorType 1 0x04 INTERFACE Descriptor Type
@@ -1285,9 +1285,9 @@ typedef enum {
1285 * 6 bInterfaceSubClass 1 0xFF Subclass Code 1285 * 6 bInterfaceSubClass 1 0xFF Subclass Code
1286 * 7 bInterfaceProtocol 1 0xFF Protocol Code 1286 * 7 bInterfaceProtocol 1 0xFF Protocol Code
1287 * 8 iInterface 1 0x02 Index of interface string description 1287 * 8 iInterface 1 0x02 Index of interface string description
1288 * 1288 *
1289 * IN Endpoint Descriptor 1289 * IN Endpoint Descriptor
1290 * 1290 *
1291 * Offset Field Size Value 1291 * Offset Field Size Value
1292 * 0 bLength 1 0x07 Size of descriptor in bytes 1292 * 0 bLength 1 0x07 Size of descriptor in bytes
1293 * 1 bDescriptorType 1 0x05 ENDPOINT descriptor type 1293 * 1 bDescriptorType 1 0x05 ENDPOINT descriptor type
@@ -1295,9 +1295,9 @@ typedef enum {
1295 * 3 bmAttributes 1 0x02 Endpoint attributes - Bulk 1295 * 3 bmAttributes 1 0x02 Endpoint attributes - Bulk
1296 * 4 bNumEndpoints 2 0x0040 maximum packet size 1296 * 4 bNumEndpoints 2 0x0040 maximum packet size
1297 * 5 bInterval 1 0x00 Interval for polling endpoint 1297 * 5 bInterval 1 0x00 Interval for polling endpoint
1298 * 1298 *
1299 * OUT Endpoint Descriptor 1299 * OUT Endpoint Descriptor
1300 * 1300 *
1301 * Offset Field Size Value 1301 * Offset Field Size Value
1302 * 0 bLength 1 0x07 Size of descriptor in bytes 1302 * 0 bLength 1 0x07 Size of descriptor in bytes
1303 * 1 bDescriptorType 1 0x05 ENDPOINT descriptor type 1303 * 1 bDescriptorType 1 0x05 ENDPOINT descriptor type
@@ -1305,17 +1305,17 @@ typedef enum {
1305 * 3 bmAttributes 1 0x02 Endpoint attributes - Bulk 1305 * 3 bmAttributes 1 0x02 Endpoint attributes - Bulk
1306 * 4 bNumEndpoints 2 0x0040 maximum packet size 1306 * 4 bNumEndpoints 2 0x0040 maximum packet size
1307 * 5 bInterval 1 0x00 Interval for polling endpoint 1307 * 5 bInterval 1 0x00 Interval for polling endpoint
1308 * 1308 *
1309 * DATA FORMAT 1309 * DATA FORMAT
1310 * 1310 *
1311 * IN Endpoint 1311 * IN Endpoint
1312 * 1312 *
1313 * The device reserves the first two bytes of data on this endpoint to contain the current 1313 * The device reserves the first two bytes of data on this endpoint to contain the current
1314 * values of the modem and line status registers. In the absence of data, the device 1314 * values of the modem and line status registers. In the absence of data, the device
1315 * generates a message consisting of these two status bytes every 40 ms 1315 * generates a message consisting of these two status bytes every 40 ms
1316 * 1316 *
1317 * Byte 0: Modem Status 1317 * Byte 0: Modem Status
1318 * 1318 *
1319 * Offset Description 1319 * Offset Description
1320 * B0 Reserved - must be 1 1320 * B0 Reserved - must be 1
1321 * B1 Reserved - must be 0 1321 * B1 Reserved - must be 0
@@ -1325,9 +1325,9 @@ typedef enum {
1325 * B5 Data Set Ready (DSR) 1325 * B5 Data Set Ready (DSR)
1326 * B6 Ring Indicator (RI) 1326 * B6 Ring Indicator (RI)
1327 * B7 Receive Line Signal Detect (RLSD) 1327 * B7 Receive Line Signal Detect (RLSD)
1328 * 1328 *
1329 * Byte 1: Line Status 1329 * Byte 1: Line Status
1330 * 1330 *
1331 * Offset Description 1331 * Offset Description
1332 * B0 Data Ready (DR) 1332 * B0 Data Ready (DR)
1333 * B1 Overrun Error (OE) 1333 * B1 Overrun Error (OE)
@@ -1337,7 +1337,7 @@ typedef enum {
1337 * B5 Transmitter Holding Register (THRE) 1337 * B5 Transmitter Holding Register (THRE)
1338 * B6 Transmitter Empty (TEMT) 1338 * B6 Transmitter Empty (TEMT)
1339 * B7 Error in RCVR FIFO 1339 * B7 Error in RCVR FIFO
1340 * 1340 *
1341 */ 1341 */
1342#define FTDI_RS0_CTS (1 << 4) 1342#define FTDI_RS0_CTS (1 << 4)
1343#define FTDI_RS0_DSR (1 << 5) 1343#define FTDI_RS0_DSR (1 << 5)
@@ -1355,17 +1355,17 @@ typedef enum {
1355 1355
1356/* 1356/*
1357 * OUT Endpoint 1357 * OUT Endpoint
1358 * 1358 *
1359 * This device reserves the first bytes of data on this endpoint contain the length 1359 * This device reserves the first bytes of data on this endpoint contain the length
1360 * and port identifier of the message. For the FTDI USB Serial converter the port 1360 * and port identifier of the message. For the FTDI USB Serial converter the port
1361 * identifier is always 1. 1361 * identifier is always 1.
1362 * 1362 *
1363 * Byte 0: Line Status 1363 * Byte 0: Line Status
1364 * 1364 *
1365 * Offset Description 1365 * Offset Description
1366 * B0 Reserved - must be 1 1366 * B0 Reserved - must be 1
1367 * B1 Reserved - must be 0 1367 * B1 Reserved - must be 0
1368 * B2..7 Length of message - (not including Byte 0) 1368 * B2..7 Length of message - (not including Byte 0)
1369 * 1369 *
1370 */ 1370 */
1371 1371