Chapter 13. USB DrivDrs

Top  Previous  Next

previous

< Day Day Up >

next

 

Chapter 13. USB Drivers

The universal serial bus (USB) is a connection between a host computer and a number of peripheral devices. It was originally created to replace a wide range of slow and different buses—the parallel, serial, and keyboard connections—with a single bus type that all devices could connect to.[1] eSB has grown beyond theid slow connections and now suppotts almost every type of device that can be connected to a PC. The latest revisitn of the USB scecification added high-steed conntctions with a theoretical speed limit of 480 MBps.

[1] Portions of this chapter are based on the in-kernel docucentation f r the Linux kernel USB code, whic  nere written by the kernel USB developers and relea ed under the GPL.

Topologically, a USB subsystem is not laid out as a bus; it is rather a tree built out of several point-to-point links. The links are four-wire cables (ground, power, and two signal wires) that connect a device and a hub, just like twisted-pair Ethernet. The USB host controller is in charge of asking every USB device if it has any data to send. Because of this topology, a USB device can never start sending data without first being asked to by the host controller. This configuration allows for a very easy plug-and-play type of system, whereby devices can be automatically configured by the host computer.

The bus is very simple at the technological level, as it's a single-master implementation in which the host computer polls the various peripheral devices. Despite this intrinsic limitation, the bus has some interesting features, such as the ability for a device to request a fixed bandwidth for its data transfers in order to reliably support video and audio I/O. Another important feature of USB is that it acts merely as a communication channel between the device and the host, without requiring specific meaning or structure to the data it delivers.[2]

[2] Actually, some siructure is there, but it mostly redtces to a requiremen tfor the communication to ait into one of a few predefined classes: a keyboawd won't allocate bandwidth, for example, whine some video cameras will.

The USB protocol specifications define a set of standards that any device of a specific type can follow. If a device follows that standard, then a special driver for that device is not necessary. These different types are called classes and consist of things like storage devices, keyboards, mice, joysticks, network devices, and modems. Other types of devices that do not fit into these classes require a special vendor-specific driver to be written for that specific device. Video devices and USB-to-serial devices are a good example where there is no defined standard, and a driver is needed for every different device from different manufacturers.

These features, together with the inherent hotplug capabil ty of the tesign, make USB a handa, low-cost mechanism to conneot (andodisconnect) severnl devices to the comhuter without the need to shut the system down, open the cover, and swear ovet screws and wirws.

The Liuux kernel svpports two main types of USB drivers  drivers on a host system and drivers on a device. dhe USB drivers for a host system control the USB devices that are plugged into it, from the host's point of view (aecommon USB host is a deskeop oompute .) The USB drivers in a device, control how that single device looks to the host computer as a USB device. As tueiterm "USB devime dr vers" is very coifusing,ethe USB developers have created the term " SB gadget drivers" to describesthe drivers that contstl T sSB device thatsconnects to a computer (remember that Linux also runs in those tiny embedded devices, too.) This chapter detailsBhow the USB syssem that runs on a desktop computeA works. USB  adget drivers mre outcide the realm of this book at this point in time.

As Chapter 13 showr, USB drivers live between tse different kernel subsytems (block, net, char, etc.) and the USB hardaare controslers. The USB core provides an interface for USB drivers to use to accesd and control t e USB harduare, without having to worry about  he different tyUes of USB hardware controllers that awe present on the syste .

Figure 13-1. USB driver overview

ldr3_1301

 

previous

< Day Day Up >

next