4.2.5. Porting USB¶
The USB controller integrated in AM62x is a dual-role controller. The USB controller can work in three different modes, depending on kernel devicetree configuration and board design:
host-only mode
device-only mode
dual-role mode
This section explains the kernel and devicetree configurations to use the three different USB modes.
4.2.5.1. USB Kernel Config Options¶
The USB framework in the Linux kernel has multiple layers of drivers, as shown below:
USB Host Applications USB Gadget Applications
===================== ===========================
USB Class Drivers USB Gadget Function Drivers
(MSC, HID, Network...) (g_msc, g_hid, g_ether...)
---------------------- ---------------------------
USB Host Drivers USB Gadget Drivers
-----------------------------------------------------------
USB Core Drivers
-----------------------------------------------------------
USB Controller Drivers
-----------------------------------------------------------
USB Controller & PHY Platform Drivers
-----------------------------------------------------------
Each driver layer has one or more associated kernel config options. The kernel config options are used to enable, disable or select the drivers.
For AM62x, the following kernel config options are essential to enable USB functionality. The options can be enabled in the kernel menuconfig:
Device Drivers --->
[*] USB support --->
<M> Support for Host-side USB
[*] USB announce new devices
<M> xHCI HCD (USB 3.0) support
<M> DesignWare USB3 DRD Core Support
DWC3 Mode Selection (Dual Role mode) --->
*** Platform Glue Driver Support ***
<M> Texas Instruments AM62 Platforms
The config options listed above do not control the USB host class drivers and USB gadget functions drivers.
The options for USB host class drivers are listed under
Device Drivers --->
[*] USB support --->
and the USB gadget function drivers are listed under
Device Drivers --->
[*] USB support --->
<M> USB Gadget Support --->
4.2.5.2. USB DT Bindings¶
There are several DT nodes which may need adjustment for custom boards depending on the USB use cases:
usbss
usb
usbss
The usbss node defines the USB subsystem. It has several adjustable DT properties, ti,usb2-only and ti,vbus-divider. Please refer to the following kernel documentation for usage details:
usb
The DT property dr_mode in the usb node defines the work mode of the USB module. dr_mode can be assigned to one of the following string values:
dr_mode |
Notes |
---|---|
“host” |
Specifies the USB module to work in host-only mode. |
“peripheral” |
Specifies the USB module to work in device-only mode (also called peripheral-only or gadget-only mode). |
“otg” |
Specifies the USB module to work in dual-role mode, in which the mode is determined by the USB_ID pin status. The USB module works in host mode when USB_ID pin is grounded, or in device mode when USB_ID pin is float. When dr_mode = “otg”, the USB_ID pin should be routed to the ID pin of the USB receptacle. That allows the inserted USB cable to control the status of the USB_ID pin. |