More minor IPI work.
[dragonfly/vkernel-mp.git] / sys / dev / usbmisc / uftdi / uftdireg.h
blobda5004b0e1b2e4325c9891d3e035ba48355b3797
1 /*
2 * $NetBSD: uftdireg.h,v 1.6 2002/07/11 21:14:28 augustss Exp $
3 * $FreeBSD: src/sys/dev/usb/uftdireg.h,v 1.1 2002/08/11 23:32:33 joe Exp $
4 * $DragonFly: src/sys/dev/usbmisc/uftdi/uftdireg.h,v 1.3 2003/12/30 02:01:46 dillon Exp $
5 */
7 /*
8 * Definitions for the FTDI USB Single Port Serial Converter -
9 * known as FTDI_SIO (Serial Input/Output application of the chipset)
11 * The device is based on the FTDI FT8U100AX chip. It has a DB25 on one side,
12 * USB on the other.
14 * Thanx to FTDI (http://www.ftdi.co.uk) for so kindly providing details
15 * of the protocol required to talk to the device and ongoing assistence
16 * during development.
18 * Bill Ryder - bryder@sgi.com of Silicon Graphics, Inc. is the original
19 * author of this file.
21 /* Modified by Lennart Augustsson */
23 /* Vendor Request Interface */
24 #define FTDI_SIO_RESET 0 /* Reset the port */
25 #define FTDI_SIO_MODEM_CTRL 1 /* Set the modem control register */
26 #define FTDI_SIO_SET_FLOW_CTRL 2 /* Set flow control register */
27 #define FTDI_SIO_SET_BAUD_RATE 3 /* Set baud rate */
28 #define FTDI_SIO_SET_DATA 4 /* Set the data characteristics of the port */
29 #define FTDI_SIO_GET_STATUS 5 /* Retrieve current value of status reg */
30 #define FTDI_SIO_SET_EVENT_CHAR 6 /* Set the event character */
31 #define FTDI_SIO_SET_ERROR_CHAR 7 /* Set the error character */
33 /* Port Identifier Table */
34 #define FTDI_PIT_DEFAULT 0 /* SIOA */
35 #define FTDI_PIT_SIOA 1 /* SIOA */
36 #define FTDI_PIT_SIOB 2 /* SIOB */
37 #define FTDI_PIT_PARALLEL 3 /* Parallel */
39 enum uftdi_type {
40 UFTDI_TYPE_SIO,
41 UFTDI_TYPE_8U232AM
45 * BmRequestType: 0100 0000B
46 * bRequest: FTDI_SIO_RESET
47 * wValue: Control Value
48 * 0 = Reset SIO
49 * 1 = Purge RX buffer
50 * 2 = Purge TX buffer
51 * wIndex: Port
52 * wLength: 0
53 * Data: None
55 * The Reset SIO command has this effect:
57 * Sets flow control set to 'none'
58 * Event char = 0x0d
59 * Event trigger = disabled
60 * Purge RX buffer
61 * Purge TX buffer
62 * Clear DTR
63 * Clear RTS
64 * baud and data format not reset
66 * The Purge RX and TX buffer commands affect nothing except the buffers
69 /* FTDI_SIO_RESET */
70 #define FTDI_SIO_RESET_SIO 0
71 #define FTDI_SIO_RESET_PURGE_RX 1
72 #define FTDI_SIO_RESET_PURGE_TX 2
76 * BmRequestType: 0100 0000B
77 * bRequest: FTDI_SIO_SET_BAUDRATE
78 * wValue: BaudRate value - see below
79 * wIndex: Port
80 * wLength: 0
81 * Data: None
83 /* FTDI_SIO_SET_BAUDRATE */
84 enum {
85 ftdi_sio_b300 = 0,
86 ftdi_sio_b600 = 1,
87 ftdi_sio_b1200 = 2,
88 ftdi_sio_b2400 = 3,
89 ftdi_sio_b4800 = 4,
90 ftdi_sio_b9600 = 5,
91 ftdi_sio_b19200 = 6,
92 ftdi_sio_b38400 = 7,
93 ftdi_sio_b57600 = 8,
94 ftdi_sio_b115200 = 9
97 enum {
98 ftdi_8u232am_b300 = 0x2710,
99 ftdi_8u232am_b600 = 0x1388,
100 ftdi_8u232am_b1200 = 0x09c4,
101 ftdi_8u232am_b2400 = 0x04e2,
102 ftdi_8u232am_b4800 = 0x0271,
103 ftdi_8u232am_b9600 = 0x4138,
104 ftdi_8u232am_b19200 = 0x809c,
105 ftdi_8u232am_b38400 = 0xc04e,
106 ftdi_8u232am_b57600 = 0x0034,
107 ftdi_8u232am_b115200 = 0x001a,
108 ftdi_8u232am_b230400 = 0x000d,
109 ftdi_8u232am_b460800 = 0x4006,
110 ftdi_8u232am_b921600 = 0x8003
114 * BmRequestType: 0100 0000B
115 * bRequest: FTDI_SIO_SET_DATA
116 * wValue: Data characteristics (see below)
117 * wIndex: Port
118 * wLength: 0
119 * Data: No
121 * Data characteristics
123 * B0..7 Number of data bits
124 * B8..10 Parity
125 * 0 = None
126 * 1 = Odd
127 * 2 = Even
128 * 3 = Mark
129 * 4 = Space
130 * B11..13 Stop Bits
131 * 0 = 1
132 * 1 = 1.5
133 * 2 = 2
134 * B14..15 Reserved
137 /* FTDI_SIO_SET_DATA */
138 #define FTDI_SIO_SET_DATA_BITS(n) (n)
139 #define FTDI_SIO_SET_DATA_PARITY_NONE (0x0 << 8)
140 #define FTDI_SIO_SET_DATA_PARITY_ODD (0x1 << 8)
141 #define FTDI_SIO_SET_DATA_PARITY_EVEN (0x2 << 8)
142 #define FTDI_SIO_SET_DATA_PARITY_MARK (0x3 << 8)
143 #define FTDI_SIO_SET_DATA_PARITY_SPACE (0x4 << 8)
144 #define FTDI_SIO_SET_DATA_STOP_BITS_1 (0x0 << 11)
145 #define FTDI_SIO_SET_DATA_STOP_BITS_15 (0x1 << 11)
146 #define FTDI_SIO_SET_DATA_STOP_BITS_2 (0x2 << 11)
147 #define FTDI_SIO_SET_BREAK (0x1 << 14)
151 * BmRequestType: 0100 0000B
152 * bRequest: FTDI_SIO_MODEM_CTRL
153 * wValue: ControlValue (see below)
154 * wIndex: Port
155 * wLength: 0
156 * Data: None
158 * NOTE: If the device is in RTS/CTS flow control, the RTS set by this
159 * command will be IGNORED without an error being returned
160 * Also - you can not set DTR and RTS with one control message
162 * ControlValue
163 * B0 DTR state
164 * 0 = reset
165 * 1 = set
166 * B1 RTS state
167 * 0 = reset
168 * 1 = set
169 * B2..7 Reserved
170 * B8 DTR state enable
171 * 0 = ignore
172 * 1 = use DTR state
173 * B9 RTS state enable
174 * 0 = ignore
175 * 1 = use RTS state
176 * B10..15 Reserved
178 /* FTDI_SIO_MODEM_CTRL */
179 #define FTDI_SIO_SET_DTR_MASK 0x1
180 #define FTDI_SIO_SET_DTR_HIGH (1 | ( FTDI_SIO_SET_DTR_MASK << 8))
181 #define FTDI_SIO_SET_DTR_LOW (0 | ( FTDI_SIO_SET_DTR_MASK << 8))
182 #define FTDI_SIO_SET_RTS_MASK 0x2
183 #define FTDI_SIO_SET_RTS_HIGH (2 | ( FTDI_SIO_SET_RTS_MASK << 8))
184 #define FTDI_SIO_SET_RTS_LOW (0 | ( FTDI_SIO_SET_RTS_MASK << 8))
188 * BmRequestType: 0100 0000b
189 * bRequest: FTDI_SIO_SET_FLOW_CTRL
190 * wValue: Xoff/Xon
191 * wIndex: Protocol/Port - hIndex is protocl / lIndex is port
192 * wLength: 0
193 * Data: None
195 * hIndex protocol is:
196 * B0 Output handshaking using RTS/CTS
197 * 0 = disabled
198 * 1 = enabled
199 * B1 Output handshaking using DTR/DSR
200 * 0 = disabled
201 * 1 = enabled
202 * B2 Xon/Xoff handshaking
203 * 0 = disabled
204 * 1 = enabled
206 * A value of zero in the hIndex field disables handshaking
208 * If Xon/Xoff handshaking is specified, the hValue field should contain the
209 * XOFF character and the lValue field contains the XON character.
211 /* FTDI_SIO_SET_FLOW_CTRL */
212 #define FTDI_SIO_DISABLE_FLOW_CTRL 0x0
213 #define FTDI_SIO_RTS_CTS_HS 0x1
214 #define FTDI_SIO_DTR_DSR_HS 0x2
215 #define FTDI_SIO_XON_XOFF_HS 0x4
219 * BmRequestType: 0100 0000b
220 * bRequest: FTDI_SIO_SET_EVENT_CHAR
221 * wValue: Event Char
222 * wIndex: Port
223 * wLength: 0
224 * Data: None
226 * wValue:
227 * B0..7 Event Character
228 * B8 Event Character Processing
229 * 0 = disabled
230 * 1 = enabled
231 * B9..15 Reserved
233 * FTDI_SIO_SET_EVENT_CHAR
235 * Set the special event character for the specified communications port.
236 * If the device sees this character it will immediately return the
237 * data read so far - rather than wait 40ms or until 62 bytes are read
238 * which is what normally happens.
244 * BmRequestType: 0100 0000b
245 * bRequest: FTDI_SIO_SET_ERROR_CHAR
246 * wValue: Error Char
247 * wIndex: Port
248 * wLength: 0
249 * Data: None
251 * Error Char
252 * B0..7 Error Character
253 * B8 Error Character Processing
254 * 0 = disabled
255 * 1 = enabled
256 * B9..15 Reserved
259 * FTDI_SIO_SET_ERROR_CHAR
260 * Set the parity error replacement character for the specified communications
261 * port.
266 * BmRequestType: 1100 0000b
267 * bRequest: FTDI_SIO_GET_MODEM_STATUS
268 * wValue: zero
269 * wIndex: Port
270 * wLength: 1
271 * Data: Status
273 * One byte of data is returned
274 * B0..3 0
275 * B4 CTS
276 * 0 = inactive
277 * 1 = active
278 * B5 DSR
279 * 0 = inactive
280 * 1 = active
281 * B6 Ring Indicator (RI)
282 * 0 = inactive
283 * 1 = active
284 * B7 Receive Line Signal Detect (RLSD)
285 * 0 = inactive
286 * 1 = active
288 * FTDI_SIO_GET_MODEM_STATUS
289 * Retrieve the current value of the modem status register.
291 #define FTDI_SIO_CTS_MASK 0x10
292 #define FTDI_SIO_DSR_MASK 0x20
293 #define FTDI_SIO_RI_MASK 0x40
294 #define FTDI_SIO_RLSD_MASK 0x80
300 * DATA FORMAT
302 * IN Endpoint
304 * The device reserves the first two bytes of data on this endpoint to contain
305 * the current values of the modem and line status registers. In the absence of
306 * data, the device generates a message consisting of these two status bytes
307 * every 40 ms.
309 * Byte 0: Modem Status
310 * NOTE: 4 upper bits have same layout as the MSR register in a 16550
312 * Offset Description
313 * B0..3 Port
314 * B4 Clear to Send (CTS)
315 * B5 Data Set Ready (DSR)
316 * B6 Ring Indicator (RI)
317 * B7 Receive Line Signal Detect (RLSD)
319 * Byte 1: Line Status
320 * NOTE: same layout as the LSR register in a 16550
322 * Offset Description
323 * B0 Data Ready (DR)
324 * B1 Overrun Error (OE)
325 * B2 Parity Error (PE)
326 * B3 Framing Error (FE)
327 * B4 Break Interrupt (BI)
328 * B5 Transmitter Holding Register (THRE)
329 * B6 Transmitter Empty (TEMT)
330 * B7 Error in RCVR FIFO
333 * OUT Endpoint
335 * This device reserves the first bytes of data on this endpoint contain the
336 * length and port identifier of the message. For the FTDI USB Serial converter
337 * the port identifier is always 1.
339 * Byte 0: Port & length
341 * Offset Description
342 * B0..1 Port
343 * B2..7 Length of message - (not including Byte 0)
346 #define FTDI_PORT_MASK 0x0f
347 #define FTDI_MSR_MASK 0xf0
348 #define FTDI_GET_MSR(p) (((p)[0]) & FTDI_MSR_MASK)
349 #define FTDI_GET_LSR(p) ((p)[1])
350 #define FTDI_LSR_MASK (~0x60) /* interesting bits */
351 #define FTDI_OUT_TAG(len, port) (((len) << 2) | (port))