4.2.3. Porting USB

The USB controller integrated in AM64x 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.3.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 AM64x, 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>   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 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.3.2. USB DT Bindings

There are several DT nodes which may need adjustment for custom boards depending on the USB use cases:

  • usbss

  • usb

  • serdes_ln_ctrl

  • serdes

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.

serdes_ln_ctrl

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

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

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

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

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

serdes

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

cdns,phy-type = <PHY_TYPE_USB3>;

On the other hand, if the Serdes PHY is routed to the PCIe module, then cdns,phy-type should be defined as

cdns,phy-type = <PHY_TYPE_PCIE>;