ftdi_sio.h 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Driver definitions for the FTDI USB Single Port Serial Converter -
  4. * known as FTDI_SIO (Serial Input/Output application of the chipset)
  5. *
  6. * For USB vendor/product IDs (VID/PID), please see ftdi_sio_ids.h
  7. *
  8. *
  9. * 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. *
  14. * The device is based on the FTDI FT8U100AX chip. It has a DB25 on one side,
  15. * USB on the other.
  16. *
  17. * Thanx to FTDI (http://www.ftdichip.com) for so kindly providing details
  18. * of the protocol required to talk to the device and ongoing assistence
  19. * during development.
  20. *
  21. * Bill Ryder - bryder@sgi.com formerly of Silicon Graphics, Inc.- wrote the
  22. * FTDI_SIO implementation.
  23. *
  24. */
  25. /* Commands */
  26. #define FTDI_SIO_RESET 0 /* Reset the port */
  27. #define FTDI_SIO_MODEM_CTRL 1 /* Set the modem control register */
  28. #define FTDI_SIO_SET_FLOW_CTRL 2 /* Set flow control register */
  29. #define FTDI_SIO_SET_BAUD_RATE 3 /* Set baud rate */
  30. #define FTDI_SIO_SET_DATA 4 /* Set the data characteristics of
  31. the port */
  32. #define FTDI_SIO_GET_MODEM_STATUS 5 /* Retrieve current value of modem
  33. status register */
  34. #define FTDI_SIO_SET_EVENT_CHAR 6 /* Set the event character */
  35. #define FTDI_SIO_SET_ERROR_CHAR 7 /* Set the error character */
  36. #define FTDI_SIO_SET_LATENCY_TIMER 9 /* Set the latency timer */
  37. #define FTDI_SIO_GET_LATENCY_TIMER 0x0a /* Get the latency timer */
  38. #define FTDI_SIO_SET_BITMODE 0x0b /* Set bitbang mode */
  39. #define FTDI_SIO_READ_PINS 0x0c /* Read immediate value of pins */
  40. #define FTDI_SIO_READ_EEPROM 0x90 /* Read EEPROM */
  41. /* Interface indices for FT2232, FT2232H and FT4232H devices */
  42. #define INTERFACE_A 1
  43. #define INTERFACE_B 2
  44. #define INTERFACE_C 3
  45. #define INTERFACE_D 4
  46. /*
  47. * BmRequestType: 1100 0000b
  48. * bRequest: FTDI_E2_READ
  49. * wValue: 0
  50. * wIndex: Address of word to read
  51. * wLength: 2
  52. * Data: Will return a word of data from E2Address
  53. *
  54. */
  55. /* Port Identifier Table */
  56. #define PIT_DEFAULT 0 /* SIOA */
  57. #define PIT_SIOA 1 /* SIOA */
  58. /* The device this driver is tested with one has only one port */
  59. #define PIT_SIOB 2 /* SIOB */
  60. #define PIT_PARALLEL 3 /* Parallel */
  61. /* FTDI_SIO_RESET */
  62. #define FTDI_SIO_RESET_REQUEST FTDI_SIO_RESET
  63. #define FTDI_SIO_RESET_REQUEST_TYPE 0x40
  64. #define FTDI_SIO_RESET_SIO 0
  65. #define FTDI_SIO_RESET_PURGE_RX 1
  66. #define FTDI_SIO_RESET_PURGE_TX 2
  67. /*
  68. * BmRequestType: 0100 0000B
  69. * bRequest: FTDI_SIO_RESET
  70. * wValue: Control Value
  71. * 0 = Reset SIO
  72. * 1 = Purge RX buffer
  73. * 2 = Purge TX buffer
  74. * wIndex: Port
  75. * wLength: 0
  76. * Data: None
  77. *
  78. * The Reset SIO command has this effect:
  79. *
  80. * Sets flow control set to 'none'
  81. * Event char = $0D
  82. * Event trigger = disabled
  83. * Purge RX buffer
  84. * Purge TX buffer
  85. * Clear DTR
  86. * Clear RTS
  87. * baud and data format not reset
  88. *
  89. * The Purge RX and TX buffer commands affect nothing except the buffers
  90. *
  91. */
  92. /* FTDI_SIO_SET_BAUDRATE */
  93. #define FTDI_SIO_SET_BAUDRATE_REQUEST_TYPE 0x40
  94. #define FTDI_SIO_SET_BAUDRATE_REQUEST 3
  95. /*
  96. * BmRequestType: 0100 0000B
  97. * bRequest: FTDI_SIO_SET_BAUDRATE
  98. * wValue: BaudDivisor value - see below
  99. * wIndex: Port
  100. * wLength: 0
  101. * Data: None
  102. * The BaudDivisor values are calculated as follows:
  103. * - BaseClock is either 12000000 or 48000000 depending on the device.
  104. * FIXME: I wish I knew how to detect old chips to select proper base clock!
  105. * - BaudDivisor is a fixed point number encoded in a funny way.
  106. * (--WRONG WAY OF THINKING--)
  107. * BaudDivisor is a fixed point number encoded with following bit weighs:
  108. * (-2)(-1)(13..0). It is a radical with a denominator of 4, so values
  109. * end with 0.0 (00...), 0.25 (10...), 0.5 (01...), and 0.75 (11...).
  110. * (--THE REALITY--)
  111. * The both-bits-set has quite different meaning from 0.75 - the chip
  112. * designers have decided it to mean 0.125 instead of 0.75.
  113. * This info looked up in FTDI application note "FT8U232 DEVICES \ Data Rates
  114. * and Flow Control Consideration for USB to RS232".
  115. * - BaudDivisor = (BaseClock / 16) / BaudRate, where the (=) operation should
  116. * automagically re-encode the resulting value to take fractions into
  117. * consideration.
  118. * As all values are integers, some bit twiddling is in order:
  119. * BaudDivisor = (BaseClock / 16 / BaudRate) |
  120. * (((BaseClock / 2 / BaudRate) & 4) ? 0x4000 // 0.5
  121. * : ((BaseClock / 2 / BaudRate) & 2) ? 0x8000 // 0.25
  122. * : ((BaseClock / 2 / BaudRate) & 1) ? 0xc000 // 0.125
  123. * : 0)
  124. *
  125. * For the FT232BM, a 17th divisor bit was introduced to encode the multiples
  126. * of 0.125 missing from the FT8U232AM. Bits 16 to 14 are coded as follows
  127. * (the first four codes are the same as for the FT8U232AM, where bit 16 is
  128. * always 0):
  129. * 000 - add .000 to divisor
  130. * 001 - add .500 to divisor
  131. * 010 - add .250 to divisor
  132. * 011 - add .125 to divisor
  133. * 100 - add .375 to divisor
  134. * 101 - add .625 to divisor
  135. * 110 - add .750 to divisor
  136. * 111 - add .875 to divisor
  137. * Bits 15 to 0 of the 17-bit divisor are placed in the urb value. Bit 16 is
  138. * placed in bit 0 of the urb index.
  139. *
  140. * Note that there are a couple of special cases to support the highest baud
  141. * rates. If the calculated divisor value is 1, this needs to be replaced with
  142. * 0. Additionally for the FT232BM, if the calculated divisor value is 0x4001
  143. * (1.5), this needs to be replaced with 0x0001 (1) (but this divisor value is
  144. * not supported by the FT8U232AM).
  145. */
  146. enum ftdi_chip_type {
  147. SIO = 1,
  148. FT8U232AM = 2,
  149. FT232BM = 3,
  150. FT2232C = 4,
  151. FT232RL = 5,
  152. FT2232H = 6,
  153. FT4232H = 7,
  154. FT232H = 8,
  155. FTX = 9,
  156. };
  157. enum ftdi_sio_baudrate {
  158. ftdi_sio_b300 = 0,
  159. ftdi_sio_b600 = 1,
  160. ftdi_sio_b1200 = 2,
  161. ftdi_sio_b2400 = 3,
  162. ftdi_sio_b4800 = 4,
  163. ftdi_sio_b9600 = 5,
  164. ftdi_sio_b19200 = 6,
  165. ftdi_sio_b38400 = 7,
  166. ftdi_sio_b57600 = 8,
  167. ftdi_sio_b115200 = 9
  168. };
  169. /*
  170. * The ftdi_8U232AM_xxMHz_byyy constants have been removed. The encoded divisor
  171. * values are calculated internally.
  172. */
  173. #define FTDI_SIO_SET_DATA_REQUEST FTDI_SIO_SET_DATA
  174. #define FTDI_SIO_SET_DATA_REQUEST_TYPE 0x40
  175. #define FTDI_SIO_SET_DATA_PARITY_NONE (0x0 << 8)
  176. #define FTDI_SIO_SET_DATA_PARITY_ODD (0x1 << 8)
  177. #define FTDI_SIO_SET_DATA_PARITY_EVEN (0x2 << 8)
  178. #define FTDI_SIO_SET_DATA_PARITY_MARK (0x3 << 8)
  179. #define FTDI_SIO_SET_DATA_PARITY_SPACE (0x4 << 8)
  180. #define FTDI_SIO_SET_DATA_STOP_BITS_1 (0x0 << 11)
  181. #define FTDI_SIO_SET_DATA_STOP_BITS_15 (0x1 << 11)
  182. #define FTDI_SIO_SET_DATA_STOP_BITS_2 (0x2 << 11)
  183. #define FTDI_SIO_SET_BREAK (0x1 << 14)
  184. /* FTDI_SIO_SET_DATA */
  185. /*
  186. * BmRequestType: 0100 0000B
  187. * bRequest: FTDI_SIO_SET_DATA
  188. * wValue: Data characteristics (see below)
  189. * wIndex: Port
  190. * wLength: 0
  191. * Data: No
  192. *
  193. * Data characteristics
  194. *
  195. * B0..7 Number of data bits
  196. * B8..10 Parity
  197. * 0 = None
  198. * 1 = Odd
  199. * 2 = Even
  200. * 3 = Mark
  201. * 4 = Space
  202. * B11..13 Stop Bits
  203. * 0 = 1
  204. * 1 = 1.5
  205. * 2 = 2
  206. * B14
  207. * 1 = TX ON (break)
  208. * 0 = TX OFF (normal state)
  209. * B15 Reserved
  210. *
  211. */
  212. /* FTDI_SIO_MODEM_CTRL */
  213. #define FTDI_SIO_SET_MODEM_CTRL_REQUEST_TYPE 0x40
  214. #define FTDI_SIO_SET_MODEM_CTRL_REQUEST FTDI_SIO_MODEM_CTRL
  215. /*
  216. * BmRequestType: 0100 0000B
  217. * bRequest: FTDI_SIO_MODEM_CTRL
  218. * wValue: ControlValue (see below)
  219. * wIndex: Port
  220. * wLength: 0
  221. * Data: None
  222. *
  223. * NOTE: If the device is in RTS/CTS flow control, the RTS set by this
  224. * command will be IGNORED without an error being returned
  225. * Also - you can not set DTR and RTS with one control message
  226. */
  227. #define FTDI_SIO_SET_DTR_MASK 0x1
  228. #define FTDI_SIO_SET_DTR_HIGH ((FTDI_SIO_SET_DTR_MASK << 8) | 1)
  229. #define FTDI_SIO_SET_DTR_LOW ((FTDI_SIO_SET_DTR_MASK << 8) | 0)
  230. #define FTDI_SIO_SET_RTS_MASK 0x2
  231. #define FTDI_SIO_SET_RTS_HIGH ((FTDI_SIO_SET_RTS_MASK << 8) | 2)
  232. #define FTDI_SIO_SET_RTS_LOW ((FTDI_SIO_SET_RTS_MASK << 8) | 0)
  233. /*
  234. * ControlValue
  235. * B0 DTR state
  236. * 0 = reset
  237. * 1 = set
  238. * B1 RTS state
  239. * 0 = reset
  240. * 1 = set
  241. * B2..7 Reserved
  242. * B8 DTR state enable
  243. * 0 = ignore
  244. * 1 = use DTR state
  245. * B9 RTS state enable
  246. * 0 = ignore
  247. * 1 = use RTS state
  248. * B10..15 Reserved
  249. */
  250. /* FTDI_SIO_SET_FLOW_CTRL */
  251. #define FTDI_SIO_SET_FLOW_CTRL_REQUEST_TYPE 0x40
  252. #define FTDI_SIO_SET_FLOW_CTRL_REQUEST FTDI_SIO_SET_FLOW_CTRL
  253. #define FTDI_SIO_DISABLE_FLOW_CTRL 0x0
  254. #define FTDI_SIO_RTS_CTS_HS (0x1 << 8)
  255. #define FTDI_SIO_DTR_DSR_HS (0x2 << 8)
  256. #define FTDI_SIO_XON_XOFF_HS (0x4 << 8)
  257. /*
  258. * BmRequestType: 0100 0000b
  259. * bRequest: FTDI_SIO_SET_FLOW_CTRL
  260. * wValue: Xoff/Xon
  261. * wIndex: Protocol/Port - hIndex is protocol / lIndex is port
  262. * wLength: 0
  263. * Data: None
  264. *
  265. * hIndex protocol is:
  266. * B0 Output handshaking using RTS/CTS
  267. * 0 = disabled
  268. * 1 = enabled
  269. * B1 Output handshaking using DTR/DSR
  270. * 0 = disabled
  271. * 1 = enabled
  272. * B2 Xon/Xoff handshaking
  273. * 0 = disabled
  274. * 1 = enabled
  275. *
  276. * A value of zero in the hIndex field disables handshaking
  277. *
  278. * If Xon/Xoff handshaking is specified, the hValue field should contain the
  279. * XOFF character and the lValue field contains the XON character.
  280. */
  281. /*
  282. * FTDI_SIO_GET_LATENCY_TIMER
  283. *
  284. * Set the timeout interval. The FTDI collects data from the slave
  285. * device, transmitting it to the host when either A) 62 bytes are
  286. * received, or B) the timeout interval has elapsed and the buffer
  287. * contains at least 1 byte. Setting this value to a small number
  288. * can dramatically improve performance for applications which send
  289. * small packets, since the default value is 16ms.
  290. */
  291. #define FTDI_SIO_GET_LATENCY_TIMER_REQUEST FTDI_SIO_GET_LATENCY_TIMER
  292. #define FTDI_SIO_GET_LATENCY_TIMER_REQUEST_TYPE 0xC0
  293. /*
  294. * BmRequestType: 1100 0000b
  295. * bRequest: FTDI_SIO_GET_LATENCY_TIMER
  296. * wValue: 0
  297. * wIndex: Port
  298. * wLength: 0
  299. * Data: latency (on return)
  300. */
  301. /*
  302. * FTDI_SIO_SET_LATENCY_TIMER
  303. *
  304. * Set the timeout interval. The FTDI collects data from the slave
  305. * device, transmitting it to the host when either A) 62 bytes are
  306. * received, or B) the timeout interval has elapsed and the buffer
  307. * contains at least 1 byte. Setting this value to a small number
  308. * can dramatically improve performance for applications which send
  309. * small packets, since the default value is 16ms.
  310. */
  311. #define FTDI_SIO_SET_LATENCY_TIMER_REQUEST FTDI_SIO_SET_LATENCY_TIMER
  312. #define FTDI_SIO_SET_LATENCY_TIMER_REQUEST_TYPE 0x40
  313. /*
  314. * BmRequestType: 0100 0000b
  315. * bRequest: FTDI_SIO_SET_LATENCY_TIMER
  316. * wValue: Latency (milliseconds)
  317. * wIndex: Port
  318. * wLength: 0
  319. * Data: None
  320. *
  321. * wValue:
  322. * B0..7 Latency timer
  323. * B8..15 0
  324. *
  325. */
  326. /*
  327. * FTDI_SIO_SET_EVENT_CHAR
  328. *
  329. * Set the special event character for the specified communications port.
  330. * If the device sees this character it will immediately return the
  331. * data read so far - rather than wait 40ms or until 62 bytes are read
  332. * which is what normally happens.
  333. */
  334. #define FTDI_SIO_SET_EVENT_CHAR_REQUEST FTDI_SIO_SET_EVENT_CHAR
  335. #define FTDI_SIO_SET_EVENT_CHAR_REQUEST_TYPE 0x40
  336. /*
  337. * BmRequestType: 0100 0000b
  338. * bRequest: FTDI_SIO_SET_EVENT_CHAR
  339. * wValue: EventChar
  340. * wIndex: Port
  341. * wLength: 0
  342. * Data: None
  343. *
  344. * wValue:
  345. * B0..7 Event Character
  346. * B8 Event Character Processing
  347. * 0 = disabled
  348. * 1 = enabled
  349. * B9..15 Reserved
  350. *
  351. */
  352. /* FTDI_SIO_SET_ERROR_CHAR */
  353. /*
  354. * Set the parity error replacement character for the specified communications
  355. * port
  356. */
  357. /*
  358. * BmRequestType: 0100 0000b
  359. * bRequest: FTDI_SIO_SET_EVENT_CHAR
  360. * wValue: Error Char
  361. * wIndex: Port
  362. * wLength: 0
  363. * Data: None
  364. *
  365. *Error Char
  366. * B0..7 Error Character
  367. * B8 Error Character Processing
  368. * 0 = disabled
  369. * 1 = enabled
  370. * B9..15 Reserved
  371. *
  372. */
  373. /* FTDI_SIO_GET_MODEM_STATUS */
  374. /* Retrieve the current value of the modem status register */
  375. #define FTDI_SIO_GET_MODEM_STATUS_REQUEST_TYPE 0xc0
  376. #define FTDI_SIO_GET_MODEM_STATUS_REQUEST FTDI_SIO_GET_MODEM_STATUS
  377. #define FTDI_SIO_CTS_MASK 0x10
  378. #define FTDI_SIO_DSR_MASK 0x20
  379. #define FTDI_SIO_RI_MASK 0x40
  380. #define FTDI_SIO_RLSD_MASK 0x80
  381. /*
  382. * BmRequestType: 1100 0000b
  383. * bRequest: FTDI_SIO_GET_MODEM_STATUS
  384. * wValue: zero
  385. * wIndex: Port
  386. * wLength: 1
  387. * Data: Status
  388. *
  389. * One byte of data is returned
  390. * B0..3 0
  391. * B4 CTS
  392. * 0 = inactive
  393. * 1 = active
  394. * B5 DSR
  395. * 0 = inactive
  396. * 1 = active
  397. * B6 Ring Indicator (RI)
  398. * 0 = inactive
  399. * 1 = active
  400. * B7 Receive Line Signal Detect (RLSD)
  401. * 0 = inactive
  402. * 1 = active
  403. */
  404. /* FTDI_SIO_SET_BITMODE */
  405. #define FTDI_SIO_SET_BITMODE_REQUEST_TYPE 0x40
  406. #define FTDI_SIO_SET_BITMODE_REQUEST FTDI_SIO_SET_BITMODE
  407. /* Possible bitmodes for FTDI_SIO_SET_BITMODE_REQUEST */
  408. #define FTDI_SIO_BITMODE_RESET 0x00
  409. #define FTDI_SIO_BITMODE_CBUS 0x20
  410. /* FTDI_SIO_READ_PINS */
  411. #define FTDI_SIO_READ_PINS_REQUEST_TYPE 0xc0
  412. #define FTDI_SIO_READ_PINS_REQUEST FTDI_SIO_READ_PINS
  413. /*
  414. * FTDI_SIO_READ_EEPROM
  415. *
  416. * EEPROM format found in FTDI AN_201, "FT-X MTP memory Configuration",
  417. * http://www.ftdichip.com/Support/Documents/AppNotes/AN_201_FT-X%20MTP%20Memory%20Configuration.pdf
  418. */
  419. #define FTDI_SIO_READ_EEPROM_REQUEST_TYPE 0xc0
  420. #define FTDI_SIO_READ_EEPROM_REQUEST FTDI_SIO_READ_EEPROM
  421. #define FTDI_FTX_CBUS_MUX_GPIO 0x8
  422. #define FTDI_FT232R_CBUS_MUX_GPIO 0xa
  423. /* Descriptors returned by the device
  424. *
  425. * Device Descriptor
  426. *
  427. * Offset Field Size Value Description
  428. * 0 bLength 1 0x12 Size of descriptor in bytes
  429. * 1 bDescriptorType 1 0x01 DEVICE Descriptor Type
  430. * 2 bcdUSB 2 0x0110 USB Spec Release Number
  431. * 4 bDeviceClass 1 0x00 Class Code
  432. * 5 bDeviceSubClass 1 0x00 SubClass Code
  433. * 6 bDeviceProtocol 1 0x00 Protocol Code
  434. * 7 bMaxPacketSize0 1 0x08 Maximum packet size for endpoint 0
  435. * 8 idVendor 2 0x0403 Vendor ID
  436. * 10 idProduct 2 0x8372 Product ID (FTDI_SIO_PID)
  437. * 12 bcdDevice 2 0x0001 Device release number
  438. * 14 iManufacturer 1 0x01 Index of man. string desc
  439. * 15 iProduct 1 0x02 Index of prod string desc
  440. * 16 iSerialNumber 1 0x02 Index of serial nmr string desc
  441. * 17 bNumConfigurations 1 0x01 Number of possible configurations
  442. *
  443. * Configuration Descriptor
  444. *
  445. * Offset Field Size Value
  446. * 0 bLength 1 0x09 Size of descriptor in bytes
  447. * 1 bDescriptorType 1 0x02 CONFIGURATION Descriptor Type
  448. * 2 wTotalLength 2 0x0020 Total length of data
  449. * 4 bNumInterfaces 1 0x01 Number of interfaces supported
  450. * 5 bConfigurationValue 1 0x01 Argument for SetCOnfiguration() req
  451. * 6 iConfiguration 1 0x02 Index of config string descriptor
  452. * 7 bmAttributes 1 0x20 Config characteristics Remote Wakeup
  453. * 8 MaxPower 1 0x1E Max power consumption
  454. *
  455. * Interface Descriptor
  456. *
  457. * Offset Field Size Value
  458. * 0 bLength 1 0x09 Size of descriptor in bytes
  459. * 1 bDescriptorType 1 0x04 INTERFACE Descriptor Type
  460. * 2 bInterfaceNumber 1 0x00 Number of interface
  461. * 3 bAlternateSetting 1 0x00 Value used to select alternate
  462. * 4 bNumEndpoints 1 0x02 Number of endpoints
  463. * 5 bInterfaceClass 1 0xFF Class Code
  464. * 6 bInterfaceSubClass 1 0xFF Subclass Code
  465. * 7 bInterfaceProtocol 1 0xFF Protocol Code
  466. * 8 iInterface 1 0x02 Index of interface string description
  467. *
  468. * IN Endpoint Descriptor
  469. *
  470. * Offset Field Size Value
  471. * 0 bLength 1 0x07 Size of descriptor in bytes
  472. * 1 bDescriptorType 1 0x05 ENDPOINT descriptor type
  473. * 2 bEndpointAddress 1 0x82 Address of endpoint
  474. * 3 bmAttributes 1 0x02 Endpoint attributes - Bulk
  475. * 4 bNumEndpoints 2 0x0040 maximum packet size
  476. * 5 bInterval 1 0x00 Interval for polling endpoint
  477. *
  478. * OUT Endpoint Descriptor
  479. *
  480. * Offset Field Size Value
  481. * 0 bLength 1 0x07 Size of descriptor in bytes
  482. * 1 bDescriptorType 1 0x05 ENDPOINT descriptor type
  483. * 2 bEndpointAddress 1 0x02 Address of endpoint
  484. * 3 bmAttributes 1 0x02 Endpoint attributes - Bulk
  485. * 4 bNumEndpoints 2 0x0040 maximum packet size
  486. * 5 bInterval 1 0x00 Interval for polling endpoint
  487. *
  488. * DATA FORMAT
  489. *
  490. * IN Endpoint
  491. *
  492. * The device reserves the first two bytes of data on this endpoint to contain
  493. * the current values of the modem and line status registers. In the absence of
  494. * data, the device generates a message consisting of these two status bytes
  495. * every 40 ms
  496. *
  497. * Byte 0: Modem Status
  498. *
  499. * Offset Description
  500. * B0 Reserved - must be 1
  501. * B1 Reserved - must be 0
  502. * B2 Reserved - must be 0
  503. * B3 Reserved - must be 0
  504. * B4 Clear to Send (CTS)
  505. * B5 Data Set Ready (DSR)
  506. * B6 Ring Indicator (RI)
  507. * B7 Receive Line Signal Detect (RLSD)
  508. *
  509. * Byte 1: Line Status
  510. *
  511. * Offset Description
  512. * B0 Data Ready (DR)
  513. * B1 Overrun Error (OE)
  514. * B2 Parity Error (PE)
  515. * B3 Framing Error (FE)
  516. * B4 Break Interrupt (BI)
  517. * B5 Transmitter Holding Register (THRE)
  518. * B6 Transmitter Empty (TEMT)
  519. * B7 Error in RCVR FIFO
  520. *
  521. */
  522. #define FTDI_RS0_CTS (1 << 4)
  523. #define FTDI_RS0_DSR (1 << 5)
  524. #define FTDI_RS0_RI (1 << 6)
  525. #define FTDI_RS0_RLSD (1 << 7)
  526. #define FTDI_RS_DR 1
  527. #define FTDI_RS_OE (1<<1)
  528. #define FTDI_RS_PE (1<<2)
  529. #define FTDI_RS_FE (1<<3)
  530. #define FTDI_RS_BI (1<<4)
  531. #define FTDI_RS_THRE (1<<5)
  532. #define FTDI_RS_TEMT (1<<6)
  533. #define FTDI_RS_FIFO (1<<7)
  534. /*
  535. * OUT Endpoint
  536. *
  537. * This device reserves the first bytes of data on this endpoint contain the
  538. * length and port identifier of the message. For the FTDI USB Serial converter
  539. * the port identifier is always 1.
  540. *
  541. * Byte 0: Line Status
  542. *
  543. * Offset Description
  544. * B0 Reserved - must be 1
  545. * B1 Reserved - must be 0
  546. * B2..7 Length of message - (not including Byte 0)
  547. *
  548. */