USB
USB 驱动主要实现设备驱动的底层细节,并为上层提供一套标准的 API 接口以供使用。USB模块主要特性如下:
- Complies with USB 2.0 Specification
- Supports High-Speed (HS, 480-Mbps), Full-Speed (FS, 12-Mbps), and Low-Speed (LS, 1.5-Mbps) in Host mode
- Supports High-Speed (HS, 480 Mbps), Full-Speed (FS, 12 Mbps) in Device mode
- Supports the UTMI+ Level 3 interface. The 8-bit bidirectional data buses are used
- Supports bi-directional endpoint0 for Control transfer
- Supports up to 8 User-Configurable Endpoints for Bulk, Isochronous and Interrupt bi-directional transfers (Endpoint1, Endpoint2, Endpoint3, Endpoint4)
- Supports up to (4KB+64Bytes) FIFO for EPs (Including EP0)
- Supports High-Bandwidth Isochronous & Interrupt transfers
- Automated splitting/combining of packets for Bulk transfers
- Supports point-to-point and point-to-multipoint transfer in both Host and Peripheral mode
- Includes automatic ping capabilities
- Soft connect/disconnect function
- Performs all transaction scheduling in hardware
- Power Optimization and Power Management capabilities
- Includes interface to an external Normal DMA controller for every Eps
模块配置
R128 仅有一个 USB,HAL 驱动支持两个及以上 USB 外设,故部分配置为空。
Kernel Setup --->
Drivers Setup --->
SoC HAL Drivers --->
USB devices --->
[*] enable USB driver
[*] USB HOST --->
[*] Support usb host ehci0 # USB0 配置
[*] Support usb host ohci0
[ ] Support usb host ehci1 # USB1 配置
[ ] Support usb host ohci1
[*] Mass Storage support
[*] USB CD support
[ ] Carplay host support
[ ] UVC support
[ ] HID support
[*] USB DEVICE --->
[ ] enable dma for udc driver
[*] Support usb gadget driver
usb gadget driver (adb gadget driver) --->
(X) adb gadget driver
( ) mtp gadget driver
( ) uac gadget driver
( ) ncm gadget driver
( ) msc gadget driver
[*] USB MANAGER
源码结构
.
├── Kconfig
├── Makefile
├── common # 公共操作
│ ├── Makefile
│ ├── list_head_ext.c
│ ├── list_head_ext.h
│ ├── usb_init.c
│ ├── usb_init.h
│ ├── usb_phy.c
│ └── usb_phy.h
├── core # USB 核心驱动
│ ├── Makefile
│ ├── urb.c
│ ├── urb.h
│ ├── usb_core_base.c
│ ├── usb_core_base.h
│ ├── usb_core_config.c
│ ├── usb_core_config.h
│ ├── usb_core_init.c
│ ├── usb_core_init.h
│ ├── usb_core_interface.c
│ ├── usb_core_interface.h
│ ├── usb_driver_init.c
│ ├── usb_driver_init.h
│ ├── usb_gen_hcd.c
│ ├── usb_gen_hcd.h
│ ├── usb_gen_hcd_rh.c
│ ├── usb_gen_hcd_rh.h
│ ├── usb_gen_hub.c
│ ├── usb_gen_hub.h
│ ├── usb_gen_hub_base.c
│ ├── usb_gen_hub_base.h
│ ├── usb_msg.c
│ ├── usb_msg.h
│ ├── usb_msg_base.c
│ ├── usb_msg_base.h
│ ├── usb_virt_bus.c
│ └── usb_virt_bus.h
├── gadget # gadget 相关实现
│ ├── Makefile
│ ├── function
│ │ ├── adb.c
│ │ ├── msc
│ │ │ ├── msc.c
│ │ │ ├── scsi.c
│ │ │ ├── scsi.h
│ │ │ ├── usb_slave_msc.c
│ │ │ └── usb_slave_msc.h
│ │ ├── mtp.c
│ │ └── uac.c
│ ├── gadget.c
│ ├── gadget.h
│ └── gadget_hal.c
├── hid # hid 相关实现
│ ├── Class
│ │ ├── Hid.c
│ │ ├── HidProtocol.c
│ │ ├── HidProtocol.h
│ │ ├── HidTransport.c
│ │ ├── HidTransport.h
│ │ └── Makefile
│ ├── Client
│ │ ├── KeyBoard
│ │ │ ├── KeyBoard.c
│ │ │ ├── KeyBoard.h
│ │ │ └── Makefile
│ │ ├── Makefile
│ │ ├── Mouse
│ │ │ ├── Makefile
│ │ │ ├── UsbMouse.c