Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Turn USB power off/on with BeagleBone Black kernel >= 3.8

I need to:

  • turn off -> sleep some seconds -> turn on the USB power of beaglebone black

to be able to hardware-reset a device that is connected to USB (Huawei E220 Modem)

Already tried soft-reset (with unbind/bind and with authorize 0/1), but software reset is not enough to make the device to work well again; the device has some weird bug, that is triggered by a long-time usage (after a few days connected).

Many answers were found using /sys/debug/omap_mux, but this device does not exist anymore in new kernels.

Since this question took a pair of days to get a workable answer, I decided to post it here, with the answer, so it may be useful for others.

like image 292
pzn Avatar asked Jun 04 '14 13:06

pzn


1 Answers

Thanks to my friend Cleiton Bueno http://cleitonbueno.wordpress.com/ that found this solution for me:

prerequisites:

  • apt-get install devmem2

Code that solved the problem:

devmem2 0x47401c60 b 0x00
sleep 1
echo "usb1" > /sys/bus/usb/drivers/usb/unbind
sleep 20
echo "usb1" > /sys/bus/usb/drivers/usb/bind
sleep 1
devmem2 0x47401c60 b 0x01

The "devmem2" command is responsible to direct access GPIO3_13 of the beaglebone, that controls the IC that powers on/off the USB port.

The "unbind/bind" commands are responsible to tell the usb driver to "rescan" the port after the power.

like image 177
pzn Avatar answered Oct 03 '22 21:10

pzn