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
│ │ │ ├── UsbMouse.h
│ │ │ ├── UsbMouse_DriftControl.c
│ │ │ └── UsbMouse_DriftControl.h
│ │ └── misc_lib.c
│ ├── Include
│ │ ├── Hid.h
│ │ ├── HidFunDrv.h
│ │ ├── HidSpec.h
│ │ ├── Hid_i.h
│ │ └── misc_lib.h
│ └── Makefile
├── host # Host 驱动
│ ├── Makefile
│ ├── ehci-hcd.c
│ ├── ehci-hub.c
│ ├── ehci-mem.c
│ ├── ehci-q.c
│ ├── ehci-sched.c
│ ├── ehci-sunxi.c
│ ├── ehci-timer.c
│ ├── ehci.h
│ ├── hci_hal.c
│ ├── ohci-hcd.c
│ ├── ohci-hub.c
│ ├── ohci-mem.c
│ ├── ohci-q.c
│ ├── ohci-sunxi.c
│ ├── ohci.h
│ ├── sunxi-hci.c
│ └── sunxi-hci.h
├── include
│ ├── audio.h
│ ├── bitops.h
│ ├── ch11.h
│ ├── ch9.h
│ ├── ehci_def.h
│ ├── endian.h
│ ├── error.h
│ ├── hcd.h
│ ├── mod_devicetable.h
│ ├── mod_usbhost.h
│ ├── storage.h
│ ├── usb.h
│ ├── usb_list.h
│ ├── usb_melis.h
│ ├── usb_os_platform.h
│ └── usb_rtos.h
├── manager # usb 管理类
│ ├── Makefile
│ ├── sunxi_usb_board.h
│ ├── usb_hw_scan.c
│ ├── usb_hw_scan.h
│ ├── usb_manager.c
│ ├── usb_manager_common.h
│ ├── usb_msg_center.c
│ └── usb_msg_center.h
├── platform # 芯片平台寄存器定义
│ ├── sun20iw2
│ │ ├── Makefile
│ │ ├── usb_sun20iw2.c
│ │ └── usb_sun20iw2.h
. . .
. . .
. . .
├── storage # 存储器相关实现
│ ├── Class
│ │ ├── Makefile
│ │ ├── mscProtocol.c
│ │ ├── mscProtocol.h
│ │ ├── mscTransport.c
│ │ ├── mscTransport.h
│ │ ├── mscTransport_i.c
│ │ ├── msc_common.h
│ │ └── usb_msc.c
│ ├── Disk
│ │ ├── BlkDev.c
│ │ ├── BlkDev.h
│ │ ├── CD.c
│ │ ├── CD.h
│ │ ├── Disk.c
│ │ ├── LunMgr.c
│ │ ├── LunMgr_i.h
│ │ ├── Makefile
│ │ └── Scsi2.c
│ ├── Kconfig
│ ├── Makefile
│ ├── Misc
│ │ ├── Makefile
│ │ ├── usbh_buff_manager.c
│ │ ├── usbh_disk_info.c
│ │ └── usbh_disk_remove_time.c
│ └── include
│ ├── LunMgr.h
│ ├── Scsi2.h
│ ├── usb_msc.h
│ ├── usb_msc_i.h
│ ├── usbh_buff_manager.h
│ ├── usbh_disk_info.h
│ └── usbh_disk_remove_time.h
├── udc # UDC 实现
│ ├── Makefile
│ ├── udc.c
│ ├── udc.h
│ ├── udc_hal.c
│ ├── udc_platform.h
│ ├── usb_dma.c
│ └── usb_dma.h
└── uvc # UVC 实现
├── Class
│ ├── Makefile
│ ├── uvc.c
│ ├── uvc_driver.c
│ ├── uvc_driver.h
│ ├── uvc_v4l2.c
│ ├── uvc_video.c
│ └── uvc_video.h
├── Include
│ ├── UVC.h
│ ├── assessibility.h
│ ├── uvcvideo.h
│ ├── video.h
│ └── videodev2.h
├── Makefile
├── Misc
│ ├── Makefile
│ └── assessibility.c
├── Webcam
│ ├── Makefile
│ ├── usbWebcam.c
│ ├── usbWebcam.h
│ ├── usbWebcam_proc.c
│ └── usbWebcam_proc.h
└── drv_webcam
├── Makefile
├── dev_cfg
│ ├── webcam_dev.c
│ └── webcam_dev_i.h
├── drv_webcam.c
├── drv_webcam.h
├── drv_webcam_i.h
├── fb.h
└── webcam_core
├── dev_webcam.c
├── dev_webcam_i.h
├── webcam_linklist_manager.c
└── webcam_linklist_manager.h