xref: /openbmc/linux/drivers/usb/serial/ftdi_sio.c (revision 5363cdc3c5da9bd431552cf5989ab481596f0c6d)
11da177e4SLinus Torvalds /*
21da177e4SLinus Torvalds  * USB FTDI SIO driver
31da177e4SLinus Torvalds  *
4d3901a06SJohan Hovold  *	Copyright (C) 2009 - 2010
5d3901a06SJohan Hovold  *	    Johan Hovold (jhovold@gmail.com)
61da177e4SLinus Torvalds  *	Copyright (C) 1999 - 2001
71da177e4SLinus Torvalds  *	    Greg Kroah-Hartman (greg@kroah.com)
81da177e4SLinus Torvalds  *          Bill Ryder (bryder@sgi.com)
91da177e4SLinus Torvalds  *	Copyright (C) 2002
101da177e4SLinus Torvalds  *	    Kuba Ober (kuba@mareimbrium.org)
111da177e4SLinus Torvalds  *
121da177e4SLinus Torvalds  *	This program is free software; you can redistribute it and/or modify
131da177e4SLinus Torvalds  *	it under the terms of the GNU General Public License as published by
141da177e4SLinus Torvalds  *	the Free Software Foundation; either version 2 of the License, or
151da177e4SLinus Torvalds  *	(at your option) any later version.
161da177e4SLinus Torvalds  *
17464cbb24SAlan Cox  * See Documentation/usb/usb-serial.txt for more information on using this
18464cbb24SAlan Cox  * driver
191da177e4SLinus Torvalds  *
201da177e4SLinus Torvalds  * See http://ftdi-usb-sio.sourceforge.net for upto date testing info
211da177e4SLinus Torvalds  *	and extra documentation
221da177e4SLinus Torvalds  *
23504b55ccSGreg Kroah-Hartman  * Change entries from 2004 and earlier can be found in versions of this
24504b55ccSGreg Kroah-Hartman  * file in kernel versions prior to the 2.6.24 release.
251da177e4SLinus Torvalds  *
261da177e4SLinus Torvalds  */
271da177e4SLinus Torvalds 
281da177e4SLinus Torvalds /* Bill Ryder - bryder@sgi.com - wrote the FTDI_SIO implementation */
291da177e4SLinus Torvalds /* Thanx to FTDI for so kindly providing details of the protocol required */
301da177e4SLinus Torvalds /*   to talk to the device */
31464cbb24SAlan Cox /* Thanx to gkh and the rest of the usb dev group for all code I have
32464cbb24SAlan Cox    assimilated :-) */
331da177e4SLinus Torvalds 
341da177e4SLinus Torvalds #include <linux/kernel.h>
351da177e4SLinus Torvalds #include <linux/errno.h>
361da177e4SLinus Torvalds #include <linux/init.h>
371da177e4SLinus Torvalds #include <linux/slab.h>
381da177e4SLinus Torvalds #include <linux/tty.h>
391da177e4SLinus Torvalds #include <linux/tty_driver.h>
401da177e4SLinus Torvalds #include <linux/tty_flip.h>
411da177e4SLinus Torvalds #include <linux/module.h>
421da177e4SLinus Torvalds #include <linux/spinlock.h>
43bd09a9f5SAlessio Igor Bogani #include <linux/mutex.h>
44464cbb24SAlan Cox #include <linux/uaccess.h>
451da177e4SLinus Torvalds #include <linux/usb.h>
461da177e4SLinus Torvalds #include <linux/serial.h>
47a969888cSGreg Kroah-Hartman #include <linux/usb/serial.h>
481da177e4SLinus Torvalds #include "ftdi_sio.h"
4931844d55SAndreas Mohr #include "ftdi_sio_ids.h"
501da177e4SLinus Torvalds 
511da177e4SLinus Torvalds /*
521da177e4SLinus Torvalds  * Version Information
531da177e4SLinus Torvalds  */
54d3901a06SJohan Hovold #define DRIVER_VERSION "v1.6.0"
55d3901a06SJohan Hovold #define DRIVER_AUTHOR "Greg Kroah-Hartman <greg@kroah.com>, Bill Ryder <bryder@sgi.com>, Kuba Ober <kuba@mareimbrium.org>, Andreas Mohr, Johan Hovold <jhovold@gmail.com>"
561da177e4SLinus Torvalds #define DRIVER_DESC "USB FTDI Serial Converters Driver"
571da177e4SLinus Torvalds 
581da177e4SLinus Torvalds static int debug;
59fdcb0a0fSIan Abbott static __u16 vendor = FTDI_VID;
60fdcb0a0fSIan Abbott static __u16 product;
611da177e4SLinus Torvalds 
620ffbbe25SOliver Neukum struct ftdi_private {
63c45d6320SAlan Stern 	struct kref kref;
643bb36aa2SGreg Kroah-Hartman 	enum ftdi_chip_type chip_type;
65464cbb24SAlan Cox 				/* type of device, either SIO or FT8U232AM */
660ffbbe25SOliver Neukum 	int baud_base;		/* baud base clock for divisor setting */
67464cbb24SAlan Cox 	int custom_divisor;	/* custom_divisor kludge, this is for
68464cbb24SAlan Cox 				   baud_base (different from what goes to the
69464cbb24SAlan Cox 				   chip!) */
700ffbbe25SOliver Neukum 	__u16 last_set_data_urb_value ;
71464cbb24SAlan Cox 				/* the last data state set - needed for doing
72464cbb24SAlan Cox 				 * a break
73464cbb24SAlan Cox 				 */
740ffbbe25SOliver Neukum 	int flags;		/* some ASYNC_xxxx flags are supported */
750ffbbe25SOliver Neukum 	unsigned long last_dtr_rts;	/* saved modem control outputs */
760ffbbe25SOliver Neukum 	wait_queue_head_t delta_msr_wait; /* Used for TIOCMIWAIT */
770ffbbe25SOliver Neukum 	char prev_status, diff_status;        /* Used for TIOCMIWAIT */
780ffbbe25SOliver Neukum 	struct usb_serial_port *port;
79094c2e6dSMark Adamson 	__u16 interface;	/* FT2232C, FT2232H or FT4232H port interface
80094c2e6dSMark Adamson 				   (0 for FT232/245) */
810ffbbe25SOliver Neukum 
82464cbb24SAlan Cox 	speed_t force_baud;	/* if non-zero, force the baud rate to
83464cbb24SAlan Cox 				   this value */
84464cbb24SAlan Cox 	int force_rtscts;	/* if non-zero, force RTS-CTS to always
85464cbb24SAlan Cox 				   be enabled */
860ffbbe25SOliver Neukum 
87557aaa7fSAlan Cox 	unsigned int latency;		/* latency setting in use */
88895f28baSMark Adamson 	unsigned short max_packet_size;
899c67d28eSAlessio Igor Bogani 	struct mutex cfg_lock; /* Avoid mess by parallel calls of config ioctl() and change_speed() */
900ffbbe25SOliver Neukum };
910ffbbe25SOliver Neukum 
928f977e42SIan Abbott /* struct ftdi_sio_quirk is used by devices requiring special attention. */
938f977e42SIan Abbott struct ftdi_sio_quirk {
94fa91d43bSTony Lindgren 	int (*probe)(struct usb_serial *);
95464cbb24SAlan Cox 	/* Special settings for probed ports. */
96464cbb24SAlan Cox 	void (*port_probe)(struct ftdi_private *);
978f977e42SIan Abbott };
988f977e42SIan Abbott 
9920734345SHarald Welte static int   ftdi_jtag_probe(struct usb_serial *serial);
100546d7eecSKevin Vance static int   ftdi_mtxorb_hack_setup(struct usb_serial *serial);
101b760dac2SMartin Geleynse static int   ftdi_NDI_device_setup(struct usb_serial *serial);
1020ffbbe25SOliver Neukum static void  ftdi_USB_UIRT_setup(struct ftdi_private *priv);
1030ffbbe25SOliver Neukum static void  ftdi_HE_TIRA1_setup(struct ftdi_private *priv);
1048f977e42SIan Abbott 
10520734345SHarald Welte static struct ftdi_sio_quirk ftdi_jtag_quirk = {
10620734345SHarald Welte 	.probe	= ftdi_jtag_probe,
107fa91d43bSTony Lindgren };
108fa91d43bSTony Lindgren 
109546d7eecSKevin Vance static struct ftdi_sio_quirk ftdi_mtxorb_hack_quirk = {
110546d7eecSKevin Vance 	.probe  = ftdi_mtxorb_hack_setup,
111546d7eecSKevin Vance };
112546d7eecSKevin Vance 
113b760dac2SMartin Geleynse static struct ftdi_sio_quirk ftdi_NDI_device_quirk = {
114b760dac2SMartin Geleynse 	.probe	= ftdi_NDI_device_setup,
115b760dac2SMartin Geleynse };
116b760dac2SMartin Geleynse 
1178f977e42SIan Abbott static struct ftdi_sio_quirk ftdi_USB_UIRT_quirk = {
1180ffbbe25SOliver Neukum 	.port_probe = ftdi_USB_UIRT_setup,
1198f977e42SIan Abbott };
1208f977e42SIan Abbott 
1218f977e42SIan Abbott static struct ftdi_sio_quirk ftdi_HE_TIRA1_quirk = {
1220ffbbe25SOliver Neukum 	.port_probe = ftdi_HE_TIRA1_setup,
1231da177e4SLinus Torvalds };
1241da177e4SLinus Torvalds 
1251da177e4SLinus Torvalds /*
1261da177e4SLinus Torvalds  * The 8U232AM has the same API as the sio except for:
1271da177e4SLinus Torvalds  * - it can support MUCH higher baudrates; up to:
1281da177e4SLinus Torvalds  *   o 921600 for RS232 and 2000000 for RS422/485 at 48MHz
1291da177e4SLinus Torvalds  *   o 230400 at 12MHz
1301da177e4SLinus Torvalds  *   so .. 8U232AM's baudrate setting codes are different
1311da177e4SLinus Torvalds  * - it has a two byte status code.
1321da177e4SLinus Torvalds  * - it returns characters every 16ms (the FTDI does it every 40ms)
1331da177e4SLinus Torvalds  *
1341da177e4SLinus Torvalds  * the bcdDevice value is used to differentiate FT232BM and FT245BM from
1351da177e4SLinus Torvalds  * the earlier FT8U232AM and FT8U232BM.  For now, include all known VID/PID
1361da177e4SLinus Torvalds  * combinations in both tables.
1378f977e42SIan Abbott  * FIXME: perhaps bcdDevice can also identify 12MHz FT8U232AM devices,
1388f977e42SIan Abbott  * but I don't know if those ever went into mass production. [Ian Abbott]
1391da177e4SLinus Torvalds  */
1401da177e4SLinus Torvalds 
1411da177e4SLinus Torvalds 
1421da177e4SLinus Torvalds 
14365e1ec67SAndreas Mohr /*
14465e1ec67SAndreas Mohr  * Device ID not listed? Test via module params product/vendor or
14565e1ec67SAndreas Mohr  * /sys/bus/usb/ftdi_sio/new_id, then send patch/report!
14665e1ec67SAndreas Mohr  */
1471da177e4SLinus Torvalds static struct usb_device_id id_table_combined [] = {
1482011e924SJonathan Davies 	{ USB_DEVICE(FTDI_VID, FTDI_AMC232_PID) },
1492011e924SJonathan Davies 	{ USB_DEVICE(FTDI_VID, FTDI_CANUSB_PID) },
15001ba0856SAndrew Ewert 	{ USB_DEVICE(FTDI_VID, FTDI_CANDAPTER_PID) },
15165e1ec67SAndreas Mohr 	{ USB_DEVICE(FTDI_VID, FTDI_NXTCAM_PID) },
1526e1ab3edSPeter Mack 	{ USB_DEVICE(FTDI_VID, FTDI_SCS_DEVICE_0_PID) },
1536e1ab3edSPeter Mack 	{ USB_DEVICE(FTDI_VID, FTDI_SCS_DEVICE_1_PID) },
1546e1ab3edSPeter Mack 	{ USB_DEVICE(FTDI_VID, FTDI_SCS_DEVICE_2_PID) },
1556e1ab3edSPeter Mack 	{ USB_DEVICE(FTDI_VID, FTDI_SCS_DEVICE_3_PID) },
1566e1ab3edSPeter Mack 	{ USB_DEVICE(FTDI_VID, FTDI_SCS_DEVICE_4_PID) },
1576e1ab3edSPeter Mack 	{ USB_DEVICE(FTDI_VID, FTDI_SCS_DEVICE_5_PID) },
1586e1ab3edSPeter Mack 	{ USB_DEVICE(FTDI_VID, FTDI_SCS_DEVICE_6_PID) },
1596e1ab3edSPeter Mack 	{ USB_DEVICE(FTDI_VID, FTDI_SCS_DEVICE_7_PID) },
160b6180ef7Sdranch@trinnet.net 	{ USB_DEVICE(FTDI_VID, FTDI_USINT_CAT_PID) },
161b6180ef7Sdranch@trinnet.net 	{ USB_DEVICE(FTDI_VID, FTDI_USINT_WKEY_PID) },
162b6180ef7Sdranch@trinnet.net 	{ USB_DEVICE(FTDI_VID, FTDI_USINT_RS232_PID) },
16372a9f958SRazvan Gavril 	{ USB_DEVICE(FTDI_VID, FTDI_ACTZWAVE_PID) },
1641da177e4SLinus Torvalds 	{ USB_DEVICE(FTDI_VID, FTDI_IRTRANS_PID) },
16569737dfaSLuiz Fernando N. Capitulino 	{ USB_DEVICE(FTDI_VID, FTDI_IPLUS_PID) },
166d099321bSLuiz Fernando N. Capitulino 	{ USB_DEVICE(FTDI_VID, FTDI_IPLUS2_PID) },
167fad14a0dSFrank Sievertsen 	{ USB_DEVICE(FTDI_VID, FTDI_DMX4ALL) },
1681da177e4SLinus Torvalds 	{ USB_DEVICE(FTDI_VID, FTDI_SIO_PID) },
1691da177e4SLinus Torvalds 	{ USB_DEVICE(FTDI_VID, FTDI_8U232AM_PID) },
1701da177e4SLinus Torvalds 	{ USB_DEVICE(FTDI_VID, FTDI_8U232AM_ALT_PID) },
171d8b21606SGard Spreemann 	{ USB_DEVICE(FTDI_VID, FTDI_232RL_PID) },
1721da177e4SLinus Torvalds 	{ USB_DEVICE(FTDI_VID, FTDI_8U2232C_PID) },
173094c2e6dSMark Adamson 	{ USB_DEVICE(FTDI_VID, FTDI_4232H_PID) },
174c0f8d561SChristophe Mariac 	{ USB_DEVICE(FTDI_VID, FTDI_MICRO_CHAMELEON_PID) },
1751da177e4SLinus Torvalds 	{ USB_DEVICE(FTDI_VID, FTDI_RELAIS_PID) },
1762adb80e9SGuido Scholz 	{ USB_DEVICE(FTDI_VID, FTDI_OPENDCC_PID) },
177ec3815c3Smail@rainerkeller.de 	{ USB_DEVICE(FTDI_VID, FTDI_OPENDCC_SNIFFER_PID) },
178ec3815c3Smail@rainerkeller.de 	{ USB_DEVICE(FTDI_VID, FTDI_OPENDCC_THROTTLE_PID) },
179ec3815c3Smail@rainerkeller.de 	{ USB_DEVICE(FTDI_VID, FTDI_OPENDCC_GATEWAY_PID) },
18099c1e4f8SRainer Keller 	{ USB_DEVICE(FTDI_VID, FTDI_OPENDCC_GBM_PID) },
1811da177e4SLinus Torvalds 	{ USB_DEVICE(INTERBIOMETRICS_VID, INTERBIOMETRICS_IOBOARD_PID) },
1821da177e4SLinus Torvalds 	{ USB_DEVICE(INTERBIOMETRICS_VID, INTERBIOMETRICS_MINI_IOBOARD_PID) },
183f2ee6955SAlan Cox 	{ USB_DEVICE(FTDI_VID, FTDI_SPROG_II) },
184ea233f80SGalen Seitz 	{ USB_DEVICE(FTDI_VID, FTDI_LENZ_LIUSB_PID) },
1851da177e4SLinus Torvalds 	{ USB_DEVICE(FTDI_VID, FTDI_XF_632_PID) },
1861da177e4SLinus Torvalds 	{ USB_DEVICE(FTDI_VID, FTDI_XF_634_PID) },
1871da177e4SLinus Torvalds 	{ USB_DEVICE(FTDI_VID, FTDI_XF_547_PID) },
1881da177e4SLinus Torvalds 	{ USB_DEVICE(FTDI_VID, FTDI_XF_633_PID) },
1891da177e4SLinus Torvalds 	{ USB_DEVICE(FTDI_VID, FTDI_XF_631_PID) },
1901da177e4SLinus Torvalds 	{ USB_DEVICE(FTDI_VID, FTDI_XF_635_PID) },
1911da177e4SLinus Torvalds 	{ USB_DEVICE(FTDI_VID, FTDI_XF_640_PID) },
1921da177e4SLinus Torvalds 	{ USB_DEVICE(FTDI_VID, FTDI_XF_642_PID) },
1931da177e4SLinus Torvalds 	{ USB_DEVICE(FTDI_VID, FTDI_DSS20_PID) },
1941da177e4SLinus Torvalds 	{ USB_DEVICE(FTDI_NF_RIC_VID, FTDI_NF_RIC_PID) },
1951da177e4SLinus Torvalds 	{ USB_DEVICE(FTDI_VID, FTDI_VNHCPCUSB_D_PID) },
1968f977e42SIan Abbott 	{ USB_DEVICE(FTDI_VID, FTDI_MTXORB_0_PID) },
1978f977e42SIan Abbott 	{ USB_DEVICE(FTDI_VID, FTDI_MTXORB_1_PID) },
1988f977e42SIan Abbott 	{ USB_DEVICE(FTDI_VID, FTDI_MTXORB_2_PID) },
1998f977e42SIan Abbott 	{ USB_DEVICE(FTDI_VID, FTDI_MTXORB_3_PID) },
2008f977e42SIan Abbott 	{ USB_DEVICE(FTDI_VID, FTDI_MTXORB_4_PID) },
2018f977e42SIan Abbott 	{ USB_DEVICE(FTDI_VID, FTDI_MTXORB_5_PID) },
2028f977e42SIan Abbott 	{ USB_DEVICE(FTDI_VID, FTDI_MTXORB_6_PID) },
203b34efeeaSFolkert van Heusden 	{ USB_DEVICE(FTDI_VID, FTDI_R2000KU_TRUE_RNG) },
2046fdbad80SJacques Viviers 	{ USB_DEVICE(FTDI_VID, FTDI_VARDAAN_PID) },
205ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0100_PID) },
206ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0101_PID) },
207ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0102_PID) },
208ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0103_PID) },
209ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0104_PID) },
210ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0105_PID) },
211ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0106_PID) },
212ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0107_PID) },
213ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0108_PID) },
214ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0109_PID) },
215ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_010A_PID) },
216ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_010B_PID) },
217ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_010C_PID) },
218ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_010D_PID) },
219ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_010E_PID) },
220ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_010F_PID) },
221ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0110_PID) },
222ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0111_PID) },
223ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0112_PID) },
224ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0113_PID) },
225ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0114_PID) },
226ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0115_PID) },
227ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0116_PID) },
228ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0117_PID) },
229ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0118_PID) },
230ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0119_PID) },
231ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_011A_PID) },
232ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_011B_PID) },
233ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_011C_PID) },
234ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_011D_PID) },
235ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_011E_PID) },
236ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_011F_PID) },
237ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0120_PID) },
238ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0121_PID) },
239ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0122_PID) },
240ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0123_PID) },
241ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0124_PID) },
242ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0125_PID) },
243ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0126_PID) },
244ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0127_PID),
245546d7eecSKevin Vance 		.driver_info = (kernel_ulong_t)&ftdi_mtxorb_hack_quirk },
246ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0128_PID) },
247ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0129_PID) },
248ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_012A_PID) },
249ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_012B_PID) },
250ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_012C_PID),
251ebb3770cSRay Molenkamp 		.driver_info = (kernel_ulong_t)&ftdi_mtxorb_hack_quirk },
252ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_012D_PID) },
253ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_012E_PID) },
254ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_012F_PID) },
255ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0130_PID) },
256ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0131_PID) },
257ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0132_PID) },
258ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0133_PID) },
259ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0134_PID) },
260ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0135_PID) },
261ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0136_PID) },
262ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0137_PID) },
263ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0138_PID) },
264ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0139_PID) },
265ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_013A_PID) },
266ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_013B_PID) },
267ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_013C_PID) },
268ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_013D_PID) },
269ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_013E_PID) },
270ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_013F_PID) },
271ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0140_PID) },
272ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0141_PID) },
273ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0142_PID) },
274ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0143_PID) },
275ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0144_PID) },
276ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0145_PID) },
277ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0146_PID) },
278ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0147_PID) },
279ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0148_PID) },
280ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0149_PID) },
281ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_014A_PID) },
282ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_014B_PID) },
283ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_014C_PID) },
284ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_014D_PID) },
285ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_014E_PID) },
286ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_014F_PID) },
287ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0150_PID) },
288ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0151_PID) },
289ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0152_PID) },
290ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0153_PID),
291ebb3770cSRay Molenkamp 		.driver_info = (kernel_ulong_t)&ftdi_mtxorb_hack_quirk },
292ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0154_PID),
293ebb3770cSRay Molenkamp 		.driver_info = (kernel_ulong_t)&ftdi_mtxorb_hack_quirk },
294ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0155_PID),
295ebb3770cSRay Molenkamp 		.driver_info = (kernel_ulong_t)&ftdi_mtxorb_hack_quirk },
296ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0156_PID),
297ebb3770cSRay Molenkamp 		.driver_info = (kernel_ulong_t)&ftdi_mtxorb_hack_quirk },
298ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0157_PID),
299ebb3770cSRay Molenkamp 		.driver_info = (kernel_ulong_t)&ftdi_mtxorb_hack_quirk },
300ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0158_PID),
301ebb3770cSRay Molenkamp 		.driver_info = (kernel_ulong_t)&ftdi_mtxorb_hack_quirk },
302ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0159_PID) },
303ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_015A_PID) },
304ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_015B_PID) },
305ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_015C_PID) },
306ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_015D_PID) },
307ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_015E_PID) },
308ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_015F_PID) },
309ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0160_PID) },
310ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0161_PID) },
311ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0162_PID) },
312ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0163_PID) },
313ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0164_PID) },
314ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0165_PID) },
315ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0166_PID) },
316ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0167_PID) },
317ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0168_PID) },
318ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0169_PID) },
319ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_016A_PID) },
320ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_016B_PID) },
321ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_016C_PID) },
322ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_016D_PID) },
323ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_016E_PID) },
324ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_016F_PID) },
325ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0170_PID) },
326ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0171_PID) },
327ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0172_PID) },
328ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0173_PID) },
329ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0174_PID) },
330ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0175_PID) },
331ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0176_PID) },
332ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0177_PID) },
333ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0178_PID) },
334ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0179_PID) },
335ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_017A_PID) },
336ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_017B_PID) },
337ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_017C_PID) },
338ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_017D_PID) },
339ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_017E_PID) },
340ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_017F_PID) },
341ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0180_PID) },
342ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0181_PID) },
343ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0182_PID) },
344ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0183_PID) },
345ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0184_PID) },
346ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0185_PID) },
347ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0186_PID) },
348ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0187_PID) },
349ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0188_PID) },
350ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0189_PID) },
351ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_018A_PID) },
352ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_018B_PID) },
353ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_018C_PID) },
354ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_018D_PID) },
355ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_018E_PID) },
356ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_018F_PID) },
357ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0190_PID) },
358ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0191_PID) },
359ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0192_PID) },
360ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0193_PID) },
361ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0194_PID) },
362ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0195_PID) },
363ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0196_PID) },
364ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0197_PID) },
365ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0198_PID) },
366ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0199_PID) },
367ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_019A_PID) },
368ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_019B_PID) },
369ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_019C_PID) },
370ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_019D_PID) },
371ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_019E_PID) },
372ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_019F_PID) },
373ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01A0_PID) },
374ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01A1_PID) },
375ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01A2_PID) },
376ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01A3_PID) },
377ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01A4_PID) },
378ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01A5_PID) },
379ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01A6_PID) },
380ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01A7_PID) },
381ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01A8_PID) },
382ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01A9_PID) },
383ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01AA_PID) },
384ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01AB_PID) },
385ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01AC_PID) },
386ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01AD_PID) },
387ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01AE_PID) },
388ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01AF_PID) },
389ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01B0_PID) },
390ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01B1_PID) },
391ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01B2_PID) },
392ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01B3_PID) },
393ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01B4_PID) },
394ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01B5_PID) },
395ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01B6_PID) },
396ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01B7_PID) },
397ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01B8_PID) },
398ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01B9_PID) },
399ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01BA_PID) },
400ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01BB_PID) },
401ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01BC_PID) },
402ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01BD_PID) },
403ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01BE_PID) },
404ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01BF_PID) },
405ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01C0_PID) },
406ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01C1_PID) },
407ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01C2_PID) },
408ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01C3_PID) },
409ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01C4_PID) },
410ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01C5_PID) },
411ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01C6_PID) },
412ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01C7_PID) },
413ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01C8_PID) },
414ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01C9_PID) },
415ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01CA_PID) },
416ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01CB_PID) },
417ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01CC_PID) },
418ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01CD_PID) },
419ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01CE_PID) },
420ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01CF_PID) },
421ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01D0_PID) },
422ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01D1_PID) },
423ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01D2_PID) },
424ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01D3_PID) },
425ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01D4_PID) },
426ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01D5_PID) },
427ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01D6_PID) },
428ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01D7_PID) },
429ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01D8_PID) },
430ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01D9_PID) },
431ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01DA_PID) },
432ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01DB_PID) },
433ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01DC_PID) },
434ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01DD_PID) },
435ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01DE_PID) },
436ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01DF_PID) },
437ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01E0_PID) },
438ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01E1_PID) },
439ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01E2_PID) },
440ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01E3_PID) },
441ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01E4_PID) },
442ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01E5_PID) },
443ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01E6_PID) },
444ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01E7_PID) },
445ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01E8_PID) },
446ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01E9_PID) },
447ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01EA_PID) },
448ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01EB_PID) },
449ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01EC_PID) },
450ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01ED_PID) },
451ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01EE_PID) },
452ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01EF_PID) },
453ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01F0_PID) },
454ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01F1_PID) },
455ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01F2_PID) },
456ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01F3_PID) },
457ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01F4_PID) },
458ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01F5_PID) },
459ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01F6_PID) },
460ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01F7_PID) },
461ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01F8_PID) },
462ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01F9_PID) },
463ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01FA_PID) },
464ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01FB_PID) },
465ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01FC_PID) },
466ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01FD_PID) },
467ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01FE_PID) },
468ebb3770cSRay Molenkamp 	{ USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01FF_PID) },
4698f977e42SIan Abbott 	{ USB_DEVICE(FTDI_VID, FTDI_PERLE_ULTRAPORT_PID) },
4701da177e4SLinus Torvalds 	{ USB_DEVICE(FTDI_VID, FTDI_PIEGROUP_PID) },
471274a4bbcSDave Platt 	{ USB_DEVICE(FTDI_VID, FTDI_TNC_X_PID) },
472868e440dSJelle Foks 	{ USB_DEVICE(FTDI_VID, FTDI_USBX_707_PID) },
4731da177e4SLinus Torvalds 	{ USB_DEVICE(SEALEVEL_VID, SEALEVEL_2101_PID) },
4741da177e4SLinus Torvalds 	{ USB_DEVICE(SEALEVEL_VID, SEALEVEL_2102_PID) },
4751da177e4SLinus Torvalds 	{ USB_DEVICE(SEALEVEL_VID, SEALEVEL_2103_PID) },
4761da177e4SLinus Torvalds 	{ USB_DEVICE(SEALEVEL_VID, SEALEVEL_2104_PID) },
477a1484827SJustin Carlson 	{ USB_DEVICE(SEALEVEL_VID, SEALEVEL_2106_PID) },
4781da177e4SLinus Torvalds 	{ USB_DEVICE(SEALEVEL_VID, SEALEVEL_2201_1_PID) },
4791da177e4SLinus Torvalds 	{ USB_DEVICE(SEALEVEL_VID, SEALEVEL_2201_2_PID) },
4801da177e4SLinus Torvalds 	{ USB_DEVICE(SEALEVEL_VID, SEALEVEL_2202_1_PID) },
4811da177e4SLinus Torvalds 	{ USB_DEVICE(SEALEVEL_VID, SEALEVEL_2202_2_PID) },
4821da177e4SLinus Torvalds 	{ USB_DEVICE(SEALEVEL_VID, SEALEVEL_2203_1_PID) },
4831da177e4SLinus Torvalds 	{ USB_DEVICE(SEALEVEL_VID, SEALEVEL_2203_2_PID) },
4841da177e4SLinus Torvalds 	{ USB_DEVICE(SEALEVEL_VID, SEALEVEL_2401_1_PID) },
4851da177e4SLinus Torvalds 	{ USB_DEVICE(SEALEVEL_VID, SEALEVEL_2401_2_PID) },
4861da177e4SLinus Torvalds 	{ USB_DEVICE(SEALEVEL_VID, SEALEVEL_2401_3_PID) },
4871da177e4SLinus Torvalds 	{ USB_DEVICE(SEALEVEL_VID, SEALEVEL_2401_4_PID) },
4881da177e4SLinus Torvalds 	{ USB_DEVICE(SEALEVEL_VID, SEALEVEL_2402_1_PID) },
4891da177e4SLinus Torvalds 	{ USB_DEVICE(SEALEVEL_VID, SEALEVEL_2402_2_PID) },
4901da177e4SLinus Torvalds 	{ USB_DEVICE(SEALEVEL_VID, SEALEVEL_2402_3_PID) },
4911da177e4SLinus Torvalds 	{ USB_DEVICE(SEALEVEL_VID, SEALEVEL_2402_4_PID) },
4921da177e4SLinus Torvalds 	{ USB_DEVICE(SEALEVEL_VID, SEALEVEL_2403_1_PID) },
4931da177e4SLinus Torvalds 	{ USB_DEVICE(SEALEVEL_VID, SEALEVEL_2403_2_PID) },
4941da177e4SLinus Torvalds 	{ USB_DEVICE(SEALEVEL_VID, SEALEVEL_2403_3_PID) },
4951da177e4SLinus Torvalds 	{ USB_DEVICE(SEALEVEL_VID, SEALEVEL_2403_4_PID) },
4961da177e4SLinus Torvalds 	{ USB_DEVICE(SEALEVEL_VID, SEALEVEL_2801_1_PID) },
4971da177e4SLinus Torvalds 	{ USB_DEVICE(SEALEVEL_VID, SEALEVEL_2801_2_PID) },
4981da177e4SLinus Torvalds 	{ USB_DEVICE(SEALEVEL_VID, SEALEVEL_2801_3_PID) },
4991da177e4SLinus Torvalds 	{ USB_DEVICE(SEALEVEL_VID, SEALEVEL_2801_4_PID) },
5001da177e4SLinus Torvalds 	{ USB_DEVICE(SEALEVEL_VID, SEALEVEL_2801_5_PID) },
5011da177e4SLinus Torvalds 	{ USB_DEVICE(SEALEVEL_VID, SEALEVEL_2801_6_PID) },
5021da177e4SLinus Torvalds 	{ USB_DEVICE(SEALEVEL_VID, SEALEVEL_2801_7_PID) },
5031da177e4SLinus Torvalds 	{ USB_DEVICE(SEALEVEL_VID, SEALEVEL_2801_8_PID) },
5041da177e4SLinus Torvalds 	{ USB_DEVICE(SEALEVEL_VID, SEALEVEL_2802_1_PID) },
5051da177e4SLinus Torvalds 	{ USB_DEVICE(SEALEVEL_VID, SEALEVEL_2802_2_PID) },
5061da177e4SLinus Torvalds 	{ USB_DEVICE(SEALEVEL_VID, SEALEVEL_2802_3_PID) },
5071da177e4SLinus Torvalds 	{ USB_DEVICE(SEALEVEL_VID, SEALEVEL_2802_4_PID) },
5081da177e4SLinus Torvalds 	{ USB_DEVICE(SEALEVEL_VID, SEALEVEL_2802_5_PID) },
5091da177e4SLinus Torvalds 	{ USB_DEVICE(SEALEVEL_VID, SEALEVEL_2802_6_PID) },
5101da177e4SLinus Torvalds 	{ USB_DEVICE(SEALEVEL_VID, SEALEVEL_2802_7_PID) },
5111da177e4SLinus Torvalds 	{ USB_DEVICE(SEALEVEL_VID, SEALEVEL_2802_8_PID) },
5121da177e4SLinus Torvalds 	{ USB_DEVICE(SEALEVEL_VID, SEALEVEL_2803_1_PID) },
5131da177e4SLinus Torvalds 	{ USB_DEVICE(SEALEVEL_VID, SEALEVEL_2803_2_PID) },
5141da177e4SLinus Torvalds 	{ USB_DEVICE(SEALEVEL_VID, SEALEVEL_2803_3_PID) },
5151da177e4SLinus Torvalds 	{ USB_DEVICE(SEALEVEL_VID, SEALEVEL_2803_4_PID) },
5161da177e4SLinus Torvalds 	{ USB_DEVICE(SEALEVEL_VID, SEALEVEL_2803_5_PID) },
5171da177e4SLinus Torvalds 	{ USB_DEVICE(SEALEVEL_VID, SEALEVEL_2803_6_PID) },
5181da177e4SLinus Torvalds 	{ USB_DEVICE(SEALEVEL_VID, SEALEVEL_2803_7_PID) },
5191da177e4SLinus Torvalds 	{ USB_DEVICE(SEALEVEL_VID, SEALEVEL_2803_8_PID) },
5201da177e4SLinus Torvalds 	{ USB_DEVICE(IDTECH_VID, IDTECH_IDT1221U_PID) },
5211da177e4SLinus Torvalds 	{ USB_DEVICE(OCT_VID, OCT_US101_PID) },
5228f977e42SIan Abbott 	{ USB_DEVICE(FTDI_VID, FTDI_HE_TIRA1_PID),
5238f977e42SIan Abbott 		.driver_info = (kernel_ulong_t)&ftdi_HE_TIRA1_quirk },
5248f977e42SIan Abbott 	{ USB_DEVICE(FTDI_VID, FTDI_USB_UIRT_PID),
5258f977e42SIan Abbott 		.driver_info = (kernel_ulong_t)&ftdi_USB_UIRT_quirk },
5261da177e4SLinus Torvalds 	{ USB_DEVICE(FTDI_VID, PROTEGO_SPECIAL_1) },
5271da177e4SLinus Torvalds 	{ USB_DEVICE(FTDI_VID, PROTEGO_R2X0) },
5281da177e4SLinus Torvalds 	{ USB_DEVICE(FTDI_VID, PROTEGO_SPECIAL_3) },
5291da177e4SLinus Torvalds 	{ USB_DEVICE(FTDI_VID, PROTEGO_SPECIAL_4) },
5308f977e42SIan Abbott 	{ USB_DEVICE(FTDI_VID, FTDI_GUDEADS_E808_PID) },
5318f977e42SIan Abbott 	{ USB_DEVICE(FTDI_VID, FTDI_GUDEADS_E809_PID) },
5328f977e42SIan Abbott 	{ USB_DEVICE(FTDI_VID, FTDI_GUDEADS_E80A_PID) },
5338f977e42SIan Abbott 	{ USB_DEVICE(FTDI_VID, FTDI_GUDEADS_E80B_PID) },
5348f977e42SIan Abbott 	{ USB_DEVICE(FTDI_VID, FTDI_GUDEADS_E80C_PID) },
5358f977e42SIan Abbott 	{ USB_DEVICE(FTDI_VID, FTDI_GUDEADS_E80D_PID) },
5368f977e42SIan Abbott 	{ USB_DEVICE(FTDI_VID, FTDI_GUDEADS_E80E_PID) },
5378f977e42SIan Abbott 	{ USB_DEVICE(FTDI_VID, FTDI_GUDEADS_E80F_PID) },
5388f977e42SIan Abbott 	{ USB_DEVICE(FTDI_VID, FTDI_GUDEADS_E888_PID) },
5398f977e42SIan Abbott 	{ USB_DEVICE(FTDI_VID, FTDI_GUDEADS_E889_PID) },
5408f977e42SIan Abbott 	{ USB_DEVICE(FTDI_VID, FTDI_GUDEADS_E88A_PID) },
5418f977e42SIan Abbott 	{ USB_DEVICE(FTDI_VID, FTDI_GUDEADS_E88B_PID) },
5428f977e42SIan Abbott 	{ USB_DEVICE(FTDI_VID, FTDI_GUDEADS_E88C_PID) },
5438f977e42SIan Abbott 	{ USB_DEVICE(FTDI_VID, FTDI_GUDEADS_E88D_PID) },
5448f977e42SIan Abbott 	{ USB_DEVICE(FTDI_VID, FTDI_GUDEADS_E88E_PID) },
5458f977e42SIan Abbott 	{ USB_DEVICE(FTDI_VID, FTDI_GUDEADS_E88F_PID) },
5461da177e4SLinus Torvalds 	{ USB_DEVICE(FTDI_VID, FTDI_ELV_UO100_PID) },
54747900743SIan Abbott 	{ USB_DEVICE(FTDI_VID, FTDI_ELV_UM100_PID) },
548e6ac4a40SIan Abbott 	{ USB_DEVICE(FTDI_VID, FTDI_ELV_UR100_PID) },
549e6ac4a40SIan Abbott 	{ USB_DEVICE(FTDI_VID, FTDI_ELV_ALC8500_PID) },
550207c47e1SThomas Riewe 	{ USB_DEVICE(FTDI_VID, FTDI_PYRAMID_PID) },
551bde62185SMartin Hagelin 	{ USB_DEVICE(FTDI_VID, FTDI_ELV_FHZ1000PC_PID) },
5524eaf60e0SThomas Schleusener 	{ USB_DEVICE(FTDI_VID, FTDI_IBS_US485_PID) },
5534eaf60e0SThomas Schleusener 	{ USB_DEVICE(FTDI_VID, FTDI_IBS_PICPRO_PID) },
5544eaf60e0SThomas Schleusener 	{ USB_DEVICE(FTDI_VID, FTDI_IBS_PCMCIA_PID) },
5554eaf60e0SThomas Schleusener 	{ USB_DEVICE(FTDI_VID, FTDI_IBS_PK1_PID) },
5564eaf60e0SThomas Schleusener 	{ USB_DEVICE(FTDI_VID, FTDI_IBS_RS232MON_PID) },
5574eaf60e0SThomas Schleusener 	{ USB_DEVICE(FTDI_VID, FTDI_IBS_APP70_PID) },
5584eaf60e0SThomas Schleusener 	{ USB_DEVICE(FTDI_VID, FTDI_IBS_PEDO_PID) },
5594eaf60e0SThomas Schleusener 	{ USB_DEVICE(FTDI_VID, FTDI_IBS_PROD_PID) },
560e6ac4a40SIan Abbott 	/*
56165e1ec67SAndreas Mohr 	 * ELV devices:
562e6ac4a40SIan Abbott 	 */
56365e1ec67SAndreas Mohr 	{ USB_DEVICE(FTDI_VID, FTDI_ELV_USR_PID) },
56465e1ec67SAndreas Mohr 	{ USB_DEVICE(FTDI_VID, FTDI_ELV_MSM1_PID) },
56565e1ec67SAndreas Mohr 	{ USB_DEVICE(FTDI_VID, FTDI_ELV_KL100_PID) },
56665e1ec67SAndreas Mohr 	{ USB_DEVICE(FTDI_VID, FTDI_ELV_WS550_PID) },
56765e1ec67SAndreas Mohr 	{ USB_DEVICE(FTDI_VID, FTDI_ELV_EC3000_PID) },
56865e1ec67SAndreas Mohr 	{ USB_DEVICE(FTDI_VID, FTDI_ELV_WS888_PID) },
56965e1ec67SAndreas Mohr 	{ USB_DEVICE(FTDI_VID, FTDI_ELV_TWS550_PID) },
57065e1ec67SAndreas Mohr 	{ USB_DEVICE(FTDI_VID, FTDI_ELV_FEM_PID) },
57142f8aa94SPeter Stark 	{ USB_DEVICE(FTDI_VID, FTDI_ELV_CLI7000_PID) },
57242f8aa94SPeter Stark 	{ USB_DEVICE(FTDI_VID, FTDI_ELV_PPS7330_PID) },
57342f8aa94SPeter Stark 	{ USB_DEVICE(FTDI_VID, FTDI_ELV_TFM100_PID) },
57442f8aa94SPeter Stark 	{ USB_DEVICE(FTDI_VID, FTDI_ELV_UDF77_PID) },
57542f8aa94SPeter Stark 	{ USB_DEVICE(FTDI_VID, FTDI_ELV_UIO88_PID) },
57642f8aa94SPeter Stark 	{ USB_DEVICE(FTDI_VID, FTDI_ELV_UAD8_PID) },
57742f8aa94SPeter Stark 	{ USB_DEVICE(FTDI_VID, FTDI_ELV_UDA7_PID) },
57842f8aa94SPeter Stark 	{ USB_DEVICE(FTDI_VID, FTDI_ELV_USI2_PID) },
57942f8aa94SPeter Stark 	{ USB_DEVICE(FTDI_VID, FTDI_ELV_T1100_PID) },
58042f8aa94SPeter Stark 	{ USB_DEVICE(FTDI_VID, FTDI_ELV_PCD200_PID) },
58142f8aa94SPeter Stark 	{ USB_DEVICE(FTDI_VID, FTDI_ELV_ULA200_PID) },
58242f8aa94SPeter Stark 	{ USB_DEVICE(FTDI_VID, FTDI_ELV_CSI8_PID) },
58342f8aa94SPeter Stark 	{ USB_DEVICE(FTDI_VID, FTDI_ELV_EM1000DL_PID) },
58442f8aa94SPeter Stark 	{ USB_DEVICE(FTDI_VID, FTDI_ELV_PCK100_PID) },
58542f8aa94SPeter Stark 	{ USB_DEVICE(FTDI_VID, FTDI_ELV_RFP500_PID) },
58642f8aa94SPeter Stark 	{ USB_DEVICE(FTDI_VID, FTDI_ELV_FS20SIG_PID) },
58765e1ec67SAndreas Mohr 	{ USB_DEVICE(FTDI_VID, FTDI_ELV_UTP8_PID) },
58842f8aa94SPeter Stark 	{ USB_DEVICE(FTDI_VID, FTDI_ELV_WS300PC_PID) },
58965e1ec67SAndreas Mohr 	{ USB_DEVICE(FTDI_VID, FTDI_ELV_WS444PC_PID) },
59042f8aa94SPeter Stark 	{ USB_DEVICE(FTDI_VID, FTDI_ELV_FHZ1300PC_PID) },
5914ae897dfSSven Andersen 	{ USB_DEVICE(FTDI_VID, FTDI_ELV_EM1010PC_PID) },
59242f8aa94SPeter Stark 	{ USB_DEVICE(FTDI_VID, FTDI_ELV_WS500_PID) },
593b5894a50SAndré Schenk 	{ USB_DEVICE(FTDI_VID, FTDI_ELV_HS485_PID) },
59465e1ec67SAndreas Mohr 	{ USB_DEVICE(FTDI_VID, FTDI_ELV_UMS100_PID) },
59565e1ec67SAndreas Mohr 	{ USB_DEVICE(FTDI_VID, FTDI_ELV_TFD128_PID) },
59665e1ec67SAndreas Mohr 	{ USB_DEVICE(FTDI_VID, FTDI_ELV_FM3RX_PID) },
59765e1ec67SAndreas Mohr 	{ USB_DEVICE(FTDI_VID, FTDI_ELV_WS777_PID) },
5988f977e42SIan Abbott 	{ USB_DEVICE(FTDI_VID, LINX_SDMUSBQSS_PID) },
5998f977e42SIan Abbott 	{ USB_DEVICE(FTDI_VID, LINX_MASTERDEVEL2_PID) },
6008f977e42SIan Abbott 	{ USB_DEVICE(FTDI_VID, LINX_FUTURE_0_PID) },
6018f977e42SIan Abbott 	{ USB_DEVICE(FTDI_VID, LINX_FUTURE_1_PID) },
6028f977e42SIan Abbott 	{ USB_DEVICE(FTDI_VID, LINX_FUTURE_2_PID) },
6031da177e4SLinus Torvalds 	{ USB_DEVICE(FTDI_VID, FTDI_CCSICDU20_0_PID) },
6041da177e4SLinus Torvalds 	{ USB_DEVICE(FTDI_VID, FTDI_CCSICDU40_1_PID) },
605ec434e9bSJan Capek 	{ USB_DEVICE(FTDI_VID, FTDI_CCSMACHX_2_PID) },
6069d37ff64SJan Capek 	{ USB_DEVICE(FTDI_VID, FTDI_CCSLOAD_N_GO_3_PID) },
6079d37ff64SJan Capek 	{ USB_DEVICE(FTDI_VID, FTDI_CCSICDU64_4_PID) },
6089d37ff64SJan Capek 	{ USB_DEVICE(FTDI_VID, FTDI_CCSPRIME8_5_PID) },
6091da177e4SLinus Torvalds 	{ USB_DEVICE(FTDI_VID, INSIDE_ACCESSO) },
6101da177e4SLinus Torvalds 	{ USB_DEVICE(INTREPID_VID, INTREPID_VALUECAN_PID) },
6111da177e4SLinus Torvalds 	{ USB_DEVICE(INTREPID_VID, INTREPID_NEOVI_PID) },
6121da177e4SLinus Torvalds 	{ USB_DEVICE(FALCOM_VID, FALCOM_TWIST_PID) },
613e6ac4a40SIan Abbott 	{ USB_DEVICE(FALCOM_VID, FALCOM_SAMBA_PID) },
6141da177e4SLinus Torvalds 	{ USB_DEVICE(FTDI_VID, FTDI_SUUNTO_SPORTS_PID) },
615c3d36c45SVladimir Vukicevic 	{ USB_DEVICE(FTDI_VID, FTDI_OCEANIC_PID) },
616ef31fec0SMichael Olberg 	{ USB_DEVICE(TTI_VID, TTI_QL355P_PID) },
6176f92872cSIan Abbott 	{ USB_DEVICE(FTDI_VID, FTDI_RM_CANVIEW_PID) },
61846b72d78SDaniel Sangorrin 	{ USB_DEVICE(CONTEC_VID, CONTEC_COM1USBH_PID) },
6191da177e4SLinus Torvalds 	{ USB_DEVICE(BANDB_VID, BANDB_USOTL4_PID) },
6201da177e4SLinus Torvalds 	{ USB_DEVICE(BANDB_VID, BANDB_USTL4_PID) },
6211da177e4SLinus Torvalds 	{ USB_DEVICE(BANDB_VID, BANDB_USO9ML2_PID) },
622a8cbd90aSCliff Brake 	{ USB_DEVICE(BANDB_VID, BANDB_USOPTL4_PID) },
623a8cbd90aSCliff Brake 	{ USB_DEVICE(BANDB_VID, BANDB_USPTL4_PID) },
624a8cbd90aSCliff Brake 	{ USB_DEVICE(BANDB_VID, BANDB_USO9ML2DR_2_PID) },
625a8cbd90aSCliff Brake 	{ USB_DEVICE(BANDB_VID, BANDB_USO9ML2DR_PID) },
626a8cbd90aSCliff Brake 	{ USB_DEVICE(BANDB_VID, BANDB_USOPTL4DR2_PID) },
627a8cbd90aSCliff Brake 	{ USB_DEVICE(BANDB_VID, BANDB_USOPTL4DR_PID) },
628a8cbd90aSCliff Brake 	{ USB_DEVICE(BANDB_VID, BANDB_485USB9F_2W_PID) },
629a8cbd90aSCliff Brake 	{ USB_DEVICE(BANDB_VID, BANDB_485USB9F_4W_PID) },
630a8cbd90aSCliff Brake 	{ USB_DEVICE(BANDB_VID, BANDB_232USB9M_PID) },
631a8cbd90aSCliff Brake 	{ USB_DEVICE(BANDB_VID, BANDB_485USBTB_2W_PID) },
632a8cbd90aSCliff Brake 	{ USB_DEVICE(BANDB_VID, BANDB_485USBTB_4W_PID) },
633a8cbd90aSCliff Brake 	{ USB_DEVICE(BANDB_VID, BANDB_TTL5USB9M_PID) },
634a8cbd90aSCliff Brake 	{ USB_DEVICE(BANDB_VID, BANDB_TTL3USB9M_PID) },
635a8cbd90aSCliff Brake 	{ USB_DEVICE(BANDB_VID, BANDB_ZZ_PROG1_USB_PID) },
6361da177e4SLinus Torvalds 	{ USB_DEVICE(FTDI_VID, EVER_ECO_PRO_CDS) },
6376f92872cSIan Abbott 	{ USB_DEVICE(FTDI_VID, FTDI_4N_GALAXY_DE_1_PID) },
6386f92872cSIan Abbott 	{ USB_DEVICE(FTDI_VID, FTDI_4N_GALAXY_DE_2_PID) },
639e6ac4a40SIan Abbott 	{ USB_DEVICE(FTDI_VID, XSENS_CONVERTER_0_PID) },
640e6ac4a40SIan Abbott 	{ USB_DEVICE(FTDI_VID, XSENS_CONVERTER_1_PID) },
641e6ac4a40SIan Abbott 	{ USB_DEVICE(FTDI_VID, XSENS_CONVERTER_2_PID) },
642e6ac4a40SIan Abbott 	{ USB_DEVICE(FTDI_VID, XSENS_CONVERTER_3_PID) },
643e6ac4a40SIan Abbott 	{ USB_DEVICE(FTDI_VID, XSENS_CONVERTER_4_PID) },
644e6ac4a40SIan Abbott 	{ USB_DEVICE(FTDI_VID, XSENS_CONVERTER_5_PID) },
645e6ac4a40SIan Abbott 	{ USB_DEVICE(FTDI_VID, XSENS_CONVERTER_6_PID) },
646e6ac4a40SIan Abbott 	{ USB_DEVICE(FTDI_VID, XSENS_CONVERTER_7_PID) },
6476f92872cSIan Abbott 	{ USB_DEVICE(MOBILITY_VID, MOBILITY_USB_SERIAL_PID) },
6488f977e42SIan Abbott 	{ USB_DEVICE(FTDI_VID, FTDI_ACTIVE_ROBOTS_PID) },
64934d1a8aaSIan Abbott 	{ USB_DEVICE(FTDI_VID, FTDI_MHAM_KW_PID) },
65034d1a8aaSIan Abbott 	{ USB_DEVICE(FTDI_VID, FTDI_MHAM_YS_PID) },
6519b1513d9SIan Abbott 	{ USB_DEVICE(FTDI_VID, FTDI_MHAM_Y6_PID) },
6529b1513d9SIan Abbott 	{ USB_DEVICE(FTDI_VID, FTDI_MHAM_Y8_PID) },
65334d1a8aaSIan Abbott 	{ USB_DEVICE(FTDI_VID, FTDI_MHAM_IC_PID) },
65434d1a8aaSIan Abbott 	{ USB_DEVICE(FTDI_VID, FTDI_MHAM_DB9_PID) },
65534d1a8aaSIan Abbott 	{ USB_DEVICE(FTDI_VID, FTDI_MHAM_RS232_PID) },
65634d1a8aaSIan Abbott 	{ USB_DEVICE(FTDI_VID, FTDI_MHAM_Y9_PID) },
657740a4282SIan Abbott 	{ USB_DEVICE(FTDI_VID, FTDI_TERATRONIK_VCP_PID) },
658740a4282SIan Abbott 	{ USB_DEVICE(FTDI_VID, FTDI_TERATRONIK_D2XX_PID) },
6599b1513d9SIan Abbott 	{ USB_DEVICE(EVOLUTION_VID, EVOLUTION_ER1_PID) },
660c1f8ea7dSSøren Hauberg 	{ USB_DEVICE(EVOLUTION_VID, EVO_HYBRID_PID) },
661c1f8ea7dSSøren Hauberg 	{ USB_DEVICE(EVOLUTION_VID, EVO_RCM4_PID) },
662c9c7746dSRui Santos 	{ USB_DEVICE(FTDI_VID, FTDI_ARTEMIS_PID) },
663c9c7746dSRui Santos 	{ USB_DEVICE(FTDI_VID, FTDI_ATIK_ATK16_PID) },
66409c280a2SRui Santos 	{ USB_DEVICE(FTDI_VID, FTDI_ATIK_ATK16C_PID) },
665c9c7746dSRui Santos 	{ USB_DEVICE(FTDI_VID, FTDI_ATIK_ATK16HR_PID) },
66609c280a2SRui Santos 	{ USB_DEVICE(FTDI_VID, FTDI_ATIK_ATK16HRC_PID) },
66734910434SFranco Lanza 	{ USB_DEVICE(FTDI_VID, FTDI_ATIK_ATK16IC_PID) },
668b4723ae3SIan Abbott 	{ USB_DEVICE(KOBIL_VID, KOBIL_CONV_B1_PID) },
669b4723ae3SIan Abbott 	{ USB_DEVICE(KOBIL_VID, KOBIL_CONV_KAAN_PID) },
670effac8beSPavel Fedin 	{ USB_DEVICE(POSIFLEX_VID, POSIFLEX_PP7000_PID) },
671641adaaeSLouis Nyffenegger 	{ USB_DEVICE(FTDI_VID, FTDI_TTUSB_PID) },
6727e1c0b86SIan Abbott 	{ USB_DEVICE(FTDI_VID, FTDI_ECLO_COM_1WIRE_PID) },
673a94b52acSIan Abbott 	{ USB_DEVICE(FTDI_VID, FTDI_WESTREX_MODEL_777_PID) },
674a94b52acSIan Abbott 	{ USB_DEVICE(FTDI_VID, FTDI_WESTREX_MODEL_8900F_PID) },
675ce40d290SWouter Paesen 	{ USB_DEVICE(FTDI_VID, FTDI_PCDJ_DAC2_PID) },
676cdd3b156SNathan Bronson 	{ USB_DEVICE(FTDI_VID, FTDI_RRCIRKITS_LOCOBUFFER_PID) },
6777e0258fdSIan Abbott 	{ USB_DEVICE(FTDI_VID, FTDI_ASK_RDR400_PID) },
678bf58fbd5SA. Maitland Bottoms 	{ USB_DEVICE(ICOM_ID1_VID, ICOM_ID1_PID) },
67920a0f47eSIan Abbott 	{ USB_DEVICE(FTDI_VID, FTDI_ACG_HFDUAL_PID) },
680eb79b4fdSIan Abbott 	{ USB_DEVICE(FTDI_VID, FTDI_YEI_SERVOCENTER31_PID) },
68148437486SD. Peter Siddons 	{ USB_DEVICE(FTDI_VID, FTDI_THORLABS_PID) },
682e1979fefSColin Leroy 	{ USB_DEVICE(TESTO_VID, TESTO_USB_INTERFACE_PID) },
683eaede2cbSRalf Schlatterbeck 	{ USB_DEVICE(FTDI_VID, FTDI_GAMMA_SCOUT_PID) },
6849978f9e1SIan Abbott 	{ USB_DEVICE(FTDI_VID, FTDI_TACTRIX_OPENPORT_13M_PID) },
6859978f9e1SIan Abbott 	{ USB_DEVICE(FTDI_VID, FTDI_TACTRIX_OPENPORT_13S_PID) },
6869978f9e1SIan Abbott 	{ USB_DEVICE(FTDI_VID, FTDI_TACTRIX_OPENPORT_13U_PID) },
68740c36092SKjell Myksvoll 	{ USB_DEVICE(ELEKTOR_VID, ELEKTOR_FT323R_PID) },
688b760dac2SMartin Geleynse 	{ USB_DEVICE(FTDI_VID, FTDI_NDI_HUC_PID),
689b760dac2SMartin Geleynse 		.driver_info = (kernel_ulong_t)&ftdi_NDI_device_quirk },
690b760dac2SMartin Geleynse 	{ USB_DEVICE(FTDI_VID, FTDI_NDI_SPECTRA_SCU_PID),
691b760dac2SMartin Geleynse 		.driver_info = (kernel_ulong_t)&ftdi_NDI_device_quirk },
692b760dac2SMartin Geleynse 	{ USB_DEVICE(FTDI_VID, FTDI_NDI_FUTURE_2_PID),
693b760dac2SMartin Geleynse 		.driver_info = (kernel_ulong_t)&ftdi_NDI_device_quirk },
694b760dac2SMartin Geleynse 	{ USB_DEVICE(FTDI_VID, FTDI_NDI_FUTURE_3_PID),
695b760dac2SMartin Geleynse 		.driver_info = (kernel_ulong_t)&ftdi_NDI_device_quirk },
696b760dac2SMartin Geleynse 	{ USB_DEVICE(FTDI_VID, FTDI_NDI_AURORA_SCU_PID),
697b760dac2SMartin Geleynse 		.driver_info = (kernel_ulong_t)&ftdi_NDI_device_quirk },
698822c7ef4SMicke Prag 	{ USB_DEVICE(TELLDUS_VID, TELLDUS_TELLSTICK_PID) },
699fcc6cb78SCorey Minyard 	{ USB_DEVICE(RTSYSTEMS_VID, RTSYSTEMS_SERIAL_VX7_PID) },
70028942bb6SMichael Stuermer 	{ USB_DEVICE(RTSYSTEMS_VID, RTSYSTEMS_CT29B_PID) },
701762e92faSNeil \"Superna\" ARMSTRONG 	{ USB_DEVICE(FTDI_VID, FTDI_MAXSTREAM_PID) },
702a5f62399SLex Ross 	{ USB_DEVICE(FTDI_VID, FTDI_PHI_FISCO_PID) },
703d7fde2d6SPierre Castella 	{ USB_DEVICE(TML_VID, TML_USB_SERIAL_PID) },
7044bb0ef19SEd Beroset 	{ USB_DEVICE(FTDI_VID, FTDI_ELSTER_UNICOM_PID) },
70511171d1bSMirko Bordignon 	{ USB_DEVICE(FTDI_VID, FTDI_PROPOX_JTAGCABLEII_PID) },
706fa91d43bSTony Lindgren 	{ USB_DEVICE(OLIMEX_VID, OLIMEX_ARM_USB_OCD_PID),
70720734345SHarald Welte 		.driver_info = (kernel_ulong_t)&ftdi_jtag_quirk },
70820734345SHarald Welte 	{ USB_DEVICE(FIC_VID, FIC_NEO1973_DEBUG_PID),
70920734345SHarald Welte 		.driver_info = (kernel_ulong_t)&ftdi_jtag_quirk },
71020734345SHarald Welte 	{ USB_DEVICE(FTDI_VID, FTDI_OOCDLINK_PID),
71120734345SHarald Welte 		.driver_info = (kernel_ulong_t)&ftdi_jtag_quirk },
712a00c3cadSFrederik Kriewitz 	{ USB_DEVICE(FTDI_VID, LMI_LM3S_DEVEL_BOARD_PID),
713a00c3cadSFrederik Kriewitz 		.driver_info = (kernel_ulong_t)&ftdi_jtag_quirk },
714a00c3cadSFrederik Kriewitz 	{ USB_DEVICE(FTDI_VID, LMI_LM3S_EVAL_BOARD_PID),
715a00c3cadSFrederik Kriewitz 		.driver_info = (kernel_ulong_t)&ftdi_jtag_quirk },
71614511412SKrzysztof Halasa 	{ USB_DEVICE(FTDI_VID, FTDI_TURTELIZER_PID),
71714511412SKrzysztof Halasa 		.driver_info = (kernel_ulong_t)&ftdi_jtag_quirk },
71826ab7053SAtsushi Nemoto 	{ USB_DEVICE(RATOC_VENDOR_ID, RATOC_PRODUCT_ID_USB60F) },
7192542335cSJon K Hellan 	{ USB_DEVICE(FTDI_VID, FTDI_REU_TINY_PID) },
72059c6ccd9SDaniel Suchy 
72159c6ccd9SDaniel Suchy 	/* Papouch devices based on FTDI chip */
72259c6ccd9SDaniel Suchy 	{ USB_DEVICE(PAPOUCH_VID, PAPOUCH_SB485_PID) },
72359c6ccd9SDaniel Suchy 	{ USB_DEVICE(PAPOUCH_VID, PAPOUCH_AP485_PID) },
72459c6ccd9SDaniel Suchy 	{ USB_DEVICE(PAPOUCH_VID, PAPOUCH_SB422_PID) },
72559c6ccd9SDaniel Suchy 	{ USB_DEVICE(PAPOUCH_VID, PAPOUCH_SB485_2_PID) },
72659c6ccd9SDaniel Suchy 	{ USB_DEVICE(PAPOUCH_VID, PAPOUCH_AP485_2_PID) },
72759c6ccd9SDaniel Suchy 	{ USB_DEVICE(PAPOUCH_VID, PAPOUCH_SB422_2_PID) },
72859c6ccd9SDaniel Suchy 	{ USB_DEVICE(PAPOUCH_VID, PAPOUCH_SB485S_PID) },
72959c6ccd9SDaniel Suchy 	{ USB_DEVICE(PAPOUCH_VID, PAPOUCH_SB485C_PID) },
73059c6ccd9SDaniel Suchy 	{ USB_DEVICE(PAPOUCH_VID, PAPOUCH_LEC_PID) },
73159c6ccd9SDaniel Suchy 	{ USB_DEVICE(PAPOUCH_VID, PAPOUCH_SB232_PID) },
73259c6ccd9SDaniel Suchy 	{ USB_DEVICE(PAPOUCH_VID, PAPOUCH_TMU_PID) },
73359c6ccd9SDaniel Suchy 	{ USB_DEVICE(PAPOUCH_VID, PAPOUCH_IRAMP_PID) },
73459c6ccd9SDaniel Suchy 	{ USB_DEVICE(PAPOUCH_VID, PAPOUCH_DRAK5_PID) },
73559c6ccd9SDaniel Suchy 	{ USB_DEVICE(PAPOUCH_VID, PAPOUCH_QUIDO8x8_PID) },
736a18f80b4SJaroslav Kysela 	{ USB_DEVICE(PAPOUCH_VID, PAPOUCH_QUIDO4x4_PID) },
73759c6ccd9SDaniel Suchy 	{ USB_DEVICE(PAPOUCH_VID, PAPOUCH_QUIDO2x2_PID) },
73859c6ccd9SDaniel Suchy 	{ USB_DEVICE(PAPOUCH_VID, PAPOUCH_QUIDO10x1_PID) },
73959c6ccd9SDaniel Suchy 	{ USB_DEVICE(PAPOUCH_VID, PAPOUCH_QUIDO30x3_PID) },
74059c6ccd9SDaniel Suchy 	{ USB_DEVICE(PAPOUCH_VID, PAPOUCH_QUIDO60x3_PID) },
74159c6ccd9SDaniel Suchy 	{ USB_DEVICE(PAPOUCH_VID, PAPOUCH_QUIDO2x16_PID) },
74259c6ccd9SDaniel Suchy 	{ USB_DEVICE(PAPOUCH_VID, PAPOUCH_QUIDO3x32_PID) },
74359c6ccd9SDaniel Suchy 	{ USB_DEVICE(PAPOUCH_VID, PAPOUCH_DRAK6_PID) },
74459c6ccd9SDaniel Suchy 	{ USB_DEVICE(PAPOUCH_VID, PAPOUCH_UPSUSB_PID) },
74559c6ccd9SDaniel Suchy 	{ USB_DEVICE(PAPOUCH_VID, PAPOUCH_MU_PID) },
74659c6ccd9SDaniel Suchy 	{ USB_DEVICE(PAPOUCH_VID, PAPOUCH_SIMUKEY_PID) },
747a7787e50SRadek Liboska 	{ USB_DEVICE(PAPOUCH_VID, PAPOUCH_AD4USB_PID) },
74859c6ccd9SDaniel Suchy 	{ USB_DEVICE(PAPOUCH_VID, PAPOUCH_GMUX_PID) },
74959c6ccd9SDaniel Suchy 	{ USB_DEVICE(PAPOUCH_VID, PAPOUCH_GMSR_PID) },
75059c6ccd9SDaniel Suchy 
75196285cb8SGaetan Carlier 	{ USB_DEVICE(FTDI_VID, FTDI_DOMINTELL_DGQG_PID) },
75296285cb8SGaetan Carlier 	{ USB_DEVICE(FTDI_VID, FTDI_DOMINTELL_DUSB_PID) },
75345eeff84SRobie Basak 	{ USB_DEVICE(ALTI2_VID, ALTI2_N3_PID) },
754ca80801bSMhayk Whandson 	{ USB_DEVICE(FTDI_VID, DIEBOLD_BCS_SE923_PID) },
7557f82b6ddSAxel Wachtler 	{ USB_DEVICE(ATMEL_VID, STK541_PID) },
7567f82b6ddSAxel Wachtler 	{ USB_DEVICE(DE_VID, STB_PID) },
7577f82b6ddSAxel Wachtler 	{ USB_DEVICE(DE_VID, WHT_PID) },
758b0d65900SMichael Hennerich 	{ USB_DEVICE(ADI_VID, ADI_GNICE_PID),
759b0d65900SMichael Hennerich 		.driver_info = (kernel_ulong_t)&ftdi_jtag_quirk },
76011eaf170SMichael Hennerich 	{ USB_DEVICE(ADI_VID, ADI_GNICEPLUS_PID),
76111eaf170SMichael Hennerich 		.driver_info = (kernel_ulong_t)&ftdi_jtag_quirk },
762ae27d843SPeter Korsgaard 	{ USB_DEVICE(JETI_VID, JETI_SPC1201_PID) },
7631002bb77SNicolas Pitre 	{ USB_DEVICE(MARVELL_VID, MARVELL_SHEEVAPLUG_PID),
7641002bb77SNicolas Pitre 		.driver_info = (kernel_ulong_t)&ftdi_jtag_quirk },
765d46130abSDaniel Suchy 	{ USB_DEVICE(LARSENBRUSGAARD_VID, LB_ALTITRACK_PID) },
766fca4404cSVille Sundberg 	{ USB_DEVICE(GN_OTOMETRICS_VID, AURICAL_USB_PID) },
767c47aacc6SMarko Hänninen 	{ USB_DEVICE(BAYER_VID, BAYER_CONTOUR_CABLE_PID) },
76850d0678eSDhaval Vasa 	{ USB_DEVICE(FTDI_VID, MARVELL_OPENRD_PID),
76950d0678eSDhaval Vasa 		.driver_info = (kernel_ulong_t)&ftdi_jtag_quirk },
770e7d7fcc0SPawel Ludwikow 	{ USB_DEVICE(FTDI_VID, HAMEG_HO820_PID) },
771e7d7fcc0SPawel Ludwikow 	{ USB_DEVICE(FTDI_VID, HAMEG_HO870_PID) },
7729714080dSMitchell Solomon 	{ USB_DEVICE(FTDI_VID, MJSG_GENERIC_PID) },
7739714080dSMitchell Solomon 	{ USB_DEVICE(FTDI_VID, MJSG_SR_RADIO_PID) },
7749714080dSMitchell Solomon 	{ USB_DEVICE(FTDI_VID, MJSG_HD_RADIO_PID) },
7759714080dSMitchell Solomon 	{ USB_DEVICE(FTDI_VID, MJSG_XM_RADIO_PID) },
77677dbd74eSColin Leitner 	{ USB_DEVICE(FTDI_VID, XVERVE_SIGNALYZER_ST_PID),
77777dbd74eSColin Leitner 		.driver_info = (kernel_ulong_t)&ftdi_jtag_quirk },
77877dbd74eSColin Leitner 	{ USB_DEVICE(FTDI_VID, XVERVE_SIGNALYZER_SLITE_PID),
77977dbd74eSColin Leitner 		.driver_info = (kernel_ulong_t)&ftdi_jtag_quirk },
78077dbd74eSColin Leitner 	{ USB_DEVICE(FTDI_VID, XVERVE_SIGNALYZER_SH2_PID),
78177dbd74eSColin Leitner 		.driver_info = (kernel_ulong_t)&ftdi_jtag_quirk },
78277dbd74eSColin Leitner 	{ USB_DEVICE(FTDI_VID, XVERVE_SIGNALYZER_SH4_PID),
78377dbd74eSColin Leitner 		.driver_info = (kernel_ulong_t)&ftdi_jtag_quirk },
784afad1964SJohn G. Rogers 	{ USB_DEVICE(FTDI_VID, SEGWAY_RMP200_PID) },
7853126d823SRich Mattes 	{ USB_DEVICE(FTDI_VID, ACCESIO_COM4SM_PID) },
786666cc076SMartin Michlmayr 	{ USB_DEVICE(IONICS_VID, IONICS_PLUGCOMPUTER_PID),
787666cc076SMartin Michlmayr 		.driver_info = (kernel_ulong_t)&ftdi_jtag_quirk },
78865737388SLuke Lowrey 	{ USB_DEVICE(FTDI_VID, FTDI_CHAMSYS_24_MASTER_WING_PID) },
78965737388SLuke Lowrey 	{ USB_DEVICE(FTDI_VID, FTDI_CHAMSYS_PC_WING_PID) },
79065737388SLuke Lowrey 	{ USB_DEVICE(FTDI_VID, FTDI_CHAMSYS_USB_DMX_PID) },
79165737388SLuke Lowrey 	{ USB_DEVICE(FTDI_VID, FTDI_CHAMSYS_MIDI_TIMECODE_PID) },
79265737388SLuke Lowrey 	{ USB_DEVICE(FTDI_VID, FTDI_CHAMSYS_MINI_WING_PID) },
79365737388SLuke Lowrey 	{ USB_DEVICE(FTDI_VID, FTDI_CHAMSYS_MAXI_WING_PID) },
79465737388SLuke Lowrey 	{ USB_DEVICE(FTDI_VID, FTDI_CHAMSYS_MEDIA_WING_PID) },
79565737388SLuke Lowrey 	{ USB_DEVICE(FTDI_VID, FTDI_CHAMSYS_WING_PID) },
7960f266abdSGreg Kroah-Hartman 	{ USB_DEVICE(FTDI_VID, FTDI_SCIENCESCOPE_LOGBOOKML_PID) },
7970f266abdSGreg Kroah-Hartman 	{ USB_DEVICE(FTDI_VID, FTDI_SCIENCESCOPE_LS_LOGBOOK_PID) },
7980f266abdSGreg Kroah-Hartman 	{ USB_DEVICE(FTDI_VID, FTDI_SCIENCESCOPE_HS_LOGBOOK_PID) },
799*5363cdc3SFlorian Faber 	{ USB_DEVICE(FTDI_VID, FTDI_DOTEC_PID) },
8007fea0f71SSebastien Bourdeauducq 	{ USB_DEVICE(QIHARDWARE_VID, MILKYMISTONE_JTAGSERIAL_PID),
8017fea0f71SSebastien Bourdeauducq 		.driver_info = (kernel_ulong_t)&ftdi_jtag_quirk },
802fdcb0a0fSIan Abbott 	{ },					/* Optional parameter entry */
8031da177e4SLinus Torvalds 	{ }					/* Terminating entry */
8041da177e4SLinus Torvalds };
8051da177e4SLinus Torvalds 
8061da177e4SLinus Torvalds MODULE_DEVICE_TABLE(usb, id_table_combined);
8071da177e4SLinus Torvalds 
8081da177e4SLinus Torvalds static struct usb_driver ftdi_driver = {
8091da177e4SLinus Torvalds 	.name =		"ftdi_sio",
8101da177e4SLinus Torvalds 	.probe =	usb_serial_probe,
8111da177e4SLinus Torvalds 	.disconnect =	usb_serial_disconnect,
8121da177e4SLinus Torvalds 	.id_table =	id_table_combined,
813ba9dc657SGreg Kroah-Hartman 	.no_dynamic_id =	1,
8141da177e4SLinus Torvalds };
8151da177e4SLinus Torvalds 
8164c4c9432SArjan van de Ven static const char *ftdi_chip_name[] = {
8171da177e4SLinus Torvalds 	[SIO] = "SIO",	/* the serial part of FT8U100AX */
8181da177e4SLinus Torvalds 	[FT8U232AM] = "FT8U232AM",
8191da177e4SLinus Torvalds 	[FT232BM] = "FT232BM",
8201da177e4SLinus Torvalds 	[FT2232C] = "FT2232C",
821d8b21606SGard Spreemann 	[FT232RL] = "FT232RL",
822094c2e6dSMark Adamson 	[FT2232H] = "FT2232H",
823094c2e6dSMark Adamson 	[FT4232H] = "FT4232H"
8241da177e4SLinus Torvalds };
8251da177e4SLinus Torvalds 
8261da177e4SLinus Torvalds 
8271da177e4SLinus Torvalds /* Used for TIOCMIWAIT */
8281da177e4SLinus Torvalds #define FTDI_STATUS_B0_MASK	(FTDI_RS0_CTS | FTDI_RS0_DSR | FTDI_RS0_RI | FTDI_RS0_RLSD)
8291da177e4SLinus Torvalds #define FTDI_STATUS_B1_MASK	(FTDI_RS_BI)
8301da177e4SLinus Torvalds /* End TIOCMIWAIT */
8311da177e4SLinus Torvalds 
8321da177e4SLinus Torvalds #define FTDI_IMPL_ASYNC_FLAGS = (ASYNC_SPD_HI | ASYNC_SPD_VHI \
833bbc5d276SRoel Kluin  | ASYNC_SPD_CUST | ASYNC_SPD_SHI | ASYNC_SPD_WARP)
8341da177e4SLinus Torvalds 
8351da177e4SLinus Torvalds /* function prototypes for a FTDI serial converter */
836464cbb24SAlan Cox static int  ftdi_sio_probe(struct usb_serial *serial,
837464cbb24SAlan Cox 					const struct usb_device_id *id);
83812bdbe03SJim Radford static int  ftdi_sio_port_probe(struct usb_serial_port *port);
83912bdbe03SJim Radford static int  ftdi_sio_port_remove(struct usb_serial_port *port);
840a509a7e4SAlan Cox static int  ftdi_open(struct tty_struct *tty, struct usb_serial_port *port);
841335f8514SAlan Cox static void ftdi_close(struct usb_serial_port *port);
842335f8514SAlan Cox static void ftdi_dtr_rts(struct usb_serial_port *port, int on);
8431b551015SJohan Hovold static void ftdi_process_read_urb(struct urb *urb);
844d3901a06SJohan Hovold static int ftdi_prepare_write_buffer(struct usb_serial_port *port,
845c23e5fc1SJohan Hovold 						void *dest, size_t size);
846464cbb24SAlan Cox static void ftdi_set_termios(struct tty_struct *tty,
847464cbb24SAlan Cox 			struct usb_serial_port *port, struct ktermios *old);
84895da310eSAlan Cox static int  ftdi_tiocmget(struct tty_struct *tty, struct file *file);
849464cbb24SAlan Cox static int  ftdi_tiocmset(struct tty_struct *tty, struct file *file,
850464cbb24SAlan Cox 			unsigned int set, unsigned int clear);
851464cbb24SAlan Cox static int  ftdi_ioctl(struct tty_struct *tty, struct file *file,
852464cbb24SAlan Cox 			unsigned int cmd, unsigned long arg);
85395da310eSAlan Cox static void ftdi_break_ctl(struct tty_struct *tty, int break_state);
8541da177e4SLinus Torvalds 
8551da177e4SLinus Torvalds static unsigned short int ftdi_232am_baud_base_to_divisor(int baud, int base);
8561da177e4SLinus Torvalds static unsigned short int ftdi_232am_baud_to_divisor(int baud);
8571da177e4SLinus Torvalds static __u32 ftdi_232bm_baud_base_to_divisor(int baud, int base);
8581da177e4SLinus Torvalds static __u32 ftdi_232bm_baud_to_divisor(int baud);
859094c2e6dSMark Adamson static __u32 ftdi_2232h_baud_base_to_divisor(int baud, int base);
860094c2e6dSMark Adamson static __u32 ftdi_2232h_baud_to_divisor(int baud);
8611da177e4SLinus Torvalds 
862ea65370dSGreg Kroah-Hartman static struct usb_serial_driver ftdi_sio_device = {
86318fcac35SGreg Kroah-Hartman 	.driver = {
8641da177e4SLinus Torvalds 		.owner =	THIS_MODULE,
865269bda1cSGreg Kroah-Hartman 		.name =		"ftdi_sio",
86618fcac35SGreg Kroah-Hartman 	},
867269bda1cSGreg Kroah-Hartman 	.description =		"FTDI USB Serial Device",
868d9b1b787SJohannes Hölzl 	.usb_driver = 		&ftdi_driver,
8698f977e42SIan Abbott 	.id_table =		id_table_combined,
8701da177e4SLinus Torvalds 	.num_ports =		1,
871bbcb2b90SJohan Hovold 	.bulk_in_size =		512,
872c23e5fc1SJohan Hovold 	.bulk_out_size =	256,
8738f977e42SIan Abbott 	.probe =		ftdi_sio_probe,
87412bdbe03SJim Radford 	.port_probe =		ftdi_sio_port_probe,
87512bdbe03SJim Radford 	.port_remove =		ftdi_sio_port_remove,
8761da177e4SLinus Torvalds 	.open =			ftdi_open,
8771da177e4SLinus Torvalds 	.close =		ftdi_close,
878335f8514SAlan Cox 	.dtr_rts =		ftdi_dtr_rts,
8791b551015SJohan Hovold 	.throttle =		usb_serial_generic_throttle,
8801b551015SJohan Hovold 	.unthrottle =		usb_serial_generic_unthrottle,
8811b551015SJohan Hovold 	.process_read_urb =	ftdi_process_read_urb,
882d3901a06SJohan Hovold 	.prepare_write_buffer =	ftdi_prepare_write_buffer,
8831da177e4SLinus Torvalds 	.tiocmget =		ftdi_tiocmget,
8841da177e4SLinus Torvalds 	.tiocmset =		ftdi_tiocmset,
8851da177e4SLinus Torvalds 	.ioctl =		ftdi_ioctl,
8861da177e4SLinus Torvalds 	.set_termios =		ftdi_set_termios,
8871da177e4SLinus Torvalds 	.break_ctl =		ftdi_break_ctl,
8881da177e4SLinus Torvalds };
8891da177e4SLinus Torvalds 
8901da177e4SLinus Torvalds 
8911da177e4SLinus Torvalds #define WDR_TIMEOUT 5000 /* default urb timeout */
892279e1545SIan Abbott #define WDR_SHORT_TIMEOUT 1000	/* shorter urb timeout */
8931da177e4SLinus Torvalds 
8941da177e4SLinus Torvalds /* High and low are for DTR, RTS etc etc */
8951da177e4SLinus Torvalds #define HIGH 1
8961da177e4SLinus Torvalds #define LOW 0
8971da177e4SLinus Torvalds 
8981da177e4SLinus Torvalds /*
8991da177e4SLinus Torvalds  * ***************************************************************************
900fa91d43bSTony Lindgren  * Utility functions
9011da177e4SLinus Torvalds  * ***************************************************************************
9021da177e4SLinus Torvalds  */
9031da177e4SLinus Torvalds 
9041da177e4SLinus Torvalds static unsigned short int ftdi_232am_baud_base_to_divisor(int baud, int base)
9051da177e4SLinus Torvalds {
9061da177e4SLinus Torvalds 	unsigned short int divisor;
907464cbb24SAlan Cox 	/* divisor shifted 3 bits to the left */
908464cbb24SAlan Cox 	int divisor3 = base / 2 / baud;
909464cbb24SAlan Cox 	if ((divisor3 & 0x7) == 7)
910464cbb24SAlan Cox 		divisor3++; /* round x.7/8 up to x+1 */
9111da177e4SLinus Torvalds 	divisor = divisor3 >> 3;
9121da177e4SLinus Torvalds 	divisor3 &= 0x7;
913464cbb24SAlan Cox 	if (divisor3 == 1)
914464cbb24SAlan Cox 		divisor |= 0xc000;
915464cbb24SAlan Cox 	else if (divisor3 >= 4)
916464cbb24SAlan Cox 		divisor |= 0x4000;
917464cbb24SAlan Cox 	else if (divisor3 != 0)
918464cbb24SAlan Cox 		divisor |= 0x8000;
919464cbb24SAlan Cox 	else if (divisor == 1)
920464cbb24SAlan Cox 		divisor = 0;	/* special case for maximum baud rate */
9211da177e4SLinus Torvalds 	return divisor;
9221da177e4SLinus Torvalds }
9231da177e4SLinus Torvalds 
9241da177e4SLinus Torvalds static unsigned short int ftdi_232am_baud_to_divisor(int baud)
9251da177e4SLinus Torvalds {
926464cbb24SAlan Cox 	 return ftdi_232am_baud_base_to_divisor(baud, 48000000);
9271da177e4SLinus Torvalds }
9281da177e4SLinus Torvalds 
9291da177e4SLinus Torvalds static __u32 ftdi_232bm_baud_base_to_divisor(int baud, int base)
9301da177e4SLinus Torvalds {
9311da177e4SLinus Torvalds 	static const unsigned char divfrac[8] = { 0, 3, 2, 4, 1, 5, 6, 7 };
9321da177e4SLinus Torvalds 	__u32 divisor;
933464cbb24SAlan Cox 	/* divisor shifted 3 bits to the left */
934464cbb24SAlan Cox 	int divisor3 = base / 2 / baud;
9351da177e4SLinus Torvalds 	divisor = divisor3 >> 3;
9361da177e4SLinus Torvalds 	divisor |= (__u32)divfrac[divisor3 & 0x7] << 14;
9371da177e4SLinus Torvalds 	/* Deal with special cases for highest baud rates. */
938464cbb24SAlan Cox 	if (divisor == 1)
939464cbb24SAlan Cox 		divisor = 0;
940464cbb24SAlan Cox 	else if (divisor == 0x4001)
941464cbb24SAlan Cox 		divisor = 1;
9421da177e4SLinus Torvalds 	return divisor;
9431da177e4SLinus Torvalds }
9441da177e4SLinus Torvalds 
9451da177e4SLinus Torvalds static __u32 ftdi_232bm_baud_to_divisor(int baud)
9461da177e4SLinus Torvalds {
947464cbb24SAlan Cox 	 return ftdi_232bm_baud_base_to_divisor(baud, 48000000);
9481da177e4SLinus Torvalds }
9491da177e4SLinus Torvalds 
950094c2e6dSMark Adamson static __u32 ftdi_2232h_baud_base_to_divisor(int baud, int base)
951094c2e6dSMark Adamson {
952094c2e6dSMark Adamson 	static const unsigned char divfrac[8] = { 0, 3, 2, 4, 1, 5, 6, 7 };
953094c2e6dSMark Adamson 	__u32 divisor;
954094c2e6dSMark Adamson 	int divisor3;
955094c2e6dSMark Adamson 
956094c2e6dSMark Adamson 	/* hi-speed baud rate is 10-bit sampling instead of 16-bit */
957094c2e6dSMark Adamson 	divisor3 = (base / 10 / baud) * 8;
958094c2e6dSMark Adamson 
959094c2e6dSMark Adamson 	divisor = divisor3 >> 3;
960094c2e6dSMark Adamson 	divisor |= (__u32)divfrac[divisor3 & 0x7] << 14;
961094c2e6dSMark Adamson 	/* Deal with special cases for highest baud rates. */
962094c2e6dSMark Adamson 	if (divisor == 1)
963094c2e6dSMark Adamson 		divisor = 0;
964094c2e6dSMark Adamson 	else if (divisor == 0x4001)
965094c2e6dSMark Adamson 		divisor = 1;
966094c2e6dSMark Adamson 	/*
967094c2e6dSMark Adamson 	 * Set this bit to turn off a divide by 2.5 on baud rate generator
968094c2e6dSMark Adamson 	 * This enables baud rates up to 12Mbaud but cannot reach below 1200
969094c2e6dSMark Adamson 	 * baud with this bit set
970094c2e6dSMark Adamson 	 */
971094c2e6dSMark Adamson 	divisor |= 0x00020000;
972094c2e6dSMark Adamson 	return divisor;
973094c2e6dSMark Adamson }
974094c2e6dSMark Adamson 
975094c2e6dSMark Adamson static __u32 ftdi_2232h_baud_to_divisor(int baud)
976094c2e6dSMark Adamson {
977094c2e6dSMark Adamson 	 return ftdi_2232h_baud_base_to_divisor(baud, 120000000);
978094c2e6dSMark Adamson }
979094c2e6dSMark Adamson 
98074ede0ffSIan Abbott #define set_mctrl(port, set)		update_mctrl((port), (set), 0)
98174ede0ffSIan Abbott #define clear_mctrl(port, clear)	update_mctrl((port), 0, (clear))
98274ede0ffSIan Abbott 
983464cbb24SAlan Cox static int update_mctrl(struct usb_serial_port *port, unsigned int set,
984464cbb24SAlan Cox 							unsigned int clear)
9851da177e4SLinus Torvalds {
9861da177e4SLinus Torvalds 	struct ftdi_private *priv = usb_get_serial_port_data(port);
98774ede0ffSIan Abbott 	unsigned urb_value;
9881da177e4SLinus Torvalds 	int rv;
9891da177e4SLinus Torvalds 
99074ede0ffSIan Abbott 	if (((set | clear) & (TIOCM_DTR | TIOCM_RTS)) == 0) {
991441b62c1SHarvey Harrison 		dbg("%s - DTR|RTS not being set|cleared", __func__);
99274ede0ffSIan Abbott 		return 0;	/* no change */
9931da177e4SLinus Torvalds 	}
99474ede0ffSIan Abbott 
99574ede0ffSIan Abbott 	clear &= ~set;	/* 'set' takes precedence over 'clear' */
99674ede0ffSIan Abbott 	urb_value = 0;
99774ede0ffSIan Abbott 	if (clear & TIOCM_DTR)
99874ede0ffSIan Abbott 		urb_value |= FTDI_SIO_SET_DTR_LOW;
99974ede0ffSIan Abbott 	if (clear & TIOCM_RTS)
100074ede0ffSIan Abbott 		urb_value |= FTDI_SIO_SET_RTS_LOW;
100174ede0ffSIan Abbott 	if (set & TIOCM_DTR)
100274ede0ffSIan Abbott 		urb_value |= FTDI_SIO_SET_DTR_HIGH;
100374ede0ffSIan Abbott 	if (set & TIOCM_RTS)
100474ede0ffSIan Abbott 		urb_value |= FTDI_SIO_SET_RTS_HIGH;
10051da177e4SLinus Torvalds 	rv = usb_control_msg(port->serial->dev,
10061da177e4SLinus Torvalds 			       usb_sndctrlpipe(port->serial->dev, 0),
10071da177e4SLinus Torvalds 			       FTDI_SIO_SET_MODEM_CTRL_REQUEST,
10081da177e4SLinus Torvalds 			       FTDI_SIO_SET_MODEM_CTRL_REQUEST_TYPE,
100974ede0ffSIan Abbott 			       urb_value, priv->interface,
101066e47e60SJohan Hovold 			       NULL, 0, WDR_TIMEOUT);
101174ede0ffSIan Abbott 	if (rv < 0) {
101243b11d33SAlan Cox 		dbg("%s Error from MODEM_CTRL urb: DTR %s, RTS %s",
1013441b62c1SHarvey Harrison 				__func__,
101474ede0ffSIan Abbott 				(set & TIOCM_DTR) ? "HIGH" :
101574ede0ffSIan Abbott 				(clear & TIOCM_DTR) ? "LOW" : "unchanged",
101674ede0ffSIan Abbott 				(set & TIOCM_RTS) ? "HIGH" :
101774ede0ffSIan Abbott 				(clear & TIOCM_RTS) ? "LOW" : "unchanged");
10181da177e4SLinus Torvalds 	} else {
1019441b62c1SHarvey Harrison 		dbg("%s - DTR %s, RTS %s", __func__,
102074ede0ffSIan Abbott 				(set & TIOCM_DTR) ? "HIGH" :
102174ede0ffSIan Abbott 				(clear & TIOCM_DTR) ? "LOW" : "unchanged",
102274ede0ffSIan Abbott 				(set & TIOCM_RTS) ? "HIGH" :
102374ede0ffSIan Abbott 				(clear & TIOCM_RTS) ? "LOW" : "unchanged");
10249b0f2582SAlan Cox 		/* FIXME: locking on last_dtr_rts */
102574ede0ffSIan Abbott 		priv->last_dtr_rts = (priv->last_dtr_rts & ~clear) | set;
10261da177e4SLinus Torvalds 	}
10271da177e4SLinus Torvalds 	return rv;
10281da177e4SLinus Torvalds }
10291da177e4SLinus Torvalds 
10301da177e4SLinus Torvalds 
1031464cbb24SAlan Cox static __u32 get_ftdi_divisor(struct tty_struct *tty,
1032464cbb24SAlan Cox 						struct usb_serial_port *port)
1033e49bbce1SJohan Hovold {
10341da177e4SLinus Torvalds 	struct ftdi_private *priv = usb_get_serial_port_data(port);
10351da177e4SLinus Torvalds 	__u32 div_value = 0;
10361da177e4SLinus Torvalds 	int div_okay = 1;
10371da177e4SLinus Torvalds 	int baud;
10381da177e4SLinus Torvalds 
10391da177e4SLinus Torvalds 	/*
1040464cbb24SAlan Cox 	 * The logic involved in setting the baudrate can be cleanly split into
1041464cbb24SAlan Cox 	 * 3 steps.
10421da177e4SLinus Torvalds 	 * 1. Standard baud rates are set in tty->termios->c_cflag
1043464cbb24SAlan Cox 	 * 2. If these are not enough, you can set any speed using alt_speed as
1044464cbb24SAlan Cox 	 * follows:
10451da177e4SLinus Torvalds 	 *    - set tty->termios->c_cflag speed to B38400
10461da177e4SLinus Torvalds 	 *    - set your real speed in tty->alt_speed; it gets ignored when
10471da177e4SLinus Torvalds 	 *      alt_speed==0, (or)
1048464cbb24SAlan Cox 	 *    - call TIOCSSERIAL ioctl with (struct serial_struct) set as
1049464cbb24SAlan Cox 	 *	follows:
1050464cbb24SAlan Cox 	 *      flags & ASYNC_SPD_MASK == ASYNC_SPD_[HI, VHI, SHI, WARP],
1051464cbb24SAlan Cox 	 *	this just sets alt_speed to (HI: 57600, VHI: 115200,
1052464cbb24SAlan Cox 	 *	SHI: 230400, WARP: 460800)
10531da177e4SLinus Torvalds 	 * ** Steps 1, 2 are done courtesy of tty_get_baud_rate
10541da177e4SLinus Torvalds 	 * 3. You can also set baud rate by setting custom divisor as follows
10551da177e4SLinus Torvalds 	 *    - set tty->termios->c_cflag speed to B38400
1056464cbb24SAlan Cox 	 *    - call TIOCSSERIAL ioctl with (struct serial_struct) set as
1057464cbb24SAlan Cox 	 *	follows:
10581da177e4SLinus Torvalds 	 *      o flags & ASYNC_SPD_MASK == ASYNC_SPD_CUST
10591da177e4SLinus Torvalds 	 *      o custom_divisor set to baud_base / your_new_baudrate
1060464cbb24SAlan Cox 	 * ** Step 3 is done courtesy of code borrowed from serial.c
1061464cbb24SAlan Cox 	 *    I should really spend some time and separate + move this common
1062464cbb24SAlan Cox 	 *    code to serial.c, it is replicated in nearly every serial driver
1063464cbb24SAlan Cox 	 *    you see.
10641da177e4SLinus Torvalds 	 */
10651da177e4SLinus Torvalds 
1066464cbb24SAlan Cox 	/* 1. Get the baud rate from the tty settings, this observes
1067464cbb24SAlan Cox 	      alt_speed hack */
10681da177e4SLinus Torvalds 
106995da310eSAlan Cox 	baud = tty_get_baud_rate(tty);
1070441b62c1SHarvey Harrison 	dbg("%s - tty_get_baud_rate reports speed %d", __func__, baud);
10711da177e4SLinus Torvalds 
1072464cbb24SAlan Cox 	/* 2. Observe async-compatible custom_divisor hack, update baudrate
1073464cbb24SAlan Cox 	   if needed */
10741da177e4SLinus Torvalds 
10751da177e4SLinus Torvalds 	if (baud == 38400 &&
10761da177e4SLinus Torvalds 	    ((priv->flags & ASYNC_SPD_MASK) == ASYNC_SPD_CUST) &&
10771da177e4SLinus Torvalds 	     (priv->custom_divisor)) {
10781da177e4SLinus Torvalds 		baud = priv->baud_base / priv->custom_divisor;
1079464cbb24SAlan Cox 		dbg("%s - custom divisor %d sets baud rate to %d",
1080464cbb24SAlan Cox 				__func__, priv->custom_divisor, baud);
10811da177e4SLinus Torvalds 	}
10821da177e4SLinus Torvalds 
10831da177e4SLinus Torvalds 	/* 3. Convert baudrate to device-specific divisor */
10841da177e4SLinus Torvalds 
1085464cbb24SAlan Cox 	if (!baud)
1086464cbb24SAlan Cox 		baud = 9600;
10871da177e4SLinus Torvalds 	switch (priv->chip_type) {
10881da177e4SLinus Torvalds 	case SIO: /* SIO chip */
10891da177e4SLinus Torvalds 		switch (baud) {
10901da177e4SLinus Torvalds 		case 300: div_value = ftdi_sio_b300; break;
10911da177e4SLinus Torvalds 		case 600: div_value = ftdi_sio_b600; break;
10921da177e4SLinus Torvalds 		case 1200: div_value = ftdi_sio_b1200; break;
10931da177e4SLinus Torvalds 		case 2400: div_value = ftdi_sio_b2400; break;
10941da177e4SLinus Torvalds 		case 4800: div_value = ftdi_sio_b4800; break;
10951da177e4SLinus Torvalds 		case 9600: div_value = ftdi_sio_b9600; break;
10961da177e4SLinus Torvalds 		case 19200: div_value = ftdi_sio_b19200; break;
10971da177e4SLinus Torvalds 		case 38400: div_value = ftdi_sio_b38400; break;
10981da177e4SLinus Torvalds 		case 57600: div_value = ftdi_sio_b57600;  break;
10991da177e4SLinus Torvalds 		case 115200: div_value = ftdi_sio_b115200; break;
11001da177e4SLinus Torvalds 		} /* baud */
11011da177e4SLinus Torvalds 		if (div_value == 0) {
1102464cbb24SAlan Cox 			dbg("%s - Baudrate (%d) requested is not supported",
1103464cbb24SAlan Cox 							__func__,  baud);
11041da177e4SLinus Torvalds 			div_value = ftdi_sio_b9600;
1105669a6db1SAlan Cox 			baud = 9600;
11061da177e4SLinus Torvalds 			div_okay = 0;
11071da177e4SLinus Torvalds 		}
11081da177e4SLinus Torvalds 		break;
11091da177e4SLinus Torvalds 	case FT8U232AM: /* 8U232AM chip */
11101da177e4SLinus Torvalds 		if (baud <= 3000000) {
11111da177e4SLinus Torvalds 			div_value = ftdi_232am_baud_to_divisor(baud);
11121da177e4SLinus Torvalds 		} else {
1113441b62c1SHarvey Harrison 			dbg("%s - Baud rate too high!", __func__);
1114669a6db1SAlan Cox 			baud = 9600;
11151da177e4SLinus Torvalds 			div_value = ftdi_232am_baud_to_divisor(9600);
11161da177e4SLinus Torvalds 			div_okay = 0;
11171da177e4SLinus Torvalds 		}
11181da177e4SLinus Torvalds 		break;
11191da177e4SLinus Torvalds 	case FT232BM: /* FT232BM chip */
11201da177e4SLinus Torvalds 	case FT2232C: /* FT2232C chip */
11213b009c63SDavid Brownell 	case FT232RL:
11221da177e4SLinus Torvalds 		if (baud <= 3000000) {
1123b760dac2SMartin Geleynse 			__u16 product_id = le16_to_cpu(
1124b760dac2SMartin Geleynse 				port->serial->dev->descriptor.idProduct);
1125b760dac2SMartin Geleynse 			if (((FTDI_NDI_HUC_PID == product_id) ||
1126b760dac2SMartin Geleynse 			     (FTDI_NDI_SPECTRA_SCU_PID == product_id) ||
1127b760dac2SMartin Geleynse 			     (FTDI_NDI_FUTURE_2_PID == product_id) ||
1128b760dac2SMartin Geleynse 			     (FTDI_NDI_FUTURE_3_PID == product_id) ||
1129b760dac2SMartin Geleynse 			     (FTDI_NDI_AURORA_SCU_PID == product_id)) &&
1130b760dac2SMartin Geleynse 			    (baud == 19200)) {
1131b760dac2SMartin Geleynse 				baud = 1200000;
1132b760dac2SMartin Geleynse 			}
11331da177e4SLinus Torvalds 			div_value = ftdi_232bm_baud_to_divisor(baud);
11341da177e4SLinus Torvalds 		} else {
1135441b62c1SHarvey Harrison 			dbg("%s - Baud rate too high!", __func__);
11361da177e4SLinus Torvalds 			div_value = ftdi_232bm_baud_to_divisor(9600);
11371da177e4SLinus Torvalds 			div_okay = 0;
1138669a6db1SAlan Cox 			baud = 9600;
11391da177e4SLinus Torvalds 		}
11401da177e4SLinus Torvalds 		break;
1141094c2e6dSMark Adamson 	case FT2232H: /* FT2232H chip */
1142094c2e6dSMark Adamson 	case FT4232H: /* FT4232H chip */
1143094c2e6dSMark Adamson 		if ((baud <= 12000000) & (baud >= 1200)) {
1144094c2e6dSMark Adamson 			div_value = ftdi_2232h_baud_to_divisor(baud);
1145094c2e6dSMark Adamson 		} else if (baud < 1200) {
1146094c2e6dSMark Adamson 			div_value = ftdi_232bm_baud_to_divisor(baud);
1147094c2e6dSMark Adamson 		} else {
1148094c2e6dSMark Adamson 			dbg("%s - Baud rate too high!", __func__);
1149094c2e6dSMark Adamson 			div_value = ftdi_232bm_baud_to_divisor(9600);
1150094c2e6dSMark Adamson 			div_okay = 0;
1151094c2e6dSMark Adamson 			baud = 9600;
1152094c2e6dSMark Adamson 		}
1153094c2e6dSMark Adamson 		break;
11541da177e4SLinus Torvalds 	} /* priv->chip_type */
11551da177e4SLinus Torvalds 
11561da177e4SLinus Torvalds 	if (div_okay) {
11571da177e4SLinus Torvalds 		dbg("%s - Baud rate set to %d (divisor 0x%lX) on chip %s",
1158441b62c1SHarvey Harrison 			__func__, baud, (unsigned long)div_value,
11591da177e4SLinus Torvalds 			ftdi_chip_name[priv->chip_type]);
11601da177e4SLinus Torvalds 	}
11611da177e4SLinus Torvalds 
116295da310eSAlan Cox 	tty_encode_baud_rate(tty, baud, baud);
1163464cbb24SAlan Cox 	return div_value;
11641da177e4SLinus Torvalds }
11651da177e4SLinus Torvalds 
116695da310eSAlan Cox static int change_speed(struct tty_struct *tty, struct usb_serial_port *port)
116795da310eSAlan Cox {
116895da310eSAlan Cox 	struct ftdi_private *priv = usb_get_serial_port_data(port);
116995da310eSAlan Cox 	__u16 urb_value;
117095da310eSAlan Cox 	__u16 urb_index;
117195da310eSAlan Cox 	__u32 urb_index_value;
117295da310eSAlan Cox 	int rv;
117395da310eSAlan Cox 
117495da310eSAlan Cox 	urb_index_value = get_ftdi_divisor(tty, port);
117595da310eSAlan Cox 	urb_value = (__u16)urb_index_value;
117695da310eSAlan Cox 	urb_index = (__u16)(urb_index_value >> 16);
117795da310eSAlan Cox 	if (priv->interface) {	/* FT2232C */
117895da310eSAlan Cox 		urb_index = (__u16)((urb_index << 8) | priv->interface);
117995da310eSAlan Cox 	}
118095da310eSAlan Cox 
118195da310eSAlan Cox 	rv = usb_control_msg(port->serial->dev,
118295da310eSAlan Cox 			    usb_sndctrlpipe(port->serial->dev, 0),
118395da310eSAlan Cox 			    FTDI_SIO_SET_BAUDRATE_REQUEST,
118495da310eSAlan Cox 			    FTDI_SIO_SET_BAUDRATE_REQUEST_TYPE,
118595da310eSAlan Cox 			    urb_value, urb_index,
118666e47e60SJohan Hovold 			    NULL, 0, WDR_SHORT_TIMEOUT);
118795da310eSAlan Cox 	return rv;
118895da310eSAlan Cox }
118995da310eSAlan Cox 
1190557aaa7fSAlan Cox static int write_latency_timer(struct usb_serial_port *port)
1191557aaa7fSAlan Cox {
1192557aaa7fSAlan Cox 	struct ftdi_private *priv = usb_get_serial_port_data(port);
1193557aaa7fSAlan Cox 	struct usb_device *udev = port->serial->dev;
1194c1284d77SJohan Hovold 	int rv;
1195557aaa7fSAlan Cox 	int l = priv->latency;
119695da310eSAlan Cox 
1197557aaa7fSAlan Cox 	if (priv->flags & ASYNC_LOW_LATENCY)
1198557aaa7fSAlan Cox 		l = 1;
1199557aaa7fSAlan Cox 
1200557aaa7fSAlan Cox 	dbg("%s: setting latency timer = %i", __func__, l);
1201557aaa7fSAlan Cox 
1202557aaa7fSAlan Cox 	rv = usb_control_msg(udev,
1203557aaa7fSAlan Cox 			     usb_sndctrlpipe(udev, 0),
1204557aaa7fSAlan Cox 			     FTDI_SIO_SET_LATENCY_TIMER_REQUEST,
1205557aaa7fSAlan Cox 			     FTDI_SIO_SET_LATENCY_TIMER_REQUEST_TYPE,
1206557aaa7fSAlan Cox 			     l, priv->interface,
120766e47e60SJohan Hovold 			     NULL, 0, WDR_TIMEOUT);
1208557aaa7fSAlan Cox 	if (rv < 0)
1209557aaa7fSAlan Cox 		dev_err(&port->dev, "Unable to write latency timer: %i\n", rv);
1210557aaa7fSAlan Cox 	return rv;
1211557aaa7fSAlan Cox }
1212557aaa7fSAlan Cox 
1213557aaa7fSAlan Cox static int read_latency_timer(struct usb_serial_port *port)
1214557aaa7fSAlan Cox {
1215557aaa7fSAlan Cox 	struct ftdi_private *priv = usb_get_serial_port_data(port);
1216557aaa7fSAlan Cox 	struct usb_device *udev = port->serial->dev;
121754f328d0SJohan Hovold 	unsigned char *buf;
1218c1284d77SJohan Hovold 	int rv;
1219557aaa7fSAlan Cox 
1220557aaa7fSAlan Cox 	dbg("%s", __func__);
1221557aaa7fSAlan Cox 
122254f328d0SJohan Hovold 	buf = kmalloc(1, GFP_KERNEL);
122354f328d0SJohan Hovold 	if (!buf)
122454f328d0SJohan Hovold 		return -ENOMEM;
122554f328d0SJohan Hovold 
1226557aaa7fSAlan Cox 	rv = usb_control_msg(udev,
1227557aaa7fSAlan Cox 			     usb_rcvctrlpipe(udev, 0),
1228557aaa7fSAlan Cox 			     FTDI_SIO_GET_LATENCY_TIMER_REQUEST,
1229557aaa7fSAlan Cox 			     FTDI_SIO_GET_LATENCY_TIMER_REQUEST_TYPE,
1230557aaa7fSAlan Cox 			     0, priv->interface,
123154f328d0SJohan Hovold 			     buf, 1, WDR_TIMEOUT);
12324357369dSJohan Hovold 	if (rv < 0)
1233557aaa7fSAlan Cox 		dev_err(&port->dev, "Unable to read latency timer: %i\n", rv);
12344357369dSJohan Hovold 	else
123554f328d0SJohan Hovold 		priv->latency = buf[0];
123654f328d0SJohan Hovold 
123754f328d0SJohan Hovold 	kfree(buf);
123854f328d0SJohan Hovold 
12398c4f99cdSJohan Hovold 	return rv;
1240557aaa7fSAlan Cox }
12411da177e4SLinus Torvalds 
1242464cbb24SAlan Cox static int get_serial_info(struct usb_serial_port *port,
1243464cbb24SAlan Cox 				struct serial_struct __user *retinfo)
12441da177e4SLinus Torvalds {
12451da177e4SLinus Torvalds 	struct ftdi_private *priv = usb_get_serial_port_data(port);
12461da177e4SLinus Torvalds 	struct serial_struct tmp;
12471da177e4SLinus Torvalds 
12481da177e4SLinus Torvalds 	if (!retinfo)
12491da177e4SLinus Torvalds 		return -EFAULT;
12501da177e4SLinus Torvalds 	memset(&tmp, 0, sizeof(tmp));
12511da177e4SLinus Torvalds 	tmp.flags = priv->flags;
12521da177e4SLinus Torvalds 	tmp.baud_base = priv->baud_base;
12531da177e4SLinus Torvalds 	tmp.custom_divisor = priv->custom_divisor;
12541da177e4SLinus Torvalds 	if (copy_to_user(retinfo, &tmp, sizeof(*retinfo)))
12551da177e4SLinus Torvalds 		return -EFAULT;
12561da177e4SLinus Torvalds 	return 0;
1257e49bbce1SJohan Hovold }
12581da177e4SLinus Torvalds 
125995da310eSAlan Cox static int set_serial_info(struct tty_struct *tty,
126095da310eSAlan Cox 	struct usb_serial_port *port, struct serial_struct __user *newinfo)
1261e49bbce1SJohan Hovold {
12621da177e4SLinus Torvalds 	struct ftdi_private *priv = usb_get_serial_port_data(port);
12631da177e4SLinus Torvalds 	struct serial_struct new_serial;
12641da177e4SLinus Torvalds 	struct ftdi_private old_priv;
12651da177e4SLinus Torvalds 
12661da177e4SLinus Torvalds 	if (copy_from_user(&new_serial, newinfo, sizeof(new_serial)))
12671da177e4SLinus Torvalds 		return -EFAULT;
12686b447f04SAlan Cox 
1269bd09a9f5SAlessio Igor Bogani 	mutex_lock(&priv->cfg_lock);
12701da177e4SLinus Torvalds 	old_priv = *priv;
12711da177e4SLinus Torvalds 
12721da177e4SLinus Torvalds 	/* Do error checking and permission checking */
12731da177e4SLinus Torvalds 
12741da177e4SLinus Torvalds 	if (!capable(CAP_SYS_ADMIN)) {
12751da177e4SLinus Torvalds 		if (((new_serial.flags & ~ASYNC_USR_MASK) !=
127664905b48SDan Carpenter 		     (priv->flags & ~ASYNC_USR_MASK))) {
1277bd09a9f5SAlessio Igor Bogani 			mutex_unlock(&priv->cfg_lock);
12781da177e4SLinus Torvalds 			return -EPERM;
127964905b48SDan Carpenter 		}
12801da177e4SLinus Torvalds 		priv->flags = ((priv->flags & ~ASYNC_USR_MASK) |
12811da177e4SLinus Torvalds 			       (new_serial.flags & ASYNC_USR_MASK));
12821da177e4SLinus Torvalds 		priv->custom_divisor = new_serial.custom_divisor;
12831da177e4SLinus Torvalds 		goto check_and_exit;
12841da177e4SLinus Torvalds 	}
12851da177e4SLinus Torvalds 
12861da177e4SLinus Torvalds 	if ((new_serial.baud_base != priv->baud_base) &&
12876b447f04SAlan Cox 	    (new_serial.baud_base < 9600)) {
1288bd09a9f5SAlessio Igor Bogani 		mutex_unlock(&priv->cfg_lock);
12891da177e4SLinus Torvalds 		return -EINVAL;
12906b447f04SAlan Cox 	}
12911da177e4SLinus Torvalds 
12921da177e4SLinus Torvalds 	/* Make the changes - these are privileged changes! */
12931da177e4SLinus Torvalds 
12941da177e4SLinus Torvalds 	priv->flags = ((priv->flags & ~ASYNC_FLAGS) |
12951da177e4SLinus Torvalds 					(new_serial.flags & ASYNC_FLAGS));
12961da177e4SLinus Torvalds 	priv->custom_divisor = new_serial.custom_divisor;
12971da177e4SLinus Torvalds 
1298557aaa7fSAlan Cox 	write_latency_timer(port);
12991da177e4SLinus Torvalds 
13001da177e4SLinus Torvalds check_and_exit:
13011da177e4SLinus Torvalds 	if ((old_priv.flags & ASYNC_SPD_MASK) !=
13021da177e4SLinus Torvalds 	     (priv->flags & ASYNC_SPD_MASK)) {
13031da177e4SLinus Torvalds 		if ((priv->flags & ASYNC_SPD_MASK) == ASYNC_SPD_HI)
130495da310eSAlan Cox 			tty->alt_speed = 57600;
13051da177e4SLinus Torvalds 		else if ((priv->flags & ASYNC_SPD_MASK) == ASYNC_SPD_VHI)
130695da310eSAlan Cox 			tty->alt_speed = 115200;
13071da177e4SLinus Torvalds 		else if ((priv->flags & ASYNC_SPD_MASK) == ASYNC_SPD_SHI)
130895da310eSAlan Cox 			tty->alt_speed = 230400;
13091da177e4SLinus Torvalds 		else if ((priv->flags & ASYNC_SPD_MASK) == ASYNC_SPD_WARP)
131095da310eSAlan Cox 			tty->alt_speed = 460800;
13111da177e4SLinus Torvalds 		else
131295da310eSAlan Cox 			tty->alt_speed = 0;
13131da177e4SLinus Torvalds 	}
13141da177e4SLinus Torvalds 	if (((old_priv.flags & ASYNC_SPD_MASK) !=
13151da177e4SLinus Torvalds 	     (priv->flags & ASYNC_SPD_MASK)) ||
13161da177e4SLinus Torvalds 	    (((priv->flags & ASYNC_SPD_MASK) == ASYNC_SPD_CUST) &&
13171da177e4SLinus Torvalds 	     (old_priv.custom_divisor != priv->custom_divisor))) {
131895da310eSAlan Cox 		change_speed(tty, port);
13199c67d28eSAlessio Igor Bogani 		mutex_unlock(&priv->cfg_lock);
13201da177e4SLinus Torvalds 	}
13216b447f04SAlan Cox 	else
1322bd09a9f5SAlessio Igor Bogani 		mutex_unlock(&priv->cfg_lock);
132395da310eSAlan Cox 	return 0;
1324e49bbce1SJohan Hovold }
13251da177e4SLinus Torvalds 
13261da177e4SLinus Torvalds 
13278f977e42SIan Abbott /* Determine type of FTDI chip based on USB config and descriptor. */
13288f977e42SIan Abbott static void ftdi_determine_type(struct usb_serial_port *port)
13298f977e42SIan Abbott {
13308f977e42SIan Abbott 	struct ftdi_private *priv = usb_get_serial_port_data(port);
13318f977e42SIan Abbott 	struct usb_serial *serial = port->serial;
13328f977e42SIan Abbott 	struct usb_device *udev = serial->dev;
13338f977e42SIan Abbott 	unsigned version;
13348f977e42SIan Abbott 	unsigned interfaces;
13358f977e42SIan Abbott 
13368f977e42SIan Abbott 	/* Assume it is not the original SIO device for now. */
1337f5e09b7cSIan Abbott 	priv->baud_base = 48000000 / 2;
13388f977e42SIan Abbott 
13398f977e42SIan Abbott 	version = le16_to_cpu(udev->descriptor.bcdDevice);
13408f977e42SIan Abbott 	interfaces = udev->actconfig->desc.bNumInterfaces;
1341441b62c1SHarvey Harrison 	dbg("%s: bcdDevice = 0x%x, bNumInterfaces = %u", __func__,
13428f977e42SIan Abbott 			version, interfaces);
13438f977e42SIan Abbott 	if (interfaces > 1) {
13448f977e42SIan Abbott 		int inter;
13458f977e42SIan Abbott 
1346094c2e6dSMark Adamson 		/* Multiple interfaces.*/
1347094c2e6dSMark Adamson 		if (version == 0x0800) {
1348094c2e6dSMark Adamson 			priv->chip_type = FT4232H;
1349094c2e6dSMark Adamson 			/* Hi-speed - baud clock runs at 120MHz */
1350094c2e6dSMark Adamson 			priv->baud_base = 120000000 / 2;
1351094c2e6dSMark Adamson 		} else if (version == 0x0700) {
1352094c2e6dSMark Adamson 			priv->chip_type = FT2232H;
1353094c2e6dSMark Adamson 			/* Hi-speed - baud clock runs at 120MHz */
1354094c2e6dSMark Adamson 			priv->baud_base = 120000000 / 2;
1355094c2e6dSMark Adamson 		} else
13568f977e42SIan Abbott 			priv->chip_type = FT2232C;
1357094c2e6dSMark Adamson 
13588f977e42SIan Abbott 		/* Determine interface code. */
13598f977e42SIan Abbott 		inter = serial->interface->altsetting->desc.bInterfaceNumber;
1360094c2e6dSMark Adamson 		if (inter == 0) {
1361094c2e6dSMark Adamson 			priv->interface = INTERFACE_A;
1362094c2e6dSMark Adamson 		} else  if (inter == 1) {
1363094c2e6dSMark Adamson 			priv->interface = INTERFACE_B;
1364094c2e6dSMark Adamson 		} else  if (inter == 2) {
1365094c2e6dSMark Adamson 			priv->interface = INTERFACE_C;
1366094c2e6dSMark Adamson 		} else  if (inter == 3) {
1367094c2e6dSMark Adamson 			priv->interface = INTERFACE_D;
1368094c2e6dSMark Adamson 		}
13698f977e42SIan Abbott 		/* BM-type devices have a bug where bcdDevice gets set
13708f977e42SIan Abbott 		 * to 0x200 when iSerialNumber is 0.  */
13718f977e42SIan Abbott 		if (version < 0x500) {
13728f977e42SIan Abbott 			dbg("%s: something fishy - bcdDevice too low for multi-interface device",
1373441b62c1SHarvey Harrison 					__func__);
13748f977e42SIan Abbott 		}
13758f977e42SIan Abbott 	} else if (version < 0x200) {
1376330e3c4cSAndreas Mohr 		/* Old device.  Assume it's the original SIO. */
13778f977e42SIan Abbott 		priv->chip_type = SIO;
13788f977e42SIan Abbott 		priv->baud_base = 12000000 / 16;
13798f977e42SIan Abbott 	} else if (version < 0x400) {
1380330e3c4cSAndreas Mohr 		/* Assume it's an FT8U232AM (or FT8U245AM) */
13818f977e42SIan Abbott 		/* (It might be a BM because of the iSerialNumber bug,
13828f977e42SIan Abbott 		 * but it will still work as an AM device.) */
13838f977e42SIan Abbott 		priv->chip_type = FT8U232AM;
13843b009c63SDavid Brownell 	} else if (version < 0x600) {
1385330e3c4cSAndreas Mohr 		/* Assume it's an FT232BM (or FT245BM) */
13868f977e42SIan Abbott 		priv->chip_type = FT232BM;
13873b009c63SDavid Brownell 	} else {
1388330e3c4cSAndreas Mohr 		/* Assume it's an FT232R */
13893b009c63SDavid Brownell 		priv->chip_type = FT232RL;
13908f977e42SIan Abbott 	}
1391c197a8dbSGreg Kroah-Hartman 	dev_info(&udev->dev, "Detected %s\n", ftdi_chip_name[priv->chip_type]);
13928f977e42SIan Abbott }
13938f977e42SIan Abbott 
13948f977e42SIan Abbott 
1395895f28baSMark Adamson /* Determine the maximum packet size for the device.  This depends on the chip
1396895f28baSMark Adamson  * type and the USB host capabilities.  The value should be obtained from the
1397895f28baSMark Adamson  * device descriptor as the chip will use the appropriate values for the host.*/
1398895f28baSMark Adamson static void ftdi_set_max_packet_size(struct usb_serial_port *port)
1399895f28baSMark Adamson {
1400895f28baSMark Adamson 	struct ftdi_private *priv = usb_get_serial_port_data(port);
1401895f28baSMark Adamson 	struct usb_serial *serial = port->serial;
1402895f28baSMark Adamson 	struct usb_device *udev = serial->dev;
1403895f28baSMark Adamson 
1404895f28baSMark Adamson 	struct usb_interface *interface = serial->interface;
1405895f28baSMark Adamson 	struct usb_endpoint_descriptor *ep_desc = &interface->cur_altsetting->endpoint[1].desc;
1406895f28baSMark Adamson 
1407895f28baSMark Adamson 	unsigned num_endpoints;
1408c1284d77SJohan Hovold 	int i;
1409895f28baSMark Adamson 
1410895f28baSMark Adamson 	num_endpoints = interface->cur_altsetting->desc.bNumEndpoints;
1411895f28baSMark Adamson 	dev_info(&udev->dev, "Number of endpoints %d\n", num_endpoints);
1412895f28baSMark Adamson 
1413895f28baSMark Adamson 	/* NOTE: some customers have programmed FT232R/FT245R devices
1414895f28baSMark Adamson 	 * with an endpoint size of 0 - not good.  In this case, we
1415895f28baSMark Adamson 	 * want to override the endpoint descriptor setting and use a
1416895f28baSMark Adamson 	 * value of 64 for wMaxPacketSize */
1417895f28baSMark Adamson 	for (i = 0; i < num_endpoints; i++) {
1418895f28baSMark Adamson 		dev_info(&udev->dev, "Endpoint %d MaxPacketSize %d\n", i+1,
1419895f28baSMark Adamson 			interface->cur_altsetting->endpoint[i].desc.wMaxPacketSize);
1420895f28baSMark Adamson 		ep_desc = &interface->cur_altsetting->endpoint[i].desc;
1421895f28baSMark Adamson 		if (ep_desc->wMaxPacketSize == 0) {
1422895f28baSMark Adamson 			ep_desc->wMaxPacketSize = cpu_to_le16(0x40);
1423895f28baSMark Adamson 			dev_info(&udev->dev, "Overriding wMaxPacketSize on endpoint %d\n", i);
1424895f28baSMark Adamson 		}
1425895f28baSMark Adamson 	}
1426895f28baSMark Adamson 
1427895f28baSMark Adamson 	/* set max packet size based on descriptor */
1428d1ab903dSMichael Wileczka 	priv->max_packet_size = le16_to_cpu(ep_desc->wMaxPacketSize);
1429895f28baSMark Adamson 
1430895f28baSMark Adamson 	dev_info(&udev->dev, "Setting MaxPacketSize %d\n", priv->max_packet_size);
1431895f28baSMark Adamson }
1432895f28baSMark Adamson 
1433895f28baSMark Adamson 
14341da177e4SLinus Torvalds /*
14351da177e4SLinus Torvalds  * ***************************************************************************
14361da177e4SLinus Torvalds  * Sysfs Attribute
14371da177e4SLinus Torvalds  * ***************************************************************************
14381da177e4SLinus Torvalds  */
14391da177e4SLinus Torvalds 
1440464cbb24SAlan Cox static ssize_t show_latency_timer(struct device *dev,
1441464cbb24SAlan Cox 				struct device_attribute *attr, char *buf)
14421da177e4SLinus Torvalds {
14431da177e4SLinus Torvalds 	struct usb_serial_port *port = to_usb_serial_port(dev);
14441da177e4SLinus Torvalds 	struct ftdi_private *priv = usb_get_serial_port_data(port);
1445557aaa7fSAlan Cox 	if (priv->flags & ASYNC_LOW_LATENCY)
1446557aaa7fSAlan Cox 		return sprintf(buf, "1\n");
1447557aaa7fSAlan Cox 	else
1448557aaa7fSAlan Cox 		return sprintf(buf, "%i\n", priv->latency);
14491da177e4SLinus Torvalds }
1450557aaa7fSAlan Cox 
14511da177e4SLinus Torvalds 
14521da177e4SLinus Torvalds /* Write a new value of the latency timer, in units of milliseconds. */
1453464cbb24SAlan Cox static ssize_t store_latency_timer(struct device *dev,
1454464cbb24SAlan Cox 			struct device_attribute *attr, const char *valbuf,
14551da177e4SLinus Torvalds 			size_t count)
14561da177e4SLinus Torvalds {
14571da177e4SLinus Torvalds 	struct usb_serial_port *port = to_usb_serial_port(dev);
14581da177e4SLinus Torvalds 	struct ftdi_private *priv = usb_get_serial_port_data(port);
14591da177e4SLinus Torvalds 	int v = simple_strtoul(valbuf, NULL, 10);
1460c1284d77SJohan Hovold 	int rv;
14611da177e4SLinus Torvalds 
1462557aaa7fSAlan Cox 	priv->latency = v;
1463557aaa7fSAlan Cox 	rv = write_latency_timer(port);
1464557aaa7fSAlan Cox 	if (rv < 0)
14651da177e4SLinus Torvalds 		return -EIO;
14661da177e4SLinus Torvalds 	return count;
14671da177e4SLinus Torvalds }
14681da177e4SLinus Torvalds 
14691da177e4SLinus Torvalds /* Write an event character directly to the FTDI register.  The ASCII
14701da177e4SLinus Torvalds    value is in the low 8 bits, with the enable bit in the 9th bit. */
1471464cbb24SAlan Cox static ssize_t store_event_char(struct device *dev,
1472464cbb24SAlan Cox 	struct device_attribute *attr, const char *valbuf, size_t count)
14731da177e4SLinus Torvalds {
14741da177e4SLinus Torvalds 	struct usb_serial_port *port = to_usb_serial_port(dev);
14751da177e4SLinus Torvalds 	struct ftdi_private *priv = usb_get_serial_port_data(port);
147612bdbe03SJim Radford 	struct usb_device *udev = port->serial->dev;
14771da177e4SLinus Torvalds 	int v = simple_strtoul(valbuf, NULL, 10);
1478c1284d77SJohan Hovold 	int rv;
14791da177e4SLinus Torvalds 
1480441b62c1SHarvey Harrison 	dbg("%s: setting event char = %i", __func__, v);
14811da177e4SLinus Torvalds 
14821da177e4SLinus Torvalds 	rv = usb_control_msg(udev,
14831da177e4SLinus Torvalds 			     usb_sndctrlpipe(udev, 0),
14841da177e4SLinus Torvalds 			     FTDI_SIO_SET_EVENT_CHAR_REQUEST,
14851da177e4SLinus Torvalds 			     FTDI_SIO_SET_EVENT_CHAR_REQUEST_TYPE,
14861da177e4SLinus Torvalds 			     v, priv->interface,
148766e47e60SJohan Hovold 			     NULL, 0, WDR_TIMEOUT);
14881da177e4SLinus Torvalds 	if (rv < 0) {
14891da177e4SLinus Torvalds 		dbg("Unable to write event character: %i", rv);
14901da177e4SLinus Torvalds 		return -EIO;
14911da177e4SLinus Torvalds 	}
14921da177e4SLinus Torvalds 
14931da177e4SLinus Torvalds 	return count;
14941da177e4SLinus Torvalds }
14951da177e4SLinus Torvalds 
1496464cbb24SAlan Cox static DEVICE_ATTR(latency_timer, S_IWUSR | S_IRUGO, show_latency_timer,
1497464cbb24SAlan Cox 							store_latency_timer);
14981da177e4SLinus Torvalds static DEVICE_ATTR(event_char, S_IWUSR, NULL, store_event_char);
14991da177e4SLinus Torvalds 
150012bdbe03SJim Radford static int create_sysfs_attrs(struct usb_serial_port *port)
15011da177e4SLinus Torvalds {
150212bdbe03SJim Radford 	struct ftdi_private *priv = usb_get_serial_port_data(port);
150313f4db9eSGreg Kroah-Hartman 	int retval = 0;
15041da177e4SLinus Torvalds 
1505441b62c1SHarvey Harrison 	dbg("%s", __func__);
15061da177e4SLinus Torvalds 
15071da177e4SLinus Torvalds 	/* XXX I've no idea if the original SIO supports the event_char
15081da177e4SLinus Torvalds 	 * sysfs parameter, so I'm playing it safe.  */
15091da177e4SLinus Torvalds 	if (priv->chip_type != SIO) {
15101da177e4SLinus Torvalds 		dbg("sysfs attributes for %s", ftdi_chip_name[priv->chip_type]);
151112bdbe03SJim Radford 		retval = device_create_file(&port->dev, &dev_attr_event_char);
151213f4db9eSGreg Kroah-Hartman 		if ((!retval) &&
151397cd49ebSStepan Moskovchenko 		    (priv->chip_type == FT232BM ||
151497cd49ebSStepan Moskovchenko 		     priv->chip_type == FT2232C ||
1515094c2e6dSMark Adamson 		     priv->chip_type == FT232RL ||
1516094c2e6dSMark Adamson 		     priv->chip_type == FT2232H ||
1517094c2e6dSMark Adamson 		     priv->chip_type == FT4232H)) {
151812bdbe03SJim Radford 			retval = device_create_file(&port->dev,
151913f4db9eSGreg Kroah-Hartman 						    &dev_attr_latency_timer);
15201da177e4SLinus Torvalds 		}
15211da177e4SLinus Torvalds 	}
152213f4db9eSGreg Kroah-Hartman 	return retval;
15231da177e4SLinus Torvalds }
15241da177e4SLinus Torvalds 
152512bdbe03SJim Radford static void remove_sysfs_attrs(struct usb_serial_port *port)
15261da177e4SLinus Torvalds {
152712bdbe03SJim Radford 	struct ftdi_private *priv = usb_get_serial_port_data(port);
15281da177e4SLinus Torvalds 
1529441b62c1SHarvey Harrison 	dbg("%s", __func__);
15301da177e4SLinus Torvalds 
15311da177e4SLinus Torvalds 	/* XXX see create_sysfs_attrs */
15321da177e4SLinus Torvalds 	if (priv->chip_type != SIO) {
153312bdbe03SJim Radford 		device_remove_file(&port->dev, &dev_attr_event_char);
1534ed6e5282SAndrew M. Bishop 		if (priv->chip_type == FT232BM ||
1535ed6e5282SAndrew M. Bishop 		    priv->chip_type == FT2232C ||
1536094c2e6dSMark Adamson 		    priv->chip_type == FT232RL ||
1537094c2e6dSMark Adamson 		    priv->chip_type == FT2232H ||
1538094c2e6dSMark Adamson 		    priv->chip_type == FT4232H) {
153912bdbe03SJim Radford 			device_remove_file(&port->dev, &dev_attr_latency_timer);
15401da177e4SLinus Torvalds 		}
15411da177e4SLinus Torvalds 	}
15421da177e4SLinus Torvalds 
15431da177e4SLinus Torvalds }
15441da177e4SLinus Torvalds 
15451da177e4SLinus Torvalds /*
15461da177e4SLinus Torvalds  * ***************************************************************************
15471da177e4SLinus Torvalds  * FTDI driver specific functions
15481da177e4SLinus Torvalds  * ***************************************************************************
15491da177e4SLinus Torvalds  */
15501da177e4SLinus Torvalds 
15518f977e42SIan Abbott /* Probe function to check for special devices */
1552464cbb24SAlan Cox static int ftdi_sio_probe(struct usb_serial *serial,
1553464cbb24SAlan Cox 					const struct usb_device_id *id)
15548f977e42SIan Abbott {
1555464cbb24SAlan Cox 	struct ftdi_sio_quirk *quirk =
1556464cbb24SAlan Cox 				(struct ftdi_sio_quirk *)id->driver_info;
1557fa91d43bSTony Lindgren 
1558fa91d43bSTony Lindgren 	if (quirk && quirk->probe) {
1559fa91d43bSTony Lindgren 		int ret = quirk->probe(serial);
1560fa91d43bSTony Lindgren 		if (ret != 0)
1561fa91d43bSTony Lindgren 			return ret;
1562fa91d43bSTony Lindgren 	}
1563fa91d43bSTony Lindgren 
15648f977e42SIan Abbott 	usb_set_serial_data(serial, (void *)id->driver_info);
15658f977e42SIan Abbott 
1566fa91d43bSTony Lindgren 	return 0;
15678f977e42SIan Abbott }
15688f977e42SIan Abbott 
156912bdbe03SJim Radford static int ftdi_sio_port_probe(struct usb_serial_port *port)
15701da177e4SLinus Torvalds {
15711da177e4SLinus Torvalds 	struct ftdi_private *priv;
15720ffbbe25SOliver Neukum 	struct ftdi_sio_quirk *quirk = usb_get_serial_data(port->serial);
15730ffbbe25SOliver Neukum 
15741da177e4SLinus Torvalds 
1575441b62c1SHarvey Harrison 	dbg("%s", __func__);
15761da177e4SLinus Torvalds 
157780b6ca48SEric Sesterhenn 	priv = kzalloc(sizeof(struct ftdi_private), GFP_KERNEL);
15781da177e4SLinus Torvalds 	if (!priv) {
1579194343d9SGreg Kroah-Hartman 		dev_err(&port->dev, "%s- kmalloc(%Zd) failed.\n", __func__,
1580464cbb24SAlan Cox 					sizeof(struct ftdi_private));
15811da177e4SLinus Torvalds 		return -ENOMEM;
15821da177e4SLinus Torvalds 	}
15831da177e4SLinus Torvalds 
1584c45d6320SAlan Stern 	kref_init(&priv->kref);
1585bd09a9f5SAlessio Igor Bogani 	mutex_init(&priv->cfg_lock);
15861da177e4SLinus Torvalds 	init_waitqueue_head(&priv->delta_msr_wait);
15870076b4beSJohan Hovold 
15881da177e4SLinus Torvalds 	priv->flags = ASYNC_LOW_LATENCY;
15891da177e4SLinus Torvalds 
15900ffbbe25SOliver Neukum 	if (quirk && quirk->port_probe)
15910ffbbe25SOliver Neukum 		quirk->port_probe(priv);
15920ffbbe25SOliver Neukum 
1593c4028958SDavid Howells 	priv->port = port;
159412bdbe03SJim Radford 	usb_set_serial_port_data(port, priv);
15951da177e4SLinus Torvalds 
159612bdbe03SJim Radford 	ftdi_determine_type(port);
1597895f28baSMark Adamson 	ftdi_set_max_packet_size(port);
15988c4f99cdSJohan Hovold 	if (read_latency_timer(port) < 0)
15998c4f99cdSJohan Hovold 		priv->latency = 16;
1600c19db4c9SJohan Hovold 	write_latency_timer(port);
160112bdbe03SJim Radford 	create_sysfs_attrs(port);
160212bdbe03SJim Radford 	return 0;
16031da177e4SLinus Torvalds }
16041da177e4SLinus Torvalds 
16058f977e42SIan Abbott /* Setup for the USB-UIRT device, which requires hardwired
16068f977e42SIan Abbott  * baudrate (38400 gets mapped to 312500) */
16071da177e4SLinus Torvalds /* Called from usbserial:serial_probe */
16080ffbbe25SOliver Neukum static void ftdi_USB_UIRT_setup(struct ftdi_private *priv)
16091da177e4SLinus Torvalds {
1610441b62c1SHarvey Harrison 	dbg("%s", __func__);
16111da177e4SLinus Torvalds 
16121da177e4SLinus Torvalds 	priv->flags |= ASYNC_SPD_CUST;
16131da177e4SLinus Torvalds 	priv->custom_divisor = 77;
1614669a6db1SAlan Cox 	priv->force_baud = 38400;
1615e49bbce1SJohan Hovold }
16161da177e4SLinus Torvalds 
16178f977e42SIan Abbott /* Setup for the HE-TIRA1 device, which requires hardwired
16188f977e42SIan Abbott  * baudrate (38400 gets mapped to 100000) and RTS-CTS enabled.  */
1619464cbb24SAlan Cox 
16200ffbbe25SOliver Neukum static void ftdi_HE_TIRA1_setup(struct ftdi_private *priv)
16218f977e42SIan Abbott {
1622441b62c1SHarvey Harrison 	dbg("%s", __func__);
16231da177e4SLinus Torvalds 
16241da177e4SLinus Torvalds 	priv->flags |= ASYNC_SPD_CUST;
16251da177e4SLinus Torvalds 	priv->custom_divisor = 240;
1626669a6db1SAlan Cox 	priv->force_baud = 38400;
16271da177e4SLinus Torvalds 	priv->force_rtscts = 1;
1628e49bbce1SJohan Hovold }
16291da177e4SLinus Torvalds 
1630fa91d43bSTony Lindgren /*
1631b760dac2SMartin Geleynse  * Module parameter to control latency timer for NDI FTDI-based USB devices.
1632b760dac2SMartin Geleynse  * If this value is not set in modprobe.conf.local its value will be set to 1ms.
1633b760dac2SMartin Geleynse  */
1634b760dac2SMartin Geleynse static int ndi_latency_timer = 1;
1635b760dac2SMartin Geleynse 
1636b760dac2SMartin Geleynse /* Setup for the NDI FTDI-based USB devices, which requires hardwired
1637b760dac2SMartin Geleynse  * baudrate (19200 gets mapped to 1200000).
1638b760dac2SMartin Geleynse  *
1639b760dac2SMartin Geleynse  * Called from usbserial:serial_probe.
1640b760dac2SMartin Geleynse  */
1641b760dac2SMartin Geleynse static int ftdi_NDI_device_setup(struct usb_serial *serial)
1642b760dac2SMartin Geleynse {
1643b760dac2SMartin Geleynse 	struct usb_device *udev = serial->dev;
1644b760dac2SMartin Geleynse 	int latency = ndi_latency_timer;
1645b760dac2SMartin Geleynse 
1646b760dac2SMartin Geleynse 	if (latency == 0)
1647b760dac2SMartin Geleynse 		latency = 1;
1648b760dac2SMartin Geleynse 	if (latency > 99)
1649b760dac2SMartin Geleynse 		latency = 99;
1650b760dac2SMartin Geleynse 
1651b760dac2SMartin Geleynse 	dbg("%s setting NDI device latency to %d", __func__, latency);
1652b760dac2SMartin Geleynse 	dev_info(&udev->dev, "NDI device with a latency value of %d", latency);
1653b760dac2SMartin Geleynse 
1654c1284d77SJohan Hovold 	/* FIXME: errors are not returned */
1655c1284d77SJohan Hovold 	usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
1656b760dac2SMartin Geleynse 				FTDI_SIO_SET_LATENCY_TIMER_REQUEST,
1657b760dac2SMartin Geleynse 				FTDI_SIO_SET_LATENCY_TIMER_REQUEST_TYPE,
165866e47e60SJohan Hovold 				latency, 0, NULL, 0, WDR_TIMEOUT);
1659b760dac2SMartin Geleynse 	return 0;
1660b760dac2SMartin Geleynse }
1661b760dac2SMartin Geleynse 
1662b760dac2SMartin Geleynse /*
166320734345SHarald Welte  * First port on JTAG adaptors such as Olimex arm-usb-ocd or the FIC/OpenMoko
166420734345SHarald Welte  * Neo1973 Debug Board is reserved for JTAG interface and can be accessed from
166520734345SHarald Welte  * userspace using openocd.
1666fa91d43bSTony Lindgren  */
166720734345SHarald Welte static int ftdi_jtag_probe(struct usb_serial *serial)
1668fa91d43bSTony Lindgren {
1669fa91d43bSTony Lindgren 	struct usb_device *udev = serial->dev;
1670fa91d43bSTony Lindgren 	struct usb_interface *interface = serial->interface;
1671fa91d43bSTony Lindgren 
1672441b62c1SHarvey Harrison 	dbg("%s", __func__);
1673fa91d43bSTony Lindgren 
1674fa91d43bSTony Lindgren 	if (interface == udev->actconfig->interface[0]) {
1675c197a8dbSGreg Kroah-Hartman 		dev_info(&udev->dev,
1676c197a8dbSGreg Kroah-Hartman 			 "Ignoring serial port reserved for JTAG\n");
1677fa91d43bSTony Lindgren 		return -ENODEV;
1678fa91d43bSTony Lindgren 	}
1679fa91d43bSTony Lindgren 
1680fa91d43bSTony Lindgren 	return 0;
1681fa91d43bSTony Lindgren }
16821da177e4SLinus Torvalds 
1683546d7eecSKevin Vance /*
1684546d7eecSKevin Vance  * The Matrix Orbital VK204-25-USB has an invalid IN endpoint.
1685546d7eecSKevin Vance  * We have to correct it if we want to read from it.
1686546d7eecSKevin Vance  */
1687546d7eecSKevin Vance static int ftdi_mtxorb_hack_setup(struct usb_serial *serial)
1688546d7eecSKevin Vance {
1689546d7eecSKevin Vance 	struct usb_host_endpoint *ep = serial->dev->ep_in[1];
1690546d7eecSKevin Vance 	struct usb_endpoint_descriptor *ep_desc = &ep->desc;
1691546d7eecSKevin Vance 
1692546d7eecSKevin Vance 	if (ep->enabled && ep_desc->wMaxPacketSize == 0) {
1693fd05e720SAl Viro 		ep_desc->wMaxPacketSize = cpu_to_le16(0x40);
1694c197a8dbSGreg Kroah-Hartman 		dev_info(&serial->dev->dev,
1695c197a8dbSGreg Kroah-Hartman 			 "Fixing invalid wMaxPacketSize on read pipe\n");
1696546d7eecSKevin Vance 	}
1697546d7eecSKevin Vance 
1698546d7eecSKevin Vance 	return 0;
1699546d7eecSKevin Vance }
1700546d7eecSKevin Vance 
1701c45d6320SAlan Stern static void ftdi_sio_priv_release(struct kref *k)
1702c45d6320SAlan Stern {
1703c45d6320SAlan Stern 	struct ftdi_private *priv = container_of(k, struct ftdi_private, kref);
1704c45d6320SAlan Stern 
1705c45d6320SAlan Stern 	kfree(priv);
1706c45d6320SAlan Stern }
1707c45d6320SAlan Stern 
170812bdbe03SJim Radford static int ftdi_sio_port_remove(struct usb_serial_port *port)
170912bdbe03SJim Radford {
17101da177e4SLinus Torvalds 	struct ftdi_private *priv = usb_get_serial_port_data(port);
17111da177e4SLinus Torvalds 
1712441b62c1SHarvey Harrison 	dbg("%s", __func__);
17131da177e4SLinus Torvalds 
171412bdbe03SJim Radford 	remove_sysfs_attrs(port);
17151da177e4SLinus Torvalds 
1716c45d6320SAlan Stern 	kref_put(&priv->kref, ftdi_sio_priv_release);
17171da177e4SLinus Torvalds 
171812bdbe03SJim Radford 	return 0;
171912bdbe03SJim Radford }
17201da177e4SLinus Torvalds 
1721a509a7e4SAlan Cox static int ftdi_open(struct tty_struct *tty, struct usb_serial_port *port)
1722e49bbce1SJohan Hovold {
17231da177e4SLinus Torvalds 	struct usb_device *dev = port->serial->dev;
17241da177e4SLinus Torvalds 	struct ftdi_private *priv = usb_get_serial_port_data(port);
1725c1284d77SJohan Hovold 	int result;
17261da177e4SLinus Torvalds 
1727441b62c1SHarvey Harrison 	dbg("%s", __func__);
17281da177e4SLinus Torvalds 
17291da177e4SLinus Torvalds 	/* No error checking for this (will get errors later anyway) */
17301da177e4SLinus Torvalds 	/* See ftdi_sio.h for description of what is reset */
17311da177e4SLinus Torvalds 	usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
17321da177e4SLinus Torvalds 			FTDI_SIO_RESET_REQUEST, FTDI_SIO_RESET_REQUEST_TYPE,
17331da177e4SLinus Torvalds 			FTDI_SIO_RESET_SIO,
173466e47e60SJohan Hovold 			priv->interface, NULL, 0, WDR_TIMEOUT);
17351da177e4SLinus Torvalds 
17361da177e4SLinus Torvalds 	/* Termios defaults are set by usb_serial_init. We don't change
1737c4f01240SNick Andrew 	   port->tty->termios - this would lose speed settings, etc.
17381da177e4SLinus Torvalds 	   This is same behaviour as serial.c/rs_open() - Kuba */
17391da177e4SLinus Torvalds 
17401da177e4SLinus Torvalds 	/* ftdi_set_termios  will send usb control messages */
174195da310eSAlan Cox 	if (tty)
174295da310eSAlan Cox 		ftdi_set_termios(tty, port, tty->termios);
17431da177e4SLinus Torvalds 
17441da177e4SLinus Torvalds 	/* Start reading from the device */
17451b551015SJohan Hovold 	result = usb_serial_generic_open(tty, port);
1746cc01f17dSJohan Hovold 	if (!result)
1747c45d6320SAlan Stern 		kref_get(&priv->kref);
17481da177e4SLinus Torvalds 
17491da177e4SLinus Torvalds 	return result;
1750e49bbce1SJohan Hovold }
17511da177e4SLinus Torvalds 
1752335f8514SAlan Cox static void ftdi_dtr_rts(struct usb_serial_port *port, int on)
1753335f8514SAlan Cox {
1754335f8514SAlan Cox 	struct ftdi_private *priv = usb_get_serial_port_data(port);
1755335f8514SAlan Cox 
1756335f8514SAlan Cox 	mutex_lock(&port->serial->disc_mutex);
1757335f8514SAlan Cox 	if (!port->serial->disconnected) {
1758335f8514SAlan Cox 		/* Disable flow control */
1759335f8514SAlan Cox 		if (!on && usb_control_msg(port->serial->dev,
1760335f8514SAlan Cox 			    usb_sndctrlpipe(port->serial->dev, 0),
1761335f8514SAlan Cox 			    FTDI_SIO_SET_FLOW_CTRL_REQUEST,
1762335f8514SAlan Cox 			    FTDI_SIO_SET_FLOW_CTRL_REQUEST_TYPE,
176366e47e60SJohan Hovold 			    0, priv->interface, NULL, 0,
1764335f8514SAlan Cox 			    WDR_TIMEOUT) < 0) {
1765335f8514SAlan Cox 			    dev_err(&port->dev, "error from flowcontrol urb\n");
1766335f8514SAlan Cox 		}
1767335f8514SAlan Cox 		/* drop RTS and DTR */
1768335f8514SAlan Cox 		if (on)
1769335f8514SAlan Cox 			set_mctrl(port, TIOCM_DTR | TIOCM_RTS);
1770335f8514SAlan Cox 		else
1771335f8514SAlan Cox 			clear_mctrl(port, TIOCM_DTR | TIOCM_RTS);
1772335f8514SAlan Cox 	}
1773335f8514SAlan Cox 	mutex_unlock(&port->serial->disc_mutex);
1774335f8514SAlan Cox }
17751da177e4SLinus Torvalds 
17761da177e4SLinus Torvalds /*
17771da177e4SLinus Torvalds  * usbserial:__serial_close  only calls ftdi_close if the point is open
17781da177e4SLinus Torvalds  *
17791da177e4SLinus Torvalds  *   This only gets called when it is the last close
17801da177e4SLinus Torvalds  */
1781335f8514SAlan Cox static void ftdi_close(struct usb_serial_port *port)
1782e49bbce1SJohan Hovold {
17831da177e4SLinus Torvalds 	struct ftdi_private *priv = usb_get_serial_port_data(port);
17841da177e4SLinus Torvalds 
1785441b62c1SHarvey Harrison 	dbg("%s", __func__);
17861da177e4SLinus Torvalds 
1787c23e5fc1SJohan Hovold 	usb_serial_generic_close(port);
1788c45d6320SAlan Stern 	kref_put(&priv->kref, ftdi_sio_priv_release);
1789e49bbce1SJohan Hovold }
17901da177e4SLinus Torvalds 
17911da177e4SLinus Torvalds /* The SIO requires the first byte to have:
17921da177e4SLinus Torvalds  *  B0 1
17931da177e4SLinus Torvalds  *  B1 0
17941da177e4SLinus Torvalds  *  B2..7 length of message excluding byte 0
17951da177e4SLinus Torvalds  *
17961da177e4SLinus Torvalds  * The new devices do not require this byte
17971da177e4SLinus Torvalds  */
1798d3901a06SJohan Hovold static int ftdi_prepare_write_buffer(struct usb_serial_port *port,
1799c23e5fc1SJohan Hovold 						void *dest, size_t size)
1800e49bbce1SJohan Hovold {
1801d3901a06SJohan Hovold 	struct ftdi_private *priv;
1802c23e5fc1SJohan Hovold 	int count;
1803c23e5fc1SJohan Hovold 	unsigned long flags;
18041da177e4SLinus Torvalds 
1805d3901a06SJohan Hovold 	priv = usb_get_serial_port_data(port);
18061da177e4SLinus Torvalds 
1807e8770484SJohan Hovold 	if (priv->chip_type == SIO) {
1808c23e5fc1SJohan Hovold 		unsigned char *buffer = dest;
1809c23e5fc1SJohan Hovold 		int i, len, c;
18101da177e4SLinus Torvalds 
1811c23e5fc1SJohan Hovold 		count = 0;
1812c23e5fc1SJohan Hovold 		spin_lock_irqsave(&port->lock, flags);
1813c23e5fc1SJohan Hovold 		for (i = 0; i < size - 1; i += priv->max_packet_size) {
1814c23e5fc1SJohan Hovold 			len = min_t(int, size - i, priv->max_packet_size) - 1;
1815c23e5fc1SJohan Hovold 			c = kfifo_out(&port->write_fifo, &buffer[i + 1], len);
1816c23e5fc1SJohan Hovold 			if (!c)
1817c23e5fc1SJohan Hovold 				break;
1818c1aa075aSJohan Hovold 			buffer[i] = (c << 2) + 1;
1819c23e5fc1SJohan Hovold 			count += c + 1;
18201da177e4SLinus Torvalds 		}
1821c23e5fc1SJohan Hovold 		spin_unlock_irqrestore(&port->lock, flags);
18221da177e4SLinus Torvalds 	} else {
1823c23e5fc1SJohan Hovold 		count = kfifo_out_locked(&port->write_fifo, dest, size,
1824c23e5fc1SJohan Hovold 								&port->lock);
18251da177e4SLinus Torvalds 	}
18261da177e4SLinus Torvalds 
18271da177e4SLinus Torvalds 	return count;
182895da310eSAlan Cox }
18291da177e4SLinus Torvalds 
1830166ceb69SJohan Hovold #define FTDI_RS_ERR_MASK (FTDI_RS_BI | FTDI_RS_PE | FTDI_RS_FE | FTDI_RS_OE)
1831166ceb69SJohan Hovold 
1832cc01f17dSJohan Hovold static int ftdi_process_packet(struct tty_struct *tty,
1833cc01f17dSJohan Hovold 		struct usb_serial_port *port, struct ftdi_private *priv,
1834cc01f17dSJohan Hovold 		char *packet, int len)
183595da310eSAlan Cox {
18361da177e4SLinus Torvalds 	int i;
1837cc01f17dSJohan Hovold 	char status;
1838cc01f17dSJohan Hovold 	char flag;
1839cc01f17dSJohan Hovold 	char *ch;
18401da177e4SLinus Torvalds 
1841441b62c1SHarvey Harrison 	dbg("%s - port %d", __func__, port->number);
18421da177e4SLinus Torvalds 
1843cc01f17dSJohan Hovold 	if (len < 2) {
1844cc01f17dSJohan Hovold 		dbg("malformed packet");
1845cc01f17dSJohan Hovold 		return 0;
18461da177e4SLinus Torvalds 	}
18471da177e4SLinus Torvalds 
1848464cbb24SAlan Cox 	/* Compare new line status to the old one, signal if different/
1849464cbb24SAlan Cox 	   N.B. packet may be processed more than once, but differences
1850464cbb24SAlan Cox 	   are only processed once.  */
1851cc01f17dSJohan Hovold 	status = packet[0] & FTDI_STATUS_B0_MASK;
1852cc01f17dSJohan Hovold 	if (status != priv->prev_status) {
1853cc01f17dSJohan Hovold 		priv->diff_status |= status ^ priv->prev_status;
18541da177e4SLinus Torvalds 		wake_up_interruptible(&priv->delta_msr_wait);
1855cc01f17dSJohan Hovold 		priv->prev_status = status;
18561da177e4SLinus Torvalds 	}
18571da177e4SLinus Torvalds 
1858cc01f17dSJohan Hovold 	flag = TTY_NORMAL;
1859166ceb69SJohan Hovold 	if (packet[1] & FTDI_RS_ERR_MASK) {
1860166ceb69SJohan Hovold 		/* Break takes precedence over parity, which takes precedence
1861166ceb69SJohan Hovold 		 * over framing errors */
1862cc01f17dSJohan Hovold 		if (packet[1] & FTDI_RS_BI) {
1863cc01f17dSJohan Hovold 			flag = TTY_BREAK;
186472fda3caSJason Wessel 			usb_serial_handle_break(port);
1865166ceb69SJohan Hovold 		} else if (packet[1] & FTDI_RS_PE) {
1866cc01f17dSJohan Hovold 			flag = TTY_PARITY;
1867166ceb69SJohan Hovold 		} else if (packet[1] & FTDI_RS_FE) {
1868cc01f17dSJohan Hovold 			flag = TTY_FRAME;
1869166ceb69SJohan Hovold 		}
1870166ceb69SJohan Hovold 		/* Overrun is special, not associated with a char */
1871166ceb69SJohan Hovold 		if (packet[1] & FTDI_RS_OE)
1872166ceb69SJohan Hovold 			tty_insert_flip_char(tty, 0, TTY_OVERRUN);
18731da177e4SLinus Torvalds 	}
18741da177e4SLinus Torvalds 
1875cc01f17dSJohan Hovold 	len -= 2;
1876cc01f17dSJohan Hovold 	if (!len)
1877cc01f17dSJohan Hovold 		return 0;	/* status only */
1878cc01f17dSJohan Hovold 	ch = packet + 2;
1879cc01f17dSJohan Hovold 
188049b2597aSJohan Hovold 	if (port->port.console && port->sysrq) {
1881cc01f17dSJohan Hovold 		for (i = 0; i < len; i++, ch++) {
18826ee9f4b4SDmitry Torokhov 			if (!usb_serial_handle_sysrq_char(port, *ch))
1883cc01f17dSJohan Hovold 				tty_insert_flip_char(tty, *ch, flag);
1884cc01f17dSJohan Hovold 		}
188549b2597aSJohan Hovold 	} else {
188649b2597aSJohan Hovold 		tty_insert_flip_string_fixed_flag(tty, ch, flag, len);
1887cc01f17dSJohan Hovold 	}
188849b2597aSJohan Hovold 
1889cc01f17dSJohan Hovold 	return len;
1890cc01f17dSJohan Hovold }
1891cc01f17dSJohan Hovold 
18921b551015SJohan Hovold static void ftdi_process_read_urb(struct urb *urb)
1893cc01f17dSJohan Hovold {
18941b551015SJohan Hovold 	struct usb_serial_port *port = urb->context;
1895cc01f17dSJohan Hovold 	struct tty_struct *tty;
1896cc01f17dSJohan Hovold 	struct ftdi_private *priv = usb_get_serial_port_data(port);
1897cc01f17dSJohan Hovold 	char *data = (char *)urb->transfer_buffer;
1898cc01f17dSJohan Hovold 	int i;
1899cc01f17dSJohan Hovold 	int len;
1900cc01f17dSJohan Hovold 	int count = 0;
1901cc01f17dSJohan Hovold 
1902cc01f17dSJohan Hovold 	tty = tty_port_tty_get(&port->port);
1903cc01f17dSJohan Hovold 	if (!tty)
1904cc01f17dSJohan Hovold 		return;
1905cc01f17dSJohan Hovold 
1906cc01f17dSJohan Hovold 	for (i = 0; i < urb->actual_length; i += priv->max_packet_size) {
1907cc01f17dSJohan Hovold 		len = min_t(int, urb->actual_length - i, priv->max_packet_size);
1908cc01f17dSJohan Hovold 		count += ftdi_process_packet(tty, port, priv, &data[i], len);
1909cc01f17dSJohan Hovold 	}
1910cc01f17dSJohan Hovold 
1911cc01f17dSJohan Hovold 	if (count)
19121da177e4SLinus Torvalds 		tty_flip_buffer_push(tty);
19134a90f09bSAlan Cox 	tty_kref_put(tty);
1914cc01f17dSJohan Hovold }
19151da177e4SLinus Torvalds 
191695da310eSAlan Cox static void ftdi_break_ctl(struct tty_struct *tty, int break_state)
19171da177e4SLinus Torvalds {
191895da310eSAlan Cox 	struct usb_serial_port *port = tty->driver_data;
19191da177e4SLinus Torvalds 	struct ftdi_private *priv = usb_get_serial_port_data(port);
1920c1284d77SJohan Hovold 	__u16 urb_value;
19211da177e4SLinus Torvalds 
19221da177e4SLinus Torvalds 	/* break_state = -1 to turn on break, and 0 to turn off break */
19231da177e4SLinus Torvalds 	/* see drivers/char/tty_io.c to see it used */
19241da177e4SLinus Torvalds 	/* last_set_data_urb_value NEVER has the break bit set in it */
19251da177e4SLinus Torvalds 
1926464cbb24SAlan Cox 	if (break_state)
19271da177e4SLinus Torvalds 		urb_value = priv->last_set_data_urb_value | FTDI_SIO_SET_BREAK;
1928464cbb24SAlan Cox 	else
19291da177e4SLinus Torvalds 		urb_value = priv->last_set_data_urb_value;
19301da177e4SLinus Torvalds 
1931464cbb24SAlan Cox 	if (usb_control_msg(port->serial->dev,
1932464cbb24SAlan Cox 			usb_sndctrlpipe(port->serial->dev, 0),
19331da177e4SLinus Torvalds 			FTDI_SIO_SET_DATA_REQUEST,
19341da177e4SLinus Torvalds 			FTDI_SIO_SET_DATA_REQUEST_TYPE,
19351da177e4SLinus Torvalds 			urb_value , priv->interface,
193666e47e60SJohan Hovold 			NULL, 0, WDR_TIMEOUT) < 0) {
1937194343d9SGreg Kroah-Hartman 		dev_err(&port->dev, "%s FAILED to enable/disable break state "
1938194343d9SGreg Kroah-Hartman 			"(state was %d)\n", __func__, break_state);
19391da177e4SLinus Torvalds 	}
19401da177e4SLinus Torvalds 
1941464cbb24SAlan Cox 	dbg("%s break state is %d - urb is %d", __func__,
1942464cbb24SAlan Cox 						break_state, urb_value);
19431da177e4SLinus Torvalds 
19441da177e4SLinus Torvalds }
19451da177e4SLinus Torvalds 
19461da177e4SLinus Torvalds /* old_termios contains the original termios settings and tty->termios contains
19471da177e4SLinus Torvalds  * the new setting to be used
19481da177e4SLinus Torvalds  * WARNING: set_termios calls this with old_termios in kernel space
19491da177e4SLinus Torvalds  */
195095da310eSAlan Cox static void ftdi_set_termios(struct tty_struct *tty,
195195da310eSAlan Cox 		struct usb_serial_port *port, struct ktermios *old_termios)
1952e49bbce1SJohan Hovold {
19531da177e4SLinus Torvalds 	struct usb_device *dev = port->serial->dev;
19541da177e4SLinus Torvalds 	struct ftdi_private *priv = usb_get_serial_port_data(port);
195595da310eSAlan Cox 	struct ktermios *termios = tty->termios;
1956669a6db1SAlan Cox 	unsigned int cflag = termios->c_cflag;
19571da177e4SLinus Torvalds 	__u16 urb_value; /* will hold the new flags */
19581da177e4SLinus Torvalds 
1959464cbb24SAlan Cox 	/* Added for xon/xoff support */
1960669a6db1SAlan Cox 	unsigned int iflag = termios->c_iflag;
19611da177e4SLinus Torvalds 	unsigned char vstop;
19621da177e4SLinus Torvalds 	unsigned char vstart;
19631da177e4SLinus Torvalds 
1964441b62c1SHarvey Harrison 	dbg("%s", __func__);
19651da177e4SLinus Torvalds 
1966464cbb24SAlan Cox 	/* Force baud rate if this device requires it, unless it is set to
1967464cbb24SAlan Cox 	   B0. */
1968669a6db1SAlan Cox 	if (priv->force_baud && ((termios->c_cflag & CBAUD) != B0)) {
1969441b62c1SHarvey Harrison 		dbg("%s: forcing baud rate for this device", __func__);
197095da310eSAlan Cox 		tty_encode_baud_rate(tty, priv->force_baud,
1971bd5e47ccSAndrew Morton 					priv->force_baud);
19721da177e4SLinus Torvalds 	}
19731da177e4SLinus Torvalds 
19741da177e4SLinus Torvalds 	/* Force RTS-CTS if this device requires it. */
19751da177e4SLinus Torvalds 	if (priv->force_rtscts) {
1976441b62c1SHarvey Harrison 		dbg("%s: forcing rtscts for this device", __func__);
1977669a6db1SAlan Cox 		termios->c_cflag |= CRTSCTS;
19781da177e4SLinus Torvalds 	}
19791da177e4SLinus Torvalds 
1980669a6db1SAlan Cox 	cflag = termios->c_cflag;
19811da177e4SLinus Torvalds 
19821da177e4SLinus Torvalds 	/* FIXME -For this cut I don't care if the line is really changing or
19831da177e4SLinus Torvalds 	   not  - so just do the change regardless  - should be able to
19841da177e4SLinus Torvalds 	   compare old_termios and tty->termios */
19851da177e4SLinus Torvalds 	/* NOTE These routines can get interrupted by
1986464cbb24SAlan Cox 	   ftdi_sio_read_bulk_callback  - need to examine what this means -
1987464cbb24SAlan Cox 	   don't see any problems yet */
19881da177e4SLinus Torvalds 
19891da177e4SLinus Torvalds 	/* Set number of data bits, parity, stop bits */
19901da177e4SLinus Torvalds 
19911da177e4SLinus Torvalds 	urb_value = 0;
19921da177e4SLinus Torvalds 	urb_value |= (cflag & CSTOPB ? FTDI_SIO_SET_DATA_STOP_BITS_2 :
19931da177e4SLinus Torvalds 		      FTDI_SIO_SET_DATA_STOP_BITS_1);
199438fcb830SRoland Koebler 	if (cflag & PARENB) {
199538fcb830SRoland Koebler 		if (cflag & CMSPAR)
199638fcb830SRoland Koebler 			urb_value |= cflag & PARODD ?
199738fcb830SRoland Koebler 				     FTDI_SIO_SET_DATA_PARITY_MARK :
199838fcb830SRoland Koebler 				     FTDI_SIO_SET_DATA_PARITY_SPACE;
199938fcb830SRoland Koebler 		else
200038fcb830SRoland Koebler 			urb_value |= cflag & PARODD ?
200138fcb830SRoland Koebler 				     FTDI_SIO_SET_DATA_PARITY_ODD :
200238fcb830SRoland Koebler 				     FTDI_SIO_SET_DATA_PARITY_EVEN;
200338fcb830SRoland Koebler 	} else {
200438fcb830SRoland Koebler 		urb_value |= FTDI_SIO_SET_DATA_PARITY_NONE;
200538fcb830SRoland Koebler 	}
20061da177e4SLinus Torvalds 	if (cflag & CSIZE) {
20071da177e4SLinus Torvalds 		switch (cflag & CSIZE) {
20081da177e4SLinus Torvalds 		case CS7: urb_value |= 7; dbg("Setting CS7"); break;
20091da177e4SLinus Torvalds 		case CS8: urb_value |= 8; dbg("Setting CS8"); break;
20101da177e4SLinus Torvalds 		default:
2011cabe6cc2SMark Adamson 			dev_err(&port->dev, "CSIZE was set but not CS7-CS8\n");
20121da177e4SLinus Torvalds 		}
20131da177e4SLinus Torvalds 	}
20141da177e4SLinus Torvalds 
2015464cbb24SAlan Cox 	/* This is needed by the break command since it uses the same command
2016464cbb24SAlan Cox 	   - but is or'ed with this value  */
20171da177e4SLinus Torvalds 	priv->last_set_data_urb_value = urb_value;
20181da177e4SLinus Torvalds 
20191da177e4SLinus Torvalds 	if (usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
20201da177e4SLinus Torvalds 			    FTDI_SIO_SET_DATA_REQUEST,
20211da177e4SLinus Torvalds 			    FTDI_SIO_SET_DATA_REQUEST_TYPE,
20221da177e4SLinus Torvalds 			    urb_value , priv->interface,
202366e47e60SJohan Hovold 			    NULL, 0, WDR_SHORT_TIMEOUT) < 0) {
2024194343d9SGreg Kroah-Hartman 		dev_err(&port->dev, "%s FAILED to set "
2025194343d9SGreg Kroah-Hartman 			"databits/stopbits/parity\n", __func__);
20261da177e4SLinus Torvalds 	}
20271da177e4SLinus Torvalds 
20281da177e4SLinus Torvalds 	/* Now do the baudrate */
20291da177e4SLinus Torvalds 	if ((cflag & CBAUD) == B0) {
20301da177e4SLinus Torvalds 		/* Disable flow control */
20311da177e4SLinus Torvalds 		if (usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
20321da177e4SLinus Torvalds 				    FTDI_SIO_SET_FLOW_CTRL_REQUEST,
20331da177e4SLinus Torvalds 				    FTDI_SIO_SET_FLOW_CTRL_REQUEST_TYPE,
20341da177e4SLinus Torvalds 				    0, priv->interface,
203566e47e60SJohan Hovold 				    NULL, 0, WDR_TIMEOUT) < 0) {
2036194343d9SGreg Kroah-Hartman 			dev_err(&port->dev,
2037194343d9SGreg Kroah-Hartman 				"%s error from disable flowcontrol urb\n",
2038194343d9SGreg Kroah-Hartman 				__func__);
20391da177e4SLinus Torvalds 		}
20401da177e4SLinus Torvalds 		/* Drop RTS and DTR */
204174ede0ffSIan Abbott 		clear_mctrl(port, TIOCM_DTR | TIOCM_RTS);
20421da177e4SLinus Torvalds 	} else {
20431da177e4SLinus Torvalds 		/* set the baudrate determined before */
20449c67d28eSAlessio Igor Bogani 		mutex_lock(&priv->cfg_lock);
2045464cbb24SAlan Cox 		if (change_speed(tty, port))
2046194343d9SGreg Kroah-Hartman 			dev_err(&port->dev, "%s urb failed to set baudrate\n",
2047194343d9SGreg Kroah-Hartman 				__func__);
20489c67d28eSAlessio Igor Bogani 		mutex_unlock(&priv->cfg_lock);
204972a755fcSPeter Favrholdt 		/* Ensure RTS and DTR are raised when baudrate changed from 0 */
2050464cbb24SAlan Cox 		if (!old_termios || (old_termios->c_cflag & CBAUD) == B0)
205174ede0ffSIan Abbott 			set_mctrl(port, TIOCM_DTR | TIOCM_RTS);
20521da177e4SLinus Torvalds 	}
20531da177e4SLinus Torvalds 
20541da177e4SLinus Torvalds 	/* Set flow control */
20551da177e4SLinus Torvalds 	/* Note device also supports DTR/CD (ugh) and Xon/Xoff in hardware */
20561da177e4SLinus Torvalds 	if (cflag & CRTSCTS) {
2057441b62c1SHarvey Harrison 		dbg("%s Setting to CRTSCTS flow control", __func__);
20581da177e4SLinus Torvalds 		if (usb_control_msg(dev,
20591da177e4SLinus Torvalds 				    usb_sndctrlpipe(dev, 0),
20601da177e4SLinus Torvalds 				    FTDI_SIO_SET_FLOW_CTRL_REQUEST,
20611da177e4SLinus Torvalds 				    FTDI_SIO_SET_FLOW_CTRL_REQUEST_TYPE,
20621da177e4SLinus Torvalds 				    0 , (FTDI_SIO_RTS_CTS_HS | priv->interface),
206366e47e60SJohan Hovold 				    NULL, 0, WDR_TIMEOUT) < 0) {
2064194343d9SGreg Kroah-Hartman 			dev_err(&port->dev,
2065194343d9SGreg Kroah-Hartman 				"urb failed to set to rts/cts flow control\n");
20661da177e4SLinus Torvalds 		}
20671da177e4SLinus Torvalds 
20681da177e4SLinus Torvalds 	} else {
20691da177e4SLinus Torvalds 		/*
20701da177e4SLinus Torvalds 		 * Xon/Xoff code
20711da177e4SLinus Torvalds 		 *
2072464cbb24SAlan Cox 		 * Check the IXOFF status in the iflag component of the
2073464cbb24SAlan Cox 		 * termios structure. If IXOFF is not set, the pre-xon/xoff
2074464cbb24SAlan Cox 		 * code is executed.
20751da177e4SLinus Torvalds 		 */
20761da177e4SLinus Torvalds 		if (iflag & IXOFF) {
2077464cbb24SAlan Cox 			dbg("%s  request to enable xonxoff iflag=%04x",
2078464cbb24SAlan Cox 							__func__, iflag);
2079464cbb24SAlan Cox 			/* Try to enable the XON/XOFF on the ftdi_sio
2080464cbb24SAlan Cox 			 * Set the vstart and vstop -- could have been done up
2081464cbb24SAlan Cox 			 * above where a lot of other dereferencing is done but
2082464cbb24SAlan Cox 			 * that would be very inefficient as vstart and vstop
2083464cbb24SAlan Cox 			 * are not always needed.
2084464cbb24SAlan Cox 			 */
2085669a6db1SAlan Cox 			vstart = termios->c_cc[VSTART];
2086669a6db1SAlan Cox 			vstop = termios->c_cc[VSTOP];
20871da177e4SLinus Torvalds 			urb_value = (vstop << 8) | (vstart);
20881da177e4SLinus Torvalds 
20891da177e4SLinus Torvalds 			if (usb_control_msg(dev,
20901da177e4SLinus Torvalds 					    usb_sndctrlpipe(dev, 0),
20911da177e4SLinus Torvalds 					    FTDI_SIO_SET_FLOW_CTRL_REQUEST,
20921da177e4SLinus Torvalds 					    FTDI_SIO_SET_FLOW_CTRL_REQUEST_TYPE,
20931da177e4SLinus Torvalds 					    urb_value , (FTDI_SIO_XON_XOFF_HS
20941da177e4SLinus Torvalds 							 | priv->interface),
209566e47e60SJohan Hovold 					    NULL, 0, WDR_TIMEOUT) < 0) {
2096194343d9SGreg Kroah-Hartman 				dev_err(&port->dev, "urb failed to set to "
2097194343d9SGreg Kroah-Hartman 					"xon/xoff flow control\n");
20981da177e4SLinus Torvalds 			}
20991da177e4SLinus Torvalds 		} else {
2100464cbb24SAlan Cox 			/* else clause to only run if cflag ! CRTSCTS and iflag
2101464cbb24SAlan Cox 			 * ! XOFF. CHECKME Assuming XON/XOFF handled by tty
2102464cbb24SAlan Cox 			 * stack - not by device */
2103441b62c1SHarvey Harrison 			dbg("%s Turning off hardware flow control", __func__);
21041da177e4SLinus Torvalds 			if (usb_control_msg(dev,
21051da177e4SLinus Torvalds 					    usb_sndctrlpipe(dev, 0),
21061da177e4SLinus Torvalds 					    FTDI_SIO_SET_FLOW_CTRL_REQUEST,
21071da177e4SLinus Torvalds 					    FTDI_SIO_SET_FLOW_CTRL_REQUEST_TYPE,
21081da177e4SLinus Torvalds 					    0, priv->interface,
210966e47e60SJohan Hovold 					    NULL, 0, WDR_TIMEOUT) < 0) {
2110194343d9SGreg Kroah-Hartman 				dev_err(&port->dev,
2111194343d9SGreg Kroah-Hartman 					"urb failed to clear flow control\n");
21121da177e4SLinus Torvalds 			}
21131da177e4SLinus Torvalds 		}
21141da177e4SLinus Torvalds 
21151da177e4SLinus Torvalds 	}
211695da310eSAlan Cox }
21171da177e4SLinus Torvalds 
211895da310eSAlan Cox static int ftdi_tiocmget(struct tty_struct *tty, struct file *file)
21191da177e4SLinus Torvalds {
212095da310eSAlan Cox 	struct usb_serial_port *port = tty->driver_data;
21211da177e4SLinus Torvalds 	struct ftdi_private *priv = usb_get_serial_port_data(port);
212266e47e60SJohan Hovold 	unsigned char *buf;
2123a3f8168bSJohan Hovold 	int len;
21241da177e4SLinus Torvalds 	int ret;
21251da177e4SLinus Torvalds 
2126441b62c1SHarvey Harrison 	dbg("%s TIOCMGET", __func__);
212766e47e60SJohan Hovold 
212866e47e60SJohan Hovold 	buf = kmalloc(2, GFP_KERNEL);
212966e47e60SJohan Hovold 	if (!buf)
213066e47e60SJohan Hovold 		return -ENOMEM;
2131a3f8168bSJohan Hovold 	/*
2132a3f8168bSJohan Hovold 	 * The 8U232AM returns a two byte value (the SIO a 1 byte value) in
2133a3f8168bSJohan Hovold 	 * the same format as the data returned from the in point.
2134a3f8168bSJohan Hovold 	 */
21351da177e4SLinus Torvalds 	switch (priv->chip_type) {
21361da177e4SLinus Torvalds 	case SIO:
2137a3f8168bSJohan Hovold 		len = 1;
21381da177e4SLinus Torvalds 		break;
21391da177e4SLinus Torvalds 	case FT8U232AM:
21401da177e4SLinus Torvalds 	case FT232BM:
21411da177e4SLinus Torvalds 	case FT2232C:
2142ed6e5282SAndrew M. Bishop 	case FT232RL:
2143094c2e6dSMark Adamson 	case FT2232H:
2144094c2e6dSMark Adamson 	case FT4232H:
2145a3f8168bSJohan Hovold 		len = 2;
21461da177e4SLinus Torvalds 		break;
21471da177e4SLinus Torvalds 	default:
214866e47e60SJohan Hovold 		ret = -EFAULT;
214966e47e60SJohan Hovold 		goto out;
21501da177e4SLinus Torvalds 	}
21511da177e4SLinus Torvalds 
2152a3f8168bSJohan Hovold 	ret = usb_control_msg(port->serial->dev,
2153a3f8168bSJohan Hovold 			usb_rcvctrlpipe(port->serial->dev, 0),
2154a3f8168bSJohan Hovold 			FTDI_SIO_GET_MODEM_STATUS_REQUEST,
2155a3f8168bSJohan Hovold 			FTDI_SIO_GET_MODEM_STATUS_REQUEST_TYPE,
2156a3f8168bSJohan Hovold 			0, priv->interface,
2157a3f8168bSJohan Hovold 			buf, len, WDR_TIMEOUT);
2158a3f8168bSJohan Hovold 	if (ret < 0)
2159a3f8168bSJohan Hovold 		goto out;
2160a3f8168bSJohan Hovold 
216166e47e60SJohan Hovold 	ret = (buf[0] & FTDI_SIO_DSR_MASK ? TIOCM_DSR : 0) |
21621da177e4SLinus Torvalds 		(buf[0] & FTDI_SIO_CTS_MASK ? TIOCM_CTS : 0) |
21631da177e4SLinus Torvalds 		(buf[0]  & FTDI_SIO_RI_MASK  ? TIOCM_RI  : 0) |
21641da177e4SLinus Torvalds 		(buf[0]  & FTDI_SIO_RLSD_MASK ? TIOCM_CD  : 0) |
21651da177e4SLinus Torvalds 		priv->last_dtr_rts;
216666e47e60SJohan Hovold out:
216766e47e60SJohan Hovold 	kfree(buf);
216866e47e60SJohan Hovold 	return ret;
21691da177e4SLinus Torvalds }
21701da177e4SLinus Torvalds 
217195da310eSAlan Cox static int ftdi_tiocmset(struct tty_struct *tty, struct file *file,
217295da310eSAlan Cox 			unsigned int set, unsigned int clear)
21731da177e4SLinus Torvalds {
217495da310eSAlan Cox 	struct usb_serial_port *port = tty->driver_data;
2175441b62c1SHarvey Harrison 	dbg("%s TIOCMSET", __func__);
217674ede0ffSIan Abbott 	return update_mctrl(port, set, clear);
21771da177e4SLinus Torvalds }
21781da177e4SLinus Torvalds 
2179464cbb24SAlan Cox static int ftdi_ioctl(struct tty_struct *tty, struct file *file,
2180464cbb24SAlan Cox 					unsigned int cmd, unsigned long arg)
21811da177e4SLinus Torvalds {
218295da310eSAlan Cox 	struct usb_serial_port *port = tty->driver_data;
21831da177e4SLinus Torvalds 	struct ftdi_private *priv = usb_get_serial_port_data(port);
21841da177e4SLinus Torvalds 
2185441b62c1SHarvey Harrison 	dbg("%s cmd 0x%04x", __func__, cmd);
21861da177e4SLinus Torvalds 
21871da177e4SLinus Torvalds 	/* Based on code from acm.c and others */
21881da177e4SLinus Torvalds 	switch (cmd) {
21891da177e4SLinus Torvalds 
21901da177e4SLinus Torvalds 	case TIOCGSERIAL: /* gets serial port data */
2191464cbb24SAlan Cox 		return get_serial_info(port,
2192464cbb24SAlan Cox 					(struct serial_struct __user *) arg);
21931da177e4SLinus Torvalds 
21941da177e4SLinus Torvalds 	case TIOCSSERIAL: /* sets serial port data */
2195464cbb24SAlan Cox 		return set_serial_info(tty, port,
2196464cbb24SAlan Cox 					(struct serial_struct __user *) arg);
21971da177e4SLinus Torvalds 
21981da177e4SLinus Torvalds 	/*
21991da177e4SLinus Torvalds 	 * Wait for any of the 4 modem inputs (DCD,RI,DSR,CTS) to change
22001da177e4SLinus Torvalds 	 * - mask passed in arg for lines of interest
22011da177e4SLinus Torvalds 	 *   (use |'ed TIOCM_RNG/DSR/CD/CTS for masking)
22021da177e4SLinus Torvalds 	 * Caller should use TIOCGICOUNT to see which one it was.
22030bca1b91SAlan Cox 	 * (except that the driver doesn't support it !)
22041da177e4SLinus Torvalds 	 *
22051da177e4SLinus Torvalds 	 * This code is borrowed from linux/drivers/char/serial.c
22061da177e4SLinus Torvalds 	 */
22071da177e4SLinus Torvalds 	case TIOCMIWAIT:
22081da177e4SLinus Torvalds 		while (priv != NULL) {
22091da177e4SLinus Torvalds 			interruptible_sleep_on(&priv->delta_msr_wait);
22101da177e4SLinus Torvalds 			/* see if a signal did it */
22111da177e4SLinus Torvalds 			if (signal_pending(current))
22121da177e4SLinus Torvalds 				return -ERESTARTSYS;
22131da177e4SLinus Torvalds 			else {
22141da177e4SLinus Torvalds 				char diff = priv->diff_status;
22151da177e4SLinus Torvalds 
2216464cbb24SAlan Cox 				if (diff == 0)
22171da177e4SLinus Torvalds 					return -EIO; /* no change => error */
22181da177e4SLinus Torvalds 
22191da177e4SLinus Torvalds 				/* Consume all events */
22201da177e4SLinus Torvalds 				priv->diff_status = 0;
22211da177e4SLinus Torvalds 
2222464cbb24SAlan Cox 				/* Return 0 if caller wanted to know about
2223464cbb24SAlan Cox 				   these bits */
22241da177e4SLinus Torvalds 				if (((arg & TIOCM_RNG) && (diff & FTDI_RS0_RI)) ||
22251da177e4SLinus Torvalds 				    ((arg & TIOCM_DSR) && (diff & FTDI_RS0_DSR)) ||
22261da177e4SLinus Torvalds 				    ((arg & TIOCM_CD)  && (diff & FTDI_RS0_RLSD)) ||
22271da177e4SLinus Torvalds 				    ((arg & TIOCM_CTS) && (diff & FTDI_RS0_CTS))) {
22281da177e4SLinus Torvalds 					return 0;
22291da177e4SLinus Torvalds 				}
22301da177e4SLinus Torvalds 				/*
2231464cbb24SAlan Cox 				 * Otherwise caller can't care less about what
2232464cbb24SAlan Cox 				 * happened,and so we continue to wait for more
2233464cbb24SAlan Cox 				 * events.
22341da177e4SLinus Torvalds 				 */
22351da177e4SLinus Torvalds 			}
22361da177e4SLinus Torvalds 		}
223795da310eSAlan Cox 		return 0;
22381da177e4SLinus Torvalds 	default:
22391da177e4SLinus Torvalds 		break;
22401da177e4SLinus Torvalds 	}
2241464cbb24SAlan Cox 	/* This is not necessarily an error - turns out the higher layers
2242464cbb24SAlan Cox 	 * will do some ioctls themselves (see comment above)
22431da177e4SLinus Torvalds 	 */
2244441b62c1SHarvey Harrison 	dbg("%s arg not supported - it was 0x%04x - check /usr/include/asm/ioctls.h", __func__, cmd);
224595da310eSAlan Cox 	return -ENOIOCTLCMD;
224695da310eSAlan Cox }
22471da177e4SLinus Torvalds 
22481da177e4SLinus Torvalds static int __init ftdi_init(void)
22491da177e4SLinus Torvalds {
22501da177e4SLinus Torvalds 	int retval;
22511da177e4SLinus Torvalds 
2252441b62c1SHarvey Harrison 	dbg("%s", __func__);
2253fdcb0a0fSIan Abbott 	if (vendor > 0 && product > 0) {
2254fdcb0a0fSIan Abbott 		/* Add user specified VID/PID to reserved element of table. */
2255fdcb0a0fSIan Abbott 		int i;
2256fdcb0a0fSIan Abbott 		for (i = 0; id_table_combined[i].idVendor; i++)
2257fdcb0a0fSIan Abbott 			;
2258fdcb0a0fSIan Abbott 		id_table_combined[i].match_flags = USB_DEVICE_ID_MATCH_DEVICE;
2259fdcb0a0fSIan Abbott 		id_table_combined[i].idVendor = vendor;
2260fdcb0a0fSIan Abbott 		id_table_combined[i].idProduct = product;
2261fdcb0a0fSIan Abbott 	}
22628f977e42SIan Abbott 	retval = usb_serial_register(&ftdi_sio_device);
22631da177e4SLinus Torvalds 	if (retval)
22648f977e42SIan Abbott 		goto failed_sio_register;
22651da177e4SLinus Torvalds 	retval = usb_register(&ftdi_driver);
22661da177e4SLinus Torvalds 	if (retval)
22671da177e4SLinus Torvalds 		goto failed_usb_register;
22681da177e4SLinus Torvalds 
2269c197a8dbSGreg Kroah-Hartman 	printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":"
2270c197a8dbSGreg Kroah-Hartman 	       DRIVER_DESC "\n");
22711da177e4SLinus Torvalds 	return 0;
22721da177e4SLinus Torvalds failed_usb_register:
22738f977e42SIan Abbott 	usb_serial_deregister(&ftdi_sio_device);
22748f977e42SIan Abbott failed_sio_register:
22751da177e4SLinus Torvalds 	return retval;
22761da177e4SLinus Torvalds }
22771da177e4SLinus Torvalds 
22781da177e4SLinus Torvalds static void __exit ftdi_exit(void)
22791da177e4SLinus Torvalds {
2280441b62c1SHarvey Harrison 	dbg("%s", __func__);
22811da177e4SLinus Torvalds 
22821da177e4SLinus Torvalds 	usb_deregister(&ftdi_driver);
22838f977e42SIan Abbott 	usb_serial_deregister(&ftdi_sio_device);
22841da177e4SLinus Torvalds }
22851da177e4SLinus Torvalds 
22861da177e4SLinus Torvalds 
22871da177e4SLinus Torvalds module_init(ftdi_init);
22881da177e4SLinus Torvalds module_exit(ftdi_exit);
22891da177e4SLinus Torvalds 
22901da177e4SLinus Torvalds MODULE_AUTHOR(DRIVER_AUTHOR);
22911da177e4SLinus Torvalds MODULE_DESCRIPTION(DRIVER_DESC);
22921da177e4SLinus Torvalds MODULE_LICENSE("GPL");
22931da177e4SLinus Torvalds 
22941da177e4SLinus Torvalds module_param(debug, bool, S_IRUGO | S_IWUSR);
22951da177e4SLinus Torvalds MODULE_PARM_DESC(debug, "Debug enabled or not");
2296fdcb0a0fSIan Abbott module_param(vendor, ushort, 0);
2297fdcb0a0fSIan Abbott MODULE_PARM_DESC(vendor, "User specified vendor ID (default="
2298fdcb0a0fSIan Abbott 		__MODULE_STRING(FTDI_VID)")");
2299fdcb0a0fSIan Abbott module_param(product, ushort, 0);
230068265043SPaulius Zaleckas MODULE_PARM_DESC(product, "User specified product ID");
23011da177e4SLinus Torvalds 
2302b760dac2SMartin Geleynse module_param(ndi_latency_timer, int, S_IRUGO | S_IWUSR);
2303b760dac2SMartin Geleynse MODULE_PARM_DESC(ndi_latency_timer, "NDI device latency timer override");
2304