Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /*
0003  * Driver definitions for the FTDI USB Single Port Serial Converter -
0004  * known as FTDI_SIO (Serial Input/Output application of the chipset)
0005  *
0006  * For USB vendor/product IDs (VID/PID), please see ftdi_sio_ids.h
0007  *
0008  *
0009  * The example I have is known as the USC-1000 which is available from
0010  * http://www.dse.co.nz - cat no XH4214 It looks similar to this:
0011  * http://www.dansdata.com/usbser.htm but I can't be sure There are other
0012  * USC-1000s which don't look like my device though so beware!
0013  *
0014  * The device is based on the FTDI FT8U100AX chip. It has a DB25 on one side,
0015  * USB on the other.
0016  *
0017  * Thanx to FTDI (http://www.ftdichip.com) for so kindly providing details
0018  * of the protocol required to talk to the device and ongoing assistence
0019  * during development.
0020  *
0021  * Bill Ryder - bryder@sgi.com formerly of Silicon Graphics, Inc.- wrote the
0022  * FTDI_SIO implementation.
0023  *
0024  */
0025 
0026 /* Commands */
0027 #define FTDI_SIO_RESET          0 /* Reset the port */
0028 #define FTDI_SIO_MODEM_CTRL     1 /* Set the modem control register */
0029 #define FTDI_SIO_SET_FLOW_CTRL      2 /* Set flow control register */
0030 #define FTDI_SIO_SET_BAUD_RATE      3 /* Set baud rate */
0031 #define FTDI_SIO_SET_DATA       4 /* Set the data characteristics of
0032                          the port */
0033 #define FTDI_SIO_GET_MODEM_STATUS   5 /* Retrieve current value of modem
0034                          status register */
0035 #define FTDI_SIO_SET_EVENT_CHAR     6 /* Set the event character */
0036 #define FTDI_SIO_SET_ERROR_CHAR     7 /* Set the error character */
0037 #define FTDI_SIO_SET_LATENCY_TIMER  9 /* Set the latency timer */
0038 #define FTDI_SIO_GET_LATENCY_TIMER  0x0a /* Get the latency timer */
0039 #define FTDI_SIO_SET_BITMODE        0x0b /* Set bitbang mode */
0040 #define FTDI_SIO_READ_PINS      0x0c /* Read immediate value of pins */
0041 #define FTDI_SIO_READ_EEPROM        0x90 /* Read EEPROM */
0042 
0043 /* Interface indices for FT2232, FT2232H and FT4232H devices */
0044 #define INTERFACE_A     1
0045 #define INTERFACE_B     2
0046 #define INTERFACE_C     3
0047 #define INTERFACE_D     4
0048 
0049 
0050 /*
0051  *   BmRequestType:  1100 0000b
0052  *   bRequest:       FTDI_E2_READ
0053  *   wValue:         0
0054  *   wIndex:         Address of word to read
0055  *   wLength:        2
0056  *   Data:           Will return a word of data from E2Address
0057  *
0058  */
0059 
0060 /* Port Identifier Table */
0061 #define PIT_DEFAULT     0 /* SIOA */
0062 #define PIT_SIOA        1 /* SIOA */
0063 /* The device this driver is tested with one has only one port */
0064 #define PIT_SIOB        2 /* SIOB */
0065 #define PIT_PARALLEL        3 /* Parallel */
0066 
0067 /* FTDI_SIO_RESET */
0068 #define FTDI_SIO_RESET_REQUEST FTDI_SIO_RESET
0069 #define FTDI_SIO_RESET_REQUEST_TYPE 0x40
0070 #define FTDI_SIO_RESET_SIO 0
0071 #define FTDI_SIO_RESET_PURGE_RX 1
0072 #define FTDI_SIO_RESET_PURGE_TX 2
0073 
0074 /*
0075  * BmRequestType:  0100 0000B
0076  * bRequest:       FTDI_SIO_RESET
0077  * wValue:         Control Value
0078  *                   0 = Reset SIO
0079  *                   1 = Purge RX buffer
0080  *                   2 = Purge TX buffer
0081  * wIndex:         Port
0082  * wLength:        0
0083  * Data:           None
0084  *
0085  * The Reset SIO command has this effect:
0086  *
0087  *    Sets flow control set to 'none'
0088  *    Event char = $0D
0089  *    Event trigger = disabled
0090  *    Purge RX buffer
0091  *    Purge TX buffer
0092  *    Clear DTR
0093  *    Clear RTS
0094  *    baud and data format not reset
0095  *
0096  * The Purge RX and TX buffer commands affect nothing except the buffers
0097  *
0098    */
0099 
0100 /* FTDI_SIO_SET_BAUDRATE */
0101 #define FTDI_SIO_SET_BAUDRATE_REQUEST_TYPE 0x40
0102 #define FTDI_SIO_SET_BAUDRATE_REQUEST 3
0103 
0104 /*
0105  * BmRequestType:  0100 0000B
0106  * bRequest:       FTDI_SIO_SET_BAUDRATE
0107  * wValue:         BaudDivisor value - see below
0108  * wIndex:         Port
0109  * wLength:        0
0110  * Data:           None
0111  * The BaudDivisor values are calculated as follows:
0112  * - BaseClock is either 12000000 or 48000000 depending on the device.
0113  *   FIXME: I wish I knew how to detect old chips to select proper base clock!
0114  * - BaudDivisor is a fixed point number encoded in a funny way.
0115  *   (--WRONG WAY OF THINKING--)
0116  *   BaudDivisor is a fixed point number encoded with following bit weighs:
0117  *   (-2)(-1)(13..0). It is a radical with a denominator of 4, so values
0118  *   end with 0.0 (00...), 0.25 (10...), 0.5 (01...), and 0.75 (11...).
0119  *   (--THE REALITY--)
0120  *   The both-bits-set has quite different meaning from 0.75 - the chip
0121  *   designers have decided it to mean 0.125 instead of 0.75.
0122  *   This info looked up in FTDI application note "FT8U232 DEVICES \ Data Rates
0123  *   and Flow Control Consideration for USB to RS232".
0124  * - BaudDivisor = (BaseClock / 16) / BaudRate, where the (=) operation should
0125  *   automagically re-encode the resulting value to take fractions into
0126  *   consideration.
0127  * As all values are integers, some bit twiddling is in order:
0128  *   BaudDivisor = (BaseClock / 16 / BaudRate) |
0129  *   (((BaseClock / 2 / BaudRate) & 4) ? 0x4000    // 0.5
0130  *    : ((BaseClock / 2 / BaudRate) & 2) ? 0x8000  // 0.25
0131  *    : ((BaseClock / 2 / BaudRate) & 1) ? 0xc000  // 0.125
0132  *    : 0)
0133  *
0134  * For the FT232BM, a 17th divisor bit was introduced to encode the multiples
0135  * of 0.125 missing from the FT8U232AM.  Bits 16 to 14 are coded as follows
0136  * (the first four codes are the same as for the FT8U232AM, where bit 16 is
0137  * always 0):
0138  *   000 - add .000 to divisor
0139  *   001 - add .500 to divisor
0140  *   010 - add .250 to divisor
0141  *   011 - add .125 to divisor
0142  *   100 - add .375 to divisor
0143  *   101 - add .625 to divisor
0144  *   110 - add .750 to divisor
0145  *   111 - add .875 to divisor
0146  * Bits 15 to 0 of the 17-bit divisor are placed in the urb value.  Bit 16 is
0147  * placed in bit 0 of the urb index.
0148  *
0149  * Note that there are a couple of special cases to support the highest baud
0150  * rates.  If the calculated divisor value is 1, this needs to be replaced with
0151  * 0.  Additionally for the FT232BM, if the calculated divisor value is 0x4001
0152  * (1.5), this needs to be replaced with 0x0001 (1) (but this divisor value is
0153  * not supported by the FT8U232AM).
0154  */
0155 
0156 enum ftdi_chip_type {
0157     SIO = 1,
0158     FT8U232AM = 2,
0159     FT232BM = 3,
0160     FT2232C = 4,
0161     FT232RL = 5,
0162     FT2232H = 6,
0163     FT4232H = 7,
0164     FT232H  = 8,
0165     FTX     = 9,
0166 };
0167 
0168 enum ftdi_sio_baudrate {
0169     ftdi_sio_b300 = 0,
0170     ftdi_sio_b600 = 1,
0171     ftdi_sio_b1200 = 2,
0172     ftdi_sio_b2400 = 3,
0173     ftdi_sio_b4800 = 4,
0174     ftdi_sio_b9600 = 5,
0175     ftdi_sio_b19200 = 6,
0176     ftdi_sio_b38400 = 7,
0177     ftdi_sio_b57600 = 8,
0178     ftdi_sio_b115200 = 9
0179 };
0180 
0181 /*
0182  * The ftdi_8U232AM_xxMHz_byyy constants have been removed. The encoded divisor
0183  * values are calculated internally.
0184  */
0185 #define FTDI_SIO_SET_DATA_REQUEST   FTDI_SIO_SET_DATA
0186 #define FTDI_SIO_SET_DATA_REQUEST_TYPE  0x40
0187 #define FTDI_SIO_SET_DATA_PARITY_NONE   (0x0 << 8)
0188 #define FTDI_SIO_SET_DATA_PARITY_ODD    (0x1 << 8)
0189 #define FTDI_SIO_SET_DATA_PARITY_EVEN   (0x2 << 8)
0190 #define FTDI_SIO_SET_DATA_PARITY_MARK   (0x3 << 8)
0191 #define FTDI_SIO_SET_DATA_PARITY_SPACE  (0x4 << 8)
0192 #define FTDI_SIO_SET_DATA_STOP_BITS_1   (0x0 << 11)
0193 #define FTDI_SIO_SET_DATA_STOP_BITS_15  (0x1 << 11)
0194 #define FTDI_SIO_SET_DATA_STOP_BITS_2   (0x2 << 11)
0195 #define FTDI_SIO_SET_BREAK      (0x1 << 14)
0196 /* FTDI_SIO_SET_DATA */
0197 
0198 /*
0199  * BmRequestType:  0100 0000B
0200  * bRequest:       FTDI_SIO_SET_DATA
0201  * wValue:         Data characteristics (see below)
0202  * wIndex:         Port
0203  * wLength:        0
0204  * Data:           No
0205  *
0206  * Data characteristics
0207  *
0208  *   B0..7   Number of data bits
0209  *   B8..10  Parity
0210  *           0 = None
0211  *           1 = Odd
0212  *           2 = Even
0213  *           3 = Mark
0214  *           4 = Space
0215  *   B11..13 Stop Bits
0216  *           0 = 1
0217  *           1 = 1.5
0218  *           2 = 2
0219  *   B14
0220  *           1 = TX ON (break)
0221  *           0 = TX OFF (normal state)
0222  *   B15 Reserved
0223  *
0224  */
0225 
0226 
0227 
0228 /* FTDI_SIO_MODEM_CTRL */
0229 #define FTDI_SIO_SET_MODEM_CTRL_REQUEST_TYPE 0x40
0230 #define FTDI_SIO_SET_MODEM_CTRL_REQUEST FTDI_SIO_MODEM_CTRL
0231 
0232 /*
0233  * BmRequestType:   0100 0000B
0234  * bRequest:        FTDI_SIO_MODEM_CTRL
0235  * wValue:          ControlValue (see below)
0236  * wIndex:          Port
0237  * wLength:         0
0238  * Data:            None
0239  *
0240  * NOTE: If the device is in RTS/CTS flow control, the RTS set by this
0241  * command will be IGNORED without an error being returned
0242  * Also - you can not set DTR and RTS with one control message
0243  */
0244 
0245 #define FTDI_SIO_SET_DTR_MASK 0x1
0246 #define FTDI_SIO_SET_DTR_HIGH ((FTDI_SIO_SET_DTR_MASK  << 8) | 1)
0247 #define FTDI_SIO_SET_DTR_LOW  ((FTDI_SIO_SET_DTR_MASK  << 8) | 0)
0248 #define FTDI_SIO_SET_RTS_MASK 0x2
0249 #define FTDI_SIO_SET_RTS_HIGH ((FTDI_SIO_SET_RTS_MASK << 8) | 2)
0250 #define FTDI_SIO_SET_RTS_LOW  ((FTDI_SIO_SET_RTS_MASK << 8) | 0)
0251 
0252 /*
0253  * ControlValue
0254  * B0    DTR state
0255  *          0 = reset
0256  *          1 = set
0257  * B1    RTS state
0258  *          0 = reset
0259  *          1 = set
0260  * B2..7 Reserved
0261  * B8    DTR state enable
0262  *          0 = ignore
0263  *          1 = use DTR state
0264  * B9    RTS state enable
0265  *          0 = ignore
0266  *          1 = use RTS state
0267  * B10..15 Reserved
0268  */
0269 
0270 /* FTDI_SIO_SET_FLOW_CTRL */
0271 #define FTDI_SIO_SET_FLOW_CTRL_REQUEST_TYPE 0x40
0272 #define FTDI_SIO_SET_FLOW_CTRL_REQUEST FTDI_SIO_SET_FLOW_CTRL
0273 #define FTDI_SIO_DISABLE_FLOW_CTRL 0x0
0274 #define FTDI_SIO_RTS_CTS_HS (0x1 << 8)
0275 #define FTDI_SIO_DTR_DSR_HS (0x2 << 8)
0276 #define FTDI_SIO_XON_XOFF_HS (0x4 << 8)
0277 /*
0278  *   BmRequestType:  0100 0000b
0279  *   bRequest:       FTDI_SIO_SET_FLOW_CTRL
0280  *   wValue:         Xoff/Xon
0281  *   wIndex:         Protocol/Port - hIndex is protocol / lIndex is port
0282  *   wLength:        0
0283  *   Data:           None
0284  *
0285  * hIndex protocol is:
0286  *   B0 Output handshaking using RTS/CTS
0287  *       0 = disabled
0288  *       1 = enabled
0289  *   B1 Output handshaking using DTR/DSR
0290  *       0 = disabled
0291  *       1 = enabled
0292  *   B2 Xon/Xoff handshaking
0293  *       0 = disabled
0294  *       1 = enabled
0295  *
0296  * A value of zero in the hIndex field disables handshaking
0297  *
0298  * If Xon/Xoff handshaking is specified, the hValue field should contain the
0299  * XOFF character and the lValue field contains the XON character.
0300  */
0301 
0302 /*
0303  * FTDI_SIO_GET_LATENCY_TIMER
0304  *
0305  * Set the timeout interval. The FTDI collects data from the
0306  * device, transmitting it to the host when either A) 62 bytes are
0307  * received, or B) the timeout interval has elapsed and the buffer
0308  * contains at least 1 byte.  Setting this value to a small number
0309  * can dramatically improve performance for applications which send
0310  * small packets, since the default value is 16ms.
0311  */
0312 #define  FTDI_SIO_GET_LATENCY_TIMER_REQUEST FTDI_SIO_GET_LATENCY_TIMER
0313 #define  FTDI_SIO_GET_LATENCY_TIMER_REQUEST_TYPE 0xC0
0314 
0315 /*
0316  *  BmRequestType:   1100 0000b
0317  *  bRequest:        FTDI_SIO_GET_LATENCY_TIMER
0318  *  wValue:          0
0319  *  wIndex:          Port
0320  *  wLength:         0
0321  *  Data:            latency (on return)
0322  */
0323 
0324 /*
0325  * FTDI_SIO_SET_LATENCY_TIMER
0326  *
0327  * Set the timeout interval. The FTDI collects data from the
0328  * device, transmitting it to the host when either A) 62 bytes are
0329  * received, or B) the timeout interval has elapsed and the buffer
0330  * contains at least 1 byte.  Setting this value to a small number
0331  * can dramatically improve performance for applications which send
0332  * small packets, since the default value is 16ms.
0333  */
0334 #define  FTDI_SIO_SET_LATENCY_TIMER_REQUEST FTDI_SIO_SET_LATENCY_TIMER
0335 #define  FTDI_SIO_SET_LATENCY_TIMER_REQUEST_TYPE 0x40
0336 
0337 /*
0338  *  BmRequestType:   0100 0000b
0339  *  bRequest:        FTDI_SIO_SET_LATENCY_TIMER
0340  *  wValue:          Latency (milliseconds)
0341  *  wIndex:          Port
0342  *  wLength:         0
0343  *  Data:            None
0344  *
0345  * wValue:
0346  *   B0..7   Latency timer
0347  *   B8..15  0
0348  *
0349  */
0350 
0351 /*
0352  * FTDI_SIO_SET_EVENT_CHAR
0353  *
0354  * Set the special event character for the specified communications port.
0355  * If the device sees this character it will immediately return the
0356  * data read so far - rather than wait 40ms or until 62 bytes are read
0357  * which is what normally happens.
0358  */
0359 
0360 
0361 #define  FTDI_SIO_SET_EVENT_CHAR_REQUEST FTDI_SIO_SET_EVENT_CHAR
0362 #define  FTDI_SIO_SET_EVENT_CHAR_REQUEST_TYPE 0x40
0363 
0364 
0365 /*
0366  *  BmRequestType:   0100 0000b
0367  *  bRequest:        FTDI_SIO_SET_EVENT_CHAR
0368  *  wValue:          EventChar
0369  *  wIndex:          Port
0370  *  wLength:         0
0371  *  Data:            None
0372  *
0373  * wValue:
0374  *   B0..7   Event Character
0375  *   B8      Event Character Processing
0376  *             0 = disabled
0377  *             1 = enabled
0378  *   B9..15  Reserved
0379  *
0380  */
0381 
0382 /* FTDI_SIO_SET_ERROR_CHAR */
0383 
0384 /*
0385  * Set the parity error replacement character for the specified communications
0386  * port
0387  */
0388 
0389 /*
0390  *  BmRequestType:  0100 0000b
0391  *  bRequest:       FTDI_SIO_SET_EVENT_CHAR
0392  *  wValue:         Error Char
0393  *  wIndex:         Port
0394  *  wLength:        0
0395  *  Data:           None
0396  *
0397  *Error Char
0398  *  B0..7  Error Character
0399  *  B8     Error Character Processing
0400  *           0 = disabled
0401  *           1 = enabled
0402  *  B9..15 Reserved
0403  *
0404  */
0405 
0406 /* FTDI_SIO_GET_MODEM_STATUS */
0407 /* Retrieve the current value of the modem status register */
0408 
0409 #define FTDI_SIO_GET_MODEM_STATUS_REQUEST_TYPE 0xc0
0410 #define FTDI_SIO_GET_MODEM_STATUS_REQUEST FTDI_SIO_GET_MODEM_STATUS
0411 #define FTDI_SIO_CTS_MASK 0x10
0412 #define FTDI_SIO_DSR_MASK 0x20
0413 #define FTDI_SIO_RI_MASK  0x40
0414 #define FTDI_SIO_RLSD_MASK 0x80
0415 /*
0416  *   BmRequestType:   1100 0000b
0417  *   bRequest:        FTDI_SIO_GET_MODEM_STATUS
0418  *   wValue:          zero
0419  *   wIndex:          Port
0420  *   wLength:         1
0421  *   Data:            Status
0422  *
0423  * One byte of data is returned
0424  * B0..3 0
0425  * B4    CTS
0426  *         0 = inactive
0427  *         1 = active
0428  * B5    DSR
0429  *         0 = inactive
0430  *         1 = active
0431  * B6    Ring Indicator (RI)
0432  *         0 = inactive
0433  *         1 = active
0434  * B7    Receive Line Signal Detect (RLSD)
0435  *         0 = inactive
0436  *         1 = active
0437  */
0438 
0439 /* FTDI_SIO_SET_BITMODE */
0440 #define FTDI_SIO_SET_BITMODE_REQUEST_TYPE 0x40
0441 #define FTDI_SIO_SET_BITMODE_REQUEST FTDI_SIO_SET_BITMODE
0442 
0443 /* Possible bitmodes for FTDI_SIO_SET_BITMODE_REQUEST */
0444 #define FTDI_SIO_BITMODE_RESET      0x00
0445 #define FTDI_SIO_BITMODE_CBUS       0x20
0446 
0447 /* FTDI_SIO_READ_PINS */
0448 #define FTDI_SIO_READ_PINS_REQUEST_TYPE 0xc0
0449 #define FTDI_SIO_READ_PINS_REQUEST FTDI_SIO_READ_PINS
0450 
0451 /*
0452  * FTDI_SIO_READ_EEPROM
0453  *
0454  * EEPROM format found in FTDI AN_201, "FT-X MTP memory Configuration",
0455  * http://www.ftdichip.com/Support/Documents/AppNotes/AN_201_FT-X%20MTP%20Memory%20Configuration.pdf
0456  */
0457 #define FTDI_SIO_READ_EEPROM_REQUEST_TYPE 0xc0
0458 #define FTDI_SIO_READ_EEPROM_REQUEST FTDI_SIO_READ_EEPROM
0459 
0460 #define FTDI_FTX_CBUS_MUX_GPIO      0x8
0461 #define FTDI_FT232R_CBUS_MUX_GPIO   0xa
0462 
0463 
0464 /* Descriptors returned by the device
0465  *
0466  *  Device Descriptor
0467  *
0468  * Offset   Field       Size    Value   Description
0469  * 0    bLength     1   0x12    Size of descriptor in bytes
0470  * 1    bDescriptorType 1   0x01    DEVICE Descriptor Type
0471  * 2    bcdUSB      2   0x0110  USB Spec Release Number
0472  * 4    bDeviceClass    1   0x00    Class Code
0473  * 5    bDeviceSubClass 1   0x00    SubClass Code
0474  * 6    bDeviceProtocol 1   0x00    Protocol Code
0475  * 7    bMaxPacketSize0 1   0x08    Maximum packet size for endpoint 0
0476  * 8    idVendor    2   0x0403  Vendor ID
0477  * 10   idProduct   2   0x8372  Product ID (FTDI_SIO_PID)
0478  * 12   bcdDevice   2   0x0001  Device release number
0479  * 14   iManufacturer   1   0x01    Index of man. string desc
0480  * 15   iProduct    1   0x02    Index of prod string desc
0481  * 16   iSerialNumber   1   0x02    Index of serial nmr string desc
0482  * 17   bNumConfigurations 1    0x01    Number of possible configurations
0483  *
0484  * Configuration Descriptor
0485  *
0486  * Offset   Field           Size    Value
0487  * 0    bLength         1   0x09    Size of descriptor in bytes
0488  * 1    bDescriptorType     1   0x02    CONFIGURATION Descriptor Type
0489  * 2    wTotalLength        2   0x0020  Total length of data
0490  * 4    bNumInterfaces      1   0x01    Number of interfaces supported
0491  * 5    bConfigurationValue 1   0x01    Argument for SetCOnfiguration() req
0492  * 6    iConfiguration      1   0x02    Index of config string descriptor
0493  * 7    bmAttributes        1   0x20    Config characteristics Remote Wakeup
0494  * 8    MaxPower        1   0x1E    Max power consumption
0495  *
0496  * Interface Descriptor
0497  *
0498  * Offset   Field           Size    Value
0499  * 0    bLength         1   0x09    Size of descriptor in bytes
0500  * 1    bDescriptorType     1   0x04    INTERFACE Descriptor Type
0501  * 2    bInterfaceNumber    1   0x00    Number of interface
0502  * 3    bAlternateSetting   1   0x00    Value used to select alternate
0503  * 4    bNumEndpoints       1   0x02    Number of endpoints
0504  * 5    bInterfaceClass     1   0xFF    Class Code
0505  * 6    bInterfaceSubClass  1   0xFF    Subclass Code
0506  * 7    bInterfaceProtocol  1   0xFF    Protocol Code
0507  * 8    iInterface      1   0x02    Index of interface string description
0508  *
0509  * IN Endpoint Descriptor
0510  *
0511  * Offset   Field           Size    Value
0512  * 0    bLength         1   0x07    Size of descriptor in bytes
0513  * 1    bDescriptorType     1   0x05    ENDPOINT descriptor type
0514  * 2    bEndpointAddress    1   0x82    Address of endpoint
0515  * 3    bmAttributes        1   0x02    Endpoint attributes - Bulk
0516  * 4    bNumEndpoints       2   0x0040  maximum packet size
0517  * 5    bInterval       1   0x00    Interval for polling endpoint
0518  *
0519  * OUT Endpoint Descriptor
0520  *
0521  * Offset   Field           Size    Value
0522  * 0    bLength         1   0x07    Size of descriptor in bytes
0523  * 1    bDescriptorType     1   0x05    ENDPOINT descriptor type
0524  * 2    bEndpointAddress    1   0x02    Address of endpoint
0525  * 3    bmAttributes        1   0x02    Endpoint attributes - Bulk
0526  * 4    bNumEndpoints       2   0x0040  maximum packet size
0527  * 5    bInterval       1   0x00    Interval for polling endpoint
0528  *
0529  * DATA FORMAT
0530  *
0531  * IN Endpoint
0532  *
0533  * The device reserves the first two bytes of data on this endpoint to contain
0534  * the current values of the modem and line status registers. In the absence of
0535  * data, the device generates a message consisting of these two status bytes
0536  * every 40 ms
0537  *
0538  * Byte 0: Modem Status
0539  *
0540  * Offset   Description
0541  * B0   Reserved - must be 1
0542  * B1   Reserved - must be 0
0543  * B2   Reserved - must be 0
0544  * B3   Reserved - must be 0
0545  * B4   Clear to Send (CTS)
0546  * B5   Data Set Ready (DSR)
0547  * B6   Ring Indicator (RI)
0548  * B7   Receive Line Signal Detect (RLSD)
0549  *
0550  * Byte 1: Line Status
0551  *
0552  * Offset   Description
0553  * B0   Data Ready (DR)
0554  * B1   Overrun Error (OE)
0555  * B2   Parity Error (PE)
0556  * B3   Framing Error (FE)
0557  * B4   Break Interrupt (BI)
0558  * B5   Transmitter Holding Register (THRE)
0559  * B6   Transmitter Empty (TEMT)
0560  * B7   Error in RCVR FIFO
0561  *
0562  */
0563 #define FTDI_RS0_CTS    (1 << 4)
0564 #define FTDI_RS0_DSR    (1 << 5)
0565 #define FTDI_RS0_RI (1 << 6)
0566 #define FTDI_RS0_RLSD   (1 << 7)
0567 
0568 #define FTDI_RS_DR  1
0569 #define FTDI_RS_OE  (1<<1)
0570 #define FTDI_RS_PE  (1<<2)
0571 #define FTDI_RS_FE  (1<<3)
0572 #define FTDI_RS_BI  (1<<4)
0573 #define FTDI_RS_THRE    (1<<5)
0574 #define FTDI_RS_TEMT    (1<<6)
0575 #define FTDI_RS_FIFO    (1<<7)
0576 
0577 /*
0578  * OUT Endpoint
0579  *
0580  * This device reserves the first bytes of data on this endpoint contain the
0581  * length and port identifier of the message. For the FTDI USB Serial converter
0582  * the port identifier is always 1.
0583  *
0584  * Byte 0: Line Status
0585  *
0586  * Offset   Description
0587  * B0   Reserved - must be 1
0588  * B1   Reserved - must be 0
0589  * B2..7    Length of message - (not including Byte 0)
0590  *
0591  */