[Gta04-owner] [PATCH] usb: various hacks related to otg

Andreas Kemnade andreas at kemnade.info
Fri Nov 1 16:11:58 CET 2013

    - start switch to b_host role via sysfs
    - control vbus output power
       - can be used to start charging when a charger with ID
         grounded is first connected to the device and then to the
         wall outlet
    - enable/disable pulldown resistors via sysfs,
      can be used to emulate a connection to a usb host,
      useful for switching to b_host when using y-cables
    - script for entering b_host mode

Signed-off-by: Andreas Kemnade <andreas at kemnade.info>
 GTA04/scripts/b_host.sh |   35 +++++++++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)
 create mode 100755 GTA04/scripts/b_host.sh

diff --git a/GTA04/scripts/b_host.sh b/GTA04/scripts/b_host.sh
new file mode 100755
index 0000000..16e04c1
--- /dev/null
+++ b/GTA04/scripts/b_host.sh
@@ -0,0 +1,35 @@
+# if not in software-controlled charging mode, Vbus (and only that)
+# has to be applied before running the script
+echo "$MUSB_M"
+if [ "$MUSB_M" != b_idle ] ; then
+	echo Invalid mode at start
+        exit
+# trigger a transition from b_idle to b_peripheral by simulating
+# a connection to a host (enable pull-down resistors)
+echo on > /sys/bus/platform/devices/twl4030_usb/fake_host
+sleep 0.2
+# trigger a transition from b_peripheral to b_hnp_enable
+echo host >$MUSB_MODE
+sleep 0.2
+# simulate a disconnection from host
+echo off > /sys/bus/platform/devices/twl4030_usb/fake_host
+sleep 0.2
+# be a host by ourselfs (if we wouldn't mess with this bit,
+# it would be already set here)
+echo on > /sys/bus/platform/devices/twl4030_usb/fake_host
+echo "$MUSB_M"
+if [ "$MUSB_M" = b_wait_acon ] ; then
+	echo "Prepared for being usb host, time to attach your device"

More information about the Gta04-owner mailing list