wiki:ventana/gw5200usb

Version 3 (modified by Ron Eisworth, 6 years ago) ( diff )

--

GW52xx USB Steering

The GW52xx has the ability to route the OTG USB between a Mini-PCIe slot J8 and the front panel micro connector. This can be controlled through software.

This can be done with settings in the bootloader as shown here:

http://trac.gateworks.com/wiki/ventana/bootloader#USBFront-panelvsPCIesocketrouting

Option 2 - Command Line

The steering is controlled via GPIO2. This can be controlled in Linux at the command line once the board is booted and access to the serial console is acquired.

Setting the GPIO high will route to the Mini-PCIe slot and setting the GPIO low (0) will route it to the front panel connector:

echo 2 > /sys/class/gpio/export
echo out > /sys/class/gpio/gpio2/direction
echo 1 > /sys/class/gpio/gpio2/value

Additionally, to accomplish this switching back and forth during run time, please use the script below:

#!/bin/sh
#
# GW52xx:
#  Dynamically switch USB OTG from front-panel (fp) and PCIe socket (pci)
#  at run-time and trigger re-enumeration
#
# usage: gw52xx-usbswitch fp|pci
#
[ -d /sys/class/gpio/gpio2 ] || {
  echo "setup"
  devmem 0x20e0224 32 0x15 # hack to set SION bit in case we want read-back
  echo 2 > /sys/class/gpio/export
  echo out > /sys/class/gpio/gpio2/direction
}
case "$1" in
  fp)  echo 0 > /sys/class/gpio/gpio2/value;;
  pci) echo 1 > /sys/class/gpio/gpio2/value;;
esac
# set GPIO_2 pad-mux to GPIO1__IO2 to effectively let OTG_ID go interally go
# high and trigger a mode-switch to client-mode and thus disconnect
devmem 0x20e0210 32 0x5
# set GPIO_2 pad-mux back to USBOTG_IDSEL to let OTG_ID get pulled down by
# attached cable and trigger a mode-switch to host-mode and thus enumerate
devmem 0x20e0210 32 0x3
Note: See TracWiki for help on using the wiki.