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.\" 27b47fd404SAndrew Thompson.Dd May 20, 2009 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: 61*7e3de069SJoel 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 81b2c1f437SNick Hibmadevice will always be present as it is needed for the 82b2c1f437SNick Hibmaroot hub. 83b2c1f437SNick Hibma.Sh INTRODUCTION TO USB 84b2c1f437SNick HibmaThe 85b2c1f437SNick Hibma.Tn USB 86b47fd404SAndrew Thompsonis a system where external devices can be connected to a PC. 87b47fd404SAndrew ThompsonThe most common USB speeds are: 88*7e3de069SJoel Dahl.Bl -tag -width 6n -offset indent 89b47fd404SAndrew Thompson.It Low Speed (1.5MBit/sec) 90b47fd404SAndrew Thompson.It Full Speed (12MBit/sec) 91b47fd404SAndrew Thompson.It High Speed (480MBit/sec) 92b47fd404SAndrew Thompson.El 93b47fd404SAndrew Thompson.Pp 94b2c1f437SNick HibmaEach 95b2c1f437SNick Hibma.Tn USB 96b47fd404SAndrew Thompsonhas a USB controller that is the master of the bus. 97b47fd404SAndrew ThompsonThe physical communication is simplex which means the host controller only communicates with one USB device at a time. 98b2c1f437SNick Hibma.Pp 99b47fd404SAndrew ThompsonThere can be up to 127 devices connected to an USB HUB tree. 100b2c1f437SNick HibmaThe addresses are assigned 101b2c1f437SNick Hibmadynamically by the host when each device is attached to the bus. 102b2c1f437SNick Hibma.Pp 103b2c1f437SNick HibmaWithin each device there can be up to 16 endpoints. 104b2c1f437SNick HibmaEach endpoint 105b2c1f437SNick Hibmais individually addressed and the addresses are static. 106b2c1f437SNick HibmaEach of these endpoints will communicate in one of four different modes: 10790305461SRuslan Ermilov.Em control , isochronous , bulk , 10890305461SRuslan Ermilovor 10990305461SRuslan Ermilov.Em interrupt . 110b2c1f437SNick HibmaA device always has at least one endpoint. 111b2c1f437SNick HibmaThis endpoint has address 0 and is a control 112b2c1f437SNick Hibmaendpoint and is used to give commands to and extract basic data, 113b2c1f437SNick Hibmasuch as descriptors, from the device. 114b2c1f437SNick HibmaEach endpoint, except the control endpoint, is unidirectional. 115b2c1f437SNick Hibma.Pp 116b2c1f437SNick HibmaThe endpoints in a device are grouped into interfaces. 11757e4378bSRuslan ErmilovAn interface is a logical unit within a device; e.g.\& 118b2c1f437SNick Hibmaa compound device with both a keyboard and a trackball would present 119b2c1f437SNick Hibmaone interface for each. 120b2c1f437SNick HibmaAn interface can sometimes be set into different modes, 121b2c1f437SNick Hibmacalled alternate settings, which affects how it operates. 122b2c1f437SNick HibmaDifferent alternate settings can have different endpoints 123b2c1f437SNick Hibmawithin it. 124b2c1f437SNick Hibma.Pp 125b2c1f437SNick HibmaA device may operate in different configurations. 126b2c1f437SNick HibmaDepending on the 12790305461SRuslan Ermilovconfiguration, the device may present different sets of endpoints 128b2c1f437SNick Hibmaand interfaces. 129b2c1f437SNick Hibma.Pp 130b2c1f437SNick HibmaThe bus enumeration of the 131b2c1f437SNick Hibma.Tn USB 132b2c1f437SNick Hibmabus proceeds in several steps: 133b2c1f437SNick Hibma.Bl -enum 134b2c1f437SNick Hibma.It 135b47fd404SAndrew ThompsonAny interface specific driver can attach to the device. 136b2c1f437SNick Hibma.It 137b47fd404SAndrew ThompsonIf none is found, generic interface class drivers can attach. 138b2c1f437SNick Hibma.El 139b2c1f437SNick Hibma.Sh SEE ALSO 140b2c1f437SNick HibmaThe 141b2c1f437SNick Hibma.Tn USB 142a31999caSJosef Karthauserspecifications can be found at: 14390305461SRuslan Ermilov.Pp 144b8a83c23SHiten Pandya.D1 Pa http://www.usb.org/developers/docs/ 145b2c1f437SNick Hibma.Pp 146b47fd404SAndrew Thompson.Xr libusb 3 , 147b35f050eSAndrew Thompson.Xr usbdi 4 , 148a31999caSJosef Karthauser.Xr aue 4 , 149c37e6fb3SWarner Losh.Xr axe 4 , 150a31999caSJosef Karthauser.Xr cue 4 , 151ad787bb4SSimon L. B. Nielsen.Xr ehci 4 , 152a31999caSJosef Karthauser.Xr kue 4 , 153aa58a571SKevin Lo.Xr mos 4 , 154b2c1f437SNick Hibma.Xr ohci 4 , 1555521ff5aSRuslan Ermilov.Xr pci 4 , 156c37e6fb3SWarner Losh.Xr rue 4 , 15702ea0857SJosef Karthauser.Xr ucom 4 , 158c37e6fb3SWarner Losh.Xr udav 4 , 159def37e7cSMike Pritchard.Xr uhci 4 , 160b2c1f437SNick Hibma.Xr uhid 4 , 161b2c1f437SNick Hibma.Xr ukbd 4 , 1626b9ba891STom Rhodes.Xr ulpt 4 , 163a31999caSJosef Karthauser.Xr umass 4 , 164b2c1f437SNick Hibma.Xr ums 4 , 1658140bbcaSTom Rhodes.Xr uplcom 4 , 166a31999caSJosef Karthauser.Xr urio 4 , 1678140bbcaSTom Rhodes.Xr uvscom 4 , 168f728775bSHans Petter Selasky.Xr usbconfig 8 , 169f728775bSHans Petter Selasky.Xr xhci 4 170b47fd404SAndrew Thompson.Sh STANDARDS 171b47fd404SAndrew ThompsonThe 172b47fd404SAndrew Thompson.Nm 173b47fd404SAndrew Thompsonmodule complies with the USB 2.0 standard. 174b2c1f437SNick Hibma.Sh HISTORY 175b2c1f437SNick HibmaThe 176b2c1f437SNick Hibma.Nm 177b47fd404SAndrew Thompsonmodule has been inspired by the NetBSD USB stack initially written by 178b47fd404SAndrew ThompsonLennart Augustsson. The 179b2c1f437SNick Hibma.Nm 180b47fd404SAndrew Thompsonmodule was written by 18162486687SUlrich Spörlein.An Hans Petter Selasky Aq hselasky@FreeBSD.org . 182