USB(3)USB(3)
unhandled troff command .EQ
delim $$
unhandled troff command .EN
NAME
usb – USB Host Controller Interface
SYNOPSIS
DESCRIPTION
The Universal Serial Bus is a complex yet popular bus
for connecting all kind of devices to a computer.
It is a four-wire tree-shaped bus that provides both communication and (limited)
power to devices.
Branching points in the tree are provided by devices called
Most PCs have one or more USB controllers called
Host controllers come in four flavours: UHCI and OHCI for USB 1 (up to 12 Mb/s), EHCI for USB 2 (up to 480 Mb/s) and XHCI for USB 3 (up to 5 Gb/s). We currently support all but XHCI, which is still quite new.
The USB bus is fully controlled by the host; all devices are polled. Hubs are passive in the sense that they do not poll the devices attached to them. The host polls those devices and the hubs merely route the messages.
Devices may be added to or removed from the bus at any time. When a device is attached, the host queries it to determine its type and speed. The querying process is standardized. The first level of querying is the same for all devices, the next is somewhat specialized for particular classes of devices (such as mice, keyboards, or audio devices). Specialization continues as subclasses and subsubclasses are explored.
Enumeration of the bus and initial configuration of devices is done
by a user level program,
The kernel device described in this page is responsible for providing
I/O for using the devices through so called
Devices and Endpoints
A device includes one or more functions (e.g., audio output,
volume control buttons, mouse input, etc.)
Communication with device functions is performed
by some combination of
issuing control requests to, sending data to, and receiving data from
device
Their main use is to configure devices. Writing a message with a specific format (specified in the USB specification) issues a request to the device. If the request implies a reply, a read can be made next to retrieve the requested data (if the write succeeded).
Used to send and receive messages to or from a specific device function (e.g., to read events from a mouse).
Used to send and receive larger amounts of data through streams (e.g., to write blocks to a disk).
Used to send and receive data in a timely manner (e.g., to write audio samples to a speaker).
All USB devices include at least
a control endpoint to perform device configuration.
This is called the
Operation
Bus enumeration and device configuration is performed by
Each directory
For each device attached to the bus, and configured by
The device driver may use the setup endpoint
to issue control requests and perhaps to create more endpoints for the device.
Each new endpoint created has its own directory as said above.
For example, if the driver for the device
All endpoint directories contain two files:
data
The
USB errors reported by the endpoint upon I/O failures
are passed to the user process through the error string.
I/O stalls not resulting from an error, usually
an indication from the device, are reported by indicating that the
number of bytes transferred has been zero.
In most cases, the correct course of action after noticing the stall
is for the device driver to issue a ‘clear halt’ request (see
For control and isochronous transfers, there is an implicit
timeout performed by the kernel and it is not necessary for applications
to place their own timers.
For other transfer types, the kernel will not time out any operation
by default
(but see the
ctl and status
The
This may result from the read of an endpoint control file:
(the first line is wrapped to make it fit here) enabled control rw speed full maxpkt 64 pollival 0 samplesz 0 hz 0 hub 1 port 3 busy storage csp 0x500608 vid 0x951 did 0x1613 Kingston 'DT 101 II'
The first line contains status information.
The rest is information supplied by
One of
One of
Used when performing I/O on the data file.
The polling period expressed as a number of µframes
(for high-speed endpoints) or frames (for low- and full-speed endpoints).
Note that a µframe takes 125 µs while a frame takes 1 ms.
This is only of relevance for interrupt and isochronous endpoints.
This value determines how often I/O happens.
Note that the control request adjusting the polling interval does
Number of bytes per I/O sample (isochronous endpoints only).
Number of samples per second (Hertz).
Device address of the hub where the device is attached.
Port number (in the hub) where the device is attached.
The second line contains information describing the device:
As provided by the device itself.
Class, Subclass, and Protocol for the device. If the device contains different functions and has more CSPs, all of them will be listed. The first one is that of the device itself. For example, a mouse and keyboard combo may identify itself as a keyboard but then include two CSPs, one for the keyboard and another one for the mouse.
Vendor and device identifiers.
Provided by the device and identifying the manufacturer and type of device.
For example, to find a mouse not yet in use by a driver, scan the
Control requests
Endpoint control files accept the following requests.
In most cases
the driver does not issue them, leaving the task to either
Prevent further I/O on the device (delete the endpoint) and remove its file interface as soon as no process is using their files.
Set the maximum packet size to
Only for interrupt and isochronous endpoints.
Set the polling interval as a function of the value
Use
Use
Use
If
Clear the halt condition for an endpoint. Used to recover from a stall caused by a device to signal its driver (usually due to an unknown request or a failure to complete one).
Replaces description information in
Tell this driver that the device has been given an address,
which causes the device to enter the
Generates an additional file name,
Enable debugging of the endpoint.
Enable time-outs for the endpoint.
Transfers are timed out by the kernel after
Setup endpoints
(those represented by
Creates a new endpoint with number
Set the endpoint speed to full, low, or high, respectively.
Tell this driver that the endpoint corresponds to a hub device.
Setup endpoints for hub devices also accept his request:
Create a new setup endpoint to represent a new device.
The first argument is the device speed.
The file
Sets the global debug flag to
Dumps data structures for inspection.
FILES
root of the USB interface
SOURCE
SEE ALSO
BUGS
USB controllers limit the speed of all their ports to that of the slowest device connected to any one of them.
Isochronous input streams are not implemented for OHCI.
Some EHCI controllers drop completion interrupts and so must be polled, which hurts throughput.