xref: /freebsd/share/man/man4/usb.4 (revision 1adc28f5a882d58135de190afdbf323bc43bff3a)
1936663c8SJoel Dahl.\" Copyright (c) 1997, 1998 Nick Hibma <n_hibma@FreeBSD.org>
2b47fd404SAndrew Thompson.\" Copyright (c) 2008 Hans Petter Selasky. All rights reserved.
3b47fd404SAndrew Thompson.\"
4b47fd404SAndrew Thompson.\" Redistribution and use in source and binary forms, with or without
5b47fd404SAndrew Thompson.\" modification, are permitted provided that the following conditions
6b47fd404SAndrew Thompson.\" are met:
7b47fd404SAndrew Thompson.\" 1. Redistributions of source code must retain the above copyright
8b47fd404SAndrew Thompson.\"    notice, this list of conditions and the following disclaimer.
9b47fd404SAndrew Thompson.\" 2. Redistributions in binary form must reproduce the above copyright
10b47fd404SAndrew Thompson.\"    notice, this list of conditions and the following disclaimer in the
11b47fd404SAndrew Thompson.\"    documentation and/or other materials provided with the distribution.
12b47fd404SAndrew Thompson.\"
13b47fd404SAndrew Thompson.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14b47fd404SAndrew Thompson.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15b47fd404SAndrew Thompson.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16b47fd404SAndrew Thompson.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17b47fd404SAndrew Thompson.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18b47fd404SAndrew Thompson.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19b47fd404SAndrew Thompson.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20b47fd404SAndrew Thompson.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21b47fd404SAndrew Thompson.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22b47fd404SAndrew Thompson.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23b47fd404SAndrew Thompson.\" SUCH DAMAGE.
24b47fd404SAndrew Thompson.\"
257f3dea24SPeter Wemm.\" $FreeBSD$
26b2c1f437SNick Hibma.\"
277722b7d5SEdward Tomasz Napierala.Dd April 24, 2018
28474fc32bSAlexey Zelkin.Dt USB 4
293d45e180SRuslan Ermilov.Os
30b2c1f437SNick Hibma.Sh NAME
31b2c1f437SNick Hibma.Nm usb
32b2c1f437SNick Hibma.Nd Universal Serial Bus
33b2c1f437SNick Hibma.Sh SYNOPSIS
340a771a3bSChristian BruefferTo compile this driver into the kernel,
350a771a3bSChristian Bruefferplace the following line in your
360a771a3bSChristian Bruefferkernel configuration file:
370a771a3bSChristian Brueffer.Bd -ragged -offset indent
38b9781e20SJeroen Ruigrok van der Werven.Cd "device usb"
390a771a3bSChristian Brueffer.Ed
400a771a3bSChristian Brueffer.Pp
410a771a3bSChristian BruefferAlternatively, to load the driver as a
420a771a3bSChristian Brueffermodule at boot time, place the following line in
430a771a3bSChristian Brueffer.Xr loader.conf 5 :
440a771a3bSChristian Brueffer.Bd -literal -offset indent
450a771a3bSChristian Bruefferusb_load="YES"
460a771a3bSChristian Brueffer.Ed
47b47fd404SAndrew Thompson.Sh USERLAND PROGRAMMING
48b47fd404SAndrew ThompsonUSB functions can be accessed from userland through the libusb library.
49b47fd404SAndrew ThompsonSee
50b47fd404SAndrew Thompson.Xr libusb 3
51b47fd404SAndrew Thompsonfor more information.
52b2c1f437SNick Hibma.Sh DESCRIPTION
53d4be94a1SChris Costello.Fx
54b2c1f437SNick Hibmaprovides machine-independent bus support and drivers for
55b2c1f437SNick Hibma.Tn USB
56b47fd404SAndrew Thompsondevices in host and device side mode.
57b2c1f437SNick Hibma.Pp
58b2c1f437SNick HibmaThe
59b2c1f437SNick Hibma.Nm
60b47fd404SAndrew Thompsondriver has three layers:
617e3de069SJoel Dahl.Bl -tag -width 6n -offset indent
62b47fd404SAndrew Thompson.It USB Controller (Bus)
63b47fd404SAndrew Thompson.It USB Device
64b47fd404SAndrew Thompson.It USB Driver
65b47fd404SAndrew Thompson.El
66b47fd404SAndrew Thompson.Pp
676d249eeeSSheldon HearnThe controller attaches to a physical bus
68b47fd404SAndrew Thompsonlike
69b47fd404SAndrew Thompson.Xr pci 4 .
70b2c1f437SNick HibmaThe
71b2c1f437SNick Hibma.Tn USB
7290305461SRuslan Ermilovbus attaches to the controller, and the root hub attaches
73b2c1f437SNick Hibmato the controller.
74b2c1f437SNick HibmaAny devices attached to the bus will attach to the root hub
7590305461SRuslan Ermilovor another hub attached to the
7690305461SRuslan Ermilov.Tn USB
7790305461SRuslan Ermilovbus.
78b2c1f437SNick Hibma.Pp
79b2c1f437SNick HibmaThe
80b2c1f437SNick Hibma.Nm uhub
819c359511SEnji Cooperdevice will always be present as it is needed for the root hub.
82b2c1f437SNick Hibma.Sh INTRODUCTION TO USB
83b2c1f437SNick HibmaThe
84b2c1f437SNick Hibma.Tn USB
85b47fd404SAndrew Thompsonis a system where external devices can be connected to a PC.
86b47fd404SAndrew ThompsonThe most common USB speeds are:
877e3de069SJoel Dahl.Bl -tag -width 6n -offset indent
88b47fd404SAndrew Thompson.It Low Speed (1.5MBit/sec)
89b47fd404SAndrew Thompson.It Full Speed (12MBit/sec)
90b47fd404SAndrew Thompson.It High Speed (480MBit/sec)
91b47fd404SAndrew Thompson.El
92b47fd404SAndrew Thompson.Pp
93b2c1f437SNick HibmaEach
94b2c1f437SNick Hibma.Tn USB
95b47fd404SAndrew Thompsonhas a USB controller that is the master of the bus.
969c359511SEnji CooperThe physical communication is simplex which means the host controller only
979c359511SEnji Coopercommunicates with one USB device at a time.
98b2c1f437SNick Hibma.Pp
99b47fd404SAndrew ThompsonThere can be up to 127 devices connected to an USB HUB tree.
1009c359511SEnji CooperThe addresses are assigned dynamically by the host when each device is
1019c359511SEnji Cooperattached to the bus.
102b2c1f437SNick Hibma.Pp
103b2c1f437SNick HibmaWithin each device there can be up to 16 endpoints.
1049c359511SEnji CooperEach endpoint is individually addressed and the addresses are static.
105b2c1f437SNick HibmaEach of these endpoints will communicate in one of four different modes:
10690305461SRuslan Ermilov.Em control , isochronous , bulk ,
10790305461SRuslan Ermilovor
10890305461SRuslan Ermilov.Em interrupt .
109b2c1f437SNick HibmaA device always has at least one endpoint.
1109c359511SEnji CooperThis endpoint has address 0 and is a control endpoint and is used to give
1119c359511SEnji Coopercommands to and extract basic data, such as descriptors, from the device.
112b2c1f437SNick HibmaEach endpoint, except the control endpoint, is unidirectional.
113b2c1f437SNick Hibma.Pp
114b2c1f437SNick HibmaThe endpoints in a device are grouped into interfaces.
1159c359511SEnji CooperAn interface is a logical unit within a device, e.g., a compound device with
1169c359511SEnji Cooperboth a keyboard and a trackball, would present one interface for each.
1179c359511SEnji CooperAn interface can sometimes be set into different modes, called alternate
1189c359511SEnji Coopersettings, which affects how it operates.
1199c359511SEnji CooperDifferent alternate settings can have different endpoints within it.
120b2c1f437SNick Hibma.Pp
121b2c1f437SNick HibmaA device may operate in different configurations.
1229c359511SEnji CooperDepending on the configuration, the device may present different sets of
1239c359511SEnji Cooperendpoints and interfaces.
124b2c1f437SNick Hibma.Pp
125b2c1f437SNick HibmaThe bus enumeration of the
126b2c1f437SNick Hibma.Tn USB
127b2c1f437SNick Hibmabus proceeds in several steps:
128b2c1f437SNick Hibma.Bl -enum
129b2c1f437SNick Hibma.It
130b47fd404SAndrew ThompsonAny interface specific driver can attach to the device.
131b2c1f437SNick Hibma.It
132b47fd404SAndrew ThompsonIf none is found, generic interface class drivers can attach.
133b2c1f437SNick Hibma.El
1347722b7d5SEdward Tomasz Napierala.Sh SYSCTL VARIABLES
1357722b7d5SEdward Tomasz NapieralaThe following variables are available as both
1367722b7d5SEdward Tomasz Napierala.Xr sysctl 8
1377722b7d5SEdward Tomasz Napieralavariables and
1387722b7d5SEdward Tomasz Napierala.Xr loader 8
1397722b7d5SEdward Tomasz Napieralatunables:
1407722b7d5SEdward Tomasz Napierala.Bl -tag -width indent
1417722b7d5SEdward Tomasz Napierala.It Va hw.usb.debug
1424426f429SBrad DavisDebug output level, where 0 is debugging disabled and larger values increase
1434426f429SBrad Davisdebug message verbosity.
1444426f429SBrad DavisDefault is 0.
145*1adc28f5SChristian Brueffer.El
146b2c1f437SNick Hibma.Sh SEE ALSO
147b2c1f437SNick HibmaThe
148b2c1f437SNick Hibma.Tn USB
149a31999caSJosef Karthauserspecifications can be found at:
15090305461SRuslan Ermilov.Pp
151b8a83c23SHiten Pandya.D1 Pa http://www.usb.org/developers/docs/
152b2c1f437SNick Hibma.Pp
153b47fd404SAndrew Thompson.Xr libusb 3 ,
154a31999caSJosef Karthauser.Xr aue 4 ,
155c37e6fb3SWarner Losh.Xr axe 4 ,
15686bd3034SLi-Wen Hsu.Xr axge 4 ,
157a31999caSJosef Karthauser.Xr cue 4 ,
158ad787bb4SSimon L. B. Nielsen.Xr ehci 4 ,
159a31999caSJosef Karthauser.Xr kue 4 ,
160aa58a571SKevin Lo.Xr mos 4 ,
161b2c1f437SNick Hibma.Xr ohci 4 ,
1625521ff5aSRuslan Ermilov.Xr pci 4 ,
163c37e6fb3SWarner Losh.Xr rue 4 ,
16402ea0857SJosef Karthauser.Xr ucom 4 ,
165c37e6fb3SWarner Losh.Xr udav 4 ,
166def37e7cSMike Pritchard.Xr uhci 4 ,
167b2c1f437SNick Hibma.Xr uhid 4 ,
168b2c1f437SNick Hibma.Xr ukbd 4 ,
1696b9ba891STom Rhodes.Xr ulpt 4 ,
170a31999caSJosef Karthauser.Xr umass 4 ,
171b2c1f437SNick Hibma.Xr ums 4 ,
1728140bbcaSTom Rhodes.Xr uplcom 4 ,
173a31999caSJosef Karthauser.Xr urio 4 ,
1748140bbcaSTom Rhodes.Xr uvscom 4 ,
175f728775bSHans Petter Selasky.Xr xhci 4
1769c359511SEnji Cooper.Xr usbconfig 8 ,
177*1adc28f5SChristian Brueffer.Xr usbdi 9
178b47fd404SAndrew Thompson.Sh STANDARDS
179b47fd404SAndrew ThompsonThe
180b47fd404SAndrew Thompson.Nm
181b47fd404SAndrew Thompsonmodule complies with the USB 2.0 standard.
182b2c1f437SNick Hibma.Sh HISTORY
183b2c1f437SNick HibmaThe
184b2c1f437SNick Hibma.Nm
1856c899950SBaptiste Daroussinmodule has been inspired by the
1866c899950SBaptiste Daroussin.Nx
1876c899950SBaptiste DaroussinUSB stack initially written by
1886c899950SBaptiste Daroussin.An Lennart Augustsson .
1896c899950SBaptiste DaroussinThe
190b2c1f437SNick Hibma.Nm
191b47fd404SAndrew Thompsonmodule was written by
1926c899950SBaptiste Daroussin.An Hans Petter Selasky Aq Mt hselasky@FreeBSD.org .
193