4.2.3. Porting USB

The USB controller integrated in AM64x is a dual-role controller, which 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.3.1. USB Kernel Config Options

The USB framework in Linux kernel has multiple layers of drivers, as shown in the figure 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 to enable, disable or select the drivers.

For AM64x the following kernel config options are essential to enable the USB function. The options can be enabled in kernel menuconfig which is detailed in Build Kernel.

Device Drivers  --->
  [*] USB support  --->
    <M>   Support for Host-side USB
    [*]   USB announce new devices
    <M>   xHCI HCD (USB 3.0) support
    <M>   Cadence USB3 Dual-Role Controller
    [*]     Cadence USB3 device controller
    [*]     Cadence USB3 host controller
    <M>     Cadence USB3 support on TI platforms
    <M>   USB Gadget Support  --->
    {M}   USB Role Switch Support

Device Drivers  --->
    PHY Subsystem  --->
    <*> Cadence Torrent PHY driver
    <*> TI J721E WIZ (SERDES Wrapper) support

The config options listed above does 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.3.2. USB DT Bindings

There are several DT nodes which might need adjustment for custom boards depending on the designed USB use cases.

  • usbss
  • usb
  • serdes_ln_ctrl
  • serdes

usbss

usbss node defines the USB subsystem. It has a couple adjustable DT properties, ti,usb2-only and ti,vbus-divider. Please refer to the following kernel documentation for details of the usage:

usb

DT property dr_mode in usb node defines the work mode of the USB module. It 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, so the USB_ID pin status is controlled by the inserted USB cable.

serdes_ln_ctrl

The Serdes PHY on AM64x is shared between the USB module and the PCIe module. The muxing is controlled by idle-states property in serdes_ln_ctrl node.

When the custom board designs the USB module to support super-speed, idle-states property should be defined as following to route the Serdes PHY to the USB module. This is the default setting in AM64x Starter Kit.

&serdes_ln_ctrl {
        idle-states = <AM64_SERDES0_LANE0_USB>;
};

Otherwise if the custom board uses PCIe module, idle-states property should be defined as following to route the Serdes PHY to the PCIe module. This is the default setting in AM64x GPEVM.

&serdes_ln_ctrl {
        idle-states = <AM64_SERDES0_LANE0_PCIE0>;
};

serdes

The adjustable DT property in serdes node is cdns,phy-type. When the Serdes PHY is routed to the USB module, it should be defined as

cdns,phy-type = <PHY_TYPE_USB3>;

While if the Serdes PHY is routed to the PCIe module, it should be defined as

cdns,phy-type = <PHY_TYPE_PCIE>;