一、Linux USB框图
主要就分为俩大块:
1、USB subsystem
2、USB Driver ———— 驱动开发人员大多在这一块工作。
二、Linux USB框图中各个部件的解释
USB Device
This is just a normal USB device like Pendrive, Mice, Keyboards, USB to Serial converter, USB MP3 Player, etc.
USB Host Controller
The USB host controller is used to control the communications between the host system and USB devices. This USB host controller contains both hardware and software parts.
Hardware:
This hardware part is used for the below operations.
- Detecting the connected and disconnected USB devices.
- Providing power to the connected USB devices.
- and so on.
Software:
The software part is also called as a USB host controller driver. This will be used to loading the correct USB device drivers, and managing the data transfer between the driver and USB host controller.
So this USB host controller is doing the initial transaction once the USB device is detected in the system. Here Initial transaction means, get the devices vendor id, get the devices product id, device type, etc. Once that is done, then the USB host controller driver will assign the appropriate USB device driver to the device.
There are multiple USB host controller interfaces are available.
- Open Host Controller Interface (OHCI) – USB 1.X. eg: USB 1.1
- Universal Host Controller Interface (UHCI) – USB 1.X.
- Enhanced Host Controller Interface (EHCI) – USB 2.0.
- Extended Host Controller Interface (XHCI) – USB 3.0.
USB core
USB core is a codebase consisting of routines and structures available to HCDs (Host Controller Driver) and USB drivers.
USB Driver
This is the USB driver which we are going to write for the USB devices.
三、USB描述符
Till now, we have some ideas about the USB and its subsystem in Linux. Now Let’s discuss the USB device. The USB device contains a number of descriptors that help to define what the device is capable of. We will discuss about the below descriptors.
- Device descriptor
- Configuration descriptor
- Interface descriptor
- Endpoint descriptor
Device descriptor
USB devices can only have one device descriptor. The device descriptor includes information such as what USB revision the device complies with, the Product and Vendor IDs used to load the appropriate drivers, and the number of possible configuration descriptors the device can have.
Configuration descriptor
The configuration descriptor specifies values such as the amount of power this particular configuration uses if the device is self or bus-powered and the number of interfaces it has.