没有合适的资源?快使用搜索试试~ 我知道了~
资源详情
资源评论
资源推荐
Programming Guide for Linux USB Device
Drivers
(c) 2000 by Detlef Fliegl, deti@fliegl.de
http://usb.cs.tum.edu
$Id: usbdoc.tex,v 1.32 2000/12/25 18:36:26 deti Exp $
This document can be found on http://usb.cs.tum.edu/usbdoc and can be
downloaded from http://usb.cs.tum.edu/download/usbdoc
This document may not be published, printed or used in excerpts without
explicit permission of the author.
1
1
Preface
The development of the Linux USB subsystem started in 1997 and in the mean-
time it was redesigned many times. This implied various changes of its internal
structure and its API too. So it is even hard for experienced device driver de-
velopers to keep up to date with all ongoing discussions and current changes.
This document should give detailed information about the current state of
the USB subsystem and its API for USB device drivers. The first section will
deal with the basics of USB devices. You will learn about different types of
devices and their properties. Going into detail you will see how USB devices
communicate on the bus. The second section gives an overview of the Linux
USB subsystem [2] and the device driver framework. Then the API and its data
structures will be explained step by step. The last section of this document
contains a reference of all API calls and their return codes.
CONTENTS 2
Contents
1 The Universal Serial Bus 4
1.1 Host Controllers . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.2 USB Devices and Transfer Characteristics . . . . . . . . . . . . . 4
1.2.1 Hubs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
1.2.2 Data Flow Types . . . . . . . . . . . . . . . . . . . . . . . 5
1.3 Enumeration and Device Descriptors . . . . . . . . . . . . . . . . 6
1.3.1 Standard Descriptors . . . . . . . . . . . . . . . . . . . . 7
1.3.2 Device Classes . . . . . . . . . . . . . . . . . . . . . . . . 8
1.3.3 Human Interface Devices (HID) . . . . . . . . . . . . . . . 8
1.4 USB Device Drivers . . . . . . . . . . . . . . . . . . . . . . . . . 9
2 The Linux USB Subsystem 10
2.1 The USB Device Driver Framework . . . . . . . . . . . . . . . . . 10
2.1.1 Framework Data Structures . . . . . . . . . . . . . . . . . 11
2.1.2 Framework Entry Points . . . . . . . . . . . . . . . . . . . 12
2.1.3 Framework Functions . . . . . . . . . . . . . . . . . . . . 13
2.2 Configuring USB Devices . . . . . . . . . . . . . . . . . . . . . . 14
2.2.1 Descriptor Data Structures . . . . . . . . . . . . . . . . . 14
2.2.2 Standard Device Requests . . . . . . . . . . . . . . . . . 16
2.3 USB Transfers . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
2.3.1 Transfer Data Structures & Macros . . . . . . . . . . . . . 17
2.3.2 URB Functions . . . . . . . . . . . . . . . . . . . . . . . . 23
2.3.3 URB Macros . . . . . . . . . . . . . . . . . . . . . . . . . 24
2.3.4 Compatibility Wrappers . . . . . . . . . . . . . . . . . . . 24
2.4 Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
3 Reference 26
3.1 Error Codes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
3.1.1 Error codes returned by usb submit urb . . . . . . . . . . 26
3.1.2 URB Error Codes . . . . . . . . . . . . . . . . . . . . . . . 26
3.1.3 Error Codes returned by USB Core Functions . . . . . . . 27
LIST OF FIGURES 3
List of Figures
1 USB Topology . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2 USB Descriptor Hierarchy . . . . . . . . . . . . . . . . . . . . . . 7
3 USB Core API Layers . . . . . . . . . . . . . . . . . . . . . . . . 10
4 usb driver structure . . . . . . . . . . . . . . . . . . . . . . . . . . 11
5 A simple probe function . . . . . . . . . . . . . . . . . . . . . . . 12
6 A simple disconnect function . . . . . . . . . . . . . . . . . . . . 13
7 URB Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
8 A simple completion handler . . . . . . . . . . . . . . . . . . . . 20
1 THE UNIVERSAL SERIAL BUS 4
1 The Universal Serial Bus
In 1994 an alliance of four industrial partners (Compaq, Intel, Microsoft and
NEC) started to specify the Universal Serial Bus (USB). The bus was originally
designed with these intentions:
• Connection of the PC to the telephone
• Ease-of-use
• Port expansion
The specification (version 1.0) was first released in january 1996 and the
latest official version 1.1 was released in september 1998 [4]. The document
is still under development and a version 2.0 was announced in 1999. More
information and all specification papers can be found in [1]. The USB is strictly
hierarchical and it is controlled by one host. The host uses a master / slave
protocol to communicate with attached USB devices. This means that every
kind of communication is initiated by the host and devices cannot establish any
direct connection to other devices. This seems to be a drawback in comparison
to other bus architectures but it is not because the USB was designed as a
compromise of costs and performance. The master / slave protocol solves
implicitly problems like collision avoidance or distributed bus arbitration. The
current implementation of the USB allows 127 devices to be connected at the
same time and the communication bandwidth is limited to 12Mbit/s.
1.1 Host Controllers
Today the USB host controller is integrated on most motherboard chipsets.
Older boards which are not equipped with such a controller can be upgraded
by PCI cards with such host controllers. All these controllers are compatible
with either the Open Host Controller Interface (OHCI by Compaq, Microsoft
and National Semiconductor) or the Universal Host Controller Interface (UHCI
by Intel [7]) standard. Both types have the same capabilities and USB devices
do not have to care about the host controller. Basically the hardware of UHCI
is simpler and therefore it needs a more complex device driver, which could
cause slightly more CPU load.
1.2 USB Devices and Transfer Characteristics
There are different types of USB devices as they can be used for different
purposes. First a device can be self powered, bus powered or both. The
USB can provide a power supply up to 500mA for its devices. If there are
only bus powered devices on the bus the maximum power dissipation could be
exceeded and therefore self powered devices exist. They need to have their
own power supply. Devices that support both power types can switch to self
powered mode when attaching an external power supply.
剩余30页未读,继续阅读
yangzex
- 粉丝: 156
- 资源: 27
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0