1 /* $NetBSD: uftdireg.h,v 1.6 2002/07/11 21:14:28 augustss Exp $ */
5 * Definitions for the FTDI USB Single Port Serial Converter -
6 * known as FTDI_SIO (Serial Input/Output application of the chipset)
8 * The device is based on the FTDI FT8U100AX chip. It has a DB25 on one side,
11 * Thanx to FTDI (http://www.ftdi.co.uk) for so kindly providing details
12 * of the protocol required to talk to the device and ongoing assistence
15 * Bill Ryder - bryder@sgi.com of Silicon Graphics, Inc. is the original
16 * author of this file.
18 /* Modified by Lennart Augustsson */
20 /* Vendor Request Interface */
21 #define FTDI_SIO_RESET 0 /* Reset the port */
22 #define FTDI_SIO_MODEM_CTRL 1 /* Set the modem control register */
23 #define FTDI_SIO_SET_FLOW_CTRL 2 /* Set flow control register */
24 #define FTDI_SIO_SET_BAUD_RATE 3 /* Set baud rate */
25 #define FTDI_SIO_SET_DATA 4 /* Set the data characteristics of the
27 #define FTDI_SIO_GET_STATUS 5 /* Retrieve current value of status
29 #define FTDI_SIO_SET_EVENT_CHAR 6 /* Set the event character */
30 #define FTDI_SIO_SET_ERROR_CHAR 7 /* Set the error character */
32 /* Port Identifier Table */
33 #define FTDI_PIT_DEFAULT 0 /* SIOA */
34 #define FTDI_PIT_SIOA 1 /* SIOA */
35 #define FTDI_PIT_SIOB 2 /* SIOB */
36 #define FTDI_PIT_PARALLEL 3 /* Parallel */
44 * BmRequestType: 0100 0000B
45 * bRequest: FTDI_SIO_RESET
46 * wValue: Control Value
54 * The Reset SIO command has this effect:
56 * Sets flow control set to 'none'
58 * Event trigger = disabled
63 * baud and data format not reset
65 * The Purge RX and TX buffer commands affect nothing except the buffers
68 #define FTDI_SIO_RESET_SIO 0
69 #define FTDI_SIO_RESET_PURGE_RX 1
70 #define FTDI_SIO_RESET_PURGE_TX 2
73 * BmRequestType: 0100 0000B
74 * bRequest: FTDI_SIO_SET_BAUDRATE
75 * wValue: BaudRate value - see below
80 /* FTDI_SIO_SET_BAUDRATE */
94 #define FTDI_8U232AM_FREQ 3000000
96 /* Bounds for normal divisors as 4-bit fixed precision ints. */
97 #define FTDI_8U232AM_MIN_DIV 0x20
98 #define FTDI_8U232AM_MAX_DIV 0x3fff8
101 * BmRequestType: 0100 0000B
102 * bRequest: FTDI_SIO_SET_DATA
103 * wValue: Data characteristics (see below)
108 * Data characteristics
110 * B0..7 Number of data bits
124 /* FTDI_SIO_SET_DATA */
125 #define FTDI_SIO_SET_DATA_BITS(n) (n)
126 #define FTDI_SIO_SET_DATA_PARITY_NONE (0x0 << 8)
127 #define FTDI_SIO_SET_DATA_PARITY_ODD (0x1 << 8)
128 #define FTDI_SIO_SET_DATA_PARITY_EVEN (0x2 << 8)
129 #define FTDI_SIO_SET_DATA_PARITY_MARK (0x3 << 8)
130 #define FTDI_SIO_SET_DATA_PARITY_SPACE (0x4 << 8)
131 #define FTDI_SIO_SET_DATA_STOP_BITS_1 (0x0 << 11)
132 #define FTDI_SIO_SET_DATA_STOP_BITS_15 (0x1 << 11)
133 #define FTDI_SIO_SET_DATA_STOP_BITS_2 (0x2 << 11)
134 #define FTDI_SIO_SET_BREAK (0x1 << 14)
137 * BmRequestType: 0100 0000B
138 * bRequest: FTDI_SIO_MODEM_CTRL
139 * wValue: ControlValue (see below)
144 * NOTE: If the device is in RTS/CTS flow control, the RTS set by this
145 * command will be IGNORED without an error being returned
146 * Also - you can not set DTR and RTS with one control message
156 * B8 DTR state enable
159 * B9 RTS state enable
164 /* FTDI_SIO_MODEM_CTRL */
165 #define FTDI_SIO_SET_DTR_MASK 0x1
166 #define FTDI_SIO_SET_DTR_HIGH (1 | ( FTDI_SIO_SET_DTR_MASK << 8))
167 #define FTDI_SIO_SET_DTR_LOW (0 | ( FTDI_SIO_SET_DTR_MASK << 8))
168 #define FTDI_SIO_SET_RTS_MASK 0x2
169 #define FTDI_SIO_SET_RTS_HIGH (2 | ( FTDI_SIO_SET_RTS_MASK << 8))
170 #define FTDI_SIO_SET_RTS_LOW (0 | ( FTDI_SIO_SET_RTS_MASK << 8))
173 * BmRequestType: 0100 0000b
174 * bRequest: FTDI_SIO_SET_FLOW_CTRL
176 * wIndex: Protocol/Port - hIndex is protocl / lIndex is port
180 * hIndex protocol is:
181 * B0 Output handshaking using RTS/CTS
184 * B1 Output handshaking using DTR/DSR
187 * B2 Xon/Xoff handshaking
191 * A value of zero in the hIndex field disables handshaking
193 * If Xon/Xoff handshaking is specified, the hValue field should contain the
194 * XOFF character and the lValue field contains the XON character.
196 /* FTDI_SIO_SET_FLOW_CTRL */
197 #define FTDI_SIO_DISABLE_FLOW_CTRL 0x0
198 #define FTDI_SIO_RTS_CTS_HS 0x1
199 #define FTDI_SIO_DTR_DSR_HS 0x2
200 #define FTDI_SIO_XON_XOFF_HS 0x4
203 * BmRequestType: 0100 0000b
204 * bRequest: FTDI_SIO_SET_EVENT_CHAR
211 * B0..7 Event Character
212 * B8 Event Character Processing
217 * FTDI_SIO_SET_EVENT_CHAR
219 * Set the special event character for the specified communications port.
220 * If the device sees this character it will immediately return the
221 * data read so far - rather than wait 40ms or until 62 bytes are read
222 * which is what normally happens.
226 * BmRequestType: 0100 0000b
227 * bRequest: FTDI_SIO_SET_ERROR_CHAR
234 * B0..7 Error Character
235 * B8 Error Character Processing
240 * FTDI_SIO_SET_ERROR_CHAR
241 * Set the parity error replacement character for the specified communications
246 * BmRequestType: 1100 0000b
247 * bRequest: FTDI_SIO_GET_MODEM_STATUS
253 * One byte of data is returned
261 * B6 Ring Indicator (RI)
264 * B7 Receive Line Signal Detect (RLSD)
268 * FTDI_SIO_GET_MODEM_STATUS
269 * Retrieve the current value of the modem status register.
271 #define FTDI_SIO_CTS_MASK 0x10
272 #define FTDI_SIO_DSR_MASK 0x20
273 #define FTDI_SIO_RI_MASK 0x40
274 #define FTDI_SIO_RLSD_MASK 0x80
281 * The device reserves the first two bytes of data on this endpoint to contain
282 * the current values of the modem and line status registers. In the absence of
283 * data, the device generates a message consisting of these two status bytes
286 * Byte 0: Modem Status
287 * NOTE: 4 upper bits have same layout as the MSR register in a 16550
291 * B4 Clear to Send (CTS)
292 * B5 Data Set Ready (DSR)
293 * B6 Ring Indicator (RI)
294 * B7 Receive Line Signal Detect (RLSD)
296 * Byte 1: Line Status
297 * NOTE: same layout as the LSR register in a 16550
301 * B1 Overrun Error (OE)
302 * B2 Parity Error (PE)
303 * B3 Framing Error (FE)
304 * B4 Break Interrupt (BI)
305 * B5 Transmitter Holding Register (THRE)
306 * B6 Transmitter Empty (TEMT)
307 * B7 Error in RCVR FIFO
311 * This device reserves the first bytes of data on this endpoint contain the
312 * length and port identifier of the message. For the FTDI USB Serial converter
313 * the port identifier is always 1.
315 * Byte 0: Port & length
319 * B2..7 Length of message - (not including Byte 0)
321 #define FTDI_PORT_MASK 0x0f
322 #define FTDI_MSR_MASK 0xf0
323 #define FTDI_GET_MSR(p) (((p)[0]) & FTDI_MSR_MASK)
324 #define FTDI_GET_LSR(p) ((p)[1])
325 #define FTDI_LSR_MASK (~0x60) /* interesting bits */
326 #define FTDI_OUT_TAG(len, port) (((len) << 2) | (port))