blob: dcd0b6e05baf87d0400ea2e29a4abe1f2a5fde39 [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002/*
Andreas Mohr31844d52009-12-16 21:45:10 +01003 * Driver definitions for the FTDI USB Single Port Serial Converter -
Alan Cox464cbb22008-07-22 11:11:23 +01004 * known as FTDI_SIO (Serial Input/Output application of the chipset)
Linus Torvalds1da177e2005-04-16 15:20:36 -07005 *
Andreas Mohr31844d52009-12-16 21:45:10 +01006 * For USB vendor/product IDs (VID/PID), please see ftdi_sio_ids.h
7 *
8 *
Linus Torvalds1da177e2005-04-16 15:20:36 -07009 * The example I have is known as the USC-1000 which is available from
10 * http://www.dse.co.nz - cat no XH4214 It looks similar to this:
11 * http://www.dansdata.com/usbser.htm but I can't be sure There are other
12 * USC-1000s which don't look like my device though so beware!
13 *
Alan Cox464cbb22008-07-22 11:11:23 +010014 * The device is based on the FTDI FT8U100AX chip. It has a DB25 on one side,
Linus Torvalds1da177e2005-04-16 15:20:36 -070015 * USB on the other.
16 *
Mark Adamson094c2e62009-04-09 15:03:09 +010017 * Thanx to FTDI (http://www.ftdichip.com) for so kindly providing details
Linus Torvalds1da177e2005-04-16 15:20:36 -070018 * of the protocol required to talk to the device and ongoing assistence
19 * during development.
20 *
Alan Cox464cbb22008-07-22 11:11:23 +010021 * Bill Ryder - bryder@sgi.com formerly of Silicon Graphics, Inc.- wrote the
Linus Torvalds1da177e2005-04-16 15:20:36 -070022 * FTDI_SIO implementation.
23 *
Linus Torvalds1da177e2005-04-16 15:20:36 -070024 */
25
Linus Torvalds1da177e2005-04-16 15:20:36 -070026/* Commands */
Greg Kroah-Hartman3bb36aa2010-05-17 10:33:41 -070027#define FTDI_SIO_RESET 0 /* Reset the port */
28#define FTDI_SIO_MODEM_CTRL 1 /* Set the modem control register */
29#define FTDI_SIO_SET_FLOW_CTRL 2 /* Set flow control register */
30#define FTDI_SIO_SET_BAUD_RATE 3 /* Set baud rate */
31#define FTDI_SIO_SET_DATA 4 /* Set the data characteristics of
32 the port */
33#define FTDI_SIO_GET_MODEM_STATUS 5 /* Retrieve current value of modem
34 status register */
35#define FTDI_SIO_SET_EVENT_CHAR 6 /* Set the event character */
36#define FTDI_SIO_SET_ERROR_CHAR 7 /* Set the error character */
Linus Torvalds1da177e2005-04-16 15:20:36 -070037#define FTDI_SIO_SET_LATENCY_TIMER 9 /* Set the latency timer */
38#define FTDI_SIO_GET_LATENCY_TIMER 10 /* Get the latency timer */
39
Andreas Mohr0a2a3772010-01-17 11:45:47 +010040/* Interface indices for FT2232, FT2232H and FT4232H devices */
Mark Adamson094c2e62009-04-09 15:03:09 +010041#define INTERFACE_A 1
42#define INTERFACE_B 2
43#define INTERFACE_C 3
44#define INTERFACE_D 4
Linus Torvalds1da177e2005-04-16 15:20:36 -070045
Pawel Ludwikowe7d7fcc2009-08-27 14:15:50 +020046
47/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070048 * BmRequestType: 1100 0000b
49 * bRequest: FTDI_E2_READ
50 * wValue: 0
51 * wIndex: Address of word to read
52 * wLength: 2
53 * Data: Will return a word of data from E2Address
54 *
55 */
56
57/* Port Identifier Table */
Greg Kroah-Hartman3bb36aa2010-05-17 10:33:41 -070058#define PIT_DEFAULT 0 /* SIOA */
Linus Torvalds1da177e2005-04-16 15:20:36 -070059#define PIT_SIOA 1 /* SIOA */
60/* The device this driver is tested with one has only one port */
61#define PIT_SIOB 2 /* SIOB */
62#define PIT_PARALLEL 3 /* Parallel */
63
64/* FTDI_SIO_RESET */
65#define FTDI_SIO_RESET_REQUEST FTDI_SIO_RESET
66#define FTDI_SIO_RESET_REQUEST_TYPE 0x40
67#define FTDI_SIO_RESET_SIO 0
68#define FTDI_SIO_RESET_PURGE_RX 1
69#define FTDI_SIO_RESET_PURGE_TX 2
70
71/*
72 * BmRequestType: 0100 0000B
73 * bRequest: FTDI_SIO_RESET
Alan Cox464cbb22008-07-22 11:11:23 +010074 * wValue: Control Value
Linus Torvalds1da177e2005-04-16 15:20:36 -070075 * 0 = Reset SIO
76 * 1 = Purge RX buffer
77 * 2 = Purge TX buffer
78 * wIndex: Port
79 * wLength: 0
80 * Data: None
81 *
82 * The Reset SIO command has this effect:
83 *
84 * Sets flow control set to 'none'
85 * Event char = $0D
86 * Event trigger = disabled
87 * Purge RX buffer
88 * Purge TX buffer
89 * Clear DTR
90 * Clear RTS
91 * baud and data format not reset
92 *
93 * The Purge RX and TX buffer commands affect nothing except the buffers
94 *
95 */
96
97/* FTDI_SIO_SET_BAUDRATE */
98#define FTDI_SIO_SET_BAUDRATE_REQUEST_TYPE 0x40
99#define FTDI_SIO_SET_BAUDRATE_REQUEST 3
100
101/*
102 * BmRequestType: 0100 0000B
103 * bRequest: FTDI_SIO_SET_BAUDRATE
104 * wValue: BaudDivisor value - see below
105 * wIndex: Port
106 * wLength: 0
107 * Data: None
108 * The BaudDivisor values are calculated as follows:
Greg Kroah-Hartman3bb36aa2010-05-17 10:33:41 -0700109 * - BaseClock is either 12000000 or 48000000 depending on the device.
110 * FIXME: I wish I knew how to detect old chips to select proper base clock!
Linus Torvalds1da177e2005-04-16 15:20:36 -0700111 * - BaudDivisor is a fixed point number encoded in a funny way.
112 * (--WRONG WAY OF THINKING--)
113 * BaudDivisor is a fixed point number encoded with following bit weighs:
114 * (-2)(-1)(13..0). It is a radical with a denominator of 4, so values
115 * end with 0.0 (00...), 0.25 (10...), 0.5 (01...), and 0.75 (11...).
116 * (--THE REALITY--)
Greg Kroah-Hartman3bb36aa2010-05-17 10:33:41 -0700117 * The both-bits-set has quite different meaning from 0.75 - the chip
118 * designers have decided it to mean 0.125 instead of 0.75.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700119 * This info looked up in FTDI application note "FT8U232 DEVICES \ Data Rates
120 * and Flow Control Consideration for USB to RS232".
121 * - BaudDivisor = (BaseClock / 16) / BaudRate, where the (=) operation should
Greg Kroah-Hartman3bb36aa2010-05-17 10:33:41 -0700122 * automagically re-encode the resulting value to take fractions into
123 * consideration.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700124 * As all values are integers, some bit twiddling is in order:
125 * BaudDivisor = (BaseClock / 16 / BaudRate) |
126 * (((BaseClock / 2 / BaudRate) & 4) ? 0x4000 // 0.5
127 * : ((BaseClock / 2 / BaudRate) & 2) ? 0x8000 // 0.25
128 * : ((BaseClock / 2 / BaudRate) & 1) ? 0xc000 // 0.125
129 * : 0)
130 *
131 * For the FT232BM, a 17th divisor bit was introduced to encode the multiples
132 * of 0.125 missing from the FT8U232AM. Bits 16 to 14 are coded as follows
133 * (the first four codes are the same as for the FT8U232AM, where bit 16 is
134 * always 0):
135 * 000 - add .000 to divisor
136 * 001 - add .500 to divisor
137 * 010 - add .250 to divisor
138 * 011 - add .125 to divisor
139 * 100 - add .375 to divisor
140 * 101 - add .625 to divisor
141 * 110 - add .750 to divisor
142 * 111 - add .875 to divisor
Alan Cox464cbb22008-07-22 11:11:23 +0100143 * Bits 15 to 0 of the 17-bit divisor are placed in the urb value. Bit 16 is
Linus Torvalds1da177e2005-04-16 15:20:36 -0700144 * placed in bit 0 of the urb index.
145 *
146 * Note that there are a couple of special cases to support the highest baud
147 * rates. If the calculated divisor value is 1, this needs to be replaced with
148 * 0. Additionally for the FT232BM, if the calculated divisor value is 0x4001
149 * (1.5), this needs to be replaced with 0x0001 (1) (but this divisor value is
150 * not supported by the FT8U232AM).
151 */
152
Greg Kroah-Hartman3bb36aa2010-05-17 10:33:41 -0700153enum ftdi_chip_type {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700154 SIO = 1,
155 FT8U232AM = 2,
156 FT232BM = 3,
157 FT2232C = 4,
Gard Spreemannd8b21602007-03-05 00:03:26 +0100158 FT232RL = 5,
Mark Adamson094c2e62009-04-09 15:03:09 +0100159 FT2232H = 6,
Uwe Bonnes309427b2011-06-17 17:30:23 +0200160 FT4232H = 7,
Jim Parisdc0827c2012-03-14 17:54:25 -0400161 FT232H = 8,
162 FTX = 9,
Greg Kroah-Hartman3bb36aa2010-05-17 10:33:41 -0700163};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700164
Greg Kroah-Hartman3bb36aa2010-05-17 10:33:41 -0700165enum ftdi_sio_baudrate {
166 ftdi_sio_b300 = 0,
167 ftdi_sio_b600 = 1,
168 ftdi_sio_b1200 = 2,
169 ftdi_sio_b2400 = 3,
170 ftdi_sio_b4800 = 4,
171 ftdi_sio_b9600 = 5,
172 ftdi_sio_b19200 = 6,
173 ftdi_sio_b38400 = 7,
174 ftdi_sio_b57600 = 8,
175 ftdi_sio_b115200 = 9
176};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700177
178/*
Greg Kroah-Hartman3bb36aa2010-05-17 10:33:41 -0700179 * The ftdi_8U232AM_xxMHz_byyy constants have been removed. The encoded divisor
180 * values are calculated internally.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700181 */
Greg Kroah-Hartman3bb36aa2010-05-17 10:33:41 -0700182#define FTDI_SIO_SET_DATA_REQUEST FTDI_SIO_SET_DATA
183#define FTDI_SIO_SET_DATA_REQUEST_TYPE 0x40
184#define FTDI_SIO_SET_DATA_PARITY_NONE (0x0 << 8)
185#define FTDI_SIO_SET_DATA_PARITY_ODD (0x1 << 8)
186#define FTDI_SIO_SET_DATA_PARITY_EVEN (0x2 << 8)
187#define FTDI_SIO_SET_DATA_PARITY_MARK (0x3 << 8)
188#define FTDI_SIO_SET_DATA_PARITY_SPACE (0x4 << 8)
189#define FTDI_SIO_SET_DATA_STOP_BITS_1 (0x0 << 11)
190#define FTDI_SIO_SET_DATA_STOP_BITS_15 (0x1 << 11)
191#define FTDI_SIO_SET_DATA_STOP_BITS_2 (0x2 << 11)
192#define FTDI_SIO_SET_BREAK (0x1 << 14)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700193/* FTDI_SIO_SET_DATA */
194
195/*
Alan Cox464cbb22008-07-22 11:11:23 +0100196 * BmRequestType: 0100 0000B
Linus Torvalds1da177e2005-04-16 15:20:36 -0700197 * bRequest: FTDI_SIO_SET_DATA
198 * wValue: Data characteristics (see below)
199 * wIndex: Port
200 * wLength: 0
201 * Data: No
202 *
203 * Data characteristics
204 *
205 * B0..7 Number of data bits
206 * B8..10 Parity
207 * 0 = None
208 * 1 = Odd
209 * 2 = Even
210 * 3 = Mark
211 * 4 = Space
212 * B11..13 Stop Bits
213 * 0 = 1
214 * 1 = 1.5
215 * 2 = 2
216 * B14
217 * 1 = TX ON (break)
218 * 0 = TX OFF (normal state)
219 * B15 Reserved
220 *
221 */
222
223
224
225/* FTDI_SIO_MODEM_CTRL */
226#define FTDI_SIO_SET_MODEM_CTRL_REQUEST_TYPE 0x40
227#define FTDI_SIO_SET_MODEM_CTRL_REQUEST FTDI_SIO_MODEM_CTRL
228
Alan Cox464cbb22008-07-22 11:11:23 +0100229/*
Linus Torvalds1da177e2005-04-16 15:20:36 -0700230 * BmRequestType: 0100 0000B
231 * bRequest: FTDI_SIO_MODEM_CTRL
232 * wValue: ControlValue (see below)
233 * wIndex: Port
234 * wLength: 0
235 * Data: None
236 *
237 * NOTE: If the device is in RTS/CTS flow control, the RTS set by this
238 * command will be IGNORED without an error being returned
239 * Also - you can not set DTR and RTS with one control message
240 */
241
242#define FTDI_SIO_SET_DTR_MASK 0x1
Mathieu OTHACEHEfb571102016-02-04 19:01:27 +0100243#define FTDI_SIO_SET_DTR_HIGH ((FTDI_SIO_SET_DTR_MASK << 8) | 1)
244#define FTDI_SIO_SET_DTR_LOW ((FTDI_SIO_SET_DTR_MASK << 8) | 0)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700245#define FTDI_SIO_SET_RTS_MASK 0x2
Mathieu OTHACEHEfb571102016-02-04 19:01:27 +0100246#define FTDI_SIO_SET_RTS_HIGH ((FTDI_SIO_SET_RTS_MASK << 8) | 2)
247#define FTDI_SIO_SET_RTS_LOW ((FTDI_SIO_SET_RTS_MASK << 8) | 0)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700248
249/*
250 * ControlValue
251 * B0 DTR state
252 * 0 = reset
253 * 1 = set
254 * B1 RTS state
255 * 0 = reset
256 * 1 = set
257 * B2..7 Reserved
258 * B8 DTR state enable
259 * 0 = ignore
260 * 1 = use DTR state
261 * B9 RTS state enable
262 * 0 = ignore
263 * 1 = use RTS state
264 * B10..15 Reserved
265 */
266
267/* FTDI_SIO_SET_FLOW_CTRL */
268#define FTDI_SIO_SET_FLOW_CTRL_REQUEST_TYPE 0x40
269#define FTDI_SIO_SET_FLOW_CTRL_REQUEST FTDI_SIO_SET_FLOW_CTRL
Alan Cox464cbb22008-07-22 11:11:23 +0100270#define FTDI_SIO_DISABLE_FLOW_CTRL 0x0
Linus Torvalds1da177e2005-04-16 15:20:36 -0700271#define FTDI_SIO_RTS_CTS_HS (0x1 << 8)
272#define FTDI_SIO_DTR_DSR_HS (0x2 << 8)
273#define FTDI_SIO_XON_XOFF_HS (0x4 << 8)
274/*
275 * BmRequestType: 0100 0000b
276 * bRequest: FTDI_SIO_SET_FLOW_CTRL
277 * wValue: Xoff/Xon
Andreas Mohr0a2a3772010-01-17 11:45:47 +0100278 * wIndex: Protocol/Port - hIndex is protocol / lIndex is port
Alan Cox464cbb22008-07-22 11:11:23 +0100279 * wLength: 0
Linus Torvalds1da177e2005-04-16 15:20:36 -0700280 * Data: None
281 *
282 * hIndex protocol is:
283 * B0 Output handshaking using RTS/CTS
284 * 0 = disabled
285 * 1 = enabled
286 * B1 Output handshaking using DTR/DSR
287 * 0 = disabled
288 * 1 = enabled
289 * B2 Xon/Xoff handshaking
290 * 0 = disabled
291 * 1 = enabled
292 *
293 * A value of zero in the hIndex field disables handshaking
294 *
Greg Kroah-Hartman3bb36aa2010-05-17 10:33:41 -0700295 * If Xon/Xoff handshaking is specified, the hValue field should contain the
296 * XOFF character and the lValue field contains the XON character.
Alan Cox464cbb22008-07-22 11:11:23 +0100297 */
298
Linus Torvalds1da177e2005-04-16 15:20:36 -0700299/*
300 * FTDI_SIO_GET_LATENCY_TIMER
301 *
302 * Set the timeout interval. The FTDI collects data from the slave
303 * device, transmitting it to the host when either A) 62 bytes are
304 * received, or B) the timeout interval has elapsed and the buffer
305 * contains at least 1 byte. Setting this value to a small number
306 * can dramatically improve performance for applications which send
307 * small packets, since the default value is 16ms.
308 */
309#define FTDI_SIO_GET_LATENCY_TIMER_REQUEST FTDI_SIO_GET_LATENCY_TIMER
310#define FTDI_SIO_GET_LATENCY_TIMER_REQUEST_TYPE 0xC0
311
Alan Cox464cbb22008-07-22 11:11:23 +0100312/*
Linus Torvalds1da177e2005-04-16 15:20:36 -0700313 * BmRequestType: 1100 0000b
314 * bRequest: FTDI_SIO_GET_LATENCY_TIMER
315 * wValue: 0
316 * wIndex: Port
317 * wLength: 0
318 * Data: latency (on return)
319 */
320
Alan Cox464cbb22008-07-22 11:11:23 +0100321/*
Linus Torvalds1da177e2005-04-16 15:20:36 -0700322 * FTDI_SIO_SET_LATENCY_TIMER
323 *
324 * Set the timeout interval. The FTDI collects data from the slave
325 * device, transmitting it to the host when either A) 62 bytes are
326 * received, or B) the timeout interval has elapsed and the buffer
327 * contains at least 1 byte. Setting this value to a small number
328 * can dramatically improve performance for applications which send
329 * small packets, since the default value is 16ms.
330 */
331#define FTDI_SIO_SET_LATENCY_TIMER_REQUEST FTDI_SIO_SET_LATENCY_TIMER
332#define FTDI_SIO_SET_LATENCY_TIMER_REQUEST_TYPE 0x40
333
Alan Cox464cbb22008-07-22 11:11:23 +0100334/*
Linus Torvalds1da177e2005-04-16 15:20:36 -0700335 * BmRequestType: 0100 0000b
336 * bRequest: FTDI_SIO_SET_LATENCY_TIMER
337 * wValue: Latency (milliseconds)
338 * wIndex: Port
339 * wLength: 0
340 * Data: None
341 *
342 * wValue:
343 * B0..7 Latency timer
344 * B8..15 0
345 *
346 */
347
348/*
Alan Cox464cbb22008-07-22 11:11:23 +0100349 * FTDI_SIO_SET_EVENT_CHAR
Linus Torvalds1da177e2005-04-16 15:20:36 -0700350 *
351 * Set the special event character for the specified communications port.
352 * If the device sees this character it will immediately return the
353 * data read so far - rather than wait 40ms or until 62 bytes are read
354 * which is what normally happens.
355 */
356
357
358#define FTDI_SIO_SET_EVENT_CHAR_REQUEST FTDI_SIO_SET_EVENT_CHAR
359#define FTDI_SIO_SET_EVENT_CHAR_REQUEST_TYPE 0x40
360
361
Alan Cox464cbb22008-07-22 11:11:23 +0100362/*
Linus Torvalds1da177e2005-04-16 15:20:36 -0700363 * BmRequestType: 0100 0000b
364 * bRequest: FTDI_SIO_SET_EVENT_CHAR
365 * wValue: EventChar
366 * wIndex: Port
367 * wLength: 0
368 * Data: None
369 *
370 * wValue:
371 * B0..7 Event Character
372 * B8 Event Character Processing
373 * 0 = disabled
374 * 1 = enabled
375 * B9..15 Reserved
376 *
377 */
Alan Cox464cbb22008-07-22 11:11:23 +0100378
Linus Torvalds1da177e2005-04-16 15:20:36 -0700379/* FTDI_SIO_SET_ERROR_CHAR */
380
Greg Kroah-Hartman3bb36aa2010-05-17 10:33:41 -0700381/*
382 * Set the parity error replacement character for the specified communications
383 * port
384 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700385
Alan Cox464cbb22008-07-22 11:11:23 +0100386/*
Linus Torvalds1da177e2005-04-16 15:20:36 -0700387 * BmRequestType: 0100 0000b
388 * bRequest: FTDI_SIO_SET_EVENT_CHAR
389 * wValue: Error Char
390 * wIndex: Port
391 * wLength: 0
392 * Data: None
393 *
394 *Error Char
395 * B0..7 Error Character
396 * B8 Error Character Processing
397 * 0 = disabled
398 * 1 = enabled
399 * B9..15 Reserved
400 *
401 */
402
403/* FTDI_SIO_GET_MODEM_STATUS */
Matt Mackall4a4efbd2006-01-03 13:27:11 +0100404/* Retrieve the current value of the modem status register */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700405
406#define FTDI_SIO_GET_MODEM_STATUS_REQUEST_TYPE 0xc0
407#define FTDI_SIO_GET_MODEM_STATUS_REQUEST FTDI_SIO_GET_MODEM_STATUS
408#define FTDI_SIO_CTS_MASK 0x10
409#define FTDI_SIO_DSR_MASK 0x20
410#define FTDI_SIO_RI_MASK 0x40
411#define FTDI_SIO_RLSD_MASK 0x80
Alan Cox464cbb22008-07-22 11:11:23 +0100412/*
Linus Torvalds1da177e2005-04-16 15:20:36 -0700413 * BmRequestType: 1100 0000b
414 * bRequest: FTDI_SIO_GET_MODEM_STATUS
415 * wValue: zero
416 * wIndex: Port
417 * wLength: 1
418 * Data: Status
Alan Cox464cbb22008-07-22 11:11:23 +0100419 *
420 * One byte of data is returned
Linus Torvalds1da177e2005-04-16 15:20:36 -0700421 * B0..3 0
422 * B4 CTS
423 * 0 = inactive
424 * 1 = active
425 * B5 DSR
426 * 0 = inactive
427 * 1 = active
428 * B6 Ring Indicator (RI)
429 * 0 = inactive
430 * 1 = active
431 * B7 Receive Line Signal Detect (RLSD)
432 * 0 = inactive
Alan Cox464cbb22008-07-22 11:11:23 +0100433 * 1 = active
Linus Torvalds1da177e2005-04-16 15:20:36 -0700434 */
435
436
437
Alan Cox464cbb22008-07-22 11:11:23 +0100438/* Descriptors returned by the device
439 *
Linus Torvalds1da177e2005-04-16 15:20:36 -0700440 * Device Descriptor
Alan Cox464cbb22008-07-22 11:11:23 +0100441 *
Linus Torvalds1da177e2005-04-16 15:20:36 -0700442 * Offset Field Size Value Description
443 * 0 bLength 1 0x12 Size of descriptor in bytes
444 * 1 bDescriptorType 1 0x01 DEVICE Descriptor Type
445 * 2 bcdUSB 2 0x0110 USB Spec Release Number
446 * 4 bDeviceClass 1 0x00 Class Code
447 * 5 bDeviceSubClass 1 0x00 SubClass Code
448 * 6 bDeviceProtocol 1 0x00 Protocol Code
449 * 7 bMaxPacketSize0 1 0x08 Maximum packet size for endpoint 0
450 * 8 idVendor 2 0x0403 Vendor ID
451 * 10 idProduct 2 0x8372 Product ID (FTDI_SIO_PID)
452 * 12 bcdDevice 2 0x0001 Device release number
453 * 14 iManufacturer 1 0x01 Index of man. string desc
454 * 15 iProduct 1 0x02 Index of prod string desc
455 * 16 iSerialNumber 1 0x02 Index of serial nmr string desc
456 * 17 bNumConfigurations 1 0x01 Number of possible configurations
Alan Cox464cbb22008-07-22 11:11:23 +0100457 *
Linus Torvalds1da177e2005-04-16 15:20:36 -0700458 * Configuration Descriptor
Alan Cox464cbb22008-07-22 11:11:23 +0100459 *
Linus Torvalds1da177e2005-04-16 15:20:36 -0700460 * Offset Field Size Value
461 * 0 bLength 1 0x09 Size of descriptor in bytes
462 * 1 bDescriptorType 1 0x02 CONFIGURATION Descriptor Type
463 * 2 wTotalLength 2 0x0020 Total length of data
464 * 4 bNumInterfaces 1 0x01 Number of interfaces supported
465 * 5 bConfigurationValue 1 0x01 Argument for SetCOnfiguration() req
466 * 6 iConfiguration 1 0x02 Index of config string descriptor
467 * 7 bmAttributes 1 0x20 Config characteristics Remote Wakeup
468 * 8 MaxPower 1 0x1E Max power consumption
Alan Cox464cbb22008-07-22 11:11:23 +0100469 *
Linus Torvalds1da177e2005-04-16 15:20:36 -0700470 * Interface Descriptor
Alan Cox464cbb22008-07-22 11:11:23 +0100471 *
Linus Torvalds1da177e2005-04-16 15:20:36 -0700472 * Offset Field Size Value
473 * 0 bLength 1 0x09 Size of descriptor in bytes
474 * 1 bDescriptorType 1 0x04 INTERFACE Descriptor Type
475 * 2 bInterfaceNumber 1 0x00 Number of interface
476 * 3 bAlternateSetting 1 0x00 Value used to select alternate
477 * 4 bNumEndpoints 1 0x02 Number of endpoints
478 * 5 bInterfaceClass 1 0xFF Class Code
479 * 6 bInterfaceSubClass 1 0xFF Subclass Code
480 * 7 bInterfaceProtocol 1 0xFF Protocol Code
481 * 8 iInterface 1 0x02 Index of interface string description
Alan Cox464cbb22008-07-22 11:11:23 +0100482 *
Linus Torvalds1da177e2005-04-16 15:20:36 -0700483 * IN Endpoint Descriptor
Alan Cox464cbb22008-07-22 11:11:23 +0100484 *
Linus Torvalds1da177e2005-04-16 15:20:36 -0700485 * Offset Field Size Value
486 * 0 bLength 1 0x07 Size of descriptor in bytes
487 * 1 bDescriptorType 1 0x05 ENDPOINT descriptor type
488 * 2 bEndpointAddress 1 0x82 Address of endpoint
489 * 3 bmAttributes 1 0x02 Endpoint attributes - Bulk
490 * 4 bNumEndpoints 2 0x0040 maximum packet size
491 * 5 bInterval 1 0x00 Interval for polling endpoint
Alan Cox464cbb22008-07-22 11:11:23 +0100492 *
Linus Torvalds1da177e2005-04-16 15:20:36 -0700493 * OUT Endpoint Descriptor
Alan Cox464cbb22008-07-22 11:11:23 +0100494 *
Linus Torvalds1da177e2005-04-16 15:20:36 -0700495 * Offset Field Size Value
496 * 0 bLength 1 0x07 Size of descriptor in bytes
497 * 1 bDescriptorType 1 0x05 ENDPOINT descriptor type
498 * 2 bEndpointAddress 1 0x02 Address of endpoint
499 * 3 bmAttributes 1 0x02 Endpoint attributes - Bulk
500 * 4 bNumEndpoints 2 0x0040 maximum packet size
501 * 5 bInterval 1 0x00 Interval for polling endpoint
Alan Cox464cbb22008-07-22 11:11:23 +0100502 *
Linus Torvalds1da177e2005-04-16 15:20:36 -0700503 * DATA FORMAT
Alan Cox464cbb22008-07-22 11:11:23 +0100504 *
Linus Torvalds1da177e2005-04-16 15:20:36 -0700505 * IN Endpoint
Alan Cox464cbb22008-07-22 11:11:23 +0100506 *
Greg Kroah-Hartman3bb36aa2010-05-17 10:33:41 -0700507 * The device reserves the first two bytes of data on this endpoint to contain
508 * the current values of the modem and line status registers. In the absence of
509 * data, the device generates a message consisting of these two status bytes
510 * every 40 ms
Alan Cox464cbb22008-07-22 11:11:23 +0100511 *
Linus Torvalds1da177e2005-04-16 15:20:36 -0700512 * Byte 0: Modem Status
Alan Cox464cbb22008-07-22 11:11:23 +0100513 *
Linus Torvalds1da177e2005-04-16 15:20:36 -0700514 * Offset Description
515 * B0 Reserved - must be 1
516 * B1 Reserved - must be 0
517 * B2 Reserved - must be 0
518 * B3 Reserved - must be 0
519 * B4 Clear to Send (CTS)
520 * B5 Data Set Ready (DSR)
521 * B6 Ring Indicator (RI)
522 * B7 Receive Line Signal Detect (RLSD)
Alan Cox464cbb22008-07-22 11:11:23 +0100523 *
Linus Torvalds1da177e2005-04-16 15:20:36 -0700524 * Byte 1: Line Status
Alan Cox464cbb22008-07-22 11:11:23 +0100525 *
Linus Torvalds1da177e2005-04-16 15:20:36 -0700526 * Offset Description
527 * B0 Data Ready (DR)
528 * B1 Overrun Error (OE)
529 * B2 Parity Error (PE)
530 * B3 Framing Error (FE)
531 * B4 Break Interrupt (BI)
532 * B5 Transmitter Holding Register (THRE)
533 * B6 Transmitter Empty (TEMT)
534 * B7 Error in RCVR FIFO
Alan Cox464cbb22008-07-22 11:11:23 +0100535 *
Linus Torvalds1da177e2005-04-16 15:20:36 -0700536 */
537#define FTDI_RS0_CTS (1 << 4)
538#define FTDI_RS0_DSR (1 << 5)
539#define FTDI_RS0_RI (1 << 6)
540#define FTDI_RS0_RLSD (1 << 7)
541
Greg Kroah-Hartman3bb36aa2010-05-17 10:33:41 -0700542#define FTDI_RS_DR 1
543#define FTDI_RS_OE (1<<1)
544#define FTDI_RS_PE (1<<2)
545#define FTDI_RS_FE (1<<3)
546#define FTDI_RS_BI (1<<4)
547#define FTDI_RS_THRE (1<<5)
548#define FTDI_RS_TEMT (1<<6)
549#define FTDI_RS_FIFO (1<<7)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700550
551/*
552 * OUT Endpoint
Alan Cox464cbb22008-07-22 11:11:23 +0100553 *
Greg Kroah-Hartman3bb36aa2010-05-17 10:33:41 -0700554 * This device reserves the first bytes of data on this endpoint contain the
555 * length and port identifier of the message. For the FTDI USB Serial converter
556 * the port identifier is always 1.
Alan Cox464cbb22008-07-22 11:11:23 +0100557 *
Linus Torvalds1da177e2005-04-16 15:20:36 -0700558 * Byte 0: Line Status
Alan Cox464cbb22008-07-22 11:11:23 +0100559 *
Linus Torvalds1da177e2005-04-16 15:20:36 -0700560 * Offset Description
561 * B0 Reserved - must be 1
562 * B1 Reserved - must be 0
563 * B2..7 Length of message - (not including Byte 0)
Alan Cox464cbb22008-07-22 11:11:23 +0100564 *
Linus Torvalds1da177e2005-04-16 15:20:36 -0700565 */