From 8c52a7cf8e066d7ce202e38863c225a7d4d0bfeb Mon Sep 17 00:00:00 2001 From: Andreas Kemnade Date: Fri, 1 Nov 2013 16:29:06 +0100 Subject: usb: various hacks related to otg - 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 --- GTA04/README | 5 +++++ GTA04/scripts/b_host.sh | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100755 GTA04/scripts/b_host.sh (limited to 'GTA04') diff --git a/GTA04/README b/GTA04/README index dad8c0a..fcb638d 100644 --- a/GTA04/README +++ b/GTA04/README @@ -28,3 +28,8 @@ simple tasks + vibra.py shows how to program the vibrator as a rumble effect. + + b_host.sh helps to switch to b_host otg state (GTA04 is external + powered but plays the role of an usb host, the id pin is + not grounded in that situation). First apply power or switch on + software-controlled charging, run that script, then also connect + the usb data lines 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 -- cgit v1.1