xref: /freebsd/share/man/man4/uftdi.4 (revision 926ce35a7e33457153b56be1ba51a31aea674000)
1.\" $NetBSD: uftdi.4,v 1.5 2002/02/07 03:15:08 ross Exp $
2.\"
3.\" Copyright (c) 2000 The NetBSD Foundation, Inc.
4.\" All rights reserved.
5.\"
6.\" This code is derived from software contributed to The NetBSD Foundation
7.\" by Lennart Augustsson.
8.\"
9.\" Redistribution and use in source and binary forms, with or without
10.\" modification, are permitted provided that the following conditions
11.\" are met:
12.\" 1. Redistributions of source code must retain the above copyright
13.\"    notice, this list of conditions and the following disclaimer.
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\"    notice, this list of conditions and the following disclaimer in the
16.\"    documentation and/or other materials provided with the distribution.
17.\"
18.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
19.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
20.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
22.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28.\" POSSIBILITY OF SUCH DAMAGE.
29.\"
30.\" $FreeBSD$
31.\"
32.Dd April 26, 2017
33.Dt UFTDI 4
34.Os
35.Sh NAME
36.Nm uftdi
37.Nd USB support for serial adapters based on the FTDI family of USB
38serial adapter chips.
39.Sh SYNOPSIS
40To compile this driver into the kernel,
41place the following lines in your
42kernel configuration file:
43.Bd -ragged -offset indent
44.Cd "device usb"
45.Cd "device ucom"
46.Cd "device uftdi"
47.Ed
48.Pp
49Alternatively, to load the driver as a
50module at boot time, place the following line in
51.Xr loader.conf 5 :
52.Bd -literal -offset indent
53uftdi_load="YES"
54.Ed
55.Sh DESCRIPTION
56The
57.Nm
58driver provides support for various serial adapters based on the
59following FTDI chips:
60.Pp
61.Bl -bullet -compact
62.It
63FT8U100AX
64.It
65FT8U232AM
66.It
67FT8U232BM
68.It
69FT232R
70.It
71FT2232C
72.It
73FT2232D
74.It
75FT2232H
76.It
77FT4232H
78.It
79FT230X
80.El
81.Pp
82The device is accessed through the
83.Xr ucom 4
84driver which makes it behave like a
85.Xr tty 4 .
86.Pp
87Many of the supported chips provide additional functionality
88such as bitbang mode and the MPSSE engine for serial bus emulation.
89The
90.Nm
91driver provides access to that functionality with the following
92.Xr ioctl 2
93calls, defined in
94.In dev/usb/uftdiio.h :
95.Bl -tag -width indent
96.It Dv UFTDIIOC_RESET_IO Pq Vt int
97Reset the channel to its default configuration, flush RX and TX FIFOs.
98.It Dv UFTDIIOC_RESET_RX Pq Vt int
99Flush the RX FIFO.
100.It Dv UFTDIIOC_RESET_TX Pq Vt int
101Flush the TX FIFO.
102.It Dv UFTDIIOC_SET_BITMODE Pq Vt "struct uftdi_bitmode"
103Put the channel into the operating mode specified in
104.Va mode ,
105and set the pins indicated by ones in
106.Va iomask
107to output mode.
108The
109.Va mode
110must be one of the
111.Va uftdi_bitmodes
112values.
113Setting
114.Va mode
115to
116.Dv UFTDI_BITMODE_NONE
117returns the channel to standard UART mode.
118.Bd -literal
119enum uftdi_bitmodes
120{
121	UFTDI_BITMODE_ASYNC = 0,
122	UFTDI_BITMODE_MPSSE = 1,
123	UFTDI_BITMODE_SYNC = 2,
124	UFTDI_BITMODE_CPU_EMUL = 3,
125	UFTDI_BITMODE_FAST_SERIAL = 4,
126	UFTDI_BITMODE_CBUS = 5,
127	UFTDI_BITMODE_NONE = 0xff,
128};
129
130struct uftdi_bitmode
131{
132	uint8_t mode;
133	uint8_t iomask;
134};
135.Ed
136.Pp
137Manuals and application notes published by FTDI describe these
138modes in detail.
139To use most of these modes, you first put the channel into
140the desired mode, then you
141.Xr read 2
142and
143.Xr write 2
144data which either reflects pin state or is interpreted
145as MPSSE commands and parameters, depending on the mode.
146.It Dv UFTDIIOC_GET_BITMODE Pq Vt "struct uftdi_bitmode"
147Return the current bitbang mode in the
148.Va mode
149member, and the state of the DBUS0..DBUS7 pins at the time
150of the call in the
151.Va iomask
152member.
153The pin state can be read while the chip is in any mode, including
154.Dv UFTDI_BITMODE_NONE
155(UART) mode.
156.It Dv UFTDIIOC_SET_ERROR_CHAR Pq Vt int
157Set the character which is inserted into the buffer to mark
158the point of an error such as FIFO overflow.
159.It Dv UFTDIIOC_SET_EVENT_CHAR Pq Vt int
160Set the character which causes a partial FIFO full of data
161to be returned immediately even if the FIFO is not full.
162.It Dv UFTDIIOC_SET_LATENCY Pq Vt int
163Set the amount of time to wait for a full FIFO,
164in milliseconds.
165If more than this much time elapses without receiving a new
166character, any characters in the FIFO are returned.
167.It Dv UFTDIIOC_GET_LATENCY Pq Vt int
168Get the current value of the latency timer.
169.It Dv UFTDIIOC_GET_HWREV Pq Vt int
170Get the hardware revision number.
171This is the
172.Va bcdDevice
173value from the
174.Va usb_device_descriptor .
175.It Dv UFTDIIOC_READ_EEPROM Pq Vt "struct uftdi_eeio"
176Read one or more words from the configuration eeprom.
177The FTDI chip performs eeprom I/O in 16-bit words.
178Set
179.Va offset
180and
181.Va length
182to values evenly divisible by two before the call, and the
183.Va data
184array will contain the requested values from eeprom after the call.
185.Bd -literal
186struct uftdi_eeio
187{
188	uint16_t offset;
189	uint16_t length;
190	uint16_t data[64];
191};
192.Ed
193.Pp
194The FT232R chip has an internal eeprom.
195An external serial eeprom is optional on other FTDI chips.
196The eeprom may contain 64, 128, or 256 words,
197depending on the part used.
198Multiple calls may be needed to read or write the larger parts.
199When no eeprom is present, all words in the returned data are 0xffff.
200An erased eeprom also reads as all 0xffff.
201.It Dv UFTDIIOC_WRITE_EEPROM Pq Vt "struct uftdi_eeio"
202Write one or more words to the configuration eeprom.
203The
204.Va uftdi_eeio
205values are as described for
206.Dv UFTDIIOC_READ_EEPROM .
207.Pp
208The FTDI chip does a blind write to the eeprom, and it will appear
209to succeed even when no eeprom is present.
210To ensure a good write you must read back and verify the data.
211It is
212.Em not
213necessary to erase before writing.
214Any position within the eeprom can be overwritten at any time.
215.It Dv UFTDIIOC_ERASE_EEPROM Pq Vt int
216Erase the entire eeprom.
217This is useful primarily for test and debugging, as there is no
218need to erase before writing.
219To help prevent accidental erasure caused by calling the wrong
220ioctl, you must pass the special value
221.Dv UFTDI_CONFIRM_ERASE
222as the argument to this ioctl.
223.El
224.Sh HARDWARE
225The
226.Nm
227driver supports the following adapters:
228.Pp
229.Bl -bullet -compact
230.It
231B&B Electronics USB->RS422/485 adapter
232.It
233Elexol USB MOD1 and USB MOD3
234.It
235HP USB-Serial adapter shipped with some HP laptops
236.It
237Inland UAS111
238.It
239QVS USC-1000
240.It
241Buffalo PC-OP-RS / Kurouto-shikou KURO-RS universal remote
242.It
243Prologix GPIB-USB Controller
244.El
245.Sh FILES
246.Bl -tag -width "/dev/ttyU*.init" -compact
247.It Pa /dev/ttyU*
248for callin ports
249.It Pa /dev/ttyU*.init
250.It Pa /dev/ttyU*.lock
251corresponding callin initial-state and lock-state devices
252.Pp
253.It Pa /dev/cuaU*
254for callout ports
255.It Pa /dev/cuaU*.init
256.It Pa /dev/cuaU*.lock
257corresponding callout initial-state and lock-state devices
258.El
259.Sh SEE ALSO
260.Xr tty 4 ,
261.Xr ucom 4 ,
262.Xr usb 4
263.Sh HISTORY
264The
265.Nm
266driver
267appeared in
268.Fx 4.8
269from
270.Nx 1.5 .
271