Search by Tags

USB On-The-Go

 

Compare with Revision




Subscribe for this article updates

All Colibri modules have one port which can work either in USB host or in USB function mode (also known as Client mode). This is not a full support of all USB On-The-Go (OTG) features, but it is possible to switch between host and function mode at runtime, without reboot.

Colibri PXA Modules

The Colibri PXA modules automatically select between host and function mode, depending on the USB cable detect pin. For details, refer to the following article:

USB client driver registry settings

Colibri Tegra Modules

Switch manually (before image V1.2)

Revisions before 1.2 did not support the automatic switch between host and function mode. The port is working in function mode by default. To activate the host mode, add the following registry settings:

[HKLM\Drivers\BuiltIn\USBEHCI1]
Dll="libnvusbh.dll"                         ;activate USBEHCI1 driver
[HKLM\Drivers\BuiltIn\USBFN]
Dll="_libnvusbfn.dll"                       ;deactivate USBFN driver

Don't forget to save the registry before rebooting the module.

Enable Automatic Switching between USB Host and USB Function

Automatic switching between USB host and function is supported in image V1.2 and later.

To enable the automatic switching, disable USBFN and USBEHCI1, enable USBOTG instead. This can be achieved by a few registry settings:

[HKLM\Drivers\BuiltIn\USBEHCI1]
Dll="_libnvusbh.dll"                       ;deactivate USBEHCI1 driver
[HKLM\Drivers\BuiltIn\USBFN]
Dll="_libnvusbfn.dll"                      ;deactivate USBFN driver
[HKLM\Drivers\BuiltIn\USBOTG]
Dll="libnvusbotg.dll"                      ;activate USBOTG driver

Depending on the hardware layout some additional settings are needed in order to make the OTG switch working stable:

[HKLM\Drivers\BuiltIn\USBOTG]
DebounceDelay=dword:50                   ;Delay to OTG driver waits for settling the CableDetectPin
                                         ;before switching between Host <-> Client in ms. Default: 50ms 
USBFNUnloadDelay=dword:10                ;Delay before unloading USBFn after level change is detected 
                                         ;on CableDetectPin in ms. Default: 10ms

Don't forget to save the registry before rebooting the module.

Colibri and Apalis IMX6 modules

It is possible to force the usb on-the-go port to behave only as host or as client by changing some registry entries.

First of all, USB on-the-go must be disabled:

[HKEY_LOCAL_MACHINE\Drivers\BuiltIn\UsbOtg]
“Dll” = “_fsl_usbotg.dll”

To enable host add those entries:

[HKEY_LOCAL_MACHINE\Drivers\BuiltIn\HCD_HSH2]
"Prefix"="HCD" 
"Dll"="hcd_hsotg.dll" 
"Order"=dword:15
"Class"=dword:0c
"SubClass"=dword:03
"ProgIF"=dword:20
"InterfaceType"=dword:0
"MemBase"=dword:2184000
"MemLen"=dword:1000
"irq"=dword:4B
"IsrDll"="giisr.dll" 
"IsrHandler"="ISRHandler" 
"OTGSupport"=dword:0
"OTGGroup"="01"

To enable client:

[HKEY_LOCAL_MACHINE\Drivers\BuiltIn\UFN]
"Prefix"="UFN"
"Dll"="usbfn.dll"
"Index"=dword:1
"Order"=dword:22
"MemBase"=dword:02184000
"MemLen"=dword:00001000
"Irq"=dword:4b
"Priority256"=dword:64
"OTGSupport" = dword:0
"OTGGroup"="01"
"BusIoctl"=dword:2a0048
"IClass"= multi_sz:"{E2BDC372-598F-4619-BC50-54B3F7848D35}=%b","{6F40791D-300E-44E4-BC38-E0E63CA8375C}=%b"

There are basically two hardware configurations for the USB OTG, which should be handled differently.

In both configurations the 5V USB power is controlled by a Power Enable (PE) pin:

  1. Micro-USB connector with ID pin When idle, the 5V must be off! Otherwise we generate a short circuit as soon as we connect a PC to the Micro-USB. This means that while idle either the client driver is active, or no driver at all. Only when the ID pin is shorted to GND, we switch to the host driver and turn 5V on.
  2. Separate USB Host(A) / USB Client(B) Connector When idle, the 5V must be on! Otherwise we cannot detect when someone connects a USB device This means that while idle the host driver is active Only when the 5V-input of the USB Client connector is detected, we switch to the client driver. Both hardware configurations are implemented on the Colibri Evaluation Board.

There is a registry setting to switch between the behaviors:

[HKEY_LOCAL_MACHINE\Drivers\BuiltIn\USBOTG] 
"CableDetectPol"=dword:0x00000001 ;default 1 

On the Module we only have one pin to detect the host/client status. Default is, that we detect the 5V connected to a USB client(B) connector (CableDetectPol=1). The alternative configuration is to detect an ID pin pulled to GND (CableDetectPol=0)