| 1 | {{{#!html |
| 2 | <div id="wikipage" class="trac-content"><h1 id="GW52xxUSBSteering"><b style="color:#000;background:#66ffff">GW52xx USB Steering</b></h1> |
| 3 | <p> |
| 4 | 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. |
| 5 | </p> |
| 6 | <h2 id="Option1-Bootloader-Recommended">Option 1 - Bootloader - Recommended</h2> |
| 7 | <ul><li><strong>Recommended</strong>- This can be done with settings in the bootloader as shown here: <a class="wiki" href="/wiki/ventana/bootloader#USBFront-panelvsPCIesocketrouting">GW52xx Bootloader Configuration</a> |
| 8 | </li></ul><h2 id="Option2-CommandLine">Option 2 - Command Line</h2> |
| 9 | <p> |
| 10 | 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. |
| 11 | </p> |
| 12 | <p> |
| 13 | 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: |
| 14 | </p> |
| 15 | <pre class="wiki">echo 2 > /sys/class/gpio/export |
| 16 | echo out > /sys/class/gpio/gpio2/direction |
| 17 | echo 1 > /sys/class/gpio/gpio2/value |
| 18 | </pre><p> |
| 19 | Additionally, to accomplish this switching back and forth <strong>during run time</strong>, please use the script below: |
| 20 | </p> |
| 21 | <pre class="wiki">#!/bin/sh |
| 22 | # |
| 23 | # GW52xx: |
| 24 | # Dynamically switch USB OTG from front-panel (fp) and PCIe socket (pci) |
| 25 | # at run-time and trigger re-enumeration |
| 26 | # |
| 27 | # usage: gw52xx-usbswitch fp|pci |
| 28 | # |
| 29 | [ -d /sys/class/gpio/gpio2 ] || { |
| 30 | echo "setup" |
| 31 | devmem 0x20e0224 32 0x15 # hack to set SION bit in case we want read-back |
| 32 | echo 2 > /sys/class/gpio/export |
| 33 | echo out > /sys/class/gpio/gpio2/direction |
| 34 | } |
| 35 | case "$1" in |
| 36 | fp) echo 0 > /sys/class/gpio/gpio2/value;; |
| 37 | pci) echo 1 > /sys/class/gpio/gpio2/value;; |
| 38 | esac |
| 39 | # set GPIO_2 pad-mux to GPIO1__IO2 to effectively let OTG_ID go interally go |
| 40 | # high and trigger a mode-switch to client-mode and thus disconnect |
| 41 | devmem 0x20e0210 32 0x5 |
| 42 | # set GPIO_2 pad-mux back to USBOTG_IDSEL to let OTG_ID get pulled down by |
| 43 | # attached cable and trigger a mode-switch to host-mode and thus enumerate |
| 44 | devmem 0x20e0210 32 0x3 |
| 45 | </pre |
| 46 | }}} |