[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 @@
+#!/bin/sh
+# if not in software-controlled charging mode, Vbus (and only that)
+# has to be applied before running the script
+#MUSB_MODE=/sys/bus/platform/devices/musb-hdrc/mode
+#MUSB_MODE=/sys/bus/platform/devices/musb-hdrc.0/mode
+MUSB_MODE=/sys/bus/platform/devices/musb-hdrc.1.auto/mode
+
+MUSB_M=`cat $MUSB_MODE`
+echo "$MUSB_M"
+if [ "$MUSB_M" != b_idle ] ; then
+	echo Invalid mode at start
+        exit
+fi
+# 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
+cat $MUSB_MODE
+# trigger a transition from b_peripheral to b_hnp_enable
+echo host >$MUSB_MODE
+cat $MUSB_MODE
+sleep 0.2
+# simulate a disconnection from host
+echo off > /sys/bus/platform/devices/twl4030_usb/fake_host
+sleep 0.2
+cat $MUSB_MODE
+# 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
+MUSB_M=`cat $MUSB_MODE`
+echo "$MUSB_M"
+
+if [ "$MUSB_M" = b_wait_acon ] ; then
+	echo "Prepared for being usb host, time to attach your device"
+fi
-- 
1.7.10.4



More information about the Gta04-owner mailing list