xref: /freebsd/share/man/man4/uftdi.4 (revision fa9896e082a1046ff4fbc75fcba4d18d1f2efc19)
131f48889SJosef Karthauser.\" $NetBSD: uftdi.4,v 1.5 2002/02/07 03:15:08 ross Exp $
231f48889SJosef Karthauser.\"
331f48889SJosef Karthauser.\" Copyright (c) 2000 The NetBSD Foundation, Inc.
431f48889SJosef Karthauser.\" All rights reserved.
531f48889SJosef Karthauser.\"
631f48889SJosef Karthauser.\" This code is derived from software contributed to The NetBSD Foundation
731f48889SJosef Karthauser.\" by Lennart Augustsson.
831f48889SJosef Karthauser.\"
931f48889SJosef Karthauser.\" Redistribution and use in source and binary forms, with or without
1031f48889SJosef Karthauser.\" modification, are permitted provided that the following conditions
1131f48889SJosef Karthauser.\" are met:
1231f48889SJosef Karthauser.\" 1. Redistributions of source code must retain the above copyright
1331f48889SJosef Karthauser.\"    notice, this list of conditions and the following disclaimer.
1431f48889SJosef Karthauser.\" 2. Redistributions in binary form must reproduce the above copyright
1531f48889SJosef Karthauser.\"    notice, this list of conditions and the following disclaimer in the
1631f48889SJosef Karthauser.\"    documentation and/or other materials provided with the distribution.
1731f48889SJosef Karthauser.\"
1831f48889SJosef Karthauser.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
1931f48889SJosef Karthauser.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
2031f48889SJosef Karthauser.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
2131f48889SJosef Karthauser.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
2231f48889SJosef Karthauser.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
2331f48889SJosef Karthauser.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
2431f48889SJosef Karthauser.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
2531f48889SJosef Karthauser.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
2631f48889SJosef Karthauser.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
2731f48889SJosef Karthauser.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
2831f48889SJosef Karthauser.\" POSSIBILITY OF SUCH DAMAGE.
2931f48889SJosef Karthauser.\"
304f4acb65SEdward Tomasz Napierala.Dd April 26, 2017
3131f48889SJosef Karthauser.Dt UFTDI 4
3231f48889SJosef Karthauser.Os
3331f48889SJosef Karthauser.Sh NAME
3431f48889SJosef Karthauser.Nm uftdi
35ea25ea8cSIan Lepore.Nd USB support for serial adapters based on the FTDI family of USB
36ea25ea8cSIan Leporeserial adapter chips.
3731f48889SJosef Karthauser.Sh SYNOPSIS
380a771a3bSChristian BruefferTo compile this driver into the kernel,
390a771a3bSChristian Bruefferplace the following lines in your
400a771a3bSChristian Bruefferkernel configuration file:
410a771a3bSChristian Brueffer.Bd -ragged -offset indent
4299fc5899SMartin Wilke.Cd "device usb"
4399fc5899SMartin Wilke.Cd "device ucom"
44fc1a4ecfSWarner Losh.Cd "device uftdi"
450a771a3bSChristian Brueffer.Ed
460a771a3bSChristian Brueffer.Pp
470a771a3bSChristian BruefferAlternatively, to load the driver as a
480a771a3bSChristian Brueffermodule at boot time, place the following line in
490a771a3bSChristian Brueffer.Xr loader.conf 5 :
500a771a3bSChristian Brueffer.Bd -literal -offset indent
510a771a3bSChristian Bruefferuftdi_load="YES"
520a771a3bSChristian Brueffer.Ed
5331f48889SJosef Karthauser.Sh DESCRIPTION
5431f48889SJosef KarthauserThe
5531f48889SJosef Karthauser.Nm
56ea25ea8cSIan Leporedriver provides support for various serial adapters based on the
57ea25ea8cSIan Leporefollowing FTDI chips:
58ea25ea8cSIan Lepore.Pp
59ea25ea8cSIan Lepore.Bl -bullet -compact
60ea25ea8cSIan Lepore.It
61ea25ea8cSIan LeporeFT8U100AX
62ea25ea8cSIan Lepore.It
63ea25ea8cSIan LeporeFT8U232AM
64ea25ea8cSIan Lepore.It
65ea25ea8cSIan LeporeFT8U232BM
66ea25ea8cSIan Lepore.It
67ea25ea8cSIan LeporeFT232R
68ea25ea8cSIan Lepore.It
69ea25ea8cSIan LeporeFT2232C
70ea25ea8cSIan Lepore.It
71ea25ea8cSIan LeporeFT2232D
72ea25ea8cSIan Lepore.It
73ea25ea8cSIan LeporeFT2232H
74ea25ea8cSIan Lepore.It
75ea25ea8cSIan LeporeFT4232H
76ea25ea8cSIan Lepore.It
77ea25ea8cSIan LeporeFT230X
78ea25ea8cSIan Lepore.El
7931f48889SJosef Karthauser.Pp
8031f48889SJosef KarthauserThe device is accessed through the
8131f48889SJosef Karthauser.Xr ucom 4
8231f48889SJosef Karthauserdriver which makes it behave like a
8331f48889SJosef Karthauser.Xr tty 4 .
84a9d84a2bSIan Lepore.Pp
85a9d84a2bSIan LeporeMany of the supported chips provide additional functionality
86a9d84a2bSIan Leporesuch as bitbang mode and the MPSSE engine for serial bus emulation.
87a9d84a2bSIan LeporeThe
88a9d84a2bSIan Lepore.Nm
89a9d84a2bSIan Leporedriver provides access to that functionality with the following
90a9d84a2bSIan Lepore.Xr ioctl 2
91a9d84a2bSIan Leporecalls, defined in
92a9d84a2bSIan Lepore.In dev/usb/uftdiio.h :
93a9d84a2bSIan Lepore.Bl -tag -width indent
94a9d84a2bSIan Lepore.It Dv UFTDIIOC_RESET_IO Pq Vt int
95a9d84a2bSIan LeporeReset the channel to its default configuration, flush RX and TX FIFOs.
96a9d84a2bSIan Lepore.It Dv UFTDIIOC_RESET_RX Pq Vt int
97a9d84a2bSIan LeporeFlush the RX FIFO.
98a9d84a2bSIan Lepore.It Dv UFTDIIOC_RESET_TX Pq Vt int
99a9d84a2bSIan LeporeFlush the TX FIFO.
100a9d84a2bSIan Lepore.It Dv UFTDIIOC_SET_BITMODE Pq Vt "struct uftdi_bitmode"
101a9d84a2bSIan LeporePut the channel into the operating mode specified in
102a9d84a2bSIan Lepore.Va mode ,
103a9d84a2bSIan Leporeand set the pins indicated by ones in
104a9d84a2bSIan Lepore.Va iomask
105a9d84a2bSIan Leporeto output mode.
106a9d84a2bSIan LeporeThe
107a9d84a2bSIan Lepore.Va mode
108a9d84a2bSIan Leporemust be one of the
109a9d84a2bSIan Lepore.Va uftdi_bitmodes
110a9d84a2bSIan Leporevalues.
111374b1ec1SIan LeporeSetting
112374b1ec1SIan Lepore.Va mode
113374b1ec1SIan Leporeto
114374b1ec1SIan Lepore.Dv UFTDI_BITMODE_NONE
115374b1ec1SIan Leporereturns the channel to standard UART mode.
116a9d84a2bSIan Lepore.Bd -literal
117a9d84a2bSIan Leporeenum uftdi_bitmodes
118a9d84a2bSIan Lepore{
119a9d84a2bSIan Lepore	UFTDI_BITMODE_ASYNC = 0,
120a9d84a2bSIan Lepore	UFTDI_BITMODE_MPSSE = 1,
121a9d84a2bSIan Lepore	UFTDI_BITMODE_SYNC = 2,
122a9d84a2bSIan Lepore	UFTDI_BITMODE_CPU_EMUL = 3,
123a9d84a2bSIan Lepore	UFTDI_BITMODE_FAST_SERIAL = 4,
124a9d84a2bSIan Lepore	UFTDI_BITMODE_CBUS = 5,
125a9d84a2bSIan Lepore	UFTDI_BITMODE_NONE = 0xff,
126a9d84a2bSIan Lepore};
127a9d84a2bSIan Lepore
128a9d84a2bSIan Leporestruct uftdi_bitmode
129a9d84a2bSIan Lepore{
130a9d84a2bSIan Lepore	uint8_t mode;
131a9d84a2bSIan Lepore	uint8_t iomask;
132a9d84a2bSIan Lepore};
133a9d84a2bSIan Lepore.Ed
134a9d84a2bSIan Lepore.Pp
135a9d84a2bSIan LeporeManuals and application notes published by FTDI describe these
136a9d84a2bSIan Leporemodes in detail.
137a9d84a2bSIan LeporeTo use most of these modes, you first put the channel into
138a9d84a2bSIan Leporethe desired mode, then you
139a9d84a2bSIan Lepore.Xr read 2
140a9d84a2bSIan Leporeand
141a9d84a2bSIan Lepore.Xr write 2
142a9d84a2bSIan Leporedata which either reflects pin state or is interpreted
143a9d84a2bSIan Leporeas MPSSE commands and parameters, depending on the mode.
144a9d84a2bSIan Lepore.It Dv UFTDIIOC_GET_BITMODE Pq Vt "struct uftdi_bitmode"
145374b1ec1SIan LeporeReturn the current bitbang mode in the
146374b1ec1SIan Lepore.Va mode
147374b1ec1SIan Leporemember, and the state of the DBUS0..DBUS7 pins at the time
148374b1ec1SIan Leporeof the call in the
149a9d84a2bSIan Lepore.Va iomask
150a9d84a2bSIan Leporemember.
151374b1ec1SIan LeporeThe pin state can be read while the chip is in any mode, including
152374b1ec1SIan Lepore.Dv UFTDI_BITMODE_NONE
153374b1ec1SIan Lepore(UART) mode.
154a9d84a2bSIan Lepore.It Dv UFTDIIOC_SET_ERROR_CHAR Pq Vt int
155a9d84a2bSIan LeporeSet the character which is inserted into the buffer to mark
156a9d84a2bSIan Leporethe point of an error such as FIFO overflow.
157a9d84a2bSIan Lepore.It Dv UFTDIIOC_SET_EVENT_CHAR Pq Vt int
158a9d84a2bSIan LeporeSet the character which causes a partial FIFO full of data
159a9d84a2bSIan Leporeto be returned immediately even if the FIFO is not full.
160a9d84a2bSIan Lepore.It Dv UFTDIIOC_SET_LATENCY Pq Vt int
161a9d84a2bSIan LeporeSet the amount of time to wait for a full FIFO,
162a9d84a2bSIan Leporein milliseconds.
163a9d84a2bSIan LeporeIf more than this much time elapses without receiving a new
164a9d84a2bSIan Leporecharacter, any characters in the FIFO are returned.
165a9d84a2bSIan Lepore.It Dv UFTDIIOC_GET_LATENCY Pq Vt int
166a9d84a2bSIan LeporeGet the current value of the latency timer.
167a9d84a2bSIan Lepore.It Dv UFTDIIOC_GET_HWREV Pq Vt int
168a9d84a2bSIan LeporeGet the hardware revision number.
169a9d84a2bSIan LeporeThis is the
170a9d84a2bSIan Lepore.Va bcdDevice
171a9d84a2bSIan Leporevalue from the
172a9d84a2bSIan Lepore.Va usb_device_descriptor .
173374b1ec1SIan Lepore.It Dv UFTDIIOC_READ_EEPROM Pq Vt "struct uftdi_eeio"
174374b1ec1SIan LeporeRead one or more words from the configuration eeprom.
175374b1ec1SIan LeporeThe FTDI chip performs eeprom I/O in 16-bit words.
176374b1ec1SIan LeporeSet
177374b1ec1SIan Lepore.Va offset
178374b1ec1SIan Leporeand
179374b1ec1SIan Lepore.Va length
180374b1ec1SIan Leporeto values evenly divisible by two before the call, and the
181374b1ec1SIan Lepore.Va data
182374b1ec1SIan Leporearray will contain the requested values from eeprom after the call.
183374b1ec1SIan Lepore.Bd -literal
184374b1ec1SIan Leporestruct uftdi_eeio
185374b1ec1SIan Lepore{
186374b1ec1SIan Lepore	uint16_t offset;
187374b1ec1SIan Lepore	uint16_t length;
188374b1ec1SIan Lepore	uint16_t data[64];
189374b1ec1SIan Lepore};
190374b1ec1SIan Lepore.Ed
191374b1ec1SIan Lepore.Pp
192374b1ec1SIan LeporeThe FT232R chip has an internal eeprom.
193374b1ec1SIan LeporeAn external serial eeprom is optional on other FTDI chips.
194374b1ec1SIan LeporeThe eeprom may contain 64, 128, or 256 words,
195374b1ec1SIan Leporedepending on the part used.
196374b1ec1SIan LeporeMultiple calls may be needed to read or write the larger parts.
197374b1ec1SIan LeporeWhen no eeprom is present, all words in the returned data are 0xffff.
198374b1ec1SIan LeporeAn erased eeprom also reads as all 0xffff.
199374b1ec1SIan Lepore.It Dv UFTDIIOC_WRITE_EEPROM Pq Vt "struct uftdi_eeio"
200374b1ec1SIan LeporeWrite one or more words to the configuration eeprom.
201374b1ec1SIan LeporeThe
202374b1ec1SIan Lepore.Va uftdi_eeio
203374b1ec1SIan Leporevalues are as described for
204374b1ec1SIan Lepore.Dv UFTDIIOC_READ_EEPROM .
205374b1ec1SIan Lepore.Pp
206374b1ec1SIan LeporeThe FTDI chip does a blind write to the eeprom, and it will appear
207374b1ec1SIan Leporeto succeed even when no eeprom is present.
208374b1ec1SIan LeporeTo ensure a good write you must read back and verify the data.
209374b1ec1SIan LeporeIt is
210374b1ec1SIan Lepore.Em not
211374b1ec1SIan Leporenecessary to erase before writing.
212374b1ec1SIan LeporeAny position within the eeprom can be overwritten at any time.
213374b1ec1SIan Lepore.It Dv UFTDIIOC_ERASE_EEPROM Pq Vt int
214374b1ec1SIan LeporeErase the entire eeprom.
215374b1ec1SIan LeporeThis is useful primarily for test and debugging, as there is no
216374b1ec1SIan Leporeneed to erase before writing.
217374b1ec1SIan LeporeTo help prevent accidental erasure caused by calling the wrong
218374b1ec1SIan Leporeioctl, you must pass the special value
219374b1ec1SIan Lepore.Dv UFTDI_CONFIRM_ERASE
220374b1ec1SIan Leporeas the argument to this ioctl.
22101c73a3bSGlen Barber.El
222fe72d7b1SSimon L. B. Nielsen.Sh HARDWARE
223fe72d7b1SSimon L. B. NielsenThe
224fe72d7b1SSimon L. B. Nielsen.Nm
225fe72d7b1SSimon L. B. Nielsendriver supports the following adapters:
226fe72d7b1SSimon L. B. Nielsen.Pp
227fe72d7b1SSimon L. B. Nielsen.Bl -bullet -compact
228fe72d7b1SSimon L. B. Nielsen.It
2293aa6430fSLukas ErtlB&B Electronics USB->RS422/485 adapter
2303aa6430fSLukas Ertl.It
23129881a83SMarc FonvieilleElexol USB MOD1 and USB MOD3
232f53b14baSMarc Fonvieille.It
233fe72d7b1SSimon L. B. NielsenHP USB-Serial adapter shipped with some HP laptops
234fe72d7b1SSimon L. B. Nielsen.It
235fe72d7b1SSimon L. B. NielsenInland UAS111
236fe72d7b1SSimon L. B. Nielsen.It
237fe72d7b1SSimon L. B. NielsenQVS USC-1000
23899f1557aSTakanori Watanabe.It
23999f1557aSTakanori WatanabeBuffalo PC-OP-RS / Kurouto-shikou KURO-RS universal remote
2407bc5465eSPoul-Henning Kamp.It
2417bc5465eSPoul-Henning KampPrologix GPIB-USB Controller
242fe72d7b1SSimon L. B. Nielsen.El
2434f4acb65SEdward Tomasz Napierala.Sh FILES
244*fa196deaSEdward Tomasz Napierala.Bl -tag -width "/dev/ttyU*.init" -compact
245*fa196deaSEdward Tomasz Napierala.It Pa /dev/ttyU*
2464f4acb65SEdward Tomasz Napieralafor callin ports
247*fa196deaSEdward Tomasz Napierala.It Pa /dev/ttyU*.init
248*fa196deaSEdward Tomasz Napierala.It Pa /dev/ttyU*.lock
2494f4acb65SEdward Tomasz Napieralacorresponding callin initial-state and lock-state devices
2504f4acb65SEdward Tomasz Napierala.Pp
251*fa196deaSEdward Tomasz Napierala.It Pa /dev/cuaU*
2524f4acb65SEdward Tomasz Napieralafor callout ports
253*fa196deaSEdward Tomasz Napierala.It Pa /dev/cuaU*.init
254*fa196deaSEdward Tomasz Napierala.It Pa /dev/cuaU*.lock
2554f4acb65SEdward Tomasz Napieralacorresponding callout initial-state and lock-state devices
2564f4acb65SEdward Tomasz Napierala.El
25731f48889SJosef Karthauser.Sh SEE ALSO
25831f48889SJosef Karthauser.Xr tty 4 ,
25931f48889SJosef Karthauser.Xr ucom 4 ,
26031f48889SJosef Karthauser.Xr usb 4
26131f48889SJosef Karthauser.Sh HISTORY
26231f48889SJosef KarthauserThe
26331f48889SJosef Karthauser.Nm
26431f48889SJosef Karthauserdriver
26531f48889SJosef Karthauserappeared in
266a10ab609SDavid E. O'Brien.Fx 4.8
267a10ab609SDavid E. O'Brienfrom
26831f48889SJosef Karthauser.Nx 1.5 .
269