Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

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