1 .\" Copyright (c) 1997, 1998
2 .\" Nick Hibma <n_hibma@FreeBSD.org>. All rights reserved.
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
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 .\" 3. Neither the name of the author nor the names of any co-contributors
13 .\" may be used to endorse or promote products derived from this software
14 .\" without specific prior written permission.
16 .\" THIS SOFTWARE IS PROVIDED BY NICK HIBMA AND CONTRIBUTORS ``AS IS'' AND
17 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 .\" ARE DISCLAIMED. IN NO EVENT SHALL NICK HIBMA OR THE VOICES IN HIS HEAD
20 .\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 .\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 .\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 .\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 .\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
26 .\" THE POSSIBILITY OF SUCH DAMAGE.
28 .\" $FreeBSD: src/share/man/man4/usb.4,v 1.9.2.10 2002/12/19 20:48:25 trhodes Exp $
29 .\" $DragonFly: src/share/man/man4/usb.4,v 1.3 2004/03/11 12:28:55 hmp Exp $
36 .Nd Universal Serial Bus
44 provides machine-independent bus support and drivers for
50 driver has three layers: the controller, the bus, and the
52 The controller attaches to a physical bus
57 bus attaches to the controller, and the root hub attaches
59 Any devices attached to the bus will attach to the root hub
60 or another hub attached to the
66 device will always be present as it is needed for the
68 .Sh INTRODUCTION TO USB
71 is a 12 Mb/s serial bus (1.5 Mb/s for low speed devices).
74 has a host controller that is the master of the bus;
75 all other devices on the bus only speak when spoken to.
77 There can be up to 127 devices (apart from the host controller)
78 on a bus, each with its own address.
79 The addresses are assigned
80 dynamically by the host when each device is attached to the bus.
82 Within each device there can be up to 16 endpoints.
84 is individually addressed and the addresses are static.
85 Each of these endpoints will communicate in one of four different modes:
86 .Em control , isochronous , bulk ,
89 A device always has at least one endpoint.
90 This endpoint has address 0 and is a control
91 endpoint and is used to give commands to and extract basic data,
92 such as descriptors, from the device.
93 Each endpoint, except the control endpoint, is unidirectional.
95 The endpoints in a device are grouped into interfaces.
96 An interface is a logical unit within a device; e.g.\&
97 a compound device with both a keyboard and a trackball would present
98 one interface for each.
99 An interface can sometimes be set into different modes,
100 called alternate settings, which affects how it operates.
101 Different alternate settings can have different endpoints
104 A device may operate in different configurations.
106 configuration, the device may present different sets of endpoints
109 Each device located on a hub has several
112 .Bl -tag -compact -width xxxxxx
114 this is the number of the port on the closest upstream hub.
116 this is the configuration the device must be in for this driver to attach.
117 This locator does not set the configuration; it is iterated by the bus
120 this is the interface number within a device that an interface driver
123 this is the 16 bit vendor id of the device.
125 this is the 16 bit product id of the device.
127 this is the 16 bit release (revision) number of the device.
129 The first locator can be used to pin down a particular device
130 according to its physical position in the device tree.
131 The last three locators can be used to pin down a particular
132 device according to what device it actually is.
134 The bus enumeration of the
136 bus proceeds in several steps:
139 Any device specific driver can attach to the device.
141 If none is found, any device class specific driver can attach.
143 If none is found, all configurations are iterated over.
144 For each configuration, all the interfaces are iterated over, and interface
146 If any interface driver attached in a certain
147 configuration, the iteration over configurations is stopped.
149 If still no drivers have been found, the generic
153 .Sh USB CONTROLLER INTERFACE
154 Use the following to get access to the
156 specific structures and defines.
162 can be opened and a few operations can be performed on it.
165 system call will say that I/O is possible on the controller device when a
167 device has been connected or disconnected to the bus.
171 commands are supported on the controller device:
172 .Bl -tag -width xxxxxx
174 This command will cause a complete bus discovery to be initiated.
175 If any devices attached or detached from the bus they will be
176 processed during this command.
177 This is the only way that new devices are found on the bus.
178 .It Dv USB_DEVICEINFO Vt "struct usb_device_info"
179 This command can be used to retrieve some information about a device
183 field should be filled before the call and the other fields will
184 be filled by information about the device on that address.
185 Should no such device exist, an error is reported.
187 struct usb_device_info {
190 usb_event_cookie_t cookie;
191 char product[USB_MAX_STRING_LEN];
192 char vendor[USB_MAX_STRING_LEN];
204 char devnames[USB_MAX_DEVNAMES][USB_MAX_DEVNAMELEN];
206 #define USB_PORT_ENABLED 0xff
207 #define USB_PORT_SUSPENDED 0xfe
208 #define USB_PORT_POWERED 0xfd
209 #define USB_PORT_DISABLED 0xfc
216 contain the topological information for the device.
218 contains the device names of the connected drivers.
222 Zip drive connected will be
228 fields contain self-explanatory descriptions of the device.
229 .Va productNo , vendorNo , releaseNo , class , subclass
232 contain the corresponding values from the device descriptors.
235 field shows the current configuration of the device.
238 indicates whether the device is a full speed (0) or low speed (1)
242 field shows the power consumption in milli-amps drawn at 5 volts,
243 or zero if the device is self powered.
245 If the device is a hub, the
247 field is non-zero, and the
249 field contains the addresses of the connected devices.
250 If no device is connected to a port, one of the
252 values indicates its status.
253 .It Dv USB_DEVICESTATS Vt "struct usb_device_stats"
254 This command retrieves statistics about the controller.
256 struct usb_device_stats {
263 field is indexed by the transfer kind, i.e.\&
265 and indicates how many transfers of each kind that has been completed
267 .It Dv USB_REQUEST Vt "struct usb_ctl_request"
268 This command can be used to execute arbitrary requests on the control pipe.
271 and should be used with great care since it
272 can destroy the bus integrity.
277 contains definitions for the types used by the various
280 The naming convention of the fields for the various
282 descriptors exactly follows the naming in the
285 Byte sized fields can be accessed directly, but word (16 bit)
286 sized fields must be access by the
289 .Fn USETW field value
290 macros to handle byte order and alignment properly.
293 .Aq Pa dev/usb/usbhid.h
294 similarly contains the definitions for
295 Human Interface Devices
297 .Sh USB EVENT INTERFACE
300 events are reported via the
303 This devices can be opened for reading and each
305 will yield an event record (if something has happened).
308 system call can be used to determine if an event record is available
311 The event record has the following definition:
315 #define USB_EVENT_CTRLR_ATTACH 1
316 #define USB_EVENT_CTRLR_DETACH 2
317 #define USB_EVENT_DEVICE_ATTACH 3
318 #define USB_EVENT_DEVICE_DETACH 4
319 #define USB_EVENT_DRIVER_ATTACH 5
320 #define USB_EVENT_DRIVER_DETACH 6
321 struct timespec ue_time;
326 struct usb_device_info ue_device;
328 usb_event_cookie_t ue_cookie;
336 field identifies the type of event that is described.
337 The possible events are attach/detach of a host controller,
338 a device, or a device driver.
339 The union contains information
340 pertinent to the different types of events.
344 contains the number of the
346 bus for host controller events.
350 record contains information about the device in a device event event.
354 is an opaque value that uniquely determines which which
355 device a device driver has been attached to (i.e., it equals
356 the cookie value in the device that the driver attached to).
360 contains the name of the device (driver) as seen in, e.g.,
363 Note that there is a separation between device and device
365 A device event is generated when a physical
367 device is attached or detached.
371 have zero, one, or many device drivers associated with it.
375 specifications can be found at:
377 .D1 Pa http://www.usb.org/developers/docs.html
399 driver first appeared in
404 driver was written by
405 .An Lennart Augustsson Aq augustss@carlstedt.se