summaryrefslogtreecommitdiff
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
parenteefe273ce6395f3f6872a63f0a0f242b5065a17e (diff)
downloadrockbox-d538db0259e7297f6bf3ab96f9e1884d793abb05.tar.gz
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
-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 @@
40 40
41static struct usb_endpoint endpoints[USB_NUM_EPS][2]; 41static struct usb_endpoint endpoints[USB_NUM_EPS][2];
42static int got_set_configuration = 0; 42static int got_set_configuration = 0;
43static int usb_enum_timeout = -1;
43 44
44/* 45/*
45 * dma/setup descriptors and buffers should avoid sharing 46 * dma/setup descriptors and buffers should avoid sharing
@@ -298,6 +299,8 @@ void usb_drv_init(void)
298 | USB_GPIO_CLK_SEL10; /* 0x06180000; */ 299 | USB_GPIO_CLK_SEL10; /* 0x06180000; */
299 300
300 tick_add_task(usb_tick); 301 tick_add_task(usb_tick);
302
303 usb_enum_timeout = HZ; /* one second timeout for enumeration */
301} 304}
302 305
303void usb_drv_exit(void) 306void usb_drv_exit(void)
@@ -677,6 +680,14 @@ static void usb_tick(void)
677 struct usb_endpoint *eps = &endpoints[0][0]; 680 struct usb_endpoint *eps = &endpoints[0][0];
678 int i; 681 int i;
679 682
683 if (usb_enum_timeout != -1) {
684 /*
685 * If the enum times out it's a charger, drop out of usb mode.
686 */
687 if (usb_enum_timeout-- <= 0)
688 usb_remove_int();
689 }
690
680 for (i=0; i<2*USB_NUM_EPS; i++) { 691 for (i=0; i<2*USB_NUM_EPS; i++) {
681 if (!(eps[i].state & EP_STATE_BUSY) || 692 if (!(eps[i].state & EP_STATE_BUSY) ||
682 !TIME_AFTER(current_tick, endpoints[i])) 693 !TIME_AFTER(current_tick, endpoints[i]))
@@ -787,6 +798,7 @@ void INT_USB(void)
787 } 798 }
788 if (intr & USB_DEV_INTR_ENUM_DONE) {/* speed enumeration complete */ 799 if (intr & USB_DEV_INTR_ENUM_DONE) {/* speed enumeration complete */
789 int spd = USB_DEV_STS & USB_DEV_STS_MASK_SPD; /* Enumerated Speed */ 800 int spd = USB_DEV_STS & USB_DEV_STS_MASK_SPD; /* Enumerated Speed */
801 usb_enum_timeout = -1;
790 802
791 logf("speed enum complete: "); 803 logf("speed enum complete: ");
792 if (spd == USB_DEV_STS_SPD_HS) logf("hs\n"); 804 if (spd == USB_DEV_STS_SPD_HS) logf("hs\n");