diff options
author | Michael Sevakis <jethead71@rockbox.org> | 2011-01-17 12:24:41 +0000 |
---|---|---|
committer | Michael Sevakis <jethead71@rockbox.org> | 2011-01-17 12:24:41 +0000 |
commit | 05f6f3419aec991307e7c81e0738e0496a21d89b (patch) | |
tree | 4bad4a187bc2a2bdd714e086ac9910a9b3de6357 /firmware/usb.c | |
parent | bcc0f88372fd2be986a5e279dd7e3bd556d6c984 (diff) | |
download | rockbox-05f6f3419aec991307e7c81e0738e0496a21d89b.tar.gz rockbox-05f6f3419aec991307e7c81e0738e0496a21d89b.zip |
Add a higher level USB detection that prevents fraudulent bus resets from causing USB mode to be entered. Enable for SA9200 only at this time. Also, for SA9200, use the bus power GPIO rather than the 'connector inserted' GPIO to detect the cable.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29068 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/usb.c')
-rw-r--r-- | firmware/usb.c | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/firmware/usb.c b/firmware/usb.c index c8f0118730..ca0e86b478 100644 --- a/firmware/usb.c +++ b/firmware/usb.c | |||
@@ -136,7 +136,7 @@ static inline void usb_slave_mode(bool on) | |||
136 | } | 136 | } |
137 | else /* usb_state == USB_INSERTED (only!) */ | 137 | else /* usb_state == USB_INSERTED (only!) */ |
138 | { | 138 | { |
139 | #ifndef USB_DETECT_BY_DRV | 139 | #if !defined(USB_DETECT_BY_DRV) && !defined(USB_DETECT_BY_CORE) |
140 | usb_enable(false); | 140 | usb_enable(false); |
141 | #endif | 141 | #endif |
142 | #ifdef HAVE_PRIORITY_SCHEDULING | 142 | #ifdef HAVE_PRIORITY_SCHEDULING |
@@ -244,7 +244,7 @@ static void usb_thread(void) | |||
244 | (struct usb_transfer_completion_event_data*)ev.data); | 244 | (struct usb_transfer_completion_event_data*)ev.data); |
245 | break; | 245 | break; |
246 | #endif | 246 | #endif |
247 | #ifdef USB_DETECT_BY_DRV | 247 | #if defined(USB_DETECT_BY_DRV) || defined(USB_DETECT_BY_CORE) |
248 | /* In this case, these events the handle cable insertion USB | 248 | /* In this case, these events the handle cable insertion USB |
249 | * driver determines INSERTED/EXTRACTED state. */ | 249 | * driver determines INSERTED/EXTRACTED state. */ |
250 | case USB_POWERED: | 250 | case USB_POWERED: |
@@ -263,7 +263,7 @@ static void usb_thread(void) | |||
263 | * available. */ | 263 | * available. */ |
264 | queue_post(&usb_queue, USB_EXTRACTED, 0); | 264 | queue_post(&usb_queue, USB_EXTRACTED, 0); |
265 | break; | 265 | break; |
266 | #endif /* USB_DETECT_BY_DRV */ | 266 | #endif /* USB_DETECT_BY_DRV || USB_DETECT_BY_CORE */ |
267 | case USB_INSERTED: | 267 | case USB_INSERTED: |
268 | #ifdef HAVE_LCD_BITMAP | 268 | #ifdef HAVE_LCD_BITMAP |
269 | if(do_screendump_instead_of_usb) | 269 | if(do_screendump_instead_of_usb) |
@@ -379,7 +379,8 @@ static void usb_thread(void) | |||
379 | #ifdef HAVE_USBSTACK | 379 | #ifdef HAVE_USBSTACK |
380 | if(!exclusive_storage_access) | 380 | if(!exclusive_storage_access) |
381 | { | 381 | { |
382 | #ifndef USB_DETECT_BY_DRV /* Disabled handling USB_UNPOWERED */ | 382 | #if !defined(USB_DETECT_BY_DRV) && !defined(USB_DETECT_BY_CORE) |
383 | /* Disabled handling USB_UNPOWERED */ | ||
383 | usb_enable(false); | 384 | usb_enable(false); |
384 | #endif | 385 | #endif |
385 | break; | 386 | break; |
@@ -457,7 +458,8 @@ void usb_status_event(int current_status) | |||
457 | { | 458 | { |
458 | /* Caller isn't expected to filter for changes in status. | 459 | /* Caller isn't expected to filter for changes in status. |
459 | * current_status: | 460 | * current_status: |
460 | * USB_DETECT_BY_DRV: USB_POWERED, USB_UNPOWERED, USB_INSERTED (driver) | 461 | * USB_DETECT_BY_DRV/CORE: USB_POWERED, USB_UNPOWERED, |
462 | USB_INSERTED (driver/core) | ||
461 | * else: USB_INSERTED, USB_EXTRACTED | 463 | * else: USB_INSERTED, USB_EXTRACTED |
462 | */ | 464 | */ |
463 | if(usb_monitor_enabled) | 465 | if(usb_monitor_enabled) |
@@ -481,7 +483,10 @@ void usb_start_monitoring(void) | |||
481 | 483 | ||
482 | usb_monitor_enabled = true; | 484 | usb_monitor_enabled = true; |
483 | 485 | ||
484 | #ifdef USB_DETECT_BY_DRV | 486 | #ifdef USB_STATUS_BY_EVENT |
487 | /* Filter the status - an event may have been missed because it was | ||
488 | * sent before monitoring was enabled due to the connector already | ||
489 | * having been inserted before before or during boot. */ | ||
485 | status = (status == USB_INSERTED) ? USB_POWERED : USB_UNPOWERED; | 490 | status = (status == USB_INSERTED) ? USB_POWERED : USB_UNPOWERED; |
486 | #endif | 491 | #endif |
487 | usb_status_event(status); | 492 | usb_status_event(status); |
@@ -577,7 +582,7 @@ void usb_init(void) | |||
577 | { | 582 | { |
578 | /* We assume that the USB cable is extracted */ | 583 | /* We assume that the USB cable is extracted */ |
579 | usb_state = USB_EXTRACTED; | 584 | usb_state = USB_EXTRACTED; |
580 | #ifdef USB_DETECT_BY_DRV | 585 | #if defined(USB_DETECT_BY_DRV) || defined(USB_DETECT_BY_CORE) |
581 | last_usb_status = USB_UNPOWERED; | 586 | last_usb_status = USB_UNPOWERED; |
582 | #else | 587 | #else |
583 | last_usb_status = USB_EXTRACTED; | 588 | last_usb_status = USB_EXTRACTED; |