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