xref: /freebsd/share/man/man4/uftdi.4 (revision fa196dea221ece5efebff38017ac66220b46c2ce)
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.\"
3031f48889SJosef Karthauser.\" $FreeBSD$
3131f48889SJosef Karthauser.\"
324f4acb65SEdward Tomasz Napierala.Dd April 26, 2017
3331f48889SJosef Karthauser.Dt UFTDI 4
3431f48889SJosef Karthauser.Os
3531f48889SJosef Karthauser.Sh NAME
3631f48889SJosef Karthauser.Nm uftdi
37ea25ea8cSIan Lepore.Nd USB support for serial adapters based on the FTDI family of USB
38ea25ea8cSIan Leporeserial adapter chips.
3931f48889SJosef Karthauser.Sh SYNOPSIS
400a771a3bSChristian BruefferTo compile this driver into the kernel,
410a771a3bSChristian Bruefferplace the following lines in your
420a771a3bSChristian Bruefferkernel configuration file:
430a771a3bSChristian Brueffer.Bd -ragged -offset indent
4499fc5899SMartin Wilke.Cd "device usb"
4599fc5899SMartin Wilke.Cd "device ucom"
46fc1a4ecfSWarner Losh.Cd "device uftdi"
470a771a3bSChristian Brueffer.Ed
480a771a3bSChristian Brueffer.Pp
490a771a3bSChristian BruefferAlternatively, to load the driver as a
500a771a3bSChristian Brueffermodule at boot time, place the following line in
510a771a3bSChristian Brueffer.Xr loader.conf 5 :
520a771a3bSChristian Brueffer.Bd -literal -offset indent
530a771a3bSChristian Bruefferuftdi_load="YES"
540a771a3bSChristian Brueffer.Ed
5531f48889SJosef Karthauser.Sh DESCRIPTION
5631f48889SJosef KarthauserThe
5731f48889SJosef Karthauser.Nm
58ea25ea8cSIan Leporedriver provides support for various serial adapters based on the
59ea25ea8cSIan Leporefollowing FTDI chips:
60ea25ea8cSIan Lepore.Pp
61ea25ea8cSIan Lepore.Bl -bullet -compact
62ea25ea8cSIan Lepore.It
63ea25ea8cSIan LeporeFT8U100AX
64ea25ea8cSIan Lepore.It
65ea25ea8cSIan LeporeFT8U232AM
66ea25ea8cSIan Lepore.It
67ea25ea8cSIan LeporeFT8U232BM
68ea25ea8cSIan Lepore.It
69ea25ea8cSIan LeporeFT232R
70ea25ea8cSIan Lepore.It
71ea25ea8cSIan LeporeFT2232C
72ea25ea8cSIan Lepore.It
73ea25ea8cSIan LeporeFT2232D
74ea25ea8cSIan Lepore.It
75ea25ea8cSIan LeporeFT2232H
76ea25ea8cSIan Lepore.It
77ea25ea8cSIan LeporeFT4232H
78ea25ea8cSIan Lepore.It
79ea25ea8cSIan LeporeFT230X
80ea25ea8cSIan Lepore.El
8131f48889SJosef Karthauser.Pp
8231f48889SJosef KarthauserThe device is accessed through the
8331f48889SJosef Karthauser.Xr ucom 4
8431f48889SJosef Karthauserdriver which makes it behave like a
8531f48889SJosef Karthauser.Xr tty 4 .
86a9d84a2bSIan Lepore.Pp
87a9d84a2bSIan LeporeMany of the supported chips provide additional functionality
88a9d84a2bSIan Leporesuch as bitbang mode and the MPSSE engine for serial bus emulation.
89a9d84a2bSIan LeporeThe
90a9d84a2bSIan Lepore.Nm
91a9d84a2bSIan Leporedriver provides access to that functionality with the following
92a9d84a2bSIan Lepore.Xr ioctl 2
93a9d84a2bSIan Leporecalls, defined in
94a9d84a2bSIan Lepore.In dev/usb/uftdiio.h :
95a9d84a2bSIan Lepore.Bl -tag -width indent
96a9d84a2bSIan Lepore.It Dv UFTDIIOC_RESET_IO Pq Vt int
97a9d84a2bSIan LeporeReset the channel to its default configuration, flush RX and TX FIFOs.
98a9d84a2bSIan Lepore.It Dv UFTDIIOC_RESET_RX Pq Vt int
99a9d84a2bSIan LeporeFlush the RX FIFO.
100a9d84a2bSIan Lepore.It Dv UFTDIIOC_RESET_TX Pq Vt int
101a9d84a2bSIan LeporeFlush the TX FIFO.
102a9d84a2bSIan Lepore.It Dv UFTDIIOC_SET_BITMODE Pq Vt "struct uftdi_bitmode"
103a9d84a2bSIan LeporePut the channel into the operating mode specified in
104a9d84a2bSIan Lepore.Va mode ,
105a9d84a2bSIan Leporeand set the pins indicated by ones in
106a9d84a2bSIan Lepore.Va iomask
107a9d84a2bSIan Leporeto output mode.
108a9d84a2bSIan LeporeThe
109a9d84a2bSIan Lepore.Va mode
110a9d84a2bSIan Leporemust be one of the
111a9d84a2bSIan Lepore.Va uftdi_bitmodes
112a9d84a2bSIan Leporevalues.
113374b1ec1SIan LeporeSetting
114374b1ec1SIan Lepore.Va mode
115374b1ec1SIan Leporeto
116374b1ec1SIan Lepore.Dv UFTDI_BITMODE_NONE
117374b1ec1SIan Leporereturns the channel to standard UART mode.
118a9d84a2bSIan Lepore.Bd -literal
119a9d84a2bSIan Leporeenum uftdi_bitmodes
120a9d84a2bSIan Lepore{
121a9d84a2bSIan Lepore	UFTDI_BITMODE_ASYNC = 0,
122a9d84a2bSIan Lepore	UFTDI_BITMODE_MPSSE = 1,
123a9d84a2bSIan Lepore	UFTDI_BITMODE_SYNC = 2,
124a9d84a2bSIan Lepore	UFTDI_BITMODE_CPU_EMUL = 3,
125a9d84a2bSIan Lepore	UFTDI_BITMODE_FAST_SERIAL = 4,
126a9d84a2bSIan Lepore	UFTDI_BITMODE_CBUS = 5,
127a9d84a2bSIan Lepore	UFTDI_BITMODE_NONE = 0xff,
128a9d84a2bSIan Lepore};
129a9d84a2bSIan Lepore
130a9d84a2bSIan Leporestruct uftdi_bitmode
131a9d84a2bSIan Lepore{
132a9d84a2bSIan Lepore	uint8_t mode;
133a9d84a2bSIan Lepore	uint8_t iomask;
134a9d84a2bSIan Lepore};
135a9d84a2bSIan Lepore.Ed
136a9d84a2bSIan Lepore.Pp
137a9d84a2bSIan LeporeManuals and application notes published by FTDI describe these
138a9d84a2bSIan Leporemodes in detail.
139a9d84a2bSIan LeporeTo use most of these modes, you first put the channel into
140a9d84a2bSIan Leporethe desired mode, then you
141a9d84a2bSIan Lepore.Xr read 2
142a9d84a2bSIan Leporeand
143a9d84a2bSIan Lepore.Xr write 2
144a9d84a2bSIan Leporedata which either reflects pin state or is interpreted
145a9d84a2bSIan Leporeas MPSSE commands and parameters, depending on the mode.
146a9d84a2bSIan Lepore.It Dv UFTDIIOC_GET_BITMODE Pq Vt "struct uftdi_bitmode"
147374b1ec1SIan LeporeReturn the current bitbang mode in the
148374b1ec1SIan Lepore.Va mode
149374b1ec1SIan Leporemember, and the state of the DBUS0..DBUS7 pins at the time
150374b1ec1SIan Leporeof the call in the
151a9d84a2bSIan Lepore.Va iomask
152a9d84a2bSIan Leporemember.
153374b1ec1SIan LeporeThe pin state can be read while the chip is in any mode, including
154374b1ec1SIan Lepore.Dv UFTDI_BITMODE_NONE
155374b1ec1SIan Lepore(UART) mode.
156a9d84a2bSIan Lepore.It Dv UFTDIIOC_SET_ERROR_CHAR Pq Vt int
157a9d84a2bSIan LeporeSet the character which is inserted into the buffer to mark
158a9d84a2bSIan Leporethe point of an error such as FIFO overflow.
159a9d84a2bSIan Lepore.It Dv UFTDIIOC_SET_EVENT_CHAR Pq Vt int
160a9d84a2bSIan LeporeSet the character which causes a partial FIFO full of data
161a9d84a2bSIan Leporeto be returned immediately even if the FIFO is not full.
162a9d84a2bSIan Lepore.It Dv UFTDIIOC_SET_LATENCY Pq Vt int
163a9d84a2bSIan LeporeSet the amount of time to wait for a full FIFO,
164a9d84a2bSIan Leporein milliseconds.
165a9d84a2bSIan LeporeIf more than this much time elapses without receiving a new
166a9d84a2bSIan Leporecharacter, any characters in the FIFO are returned.
167a9d84a2bSIan Lepore.It Dv UFTDIIOC_GET_LATENCY Pq Vt int
168a9d84a2bSIan LeporeGet the current value of the latency timer.
169a9d84a2bSIan Lepore.It Dv UFTDIIOC_GET_HWREV Pq Vt int
170a9d84a2bSIan LeporeGet the hardware revision number.
171a9d84a2bSIan LeporeThis is the
172a9d84a2bSIan Lepore.Va bcdDevice
173a9d84a2bSIan Leporevalue from the
174a9d84a2bSIan Lepore.Va usb_device_descriptor .
175374b1ec1SIan Lepore.It Dv UFTDIIOC_READ_EEPROM Pq Vt "struct uftdi_eeio"
176374b1ec1SIan LeporeRead one or more words from the configuration eeprom.
177374b1ec1SIan LeporeThe FTDI chip performs eeprom I/O in 16-bit words.
178374b1ec1SIan LeporeSet
179374b1ec1SIan Lepore.Va offset
180374b1ec1SIan Leporeand
181374b1ec1SIan Lepore.Va length
182374b1ec1SIan Leporeto values evenly divisible by two before the call, and the
183374b1ec1SIan Lepore.Va data
184374b1ec1SIan Leporearray will contain the requested values from eeprom after the call.
185374b1ec1SIan Lepore.Bd -literal
186374b1ec1SIan Leporestruct uftdi_eeio
187374b1ec1SIan Lepore{
188374b1ec1SIan Lepore	uint16_t offset;
189374b1ec1SIan Lepore	uint16_t length;
190374b1ec1SIan Lepore	uint16_t data[64];
191374b1ec1SIan Lepore};
192374b1ec1SIan Lepore.Ed
193374b1ec1SIan Lepore.Pp
194374b1ec1SIan LeporeThe FT232R chip has an internal eeprom.
195374b1ec1SIan LeporeAn external serial eeprom is optional on other FTDI chips.
196374b1ec1SIan LeporeThe eeprom may contain 64, 128, or 256 words,
197374b1ec1SIan Leporedepending on the part used.
198374b1ec1SIan LeporeMultiple calls may be needed to read or write the larger parts.
199374b1ec1SIan LeporeWhen no eeprom is present, all words in the returned data are 0xffff.
200374b1ec1SIan LeporeAn erased eeprom also reads as all 0xffff.
201374b1ec1SIan Lepore.It Dv UFTDIIOC_WRITE_EEPROM Pq Vt "struct uftdi_eeio"
202374b1ec1SIan LeporeWrite one or more words to the configuration eeprom.
203374b1ec1SIan LeporeThe
204374b1ec1SIan Lepore.Va uftdi_eeio
205374b1ec1SIan Leporevalues are as described for
206374b1ec1SIan Lepore.Dv UFTDIIOC_READ_EEPROM .
207374b1ec1SIan Lepore.Pp
208374b1ec1SIan LeporeThe FTDI chip does a blind write to the eeprom, and it will appear
209374b1ec1SIan Leporeto succeed even when no eeprom is present.
210374b1ec1SIan LeporeTo ensure a good write you must read back and verify the data.
211374b1ec1SIan LeporeIt is
212374b1ec1SIan Lepore.Em not
213374b1ec1SIan Leporenecessary to erase before writing.
214374b1ec1SIan LeporeAny position within the eeprom can be overwritten at any time.
215374b1ec1SIan Lepore.It Dv UFTDIIOC_ERASE_EEPROM Pq Vt int
216374b1ec1SIan LeporeErase the entire eeprom.
217374b1ec1SIan LeporeThis is useful primarily for test and debugging, as there is no
218374b1ec1SIan Leporeneed to erase before writing.
219374b1ec1SIan LeporeTo help prevent accidental erasure caused by calling the wrong
220374b1ec1SIan Leporeioctl, you must pass the special value
221374b1ec1SIan Lepore.Dv UFTDI_CONFIRM_ERASE
222374b1ec1SIan Leporeas the argument to this ioctl.
22301c73a3bSGlen Barber.El
224fe72d7b1SSimon L. B. Nielsen.Sh HARDWARE
225fe72d7b1SSimon L. B. NielsenThe
226fe72d7b1SSimon L. B. Nielsen.Nm
227fe72d7b1SSimon L. B. Nielsendriver supports the following adapters:
228fe72d7b1SSimon L. B. Nielsen.Pp
229fe72d7b1SSimon L. B. Nielsen.Bl -bullet -compact
230fe72d7b1SSimon L. B. Nielsen.It
2313aa6430fSLukas ErtlB&B Electronics USB->RS422/485 adapter
2323aa6430fSLukas Ertl.It
23329881a83SMarc FonvieilleElexol USB MOD1 and USB MOD3
234f53b14baSMarc Fonvieille.It
235fe72d7b1SSimon L. B. NielsenHP USB-Serial adapter shipped with some HP laptops
236fe72d7b1SSimon L. B. Nielsen.It
237fe72d7b1SSimon L. B. NielsenInland UAS111
238fe72d7b1SSimon L. B. Nielsen.It
239fe72d7b1SSimon L. B. NielsenQVS USC-1000
24099f1557aSTakanori Watanabe.It
24199f1557aSTakanori WatanabeBuffalo PC-OP-RS / Kurouto-shikou KURO-RS universal remote
2427bc5465eSPoul-Henning Kamp.It
2437bc5465eSPoul-Henning KampPrologix GPIB-USB Controller
244fe72d7b1SSimon L. B. Nielsen.El
2454f4acb65SEdward Tomasz Napierala.Sh FILES
246*fa196deaSEdward Tomasz Napierala.Bl -tag -width "/dev/ttyU*.init" -compact
247*fa196deaSEdward Tomasz Napierala.It Pa /dev/ttyU*
2484f4acb65SEdward Tomasz Napieralafor callin ports
249*fa196deaSEdward Tomasz Napierala.It Pa /dev/ttyU*.init
250*fa196deaSEdward Tomasz Napierala.It Pa /dev/ttyU*.lock
2514f4acb65SEdward Tomasz Napieralacorresponding callin initial-state and lock-state devices
2524f4acb65SEdward Tomasz Napierala.Pp
253*fa196deaSEdward Tomasz Napierala.It Pa /dev/cuaU*
2544f4acb65SEdward Tomasz Napieralafor callout ports
255*fa196deaSEdward Tomasz Napierala.It Pa /dev/cuaU*.init
256*fa196deaSEdward Tomasz Napierala.It Pa /dev/cuaU*.lock
2574f4acb65SEdward Tomasz Napieralacorresponding callout initial-state and lock-state devices
2584f4acb65SEdward Tomasz Napierala.El
25931f48889SJosef Karthauser.Sh SEE ALSO
26031f48889SJosef Karthauser.Xr tty 4 ,
26131f48889SJosef Karthauser.Xr ucom 4 ,
26231f48889SJosef Karthauser.Xr usb 4
26331f48889SJosef Karthauser.Sh HISTORY
26431f48889SJosef KarthauserThe
26531f48889SJosef Karthauser.Nm
26631f48889SJosef Karthauserdriver
26731f48889SJosef Karthauserappeared in
268a10ab609SDavid E. O'Brien.Fx 4.8
269a10ab609SDavid E. O'Brienfrom
27031f48889SJosef Karthauser.Nx 1.5 .
271