From d538db0259e7297f6bf3ab96f9e1884d793abb05 Mon Sep 17 00:00:00 2001 From: Tobias Diedrich Date: Sun, 27 Jun 2010 03:04:44 +0000 Subject: 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 --- firmware/target/arm/as3525/usb-drv-as3525.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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"); -- cgit v1.2.3