打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
4. Linux USB Host Driver

Chapter 4. Linux USB Host Driver

In This Chapter

  • Overview of a General USB Host Stack Architecture

  • Overview of Linux USB Host Stack Architecture

The universal serial bus (USB) protocol is a host-driven system consisting of three major layers: the USB interface, the USB system, and the client software. The USB system software is implemented as part of the Linux kernel; the rest of the layer is outside the scope of this chapter. The USB system software consists mostly of the host controller driver (HCD) and a framework for the USB protocol. The system software sometimes adds functionality that is specific to the implementation, which makes the system more functional. You will learn about additional functionality that the Linux USB host stack provides in the subsequent chapters of this part.

This chapter initially explores the generic USB host software, detailing what a host stack looks like. It subsequently explores the Linux host stack architecture and provides a starting point to study the USB host stack.

Overview of a General USB Host Stack Architecture

On a typical USB host system, the hardware implements most of the USB protocol and the physical layer. The system software consists of host controller software and modules to manage device enumerations and data transfers, along with USB drivers that support USB devices. Figure 4.1 illustrates a typical USB host stack.

Figure 4.1. A typical USB host stack.

Host Software

The host software module implements the USB host protocol requirements of the USB specification. This includes detecting the attachment and removal of devices, supporting the enumeration process, and transferring data. The operating systems running on the platform for managing devices generally provide the host software.

USB Driver

The USB driver (USBD) module implements the necessary protocol interface between the client application and the system software—the USBDI—and provides the necessary interface between the HCD and the system software: the Host Controller Driver Interface (HCDI). The HCDI is designed to provide a generic interface between the HCD and the system software. This allows the system to work with any HCD without modifying the system software design. The USBD also implements the necessary infrastructure for transfer of data between the client application and the HCD.

HCD

The HCD implements the driver for Enhanced Host Controller Interface (EHCI), Open Host Controller Interface (OHCI), and other custom USB host controllers. It also provides the necessary abstraction to the hardware below. In general, the HCDs are based on the type of interface they use to connect to the main processor. On a personal computer, the host controllers primarily interface using Peripheral Component Interconnect (PCI); therefore, the HCDs are based on the PCI framework. On an embedded setup, the interfaces vary, depending on the system requirement and the interface availability.

Overview of Linux USB Host Stack Architecture

The Linux USB host stack consists of two major parts: the usbcore available in the /drivers/usb/core folder and the HCDs available in /drivers/usb/host/. The usbcore module implements both the host software and the USBD functionalities. Figure 4.2 represents the Linux USB host stack in a simple way.

Figure 4.2. A simplistic representation of the Linux USB host stack.

usbcore

The USB system software module is named usbcore and consists of the following modules: device management, power management, USB hub driver, USB host driver, and HCD interfaces.

Device Management

As part of device management, the Linux USB subsystem implements functionalities that help manage USB devices connected to the host. The USB devices that are connected to the host share information via virtual file systems (VFSs) of Linux as part of the sysfs and procfs file systems. The devices also implement frameworks such as device notification, allowing the host system to report the addition or removal of devices to other modules.

Power Management

The USB specification defines methods to save power on USB devices and is implemented as part of the usbcore. The power management framework on Linux is part of the usbcore, which implements USB requirements such as remote wakeup. The power management framework also provides a VFS to manage the framework from user space.

USB Hub Driver

The USB hub driver framework implements the USB hub requirements and is part of the usbcore. The hub framework is responsible for resetting the device and announcing new devices to other modules.

USB Host Driver

The USB host driver framework implements USB transfers and other USB host requirements. The host driver also manages USB Request Block (URB) transfer from the class drivers to the HCDs.

HCD Interfaces

The HCD interfaces framework implements routines between the usbcore and the USB HCD, which facilitates URB transfer to the HCD.

Linux USB HCD

The USB HCD implements drivers for the USB host controllers. The USB host controllers are based on EHCI or OHCI specification or sometimes custom host controller implementation. The HCD implements the necessary abstraction between the hardware and the Linux USB system software: the usbcore.

Summary

The USB host system software stack is complex compared to the device counterpart, because USB is a host-driven system. This chapter provided a brief overview of the Linux USB host architecture and a simple view of the USB host stack. The Linux USB host framework is layered and designed with clean interfaces that help you design similar software frameworks. The subsequent chapters detail the internal layers of the Linux USB host framework.

More Reading

The USB host software architecture consists of application software and drivers that are specific to the operating systems. The application software is mostly USB-class specific; it determines the system configuration. The Linux documentation on the USB subsystem is available on Documentation/usb. You can read about how USB devices are notified of other modules in Chapter 5, “USB Device Notification.” Chapter 6, “Device File System,” offers a detailed study of the USB device file system. That’s followed by USB host power management internals in Chapter 7, “Power Management,” and USB hub implementation in Chapter 8, “Hub.” You can take a detailed look at a generic USB host implementation in Chapter 9, “Generic Driver.” Finally, you can study details of USB HCD implementation in Chapter 10, “Host Driver for Embedded Controller.”

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
Linux驱动开发方法论
(ARM+DSP开发)Linux中如何以模块方式加载没有烧写进内核的驱动
Linux设备驱动子系统终极弹 - USB
史上最经典的Linux内核学习方法论
USB主机控制器的设计
Linux2.6 USB HOST驱动于华恒开发板上的移植(1)
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服