summaryrefslogtreecommitdiffstats
path: root/firmware
diff options
context:
space:
mode:
authorTobias Diedrich <ranma+coreboot@tdiedrich.de>2010-06-27 03:04:44 +0000
committerTobias Diedrich <ranma+coreboot@tdiedrich.de>2010-06-27 03:04:44 +0000
commitd538db0259e7297f6bf3ab96f9e1884d793abb05 (patch)
tree15b80072becf5de17dfd12fe1e1999843724787d /firmware
parenteefe273ce6395f3f6872a63f0a0f242b5065a17e (diff)
downloadrockbox-d538db0259e7297f6bf3ab96f9e1884d793abb05.tar.gz
rockbox-d538db0259e7297f6bf3ab96f9e1884d793abb05.tar.bz2
rockbox-d538db0259e7297f6bf3ab96f9e1884d793abb05.zip
Add one second timeout for USB enumeration, so we don't get stuck in USB mode if it's just a charger.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27149 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware')
-rw-r--r--firmware/target/arm/as3525/usb-drv-as3525.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/firmware/target/arm/as3525/usb-drv-as3525.c b/firmware/target/arm/as3525/usb-drv-as3525.c
index 09a680476d..4036db6010 100644
--- a/firmware/target/arm/as3525/usb-drv-as3525.c
+++ b/firmware/target/arm/as3525/usb-drv-as3525.c
@@ -40,6 +40,7 @@
static struct usb_endpoint endpoints[USB_NUM_EPS][2];
static int got_set_configuration = 0;
+static int usb_enum_timeout = -1;
/*
* dma/setup descriptors and buffers should avoid sharing
@@ -298,6 +299,8 @@ void usb_drv_init(void)
| USB_GPIO_CLK_SEL10; /* 0x06180000; */
tick_add_task(usb_tick);
+
+ usb_enum_timeout = HZ; /* one second timeout for enumeration */
}
void usb_drv_exit(void)
@@ -677,6 +680,14 @@ static void usb_tick(void)
struct usb_endpoint *eps = &endpoints[0][0];
int i;
+ if (usb_enum_timeout != -1) {
+ /*
+ * If the enum times out it's a charger, drop out of usb mode.
+ */
+ if (usb_enum_timeout-- <= 0)
+ usb_remove_int();
+ }
+
for (i=0; i<2*USB_NUM_EPS; i++) {
if (!(eps[i].state & EP_STATE_BUSY) ||
!TIME_AFTER(current_tick, endpoints[i]))
@@ -787,6 +798,7 @@ void INT_USB(void)
}
if (intr & USB_DEV_INTR_ENUM_DONE) {/* speed enumeration complete */
int spd = USB_DEV_STS & USB_DEV_STS_MASK_SPD; /* Enumerated Speed */
+ usb_enum_timeout = -1;
logf("speed enum complete: ");
if (spd == USB_DEV_STS_SPD_HS) logf("hs\n");