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.32 2005/04/20 07:33:09 simon Exp $
35 .Nd Universal Serial Bus
43 provides machine-independent bus support and drivers for
49 driver has three layers: the controller, the bus, and the
51 The controller attaches to a physical bus
56 bus attaches to the controller, and the root hub attaches
58 Any devices attached to the bus will attach to the root hub
59 or another hub attached to the
65 device will always be present as it is needed for the
68 .Bl -tag -width ".Xr snd_uaudio 4" -offset indent -compact
72 Mass Storage Devices, e.g., external disk drives
74 .Ss Wired network interfaces
75 .Bl -tag -width ".Xr snd_uaudio 4" -offset indent -compact
77 ADMtek AN986 Pegasus Ethernet driver
79 ASIX Electronics AX88172 Ethernet driver
81 CATC USB-EL1210A Ethernet driver
83 Kawasaki LSI KL5KUSB101B Ethernet driver
85 USB CDC (communication device class) driver for the LG P-500 smartphone
87 RealTek RTL8150 Ethernet driver
89 .Ss Wireless network interfaces
90 .Bl -tag -width ".Xr snd_uaudio 4" -offset indent -compact
92 NDIS miniport driver wrapper
94 .\"Ralink Technology RT2501USB/RT2601USB IEEE 802.11 driver
98 .\"Ralink Technology RT2500USB IEEE 802.11 driver
100 .Ss Serial and parallel interfaces
101 .Bl -tag -width ".Xr snd_uaudio 4" -offset indent -compact
103 MosChip Semiconductor MCS7703 based serial adapters
105 Arkmicro Technologies ARK3116 based serial adapters
107 Belkin serial adapters
109 WinChipHead CH341/CH340 serial adapters
113 serial devices based on the FTDI chips
115 generic serial device
119 Magic Control Technology USB-232 based serial adapters
121 Prolific PL-2303/2303X/2303HX serial adapters
123 Silicon Laboratories CP2101, CP2102 and CP2103 USB to serial bridge
125 Texas Instruments TUSB3410 RS232 to USB converter
127 support for the Handspring Visor, a Palmpilot compatible PDA
129 SUNTAC Slipper U VS-10U serial adapters
132 .Bl -tag -width ".Xr snd_uaudio 4" -offset indent -compact
136 driver for the Rio500 MP3 player
138 .Ss Radio receiver devices
139 .Bl -tag -width ".Xr snd_uaudio 4" -offset indent -compact
141 Cypress Semiconductor FM Radio
143 .Ss Human Interface Devices
144 .Bl -tag -width ".Xr snd_uaudio 4" -offset indent -compact
146 generic driver for Human Interface Devices
148 base driver for all Human Interface Devices
150 keyboards that follow the boot protocol
154 .Ss Miscellaneous devices
155 .Bl -tag -width ".Xr snd_uaudio 4" -offset indent -compact
157 generic device support
161 .Sh INTRODUCTION TO USB
164 is a 12 Mb/s serial bus (1.5 Mb/s for low speed devices).
167 has a host controller that is the master of the bus;
168 all other devices on the bus only speak when spoken to.
170 There can be up to 127 devices (apart from the host controller)
171 on a bus, each with its own address.
172 The addresses are assigned
173 dynamically by the host when each device is attached to the bus.
175 Within each device there can be up to 16 endpoints.
177 is individually addressed and the addresses are static.
178 Each of these endpoints will communicate in one of four different modes:
179 .Em control , isochronous , bulk ,
182 A device always has at least one endpoint.
183 This endpoint has address 0 and is a control
184 endpoint and is used to give commands to and extract basic data,
185 such as descriptors, from the device.
186 Each endpoint, except the control endpoint, is unidirectional.
188 The endpoints in a device are grouped into interfaces.
189 An interface is a logical unit within a device; e.g.\&
190 a compound device with both a keyboard and a trackball would present
191 one interface for each.
192 An interface can sometimes be set into different modes,
193 called alternate settings, which affects how it operates.
194 Different alternate settings can have different endpoints
197 A device may operate in different configurations.
199 configuration, the device may present different sets of endpoints
202 .\"Each device located on a hub has several
205 .\".Bl -tag -compact -width xxxxxx
207 .\"this is the number of the port on the closest upstream hub.
208 .\".It Cd configuration
209 .\"this is the configuration the device must be in for this driver to attach.
210 .\"This locator does not set the configuration; it is iterated by the bus
213 .\"this is the interface number within a device that an interface driver
216 .\"this is the 16 bit vendor id of the device.
218 .\"this is the 16 bit product id of the device.
220 .\"this is the 16 bit release (revision) number of the device.
222 .\"The first locator can be used to pin down a particular device
223 .\"according to its physical position in the device tree.
224 .\"The last three locators can be used to pin down a particular
225 .\"device according to what device it actually is.
227 The bus enumeration of the
229 bus proceeds in several steps:
232 Any device specific driver can attach to the device.
234 If none is found, any device class specific driver can attach.
236 If none is found, all configurations are iterated over.
237 For each configuration, all the interfaces are iterated over, and interface
239 If any interface driver attached in a certain
240 configuration, the iteration over configurations is stopped.
242 If still no drivers have been found, the generic
246 .Sh USB CONTROLLER INTERFACE
247 Use the following to get access to the
249 specific structures and defines.
255 can be opened and a few operations can be performed on it.
258 system call will say that I/O is possible on the controller device when a
260 device has been connected or disconnected to the bus.
264 commands are supported on the controller device:
265 .Bl -tag -width xxxxxx
267 This command will cause a complete bus discovery to be initiated.
268 If any devices attached or detached from the bus they will be
269 processed during this command.
270 This is the only way that new devices are found on the bus.
271 .It Dv USB_DEVICEINFO Vt "struct usb_device_info"
272 This command can be used to retrieve some information about a device
276 field should be filled before the call and the other fields will
277 be filled by information about the device on that address.
278 Should no such device exist, an error is reported.
280 #define USB_MAX_DEVNAMES 4
281 #define USB_MAX_DEVNAMELEN 16
282 struct usb_device_info {
284 u_int8_t udi_addr; /* device address */
285 usb_event_cookie_t udi_cookie;
286 char udi_product[USB_MAX_STRING_LEN];
287 char udi_vendor[USB_MAX_STRING_LEN];
289 u_int16_t udi_productNo;
290 u_int16_t udi_vendorNo;
291 u_int16_t udi_releaseNo;
293 u_int8_t udi_subclass;
294 u_int8_t udi_protocol;
297 #define USB_SPEED_LOW 1
298 #define USB_SPEED_FULL 2
299 #define USB_SPEED_HIGH 3
300 int udi_power; /* power consumption in mA, 0 if selfpowered */
302 char udi_devnames[USB_MAX_DEVNAMES][USB_MAX_DEVNAMELEN];
303 u_int8_t udi_ports[16];/* hub only: addresses of devices on ports */
304 #define USB_PORT_ENABLED 0xff
305 #define USB_PORT_SUSPENDED 0xfe
306 #define USB_PORT_POWERED 0xfd
307 #define USB_PORT_DISABLED 0xfc
314 contain the topological information for the device.
316 contains the device names of the connected drivers.
320 Zip drive connected will be
323 .Va udi_product , udi_vendor
326 fields contain self-explanatory descriptions of the device.
327 .Va udi_productNo , udi_vendorNo , udi_releaseNo , udi_class , udi_subclass
330 contain the corresponding values from the device descriptors.
333 field shows the current configuration of the device.
336 indicates whether the device is at low speed
337 .Pq Dv USB_SPEED_LOW ,
339 .Pq Dv USB_SPEED_FULL
341 .Pq Dv USB_SPEED_HIGH .
344 field shows the power consumption in milli-amps drawn at 5 volts,
345 or zero if the device is self powered.
347 If the device is a hub, the
349 field is non-zero, and the
351 field contains the addresses of the connected devices.
352 If no device is connected to a port, one of the
354 values indicates its status.
355 .It Dv USB_DEVICESTATS Vt "struct usb_device_stats"
356 This command retrieves statistics about the controller.
358 struct usb_device_stats {
359 u_long uds_requests[4];
365 field is indexed by the transfer kind, i.e.\&
367 and indicates how many transfers of each kind that has been completed
369 .It Dv USB_REQUEST Vt "struct usb_ctl_request"
370 This command can be used to execute arbitrary requests on the control pipe.
373 and should be used with great care since it
374 can destroy the bus integrity.
379 contains definitions for the types used by the various
382 The naming convention of the fields for the various
384 descriptors exactly follows the naming in the
387 Byte sized fields can be accessed directly, but word (16 bit)
388 sized fields must be access by the
391 .Fn USETW field value
392 macros to handle byte order and alignment properly.
396 similarly contains the definitions for
397 Human Interface Devices
399 .Sh USB EVENT INTERFACE
402 events are reported via the
405 This devices can be opened for reading and each
407 will yield an event record (if something has happened).
410 system call can be used to determine if an event record is available
413 The event record has the following definition:
417 #define USB_EVENT_CTRLR_ATTACH 1
418 #define USB_EVENT_CTRLR_DETACH 2
419 #define USB_EVENT_DEVICE_ATTACH 3
420 #define USB_EVENT_DEVICE_DETACH 4
421 #define USB_EVENT_DRIVER_ATTACH 5
422 #define USB_EVENT_DRIVER_DETACH 6
423 struct timespec ue_time;
428 struct usb_device_info ue_device;
430 usb_event_cookie_t ue_cookie;
438 field identifies the type of event that is described.
439 The possible events are attach/detach of a host controller,
440 a device, or a device driver.
441 The union contains information
442 pertinent to the different types of events.
444 .Fn USB_EVENT_IS_ATTACH "ue_type"
446 .Fn USB_EVENT_IS_DETACH "ue_type"
447 can be used to determine if an event was an
455 contains the number of the
457 bus for host controller events.
461 record contains information about the device in a device event.
465 is an opaque value that uniquely determines which
466 device a device driver has been attached to (i.e., it equals
467 the cookie value in the device that the driver attached to).
471 contains the name of the device (driver) as seen in, e.g.,
474 Note that there is a separation between device and device
476 A device event is generated when a physical
478 device is attached or detached.
482 have zero, one, or many device drivers associated with it.
486 specifications can be found at:
488 .D1 Pa http://www.usb.org/developers/docs/
499 driver first appeared in
504 driver was written by
505 .An Lennart Augustsson Aq Mt augustss@carlstedt.se