| 21 | | |
| 22 | | Additionally, to accomplish this switching back and forth during run time, please use the script below: |
| 23 | | {{{#!bash |
| 24 | | #!/bin/sh |
| 25 | | # |
| 26 | | # GW52xx: |
| 27 | | # Dynamically switch USB OTG from front-panel (fp) and PCIe socket (pci) |
| 28 | | # at run-time and trigger re-enumeration |
| 29 | | # |
| 30 | | # usage: gw52xx-usbswitch fp|pci |
| 31 | | # |
| 32 | | [ -d /sys/class/gpio/gpio2 ] || { |
| 33 | | echo "setup" |
| 34 | | devmem 0x20e0224 32 0x15 # hack to set SION bit in case we want read-back |
| 35 | | echo 2 > /sys/class/gpio/export |
| 36 | | echo out > /sys/class/gpio/gpio2/direction |
| 37 | | } |
| 38 | | case "$1" in |
| 39 | | fp) echo 0 > /sys/class/gpio/gpio2/value;; |
| 40 | | pci) echo 1 > /sys/class/gpio/gpio2/value;; |
| 41 | | esac |
| 42 | | # set GPIO_2 pad-mux to GPIO1__IO2 to effectively let OTG_ID go interally go |
| 43 | | # high and trigger a mode-switch to client-mode and thus disconnect |
| 44 | | devmem 0x20e0210 32 0x5 |
| 45 | | # set GPIO_2 pad-mux back to USBOTG_IDSEL to let OTG_ID get pulled down by |
| 46 | | # attached cable and trigger a mode-switch to host-mode and thus enumerate |
| 47 | | devmem 0x20e0210 32 0x3 |
| 48 | | }}} |