From: Dan White Date: Mon, 29 Oct 2012 19:09:16 +0000 (-0500) Subject: Ensure or warn about kernel USB autosuspend X-Git-Tag: bootrom-initial-submission~52 X-Git-Url: http://git.whiteaudio.com/gitweb/?a=commitdiff_plain;h=8240b1f5274bd8e8835d20630a89b2323bd1eb1e;p=430.git Ensure or warn about kernel USB autosuspend --- diff --git a/python-lib/devboard.py b/python-lib/devboard.py index 0d99217..356aa11 100644 --- a/python-lib/devboard.py +++ b/python-lib/devboard.py @@ -1,6 +1,8 @@ #!/usr/bin/env python from datetime import datetime as dt +import glob +import os from time import sleep import yaml @@ -187,17 +189,16 @@ arb = None amux = None -def close_usb(): +def close_usb(delay=0): """ Close the three MPSSE ports from the usb side. If the serial port is also closed, the kernel will suspend the device. This makes the SUSPEND pin go low on the usbio board and allows a circuit to cut power to the devboard. """ - print 'closing usb ports' + print 'closing usb ports, waiting for kernel to suspend port' for c in (spi0.context, spi1.context, i2c.context): usbio.ftdi.usb_close(c) - print 'sleeping...' - sleep(5) + sleep(delay) def init_devboard(name='devboard-defaults.yaml'): @@ -214,9 +215,28 @@ def init_devboard(name='devboard-defaults.yaml'): global chain, mux global arb, amux + + USB_SUSPEND_DELAY = 0 + + # check for appropriate usb autosuspend settings + for p in glob.glob('/sys/bus/usb/devices/*'): + m = '%s/manufacturer' % p + c = '%s/power/control' % p + a = '%s/power/autosuspend_delay_ms' % p + if os.path.exists(m) and ('White Audio' in open(m).readline()): + control = open(c).readline().strip() + autosuspend = open(a).readline().strip() + ms = int(autosuspend) + if 'auto' not in control: + print "WARNING: autosuspend is not 'auto', currently: %s" % control + print "******* therefore unable to power-cycle devboard." + print 'INFO: kernel autosuspend is %i ms' % ms + USB_SUSPEND_DELAY = 1.2 * (ms + 1) / 1e3 + #blank the slate if is_initialized: - close_usb() + close_usb(USB_SUSPEND_DELAY) + _config = {} spi0 = None spi1 = None diff --git a/python-lib/test-nco.py b/python-lib/test-nco.py index d1f3f28..c386f8b 100644 --- a/python-lib/test-nco.py +++ b/python-lib/test-nco.py @@ -5,15 +5,8 @@ from time import sleep import devboard as dev dev.init_devboard(1) +# requires devboard be already initialized from calibrate import calibrate - - -sleep(5) -dev.init_devboard(1) - - - -