FreeBSD kernel usb device Code
uftdi_reg.h
Go to the documentation of this file.
1
/* $NetBSD: uftdireg.h,v 1.6 2002/07/11 21:14:28 augustss Exp $ */
2
/* $FreeBSD$ */
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
26
* port */
27
#define FTDI_SIO_GET_STATUS 5
/* Retrieve current value of status
28
* reg */
29
#define FTDI_SIO_SET_EVENT_CHAR 6
/* Set the event character */
30
#define FTDI_SIO_SET_ERROR_CHAR 7
/* Set the error character */
31
#define FTDI_SIO_SET_LATENCY 9
/* Set the latency timer */
32
#define FTDI_SIO_GET_LATENCY 10
/* Read the latency timer */
33
#define FTDI_SIO_SET_BITMODE 11
/* Set the bit bang I/O mode */
34
#define FTDI_SIO_GET_BITMODE 12
/* Read pin states from any mode */
35
#define FTDI_SIO_READ_EEPROM 144
/* Read eeprom word */
36
#define FTDI_SIO_WRITE_EEPROM 145
/* Write eeprom word */
37
#define FTDI_SIO_ERASE_EEPROM 146
/* Erase entire eeprom */
38
39
/* Port Identifier Table */
40
#define FTDI_PIT_DEFAULT 0
/* SIOA */
41
#define FTDI_PIT_SIOA 1
/* SIOA */
42
#define FTDI_PIT_SIOB 2
/* SIOB */
43
#define FTDI_PIT_PARALLEL 3
/* Parallel */
44
45
/* Values for driver_info */
46
#define UFTDI_JTAG_IFACE(i) (1 << i)
/* Flag interface as jtag */
47
#define UFTDI_JTAG_IFACES_MAX 8
/* Allow up to 8 jtag intfs */
48
#define UFTDI_JTAG_CHECK_STRING 0xff
/* Check product names table */
49
#define UFTDI_JTAG_MASK 0xff
50
51
/*
52
* BmRequestType: 0100 0000B
53
* bRequest: FTDI_SIO_RESET
54
* wValue: Control Value
55
* 0 = Reset SIO
56
* 1 = Purge RX buffer
57
* 2 = Purge TX buffer
58
* wIndex: Port
59
* wLength: 0
60
* Data: None
61
*
62
* The Reset SIO command has this effect:
63
*
64
* Sets flow control set to 'none'
65
* Event char = 0x0d
66
* Event trigger = disabled
67
* Purge RX buffer
68
* Purge TX buffer
69
* Clear DTR
70
* Clear RTS
71
* baud and data format not reset
72
*
73
* The Purge RX and TX buffer commands affect nothing except the buffers
74
*/
75
/* FTDI_SIO_RESET */
76
#define FTDI_SIO_RESET_SIO 0
77
#define FTDI_SIO_RESET_PURGE_RX 1
78
#define FTDI_SIO_RESET_PURGE_TX 2
79
80
/*
81
* BmRequestType: 0100 0000B
82
* bRequest: FTDI_SIO_SET_BAUDRATE
83
* wValue: BaudRate low bits
84
* wIndex: Port and BaudRate high bits
85
* wLength: 0
86
* Data: None
87
*/
88
/* FTDI_SIO_SET_BAUDRATE */
89
90
/*
91
* BmRequestType: 0100 0000B
92
* bRequest: FTDI_SIO_SET_DATA
93
* wValue: Data characteristics (see below)
94
* wIndex: Port
95
* wLength: 0
96
* Data: No
97
*
98
* Data characteristics
99
*
100
* B0..7 Number of data bits
101
* B8..10 Parity
102
* 0 = None
103
* 1 = Odd
104
* 2 = Even
105
* 3 = Mark
106
* 4 = Space
107
* B11..13 Stop Bits
108
* 0 = 1
109
* 1 = 1.5
110
* 2 = 2
111
* B14..15 Reserved
112
*
113
*/
114
/* FTDI_SIO_SET_DATA */
115
#define FTDI_SIO_SET_DATA_BITS(n) (n)
116
#define FTDI_SIO_SET_DATA_PARITY_NONE (0x0 << 8)
117
#define FTDI_SIO_SET_DATA_PARITY_ODD (0x1 << 8)
118
#define FTDI_SIO_SET_DATA_PARITY_EVEN (0x2 << 8)
119
#define FTDI_SIO_SET_DATA_PARITY_MARK (0x3 << 8)
120
#define FTDI_SIO_SET_DATA_PARITY_SPACE (0x4 << 8)
121
#define FTDI_SIO_SET_DATA_STOP_BITS_1 (0x0 << 11)
122
#define FTDI_SIO_SET_DATA_STOP_BITS_15 (0x1 << 11)
123
#define FTDI_SIO_SET_DATA_STOP_BITS_2 (0x2 << 11)
124
#define FTDI_SIO_SET_BREAK (0x1 << 14)
125
126
/*
127
* BmRequestType: 0100 0000B
128
* bRequest: FTDI_SIO_MODEM_CTRL
129
* wValue: ControlValue (see below)
130
* wIndex: Port
131
* wLength: 0
132
* Data: None
133
*
134
* NOTE: If the device is in RTS/CTS flow control, the RTS set by this
135
* command will be IGNORED without an error being returned
136
* Also - you can not set DTR and RTS with one control message
137
*
138
* ControlValue
139
* B0 DTR state
140
* 0 = reset
141
* 1 = set
142
* B1 RTS state
143
* 0 = reset
144
* 1 = set
145
* B2..7 Reserved
146
* B8 DTR state enable
147
* 0 = ignore
148
* 1 = use DTR state
149
* B9 RTS state enable
150
* 0 = ignore
151
* 1 = use RTS state
152
* B10..15 Reserved
153
*/
154
/* FTDI_SIO_MODEM_CTRL */
155
#define FTDI_SIO_SET_DTR_MASK 0x1
156
#define FTDI_SIO_SET_DTR_HIGH (1 | ( FTDI_SIO_SET_DTR_MASK << 8))
157
#define FTDI_SIO_SET_DTR_LOW (0 | ( FTDI_SIO_SET_DTR_MASK << 8))
158
#define FTDI_SIO_SET_RTS_MASK 0x2
159
#define FTDI_SIO_SET_RTS_HIGH (2 | ( FTDI_SIO_SET_RTS_MASK << 8))
160
#define FTDI_SIO_SET_RTS_LOW (0 | ( FTDI_SIO_SET_RTS_MASK << 8))
161
162
/*
163
* BmRequestType: 0100 0000b
164
* bRequest: FTDI_SIO_SET_FLOW_CTRL
165
* wValue: Xoff/Xon
166
* wIndex: Protocol/Port - hIndex is protocol / lIndex is port
167
* wLength: 0
168
* Data: None
169
*
170
* hIndex protocol is:
171
* B0 Output handshaking using RTS/CTS
172
* 0 = disabled
173
* 1 = enabled
174
* B1 Output handshaking using DTR/DSR
175
* 0 = disabled
176
* 1 = enabled
177
* B2 Xon/Xoff handshaking
178
* 0 = disabled
179
* 1 = enabled
180
*
181
* A value of zero in the hIndex field disables handshaking
182
*
183
* If Xon/Xoff handshaking is specified, the hValue field should contain the
184
* XOFF character and the lValue field contains the XON character.
185
*/
186
/* FTDI_SIO_SET_FLOW_CTRL */
187
#define FTDI_SIO_DISABLE_FLOW_CTRL 0x0
188
#define FTDI_SIO_RTS_CTS_HS 0x1
189
#define FTDI_SIO_DTR_DSR_HS 0x2
190
#define FTDI_SIO_XON_XOFF_HS 0x4
191
192
/*
193
* BmRequestType: 0100 0000b
194
* bRequest: FTDI_SIO_SET_EVENT_CHAR
195
* wValue: Event Char
196
* wIndex: Port
197
* wLength: 0
198
* Data: None
199
*
200
* wValue:
201
* B0..7 Event Character
202
* B8 Event Character Processing
203
* 0 = disabled
204
* 1 = enabled
205
* B9..15 Reserved
206
*
207
* FTDI_SIO_SET_EVENT_CHAR
208
*
209
* Set the special event character for the specified communications port.
210
* If the device sees this character it will immediately return the
211
* data read so far - rather than wait 40ms or until 62 bytes are read
212
* which is what normally happens.
213
*/
214
215
/*
216
* BmRequestType: 0100 0000b
217
* bRequest: FTDI_SIO_SET_ERROR_CHAR
218
* wValue: Error Char
219
* wIndex: Port
220
* wLength: 0
221
* Data: None
222
*
223
* Error Char
224
* B0..7 Error Character
225
* B8 Error Character Processing
226
* 0 = disabled
227
* 1 = enabled
228
* B9..15 Reserved
229
* FTDI_SIO_SET_ERROR_CHAR
230
* Set the parity error replacement character for the specified communications
231
* port.
232
*/
233
234
/*
235
* BmRequestType: 1100 0000b
236
* bRequest: FTDI_SIO_GET_MODEM_STATUS
237
* wValue: zero
238
* wIndex: Port
239
* wLength: 1
240
* Data: Status
241
*
242
* One byte of data is returned
243
* B0..3 0
244
* B4 CTS
245
* 0 = inactive
246
* 1 = active
247
* B5 DSR
248
* 0 = inactive
249
* 1 = active
250
* B6 Ring Indicator (RI)
251
* 0 = inactive
252
* 1 = active
253
* B7 Receive Line Signal Detect (RLSD)
254
* 0 = inactive
255
* 1 = active
256
*
257
* FTDI_SIO_GET_MODEM_STATUS
258
* Retrieve the current value of the modem status register.
259
*/
260
#define FTDI_SIO_CTS_MASK 0x10
261
#define FTDI_SIO_DSR_MASK 0x20
262
#define FTDI_SIO_RI_MASK 0x40
263
#define FTDI_SIO_RLSD_MASK 0x80
264
265
/*
266
* DATA FORMAT
267
*
268
* IN Endpoint
269
*
270
* The device reserves the first two bytes of data on this endpoint to contain
271
* the current values of the modem and line status registers. In the absence of
272
* data, the device generates a message consisting of these two status bytes
273
* every 40 ms.
274
*
275
* Byte 0: Modem Status
276
* NOTE: 4 upper bits have same layout as the MSR register in a 16550
277
*
278
* Offset Description
279
* B0..3 Port
280
* B4 Clear to Send (CTS)
281
* B5 Data Set Ready (DSR)
282
* B6 Ring Indicator (RI)
283
* B7 Receive Line Signal Detect (RLSD)
284
*
285
* Byte 1: Line Status
286
* NOTE: same layout as the LSR register in a 16550
287
*
288
* Offset Description
289
* B0 Data Ready (DR)
290
* B1 Overrun Error (OE)
291
* B2 Parity Error (PE)
292
* B3 Framing Error (FE)
293
* B4 Break Interrupt (BI)
294
* B5 Transmitter Holding Register (THRE)
295
* B6 Transmitter Empty (TEMT)
296
* B7 Error in RCVR FIFO
297
* OUT Endpoint
298
*
299
* This device reserves the first bytes of data on this endpoint contain the
300
* length and port identifier of the message. For the FTDI USB Serial converter
301
* the port identifier is always 1.
302
*
303
* Byte 0: Port & length
304
*
305
* Offset Description
306
* B0..1 Port
307
* B2..7 Length of message - (not including Byte 0)
308
*/
309
#define FTDI_PORT_MASK 0x0f
310
#define FTDI_MSR_MASK 0xf0
311
#define FTDI_GET_MSR(p) (((p)[0]) & FTDI_MSR_MASK)
312
#define FTDI_GET_LSR(p) ((p)[1])
313
#define FTDI_LSR_MASK (~0x60)
/* interesting bits */
314
#define FTDI_OUT_TAG(len, port) (((len) << 2) | (port))
dev
usb
serial
uftdi_reg.h
Generated by
1.9.3