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.\" 25*eddaeb20SLi-Wen Hsu.Dd September 7, 2020 26474fc32bSAlexey Zelkin.Dt USB 4 273d45e180SRuslan Ermilov.Os 28b2c1f437SNick Hibma.Sh NAME 29b2c1f437SNick Hibma.Nm usb 30b2c1f437SNick Hibma.Nd Universal Serial Bus 31b2c1f437SNick Hibma.Sh SYNOPSIS 320a771a3bSChristian BruefferTo compile this driver into the kernel, 330a771a3bSChristian Bruefferplace the following line in your 340a771a3bSChristian Bruefferkernel configuration file: 350a771a3bSChristian Brueffer.Bd -ragged -offset indent 36b9781e20SJeroen Ruigrok van der Werven.Cd "device usb" 370a771a3bSChristian Brueffer.Ed 380a771a3bSChristian Brueffer.Pp 390a771a3bSChristian BruefferAlternatively, to load the driver as a 400a771a3bSChristian Brueffermodule at boot time, place the following line in 410a771a3bSChristian Brueffer.Xr loader.conf 5 : 420a771a3bSChristian Brueffer.Bd -literal -offset indent 430a771a3bSChristian Bruefferusb_load="YES" 440a771a3bSChristian Brueffer.Ed 45b47fd404SAndrew Thompson.Sh USERLAND PROGRAMMING 46b47fd404SAndrew ThompsonUSB functions can be accessed from userland through the libusb library. 47b47fd404SAndrew ThompsonSee 48b47fd404SAndrew Thompson.Xr libusb 3 49b47fd404SAndrew Thompsonfor more information. 50b2c1f437SNick Hibma.Sh DESCRIPTION 51d4be94a1SChris Costello.Fx 52b2c1f437SNick Hibmaprovides machine-independent bus support and drivers for 53*eddaeb20SLi-Wen HsuUSB devices in host and device side mode. 54b2c1f437SNick Hibma.Pp 55b2c1f437SNick HibmaThe 56b2c1f437SNick Hibma.Nm 57b47fd404SAndrew Thompsondriver has three layers: 587e3de069SJoel Dahl.Bl -tag -width 6n -offset indent 59b47fd404SAndrew Thompson.It USB Controller (Bus) 60b47fd404SAndrew Thompson.It USB Device 61b47fd404SAndrew Thompson.It USB Driver 62b47fd404SAndrew Thompson.El 63b47fd404SAndrew Thompson.Pp 646d249eeeSSheldon HearnThe controller attaches to a physical bus 65b47fd404SAndrew Thompsonlike 66b47fd404SAndrew Thompson.Xr pci 4 . 67*eddaeb20SLi-Wen HsuThe USB bus attaches to the controller, and the root hub attaches 68b2c1f437SNick Hibmato the controller. 69b2c1f437SNick HibmaAny devices attached to the bus will attach to the root hub 70*eddaeb20SLi-Wen Hsuor another hub attached to the USB bus. 71b2c1f437SNick Hibma.Pp 72b2c1f437SNick HibmaThe 73b2c1f437SNick Hibma.Nm uhub 749c359511SEnji Cooperdevice will always be present as it is needed for the root hub. 75b2c1f437SNick Hibma.Sh INTRODUCTION TO USB 76*eddaeb20SLi-Wen HsuThe USB is a system where external devices can be connected to a PC. 77b47fd404SAndrew ThompsonThe most common USB speeds are: 787e3de069SJoel Dahl.Bl -tag -width 6n -offset indent 79b47fd404SAndrew Thompson.It Low Speed (1.5 MBit/sec) 80b47fd404SAndrew Thompson.It Full Speed (12 MBit/sec) 81b47fd404SAndrew Thompson.It High Speed (480 MBit/sec) 82*eddaeb20SLi-Wen Hsu.It SuperSpeed (5 GBit/sec) 83b47fd404SAndrew Thompson.El 84b47fd404SAndrew Thompson.Pp 85*eddaeb20SLi-Wen HsuEach USB has a USB controller that is the master of the bus. 869c359511SEnji CooperThe physical communication is simplex which means the host controller only 879c359511SEnji Coopercommunicates with one USB device at a time. 88b2c1f437SNick Hibma.Pp 89b47fd404SAndrew ThompsonThere can be up to 127 devices connected to an USB HUB tree. 909c359511SEnji CooperThe addresses are assigned dynamically by the host when each device is 919c359511SEnji Cooperattached to the bus. 92b2c1f437SNick Hibma.Pp 93b2c1f437SNick HibmaWithin each device there can be up to 16 endpoints. 949c359511SEnji CooperEach endpoint is individually addressed and the addresses are static. 95b2c1f437SNick HibmaEach of these endpoints will communicate in one of four different modes: 9690305461SRuslan Ermilov.Em control , isochronous , bulk , 9790305461SRuslan Ermilovor 9890305461SRuslan Ermilov.Em interrupt . 99b2c1f437SNick HibmaA device always has at least one endpoint. 1009c359511SEnji CooperThis endpoint has address 0 and is a control endpoint and is used to give 1019c359511SEnji Coopercommands to and extract basic data, such as descriptors, from the device. 102b2c1f437SNick HibmaEach endpoint, except the control endpoint, is unidirectional. 103b2c1f437SNick Hibma.Pp 104b2c1f437SNick HibmaThe endpoints in a device are grouped into interfaces. 1059c359511SEnji CooperAn interface is a logical unit within a device, e.g., a compound device with 1069c359511SEnji Cooperboth a keyboard and a trackball, would present one interface for each. 1079c359511SEnji CooperAn interface can sometimes be set into different modes, called alternate 1089c359511SEnji Coopersettings, which affects how it operates. 1099c359511SEnji CooperDifferent alternate settings can have different endpoints within it. 110b2c1f437SNick Hibma.Pp 111b2c1f437SNick HibmaA device may operate in different configurations. 1129c359511SEnji CooperDepending on the configuration, the device may present different sets of 1139c359511SEnji Cooperendpoints and interfaces. 114b2c1f437SNick Hibma.Pp 115*eddaeb20SLi-Wen HsuThe bus enumeration of the USB bus proceeds in several steps: 116b2c1f437SNick Hibma.Bl -enum 117b2c1f437SNick Hibma.It 118b47fd404SAndrew ThompsonAny interface specific driver can attach to the device. 119b2c1f437SNick Hibma.It 120b47fd404SAndrew ThompsonIf none is found, generic interface class drivers can attach. 121b2c1f437SNick Hibma.El 1227722b7d5SEdward Tomasz Napierala.Sh SYSCTL VARIABLES 1237722b7d5SEdward Tomasz NapieralaThe following variables are available as both 1247722b7d5SEdward Tomasz Napierala.Xr sysctl 8 1257722b7d5SEdward Tomasz Napieralavariables and 1267722b7d5SEdward Tomasz Napierala.Xr loader 8 1277722b7d5SEdward Tomasz Napieralatunables: 1287722b7d5SEdward Tomasz Napierala.Bl -tag -width indent 1297722b7d5SEdward Tomasz Napierala.It Va hw.usb.debug 1304426f429SBrad DavisDebug output level, where 0 is debugging disabled and larger values increase 1314426f429SBrad Davisdebug message verbosity. 1324426f429SBrad DavisDefault is 0. 1331adc28f5SChristian Brueffer.El 134b2c1f437SNick Hibma.Sh SEE ALSO 135*eddaeb20SLi-Wen HsuThe USB specifications can be found at: 13690305461SRuslan Ermilov.Pp 137*eddaeb20SLi-Wen Hsu.D1 Pa https://www.usb.org/documents 138b2c1f437SNick Hibma.Pp 139b47fd404SAndrew Thompson.Xr libusb 3 , 140a31999caSJosef Karthauser.Xr aue 4 , 141c37e6fb3SWarner Losh.Xr axe 4 , 14286bd3034SLi-Wen Hsu.Xr axge 4 , 143a31999caSJosef Karthauser.Xr cue 4 , 144ad787bb4SSimon L. B. Nielsen.Xr ehci 4 , 145a31999caSJosef Karthauser.Xr kue 4 , 146aa58a571SKevin Lo.Xr mos 4 , 147b2c1f437SNick Hibma.Xr ohci 4 , 1485521ff5aSRuslan Ermilov.Xr pci 4 , 149c37e6fb3SWarner Losh.Xr rue 4 , 15002ea0857SJosef Karthauser.Xr ucom 4 , 151c37e6fb3SWarner Losh.Xr udav 4 , 152def37e7cSMike Pritchard.Xr uhci 4 , 153b2c1f437SNick Hibma.Xr uhid 4 , 154b2c1f437SNick Hibma.Xr ukbd 4 , 1556b9ba891STom Rhodes.Xr ulpt 4 , 156a31999caSJosef Karthauser.Xr umass 4 , 157b2c1f437SNick Hibma.Xr ums 4 , 1588140bbcaSTom Rhodes.Xr uplcom 4 , 159a31999caSJosef Karthauser.Xr urio 4 , 1608140bbcaSTom Rhodes.Xr uvscom 4 , 161f728775bSHans Petter Selasky.Xr xhci 4 1629c359511SEnji Cooper.Xr usbconfig 8 , 1631adc28f5SChristian Brueffer.Xr usbdi 9 164b47fd404SAndrew Thompson.Sh STANDARDS 165b47fd404SAndrew ThompsonThe 166b47fd404SAndrew Thompson.Nm 167*eddaeb20SLi-Wen Hsumodule complies with the USB 3.0 standard. 168b2c1f437SNick Hibma.Sh HISTORY 169b2c1f437SNick HibmaThe 170b2c1f437SNick Hibma.Nm 1716c899950SBaptiste Daroussinmodule has been inspired by the 1726c899950SBaptiste Daroussin.Nx 1736c899950SBaptiste DaroussinUSB stack initially written by 1746c899950SBaptiste Daroussin.An Lennart Augustsson . 1756c899950SBaptiste DaroussinThe 176b2c1f437SNick Hibma.Nm 177b47fd404SAndrew Thompsonmodule was written by 1786c899950SBaptiste Daroussin.An Hans Petter Selasky Aq Mt hselasky@FreeBSD.org . 179