xref: /freebsd/share/man/man4/usb.4 (revision 61ba55bcf70f2340f9c943c9571113b3fd8eda69)
1.\" Copyright (c) 1997, 1998 Nick Hibma <n_hibma@FreeBSD.org>
2.\" Copyright (c) 2008 Hans Petter Selasky. All rights reserved.
3.\"
4.\" Redistribution and use in source and binary forms, with or without
5.\" modification, are permitted provided that the following conditions
6.\" are met:
7.\" 1. Redistributions of source code must retain the above copyright
8.\"    notice, this list of conditions and the following disclaimer.
9.\" 2. Redistributions in binary form must reproduce the above copyright
10.\"    notice, this list of conditions and the following disclaimer in the
11.\"    documentation and/or other materials provided with the distribution.
12.\"
13.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23.\" SUCH DAMAGE.
24.\"
25.Dd September 7, 2020
26.Dt USB 4
27.Os
28.Sh NAME
29.Nm usb
30.Nd Universal Serial Bus
31.Sh SYNOPSIS
32To compile this driver into the kernel,
33place the following line in your
34kernel configuration file:
35.Bd -ragged -offset indent
36.Cd "device usb"
37.Ed
38.Pp
39Alternatively, to load the driver as a
40module at boot time, place the following line in
41.Xr loader.conf 5 :
42.Bd -literal -offset indent
43usb_load="YES"
44.Ed
45.Sh USERLAND PROGRAMMING
46USB functions can be accessed from userland through the libusb library.
47See
48.Xr libusb 3
49for more information.
50.Sh DESCRIPTION
51.Fx
52provides machine-independent bus support and drivers for
53USB devices in host and device side mode.
54.Pp
55The
56.Nm
57driver has three layers:
58.Bl -tag -width 6n -offset indent
59.It USB Controller (Bus)
60.It USB Device
61.It USB Driver
62.El
63.Pp
64The controller attaches to a physical bus
65like
66.Xr pci 4 .
67The USB bus attaches to the controller, and the root hub attaches
68to the controller.
69Any devices attached to the bus will attach to the root hub
70or another hub attached to the USB bus.
71.Pp
72The
73.Nm uhub
74device will always be present as it is needed for the root hub.
75.Sh INTRODUCTION TO USB
76The USB is a system where external devices can be connected to a PC.
77The most common USB speeds are:
78.Bl -tag -width 6n -offset indent
79.It Low Speed (1.5 MBit/sec)
80.It Full Speed (12 MBit/sec)
81.It High Speed (480 MBit/sec)
82.It SuperSpeed (5 GBit/sec)
83.El
84.Pp
85Each USB has a USB controller that is the master of the bus.
86The physical communication is simplex which means the host controller only
87communicates with one USB device at a time.
88.Pp
89There can be up to 127 devices connected to an USB HUB tree.
90The addresses are assigned dynamically by the host when each device is
91attached to the bus.
92.Pp
93Within each device there can be up to 16 endpoints.
94Each endpoint is individually addressed and the addresses are static.
95Each of these endpoints will communicate in one of four different modes:
96.Em control , isochronous , bulk ,
97or
98.Em interrupt .
99A device always has at least one endpoint.
100This endpoint has address 0 and is a control endpoint and is used to give
101commands to and extract basic data, such as descriptors, from the device.
102Each endpoint, except the control endpoint, is unidirectional.
103.Pp
104The endpoints in a device are grouped into interfaces.
105An interface is a logical unit within a device, e.g., a compound device with
106both a keyboard and a trackball, would present one interface for each.
107An interface can sometimes be set into different modes, called alternate
108settings, which affects how it operates.
109Different alternate settings can have different endpoints within it.
110.Pp
111A device may operate in different configurations.
112Depending on the configuration, the device may present different sets of
113endpoints and interfaces.
114.Pp
115The bus enumeration of the USB bus proceeds in several steps:
116.Bl -enum
117.It
118Any interface specific driver can attach to the device.
119.It
120If none is found, generic interface class drivers can attach.
121.El
122.Sh SYSCTL VARIABLES
123The following variables are available as both
124.Xr sysctl 8
125variables and
126.Xr loader 8
127tunables:
128.Bl -tag -width indent
129.It Va hw.usb.debug
130Debug output level, where 0 is debugging disabled and larger values increase
131debug message verbosity.
132Default is 0.
133.El
134.Sh SEE ALSO
135The USB specifications can be found at:
136.Pp
137.D1 Pa https://www.usb.org/documents
138.Pp
139.Xr libusb 3 ,
140.Xr aue 4 ,
141.Xr axe 4 ,
142.Xr axge 4 ,
143.Xr cue 4 ,
144.Xr ehci 4 ,
145.Xr kue 4 ,
146.Xr mos 4 ,
147.Xr ohci 4 ,
148.Xr pci 4 ,
149.Xr rue 4 ,
150.Xr ucom 4 ,
151.Xr udav 4 ,
152.Xr uhci 4 ,
153.Xr uhid 4 ,
154.Xr ukbd 4 ,
155.Xr ulpt 4 ,
156.Xr umass 4 ,
157.Xr ums 4 ,
158.Xr uplcom 4 ,
159.Xr urio 4 ,
160.Xr uvscom 4 ,
161.Xr xhci 4
162.Xr usbconfig 8 ,
163.Xr usbdi 9
164.Sh STANDARDS
165The
166.Nm
167module complies with the USB 3.0 standard.
168.Sh HISTORY
169The
170.Nm
171module has been inspired by the
172.Nx
173USB stack initially written by
174.An Lennart Augustsson .
175The
176.Nm
177module was written by
178.An Hans Petter Selasky Aq Mt hselasky@FreeBSD.org .
179